devel.pages.inc

  1. cis7 sites/all/modules/ulmus/devel/devel.pages.inc
  2. cle7 sites/all/modules/ulmus/devel/devel.pages.inc
  3. ecd7 sites/all/modules/ulmus/devel/devel.pages.inc
  4. elmsmedia7 sites/all/modules/ulmus/devel/devel.pages.inc
  5. harmony7 sites/all/modules/ulmus/devel/devel.pages.inc
  6. icor7 sites/all/modules/ulmus/devel/devel.pages.inc
  7. meedjum_blog7 sites/all/modules/ulmus/devel/devel.pages.inc
  8. mooc7 sites/all/modules/ulmus/devel/devel.pages.inc

Functions

Namesort descending Description
devel_cache_clear Menu callback; clears all caches, then redirects to the previous page.
devel_elements_page
devel_entity_info_page
devel_field_info_page
devel_function_reference Returns a list of all currently defined user functions in the current request lifecycle, with links their documentation.
devel_load_object Menu callback; prints the loaded structure of the current node/user.
devel_menu_item
devel_menu_rebuild Menu callback; clear the database, resetting the menu to factory defaults.
devel_phpinfo
devel_querylog_arguments
devel_querylog_explain
devel_reinstall Display a dropdown of installed modules with the option to reinstall them.
devel_reinstall_submit Process reinstall menu form submissions.
devel_render_object Menu callback; prints the render structure of the current object (currently node or user).
devel_session Menu callback: display the session.
devel_theme_registry
devel_variable_edit
devel_variable_edit_submit
devel_variable_form
devel_variable_form_submit
devel_variable_page Menu callback; display all variables.

File

sites/all/modules/ulmus/devel/devel.pages.inc
View source
  1. <?php
  2. // Menu callback that shows menu item.
  3. function devel_menu_item() {
  4. $item = menu_get_item($_GET['path']);
  5. return kdevel_print_object($item);
  6. }
  7. /**
  8. * Returns a list of all currently defined user functions in the current
  9. * request lifecycle, with links their documentation.
  10. */
  11. function devel_function_reference() {
  12. $functions = get_defined_functions();
  13. $version = devel_get_core_version(VERSION);
  14. $ufunctions = $functions['user'];
  15. sort($ufunctions);
  16. $api = variable_get('devel_api_url', 'api.drupal.org');
  17. foreach ($ufunctions as $function) {
  18. $links[] = l($function, "http://$api/api/$version/function/$function");
  19. }
  20. return theme('item_list', array('items' => $links));
  21. }
  22. /**
  23. * Menu callback; clears all caches, then redirects to the previous page.
  24. */
  25. function devel_cache_clear() {
  26. drupal_flush_all_caches();
  27. drupal_set_message('Cache cleared.');
  28. drupal_goto();
  29. }
  30. // A menu callback. Called by the AJAX link in query log.
  31. function devel_querylog_explain($request_id, $qid) {
  32. if (!is_numeric($request_id)) {
  33. return MENU_ACCESS_DENIED;
  34. }
  35. $path = "temporary://devel_querylog/$request_id.txt";
  36. $path = file_stream_wrapper_uri_normalize($path);
  37. $queries = json_decode(file_get_contents($path));
  38. $query = $queries[$qid];
  39. $result = db_query('EXPLAIN ' . $query->query, (array)$query->args)->fetchAllAssoc('table');
  40. $i = 1;
  41. foreach ($result as $row) {
  42. $row = (array)$row;
  43. if ($i == 1) {
  44. $header = array_keys($row);
  45. }
  46. $rows[] = array_values($row);
  47. $i++;
  48. }
  49. // Print and return nothing thus avoiding page wrapper.
  50. $output = theme('table', array('header' => $header, 'rows' => $rows));
  51. print $output;
  52. $GLOBALS['devel_shutdown'] = FALSE;
  53. }
  54. // A menu callback. Called by the AJAX link in query log.
  55. function devel_querylog_arguments($request_id, $qid) {
  56. if (!is_numeric($request_id)) {
  57. return MENU_ACCESS_DENIED;
  58. }
  59. $path = "temporary://devel_querylog/$request_id.txt";
  60. $path = file_stream_wrapper_uri_normalize($path);
  61. $queries = json_decode(file_get_contents($path));
  62. $query = $queries[$qid];
  63. $conn = Database::getConnection();
  64. $quoted = array();
  65. foreach ((array)$query->args as $key => $val) {
  66. $quoted[$key] = $conn->quote($val);
  67. }
  68. $output = strtr($query->query, $quoted);
  69. // print and return nothing thus avoiding page wrapper.
  70. print $output;
  71. $GLOBALS['devel_shutdown'] = FALSE;
  72. }
  73. /**
  74. * Menu callback; clear the database, resetting the menu to factory defaults.
  75. */
  76. function devel_menu_rebuild() {
  77. menu_rebuild();
  78. drupal_set_message(t('The menu router has been rebuilt.'));
  79. drupal_goto();
  80. }
  81. /**
  82. * Display a dropdown of installed modules with the option to reinstall them.
  83. */
  84. function devel_reinstall($form, &$form_state) {
  85. $output = '';
  86. $modules = module_list();
  87. sort($modules);
  88. $options = drupal_map_assoc($modules);
  89. $form['list'] = array(
  90. '#type' => 'checkboxes',
  91. '#options' => $options,
  92. '#description' => t('Uninstall and then install the selected modules. <code>hook_uninstall()</code> and <code>hook_install()</code> 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 <code>hook_uninstall()</code>.'),
  93. );
  94. $form['submit'] = array(
  95. '#value' => t('Reinstall'),
  96. '#type' => 'submit',
  97. );
  98. return $form;
  99. }
  100. /**
  101. * Process reinstall menu form submissions.
  102. */
  103. function devel_reinstall_submit($form, &$form_state) {
  104. // require_once './includes/install.inc';
  105. $modules = array_filter($form_state['values']['list']);
  106. module_disable($modules, FALSE);
  107. drupal_uninstall_modules($modules, FALSE);
  108. module_enable($modules, FALSE);
  109. drupal_set_message(t('Uninstalled and installed: %names.', array('%names' => implode(', ', $modules))));
  110. }
  111. // Menu callback.
  112. function devel_theme_registry() {
  113. drupal_theme_initialize();
  114. $hooks = theme_get_registry();
  115. ksort($hooks);
  116. return kprint_r($hooks, TRUE);
  117. }
  118. // Menu callback. $entity_type argument not currently used in the UI.
  119. function devel_entity_info_page($entity_type = NULL) {
  120. $info = entity_get_info($entity_type);
  121. ksort($info);
  122. return kprint_r($info, TRUE);
  123. }
  124. // Menu callback.
  125. function devel_field_info_page() {
  126. $info = field_info_fields();
  127. $output = kprint_r($info, TRUE, t('Fields'));
  128. $info = field_info_instances();
  129. $output .= kprint_r($info, TRUE, t('Instances'));
  130. $info = field_info_bundles();
  131. $output .= kprint_r($info, TRUE, t('Bundles'));
  132. return $output;
  133. }
  134. /**
  135. * Menu callback; display all variables.
  136. */
  137. function devel_variable_page() {
  138. // We return our own $page so as to avoid blocks.
  139. $output = drupal_get_form('devel_variable_form');
  140. drupal_set_page_content($output);
  141. $page = element_info('page');
  142. return $page;
  143. }
  144. function devel_variable_form() {
  145. $header = array(
  146. 'name' => array('data' => t('Name'), 'field' => 'name', 'sort' => 'asc'),
  147. 'value' => array('data' => t('Value'), 'field' => 'value'),
  148. 'length' => array('data' => t('Length'), 'field' => 'length'),
  149. 'edit' => array('data' => t('Operations')),
  150. );
  151. // TODO: we could get variables out of $conf but that would include hard coded ones too. ideally i would highlight overrridden/hard coded variables
  152. $query = db_select('variable', 'v')->extend('TableSort');
  153. $query->fields('v', array('name', 'value'));
  154. switch (db_driver()) {
  155. case 'mssql':
  156. $query->addExpression("LEN(v.value)", 'length');
  157. break;
  158. default:
  159. $query->addExpression("LENGTH(v.value)", 'length');
  160. break;
  161. }
  162. $result = $query
  163. ->orderByHeader($header)
  164. ->execute();
  165. foreach ($result as $row) {
  166. // $variables[$row->name] = '';
  167. $options[$row->name]['name'] = check_plain($row->name);
  168. if (merits_krumo($row->value)) {
  169. $value = krumo_ob(variable_get($row->name, NULL));
  170. }
  171. else {
  172. if (drupal_strlen($row->value) > 70) {
  173. $value = check_plain(drupal_substr($row->value, 0, 65)) .'...';
  174. }
  175. else {
  176. $value = check_plain($row->value);
  177. }
  178. }
  179. $options[$row->name]['value'] = $value;
  180. $options[$row->name]['length'] = $row->length;
  181. $options[$row->name]['edit'] = l(t('Edit'), "devel/variable/edit/$row->name");
  182. }
  183. $form['variables'] = array(
  184. '#type' => 'tableselect',
  185. '#header' => $header,
  186. '#options' => $options,
  187. '#empty' => t('No variables.'),
  188. );
  189. $form['submit'] = array(
  190. '#type' => 'submit',
  191. '#value' => t('Delete'),
  192. );
  193. // krumo($form);
  194. return $form;
  195. }
  196. function devel_variable_form_submit($form, &$form_state) {
  197. $deletes = array_filter($form_state['values']['variables']);
  198. array_walk($deletes, 'variable_del');
  199. if (count($deletes)) {
  200. drupal_set_message(format_plural(count($deletes), 'One variable deleted.', '@count variables deleted.'));
  201. }
  202. }
  203. function devel_variable_edit($form, &$form_state, $name) {
  204. $value = variable_get($name, 'not found');
  205. $form['name'] = array(
  206. '#type' => 'value',
  207. '#value' => $name
  208. );
  209. $form['value'] = array(
  210. '#type' => 'item',
  211. '#title' => t('Old value'),
  212. '#markup' => dpr($value, TRUE),
  213. );
  214. if (is_string($value) || is_numeric($value)) {
  215. $form['new'] = array(
  216. '#type' => 'textarea',
  217. '#title' => t('New value'),
  218. '#default_value' => $value
  219. );
  220. $form['submit'] = array(
  221. '#type' => 'submit',
  222. '#value' => t('Submit'),
  223. );
  224. }
  225. else {
  226. $api = variable_get('devel_api_url', 'api.drupal.org');
  227. $form['new'] = array(
  228. '#type' => 'item',
  229. '#title' => t('New value'),
  230. '#markup' => t('Sorry, complex variable types may not be edited yet. Use the <em>Execute PHP</em> block and the <a href="@variable-set-doc">variable_set()</a> function.', array('@variable-set-doc' => "http://$api/api/HEAD/function/variable_set"))
  231. );
  232. }
  233. drupal_set_title($name);
  234. return $form;
  235. }
  236. function devel_variable_edit_submit($form, &$form_state) {
  237. variable_set($form_state['values']['name'], $form_state['values']['new']);
  238. drupal_set_message(t('Saved new value for %name.', array('%name' => $form_state['values']['name'])));
  239. 'devel/variable';
  240. }
  241. /**
  242. * Menu callback: display the session.
  243. */
  244. function devel_session() {
  245. global $user;
  246. $output = kprint_r($_SESSION, TRUE);
  247. $headers = array(t('Session name'), t('Session ID'));
  248. $output .= theme('table', array('headers' => $headers, 'rows' => array(array(session_name(), session_id()))));
  249. return $output;
  250. }
  251. /**
  252. * Menu callback; prints the loaded structure of the current node/user.
  253. */
  254. function devel_load_object($type, $object, $name = NULL) {
  255. $name = isset($name) ? $name : $type;
  256. return kdevel_print_object($object, '$'. $name .'->');
  257. }
  258. /**
  259. * Menu callback; prints the render structure of the current object (currently node or user).
  260. */
  261. function devel_render_object($type, $object, $name = NULL) {
  262. $name = isset($name) ? $name : $type;
  263. $function = $type . '_view';
  264. $build = $function($object);
  265. return kdevel_print_object($build, '$'. $name .'->');
  266. }
  267. function devel_elements_page() {
  268. return kdevel_print_object(module_invoke_all('element_info'));
  269. }
  270. function devel_phpinfo() {
  271. print phpinfo();
  272. drupal_exit();
  273. }