non security modules update
This commit is contained in:
@@ -22,9 +22,8 @@ Also a dpr() function is provided, which pretty prints arrays and strings.
|
||||
Useful during development. Many other nice functions like dpm(), dvm().
|
||||
|
||||
AJAX developers in particular ought to install FirePHP Core from
|
||||
http://www.firephp.org/ and put it in the devel directory.
|
||||
This happens automatically when you enable via drush. You may also
|
||||
use a drush command to download the library. If downloading by hand,
|
||||
http://www.firephp.org/ and put it in the devel directory. You may
|
||||
use the devel-download drush command to download the library. If downloading by hand,
|
||||
your path to fb.php should look like devel/FirePHPCore/lib/FirePHPCore/fb.php.
|
||||
You can use svn checkout http://firephp.googlecode.com/svn/trunk/trunk/Libraries/FirePHPCore.
|
||||
Then you can log php variables to the Firebug console. Is quite useful.
|
||||
|
@@ -60,7 +60,7 @@ function devel_admin_settings() {
|
||||
$form['xhprof']['settings']['devel_xhprof_directory'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => 'xhprof directory',
|
||||
'#description' => t('Location of the xhprof source code on your system, usually somewhere in /usr/local/share or /usr/share, include the leading forward slash.'),
|
||||
'#description' => t('Location of the xhprof source code on your system, where the directory "xhprof_lib" can be found, usually somewhere in /usr/local/share or /usr/share, include the leading forward slash.'),
|
||||
'#default_value' => variable_get('devel_xhprof_directory', ''),
|
||||
'#states' => array(
|
||||
'invisible' => array(
|
||||
@@ -90,9 +90,9 @@ function devel_admin_settings() {
|
||||
'#description' => t('Display page execution time in the query log box.'),
|
||||
);
|
||||
|
||||
$form['dev_mem'] = array('#type' => 'checkbox',
|
||||
$form['devel_memory'] = array('#type' => 'checkbox',
|
||||
'#title' => t('Display memory usage'),
|
||||
'#default_value' => variable_get('dev_mem', 0),
|
||||
'#default_value' => variable_get('devel_memory', 0),
|
||||
'#description' => t('Display how much memory is used to generate the current page. This will show memory usage when devel_init() is called and when devel_exit() is called.'),
|
||||
);
|
||||
$form['devel_redirect_page'] = array('#type' => 'checkbox',
|
||||
|
@@ -12,21 +12,29 @@ function devel_drush_command() {
|
||||
$items['devel-download'] = array(
|
||||
'description' => dt('Downloads the FirePHP library from http://firephp.org/.'),
|
||||
'arguments' => array(
|
||||
'path' => dt('Optional. A path to the download folder. If omitted Drush will use the default location (sites/all/libraries/firephp).'),
|
||||
'path' => dt('Path to the download folder. This path is relative to the Drupal root. If omitted Drush will use the default location (sites/all/libraries/FirePHPCore).'),
|
||||
),
|
||||
);
|
||||
$items['devel-reinstall'] = array(
|
||||
'description' => dt('Disable, Uninstall, and Install a list of projects.'),
|
||||
'drush dependencies' => array('pm'),
|
||||
'arguments' => array(
|
||||
'projects' => dt('A space-separated list of project names.'),
|
||||
),
|
||||
'allow-additional-options' => array('pm-disable', 'pm-uninstall', 'pm-enable'),
|
||||
'required-arguments' => 1,
|
||||
'aliases' => array('dre'),
|
||||
);
|
||||
$items['fn-hook'] = array(
|
||||
'description' => 'List implementations of a given hook and explore source of specified one.',
|
||||
'description' => 'List implementations of a given hook and explore the source of the selected one.',
|
||||
'arguments' => array(
|
||||
'hook' => 'The name of the hook to explore.'
|
||||
'hook' => 'The name of the hook to explore (e.g. "menu" for hook_menu()).'
|
||||
),
|
||||
'examples' => array(
|
||||
'fn-hook cron' => 'List implementations of hook_cron().',
|
||||
),
|
||||
'allow-additional-options' => array('fn-view'),
|
||||
'required-arguments' => 1,
|
||||
'aliases' => array('fnh', 'hook'),
|
||||
);
|
||||
$items['fn-view'] = array(
|
||||
@@ -44,11 +52,13 @@ function devel_drush_command() {
|
||||
'fn-view NodeController::load' => 'View the source code for method load in the class NodeController'
|
||||
),
|
||||
'aliases' => array('fnv'),
|
||||
'required-arguments' => 1,
|
||||
);
|
||||
$items['devel-token'] = array(
|
||||
'description' => dt('List available tokens'),
|
||||
'aliases' => array('token'),
|
||||
'core' => array(7), // Remove once 3.0 is released.
|
||||
//@todo support --format option for json, csv, etc.
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
@@ -72,25 +82,28 @@ function drush_devel_reinstall() {
|
||||
/**
|
||||
* A command callback.
|
||||
*/
|
||||
function drush_devel_download() {
|
||||
$args = func_get_args();
|
||||
if (isset($args[0])) {
|
||||
$path = $args[0];
|
||||
function drush_devel_download($path = NULL) {
|
||||
// If no path is provided by the user, set our default path.
|
||||
if (is_null($path)) {
|
||||
// We use devel folder for legacy reason.
|
||||
$path = drupal_get_path('module', 'devel') . '/FirePHPCore';
|
||||
}
|
||||
else {
|
||||
$path = drush_get_context('DRUSH_DRUPAL_ROOT');
|
||||
// If FirePHP is not installed and libraries module is enabled,
|
||||
// try to find FirePHP by its own means.
|
||||
if (!is_dir($path)) {
|
||||
if (module_exists('libraries')) {
|
||||
$path .= '/' . libraries_get_path('FirePHPCore') . '/FirePHPCore';
|
||||
}
|
||||
else {
|
||||
$path .= '/' . drupal_get_path('module', 'devel') . '/FirePHPCore';
|
||||
// Libraries 1.x will return a path even if it doesn't exist
|
||||
// while 2.x will return FALSE.
|
||||
$path = libraries_get_path('FirePHPCore');
|
||||
if (!$path) {
|
||||
$path = 'sites/all/libraries/FirePHPCore';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_dir($path)) {
|
||||
drush_log('FirePHP already present. No download required.', 'ok');
|
||||
drush_log(dt('FirePHP already present at @path. No download required.', array('@path' => $path)), 'ok');
|
||||
}
|
||||
elseif (drush_shell_exec('svn export http://firephp.googlecode.com/svn/branches/Library-FirePHPCore-0.3 ' . $path)) {
|
||||
elseif (drush_shell_exec('svn export http://firephp.googlecode.com/svn/branches/Library-FirePHPCore-0.3 %s', $path)) {
|
||||
drush_log(dt('FirePHP has been exported via svn to @path.', array('@path' => $path)), 'success');
|
||||
}
|
||||
else {
|
||||
@@ -98,21 +111,6 @@ function drush_devel_download() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements drush_MODULE_post_COMMAND().
|
||||
*/
|
||||
function drush_devel_post_pm_enable() {
|
||||
$extensions = func_get_args();
|
||||
// Deal with comma delimited extension list.
|
||||
if (strpos($extensions[0], ',') !== FALSE) {
|
||||
$extensions = explode(',', $extensions[0]);
|
||||
}
|
||||
|
||||
if (in_array('devel', $extensions) && !drush_get_option('skip')) {
|
||||
drush_devel_download();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Command handler. Show hook implementations.
|
||||
*/
|
||||
|
@@ -7,9 +7,9 @@ tags[] = developer
|
||||
files[] = devel.test
|
||||
files[] = devel.mail.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-06-05
|
||||
version = "7.x-1.3"
|
||||
; Information added by Drupal.org packaging script on 2014-05-01
|
||||
version = "7.x-1.5"
|
||||
core = "7.x"
|
||||
project = "devel"
|
||||
datestamp = "1338940281"
|
||||
datestamp = "1398963366"
|
||||
|
||||
|
@@ -31,18 +31,27 @@ function devel_enable() {
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function devel_uninstall() {
|
||||
variable_del('devel_form_weights');
|
||||
variable_del('devel_execution');
|
||||
variable_del('dev_timer');
|
||||
variable_del('devel_query_display');
|
||||
variable_del('devel_redirect_page');
|
||||
variable_del('devel_api_url');
|
||||
variable_del('dev_mem');
|
||||
variable_del('devel_memory');
|
||||
variable_del('devel_error_handlers');
|
||||
variable_del('devel_raw_names');
|
||||
variable_del('devel_switch_user_list_size');
|
||||
variable_del('devel_switch_user_include_anon');
|
||||
variable_del('devel_switch_user_show_form');
|
||||
variable_del('devel_krumo_skin');
|
||||
variable_del('devel_page_alter');
|
||||
variable_del('devel_query_sort');
|
||||
variable_del('devel_rebuild_theme_registry');
|
||||
variable_del('devel_use_uncompressed_jquery');
|
||||
variable_del('devel_xhprof_directory');
|
||||
variable_del('devel_xhprof_enabled');
|
||||
variable_del('devel_xhprof_url');
|
||||
variable_del('devel_debug_mail_file_format');
|
||||
variable_del('devel_debug_mail_directory');
|
||||
|
||||
// Delete the development menu.
|
||||
if (module_exists('menu')) {
|
||||
@@ -106,3 +115,21 @@ function devel_update_7004() {
|
||||
variable_set('devel_error_handlers', drupal_map_assoc($error_handlers));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete variable 'devel_form_weights' from database as it was removed from code.
|
||||
*/
|
||||
function devel_update_7005() {
|
||||
variable_del('devel_form_weights');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change variable 'dev_mem' to 'devel_memory'.
|
||||
*/
|
||||
function devel_update_7006() {
|
||||
if (variable_get('dev_mem', NULL) !== NULL) {
|
||||
variable_set('devel_memory', variable_get('dev_mem'));
|
||||
}
|
||||
|
||||
variable_del('dev_mem');
|
||||
}
|
||||
|
@@ -2,11 +2,11 @@
|
||||
|
||||
// Explain link in query log
|
||||
Drupal.behaviors.devel_explain = {
|
||||
attach: function() {
|
||||
attach: function(context, settings) {
|
||||
$('a.dev-explain').click(function () {
|
||||
qid = $(this).attr("qid");
|
||||
cell = $('#devel-query-' + qid);
|
||||
$('.dev-explain', cell).load(Drupal.settings.basePath + '?q=devel/explain/' + Drupal.settings.devel.request_id + '/' + qid).show();
|
||||
$('.dev-explain', cell).load(settings.basePath + '?q=devel/explain/' + settings.devel.request_id + '/' + qid).show();
|
||||
$('.dev-placeholders', cell).hide();
|
||||
$('.dev-arguments', cell).hide();
|
||||
return false;
|
||||
@@ -16,11 +16,11 @@ Drupal.behaviors.devel_explain = {
|
||||
|
||||
// Arguments link in query log
|
||||
Drupal.behaviors.devel_arguments = {
|
||||
attach: function() {
|
||||
attach: function(context, settings) {
|
||||
$('a.dev-arguments').click(function () {
|
||||
qid = $(this).attr("qid");
|
||||
cell = $('#devel-query-' + qid);
|
||||
$('.dev-arguments', cell).load(Drupal.settings.basePath + '?q=devel/arguments/' + Drupal.settings.devel.request_id + '/' + qid).show();
|
||||
$('.dev-arguments', cell).load(settings.basePath + '?q=devel/arguments/' + settings.devel.request_id + '/' + qid).show();
|
||||
$('.dev-placeholders', cell).hide();
|
||||
$('.dev-explain', cell).hide();
|
||||
return false;
|
||||
@@ -30,7 +30,7 @@ Drupal.behaviors.devel_arguments = {
|
||||
|
||||
// Placeholders link in query log
|
||||
Drupal.behaviors.devel_placeholders = {
|
||||
attach: function() {
|
||||
attach: function(context, settings) {
|
||||
$('a.dev-placeholders').click(function () {
|
||||
qid = $(this).attr("qid");
|
||||
cell = $('#devel-query-' + qid);
|
||||
|
@@ -27,7 +27,10 @@ class DevelMailLog extends DefaultMailSystem {
|
||||
|
||||
$line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
|
||||
$output = join($line_endings, $mimeheaders) . $line_endings;
|
||||
$output .= $message['subject'] . $line_endings;
|
||||
// 'Subject:' is a mail header and should not be translated.
|
||||
$output .= 'Subject: ' . $message['subject'] . $line_endings;
|
||||
// Blank line to separate headers from body.
|
||||
$output .= $line_endings;
|
||||
$output .= preg_replace('@\r?\n@', $line_endings, $message['body']);
|
||||
return $output;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -145,20 +145,17 @@ function devel_field_info_page() {
|
||||
$output .= kprint_r($info, TRUE, t('Instances'));
|
||||
$info = field_info_bundles();
|
||||
$output .= kprint_r($info, TRUE, t('Bundles'));
|
||||
$info = field_info_field_types();
|
||||
$output .= kprint_r($info, TRUE, t('Field types'));
|
||||
$info = field_info_formatter_types();
|
||||
$output .= kprint_r($info, TRUE, t('Formatter types'));
|
||||
$info = field_info_storage_types();
|
||||
$output .= kprint_r($info, TRUE, t('Storage types'));
|
||||
$info = field_info_widget_types();
|
||||
$output .= kprint_r($info, TRUE, t('Widget types'));
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback; display all variables.
|
||||
*/
|
||||
function devel_variable_page() {
|
||||
// We return our own $page so as to avoid blocks.
|
||||
$output = drupal_get_form('devel_variable_form');
|
||||
drupal_set_page_content($output);
|
||||
$page = element_info('page');
|
||||
return $page;
|
||||
}
|
||||
|
||||
function devel_variable_form() {
|
||||
$header = array(
|
||||
'name' => array('data' => t('Name'), 'field' => 'name', 'sort' => 'asc'),
|
||||
|
@@ -45,7 +45,8 @@ class DevelMailTest extends DrupalWebTestCase {
|
||||
$this->assertEqual($content, 'From: postmaster@example.com
|
||||
X-stupid: dumb
|
||||
To: drupal@example.com
|
||||
Test mail
|
||||
Subject: Test mail
|
||||
|
||||
I am the body of this message');
|
||||
}
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
function devel_generate_drush_command() {
|
||||
$items['generate-users'] = array(
|
||||
'callback' => 'drush_devel_generate_users',
|
||||
'description' => 'Create users.',
|
||||
'arguments' => array(
|
||||
'number_users' => 'Number of users to generate.',
|
||||
@@ -17,10 +18,12 @@ function devel_generate_drush_command() {
|
||||
'options' => array(
|
||||
'kill' => 'Delete all users before generating new ones.',
|
||||
'roles' => 'A comma delimited list of role IDs which should be granted to the new users. No need to specify authenticated user role.',
|
||||
'pass' => 'Specify a password to be set for all generated users.',
|
||||
),
|
||||
'aliases' => array('genu'),
|
||||
);
|
||||
$items['generate-terms'] = array(
|
||||
'callback' => 'drush_devel_generate_terms',
|
||||
'description' => 'Create terms in specified vocabulary.',
|
||||
'arguments' => array(
|
||||
'machine_name' => 'Vocabulary machine name into which new terms will be inserted.',
|
||||
@@ -28,12 +31,13 @@ function devel_generate_drush_command() {
|
||||
),
|
||||
'options' => array(
|
||||
'kill' => 'Delete all terms in specified vocabulary before generating.',
|
||||
'feedback' => 'An integer representing interval for insertion rate logging. Defaults to 500',
|
||||
'feedback' => 'An integer representing interval for insertion rate logging. Defaults to 1000',
|
||||
),
|
||||
'aliases' => array('gent'),
|
||||
|
||||
);
|
||||
$items['generate-vocabs'] = array(
|
||||
'callback' => 'drush_devel_generate_vocabs',
|
||||
'description' => 'Create vocabularies.',
|
||||
'arguments' => array(
|
||||
'num_vocabs' => 'Number of vocabularies to create. Defaults to 1.',
|
||||
@@ -44,6 +48,7 @@ function devel_generate_drush_command() {
|
||||
'aliases' => array('genv'),
|
||||
);
|
||||
$items['generate-content'] = array(
|
||||
'callback' => 'drush_devel_generate_content',
|
||||
'description' => 'Create content.',
|
||||
'drupal dependencies' => array('devel_generate'),
|
||||
'arguments' => array(
|
||||
@@ -53,13 +58,14 @@ function devel_generate_drush_command() {
|
||||
'options' => array(
|
||||
'kill' => 'Delete all content before generating new content.',
|
||||
'types' => 'A comma delimited list of content types to create. Defaults to page,article.',
|
||||
'feedback' => 'An integer representing interval for insertion rate logging. Defaults to 500',
|
||||
'feedback' => 'An integer representing interval for insertion rate logging. Defaults to 1000',
|
||||
'skip-fields' => 'A comma delimited list of fields to omit when generating random values',
|
||||
'languages' => 'A comma-separated list of language codes',
|
||||
),
|
||||
'aliases' => array('genc'),
|
||||
);
|
||||
$items['generate-menus'] = array(
|
||||
'callback' => 'drush_devel_generate_menus',
|
||||
'description' => 'Create menus and menu items.',
|
||||
'drupal dependencies' => array('devel_generate'), // Remove these once devel.module is moved down a directory. http://drupal.org/node/925246
|
||||
'arguments' => array(
|
||||
@@ -86,7 +92,8 @@ function drush_devel_generate_users($num_users = NULL) {
|
||||
}
|
||||
drush_generate_include_devel();
|
||||
$roles = drush_get_option('roles') ? explode(',', drush_get_option('roles')) : array();
|
||||
devel_create_users($num_users, drush_get_option('kill'), 0, $roles);
|
||||
$pass = drush_get_option('pass', NULL);
|
||||
devel_create_users($num_users, drush_get_option('kill'), 0, $roles, $pass);
|
||||
drush_log(t('Generated @number users.', array('@number' => $num_users)), 'success');
|
||||
}
|
||||
|
||||
@@ -103,9 +110,14 @@ function drush_devel_generate_terms($vname = NULL, $num_terms = 10) {
|
||||
}
|
||||
|
||||
drush_generate_include_devel();
|
||||
$vocabs[$vocab->vid] = $vocab;
|
||||
devel_generate_term_data($vocabs, $num_terms, '12', drush_get_option('kill'));
|
||||
drush_log(dt('Generated @num_terms terms.', array('@num_terms' => $num_terms)), 'success');
|
||||
if (drush_get_option('kill')) {
|
||||
devel_generate_delete_vocabulary_terms($vocab->vid);
|
||||
drush_log(dt('Deleted existing terms.'), 'success');
|
||||
}
|
||||
$new_terms = devel_generate_terms($num_terms, array($vocab->vid => $vocab), '12');
|
||||
if (!empty($new_terms)) {
|
||||
drush_log(dt("Created the following new terms:\n!terms", array('!terms' => implode("\n", $new_terms))), 'success');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,8 +128,14 @@ function drush_devel_generate_vocabs($num_vocab = 1) {
|
||||
return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of vocabularies: !num.', array('!num' => $num_vocab)));
|
||||
}
|
||||
drush_generate_include_devel();
|
||||
devel_generate_vocab_data($num_vocab, '12', drush_get_option('kill'));
|
||||
drush_log(dt('Generated @num_vocab vocabularies.', array('@num_vocab' => $num_vocab)), 'success');
|
||||
if (drush_get_option('kill')) {
|
||||
devel_generate_delete_vocabularies();
|
||||
drush_log(dt('Deleted existing vocabularies.'), 'success');
|
||||
}
|
||||
$new_vocs = devel_generate_vocabs($num_vocab, '12');
|
||||
if (!empty($new_vocs)) {
|
||||
drush_log(dt("Created the following new vocabularies:\n!vocs", array('!vocs' => implode("\n", $new_vocs))), 'success');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,6 +170,10 @@ function drush_devel_generate_content($num_nodes = NULL, $max_comments = NULL) {
|
||||
$values['values']['num_nodes'] = $num_nodes;
|
||||
$values['values']['max_comments'] = $max_comments;
|
||||
$values['values']['node_types'] = drupal_map_assoc(explode(',', drush_get_option('types', 'page,article')));
|
||||
$node_types = array_filter($values['values']['node_types']);
|
||||
if (!empty($values['values']['kill_content']) && empty($node_types)) {
|
||||
return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Please provide content type (--types) in which you want to delete the content.'));
|
||||
}
|
||||
drush_generate_include_devel();
|
||||
devel_generate_content($values);
|
||||
drush_log(t('Generated @num_nodes nodes, @max_comments comments (or less) per node.', array('@num_nodes' => (int)$num_nodes, '@max_comments' => (int)$max_comments)), 'success');
|
||||
@@ -179,12 +201,26 @@ function drush_devel_generate_menus($number_menus = 2, $number_links = 50, $max_
|
||||
$user = $user_one;
|
||||
drupal_save_session(FALSE);
|
||||
|
||||
$kill = drush_get_option('kill');
|
||||
drush_generate_include_devel();
|
||||
|
||||
// Delete custom menus.
|
||||
if (drush_get_option('kill')) {
|
||||
devel_generate_delete_menus();
|
||||
drush_log(dt('Deleted existing menus and links.'), 'success');
|
||||
}
|
||||
|
||||
// Generate new menus.
|
||||
$new_menus = devel_generate_menus($number_menus, '12');
|
||||
if (!empty($new_menus)) {
|
||||
drush_log(dt("Created the following new menus:\n!menus", array('!menus' => implode("\n", $new_menus))), 'success');
|
||||
}
|
||||
|
||||
// Generate new menu links.
|
||||
$link_types = drupal_map_assoc(array('node', 'front', 'external'));
|
||||
devel_generate_menu_data($number_menus, array(), $number_links, 12, $link_types, $max_depth, $max_width, $kill);
|
||||
drush_log(t('Generated @number_menus menus, @number_links links.', array('@number_menus' => (int)$number_menus, '@number_links' => (int)$number_links)), 'success');
|
||||
$new_links = devel_generate_links($number_links, $new_menus, '12', $link_types, $max_depth, $max_width);
|
||||
drush_log(dt('Created !count new menu links.', array('!count' => count($new_links))), 'success');
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Helper functions
|
||||
|
||||
|
@@ -11,8 +11,10 @@
|
||||
* The max age of each randomly-generated user, in seconds.
|
||||
* @param $roles
|
||||
* An array of role IDs that the users should receive.
|
||||
* @param $pass
|
||||
* A string to be used as common password for all generated users.
|
||||
*/
|
||||
function devel_create_users($num, $kill, $age = 0, $roles = array()) {
|
||||
function devel_create_users($num, $kill, $age = 0, $roles = array(), $pass = NULL) {
|
||||
$url = parse_url($GLOBALS['base_url']);
|
||||
if ($kill) {
|
||||
$uids = db_select('users', 'u')
|
||||
@@ -45,8 +47,8 @@ function devel_create_users($num, $kill, $age = 0, $roles = array()) {
|
||||
$edit = array(
|
||||
'uid' => NULL,
|
||||
'name' => $name,
|
||||
'pass' => NULL, // No password avoids user_hash_password() which is expensive.
|
||||
'mail' => $name . '@' . $url['host'],
|
||||
'pass' => $pass,
|
||||
'mail' => $name . '@' . $url['host'].'.invalid',
|
||||
'status' => 1,
|
||||
'created' => REQUEST_TIME - mt_rand(0, $age),
|
||||
'roles' => drupal_map_assoc($roles),
|
||||
@@ -103,6 +105,7 @@ function devel_create_users($num, $kill, $age = 0, $roles = array()) {
|
||||
// Save the user record with the new picture.
|
||||
$edit = (array) $account;
|
||||
$edit['picture'] = $file;
|
||||
$edit['pass'] = $pass; // Reassign password as it is replaced with the hashed version in $account
|
||||
user_save($account, $edit);
|
||||
}
|
||||
}
|
||||
@@ -114,8 +117,11 @@ function devel_create_users($num, $kill, $age = 0, $roles = array()) {
|
||||
/**
|
||||
* The main API function for creating content.
|
||||
*
|
||||
* See devel_generate_content_form() for the supported keys in $form_state['values'].
|
||||
* Other modules may participate by form_alter() on that form and then handling their data during hook_nodeapi('pre_save') or in own submit handler for the form.
|
||||
* See devel_generate_content_form() for the supported keys in
|
||||
* $form_state['values'].
|
||||
* Other modules may participate by form_alter() on that form and then handling
|
||||
* their data during hook_node_insert() or in their own submit handler for the
|
||||
* form.
|
||||
*
|
||||
* @param string $form_state
|
||||
* @return void
|
||||
@@ -205,6 +211,18 @@ function devel_generate_vocabs($records, $maxlength = 12, $types = array('page',
|
||||
return $vocs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates taxonomy terms for a list of given vocabularies.
|
||||
*
|
||||
* @param $records
|
||||
* int number of terms to create in total.
|
||||
* @param $vocabs
|
||||
* array list of vocabs to populate.
|
||||
* @param $maxlength
|
||||
* int maximum length per term.
|
||||
* @return
|
||||
* array the list of names of the created terms.
|
||||
*/
|
||||
function devel_generate_terms($records, $vocabs, $maxlength = 12) {
|
||||
$terms = array();
|
||||
|
||||
@@ -255,7 +273,7 @@ function devel_generate_terms($records, $vocabs, $maxlength = 12) {
|
||||
|
||||
// Populate all core fields on behalf of field.module
|
||||
module_load_include('inc', 'devel_generate', 'devel_generate.fields');
|
||||
devel_generate_fields($term, 'term', $term->vocabulary_machine_name);
|
||||
devel_generate_fields($term, 'taxonomy_term', $term->vocabulary_machine_name);
|
||||
|
||||
if ($status = taxonomy_term_save($term)) {
|
||||
$max += 1;
|
||||
@@ -289,69 +307,49 @@ function devel_generate_get_terms($vids) {
|
||||
->fetchCol('tid');
|
||||
}
|
||||
|
||||
function devel_generate_term_data($vocabs, $num_terms, $title_length, $kill) {
|
||||
if ($kill) {
|
||||
foreach (devel_generate_get_terms(array_keys($vocabs)) as $tid) {
|
||||
taxonomy_term_delete($tid);
|
||||
}
|
||||
drupal_set_message(t('Deleted existing terms.'));
|
||||
}
|
||||
|
||||
$new_terms = devel_generate_terms($num_terms, $vocabs, $title_length);
|
||||
if (!empty($new_terms)) {
|
||||
drupal_set_message(t('Created the following new terms: !terms', array('!terms' => theme('item_list', array('items' => $new_terms)))));
|
||||
/**
|
||||
* Deletes all terms of a vocabulary.
|
||||
*
|
||||
* @param $vid
|
||||
* int a vocabulary vid.
|
||||
*/
|
||||
function devel_generate_delete_vocabulary_terms($vid) {
|
||||
foreach (taxonomy_get_tree($vid) as $term) {
|
||||
taxonomy_term_delete($term->tid);
|
||||
}
|
||||
}
|
||||
|
||||
function devel_generate_vocab_data($num_vocab, $title_length, $kill) {
|
||||
|
||||
if ($kill) {
|
||||
foreach (taxonomy_get_vocabularies() as $vid => $vocab) {
|
||||
taxonomy_vocabulary_delete($vid);
|
||||
}
|
||||
drupal_set_message(t('Deleted existing vocabularies.'));
|
||||
}
|
||||
|
||||
$new_vocs = devel_generate_vocabs($num_vocab, $title_length);
|
||||
if (!empty($new_vocs)) {
|
||||
drupal_set_message(t('Created the following new vocabularies: !vocs', array('!vocs' => theme('item_list', array('items' => $new_vocs)))));
|
||||
/**
|
||||
* Deletes all vocabularies.
|
||||
*/
|
||||
function devel_generate_delete_vocabularies() {
|
||||
foreach (taxonomy_vocabulary_load_multiple(FALSE) as $vid => $vocab) {
|
||||
taxonomy_vocabulary_delete($vid);
|
||||
}
|
||||
}
|
||||
|
||||
function devel_generate_menu_data($num_menus, $existing_menus, $num_links, $title_length, $link_types, $max_depth, $max_width, $kill) {
|
||||
// Delete menus and menu links.
|
||||
if ($kill) {
|
||||
if (module_exists('menu')) {
|
||||
foreach (menu_get_menus(FALSE) as $menu => $menu_title) {
|
||||
if (strpos($menu, 'devel-') === 0) {
|
||||
$menu = menu_load($menu);
|
||||
menu_delete($menu);
|
||||
}
|
||||
/**
|
||||
* Deletes custom generated menus
|
||||
*/
|
||||
function devel_generate_delete_menus() {
|
||||
if (module_exists('menu')) {
|
||||
foreach (menu_get_menus(FALSE) as $menu => $menu_title) {
|
||||
if (strpos($menu, 'devel-') === 0) {
|
||||
$menu = menu_load($menu);
|
||||
menu_delete($menu);
|
||||
}
|
||||
}
|
||||
// Delete menu links generated by devel.
|
||||
$result = db_select('menu_links', 'm')
|
||||
->fields('m', array('mlid'))
|
||||
->condition('m.menu_name', 'devel', '<>')
|
||||
// Look for the serialized version of 'devel' => TRUE.
|
||||
->condition('m.options', '%' . db_like('s:5:"devel";b:1') . '%', 'LIKE')
|
||||
->execute();
|
||||
foreach ($result as $link) {
|
||||
menu_link_delete($link->mlid);
|
||||
}
|
||||
drupal_set_message(t('Deleted existing menus and links.'));
|
||||
}
|
||||
|
||||
// Generate new menus.
|
||||
$new_menus = devel_generate_menus($num_menus, $title_length);
|
||||
if (!empty($new_menus)) {
|
||||
drupal_set_message(t('Created the following new menus: !menus', array('!menus' => theme('item_list', array('items' => $new_menus)))));
|
||||
// Delete menu links generated by devel.
|
||||
$result = db_select('menu_links', 'm')
|
||||
->fields('m', array('mlid'))
|
||||
->condition('m.menu_name', 'devel', '<>')
|
||||
// Look for the serialized version of 'devel' => TRUE.
|
||||
->condition('m.options', '%' . db_like('s:5:"devel";b:1') . '%', 'LIKE')
|
||||
->execute();
|
||||
foreach ($result as $link) {
|
||||
menu_link_delete($link->mlid);
|
||||
}
|
||||
|
||||
// Generate new menu links.
|
||||
$menus = $new_menus + $existing_menus;
|
||||
$new_links = devel_generate_links($num_links, $menus, $title_length, $link_types, $max_depth, $max_width);
|
||||
drupal_set_message(t('Created @count new menu links.', array('@count' => count($new_links))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +364,7 @@ function devel_generate_menus($num_menus, $title_length = 12) {
|
||||
|
||||
for ($i = 1; $i <= $num_menus; $i++) {
|
||||
$menu = array();
|
||||
$menu['title'] = devel_generate_word(mt_rand(2, $title_length));
|
||||
$menu['title'] = devel_generate_word(mt_rand(2, max(2, $title_length)));
|
||||
$menu['menu_name'] = 'devel-' . drupal_strtolower($menu['title']);
|
||||
$menu['description'] = t('Description of @name', array('@name' => $menu['title']));
|
||||
menu_save($menu);
|
||||
@@ -394,7 +392,7 @@ function devel_generate_links($num_links, $menus, $title_length, $link_types, $m
|
||||
'options' => array('devel' => TRUE),
|
||||
'weight' => mt_rand(-50, 50),
|
||||
'mlid' => 0,
|
||||
'link_title' => devel_generate_word(mt_rand(2, $title_length)),
|
||||
'link_title' => devel_generate_word(mt_rand(2, max(2, $title_length))),
|
||||
);
|
||||
$link['options']['attributes']['title'] = t('Description of @title.', array('@title' => $link['link_title']));
|
||||
|
||||
@@ -404,7 +402,7 @@ function devel_generate_links($num_links, $menus, $title_length, $link_types, $m
|
||||
}
|
||||
else {
|
||||
// Otherwise, get a random parent menu depth.
|
||||
$depth = mt_rand(1, $max_depth - 1);
|
||||
$depth = mt_rand(1, max(1, $max_depth - 1));
|
||||
}
|
||||
// Get a random parent link from the proper depth.
|
||||
do {
|
||||
@@ -674,9 +672,19 @@ function devel_generate_content_add_node(&$results) {
|
||||
$users = $results['users'];
|
||||
$node->uid = $users[array_rand($users)];
|
||||
$type = node_type_get_type($node);
|
||||
$node->title = $type->has_title ? devel_create_greeking(mt_rand(2, $results['title_length']), TRUE) : '';
|
||||
$node->revision = mt_rand(0,1);
|
||||
$node->promote = mt_rand(0, 1);
|
||||
|
||||
if ($type->has_title) {
|
||||
// We should not use the random function if the value is not random
|
||||
if ($results['title_length'] < 2) {
|
||||
$node->title = devel_create_greeking(1, TRUE);
|
||||
}
|
||||
else {
|
||||
$node->title = devel_create_greeking(mt_rand(1, $results['title_length']), TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid NOTICE.
|
||||
if (!isset($results['time_range'])) {
|
||||
$results['time_range'] = 0;
|
||||
@@ -686,14 +694,16 @@ function devel_generate_content_add_node(&$results) {
|
||||
|
||||
$node->created = REQUEST_TIME - mt_rand(0, $results['time_range']);
|
||||
|
||||
// A flag to let hook_nodeapi() implementations know that this is a generated node.
|
||||
// A flag to let hook_node_insert() implementations know that this is a
|
||||
// generated node.
|
||||
$node->devel_generate = $results;
|
||||
|
||||
// Populate all core fields on behalf of field.module
|
||||
module_load_include('inc', 'devel_generate', 'devel_generate.fields');
|
||||
devel_generate_fields($node, 'node', $node->type);
|
||||
|
||||
// See devel_generate_nodeapi() for actions that happen before and after this save.
|
||||
// See devel_generate_node_insert() for actions that happen before and after
|
||||
// this save.
|
||||
node_save($node);
|
||||
}
|
||||
|
||||
|
@@ -2,13 +2,13 @@ name = Devel generate
|
||||
description = Generate dummy users, nodes, and taxonomy terms.
|
||||
package = Development
|
||||
core = 7.x
|
||||
dependencies[] = devel
|
||||
tags[] = developer
|
||||
configure = admin/config/development/generate
|
||||
files[] = devel_generate.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-06-05
|
||||
version = "7.x-1.3"
|
||||
; Information added by Drupal.org packaging script on 2014-05-01
|
||||
version = "7.x-1.5"
|
||||
core = "7.x"
|
||||
project = "devel"
|
||||
datestamp = "1338940281"
|
||||
datestamp = "1398963366"
|
||||
|
||||
|
@@ -71,6 +71,14 @@ function devel_generate_users_form() {
|
||||
'#options' => $options,
|
||||
);
|
||||
|
||||
$form['pass'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Password to be set'),
|
||||
'#default_value' => NULL,
|
||||
'#size' => 32,
|
||||
'#description' => t('Leave this field empty if you do not need to set a password.'),
|
||||
);
|
||||
|
||||
$options = array(1 => t('Now'));
|
||||
foreach (array(3600, 86400, 604800, 2592000, 31536000) as $interval) {
|
||||
$options[$interval] = format_interval($interval, 1) . ' ' . t('ago');
|
||||
@@ -93,10 +101,10 @@ function devel_generate_users_form() {
|
||||
/**
|
||||
* FormAPI submission to generate users.
|
||||
*/
|
||||
function devel_generate_users_form_submit($form_id, &$form_state) {
|
||||
function devel_generate_users_form_submit($form, &$form_state) {
|
||||
module_load_include('inc', 'devel_generate');
|
||||
$values = $form_state['values'];
|
||||
devel_create_users($values['num'], $values['kill_users'], $values['time_range'], $values['roles']);
|
||||
devel_create_users($values['num'], $values['kill_users'], $values['time_range'], $values['roles'], $values['pass']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,14 +125,15 @@ function devel_generate_content_form() {
|
||||
}
|
||||
else {
|
||||
$types = node_type_get_types();
|
||||
$suffix = '';
|
||||
foreach ($types as $type) {
|
||||
$options[$type->type] = array(
|
||||
'type' => t($type->name),
|
||||
);
|
||||
if (module_exists('comment')) {
|
||||
$default = variable_get('comment_' . $type->type, COMMENT_NODE_OPEN);
|
||||
$map = array(t('Hidden'), t('Closed'), t('Open'));
|
||||
$suffix = '<small>. ' . t('Comments: ') . $map[$default]. '</small>';
|
||||
$options[$type->type]['comments'] = '<small>'. $map[$default]. '</small>';
|
||||
}
|
||||
$options[$type->type] = t($type->name) . $suffix;
|
||||
}
|
||||
}
|
||||
// we cannot currently generate valid polls.
|
||||
@@ -135,11 +144,18 @@ function devel_generate_content_form() {
|
||||
return;
|
||||
}
|
||||
|
||||
$header = array(
|
||||
'type' => t('Content type'),
|
||||
);
|
||||
if (module_exists('comment')) {
|
||||
$header['comments'] = t('Comments');
|
||||
}
|
||||
|
||||
$form['node_types'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Content types'),
|
||||
'#type' => 'tableselect',
|
||||
'#header' => $header,
|
||||
'#options' => $options,
|
||||
'#default_value' => array_keys($options),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
if (module_exists('checkall')) $form['node_types']['#checkall'] = TRUE;
|
||||
$form['kill_content'] = array(
|
||||
@@ -218,12 +234,21 @@ function devel_generate_content_form() {
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* FormAPI validation before generate nodes.
|
||||
*/
|
||||
function devel_generate_content_form_validate($form, &$form_state) {
|
||||
form_set_value($form['node_types'], array_filter($form_state['values']['node_types']) , $form_state);
|
||||
if (!empty($form_state['values']['kill_content']) && empty($form_state['values']['node_types'])) {
|
||||
form_set_error('', t('Please select at least one content type to delete the content.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* FormAPI submission to generate nodes.
|
||||
*/
|
||||
function devel_generate_content_form_submit($form_id, &$form_state) {
|
||||
function devel_generate_content_form_submit($form, &$form_state) {
|
||||
module_load_include('inc', 'devel_generate', 'devel_generate');
|
||||
$form_state['values']['node_types'] = array_filter($form_state['values']['node_types']);
|
||||
if ($form_state['values']['num_nodes'] <= 50 && $form_state['values']['max_comments'] <= 10) {
|
||||
module_load_include('inc', 'devel_generate');
|
||||
devel_generate_content($form_state);
|
||||
@@ -305,18 +330,36 @@ function devel_generate_vocab_form() {
|
||||
/**
|
||||
* FormAPI submission to generate taxonomy terms.
|
||||
*/
|
||||
function devel_generate_term_form_submit($form_id, &$form_state) {
|
||||
function devel_generate_term_form_submit($form, &$form_state) {
|
||||
$values = $form_state['values'];
|
||||
module_load_include('inc', 'devel_generate');
|
||||
$vocabs = taxonomy_vocabulary_load_multiple($form_state['values']['vids']);
|
||||
devel_generate_term_data($vocabs, $form_state['values']['num_terms'], $form_state['values']['title_length'], $form_state['values']['kill_taxonomy']);
|
||||
if ($values['kill_taxonomy']) {
|
||||
foreach ($values['vids'] as $vid) {
|
||||
devel_generate_delete_vocabulary_terms($vid);
|
||||
}
|
||||
drupal_set_message(t('Deleted existing terms.'));
|
||||
}
|
||||
$vocabs = taxonomy_vocabulary_load_multiple($values['vids']);
|
||||
$new_terms = devel_generate_terms($values['num_terms'], $vocabs, $values['title_length']);
|
||||
if (!empty($new_terms)) {
|
||||
drupal_set_message(t('Created the following new terms: !terms', array('!terms' => implode(', ', $new_terms))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* FormAPI submission to generate taxonomy vocabularies.
|
||||
*/
|
||||
function devel_generate_vocab_form_submit($form_id, &$form_state) {
|
||||
function devel_generate_vocab_form_submit($form, &$form_state) {
|
||||
$values = $form_state['values'];
|
||||
module_load_include('inc', 'devel_generate');
|
||||
devel_generate_vocab_data($form_state['values']['num_vocabs'], $form_state['values']['title_length'], $form_state['values']['kill_taxonomy']);
|
||||
if ($values['kill_taxonomy']) {
|
||||
devel_generate_delete_vocabularies();
|
||||
drupal_set_message(t('Deleted existing vocabularies.'));
|
||||
}
|
||||
$new_vocs = devel_generate_vocabs($values['num_vocabs'], $values['title_length']);
|
||||
if (!empty($new_vocs)) {
|
||||
drupal_set_message(t('Created the following new vocabularies: !vocs', array('!vocs' => implode(', ', $new_vocs))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -407,6 +450,7 @@ function devel_generate_menu_form() {
|
||||
$form['title_length'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Maximum number of characters in menu and menu link names'),
|
||||
'#description' => t("The minimum length is 2."),
|
||||
'#default_value' => 12,
|
||||
'#size' => 10,
|
||||
'#required' => TRUE,
|
||||
@@ -453,11 +497,26 @@ function devel_generate_menu_form() {
|
||||
/**
|
||||
* FormAPI submission to generate menus.
|
||||
*/
|
||||
function devel_generate_menu_form_submit($form_id, &$form_state) {
|
||||
function devel_generate_menu_form_submit($form, &$form_state) {
|
||||
// If the create new menus checkbox is off, set the number of new menus to 0.
|
||||
if (!isset($form_state['values']['existing_menus']['__new-menu__']) || !$form_state['values']['existing_menus']['__new-menu__']) {
|
||||
$form_state['values']['num_menus'] = 0;
|
||||
}
|
||||
module_load_include('inc', 'devel_generate');
|
||||
devel_generate_menu_data($form_state['values']['num_menus'], $form_state['values']['existing_menus'], $form_state['values']['num_links'], $form_state['values']['title_length'], $form_state['values']['link_types'], $form_state['values']['max_depth'], $form_state['values']['max_width'], $form_state['values']['kill']);
|
||||
// Delete custom menus.
|
||||
if ($form_state['values']['kill']) {
|
||||
devel_generate_delete_menus();
|
||||
drupal_set_message(t('Deleted existing menus and links.'));
|
||||
}
|
||||
|
||||
// Generate new menus.
|
||||
$new_menus = devel_generate_menus($form_state['values']['num_menus'], $form_state['values']['title_length']);
|
||||
if (!empty($new_menus)) {
|
||||
drupal_set_message(t('Created the following new menus: !menus', array('!menus' => implode(', ', $new_menus))));
|
||||
}
|
||||
|
||||
// Generate new menu links.
|
||||
$menus = $new_menus + $form_state['values']['existing_menus'];
|
||||
$new_links = devel_generate_links($form_state['values']['num_links'], $menus, $form_state['values']['title_length'], $form_state['values']['link_types'], $form_state['values']['max_depth'], $form_state['values']['max_width']);
|
||||
drupal_set_message(t('Created @count new menu links.', array('@count' => count($new_links))));
|
||||
}
|
||||
|
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implements tests for devel_generate submodule.
|
||||
*/
|
||||
|
||||
/**
|
||||
* class DevelGenerateTest
|
||||
*/
|
||||
class DevelGenerateTest extends DrupalWebTestCase {
|
||||
/*
|
||||
* The getInfo() method provides information about the test.
|
||||
* In order for the test to be run, the getInfo() method needs
|
||||
* to be implemented.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Devel Generate'),
|
||||
'description' => t('Tests the logic to generate data.'),
|
||||
'group' => t('Devel'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the testing environment
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp(array('devel', 'devel_generate', 'taxonomy', 'menu', 'comment'));
|
||||
|
||||
// Create Basic page and Article node types.
|
||||
if ($this->profile != 'standard') {
|
||||
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic Page'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests generate commands
|
||||
*/
|
||||
public function testGenerate() {
|
||||
$user = $this->drupalCreateUser(array(
|
||||
'administer taxonomy',
|
||||
'administer menu',
|
||||
'administer nodes',
|
||||
));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Generate taxonomy vocabularies.
|
||||
$edit = array(
|
||||
'num_vocabs' => 5,
|
||||
'title_length' => 12,
|
||||
'kill_taxonomy' => 1,
|
||||
);
|
||||
$this->drupalPost('admin/config/development/generate/vocabs',
|
||||
$edit, t('Generate'));
|
||||
$this->assertText(t('Deleted existing vocabularies.'));
|
||||
$this->assertText(t('Created the following new vocabularies:'));
|
||||
|
||||
// Generate taxonomy terms.
|
||||
$form = devel_generate_term_form();
|
||||
$vids = array_keys($form['vids']['#options']);
|
||||
$edit = array(
|
||||
'vids[]' => $vids,
|
||||
'num_terms' => 5,
|
||||
'title_length' => 12,
|
||||
'kill_taxonomy' => 1,
|
||||
);
|
||||
$this->drupalPost('admin/config/development/generate/taxonomy',
|
||||
$edit, t('Generate'));
|
||||
$this->assertText(t('Deleted existing terms.'));
|
||||
$this->assertText(t('Created the following new terms: '));
|
||||
|
||||
// Generate menus.
|
||||
$edit = array(
|
||||
'existing_menus[__new-menu__]' => 1,
|
||||
'num_menus' => 2,
|
||||
'num_links' => 50,
|
||||
'title_length' => 12,
|
||||
'link_types[node]' => 1,
|
||||
'link_types[front]' => 1,
|
||||
'link_types[external]' => 1,
|
||||
'max_depth' => 4,
|
||||
'max_width' => 6,
|
||||
'kill' => 1,
|
||||
);
|
||||
$this->drupalPost('admin/config/development/generate/menu',
|
||||
$edit, t('Generate'));
|
||||
$this->assertText(t('Deleted existing menus and links.'));
|
||||
$this->assertText(t('Created the following new menus:'));
|
||||
$this->assertText(t('Created 50 new menu links.'));
|
||||
|
||||
// Generate content.
|
||||
// First we create a node in order to test the Delete content checkbox.
|
||||
$this->drupalCreateNode(array());
|
||||
|
||||
// Now submit the generate content form.
|
||||
$edit = array(
|
||||
'node_types[page]' => 1,
|
||||
'kill_content' => 1,
|
||||
'num_nodes' => 2,
|
||||
'time_range' => 604800,
|
||||
'max_comments' => 3,
|
||||
'title_length' => 4,
|
||||
);
|
||||
$this->drupalPost('admin/config/development/generate/content', $edit, t('Generate'));
|
||||
$this->assertText(t('Deleted 1 nodes.'));
|
||||
$this->assertText(t('Finished creating 2 nodes'));
|
||||
}
|
||||
}
|
@@ -18,7 +18,7 @@ function _file_devel_generate($object, $field, $instance, $bundle) {
|
||||
$source->uri = $path;
|
||||
$source->uid = 1; // TODO: randomize? use case specific.
|
||||
$source->filemime = 'text/plain';
|
||||
$source->filename = array_pop(explode("//", $path));
|
||||
$source->filename = basename($path);
|
||||
$destination_dir = $field['settings']['uri_scheme'] . '://' . $instance['settings']['file_directory'];
|
||||
file_prepare_directory($destination_dir, FILE_CREATE_DIRECTORY);
|
||||
$destination = $destination_dir . '/' . basename($path);
|
||||
|
@@ -23,7 +23,7 @@ function _image_devel_generate($object, $field, $instance, $bundle) {
|
||||
|
||||
$min_resolution = empty($instance['settings']['min_resolution']) ? '100x100' : $instance['settings']['min_resolution'];
|
||||
$max_resolution = empty($instance['settings']['max_resolution']) ? '600x600' : $instance['settings']['max_resolution'];
|
||||
$extensions = array_intersect(explode(' ', $instance['settings']['file_extensions']), array('png', 'jpg'));
|
||||
$extensions = array_intersect(explode(' ', $instance['settings']['file_extensions']), array('png', 'gif', 'jpg', 'jpeg'));
|
||||
$extension = array_rand(drupal_map_assoc($extensions));
|
||||
|
||||
// Generate a max of 5 different images.
|
||||
@@ -33,7 +33,7 @@ function _image_devel_generate($object, $field, $instance, $bundle) {
|
||||
$source->uri = $path;
|
||||
$source->uid = 1; // TODO: randomize? Use case specific.
|
||||
$source->filemime = 'image/' . pathinfo($path, PATHINFO_EXTENSION);
|
||||
$source->filename = array_pop(explode("//", $path));
|
||||
$source->filename = basename($path);
|
||||
$destination_dir = $field['settings']['uri_scheme'] . '://' . $instance['settings']['file_directory'];
|
||||
file_prepare_directory($destination_dir, FILE_CREATE_DIRECTORY);
|
||||
$destination = $destination_dir . '/' . basename($path);
|
||||
@@ -89,8 +89,6 @@ function devel_generate_image($extension = 'png', $min_resolution, $max_resoluti
|
||||
|
||||
$save_function = 'image'. ($extension == 'jpg' ? 'jpeg' : $extension);
|
||||
$save_function($im, drupal_realpath($destination));
|
||||
|
||||
$images[$extension][$min_resolution][$max_resolution][$destination] = $destination;
|
||||
}
|
||||
return $destination;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ function _text_devel_generate($object, $field, $instance, $bundle) {
|
||||
$format = filter_fallback_format();
|
||||
}
|
||||
|
||||
if ($instance['widget']['type'] != 'text_textfield') {
|
||||
if (empty($field['settings']['max_length'])) {
|
||||
// Textarea handling
|
||||
$object_field['value'] = devel_create_content($format);
|
||||
if ($instance['widget']['type'] == 'text_textarea_with_summary' && !empty($instance['display_summary'])) {
|
||||
@@ -28,11 +28,7 @@ function _text_devel_generate($object, $field, $instance, $bundle) {
|
||||
}
|
||||
else {
|
||||
// Textfield handling.
|
||||
// Generate a value that respects max_length.
|
||||
if (empty($field['settings']['max_length'])) {
|
||||
$field['settings']['max_length'] = 12;
|
||||
}
|
||||
$object_field['value'] = user_password($field['settings']['max_length']);
|
||||
$object_field['value'] = substr(devel_create_greeking(mt_rand(1, $field['settings']['max_length'] / 6), FALSE), 0, $field['settings']['max_length']);
|
||||
}
|
||||
$object_field['format'] = $format;
|
||||
return $object_field;
|
||||
|
@@ -7,7 +7,7 @@ Drupal.behaviors.devel = {
|
||||
attach: function (context, settings) {
|
||||
|
||||
// Add hint to footnote
|
||||
$('.krumo-footnote .krumo-call').before('<img style="vertical-align: middle;" title="Click to expand. Double-click to show path." src="' + Drupal.settings.basePath + 'misc/help.png"/>');
|
||||
$('.krumo-footnote .krumo-call').once().before('<img style="vertical-align: middle;" title="Click to expand. Double-click to show path." src="' + settings.basePath + 'misc/help.png"/>');
|
||||
|
||||
var krumo_name = [];
|
||||
var krumo_type = [];
|
||||
|
@@ -6,9 +6,9 @@ core = 7.x
|
||||
configure = admin/config/development/devel
|
||||
tags[] = developer
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-06-05
|
||||
version = "7.x-1.3"
|
||||
; Information added by Drupal.org packaging script on 2014-05-01
|
||||
version = "7.x-1.5"
|
||||
core = "7.x"
|
||||
project = "devel"
|
||||
datestamp = "1338940281"
|
||||
datestamp = "1398963366"
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
/**
|
||||
* Perform the access by user ajax request.
|
||||
*/
|
||||
function devel_node_access_user_ajax(context) {
|
||||
function devel_node_access_user_ajax(context, settings) {
|
||||
// Get the cell ID for the first .dna-permission that isn't processed.
|
||||
var cell = $('td.dna-permission', context)
|
||||
.not('.ajax-processed', context)
|
||||
@@ -15,7 +15,7 @@
|
||||
if (cell !== undefined) {
|
||||
// Generate the URI from the basePath, path, data type, cell ID, and a
|
||||
// random token to bypass caching.
|
||||
var url = Drupal.settings.basePath
|
||||
var url = settings.basePath
|
||||
+ "?q="
|
||||
+ 'devel/node_access/by_user/json/'
|
||||
+ cell
|
||||
@@ -25,7 +25,7 @@
|
||||
$.getJSON(url, function(data) {
|
||||
$('#' + cell, context).html(data).addClass('ajax-processed');
|
||||
// Call this function again.
|
||||
devel_node_access_user_ajax(context);
|
||||
devel_node_access_user_ajax(context, settings);
|
||||
});
|
||||
// Ajax fails silently on error, mark bad requests with an error message.
|
||||
// If the request is just slow this will update when the request succeeds.
|
||||
@@ -42,7 +42,7 @@
|
||||
)
|
||||
.addClass('ajax-processed');
|
||||
// Call this function again.
|
||||
devel_node_access_user_ajax(context);
|
||||
devel_node_access_user_ajax(context, settings);
|
||||
}
|
||||
},
|
||||
3000
|
||||
@@ -55,10 +55,10 @@
|
||||
* Attach the access by user behavior which initiates ajax.
|
||||
*/
|
||||
Drupal.behaviors.develNodeAccessUserAjax = {
|
||||
attach: function(context) {
|
||||
attach: function(context, settings) {
|
||||
// Start the ajax.
|
||||
devel_node_access_user_ajax(context);
|
||||
devel_node_access_user_ajax(context, settings);
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
@@ -226,9 +226,13 @@ function dna_visible_nodes($nid = NULL) {
|
||||
if ($nid) {
|
||||
$nids[$nid] = $nid;
|
||||
}
|
||||
elseif (empty($nids) && arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL) {
|
||||
// show DNA information on node/NID even if access is denied (IF the user has the 'view devel_node_access information' permission)!
|
||||
return array(arg(1));
|
||||
elseif (empty($nids)) {
|
||||
$menu_item = menu_get_item();
|
||||
$map = $menu_item['original_map'];
|
||||
if ($map[0] == 'node' && isset($map[1]) && is_numeric($map[1]) && !isset($map[2])) {
|
||||
// show DNA information on node/NID even if access is denied (IF the user has the 'view devel_node_access information' permission)!
|
||||
return array($map[1]);
|
||||
}
|
||||
}
|
||||
return $nids;
|
||||
}
|
||||
@@ -368,6 +372,7 @@ function _devel_node_access_nar_alter(&$grants, $node) {
|
||||
}
|
||||
else {
|
||||
// it's an existing grant, check for changes
|
||||
$view = $update = $delete = FALSE;
|
||||
foreach (array('view', 'update', 'delete') as $op) {
|
||||
$$op = $grant["grant_$op"] - $data[$grant['realm']][$grant['gid']]['current']["grant_$op"];
|
||||
}
|
||||
@@ -496,6 +501,7 @@ function devel_node_access_block_info() {
|
||||
$blocks['dna_user'] = array(
|
||||
'info' => t('Devel Node Access by User'),
|
||||
'region' => 'footer',
|
||||
'status' => 0,
|
||||
'cache' => DRUPAL_NO_CACHE,
|
||||
);
|
||||
return $blocks;
|
||||
@@ -645,7 +651,7 @@ function devel_node_access_block_view($delta) {
|
||||
foreach (array('view', 'update', 'delete') as $op) {
|
||||
$grants = _devel_node_access_module_invoke_all('node_grants', $user, $op);
|
||||
// call all hook_node_grants_alter() implementations
|
||||
$ng_alter_data = _devel_node_access_ng_alter($grants, $user, $op);
|
||||
$ng_alter_datas[$op] = _devel_node_access_ng_alter($grants, $user, $op);
|
||||
$checked_grants[$nid][$op] = array_merge(array('all' => array(0)), $grants);
|
||||
}
|
||||
}
|
||||
@@ -788,7 +794,15 @@ function devel_node_access_block_view($delta) {
|
||||
'data' => '<a href="#node-' . $grant['nid'] . '">' . $row['nid'] . '</a>',
|
||||
'title' => $grant['#title'],
|
||||
);
|
||||
$row['realm'] = (empty($grant['#module']) || strpos($grant['realm'], $grant['#module']) === 0 ? '' : $grant['#module'] . ':<br />') . $grant['realm'];
|
||||
if (empty($grant['#module']) || strpos($grant['realm'], $grant['#module']) === 0) {
|
||||
$row['realm'] = $grant['realm'];
|
||||
}
|
||||
else {
|
||||
$row['realm'] = array(
|
||||
'data' => $grant['#module'] . ':<br />' . $grant['realm'],
|
||||
'title' => t("The '@module' module fails to adhere to the best practice of naming its realm(s) after itself.", array('@module' => $grant['#module'])),
|
||||
);
|
||||
}
|
||||
|
||||
// prepend information from the D7 hook_node_access_records_alter()
|
||||
$next_style = array();
|
||||
@@ -906,7 +920,7 @@ function devel_node_access_block_view($delta) {
|
||||
);
|
||||
}
|
||||
else {
|
||||
$variables['!list'] = '<div style="margin-left: 2em">' . _devel_node_access_get_grant_list($nid, $ng_alter_data) . '</div>';
|
||||
$variables['!list'] = '<div style="margin-left: 2em">' . _devel_node_access_get_grant_list($nid, $ng_alter_datas['view']) . '</div>';
|
||||
$variables['%access'] = 'view';
|
||||
$output[] = array(
|
||||
'#prefix' => "\n<div style='text-align: left' title='" . t('These are the grants returned by hook_node_grants() for this user.') . "'>",
|
||||
@@ -915,7 +929,10 @@ function devel_node_access_block_view($delta) {
|
||||
);
|
||||
$accounts[] = $user;
|
||||
}
|
||||
if (arg(0) == 'node' && is_numeric(arg(1)) && !$block1_visible) { // only for single nodes
|
||||
$menu_item = menu_get_item();
|
||||
$map = $menu_item['original_map'];
|
||||
if ($map[0] == 'node' && isset($map[1]) && is_numeric($map[1]) && !isset($map[2]) && !$block1_visible) {
|
||||
// only for single nodes
|
||||
if (user_is_logged_in()) {
|
||||
$accounts[] = user_load(0); // Anonymous, too
|
||||
}
|
||||
@@ -948,10 +965,11 @@ function devel_node_access_block_view($delta) {
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
}
|
||||
$variables['!username'] = theme('username', array('account' => $account));
|
||||
$variables['!username'] = '<em class="placeholder">' . theme('username', array('account' => $account)) . '</em>';
|
||||
$output[] = array(
|
||||
'#prefix' => "\n<div style='text-align: left'>",
|
||||
'#markup' => t("!username has the following access", $variables),
|
||||
'#type' => 'item',
|
||||
'lead-in' => array('#markup' => t("!username has the following access", $variables) . ' '),
|
||||
'items' => $account_items,
|
||||
'#suffix' => "\n</div>\n",
|
||||
);
|
||||
@@ -971,9 +989,28 @@ function devel_node_access_block_view($delta) {
|
||||
|
||||
case 'dna_user':
|
||||
// show which users can access this node
|
||||
if (arg(0) == 'node' && is_numeric($nid = arg(1)) && arg(2) == NULL && $node = node_load($nid)) {
|
||||
$menu_item = menu_get_item();
|
||||
$map = $menu_item['original_map'];
|
||||
if ($map[0] != 'node' || !isset($map[1]) || !is_numeric($map[1]) || isset($map[2])) {
|
||||
// Ignore anything but node/%.
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($menu_item['map'][1]) && is_object($node = $menu_item['map'][1])) {
|
||||
// We have the node.
|
||||
}
|
||||
elseif (is_numeric($menu_item['original_map'][1])) {
|
||||
$node = node_load($menu_item['original_map'][1]);
|
||||
}
|
||||
if (isset($node)) {
|
||||
$nid = $node->nid;
|
||||
$node_type = node_type_get_type($node);
|
||||
$headers = array(t('username'), '<span title="' . t("Create nodes of the '@Node_type' type.", array('@Node_type' => $node_type->name)) . '">' . t('create') . '</span>', t('view'), t('update'), t('delete'));
|
||||
$variables = array('@Node_type' => ($node_type ? $node_type->name : $node->type));
|
||||
$create_header = '<span title="' . t("Create nodes of the '@Node_type' type.", $variables) . '">' . t('create') . '</span>';
|
||||
if (!$node_type) {
|
||||
$create_header .= '<br /><span class="error">' . t("(missing type: '@Node_type')", $variables) . '</span>';
|
||||
}
|
||||
$headers = array(t('username'), $create_header, t('view'), t('update'), t('delete'));
|
||||
$rows = array();
|
||||
// Determine whether to use Ajax or prepopulate the tables.
|
||||
if ($ajax = variable_get('devel_node_access_user_ajax', FALSE)) {
|
||||
|
@@ -604,7 +604,8 @@ This is a list of all the values from the <code><b><?php echo realpath($ini_file
|
||||
$_recursion_marker = krumo::_marker();
|
||||
if ($hive =& krumo::_hive($dummy)) {
|
||||
foreach($hive as $i=>$bee){
|
||||
if (is_object($bee)) {
|
||||
// skip closures set as properties
|
||||
if (is_object($bee) && !($bee instanceof Closure)) {
|
||||
unset($hive[$i]->$_recursion_marker);
|
||||
// DEVEL: changed 'else' to 'elseif' below
|
||||
} elseif (is_array($bee)) {
|
||||
|
22
sites/all/modules/contrib/dev/devel/runtests.sh
Normal file
22
sites/all/modules/contrib/dev/devel/runtests.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# This script will run phpunit-based test classes using Drush's
|
||||
# test framework. First, the Drush executable is located, and
|
||||
# then phpunit is invoked, passing in drush_testcase.inc as
|
||||
# the bootstrap file.
|
||||
#
|
||||
# Any parameters that may be passed to phpunit may also be used
|
||||
# with runtests.sh.
|
||||
|
||||
DRUSH_PATH="`which drush`"
|
||||
DRUSH_DIRNAME="`dirname -- "$DRUSH_PATH"`"
|
||||
|
||||
# if [ $# = 0 ] ; then
|
||||
# phpunit --bootstrap="$DRUSH_DIRNAME/tests/drush_testcase.inc" .
|
||||
# else
|
||||
# phpunit --bootstrap="$DRUSH_DIRNAME/tests/drush_testcase.inc" "$@"
|
||||
# fi
|
||||
|
||||
#Instead, hard code target file so we don't find a simpletest file at
|
||||
# /lib/Drupal/devel_generate/Tests/DevelGenerateTest.php.
|
||||
phpunit --bootstrap="$DRUSH_DIRNAME/tests/drush_testcase.inc" develDrushTest.php
|
Reference in New Issue
Block a user