├── LICENSE.txt ├── README.md ├── config └── devel.settings.json ├── devel.admin.inc ├── devel.css ├── devel.drush.inc ├── devel.info ├── devel.install ├── devel.js ├── devel.mail.inc ├── devel.module ├── devel.pages.inc ├── devel.rules.inc ├── devel.test ├── develDrushTest.php ├── devel_generate ├── devel_generate.drush.inc ├── devel_generate.fields.inc ├── devel_generate.inc ├── devel_generate.info ├── devel_generate.module ├── devel_generate.pages.inc ├── devel_generate_batch.inc └── modules │ ├── date.devel_generate.inc │ ├── entityreference.devel_generate.inc │ ├── file.devel_generate.inc │ ├── image.devel_generate.inc │ ├── link.devel_generate.inc │ ├── list.devel_generate.inc │ ├── number.devel_generate.inc │ ├── taxonomy.devel_generate.inc │ └── text.devel_generate.inc ├── devel_krumo.css ├── devel_krumo.js ├── devel_node_access ├── README.md ├── devel_node_access.api.php ├── devel_node_access.info ├── devel_node_access.install ├── devel_node_access.js └── devel_node_access.module └── lib ├── chromephp └── ChromePhp.php ├── firephp ├── FirePHP.class.php └── fb.php └── krumo ├── INSTALL ├── LICENSE ├── README ├── TODO ├── VERSION ├── class.krumo.php ├── docs ├── Krumo │ ├── _class.krumo.php.html │ └── krumo.html ├── blank.html ├── classtrees_Krumo.html ├── elementindex.html ├── elementindex_Krumo.html ├── errors.html ├── index.html ├── li_Krumo.html ├── media │ ├── banner.css │ ├── images │ │ ├── AbstractClass.png │ │ ├── AbstractClass_logo.png │ │ ├── AbstractMethod.png │ │ ├── AbstractPrivateClass.png │ │ ├── AbstractPrivateClass_logo.png │ │ ├── AbstractPrivateMethod.png │ │ ├── Class.png │ │ ├── Class_logo.png │ │ ├── Constant.png │ │ ├── Constructor.png │ │ ├── Destructor.png │ │ ├── Function.png │ │ ├── Global.png │ │ ├── I.png │ │ ├── Index.png │ │ ├── Interface.png │ │ ├── Interface_logo.png │ │ ├── L.png │ │ ├── Lminus.png │ │ ├── Lplus.png │ │ ├── Method.png │ │ ├── Page.png │ │ ├── Page_logo.png │ │ ├── PrivateClass.png │ │ ├── PrivateClass_logo.png │ │ ├── PrivateMethod.png │ │ ├── PrivateVariable.png │ │ ├── StaticMethod.png │ │ ├── StaticVariable.png │ │ ├── T.png │ │ ├── Tminus.png │ │ ├── Tplus.png │ │ ├── Variable.png │ │ ├── blank.png │ │ ├── class_folder.png │ │ ├── empty.png │ │ ├── file.png │ │ ├── folder.png │ │ ├── function_folder.png │ │ ├── minus.gif │ │ ├── next_button.png │ │ ├── next_button_disabled.png │ │ ├── package.png │ │ ├── package_folder.png │ │ ├── plus.gif │ │ ├── previous_button.png │ │ ├── previous_button_disabled.png │ │ ├── private_class_logo.png │ │ ├── tutorial.png │ │ ├── tutorial_folder.png │ │ └── up_button.png │ ├── lib │ │ └── classTree.js │ └── stylesheet.css ├── packages.html ├── ric_INSTALL.html ├── ric_LICENSE.html ├── ric_README.html ├── ric_TODO.html └── ric_VERSION.html ├── krumo.ini ├── krumo.js └── skins ├── blue ├── bg.gif └── skin.css ├── default ├── bg.gif └── skin.css ├── green ├── bg.gif └── skin.css ├── orange ├── bg.gif └── skin.css └── white ├── collapsed.gif ├── dotted.gif ├── empty.gif ├── expanded.gif └── skin.css /README.md: -------------------------------------------------------------------------------- 1 | Developer Tools (devel) 2 | ======================= 3 | 4 | This module contains helper functions for Backdrop developers. It provides a 5 | wide array of tools for examining the functionality of your site, including: 6 | 7 | - Displaying a list of all SQL queries executed per page. 8 | - Integrating with XHProf to show what PHP was executed and identify slow calls. 9 | - Executing arbitrary PHP. 10 | - Switch between different users. 11 | - Report memory usage at the bottom of each page. 12 | - A mail-system class which redirects outbound email to files. 13 | - Utility functions for dumping variables to the page or messages area. 14 | 15 | Although the abilities of this module are restricted to a permission 16 | ('access development information'), it's a good idea not to have this module 17 | enabled on production servers due to its exceedingly dangerous functionality. 18 | 19 | The most common functions for dumping variables include: 20 | 21 | - `dpr()`: Prints a variable using `print_r()` to the messages area. 22 | - `dpm()`: Prints a variable using the krumo library to the messages area. 23 | - `dvm()`: Prints a variable using `var_export()` to the messages area. 24 | 25 | All of these functions will only show the messages to users that have the 26 | 'access development information' permission. 27 | 28 | Included in this package is also: 29 | 30 | - devel_node_access module which prints out the node_access records for a given node. Also offers hook_node_access_explain for all node access modules to implement. Handy. 31 | - devel_generate.module which bulk creates nodes, users, comment, terms for development. 32 | 33 | License 34 | ------- 35 | 36 | This project is GPL v2 software. See the LICENSE.txt file in this directory for 37 | complete text. 38 | 39 | Maintainers 40 | ----------- 41 | 42 | - Nate Haug (https://github.com/quicksketch/) 43 | - Jen Lampton (https://github.com/jenlampton) 44 | - Alan Mels (https://github.com/alanmels) 45 | 46 | Originally written for Drupal by 47 | 48 | - Moshe Weitzman (https://www.drupal.org/u/moshe-weitzman) 49 | - Hans Salvisberg (https://www.drupal.org/u/salvis) 50 | 51 | This module is seeking additional maintainers. 52 | -------------------------------------------------------------------------------- /config/devel.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "_config_name": "devel.settings", 3 | "_config_static": true, 4 | "query_display": null, 5 | "query_sort": "source", 6 | "query_slow_limit": 5, 7 | "api_url": "api.backdropcms.org", 8 | "timer_display": false, 9 | "memory_display": false, 10 | "redirect_page": false, 11 | "permission_raw_names": false, 12 | "error_handlers": [ 13 | "standard" 14 | ], 15 | "debug_mail_file_format": "%to-%subject-%datetime.mail.txt", 16 | "debug_mail_directory": "temporary://devel-mails" 17 | } 18 | -------------------------------------------------------------------------------- /devel.admin.inc: -------------------------------------------------------------------------------- 1 | 'fieldset', 18 | '#title' => t('Query logging'), 19 | ); 20 | 21 | $description = t('Display a log of the database queries needed to generate the current page, and the execution time for each. Also, queries which are repeated during a single page view are summed in the # column, and printed in red since they are candidates for caching.'); 22 | $form['queries']['query_display'] = array( 23 | '#type' => 'checkbox', 24 | '#title' => t('Display query log'), 25 | '#default_value' => $config->get('query_display', 0), 26 | '#description' => $description, 27 | ); 28 | $form['queries']['settings'] = array( 29 | '#type' => 'container', 30 | '#states' => array( 31 | // Hide the query log settings when not displaying query log. 32 | 'invisible' => array( 33 | 'input[name="query_display"]' => array('checked' => FALSE), 34 | ), 35 | ), 36 | ); 37 | $form['queries']['settings']['show_query_args_first'] = array( 38 | '#type' => 'checkbox', 39 | '#title' => t('Show query arguments'), 40 | '#default_value' => $config->get('show_query_args_first'), 41 | '#description' => t('Show arguments rather than the query placeholders in the logged query.'), 42 | ); 43 | $form['queries']['settings']['query_sort'] = array( 44 | '#type' => 'radios', 45 | '#title' => t('Sort query log'), 46 | '#default_value' => $config->get('query_sort', DEVEL_QUERY_SORT_BY_SOURCE), 47 | '#options' => array( 48 | DEVEL_QUERY_SORT_BY_SOURCE => t('by source'), 49 | DEVEL_QUERY_SORT_BY_DURATION => t('by duration') 50 | ), 51 | '#description' => t('The query table can be sorted in the order that the queries were executed or by descending duration.'), 52 | ); 53 | $form['queries']['settings']['query_slow_limit'] = array('#type' => 'textfield', 54 | '#title' => t('Slow query highlighting'), 55 | '#default_value' => $config->get('query_slow_limit'), 56 | '#size' => 4, 57 | '#maxlength' => 4, 58 | '#description' => t('Enter an integer in milliseconds. Any query which takes longer than this many milliseconds will be highlighted in the query log. This indicates a possibly inefficient query, or a candidate for caching.'), 59 | ); 60 | 61 | $form['performance'] = array( 62 | '#type' => 'fieldset', 63 | '#title' => t('Performance logging'), 64 | '#collapsible' => FALSE, 65 | ); 66 | $form['performance']['timer_display'] = array('#type' => 'checkbox', 67 | '#title' => t('Display page timer'), 68 | '#default_value' => $config->get('timer_display'), 69 | '#description' => t('Display page execution time in the query log box.'), 70 | ); 71 | $form['performance']['memory_display'] = array( 72 | '#type' => 'checkbox', 73 | '#title' => t('Display memory usage'), 74 | '#default_value' => $config->get('memory_display'), 75 | '#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.'), 76 | ); 77 | $form['performance']['redirect_page'] = array( 78 | '#type' => 'checkbox', 79 | '#title' => t('Display redirection page'), 80 | '#default_value' => $config->get('redirect_page'), 81 | '#description' => t('When a module executes backdrop_goto(), the query log and other developer information is lost. Enabling this setting presents an intermediate page to developers so that the log can be examined before continuing to the destination page.'), 82 | ); 83 | 84 | $form['theme'] = array( 85 | '#type' => 'fieldset', 86 | '#title' => t('Theming tools'), 87 | '#collapsible' => FALSE, 88 | ); 89 | $form['theme']['theme_debug'] = array( 90 | '#type' => 'checkbox', 91 | '#title' => t('Enable theme debug'), 92 | '#default_value' => config_get('system.core', 'theme_debug'), 93 | '#description' => t('Adds HTML comments containing information about the template files used to render each part of the page. Useful for finding template suggestions when building a custom theme.'), 94 | ); 95 | $form['theme']['rebuild_theme_registry'] = array( 96 | '#type' => 'checkbox', 97 | '#title' => t('Rebuild the theme registry on every page load'), 98 | '#description' => t('While creating new templates and theme_ overrides the theme registry needs to be rebuilt.'), 99 | '#default_value' => $config->get('rebuild_theme_registry'), 100 | ); 101 | 102 | $form['errors'] = array( 103 | '#type' => 'fieldset', 104 | '#title' => t('Error handling'), 105 | '#collapsible' => FALSE, 106 | ); 107 | 108 | $enabled_levels = config_get('system.core', 'watchdog_enabled_severity_levels'); 109 | if (is_array($enabled_levels)) { 110 | $form['errors']['watchdog_enabled_severity_levels'] = array( 111 | '#type' => 'checkboxes', 112 | '#title' => t('Enabled watchdog severity levels'), 113 | '#options' => watchdog_severity_levels(), 114 | '#default_value' => $enabled_levels, 115 | '#description' => t('Only messages with the enabled severity levels will be logged. The "debug" and "deprecated" levels are recommended for developer environments, but not on production sites.'), 116 | ); 117 | } 118 | 119 | $error_handlers = devel_get_handlers(); 120 | $form['errors']['devel_error_handlers'] = array( 121 | '#type' => 'select', 122 | '#title' => t('Error handlers'), 123 | '#options' => array( 124 | DEVEL_ERROR_HANDLER_NONE => t('None'), 125 | DEVEL_ERROR_HANDLER_STANDARD => t('Standard Backdrop'), 126 | DEVEL_ERROR_HANDLER_BACKTRACE_DPM => t('Krumo backtrace in the message area'), 127 | DEVEL_ERROR_HANDLER_BACKTRACE_KRUMO => t('Krumo backtrace above the rendered page'), 128 | ), 129 | '#multiple' => TRUE, 130 | '#default_value' => empty($error_handlers) ? DEVEL_ERROR_HANDLER_STANDARD : $error_handlers, 131 | '#description' => t('Select the error handler(s) to use, in case you choose to show errors on screen.', array('@choose' => url('admin/config/development/logging'))) . '
hook_uninstall()
and hook_install()
will be executed and the schema version number will be set to the most recent update number. You may have to manually clear out any existing tables first if the module doesn\'t implement hook_uninstall()
.'),
124 | );
125 | $form['submit'] = array(
126 | '#value' => t('Reinstall'),
127 | '#type' => 'submit',
128 | );
129 | return $form;
130 | }
131 |
132 | /**
133 | * Form submission callback for devel_reinstall().
134 | */
135 | function devel_reinstall_submit($form, &$form_state) {
136 | // require_once './includes/install.inc';
137 | $modules = array_filter($form_state['values']['list']);
138 | module_disable($modules, FALSE);
139 | backdrop_uninstall_modules($modules, FALSE);
140 | module_enable($modules, FALSE);
141 | backdrop_set_message(t('Uninstalled and installed: %names.', array('%names' => implode(', ', $modules))));
142 | }
143 |
144 | /**
145 | * Page callback: Rebuilds the theme registry.
146 | */
147 | function devel_theme_registry() {
148 | backdrop_theme_initialize();
149 | $hooks = theme_get_registry();
150 | ksort($hooks);
151 | return kprint_r($hooks, TRUE);
152 | }
153 |
154 | /**
155 | * Page callback: Returns information from hook_entity_info().
156 | *
157 | * @param string $entity_type
158 | * (optional) Limit results to the specified entity type. The default is to
159 | * return information about all entity types. The $entity_type argument is not
160 | * currently used in the UI.
161 | *
162 | * @return
163 | * The results from kprint_r().
164 | */
165 | function devel_entity_info_page($entity_type = NULL) {
166 | $info = entity_get_info($entity_type);
167 | ksort($info);
168 | return kprint_r($info, TRUE);
169 | }
170 |
171 | /**
172 | * Page callback: Returns information about fields.
173 | */
174 | function devel_field_info_page() {
175 | $info = field_info_fields();
176 | $output = kprint_r($info, TRUE, t('Fields'));
177 | $info = field_info_instances();
178 | $output .= kprint_r($info, TRUE, t('Instances'));
179 | $info = field_info_bundles();
180 | $output .= kprint_r($info, TRUE, t('Bundles'));
181 | return $output;
182 | }
183 |
184 | /**
185 | * Page callback: Displays the session.
186 | */
187 | function devel_session() {
188 | global $user;
189 | $output = kprint_r($_SESSION, TRUE);
190 | $headers = array(t('Session name'), t('Session ID'));
191 | $output .= theme('table', array('headers' => $headers, 'rows' => array(array(session_name(), session_id()))));
192 | return $output;
193 | }
194 |
195 | /**
196 | * Page callback: Prints the loaded structure of the current node/user.
197 | */
198 | function devel_load_object($type, $object, $name = NULL) {
199 | $name = isset($name) ? $name : $type;
200 | return kdevel_print_object($object, '$'. $name .'->');
201 | }
202 |
203 | /**
204 | * Page callback: Prints the render structure of the current object.
205 | *
206 | * @param string $type
207 | * The type of entity that will be displayed.
208 | * @param object $object
209 | * The entity to display.
210 | * @param string $name
211 | * (optional) The label to use when displaying the entity.
212 | *
213 | * @return
214 | * The results from kdevel_print_object().
215 | */
216 | function devel_render_object($type, $object, $name = NULL) {
217 | $name = isset($name) ? $name : $type;
218 | $function = $type . '_view';
219 |
220 | switch ($function) {
221 | case 'comment_view':
222 | $node = node_load($object->nid);
223 | $build = $function($object, $node);
224 | break;
225 |
226 | default:
227 | $build = $function($object);
228 | }
229 |
230 | return kdevel_print_object($build, '$'. $name .'->');
231 | }
232 |
233 | /**
234 | * Page callback: Returns information from hook_elements().
235 | */
236 | function devel_elements_page() {
237 | return kdevel_print_object(module_invoke_all('element_info'));
238 | }
239 |
240 | /**
241 | * Page callback: Returns the results from phpinfo().
242 | */
243 | function devel_phpinfo() {
244 | print phpinfo();
245 | backdrop_exit();
246 | }
247 |
--------------------------------------------------------------------------------
/devel.rules.inc:
--------------------------------------------------------------------------------
1 | array(
14 | 'base' => 'devel_rules_debug_action',
15 | 'label' => t('Debug value'),
16 | 'group' => t('Devel'),
17 | 'parameter' => array(
18 | 'value' => array('type' => 'unknown', 'label' => t('Value to debug')),
19 | ),
20 | ),
21 | );
22 | }
23 |
24 | /**
25 | * Rules action for debugging values.
26 | */
27 | function devel_rules_debug_action($value) {
28 | dpm($value);
29 | }
30 |
--------------------------------------------------------------------------------
/devel.test:
--------------------------------------------------------------------------------
1 | 'Devel Mail interface',
20 | 'description' => 'Test sending mails with debug interface',
21 | 'group' => 'Devel',
22 | );
23 | }
24 |
25 | /**
26 | * {@inheritdoc}
27 | */
28 | function setUp() {
29 | parent::setUp();
30 | }
31 |
32 | /**
33 | * Test mail logging functionality.
34 | */
35 | function testMail() {
36 | $path = backdrop_get_path('module', 'devel_generate');
37 | require_once BACKDROP_ROOT . '/' . $path . '/devel.mail.inc';
38 | $message = array();
39 | $message['to'] = 'drupal@example.com';
40 | $message['subject'] = 'Test mail';
41 | $message['headers'] = array(
42 | 'From' => 'postmaster@example.com',
43 | 'X-stupid' => 'dumb',
44 | );
45 | $message['body'] = "I am the body of this message";
46 | $d = new DevelMailLog();
47 |
48 | $filename = $d->getFileName($message);
49 | $content = $d->composeMessage($message);
50 | $expected_filename = $d->getOutputDirectory() . '/drupal@example.com-Test_mail-' . date('y-m-d_his') . '.mail.txt';
51 | $this->assertEqual($filename, $expected_filename);
52 | $this->assertEqual($content, 'From: postmaster@example.com
53 | X-stupid: dumb
54 | To: drupal@example.com
55 | Test mail
56 | I am the body of this message');
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/develDrushTest.php:
--------------------------------------------------------------------------------
1 | setUpDrupal(1, TRUE);
26 | $options = array(
27 | 'root' => $this->webroot(),
28 | 'uri' => key($sites),
29 | );
30 | $this->drush('pm-download', array('devel'), $options + array('cache' => NULL));
31 | $this->drush('pm-enable', array('devel'), $options + array('skip' => NULL, 'yes' => NULL));
32 |
33 | $this->drush('fn-view', array('drush_main'), $options);
34 | $output = $this->getOutput();
35 | $this->assertContains('@return', $output, 'Output contain @return Doxygen.');
36 | $this->assertContains('function drush_main() {', $output, 'Output contains function drush_main() declaration');
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/devel_generate/devel_generate.drush.inc:
--------------------------------------------------------------------------------
1 | 'Create users.',
14 | 'arguments' => array(
15 | 'number_users' => 'Number of users to generate.',
16 | ),
17 | 'options' => array(
18 | 'kill' => 'Delete all users before generating new ones.',
19 | 'roles' => 'A comma delimited list of role IDs which should be granted to the new users. No need to specify authenticated user role.',
20 | 'pass' => 'Specify a password to be set for all generated users.',
21 | ),
22 | 'aliases' => array('genu'),
23 | );
24 | $items['generate-terms'] = array(
25 | 'description' => 'Create terms in specified vocabulary.',
26 | 'arguments' => array(
27 | 'machine_name' => 'Vocabulary machine name into which new terms will be inserted.',
28 | 'number_terms' => 'Number of terms to insert. Defaults to 10.',
29 | ),
30 | 'options' => array(
31 | 'kill' => 'Delete all terms in specified vocabulary before generating.',
32 | 'feedback' => 'An integer representing interval for insertion rate logging. Defaults to 500',
33 | ),
34 | 'aliases' => array('gent'),
35 |
36 | );
37 | $items['generate-vocabs'] = array(
38 | 'description' => 'Create vocabularies.',
39 | 'arguments' => array(
40 | 'num_vocabs' => 'Number of vocabularies to create. Defaults to 1.',
41 | ),
42 | 'options' => array(
43 | 'kill' => 'Delete all vocabularies before generating.',
44 | ),
45 | 'aliases' => array('genv'),
46 | );
47 | $items['generate-content'] = array(
48 | 'description' => 'Create content.',
49 | 'drupal dependencies' => array('devel_generate'),
50 | 'arguments' => array(
51 | 'number_nodes' => 'Number of nodes to generate.',
52 | 'maximum_comments' => 'Maximum number of comments to generate.',
53 | ),
54 | 'options' => array(
55 | 'kill' => 'Delete all content before generating new content.',
56 | 'types' => 'A comma delimited list of content types to create. Defaults to page,post.',
57 | 'feedback' => 'An integer representing interval for insertion rate logging. Defaults to 500',
58 | 'skip-fields' => 'A comma delimited list of fields to omit when generating random values',
59 | 'languages' => 'A comma-separated list of language codes',
60 | ),
61 | 'aliases' => array('genc'),
62 | );
63 | $items['generate-menus'] = array(
64 | 'description' => 'Create menus and menu items.',
65 | 'drupal dependencies' => array('devel_generate'), // Remove these once devel.module is moved down a directory. http://drupal.org/node/925246
66 | 'arguments' => array(
67 | 'number_menus' => 'Number of menus to generate. Defaults to 2.',
68 | 'number_links' => 'Number of links to generate. Defaults to 50.',
69 | 'max_depth' => 'Max link depth. Defaults to 3',
70 | 'max_width' => 'Max width of first level of links. Defaults to 8.',
71 | ),
72 | 'options' => array(
73 | 'kill' => 'Delete all previously generated menus and links before generating new menus and links.',
74 | ),
75 | 'aliases' => array('genm'),
76 | );
77 | return $items;
78 | }
79 |
80 |
81 | /**
82 | * Command callback. Generate a number of users.
83 | */
84 | function drush_devel_generate_users($num_users = NULL) {
85 | if (drush_generate_is_number($num_users) == FALSE) {
86 | return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', t('Invalid number of users.'));
87 | }
88 | drush_generate_include_devel();
89 | $roles = drush_get_option('roles') ? explode(',', drush_get_option('roles')) : array();
90 | $pass = drush_get_option('pass', NULL);
91 | devel_create_users($num_users, drush_get_option('kill'), 0, $roles, $pass);
92 | drush_log(t('Generated @number users.', array('@number' => $num_users)), 'success');
93 | }
94 |
95 | /**
96 | * Command callback. Generate a number of terms in given vocabs.
97 | */
98 | function drush_devel_generate_terms($vname = NULL, $num_terms = 10) {
99 | // Try to convert machine name to a vocab ID
100 | if (!$vocab = taxonomy_vocabulary_load($vname)) {
101 | return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid vocabulary name: !name', array('!name' => $vname)));
102 | }
103 | if (drush_generate_is_number($num_terms) == FALSE) {
104 | return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of terms: !num', array('!num' => $num_terms)));
105 | }
106 |
107 | drush_generate_include_devel();
108 | $vocabs[$vocab->machine_name] = $vocab;
109 | devel_generate_term_data($vocabs, $num_terms, '12', drush_get_option('kill'));
110 | drush_log(dt('Generated @num_terms terms.', array('@num_terms' => $num_terms)), 'success');
111 | }
112 |
113 | /**
114 | * Command callback. Generate a number of vocabularies.
115 | */
116 | function drush_devel_generate_vocabs($num_vocab = 1) {
117 | if (drush_generate_is_number($num_vocab) == FALSE) {
118 | return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of vocabularies: !num.', array('!num' => $num_vocab)));
119 | }
120 | drush_generate_include_devel();
121 | devel_generate_vocab_data($num_vocab, '12', drush_get_option('kill'));
122 | drush_log(dt('Generated @num_vocab vocabularies.', array('@num_vocab' => $num_vocab)), 'success');
123 | }
124 |
125 | /**
126 | * Command callback. Generate a number of nodes and comments.
127 | */
128 | function drush_devel_generate_content($num_nodes = NULL, $max_comments = NULL) {
129 | if (drush_generate_is_number($num_nodes) == FALSE) {
130 | return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of nodes'));
131 | }
132 | if (!empty($max_comments) && drush_generate_is_number($max_comments) == FALSE) {
133 | return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of comments.'));
134 | }
135 |
136 | $add_language = drush_get_option('languages');
137 | if (!empty($add_language)) {
138 | $add_language = explode(',', str_replace(' ', '', $add_language));
139 | // Intersect with the enabled languages to make sure the language args
140 | // passed are actually enabled.
141 | $values['values']['add_language'] = array_intersect($add_language, array_keys(locale_language_list()));
142 | }
143 |
144 | // Load user 1; is needed for creating *published* comments.
145 | if ($max_comments) {
146 | global $user;
147 | $user_one = user_load(1);
148 | $user = $user_one;
149 | backdrop_save_session(FALSE);
150 | }
151 |
152 | $values['values']['kill_content'] = drush_get_option('kill');
153 | $values['values']['title_length'] = 6;
154 | $values['values']['num_nodes'] = $num_nodes;
155 | $values['values']['max_comments'] = $max_comments;
156 | $values['values']['node_types'] = backdrop_map_assoc(explode(',', drush_get_option('types', 'page,post')));
157 | drush_generate_include_devel();
158 | devel_generate_content($values);
159 | 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');
160 | }
161 |
162 | /**
163 | * Command callback. Generate a number of menus and menu links.
164 | */
165 | function drush_devel_generate_menus($number_menus = 2, $number_links = 50, $max_depth = 3, $max_width = 8) {
166 | if (drush_generate_is_number($number_menus) == FALSE) {
167 | return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of menus'));
168 | }
169 | if (drush_generate_is_number($number_links) == FALSE) {
170 | return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of links'));
171 | }
172 | if (drush_generate_is_number($max_depth) == FALSE || $max_depth > 9 || $max_depth < 1) {
173 | return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid maximum link depth. Use a value between 1 and 9'));
174 | }
175 | if (drush_generate_is_number($max_width) == FALSE || $max_width < 1) {
176 | return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid maximum menu width. Use a positive numeric value.'));
177 | }
178 |
179 | global $user;
180 | $user_one = user_load(1);
181 | $user = $user_one;
182 | backdrop_save_session(FALSE);
183 |
184 | $kill = drush_get_option('kill');
185 | drush_generate_include_devel();
186 | $link_types = backdrop_map_assoc(array('node', 'front', 'external'));
187 | devel_generate_menu_data($number_menus, array(), $number_links, 12, $link_types, $max_depth, $max_width, $kill);
188 | drush_log(t('Generated @number_menus menus, @number_links links.', array('@number_menus' => (int)$number_menus, '@number_links' => (int)$number_links)), 'success');
189 | }
190 | //////////////////////////////////////////////////////////////////////////////
191 | // Helper functions
192 |
193 | // Verify if param is a number.
194 | function drush_generate_is_number($number) {
195 | if ($number == NULL) return FALSE;
196 | if (!is_numeric($number)) return FALSE;
197 | return TRUE;
198 | }
199 |
200 | // Include devel_generate.inc.
201 | function drush_generate_include_devel() {
202 | $path = backdrop_get_path('module', 'devel_generate');
203 | require_once BACKDROP_ROOT . '/' . $path .'/devel_generate.inc';
204 | }
205 |
--------------------------------------------------------------------------------
/devel_generate/devel_generate.fields.inc:
--------------------------------------------------------------------------------
1 | {$field['field_name']}
66 | // is necessary here because the forum module has a bug where it
67 | // initializes the property with incorrect data.
68 | // @see http://drupal.org/node/652176
69 | $object->{$field['field_name']} = array(
70 | $field['translatable'] ? $object->language : LANGUAGE_NONE => $object_field,
71 | );
72 | }
73 | }
74 |
75 | /**
76 | * A simple function to return multiple values for fields that use
77 | * custom multiple value widgets but don't need any other special multiple
78 | * values handling. This will call the field generation function
79 | * a random number of times and compile the results into a node array.
80 | */
81 | function devel_generate_multiple($function, $object, $field, $instance, $bundle) {
82 | $object_field = array();
83 | if (function_exists($function)) {
84 | switch ($field['cardinality']) {
85 | case FIELD_CARDINALITY_UNLIMITED:
86 | $max = rand(0, 3); //just an arbitrary number for 'unlimited'
87 | break;
88 | default:
89 | $max = $field['cardinality'] - 1;
90 | break;
91 | }
92 | for ($i = 0; $i <= $max; $i++) {
93 | $result = $function($object, $field, $instance, $bundle);
94 | if (!empty($result)) {
95 | $object_field[$i] = $result;
96 | }
97 | }
98 | }
99 | return $object_field;
100 | }
101 |
--------------------------------------------------------------------------------
/devel_generate/devel_generate.info:
--------------------------------------------------------------------------------
1 | name = Devel Generate
2 | description = Generate dummy users, nodes, and taxonomy terms.
3 | package = Development
4 | backdrop = 1.x
5 | dependencies[] = devel
6 | configure = devel/generate
7 | type = module
8 |
--------------------------------------------------------------------------------
/devel_generate/devel_generate.module:
--------------------------------------------------------------------------------
1 | 'Generate content',
11 | 'description' => 'Generate sample content for theming and development purposes.',
12 | 'page callback' => 'backdrop_get_form',
13 | 'page arguments' => array('devel_generate_content_form'),
14 | 'access arguments' => array('administer nodes'),
15 | 'file' => 'devel_generate.pages.inc',
16 | );
17 |
18 | $items['admin/devel/generate/content'] = array(
19 | 'title' => 'Generate nodes',
20 | 'description' => 'Generate a given number of nodes and comments. Optionally delete current items.',
21 | 'page callback' => 'backdrop_get_form',
22 | 'page arguments' => array('devel_generate_content_form'),
23 | 'access arguments' => array('administer nodes'),
24 | 'type' => MENU_DEFAULT_LOCAL_TASK,
25 | 'file' => 'devel_generate.pages.inc',
26 | 'weight' => -1,
27 | );
28 | $items['admin/devel/generate/user'] = array(
29 | 'title' => 'Generate users',
30 | 'description' => 'Generate a given number of users. Optionally delete current users.',
31 | 'page callback' => 'backdrop_get_form',
32 | 'page arguments' => array('devel_generate_users_form'),
33 | 'access arguments' => array('administer users'),
34 | 'type' => MENU_LOCAL_TASK,
35 | 'file' => 'devel_generate.pages.inc',
36 | 'weight' => 1,
37 | );
38 | if (module_exists('taxonomy')) {
39 | $items['admin/devel/generate/taxonomy'] = array(
40 | 'title' => 'Generate terms',
41 | 'description' => 'Generate a given number of terms. Optionally delete current terms.',
42 | 'page callback' => 'backdrop_get_form',
43 | 'page arguments' => array('devel_generate_term_form'),
44 | 'access arguments' => array('administer taxonomy'),
45 | 'type' => MENU_LOCAL_TASK,
46 | 'file' => 'devel_generate.pages.inc',
47 | 'weight' => 2,
48 | );
49 | $items['admin/devel/generate/vocabs'] = array(
50 | 'title' => 'Generate vocabularies',
51 | 'description' => 'Generate a given number of vocabularies. Optionally delete current vocabularies.',
52 | 'page callback' => 'backdrop_get_form',
53 | 'page arguments' => array('devel_generate_vocab_form'),
54 | 'access arguments' => array('administer taxonomy'),
55 | 'type' => MENU_LOCAL_TASK,
56 | 'file' => 'devel_generate.pages.inc',
57 | 'weight' => 3,
58 | );
59 | }
60 | $items['admin/devel/generate/menu'] = array(
61 | 'title' => 'Generate menus',
62 | 'description' => 'Generate a given number of menus and menu links. Optionally delete current menus.',
63 | 'page callback' => 'backdrop_get_form',
64 | 'page arguments' => array('devel_generate_menu_form'),
65 | 'access arguments' => array('administer menu'),
66 | 'type' => MENU_LOCAL_TASK,
67 | 'file' => 'devel_generate.pages.inc',
68 | 'weight' => 4,
69 | );
70 |
71 | return $items;
72 | }
73 |
--------------------------------------------------------------------------------
/devel_generate/devel_generate.pages.inc:
--------------------------------------------------------------------------------
1 | 'number',
13 | '#title' => t('How many users would you like to generate?'),
14 | '#default_value' => 50,
15 | '#min' => 1,
16 | '#max' => 99999,
17 | );
18 | $form['kill_users'] = array(
19 | '#type' => 'checkbox',
20 | '#title' => t('Delete all users (except user id 1) before generating new users.'),
21 | '#default_value' => FALSE,
22 | );
23 | $options = user_roles(TRUE);
24 | unset($options[BACKDROP_AUTHENTICATED_ROLE]);
25 | $form['roles'] = array(
26 | '#type' => 'checkboxes',
27 | '#title' => t('Which roles should the users receive?'),
28 | '#description' => t('Users always receive the authenticated user role.'),
29 | '#options' => $options,
30 | );
31 |
32 | $form['pass'] = array(
33 | '#type' => 'textfield',
34 | '#title' => t('Password to be set'),
35 | '#default_value' => NULL,
36 | '#size' => 32,
37 | '#description' => t('Leave this field empty, if you do not need to set a password.'),
38 | );
39 |
40 | $options = array(1 => t('Now'));
41 | foreach (array(3600, 86400, 604800, 2592000, 31536000) as $interval) {
42 | $options[$interval] = format_interval($interval, 1) . ' ' . t('ago');
43 | }
44 | $form['time_range'] = array(
45 | '#type' => 'select',
46 | '#title' => t('How old should user accounts be?'),
47 | '#description' => t('User ages will be distributed randomly from the current time, back to the selected time.'),
48 | '#options' => $options,
49 | '#default_value' => 31536000,
50 | );
51 |
52 | $form['submit'] = array(
53 | '#type' => 'submit',
54 | '#value' => t('Generate'),
55 | );
56 | return $form;
57 | }
58 |
59 | /**
60 | * FormAPI submission to generate users.
61 | */
62 | function devel_generate_users_form_submit($form_id, &$form_state) {
63 | module_load_include('inc', 'devel_generate');
64 | $values = $form_state['values'];
65 | $roles = array_keys(array_filter($values['roles']));
66 | devel_create_users($values['num'], $values['kill_users'], $values['time_range'], $roles, $values['pass']);
67 | }
68 |
69 | /**
70 | * Generates nodes using FormAPI.
71 | */
72 | function devel_generate_content_form($form, &$form_state) {
73 | $options = array();
74 |
75 | $types = node_type_get_types();
76 | $suffix = '';
77 | foreach ($types as $type) {
78 | if (module_exists('comment')) {
79 | $default = $type->settings['comment_default'];
80 | $map = array(t('Hidden'), t('Closed'), t('Open'));
81 | $suffix = ' ('. t('Comments: ') . $map[$default]. ')';
82 | }
83 | $options[$type->type] = t($type->name) . $suffix;
84 | }
85 |
86 | if (empty($options)) {
87 | backdrop_set_message(t('You do not have any content types that can be generated. Go create a new content type already!', array('@create-type' => url('admin/structure/types/add'))), 'error', FALSE);
88 | return $form;
89 | }
90 |
91 | $form['node_types'] = array(
92 | '#type' => 'checkboxes',
93 | '#title' => t('Content types'),
94 | '#options' => $options,
95 | '#default_value' => array_keys($options),
96 | );
97 | if (module_exists('checkall')) $form['node_types']['#checkall'] = TRUE;
98 | $form['kill_content'] = array(
99 | '#type' => 'checkbox',
100 | '#title' => t('Delete all content in these content types before generating new content.'),
101 | '#default_value' => FALSE,
102 | );
103 | $form['num_nodes'] = array(
104 | '#type' => 'number',
105 | '#title' => t('How many nodes would you like to generate?'),
106 | '#default_value' => 50,
107 | '#min' => 1,
108 | '#max' => 999999,
109 | );
110 |
111 | $options = array(1 => t('Now'));
112 | foreach (array(3600, 86400, 604800, 2592000, 31536000) as $interval) {
113 | $options[$interval] = format_interval($interval, 1) . ' ' . t('ago');
114 | }
115 | $form['time_range'] = array(
116 | '#type' => 'select',
117 | '#title' => t('How far back in time should the nodes be dated?'),
118 | '#description' => t('Node creation dates will be distributed randomly from the current time, back to the selected time.'),
119 | '#options' => $options,
120 | '#default_value' => 31536000,
121 | );
122 |
123 | $form['max_comments'] = array(
124 | '#type' => module_exists('comment') ? 'number' : 'value',
125 | '#title' => t('Maximum number of comments per node.'),
126 | '#description' => t('Only content types that have comments enabled will receive comments. Note that some nodes will randomly receive zero comments. Some will receive the max.'),
127 | '#default_value' => 0,
128 | '#min' => 0,
129 | '#max' => 99999,
130 | '#access' => module_exists('comment'),
131 | );
132 | $form['title_length'] = array(
133 | '#type' => 'number',
134 | '#title' => t('Maximum number of words in titles'),
135 | '#default_value' => 4,
136 | '#min' => 1,
137 | '#max' => 100,
138 | );
139 | $form['add_alias'] = array(
140 | '#type' => 'checkbox',
141 | '#disabled' => !module_exists('path'),
142 | '#description' => t('Content types will use the default patterns when generated. Checking this box will add a custom alias to all content types that do not have a pattern specified.'),
143 | '#title' => t('Ensure all content has a URL alias.'),
144 | '#default_value' => FALSE,
145 | );
146 |
147 | unset($options);
148 | $options[LANGUAGE_NONE] = t('Language neutral');
149 | if (module_exists('locale')) {
150 | $languages = language_list(TRUE);
151 | foreach ($languages as $language) {
152 | $options[$language->langcode] = $language->name;
153 | }
154 | }
155 | $form['add_language'] = array(
156 | '#type' => 'checkboxes',
157 | '#title' => t('Set language on nodes'),
158 | '#multiple' => TRUE,
159 | '#access' => module_exists('locale'),
160 | '#description' => t('Requires locale.module'),
161 | '#options' => $options,
162 | '#default_value' => array(LANGUAGE_NONE),
163 | );
164 |
165 | $form['submit'] = array(
166 | '#type' => 'submit',
167 | '#value' => t('Generate'),
168 | );
169 | $form['#redirect'] = FALSE;
170 |
171 | return $form;
172 | }
173 |
174 | /**
175 | * FormAPI submission to generate nodes.
176 | */
177 | function devel_generate_content_form_submit($form_id, &$form_state) {
178 | module_load_include('inc', 'devel_generate', 'devel_generate');
179 | $form_state['values']['node_types'] = array_filter($form_state['values']['node_types']);
180 | if ($form_state['values']['num_nodes'] <= 50 && $form_state['values']['max_comments'] <= 10) {
181 | module_load_include('inc', 'devel_generate');
182 | devel_generate_content($form_state);
183 | }
184 | else {
185 | module_load_include('inc', 'devel_generate', 'devel_generate_batch');
186 | devel_generate_batch_content($form_state);
187 | }
188 | }
189 |
190 | /**
191 | * Generates taxonomy terms using FormAPI.
192 | */
193 | function devel_generate_term_form($form, &$form_state) {
194 | $options = array();
195 | foreach (taxonomy_get_vocabularies() as $vocab_machine_name => $vocab) {
196 | $options[$vocab_machine_name] = $vocab->name;
197 | }
198 | $form['vocabularies'] = array(
199 | '#type' => 'checkboxes',
200 | '#multiple' => TRUE,
201 | '#title' => t('Generate terms for these vocabularies'),
202 | '#required' => TRUE,
203 | '#options' => $options,
204 | );
205 | $form['num_terms'] = array(
206 | '#type' => 'number',
207 | '#title' => t('Number of terms?'),
208 | '#default_value' => 10,
209 | '#min' => 1,
210 | '#max' => 99999,
211 | );
212 | $form['title_length'] = array(
213 | '#type' => 'number',
214 | '#title' => t('Maximum number of characters in term names'),
215 | '#default_value' => 12,
216 | '#min' => 1,
217 | '#max' => 1000,
218 | );
219 | $form['kill_taxonomy'] = array(
220 | '#type' => 'checkbox',
221 | '#title' => t('Delete existing terms in specified vocabularies before generating new terms.'),
222 | '#default_value' => FALSE,
223 | );
224 | $form['submit'] = array(
225 | '#type' => 'submit',
226 | '#value' => t('Generate'),
227 | );
228 |
229 | return $form;
230 | }
231 |
232 | /**
233 | * Generates taxonomy vocabularies using FormAPI.
234 | */
235 | function devel_generate_vocab_form($form, &$form_state) {
236 | $form['num_vocabs'] = array(
237 | '#type' => 'number',
238 | '#title' => t('Number of vocabularies?'),
239 | '#default_value' => 1,
240 | '#min' => 1,
241 | '#max' => 999,
242 | );
243 | $form['title_length'] = array(
244 | '#type' => 'number',
245 | '#title' => t('Maximum number of characters in vocabulary names'),
246 | '#default_value' => 12,
247 | '#min' => 1,
248 | '#max' => 1000,
249 | );
250 | $form['kill_taxonomy'] = array(
251 | '#type' => 'checkbox',
252 | '#title' => t('Delete existing vocabularies before generating new ones.'),
253 | '#default_value' => FALSE,
254 | );
255 | $form['submit'] = array(
256 | '#type' => 'submit',
257 | '#value' => t('Generate'),
258 | );
259 |
260 | return $form;
261 | }
262 |
263 | /**
264 | * FormAPI submission to generate taxonomy terms.
265 | */
266 | function devel_generate_term_form_submit($form_id, &$form_state) {
267 | module_load_include('inc', 'devel_generate');
268 | $vocab_names = array_keys(array_filter($form_state['values']['vocabularies']));
269 | $vocabs = taxonomy_vocabulary_load_multiple($vocab_names);
270 | devel_generate_term_data($vocabs, $form_state['values']['num_terms'], $form_state['values']['title_length'], $form_state['values']['kill_taxonomy']);
271 | }
272 |
273 | /**
274 | * FormAPI submission to generate taxonomy vocabularies.
275 | */
276 | function devel_generate_vocab_form_submit($form_id, &$form_state) {
277 | module_load_include('inc', 'devel_generate');
278 | devel_generate_vocab_data($form_state['values']['num_vocabs'], $form_state['values']['title_length'], $form_state['values']['kill_taxonomy']);
279 | }
280 |
281 | /**
282 | * Inserts nodes properly based on generation options.
283 | *
284 | * @param $node
285 | * The base node created on submit. Inspects $node->devel_generate.
286 | */
287 | function devel_generate_node_insert($node) {
288 | if (isset($node->devel_generate)) {
289 | $results = $node->devel_generate;
290 |
291 | // Add comments if configured and enabled on the given type of node.
292 | if (!empty($results['max_comments']) && $node->comment >= COMMENT_NODE_OPEN) {
293 | devel_generate_add_comments($node, $results['users'], $results['max_comments'], $results['title_length']);
294 | }
295 |
296 | // Add an url alias. Cannot happen before save because we don't know the nid.
297 | if (!empty($results['add_alias'])) {
298 | // Check if an alias will be made automatically.
299 | module_load_include('inc', 'path');
300 | if (function_exists('path_generate_entity_alias')) {
301 | $alias = path_generate_entity_alias($node);
302 | if (!$alias) {
303 | $path = array(
304 | 'source' => 'node/' . $node->nid,
305 | 'alias' => 'node-' . $node->nid . '-' . $node->type,
306 | );
307 | path_save($path);
308 | }
309 | }
310 | }
311 | }
312 | }
313 |
314 | /**
315 | * Generates menus using FormAPI.
316 | */
317 | function devel_generate_menu_form() {
318 | $menu_enabled = module_exists('menu');
319 | if ($menu_enabled) {
320 | $menus = menu_get_menus() + array('__new-menu__' => t('Create new menu(s)'));
321 | }
322 | else {
323 | $menus = menu_list_system_menus();
324 | }
325 | $form['existing_menus'] = array(
326 | '#type' => 'checkboxes',
327 | '#title' => t('Generate links for these menus'),
328 | '#options' => $menus,
329 | '#default_value' => array('__new-menu__'),
330 | '#required' => TRUE,
331 | );
332 | if ($menu_enabled) {
333 | $form['num_menus'] = array(
334 | '#type' => 'number',
335 | '#title' => t('Number of new menus to create'),
336 | '#default_value' => 2,
337 | '#min' => 1,
338 | '#max' => 999,
339 | '#states' => array(
340 | 'visible' => array(
341 | ':input[name="existing_menus[__new-menu__]"]' => array('checked' => TRUE),
342 | ),
343 | ),
344 | );
345 | }
346 | $form['num_links'] = array(
347 | '#type' => 'number',
348 | '#title' => t('Number of links to generate'),
349 | '#default_value' => 50,
350 | '#min' => 1,
351 | '#max' => 10000,
352 | '#required' => TRUE,
353 | );
354 | $form['title_length'] = array(
355 | '#type' => 'number',
356 | '#title' => t('Maximum number of characters in menu and menu link names'),
357 | '#default_value' => 12,
358 | '#min' => 1,
359 | '#max' => 1000,
360 | '#required' => TRUE,
361 | );
362 | $form['link_types'] = array(
363 | '#type' => 'checkboxes',
364 | '#title' => t('Types of links to generate'),
365 | '#options' => array(
366 | 'node' => t('Nodes'),
367 | 'front' => t('Front page'),
368 | 'external' => t('External'),
369 | ),
370 | '#default_value' => array('node', 'front', 'external'),
371 | '#required' => TRUE,
372 | );
373 | $form['max_depth'] = array(
374 | '#type' => 'select',
375 | '#title' => t('Maximum link depth'),
376 | '#options' => range(0, MENU_MAX_DEPTH),
377 | '#default_value' => floor(MENU_MAX_DEPTH / 2),
378 | '#required' => TRUE,
379 | );
380 | unset($form['max_depth']['#options'][0]);
381 | $form['max_width'] = array(
382 | '#type' => 'number',
383 | '#title' => t('Maximum menu width'),
384 | '#default_value' => 6,
385 | '#min' => 1,
386 | '#max' => 100,
387 | '#description' => t("Limit the width of the generated menu's first level of links to a certain number of items."),
388 | '#required' => TRUE,
389 | );
390 | $form['kill'] = array(
391 | '#type' => 'checkbox',
392 | '#title' => t('Delete existing custom generated menus and menu links before generating new ones.'),
393 | '#default_value' => FALSE,
394 | );
395 | $form['submit'] = array(
396 | '#type' => 'submit',
397 | '#value' => t('Generate'),
398 | );
399 | return $form;
400 | }
401 |
402 | /**
403 | * FormAPI submission to generate menus.
404 | */
405 | function devel_generate_menu_form_submit($form_id, &$form_state) {
406 | // If the create new menus checkbox is off, set the number of new menus to 0.
407 | if (!isset($form_state['values']['existing_menus']['__new-menu__']) || !$form_state['values']['existing_menus']['__new-menu__']) {
408 | $form_state['values']['num_menus'] = 0;
409 | }
410 | module_load_include('inc', 'devel_generate');
411 | 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']);
412 | }
413 |
--------------------------------------------------------------------------------
/devel_generate/devel_generate_batch.inc:
--------------------------------------------------------------------------------
1 | t('Generating Content'),
30 | 'operations' => $operations,
31 | 'finished' => 'devel_generate_batch_finished',
32 | 'file' => backdrop_get_path('module', 'devel_generate') . '/devel_generate_batch.inc',
33 | );
34 | batch_set($batch);
35 | }
36 |
37 | function devel_generate_batch_content_kill(&$context) {
38 | module_load_include('inc', 'devel_generate', 'devel_generate');
39 | devel_generate_content_kill($context['results']);
40 | }
41 |
42 | function devel_generate_batch_content_pre_node($vars, &$context) {
43 | $context['results'] = $vars;
44 | $context['results']['num_nids'] = 0;
45 | module_load_include('inc', 'devel_generate', 'devel_generate');
46 | devel_generate_content_pre_node($context['results']);
47 | }
48 |
49 | /**
50 | * Batch API callback: Generate nodes.
51 | */
52 | function devel_generate_batch_content_add_node(&$context) {
53 | module_load_include('inc', 'devel_generate', 'devel_generate');
54 | devel_generate_content_add_node($context['results']);
55 | $context['results']['num_nids'] ++;
56 | }
57 |
58 | /**
59 | * Display a message when a batch is complete.
60 | */
61 | function devel_generate_batch_finished($success, $results, $operations) {
62 | if ($success) {
63 | $message = t('Finished @num_nids nodes created successfully.', array('@num_nids' => $results['num_nids']));
64 | }
65 | else {
66 | $message = t('Finished with an error.');
67 | }
68 | backdrop_set_message($message);
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/devel_generate/modules/date.devel_generate.inc:
--------------------------------------------------------------------------------
1 | getReferencableEntities();
21 | if (is_array($referencable_entity) && !empty($referencable_entity)) {
22 | // $referencable_entity is keyed by bundle type.
23 | $random_bundle = array_rand($referencable_entity);
24 | if (!empty($random_bundle)) {
25 | $target_id = array_rand($referencable_entity[$random_bundle]);
26 | if (!empty($referencable_entity[$random_bundle][$target_id])) {
27 | $object_field['target_id'] = $target_id;
28 | }
29 | }
30 | }
31 | return $object_field;
32 | }
33 |
--------------------------------------------------------------------------------
/devel_generate/modules/file.devel_generate.inc:
--------------------------------------------------------------------------------
1 | fid = NULL;
26 | $file->uri = $uri;
27 | $file->filename = backdrop_basename($uri);
28 | $file->filemime = file_get_mimetype($file->uri);
29 | // @todo Randomize file owner.
30 | $file->uid = 1;
31 | $file = file_save($file);
32 | }
33 | else {
34 | return FALSE;
35 | }
36 | }
37 | else {
38 | return FALSE;
39 | }
40 | }
41 | if (!$file) {
42 | // In case a previous file operation failed or no file is set, return FALSE
43 | return FALSE;
44 | }
45 | else {
46 | $object_field['fid'] = $file->fid;
47 | $object_field['display'] = $field['settings']['display_default'];
48 | $object_field['description'] = devel_create_greeking(10);
49 |
50 | return $object_field;
51 | }
52 | }
53 |
54 | /**
55 | * Private function for generating a random text file.
56 | */
57 | function devel_generate_textfile($filesize = 1024) {
58 | if ($tmp_file = backdrop_tempnam('temporary://', 'filefield_')) {
59 | $destination = $tmp_file . '.txt';
60 | file_unmanaged_move($tmp_file, $destination);
61 |
62 | $fp = fopen($destination, 'w');
63 | fwrite($fp, str_repeat('01', $filesize/2));
64 | fclose($fp);
65 |
66 | return $destination;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/devel_generate/modules/image.devel_generate.inc:
--------------------------------------------------------------------------------
1 | fid = NULL;
38 | $file->uri = $uri;
39 | $file->filename = backdrop_basename($uri);
40 | $file->filemime = file_get_mimetype($file->uri);
41 | // @todo Randomize file owner.
42 | $file->uid = 1;
43 | file_save($file);
44 | $images[$extension][$min_size][$max_size][$file->fid] = $file;
45 | }
46 | else {
47 | return FALSE;
48 | }
49 | }
50 | else {
51 | return FALSE;
52 | }
53 | }
54 | else {
55 | // Select one of the images we've already generated for this field.
56 | $file = new File();
57 | $file->fid = array_rand($images[$extension][$min_size][$max_size]);
58 | }
59 |
60 | $object_field['fid'] = $file->fid;
61 | $object_field['alt'] = devel_create_greeking(4);
62 | $object_field['title'] = devel_create_greeking(4);
63 | return $object_field;
64 | }
65 |
66 | /**
67 | * Private function for creating a random image.
68 | *
69 | * This function only works with the GD toolkit. ImageMagick is not supported.
70 | */
71 | function devel_generate_image($extension = 'png', $min_resolution = 0, $max_resolution = 100000) {
72 | if ($tmp_file = backdrop_tempnam('temporary://', 'imagefield_')) {
73 | $destination = $tmp_file . '.' . $extension;
74 | file_unmanaged_move($tmp_file, $destination, FILE_CREATE_DIRECTORY);
75 |
76 | $min = explode('x', $min_resolution);
77 | $max = explode('x', $max_resolution);
78 |
79 | $width = rand((int)$min[0], (int)$max[0]);
80 | $height = rand((int)$min[1], (int)$max[1]);
81 |
82 | $half_width = (int)($width/2);
83 | $half_height = (int)($height/2);
84 |
85 | // Make an image split into 4 sections with random colors.
86 | $im = imagecreate($width, $height);
87 | for ($n = 0; $n < 4; $n++) {
88 | $color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
89 | $x = (int)($half_width * ($n % 2));
90 | $y = (int)($half_height * (int) ($n >= 2));
91 | imagefilledrectangle($im, intval($x), intval($y), intval($x + $half_width), intval($y + $half_height), $color);
92 | }
93 |
94 | // Make a perfect circle in the image middle.
95 | $color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
96 | $smaller_dimension = min($width, $height);
97 | $smaller_dimension = (int)(($smaller_dimension % 2) ? $smaller_dimension : $smaller_dimension);
98 | imageellipse($im, intval($half_width), intval($half_height), intval($smaller_dimension), intval($smaller_dimension), $color);
99 |
100 | $save_function = 'image'. ($extension == 'jpg' ? 'jpeg' : $extension);
101 | $save_function($im, backdrop_realpath($destination));
102 |
103 | $images[$extension][$min_size][$max_size][$destination] = $destination;
104 | }
105 | return $destination;
106 | }
107 |
--------------------------------------------------------------------------------
/devel_generate/modules/link.devel_generate.inc:
--------------------------------------------------------------------------------
1 | url('Krumo: Structured information display solution
102 |Krumo is a debugging tool (PHP5 only), which displays structured information about any PHP variable. It is a nice replacement for print_r() or var_dump() which are used by a lot of PHP developers.
103 | 108 | 109 |Class | 125 |Description | 126 |
---|---|
129 | ![]() |
134 | 135 | Krumo API 136 | | 137 |
backward compatibility: the DIR_SEP constant isn't used anymore
166 | 167 | 168 |Set the KRUMO_DIR constant up with the absolute path to Krumo files. If it is not defined, include_path will be used. Set KRUMO_DIR only if any other module or application has not already set it up.
182 | 183 | 184 |This constant sets the maximum strings of strings that will be shown as they are. Longer strings will be truncated with this length, and their `full form` will be shown in a child node.
198 | 199 | 200 |backward compatibility: the PATH_SEPARATOR constant is availble since 4.3.0RC2
214 | 215 | 216 |Alias of krumo::dump()
241 | 244 |264 | Documentation generated on Sun, 02 Dec 2007 09:43:24 +0200 by phpDocumentor 1.4.0a2 265 |
266 |20 | Documentation generated on Sun, 02 Dec 2007 09:43:24 +0200 by phpDocumentor 1.4.0a2 21 |
22 | 23 | -------------------------------------------------------------------------------- /lib/krumo/docs/errors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |12 | Documentation generated on Sun, 02 Dec 2007 09:43:25 +0200 by phpDocumentor 1.4.0a2 13 |
14 | 15 | -------------------------------------------------------------------------------- /lib/krumo/docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |151 | Generated by 152 | phpDocumentor 1.4.0a2 153 |
154 | 155 | -------------------------------------------------------------------------------- /lib/krumo/docs/media/banner.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | background-color: #EEEEEE; 4 | margin: 0px; 5 | padding: 0px; 6 | } 7 | 8 | /* Banner (top bar) classes */ 9 | 10 | .banner { } 11 | 12 | .banner-menu 13 | { 14 | clear: both; 15 | padding: .5em; 16 | border-top: 2px solid #AAAAAA; 17 | } 18 | 19 | .banner-title 20 | { 21 | text-align: right; 22 | font-size: 20pt; 23 | font-weight: bold; 24 | margin: .2em; 25 | } 26 | 27 | .package-selector 28 | { 29 | background-color: #DDDDDD; 30 | border: 1px solid #AAAAAA; 31 | color: #000090; 32 | } 33 | -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/AbstractClass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/AbstractClass.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/AbstractClass_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/AbstractClass_logo.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/AbstractMethod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/AbstractMethod.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/AbstractPrivateClass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/AbstractPrivateClass.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/AbstractPrivateClass_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/AbstractPrivateClass_logo.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/AbstractPrivateMethod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/AbstractPrivateMethod.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Class.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Class_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Class_logo.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Constant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Constant.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Constructor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Constructor.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Destructor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Destructor.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Function.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Global.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Global.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/I.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/I.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Index.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Interface.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Interface_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Interface_logo.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/L.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/L.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Lminus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Lminus.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Lplus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Lplus.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Method.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Method.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Page.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Page_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Page_logo.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/PrivateClass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/PrivateClass.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/PrivateClass_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/PrivateClass_logo.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/PrivateMethod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/PrivateMethod.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/PrivateVariable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/PrivateVariable.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/StaticMethod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/StaticMethod.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/StaticVariable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/StaticVariable.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/T.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/T.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Tminus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Tminus.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Tplus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Tplus.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/Variable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/Variable.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/blank.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/class_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/class_folder.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/empty.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/file.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/folder.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/function_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/function_folder.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/minus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/minus.gif -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/next_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/next_button.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/next_button_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/next_button_disabled.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/package.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/package_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/package_folder.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/plus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/plus.gif -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/previous_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/previous_button.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/previous_button_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/previous_button_disabled.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/private_class_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/private_class_logo.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/tutorial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/tutorial.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/tutorial_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/tutorial_folder.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/images/up_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backdrop-contrib/devel/8dadd0c195f2eee7a4c308f4050e68e83cf9d057/lib/krumo/docs/media/images/up_button.png -------------------------------------------------------------------------------- /lib/krumo/docs/media/stylesheet.css: -------------------------------------------------------------------------------- 1 | a { color: #000090; text-decoration: none; } 2 | a:hover, a:active, a:focus { color: highlighttext; background-color: highlight; text-decoration: none; } 3 | 4 | body { background : #FFFFFF; } 5 | body, table { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; } 6 | 7 | a img { border: 0px; } 8 | 9 | /* Page layout/boxes */ 10 | 11 | .info-box { } 12 | .info-box-title { margin: 1em 0em 0em 0em; font-weight: normal; font-size: 14pt; color: #999999; border-bottom: 2px solid #999999; } 13 | .info-box-body { border: 1px solid #999999; padding: .5em; } 14 | .nav-bar { font-size: 8pt; white-space: nowrap; text-align: right; padding: .2em; margin: 0em 0em 1em 0em; } 15 | 16 | .oddrow { background-color: #F8F8F8; border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em} 17 | .evenrow { border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em} 18 | 19 | .page-body { max-width: 800px; margin: auto; } 20 | .tree { } 21 | 22 | /* Index formatting classes */ 23 | 24 | .index-item-body { margin-top: .5em; margin-bottom: .5em} 25 | .index-item-description { margin-top: .25em } 26 | .index-item-details { font-weight: normal; font-style: italic; font-size: 8pt } 27 | .index-letter-section { background-color: #EEEEEE; border: 1px dotted #999999; padding: .5em; margin-bottom: 1em} 28 | .index-letter-title { font-size: 12pt; font-weight: bold } 29 | .index-letter-menu { text-align: center; margin: 1em } 30 | .index-letter { font-size: 12pt } 31 | 32 | /* Docbook classes */ 33 | 34 | .description {} 35 | .short-description { font-weight: bold; color: #666666; } 36 | .tags { padding-left: 0em; margin-left: 3em; color: #666666; list-style-type: square; } 37 | .parameters { padding-left: 0em; margin-left: 3em; color: #014fbe; list-style-type: square; } 38 | .redefinitions { font-size: 8pt; padding-left: 0em; margin-left: 2em; } 39 | .package { font-weight: bold; } 40 | .package-title { font-weight: bold; font-size: 14pt; border-bottom: 1px solid black } 41 | .sub-package { font-weight: bold; } 42 | .tutorial { border-width: thin; border-color: #0066ff; } 43 | .tutorial-nav-box { width: 100%; border: 1px solid #999999; background-color: #F8F8F8; } 44 | 45 | /* Generic formatting */ 46 | 47 | .field { font-weight: bold; } 48 | .detail { font-size: 8pt; } 49 | .notes { font-style: italic; font-size: 8pt; } 50 | .separator { background-color: #999999; height: 2px; } 51 | .warning { color: #FF6600; } 52 | .disabled { font-style: italic; color: #999999; } 53 | 54 | /* Code elements */ 55 | 56 | .line-number { } 57 | 58 | .class-table { width: 100%; } 59 | .class-table-header { border-bottom: 1px dotted #666666; text-align: left} 60 | .class-name { color: #0000AA; font-weight: bold; } 61 | 62 | .method-summary { color: #009000; padding-left: 1em; font-size: 8pt; } 63 | .method-header { } 64 | .method-definition { margin-bottom: .2em } 65 | .method-title { color: #009000; font-weight: bold; } 66 | .method-name { font-weight: bold; } 67 | .method-signature { font-size: 85%; color: #666666; margin: .5em 0em } 68 | .method-result { font-style: italic; } 69 | 70 | .var-summary { padding-left: 1em; font-size: 8pt; } 71 | .var-header { } 72 | .var-title { color: #014fbe; margin-bottom: .3em } 73 | .var-type { font-style: italic; } 74 | .var-name { font-weight: bold; } 75 | .var-default {} 76 | .var-description { font-weight: normal; color: #000000; } 77 | 78 | .include-title { color: #014fbe;} 79 | .include-type { font-style: italic; } 80 | .include-name { font-weight: bold; } 81 | 82 | .const-title { color: #FF6600; } 83 | .const-name { font-weight: bold; } 84 | 85 | /* Syntax highlighting */ 86 | 87 | .src-code { font-family: 'Courier New', Courier, monospace; font-weight: normal; } 88 | .src-line { font-family: 'Courier New', Courier, monospace; font-weight: normal; } 89 | 90 | .src-code a:link { padding: 1px; text-decoration: underline; color: #0000DD; } 91 | .src-code a:visited { text-decoration: underline; color: #0000DD; } 92 | .src-code a:active { background-color: #FFFF66; color: #008000; } 93 | .src-code a:hover { background-color: #FFFF66; text-decoration: overline underline; color: #008000; } 94 | 95 | .src-comm { color: #666666; } 96 | .src-id { color: #FF6600; font-style: italic; } 97 | .src-inc { color: #0000AA; font-weight: bold; } 98 | .src-key { color: #0000AA; font-weight: bold; } 99 | .src-num { color: #CC0000; } 100 | .src-str { color: #CC0000; } 101 | .src-sym { } 102 | .src-var { } 103 | 104 | .src-php { font-weight: bold; } 105 | 106 | .src-doc { color: #666666; } 107 | .src-doc-close-template { color: #666666 } 108 | .src-doc-coretag { color: #008000; } 109 | .src-doc-inlinetag {} 110 | .src-doc-internal {} 111 | .src-doc-tag { color: #0080CC; } 112 | .src-doc-template { color: #666666 } 113 | .src-doc-type { font-style: italic; color: #444444 } 114 | .src-doc-var { color: #444444 } 115 | 116 | .tute-tag { color: #009999 } 117 | .tute-attribute-name { color: #0000FF } 118 | .tute-attribute-value { color: #0099FF } 119 | .tute-entity { font-weight: bold; } 120 | .tute-comment { font-style: italic } 121 | .tute-inline-tag { color: #636311; font-weight: bold } 122 | 123 | /* tutorial */ 124 | 125 | .authors { } 126 | .author { font-style: italic; font-weight: bold } 127 | .author-blurb { margin: .5em 0em .5em 2em; font-size: 85%; font-weight: normal; font-style: normal } 128 | .example { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; } 129 | .listing { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; white-space: nowrap; } 130 | .release-info { font-size: 85%; font-style: italic; margin: 1em 0em } 131 | .ref-title-box { } 132 | .ref-title { } 133 | .ref-purpose { font-style: italic; color: #666666 } 134 | .ref-synopsis { } 135 | .title { font-weight: bold; border-bottom: 1px solid #999999; color: #999999; } 136 | .cmd-synopsis { margin: 1em 0em } 137 | .cmd-title { font-weight: bold } 138 | .toc { margin-left: 2em; padding-left: 0em } 139 | 140 | /*------------------------------------------------------------------------------ 141 | webfx-tree 142 | ------------------------------------------------------------------------------*/ 143 | 144 | .webfx-tree-container { 145 | margin: 0px; 146 | padding: 0px; 147 | white-space: nowrap; 148 | font: icon; 149 | } 150 | 151 | .webfx-tree-item { 152 | padding: 0px; 153 | margin: 0px; 154 | color: black; 155 | white-space: nowrap; 156 | font: icon; 157 | } 158 | 159 | .webfx-tree-item a { 160 | margin-left: 3px; 161 | padding: 1px 2px 1px 2px; 162 | color: black; 163 | text-decoration: none; 164 | } 165 | 166 | .webfx-tree-item a:hover, .webfx-tree-item a:active { 167 | color: highlighttext; 168 | background: highlight; 169 | text-decoration: none 170 | } 171 | 172 | .webfx-tree-item img { 173 | vertical-align: middle; 174 | border: 0px; 175 | } 176 | 177 | .webfx-tree-icon { 178 | width: 16px; 179 | height: 16px; 180 | } 181 | 182 | -------------------------------------------------------------------------------- /lib/krumo/docs/packages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |12 | ------------------------------------------------------------------------------ 13 | 14 | SETUP: How to install Krumo ? 15 | 16 | ------------------------------------------------------------------------------ 17 | 18 | In order to use Krumo you have to put it on your (development) server, and 19 | include it in your script. You can put it somewhere in the INCLUDE_PATH, or 20 | specify the full path to the "class.krumo.php" file. 21 | 22 | You have to modify the "krumo.ini" file too. It is the configuration file for 23 | Krumo. The first option is choosing a skin: 24 | 25 | [skin] 26 | selected = "orange" 27 | 28 | The value for this setting has to be the name of one of the sub-folders from the 29 | "Krumo/skins/" folder. If the value provided for the skin results in not finding 30 | the skin, the `default` skin will be used instead. 31 | 32 | The second option is used to set the correct web path to the folder where Krumo 33 | is installed. This is used in order to make the images from Krumo's CSS skins 34 | web-accessible. 35 | 36 | [css] 37 | url = "http://www.example.com/Krumo/" 38 | 39 | So far those two are the only configuration options. 40 | 41 | All the CSS files ("skin.css") from the "Krumo/skins/" sub-folders must have the 42 | proper permissions in order to be readable from Krumo. Same applies for 43 | "krumo.ini" and "krumo.js" files. 44 |45 |
46 | Documentation generated on Sun, 02 Dec 2007 09:43:22 +0200 by phpDocumentor 1.4.0a2 47 |
48 | 49 | -------------------------------------------------------------------------------- /lib/krumo/docs/ric_README.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |12 | ============================================================================= 13 | 14 | Krumo 15 | version 0.2.1a 16 | 17 | ============================================================================= 18 | 19 | You probably got this package from... 20 | http://www.sourceforge.net/projects/krumo/ 21 | 22 | If there is no licence agreement with this package please download 23 | a version from the location above. You must read and accept that 24 | licence to use this software. The file is titled simply LICENSE. 25 | 26 | OVERVIEW 27 | ------------------------------------------------------------------------------ 28 | To put it simply, Krumo is a replacement for print_r() and var_dump(). By 29 | definition Krumo is a debugging tool (for PHP5), which displays structured 30 | information about any PHP variable. 31 | 32 | A lot of developers use print_r() and var_dump() in the means of debugging 33 | tools. Although they were intended to present human readble information about a 34 | variable, we can all agree that in general they are not. Krumo is an 35 | alternative: it does the same job, but it presents the information beautified 36 | using CSS and DHTML. 37 | 38 | EXAMPLES 39 | ------------------------------------------------------------------------------ 40 | Here's a basic example, which will return a report on the array variable passed 41 | as argument to it: 42 | 43 | krumo(array('a1'=> 'A1', 3, 'red')); 44 | 45 | You can dump simultaneously more then one variable - here's another example: 46 | 47 | krumo($_SERVER, $_REQUEST); 48 | 49 | You probably saw from the examples above that some of the nodes are expandable, 50 | so if you want to inspect the nested information, click on them and they will 51 | expand; if you do not need that information shown simply click again on it to 52 | collapse it. Here's an example to test this: 53 | 54 | $x1->x2->x3->x4->x5->x6->x7->x8->x9 = 'X10'; 55 | krumo($x1); 56 | 57 | The krumo() is the only standalone function from the package, and this is 58 | because basic dumps about variables (like print_r() or var_dump()) are the most 59 | common tasks such functionality is used for. The rest of the functionality can 60 | be called using static calls to the Krumo class. Here are several more examples: 61 | 62 | // print a debug backgrace 63 | krumo::backtrace(); 64 | 65 | // print all the included(or required) files 66 | krumo::includes(); 67 | 68 | // print all the included functions 69 | krumo::functions(); 70 | 71 | // print all the declared classes 72 | krumo::classes(); 73 | 74 | // print all the defined constants 75 | krumo::defines(); 76 | 77 | ... and so on, etc. 78 | 79 | A full PHPDocumenter API documentation exists both in this package and at the 80 | project's website. 81 | 82 | INSTALL 83 | ------------------------------------------------------------------------------ 84 | Read the INSTALL file. 85 | 86 | DOCUMENTATION 87 | ------------------------------------------------------------------------------ 88 | As I said, a full PHPDocumenter API documentation can be found both in this 89 | package and at the project's website. 90 | 91 | SKINS 92 | ------------------------------------------------------------------------------ 93 | There are several skins pre-installed with this package, but if you wish you can 94 | create skins of your own. The skins are simply CSS files that are prepended to 95 | the result that Krumo prints. If you want to use images in your CSS (for 96 | background, list-style, etc), you have to put "%URL%" in front of the image URL 97 | in order hook it up to the skin folder and make the image web-accessible. 98 | 99 | Here's an example: 100 | 101 | ul.krumo-first {background: url(%url%bg.gif);} 102 | 103 | TODO 104 | ------------------------------------------------------------------------------ 105 | You can find the list of stuff that is going to be added to this project in the 106 | TODO file from this very package. 107 | 108 | CONTRIBUTION 109 | ----------------------------------------------------------------------------- 110 | If you download and use and possibly even extend this tool, please let us know. 111 | Any feedback, even bad, is always welcome and your suggestions are going to be 112 | considered for our next release. Please use our SourceForge page for that: 113 | 114 | http://www.sourceforge.net/projects/krumo/ 115 | 116 |117 |
118 | Documentation generated on Sun, 02 Dec 2007 09:43:23 +0200 by phpDocumentor 1.4.0a2 119 |
120 | 121 | -------------------------------------------------------------------------------- /lib/krumo/docs/ric_TODO.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |12 | ****************************************************************************** 13 | 14 | Krumo: TODO 15 | 16 | ****************************************************************************** 17 | 18 | BUGS 19 | ---------------- 20 | - watch the SourceForge.net Bug Tracker 21 | 22 | Features: PHP 23 | ---------------- 24 | - Try to detect anonymous (lambda) functions 25 | - Try to detect whether an array is indexed or associated 26 | - Add var_export support for arrays and objects 27 | - Add JSON support for arrays and objects 28 | 29 | Features: GUI 30 | ---------------- 31 | - Nicer and friendlier skin(s) 32 | - Add top-level links for collapsing and expanding the whole tree 33 | - Add object & array -level links for collapsing and expanding all the 34 | nested nodes 35 | - Print all parent classes for the rendered objects 36 |37 |
38 | Documentation generated on Sun, 02 Dec 2007 09:43:23 +0200 by phpDocumentor 1.4.0a2 39 |
40 | 41 | -------------------------------------------------------------------------------- /lib/krumo/docs/ric_VERSION.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |12 | 0.2.1a 13 |14 |
15 | Documentation generated on Sun, 02 Dec 2007 09:43:23 +0200 by phpDocumentor 1.4.0a2 16 |
17 | 18 | -------------------------------------------------------------------------------- /lib/krumo/krumo.ini: -------------------------------------------------------------------------------- 1 | ; 2 | ; KRUMO CONFIGURATION FILE 3 | ; 4 | 5 | [skin] 6 | selected = "white" 7 | ; 8 | ; Change the above value to set the CSS skin used to render 9 | ; Krumo layout. If the skin is not found, then the "default" one 10 | ; is going to be used. 11 | ; 12 | 13 | [css] 14 | url = "http://www.example.com/Krumo/" 15 | ; 16 | ; This value is used to set the URL path to 17 | ; where the Krumo folder is. This is required in 18 | ; order to have web access to Krumo's CSS and 19 | ; image files. 20 | ; 21 | -------------------------------------------------------------------------------- /lib/krumo/krumo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * JavaScript routines for Krumo 3 | * 4 | * @link http://sourceforge.net/projects/krumo 5 | */ 6 | 7 | ///////////////////////////////////////////////////////////////////////////// 8 | 9 | /** 10 | * Krumo JS Class 11 | */ 12 | function krumo() { 13 | } 14 | 15 | // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 16 | 17 | /** 18 | * Add a CSS class to an HTML element 19 | * 20 | * @param HtmlElement el 21 | * @param string className 22 | * @return void 23 | */ 24 | krumo.reclass = function(el, className) { 25 | if (el.className.indexOf(className) < 0) { 26 | el.className += (' ' + className); 27 | } 28 | } 29 | 30 | // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 31 | 32 | /** 33 | * Remove a CSS class to an HTML element 34 | * 35 | * @param HtmlElement el 36 | * @param string className 37 | * @return void 38 | */ 39 | krumo.unclass = function(el, className) { 40 | if (el.className.indexOf(className) > -1) { 41 | el.className = el.className.replace(className, ''); 42 | } 43 | } 44 | 45 | // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 46 | 47 | /** 48 | * Toggle the nodes connected to an HTML element 49 | * 50 | * @param HtmlElement el 51 | * @return void 52 | */ 53 | krumo.toggle = function(el) { 54 | var ul = el.parentNode.getElementsByTagName('ul'); 55 | for (var i=0; i