system.module

You are here

  1. 7 modules/system/system.module
  2. 4.6 modules/system.module
  3. 4.7 modules/system.module
  4. 5 modules/system/system.module
  5. 6 modules/system/system.module
  6. 8 core/modules/system/system.module

Configuration system that lets administrators modify the workings of the site.

Functions

Namesort descending Description
blocked_ip_load Retrieve a blocked IP address from the database.
confirm_form Generates a form array for a confirmation form.
system_action_info Implements hook_action_info().
system_add_module_assets Adds CSS and JavaScript files declared in module .info files.
system_admin_compact_mode Determines whether the current user is in compact mode.
system_admin_compact_page Menu callback; Sets whether the admin menu is in compact mode or not.
system_admin_menu_block Provide a single block on the administration overview page.
system_admin_paths Implements hook_admin_paths().
system_archiver_info Implements hook_archiver_info().
system_authorized_batch_process Use authorize.php to run batch_process().
system_authorized_batch_processing_url Returns the URL for the authorize.php script when it is processing a batch.
system_authorized_get_url Return the URL for the authorize.php script.
system_authorized_init Setup a given callback to run via authorize.php with elevated privileges.
system_authorized_run Setup and invoke an operation using authorize.php.
system_block_info Implements hook_block_info().
system_block_ip_action Blocks the current user's IP address.
system_block_view Implements hook_block_view().
system_check_directory Checks the existence of the directory specified in $form_element.
system_check_http_request Checks whether the server is capable of issuing HTTP requests.
system_cron Implements hook_cron().
system_custom_theme Implements hook_custom_theme().
system_date_formats Implements hook_date_formats().
system_date_formats_rebuild Resets the database cache of date formats and saves all new date formats.
system_date_format_delete Deletes a date format from the database.
system_date_format_locale Gets the appropriate date format string for a date type and locale.
system_date_format_save Saves a date format to the database.
system_date_format_types Implements hook_date_format_types().
system_date_format_type_delete Deletes a date type from the database.
system_date_format_type_save Saves a date type to the database.
system_default_region Get the name of the default region for a given theme.
system_element_info Implements hook_element_info().
system_entity_info Implements hook_entity_info().
system_filetransfer_info Implements hook_filetransfer_info().
system_find_base_themes Find all the base themes for the specified theme.
system_flush_caches Implements hook_flush_caches().
system_form_user_profile_form_alter Implements hook_form_FORM_ID_alter().
system_form_user_register_form_alter Implements hook_form_FORM_ID_alter().
system_get_date_format Gets the format details for a particular format ID.
system_get_date_formats Gets the list of defined date formats and attributes.
system_get_date_types Gets the list of available date types and attributes.
system_get_files_database Retrieves the current status of an array of files in the system table.
system_get_info Returns an array of information about enabled modules or themes.
system_get_module_admin_tasks Generate a list of tasks offered by a specified module.
system_goto_action Redirects to a different URL.
system_goto_action_form Settings form for system_goto_action().
system_goto_action_submit
system_help Implements hook_help().
system_hook_info Implements hook_hook_info().
system_image_toolkits Implements hook_image_toolkits().
system_init Implements hook_init().
system_library Implements hook_library().
system_mail Implements hook_mail().
system_menu Implements hook_menu().
system_message_action Sends a message to the current user's screen.
system_message_action_form
system_message_action_submit
system_page_alter Implements hook_page_alter().
system_permission Implements hook_permission().
system_preprocess_block Implements hook_preprocess_block().
system_rebuild_module_data Rebuild, save, and return data about all currently available modules.
system_rebuild_theme_data Rebuild, save, and return data about all currently available themes.
system_region_list Get a list of available regions from a specified theme.
system_retrieve_file Attempts to get a file using drupal_http_request and to store it locally.
system_run_automated_cron Run the automated cron if enabled.
system_send_email_action Sends an e-mail message.
system_send_email_action_form Return a form definition so the Send email action can be configured.
system_send_email_action_submit Process system_send_email_action form submissions.
system_send_email_action_validate Validate system_send_email_action form submissions.
system_settings_form Sets up a form to save information automatically.
system_settings_form_submit Form submission handler for system_settings_form().
system_stream_wrappers Implements hook_stream_wrappers().
system_system_info_alter Implements hook_system_info_alter().
system_theme Implements hook_theme().
system_timezone Menu callback; Retrieve a JSON object containing a suggested time zone name.
system_time_zones Generate an array of time zones and their local time&date.
system_updater_info Implements hook_updater_info().
system_update_files_database Updates the records in the system table based on the files array.
system_user_login Implements hook_user_login().
system_user_timezone Add the time zone field to the user edit and register forms.
theme_confirm_form Returns HTML for a confirmation form.
theme_exposed_filters Returns HTML for an exposed filter form.
theme_system_compact_link Returns HTML for a link to show or hide inline help descriptions.
theme_system_powered_by Returns HTML for the Powered by Drupal text.
theme_system_settings_form Returns HTML for a system settings form.
_system_batch_theme Theme callback for the default batch page.
_system_date_formats_build Builds and returns information about available date formats.
_system_date_format_types_build Builds and returns information about available date types.
_system_default_theme_features Returns an array of default theme features.
_system_info_add_path Prefixes all values in an .info file array with a given path.
_system_rebuild_module_data Helper function to scan and collect module .info data.
_system_rebuild_theme_data Helper function to scan and collect theme .info data and their engines.
_system_sort_requirements Helper function to sort requirements.
_system_themes_access Menu item access callback - only admin or enabled themes can be accessed.
_system_update_bootstrap_status Refresh bootstrap column in the system table.

Constants

Namesort descending Description
DRUPAL_CRON_DEFAULT_THRESHOLD Default interval for automatic cron executions in seconds.
DRUPAL_DISABLED Disabled option on forms and settings
DRUPAL_MAXIMUM_TEMP_FILE_AGE Maximum age of temporary files in seconds.
DRUPAL_OPTIONAL Optional option on forms and settings
DRUPAL_REQUIRED Required option on forms and settings
DRUPAL_USER_TIMEZONE_DEFAULT New users will be set to the default time zone at registration.
DRUPAL_USER_TIMEZONE_EMPTY New users will get an empty time zone at registration.
DRUPAL_USER_TIMEZONE_SELECT New users will select their own timezone at registration.
DRUPAL_WEIGHT_SELECT_MAX Maximum number of values in a weight select element.
REGIONS_ALL Return all regions.
REGIONS_VISIBLE Return only visible regions.

File

modules/system/system.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Configuration system that lets administrators modify the workings of the site.
  5. */
  6. /**
  7. * Maximum age of temporary files in seconds.
  8. */
  9. define('DRUPAL_MAXIMUM_TEMP_FILE_AGE', 21600);
  10. /**
  11. * Default interval for automatic cron executions in seconds.
  12. */
  13. define('DRUPAL_CRON_DEFAULT_THRESHOLD', 10800);
  14. /**
  15. * New users will be set to the default time zone at registration.
  16. */
  17. define('DRUPAL_USER_TIMEZONE_DEFAULT', 0);
  18. /**
  19. * New users will get an empty time zone at registration.
  20. */
  21. define('DRUPAL_USER_TIMEZONE_EMPTY', 1);
  22. /**
  23. * New users will select their own timezone at registration.
  24. */
  25. define('DRUPAL_USER_TIMEZONE_SELECT', 2);
  26. /**
  27. * Disabled option on forms and settings
  28. */
  29. define('DRUPAL_DISABLED', 0);
  30. /**
  31. * Optional option on forms and settings
  32. */
  33. define('DRUPAL_OPTIONAL', 1);
  34. /**
  35. * Required option on forms and settings
  36. */
  37. define('DRUPAL_REQUIRED', 2);
  38. /**
  39. * Maximum number of values in a weight select element.
  40. *
  41. * If the number of values is over the maximum, a text field is used instead.
  42. */
  43. define('DRUPAL_WEIGHT_SELECT_MAX', 100);
  44. /**
  45. * Return only visible regions.
  46. *
  47. * @see system_region_list()
  48. */
  49. define('REGIONS_VISIBLE', 'visible');
  50. /**
  51. * Return all regions.
  52. *
  53. * @see system_region_list()
  54. */
  55. define('REGIONS_ALL', 'all');
  56. /**
  57. * Implements hook_help().
  58. */
  59. function system_help($path, $arg) {
  60. global $base_url;
  61. switch ($path) {
  62. case 'admin/help#system':
  63. $output = '';
  64. $output .= '<h3>' . t('About') . '</h3>';
  65. $output .= '<p>' . t('The System module is integral to the site, and provides basic but extensible functionality for use by other modules and themes. Some integral elements of Drupal are contained in and managed by the System module, including caching, enabling and disabling modules and themes, preparing and displaying the administrative page, and configuring fundamental site settings. A number of key system maintenance operations are also part of the System module. For more information, see the online handbook entry for <a href="@system">System module</a>.', array('@system' => 'http://drupal.org/documentation/modules/system')) . '</p>';
  66. $output .= '<h3>' . t('Uses') . '</h3>';
  67. $output .= '<dl>';
  68. $output .= '<dt>' . t('Managing modules') . '</dt>';
  69. $output .= '<dd>' . t('The System module allows users with the appropriate permissions to enable and disable modules on the <a href="@modules">Modules administration page</a>. Drupal comes with a number of core modules, and each module provides a discrete set of features and may be enabled or disabled depending on the needs of the site. Many additional modules contributed by members of the Drupal community are available for download at the <a href="@drupal-modules">Drupal.org module page</a>.', array('@modules' => url('admin/modules'), '@drupal-modules' => 'http://drupal.org/project/modules')) . '</dd>';
  70. $output .= '<dt>' . t('Managing themes') . '</dt>';
  71. $output .= '<dd>' . t('The System module allows users with the appropriate permissions to enable and disable themes on the <a href="@themes">Appearance administration page</a>. Themes determine the design and presentation of your site. Drupal comes packaged with several core themes, and additional contributed themes are available at the <a href="@drupal-themes">Drupal.org theme page</a>.', array('@themes' => url('admin/appearance'), '@drupal-themes' => 'http://drupal.org/project/themes')) . '</dd>';
  72. $output .= '<dt>' . t('Managing caching') . '</dt>';
  73. $output .= '<dd>' . t("The System module allows users with the appropriate permissions to manage caching on the <a href='@cache-settings'>Performance settings page</a>. Drupal has a robust caching system that allows the efficient re-use of previously-constructed web pages and web page components. Pages requested by anonymous users are stored in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, the caching system may significantly increase the speed of your site.", array('@cache-settings' => url('admin/config/development/performance'))) . '</dd>';
  74. $output .= '<dt>' . t('Performing system maintenance') . '</dt>';
  75. $output .= '<dd>' . t('In order for the site and its modules to continue to operate well, a set of routine administrative operations must run on a regular basis. The System module manages this task by making use of a system cron job. You can verify the status of cron tasks by visiting the <a href="@status">Status report page</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>. You can set up cron job by visiting <a href="@cron">Cron configuration</a> page', array('@status' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron', '@cron' => url('admin/config/system/cron'))) . '</dd>';
  76. $output .= '<dt>' . t('Configuring basic site settings') . '</dt>';
  77. $output .= '<dd>' . t('The System module also handles basic configuration options for your site, including <a href="@date-time-settings">Date and time settings</a>, <a href="@file-system">File system settings</a>, <a href="@clean-url">Clean URL support</a>, <a href="@site-info">Site name and other information</a>, and a <a href="@maintenance-mode">Maintenance mode</a> for taking your site temporarily offline.', array('@date-time-settings' => url('admin/config/regional/date-time'), '@file-system' => url('admin/config/media/file-system'), '@clean-url' => url('admin/config/search/clean-urls'), '@site-info' => url('admin/config/system/site-information'), '@maintenance-mode' => url('admin/config/development/maintenance'))) . '</dd>';
  78. $output .= '<dt>' . t('Configuring actions') . '</dt>';
  79. $output .= '<dd>' . t('Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Modules, such as the <a href="@trigger-help">Trigger module</a>, can fire these actions when certain system events happen; for example, when a new post is added or when a user logs in. Modules may also provide additional actions. Visit the <a href="@actions">Actions page</a> to configure actions.', array('@trigger-help' => url('admin/help/trigger'), '@actions' => url('admin/config/system/actions'))) . '</dd>';
  80. $output .= '</dl>';
  81. return $output;
  82. case 'admin/index':
  83. return '<p>' . t('This page shows you all available administration tasks for each module.') . '</p>';
  84. case 'admin/appearance':
  85. $output = '<p>' . t('Set and configure the default theme for your website. Alternative <a href="@themes">themes</a> are available.', array('@themes' => 'http://drupal.org/project/themes')) . '</p>';
  86. return $output;
  87. case 'admin/appearance/settings/' . $arg[3]:
  88. $theme_list = list_themes();
  89. $theme = $theme_list[$arg[3]];
  90. return '<p>' . t('These options control the display settings for the %name theme. When your site is displayed using this theme, these settings will be used.', array('%name' => $theme->info['name'])) . '</p>';
  91. case 'admin/appearance/settings':
  92. return '<p>' . t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') . '</p>';
  93. case 'admin/modules':
  94. $output = '<p>' . t('Download additional <a href="@modules">contributed modules</a> to extend Drupal\'s functionality.', array('@modules' => 'http://drupal.org/project/modules')) . '</p>';
  95. if (module_exists('update')) {
  96. if (update_manager_access()) {
  97. $output .= '<p>' . t('Regularly review and install <a href="@updates">available updates</a> to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated.', array('@update-php' => $base_url . '/update.php', '@updates' => url('admin/reports/updates'))) . '</p>';
  98. }
  99. else {
  100. $output .= '<p>' . t('Regularly review <a href="@updates">available updates</a> to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated.', array('@update-php' => $base_url . '/update.php', '@updates' => url('admin/reports/updates'))) . '</p>';
  101. }
  102. }
  103. else {
  104. $output .= '<p>' . t('Regularly review available updates to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated. Enable the Update manager module to update and install modules and themes.', array('@update-php' => $base_url . '/update.php')) . '</p>';
  105. }
  106. return $output;
  107. case 'admin/modules/uninstall':
  108. return '<p>' . t('The uninstall process removes all data related to a module. To uninstall a module, you must first disable it on the main <a href="@modules">Modules page</a>.', array('@modules' => url('admin/modules'))) . '</p>';
  109. case 'admin/structure/block/manage':
  110. if ($arg[4] == 'system' && $arg[5] == 'powered-by') {
  111. return '<p>' . t('The <em>Powered by Drupal</em> block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.') . '</p>';
  112. }
  113. break;
  114. case 'admin/config/development/maintenance':
  115. global $user;
  116. if ($user->uid == 1) {
  117. return '<p>' . t('If you are upgrading to a newer version of Drupal or upgrading contributed modules or themes, you may need to run the <a href="@update-php">update script</a>.', array('@update-php' => $base_url . '/update.php')) . '</p>';
  118. }
  119. break;
  120. case 'admin/config/system/actions':
  121. case 'admin/config/system/actions/manage':
  122. $output = '';
  123. $output .= '<p>' . t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration, and are listed here automatically. Advanced actions need to be created and configured before they can be used, because they have options that need to be specified; for example, sending an e-mail to a specified address, or unpublishing content containing certain words. To create an advanced action, select the action from the drop-down list in the advanced action section below and click the <em>Create</em> button.') . '</p>';
  124. if (module_exists('trigger')) {
  125. $output .= '<p>' . t('You may proceed to the <a href="@url">Triggers</a> page to assign these actions to system events.', array('@url' => url('admin/structure/trigger'))) . '</p>';
  126. }
  127. return $output;
  128. case 'admin/config/system/actions/configure':
  129. return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the Trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").');
  130. case 'admin/config/people/ip-blocking':
  131. return '<p>' . t('IP addresses listed here are blocked from your site. Blocked addresses are completely forbidden from accessing the site and instead see a brief message explaining the situation.') . '</p>';
  132. case 'admin/reports/status':
  133. return '<p>' . t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on drupal.org's support forums and project issue queues.") . '</p>';
  134. }
  135. }
  136. /**
  137. * Implements hook_theme().
  138. */
  139. function system_theme() {
  140. return array_merge(drupal_common_theme(), array(
  141. 'system_themes_page' => array(
  142. 'variables' => array('theme_groups' => NULL),
  143. 'file' => 'system.admin.inc',
  144. ),
  145. 'system_settings_form' => array(
  146. 'render element' => 'form',
  147. ),
  148. 'confirm_form' => array(
  149. 'render element' => 'form',
  150. ),
  151. 'system_modules_fieldset' => array(
  152. 'render element' => 'form',
  153. 'file' => 'system.admin.inc',
  154. ),
  155. 'system_modules_incompatible' => array(
  156. 'variables' => array('message' => NULL),
  157. 'file' => 'system.admin.inc',
  158. ),
  159. 'system_modules_uninstall' => array(
  160. 'render element' => 'form',
  161. 'file' => 'system.admin.inc',
  162. ),
  163. 'status_report' => array(
  164. 'render element' => 'requirements',
  165. 'file' => 'system.admin.inc',
  166. ),
  167. 'admin_page' => array(
  168. 'variables' => array('blocks' => NULL),
  169. 'file' => 'system.admin.inc',
  170. ),
  171. 'admin_block' => array(
  172. 'variables' => array('block' => NULL),
  173. 'file' => 'system.admin.inc',
  174. ),
  175. 'admin_block_content' => array(
  176. 'variables' => array('content' => NULL),
  177. 'file' => 'system.admin.inc',
  178. ),
  179. 'system_admin_index' => array(
  180. 'variables' => array('menu_items' => NULL),
  181. 'file' => 'system.admin.inc',
  182. ),
  183. 'system_powered_by' => array(
  184. 'variables' => array(),
  185. ),
  186. 'system_compact_link' => array(
  187. 'variables' => array(),
  188. ),
  189. 'system_date_time_settings' => array(
  190. 'render element' => 'form',
  191. 'file' => 'system.admin.inc',
  192. ),
  193. ));
  194. }
  195. /**
  196. * Implements hook_permission().
  197. */
  198. function system_permission() {
  199. return array(
  200. 'administer modules' => array(
  201. 'title' => t('Administer modules'),
  202. ),
  203. 'administer site configuration' => array(
  204. 'title' => t('Administer site configuration'),
  205. 'restrict access' => TRUE,
  206. ),
  207. 'administer themes' => array(
  208. 'title' => t('Administer themes'),
  209. ),
  210. 'administer software updates' => array(
  211. 'title' => t('Administer software updates'),
  212. 'restrict access' => TRUE,
  213. ),
  214. 'administer actions' => array(
  215. 'title' => t('Administer actions'),
  216. ),
  217. 'access administration pages' => array(
  218. 'title' => t('Use the administration pages and help'),
  219. ),
  220. 'access site in maintenance mode' => array(
  221. 'title' => t('Use the site in maintenance mode'),
  222. ),
  223. 'view the administration theme' => array(
  224. 'title' => t('View the administration theme'),
  225. 'description' => variable_get('admin_theme') ? '' : t('This is only used when the site is configured to use a separate administration theme on the <a href="@appearance-url">Appearance</a> page.', array('@appearance-url' => url('admin/appearance'))),
  226. ),
  227. 'access site reports' => array(
  228. 'title' => t('View site reports'),
  229. ),
  230. 'block IP addresses' => array(
  231. 'title' => t('Block IP addresses'),
  232. ),
  233. );
  234. }
  235. /**
  236. * Implements hook_hook_info().
  237. */
  238. function system_hook_info() {
  239. $hooks['token_info'] = array(
  240. 'group' => 'tokens',
  241. );
  242. $hooks['token_info_alter'] = array(
  243. 'group' => 'tokens',
  244. );
  245. $hooks['tokens'] = array(
  246. 'group' => 'tokens',
  247. );
  248. $hooks['tokens_alter'] = array(
  249. 'group' => 'tokens',
  250. );
  251. return $hooks;
  252. }
  253. /**
  254. * Implements hook_entity_info().
  255. */
  256. function system_entity_info() {
  257. return array(
  258. 'file' => array(
  259. 'label' => t('File'),
  260. 'base table' => 'file_managed',
  261. 'entity keys' => array(
  262. 'id' => 'fid',
  263. 'label' => 'filename',
  264. ),
  265. 'static cache' => FALSE,
  266. ),
  267. );
  268. }
  269. /**
  270. * Implements hook_element_info().
  271. */
  272. function system_element_info() {
  273. // Top level elements.
  274. $types['form'] = array(
  275. '#method' => 'post',
  276. '#action' => request_uri(),
  277. '#theme_wrappers' => array('form'),
  278. );
  279. $types['page'] = array(
  280. '#show_messages' => TRUE,
  281. '#theme' => 'page',
  282. '#theme_wrappers' => array('html'),
  283. );
  284. // By default, we don't want Ajax commands being rendered in the context of an
  285. // HTML page, so we don't provide defaults for #theme or #theme_wrappers.
  286. // However, modules can set these properties (for example, to provide an HTML
  287. // debugging page that displays rather than executes Ajax commands).
  288. $types['ajax'] = array(
  289. '#header' => TRUE,
  290. '#commands' => array(),
  291. '#error' => NULL,
  292. );
  293. $types['html_tag'] = array(
  294. '#theme' => 'html_tag',
  295. '#pre_render' => array('drupal_pre_render_conditional_comments'),
  296. '#attributes' => array(),
  297. '#value' => NULL,
  298. );
  299. $types['styles'] = array(
  300. '#items' => array(),
  301. '#pre_render' => array('drupal_pre_render_styles'),
  302. '#group_callback' => 'drupal_group_css',
  303. '#aggregate_callback' => 'drupal_aggregate_css',
  304. );
  305. // Input elements.
  306. $types['submit'] = array(
  307. '#input' => TRUE,
  308. '#name' => 'op',
  309. '#button_type' => 'submit',
  310. '#executes_submit_callback' => TRUE,
  311. '#limit_validation_errors' => FALSE,
  312. '#process' => array('ajax_process_form'),
  313. '#theme_wrappers' => array('button'),
  314. );
  315. $types['button'] = array(
  316. '#input' => TRUE,
  317. '#name' => 'op',
  318. '#button_type' => 'submit',
  319. '#executes_submit_callback' => FALSE,
  320. '#limit_validation_errors' => FALSE,
  321. '#process' => array('ajax_process_form'),
  322. '#theme_wrappers' => array('button'),
  323. );
  324. $types['image_button'] = array(
  325. '#input' => TRUE,
  326. '#button_type' => 'submit',
  327. '#executes_submit_callback' => TRUE,
  328. '#limit_validation_errors' => FALSE,
  329. '#process' => array('ajax_process_form'),
  330. '#return_value' => TRUE,
  331. '#has_garbage_value' => TRUE,
  332. '#src' => NULL,
  333. '#theme_wrappers' => array('image_button'),
  334. );
  335. $types['textfield'] = array(
  336. '#input' => TRUE,
  337. '#size' => 60,
  338. '#maxlength' => 128,
  339. '#autocomplete_path' => FALSE,
  340. '#process' => array('ajax_process_form'),
  341. '#theme' => 'textfield',
  342. '#theme_wrappers' => array('form_element'),
  343. );
  344. $types['machine_name'] = array(
  345. '#input' => TRUE,
  346. '#default_value' => NULL,
  347. '#required' => TRUE,
  348. '#maxlength' => 64,
  349. '#size' => 60,
  350. '#autocomplete_path' => FALSE,
  351. '#process' => array('form_process_machine_name', 'ajax_process_form'),
  352. '#element_validate' => array('form_validate_machine_name'),
  353. '#theme' => 'textfield',
  354. '#theme_wrappers' => array('form_element'),
  355. );
  356. $types['password'] = array(
  357. '#input' => TRUE,
  358. '#size' => 60,
  359. '#maxlength' => 128,
  360. '#process' => array('ajax_process_form'),
  361. '#theme' => 'password',
  362. '#theme_wrappers' => array('form_element'),
  363. );
  364. $types['password_confirm'] = array(
  365. '#input' => TRUE,
  366. '#process' => array('form_process_password_confirm', 'user_form_process_password_confirm'),
  367. '#theme_wrappers' => array('form_element'),
  368. );
  369. $types['textarea'] = array(
  370. '#input' => TRUE,
  371. '#cols' => 60,
  372. '#rows' => 5,
  373. '#resizable' => TRUE,
  374. '#process' => array('ajax_process_form'),
  375. '#theme' => 'textarea',
  376. '#theme_wrappers' => array('form_element'),
  377. );
  378. $types['radios'] = array(
  379. '#input' => TRUE,
  380. '#process' => array('form_process_radios'),
  381. '#theme_wrappers' => array('radios'),
  382. '#pre_render' => array('form_pre_render_conditional_form_element'),
  383. );
  384. $types['radio'] = array(
  385. '#input' => TRUE,
  386. '#default_value' => NULL,
  387. '#process' => array('ajax_process_form'),
  388. '#theme' => 'radio',
  389. '#theme_wrappers' => array('form_element'),
  390. '#title_display' => 'after',
  391. );
  392. $types['checkboxes'] = array(
  393. '#input' => TRUE,
  394. '#process' => array('form_process_checkboxes'),
  395. '#theme_wrappers' => array('checkboxes'),
  396. '#pre_render' => array('form_pre_render_conditional_form_element'),
  397. );
  398. $types['checkbox'] = array(
  399. '#input' => TRUE,
  400. '#return_value' => 1,
  401. '#theme' => 'checkbox',
  402. '#process' => array('form_process_checkbox', 'ajax_process_form'),
  403. '#theme_wrappers' => array('form_element'),
  404. '#title_display' => 'after',
  405. );
  406. $types['select'] = array(
  407. '#input' => TRUE,
  408. '#multiple' => FALSE,
  409. '#process' => array('form_process_select', 'ajax_process_form'),
  410. '#theme' => 'select',
  411. '#theme_wrappers' => array('form_element'),
  412. );
  413. $types['weight'] = array(
  414. '#input' => TRUE,
  415. '#delta' => 10,
  416. '#default_value' => 0,
  417. '#process' => array('form_process_weight', 'ajax_process_form'),
  418. );
  419. $types['date'] = array(
  420. '#input' => TRUE,
  421. '#element_validate' => array('date_validate'),
  422. '#process' => array('form_process_date'),
  423. '#theme' => 'date',
  424. '#theme_wrappers' => array('form_element'),
  425. );
  426. $types['file'] = array(
  427. '#input' => TRUE,
  428. '#size' => 60,
  429. '#theme' => 'file',
  430. '#theme_wrappers' => array('form_element'),
  431. );
  432. $types['tableselect'] = array(
  433. '#input' => TRUE,
  434. '#js_select' => TRUE,
  435. '#multiple' => TRUE,
  436. '#process' => array('form_process_tableselect'),
  437. '#options' => array(),
  438. '#empty' => '',
  439. '#theme' => 'tableselect',
  440. );
  441. // Form structure.
  442. $types['item'] = array(
  443. '#markup' => '',
  444. '#pre_render' => array('drupal_pre_render_markup'),
  445. '#theme_wrappers' => array('form_element'),
  446. );
  447. $types['hidden'] = array(
  448. '#input' => TRUE,
  449. '#process' => array('ajax_process_form'),
  450. '#theme' => 'hidden',
  451. );
  452. $types['value'] = array(
  453. '#input' => TRUE,
  454. );
  455. $types['markup'] = array(
  456. '#markup' => '',
  457. '#pre_render' => array('drupal_pre_render_markup'),
  458. );
  459. $types['link'] = array(
  460. '#pre_render' => array('drupal_pre_render_link', 'drupal_pre_render_markup'),
  461. );
  462. $types['fieldset'] = array(
  463. '#collapsible' => FALSE,
  464. '#collapsed' => FALSE,
  465. '#value' => NULL,
  466. '#process' => array('form_process_fieldset', 'ajax_process_form'),
  467. '#pre_render' => array('form_pre_render_fieldset'),
  468. '#theme_wrappers' => array('fieldset'),
  469. );
  470. $types['vertical_tabs'] = array(
  471. '#theme_wrappers' => array('vertical_tabs'),
  472. '#default_tab' => '',
  473. '#process' => array('form_process_vertical_tabs'),
  474. );
  475. $types['container'] = array(
  476. '#theme_wrappers' => array('container'),
  477. '#process' => array('form_process_container'),
  478. );
  479. $types['actions'] = array(
  480. '#theme_wrappers' => array('container'),
  481. '#process' => array('form_process_actions', 'form_process_container'),
  482. '#weight' => 100,
  483. );
  484. $types['token'] = array(
  485. '#input' => TRUE,
  486. '#theme' => 'hidden',
  487. );
  488. return $types;
  489. }
  490. /**
  491. * Implements hook_menu().
  492. */
  493. function system_menu() {
  494. $items['system/files'] = array(
  495. 'title' => 'File download',
  496. 'page callback' => 'file_download',
  497. 'page arguments' => array('private'),
  498. 'access callback' => TRUE,
  499. 'type' => MENU_CALLBACK,
  500. );
  501. $items['system/temporary'] = array(
  502. 'title' => 'Temporary files',
  503. 'page callback' => 'file_download',
  504. 'page arguments' => array('temporary'),
  505. 'access callback' => TRUE,
  506. 'type' => MENU_CALLBACK,
  507. );
  508. $items['system/ajax'] = array(
  509. 'title' => 'AHAH callback',
  510. 'page callback' => 'ajax_form_callback',
  511. 'delivery callback' => 'ajax_deliver',
  512. 'access callback' => TRUE,
  513. 'theme callback' => 'ajax_base_page_theme',
  514. 'type' => MENU_CALLBACK,
  515. 'file path' => 'includes',
  516. 'file' => 'form.inc',
  517. );
  518. $items['system/timezone'] = array(
  519. 'title' => 'Time zone',
  520. 'page callback' => 'system_timezone',
  521. 'access callback' => TRUE,
  522. 'type' => MENU_CALLBACK,
  523. 'file' => 'system.admin.inc',
  524. );
  525. $items['admin'] = array(
  526. 'title' => 'Administration',
  527. 'access arguments' => array('access administration pages'),
  528. 'page callback' => 'system_admin_menu_block_page',
  529. 'weight' => 9,
  530. 'menu_name' => 'management',
  531. 'file' => 'system.admin.inc',
  532. );
  533. $items['admin/compact'] = array(
  534. 'title' => 'Compact mode',
  535. 'page callback' => 'system_admin_compact_page',
  536. 'access arguments' => array('access administration pages'),
  537. 'type' => MENU_CALLBACK,
  538. 'file' => 'system.admin.inc',
  539. );
  540. $items['admin/tasks'] = array(
  541. 'title' => 'Tasks',
  542. 'type' => MENU_DEFAULT_LOCAL_TASK,
  543. 'weight' => -20,
  544. );
  545. $items['admin/index'] = array(
  546. 'title' => 'Index',
  547. 'page callback' => 'system_admin_index',
  548. 'access arguments' => array('access administration pages'),
  549. 'type' => MENU_LOCAL_TASK,
  550. 'weight' => -18,
  551. 'file' => 'system.admin.inc',
  552. );
  553. // Menu items that are basically just menu blocks.
  554. $items['admin/structure'] = array(
  555. 'title' => 'Structure',
  556. 'description' => 'Administer blocks, content types, menus, etc.',
  557. 'position' => 'right',
  558. 'weight' => -8,
  559. 'page callback' => 'system_admin_menu_block_page',
  560. 'access arguments' => array('access administration pages'),
  561. 'file' => 'system.admin.inc',
  562. );
  563. // Appearance.
  564. $items['admin/appearance'] = array(
  565. 'title' => 'Appearance',
  566. 'description' => 'Select and configure your themes.',
  567. 'page callback' => 'system_themes_page',
  568. 'access arguments' => array('administer themes'),
  569. 'position' => 'left',
  570. 'weight' => -6,
  571. 'file' => 'system.admin.inc',
  572. );
  573. $items['admin/appearance/list'] = array(
  574. 'title' => 'List',
  575. 'description' => 'Select and configure your theme',
  576. 'type' => MENU_DEFAULT_LOCAL_TASK,
  577. 'weight' => -1,
  578. 'file' => 'system.admin.inc',
  579. );
  580. $items['admin/appearance/enable'] = array(
  581. 'title' => 'Enable theme',
  582. 'page callback' => 'system_theme_enable',
  583. 'access arguments' => array('administer themes'),
  584. 'type' => MENU_CALLBACK,
  585. 'file' => 'system.admin.inc',
  586. );
  587. $items['admin/appearance/disable'] = array(
  588. 'title' => 'Disable theme',
  589. 'page callback' => 'system_theme_disable',
  590. 'access arguments' => array('administer themes'),
  591. 'type' => MENU_CALLBACK,
  592. 'file' => 'system.admin.inc',
  593. );
  594. $items['admin/appearance/default'] = array(
  595. 'title' => 'Set default theme',
  596. 'page callback' => 'system_theme_default',
  597. 'access arguments' => array('administer themes'),
  598. 'type' => MENU_CALLBACK,
  599. 'file' => 'system.admin.inc',
  600. );
  601. $items['admin/appearance/settings'] = array(
  602. 'title' => 'Settings',
  603. 'description' => 'Configure default and theme specific settings.',
  604. 'page callback' => 'drupal_get_form',
  605. 'page arguments' => array('system_theme_settings'),
  606. 'access arguments' => array('administer themes'),
  607. 'type' => MENU_LOCAL_TASK,
  608. 'file' => 'system.admin.inc',
  609. 'weight' => 20,
  610. );
  611. // Theme configuration subtabs.
  612. $items['admin/appearance/settings/global'] = array(
  613. 'title' => 'Global settings',
  614. 'type' => MENU_DEFAULT_LOCAL_TASK,
  615. 'weight' => -1,
  616. );
  617. foreach (list_themes() as $theme) {
  618. $items['admin/appearance/settings/' . $theme->name] = array(
  619. 'title' => $theme->info['name'],
  620. 'page arguments' => array('system_theme_settings', $theme->name),
  621. 'type' => MENU_LOCAL_TASK,
  622. 'access callback' => '_system_themes_access',
  623. 'access arguments' => array($theme),
  624. 'file' => 'system.admin.inc',
  625. );
  626. }
  627. // Modules.
  628. $items['admin/modules'] = array(
  629. 'title' => 'Modules',
  630. 'description' => 'Extend site functionality.',
  631. 'page callback' => 'drupal_get_form',
  632. 'page arguments' => array('system_modules'),
  633. 'access arguments' => array('administer modules'),
  634. 'file' => 'system.admin.inc',
  635. 'weight' => -2,
  636. );
  637. $items['admin/modules/list'] = array(
  638. 'title' => 'List',
  639. 'type' => MENU_DEFAULT_LOCAL_TASK,
  640. );
  641. $items['admin/modules/list/confirm'] = array(
  642. 'title' => 'List',
  643. 'access arguments' => array('administer modules'),
  644. 'type' => MENU_VISIBLE_IN_BREADCRUMB,
  645. );
  646. $items['admin/modules/uninstall'] = array(
  647. 'title' => 'Uninstall',
  648. 'page arguments' => array('system_modules_uninstall'),
  649. 'access arguments' => array('administer modules'),
  650. 'type' => MENU_LOCAL_TASK,
  651. 'file' => 'system.admin.inc',
  652. 'weight' => 20,
  653. );
  654. $items['admin/modules/uninstall/confirm'] = array(
  655. 'title' => 'Uninstall',
  656. 'access arguments' => array('administer modules'),
  657. 'type' => MENU_VISIBLE_IN_BREADCRUMB,
  658. 'file' => 'system.admin.inc',
  659. );
  660. // Configuration.
  661. $items['admin/config'] = array(
  662. 'title' => 'Configuration',
  663. 'description' => 'Administer settings.',
  664. 'page callback' => 'system_admin_config_page',
  665. 'access arguments' => array('access administration pages'),
  666. 'file' => 'system.admin.inc',
  667. );
  668. // IP address blocking.
  669. $items['admin/config/people/ip-blocking'] = array(
  670. 'title' => 'IP address blocking',
  671. 'description' => 'Manage blocked IP addresses.',
  672. 'page callback' => 'system_ip_blocking',
  673. 'access arguments' => array('block IP addresses'),
  674. 'file' => 'system.admin.inc',
  675. 'weight' => 10,
  676. );
  677. $items['admin/config/people/ip-blocking/delete/%blocked_ip'] = array(
  678. 'title' => 'Delete IP address',
  679. 'page callback' => 'drupal_get_form',
  680. 'page arguments' => array('system_ip_blocking_delete', 5),
  681. 'access arguments' => array('block IP addresses'),
  682. 'file' => 'system.admin.inc',
  683. );
  684. // Media settings.
  685. $items['admin/config/media'] = array(
  686. 'title' => 'Media',
  687. 'description' => 'Media tools.',
  688. 'position' => 'left',
  689. 'weight' => -10,
  690. 'page callback' => 'system_admin_menu_block_page',
  691. 'access arguments' => array('access administration pages'),
  692. 'file' => 'system.admin.inc',
  693. );
  694. $items['admin/config/media/file-system'] = array(
  695. 'title' => 'File system',
  696. 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
  697. 'page callback' => 'drupal_get_form',
  698. 'page arguments' => array('system_file_system_settings'),
  699. 'access arguments' => array('administer site configuration'),
  700. 'weight' => -10,
  701. 'file' => 'system.admin.inc',
  702. );
  703. $items['admin/config/media/image-toolkit'] = array(
  704. 'title' => 'Image toolkit',
  705. 'description' => 'Choose which image toolkit to use if you have installed optional toolkits.',
  706. 'page callback' => 'drupal_get_form',
  707. 'page arguments' => array('system_image_toolkit_settings'),
  708. 'access arguments' => array('administer site configuration'),
  709. 'weight' => 20,
  710. 'file' => 'system.admin.inc',
  711. );
  712. // Service settings.
  713. $items['admin/config/services'] = array(
  714. 'title' => 'Web services',
  715. 'description' => 'Tools related to web services.',
  716. 'position' => 'right',
  717. 'weight' => 0,
  718. 'page callback' => 'system_admin_menu_block_page',
  719. 'access arguments' => array('access administration pages'),
  720. 'file' => 'system.admin.inc',
  721. );
  722. $items['admin/config/services/rss-publishing'] = array(
  723. 'title' => 'RSS publishing',
  724. 'description' => 'Configure the site description, the number of items per feed and whether feeds should be titles/teasers/full-text.',
  725. 'page callback' => 'drupal_get_form',
  726. 'page arguments' => array('system_rss_feeds_settings'),
  727. 'access arguments' => array('administer site configuration'),
  728. 'file' => 'system.admin.inc',
  729. );
  730. // Development settings.
  731. $items['admin/config/development'] = array(
  732. 'title' => 'Development',
  733. 'description' => 'Development tools.',
  734. 'position' => 'right',
  735. 'weight' => -10,
  736. 'page callback' => 'system_admin_menu_block_page',
  737. 'access arguments' => array('access administration pages'),
  738. 'file' => 'system.admin.inc',
  739. );
  740. $items['admin/config/development/maintenance'] = array(
  741. 'title' => 'Maintenance mode',
  742. 'description' => 'Take the site offline for maintenance or bring it back online.',
  743. 'page callback' => 'drupal_get_form',
  744. 'page arguments' => array('system_site_maintenance_mode'),
  745. 'access arguments' => array('administer site configuration'),
  746. 'file' => 'system.admin.inc',
  747. 'weight' => -10,
  748. );
  749. $items['admin/config/development/performance'] = array(
  750. 'title' => 'Performance',
  751. 'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.',
  752. 'page callback' => 'drupal_get_form',
  753. 'page arguments' => array('system_performance_settings'),
  754. 'access arguments' => array('administer site configuration'),
  755. 'file' => 'system.admin.inc',
  756. 'weight' => -20,
  757. );
  758. $items['admin/config/development/logging'] = array(
  759. 'title' => 'Logging and errors',
  760. 'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destinations, such as syslog, database, email, etc.",
  761. 'page callback' => 'drupal_get_form',
  762. 'page arguments' => array('system_logging_settings'),
  763. 'access arguments' => array('administer site configuration'),
  764. 'file' => 'system.admin.inc',
  765. 'weight' => -15,
  766. );
  767. // Regional and date settings.
  768. $items['admin/config/regional'] = array(
  769. 'title' => 'Regional and language',
  770. 'description' => 'Regional settings, localization and translation.',
  771. 'position' => 'left',
  772. 'weight' => -5,
  773. 'page callback' => 'system_admin_menu_block_page',
  774. 'access arguments' => array('access administration pages'),
  775. 'file' => 'system.admin.inc',
  776. );
  777. $items['admin/config/regional/settings'] = array(
  778. 'title' => 'Regional settings',
  779. 'description' => "Settings for the site's default time zone and country.",
  780. 'page callback' => 'drupal_get_form',
  781. 'page arguments' => array('system_regional_settings'),
  782. 'access arguments' => array('administer site configuration'),
  783. 'weight' => -20,
  784. 'file' => 'system.admin.inc',
  785. );
  786. $items['admin/config/regional/date-time'] = array(
  787. 'title' => 'Date and time',
  788. 'description' => 'Configure display formats for date and time.',
  789. 'page callback' => 'drupal_get_form',
  790. 'page arguments' => array('system_date_time_settings'),
  791. 'access arguments' => array('administer site configuration'),
  792. 'weight' => -15,
  793. 'file' => 'system.admin.inc',
  794. );
  795. $items['admin/config/regional/date-time/types'] = array(
  796. 'title' => 'Types',
  797. 'description' => 'Configure display formats for date and time.',
  798. 'page callback' => 'drupal_get_form',
  799. 'page arguments' => array('system_date_time_settings'),
  800. 'access arguments' => array('administer site configuration'),
  801. 'type' => MENU_DEFAULT_LOCAL_TASK,
  802. 'weight' => -10,
  803. 'file' => 'system.admin.inc',
  804. );
  805. $items['admin/config/regional/date-time/types/add'] = array(
  806. 'title' => 'Add date type',
  807. 'description' => 'Add new date type.',
  808. 'page callback' => 'drupal_get_form',
  809. 'page arguments' => array('system_add_date_format_type_form'),
  810. 'access arguments' => array('administer site configuration'),
  811. 'type' => MENU_LOCAL_ACTION,
  812. 'weight' => -10,
  813. 'file' => 'system.admin.inc',
  814. );
  815. $items['admin/config/regional/date-time/types/%/delete'] = array(
  816. 'title' => 'Delete date type',
  817. 'description' => 'Allow users to delete a configured date type.',
  818. 'page callback' => 'drupal_get_form',
  819. 'page arguments' => array('system_delete_date_format_type_form', 5),
  820. 'access arguments' => array('administer site configuration'),
  821. 'file' => 'system.admin.inc',
  822. );
  823. $items['admin/config/regional/date-time/formats'] = array(
  824. 'title' => 'Formats',
  825. 'description' => 'Configure display format strings for date and time.',
  826. 'page callback' => 'system_date_time_formats',
  827. 'access arguments' => array('administer site configuration'),
  828. 'type' => MENU_LOCAL_TASK,
  829. 'weight' => -9,
  830. 'file' => 'system.admin.inc',
  831. );
  832. $items['admin/config/regional/date-time/formats/add'] = array(
  833. 'title' => 'Add format',
  834. 'description' => 'Allow users to add additional date formats.',
  835. 'type' => MENU_LOCAL_ACTION,
  836. 'page callback' => 'drupal_get_form',
  837. 'page arguments' => array('system_configure_date_formats_form'),
  838. 'access arguments' => array('administer site configuration'),
  839. 'weight' => -10,
  840. 'file' => 'system.admin.inc',
  841. );
  842. $items['admin/config/regional/date-time/formats/%/edit'] = array(
  843. 'title' => 'Edit date format',
  844. 'description' => 'Allow users to edit a configured date format.',
  845. 'page callback' => 'drupal_get_form',
  846. 'page arguments' => array('system_configure_date_formats_form', 5),
  847. 'access arguments' => array('administer site configuration'),
  848. 'file' => 'system.admin.inc',
  849. );
  850. $items['admin/config/regional/date-time/formats/%/delete'] = array(
  851. 'title' => 'Delete date format',
  852. 'description' => 'Allow users to delete a configured date format.',
  853. 'page callback' => 'drupal_get_form',
  854. 'page arguments' => array('system_date_delete_format_form', 5),
  855. 'access arguments' => array('administer site configuration'),
  856. 'file' => 'system.admin.inc',
  857. );
  858. $items['admin/config/regional/date-time/formats/lookup'] = array(
  859. 'title' => 'Date and time lookup',
  860. 'page callback' => 'system_date_time_lookup',
  861. 'access arguments' => array('administer site configuration'),
  862. 'type' => MENU_CALLBACK,
  863. 'file' => 'system.admin.inc',
  864. );
  865. // Search settings.
  866. $items['admin/config/search'] = array(
  867. 'title' => 'Search and metadata',
  868. 'description' => 'Local site search, metadata and SEO.',
  869. 'position' => 'left',
  870. 'weight' => -10,
  871. 'page callback' => 'system_admin_menu_block_page',
  872. 'access arguments' => array('access administration pages'),
  873. 'file' => 'system.admin.inc',
  874. );
  875. $items['admin/config/search/clean-urls'] = array(
  876. 'title' => 'Clean URLs',
  877. 'description' => 'Enable or disable clean URLs for your site.',
  878. 'page callback' => 'drupal_get_form',
  879. 'page arguments' => array('system_clean_url_settings'),
  880. 'access arguments' => array('administer site configuration'),
  881. 'file' => 'system.admin.inc',
  882. 'weight' => 5,
  883. );
  884. $items['admin/config/search/clean-urls/check'] = array(
  885. 'title' => 'Clean URL check',
  886. 'page callback' => 'drupal_json_output',
  887. 'page arguments' => array(array('status' => TRUE)),
  888. 'access callback' => TRUE,
  889. 'type' => MENU_CALLBACK,
  890. 'file' => 'system.admin.inc',
  891. );
  892. // System settings.
  893. $items['admin/config/system'] = array(
  894. 'title' => 'System',
  895. 'description' => 'General system related configuration.',
  896. 'position' => 'right',
  897. 'weight' => -20,
  898. 'page callback' => 'system_admin_menu_block_page',
  899. 'access arguments' => array('access administration pages'),
  900. 'file' => 'system.admin.inc',
  901. );
  902. $items['admin/config/system/actions'] = array(
  903. 'title' => 'Actions',
  904. 'description' => 'Manage the actions defined for your site.',
  905. 'access arguments' => array('administer actions'),
  906. 'page callback' => 'system_actions_manage',
  907. 'file' => 'system.admin.inc',
  908. );
  909. $items['admin/config/system/actions/manage'] = array(
  910. 'title' => 'Manage actions',
  911. 'description' => 'Manage the actions defined for your site.',
  912. 'page callback' => 'system_actions_manage',
  913. 'type' => MENU_DEFAULT_LOCAL_TASK,
  914. 'weight' => -2,
  915. 'file' => 'system.admin.inc',
  916. );
  917. $items['admin/config/system/actions/configure'] = array(
  918. 'title' => 'Configure an advanced action',
  919. 'page callback' => 'drupal_get_form',
  920. 'page arguments' => array('system_actions_configure'),
  921. 'access arguments' => array('administer actions'),
  922. 'type' => MENU_VISIBLE_IN_BREADCRUMB,
  923. 'file' => 'system.admin.inc',
  924. );
  925. $items['admin/config/system/actions/delete/%actions'] = array(
  926. 'title' => 'Delete action',
  927. 'description' => 'Delete an action.',
  928. 'page callback' => 'drupal_get_form',
  929. 'page arguments' => array('system_actions_delete_form', 5),
  930. 'access arguments' => array('administer actions'),
  931. 'file' => 'system.admin.inc',
  932. );
  933. $items['admin/config/system/actions/orphan'] = array(
  934. 'title' => 'Remove orphans',
  935. 'page callback' => 'system_actions_remove_orphans',
  936. 'access arguments' => array('administer actions'),
  937. 'type' => MENU_CALLBACK,
  938. 'file' => 'system.admin.inc',
  939. );
  940. $items['admin/config/system/site-information'] = array(
  941. 'title' => 'Site information',
  942. 'description' => 'Change site name, e-mail address, slogan, default front page, and number of posts per page, error pages.',
  943. 'page callback' => 'drupal_get_form',
  944. 'page arguments' => array('system_site_information_settings'),
  945. 'access arguments' => array('administer site configuration'),
  946. 'file' => 'system.admin.inc',
  947. 'weight' => -20,
  948. );
  949. $items['admin/config/system/cron'] = array(
  950. 'title' => 'Cron',
  951. 'description' => 'Manage automatic site maintenance tasks.',
  952. 'page callback' => 'drupal_get_form',
  953. 'page arguments' => array('system_cron_settings'),
  954. 'access arguments' => array('administer site configuration'),
  955. 'file' => 'system.admin.inc',
  956. 'weight' => 20,
  957. );
  958. // Additional categories
  959. $items['admin/config/user-interface'] = array(
  960. 'title' => 'User interface',
  961. 'description' => 'Tools that enhance the user interface.',
  962. 'position' => 'right',
  963. 'page callback' => 'system_admin_menu_block_page',
  964. 'access arguments' => array('access administration pages'),
  965. 'file' => 'system.admin.inc',
  966. 'weight' => -15,
  967. );
  968. $items['admin/config/workflow'] = array(
  969. 'title' => 'Workflow',
  970. 'description' => 'Content workflow, editorial workflow tools.',
  971. 'position' => 'right',
  972. 'weight' => 5,
  973. 'page callback' => 'system_admin_menu_block_page',
  974. 'access arguments' => array('access administration pages'),
  975. 'file' => 'system.admin.inc',
  976. );
  977. $items['admin/config/content'] = array(
  978. 'title' => 'Content authoring',
  979. 'description' => 'Settings related to formatting and authoring content.',
  980. 'position' => 'left',
  981. 'weight' => -15,
  982. 'page callback' => 'system_admin_menu_block_page',
  983. 'access arguments' => array('access administration pages'),
  984. 'file' => 'system.admin.inc',
  985. );
  986. // Reports.
  987. $items['admin/reports'] = array(
  988. 'title' => 'Reports',
  989. 'description' => 'View reports, updates, and errors.',
  990. 'page callback' => 'system_admin_menu_block_page',
  991. 'access arguments' => array('access site reports'),
  992. 'weight' => 5,
  993. 'position' => 'left',
  994. 'file' => 'system.admin.inc',
  995. );
  996. $items['admin/reports/status'] = array(
  997. 'title' => 'Status report',
  998. 'description' => "Get a status report about your site's operation and any detected problems.",
  999. 'page callback' => 'system_status',
  1000. 'weight' => -60,
  1001. 'access arguments' => array('administer site configuration'),
  1002. 'file' => 'system.admin.inc',
  1003. );
  1004. $items['admin/reports/status/run-cron'] = array(
  1005. 'title' => 'Run cron',
  1006. 'page callback' => 'system_run_cron',
  1007. 'access arguments' => array('administer site configuration'),
  1008. 'type' => MENU_CALLBACK,
  1009. 'file' => 'system.admin.inc',
  1010. );
  1011. $items['admin/reports/status/php'] = array(
  1012. 'title' => 'PHP',
  1013. 'page callback' => 'system_php',
  1014. 'access arguments' => array('administer site configuration'),
  1015. 'type' => MENU_CALLBACK,
  1016. 'file' => 'system.admin.inc',
  1017. );
  1018. // Default page for batch operations.
  1019. $items['batch'] = array(
  1020. 'page callback' => 'system_batch_page',
  1021. 'access callback' => TRUE,
  1022. 'theme callback' => '_system_batch_theme',
  1023. 'type' => MENU_CALLBACK,
  1024. 'file' => 'system.admin.inc',
  1025. );
  1026. return $items;
  1027. }
  1028. /**
  1029. * Theme callback for the default batch page.
  1030. */
  1031. function _system_batch_theme() {
  1032. // Retrieve the current state of the batch.
  1033. $batch = &batch_get();
  1034. if (!$batch && isset($_REQUEST['id'])) {
  1035. require_once DRUPAL_ROOT . '/includes/batch.inc';
  1036. $batch = batch_load($_REQUEST['id']);
  1037. }
  1038. // Use the same theme as the page that started the batch.
  1039. if (!empty($batch['theme'])) {
  1040. return $batch['theme'];
  1041. }
  1042. }
  1043. /**
  1044. * Implements hook_library().
  1045. */
  1046. function system_library() {
  1047. // Drupal's Ajax framework.
  1048. $libraries['drupal.ajax'] = array(
  1049. 'title' => 'Drupal AJAX',
  1050. 'website' => 'http://api.drupal.org/api/drupal/includes--ajax.inc/group/ajax/7',
  1051. 'version' => VERSION,
  1052. 'js' => array(
  1053. 'misc/ajax.js' => array('group' => JS_LIBRARY, 'weight' => 2),
  1054. ),
  1055. 'dependencies' => array(
  1056. array('system', 'drupal.progress'),
  1057. ),
  1058. );
  1059. // Drupal's batch API.
  1060. $libraries['drupal.batch'] = array(
  1061. 'title' => 'Drupal batch API',
  1062. 'version' => VERSION,
  1063. 'js' => array(
  1064. 'misc/batch.js' => array('group' => JS_DEFAULT, 'cache' => FALSE),
  1065. ),
  1066. 'dependencies' => array(
  1067. array('system', 'drupal.progress'),
  1068. ),
  1069. );
  1070. // Drupal's progress indicator.
  1071. $libraries['drupal.progress'] = array(
  1072. 'title' => 'Drupal progress indicator',
  1073. 'version' => VERSION,
  1074. 'js' => array(
  1075. 'misc/progress.js' => array('group' => JS_DEFAULT),
  1076. ),
  1077. );
  1078. // Drupal's form library.
  1079. $libraries['drupal.form'] = array(
  1080. 'title' => 'Drupal form library',
  1081. 'version' => VERSION,
  1082. 'js' => array(
  1083. 'misc/form.js' => array('group' => JS_LIBRARY, 'weight' => 1),
  1084. ),
  1085. );
  1086. // Drupal's states library.
  1087. $libraries['drupal.states'] = array(
  1088. 'title' => 'Drupal states',
  1089. 'version' => VERSION,
  1090. 'js' => array(
  1091. 'misc/states.js' => array('group' => JS_LIBRARY, 'weight' => 1),
  1092. ),
  1093. );
  1094. // Drupal's collapsible fieldset.
  1095. $libraries['drupal.collapse'] = array(
  1096. 'title' => 'Drupal collapsible fieldset',
  1097. 'version' => VERSION,
  1098. 'js' => array(
  1099. 'misc/collapse.js' => array('group' => JS_DEFAULT),
  1100. ),
  1101. 'dependencies' => array(
  1102. // collapse.js relies on drupalGetSummary in form.js
  1103. array('system', 'drupal.form'),
  1104. ),
  1105. );
  1106. // Drupal's resizable textarea.
  1107. $libraries['drupal.textarea'] = array(
  1108. 'title' => 'Drupal resizable textarea',
  1109. 'version' => VERSION,
  1110. 'js' => array(
  1111. 'misc/textarea.js' => array('group' => JS_DEFAULT),
  1112. ),
  1113. );
  1114. // Drupal's autocomplete widget.
  1115. $libraries['drupal.autocomplete'] = array(
  1116. 'title' => 'Drupal autocomplete',
  1117. 'version' => VERSION,
  1118. 'js' => array(
  1119. 'misc/autocomplete.js' => array('group' => JS_DEFAULT),
  1120. ),
  1121. );
  1122. // jQuery.
  1123. $libraries['jquery'] = array(
  1124. 'title' => 'jQuery',
  1125. 'website' => 'http://jquery.com',
  1126. 'version' => '1.4.4',
  1127. 'js' => array(
  1128. 'misc/jquery.js' => array('group' => JS_LIBRARY, 'weight' => -20),
  1129. ),
  1130. );
  1131. // jQuery Once.
  1132. $libraries['jquery.once'] = array(
  1133. 'title' => 'jQuery Once',
  1134. 'website' => 'http://plugins.jquery.com/project/once',
  1135. 'version' => '1.2',
  1136. 'js' => array(
  1137. 'misc/jquery.once.js' => array('group' => JS_LIBRARY, 'weight' => -19),
  1138. ),
  1139. );
  1140. // jQuery Form Plugin.
  1141. $libraries['jquery.form'] = array(
  1142. 'title' => 'jQuery Form Plugin',
  1143. 'website' => 'http://malsup.com/jquery/form/',
  1144. 'version' => '2.52',
  1145. 'js' => array(
  1146. 'misc/jquery.form.js' => array(),
  1147. ),
  1148. 'dependencies' => array(
  1149. array('system', 'jquery.cookie'),
  1150. ),
  1151. );
  1152. // jQuery BBQ plugin.
  1153. $libraries['jquery.bbq'] = array(
  1154. 'title' => 'jQuery BBQ',
  1155. 'website' => 'http://benalman.com/projects/jquery-bbq-plugin/',
  1156. 'version' => '1.2.1',
  1157. 'js' => array(
  1158. 'misc/jquery.ba-bbq.js' => array(),
  1159. ),
  1160. );
  1161. // Vertical Tabs.
  1162. $libraries['drupal.vertical-tabs'] = array(
  1163. 'title' => 'Vertical Tabs',
  1164. 'website' => 'http://drupal.org/node/323112',
  1165. 'version' => '1.0',
  1166. 'js' => array(
  1167. 'misc/vertical-tabs.js' => array(),
  1168. ),
  1169. 'css' => array(
  1170. 'misc/vertical-tabs.css' => array(),
  1171. ),
  1172. 'dependencies' => array(
  1173. // Vertical tabs relies on drupalGetSummary in form.js
  1174. array('system', 'drupal.form'),
  1175. ),
  1176. );
  1177. // Farbtastic.
  1178. $libraries['farbtastic'] = array(
  1179. 'title' => 'Farbtastic',
  1180. 'website' => 'http://code.google.com/p/farbtastic/',
  1181. 'version' => '1.2',
  1182. 'js' => array(
  1183. 'misc/farbtastic/farbtastic.js' => array(),
  1184. ),
  1185. 'css' => array(
  1186. 'misc/farbtastic/farbtastic.css' => array(),
  1187. ),
  1188. );
  1189. // Cookie.
  1190. $libraries['jquery.cookie'] = array(
  1191. 'title' => 'Cookie',
  1192. 'website' => 'http://plugins.jquery.com/project/cookie',
  1193. 'version' => '1.0',
  1194. 'js' => array(
  1195. 'misc/jquery.cookie.js' => array(),
  1196. ),
  1197. );
  1198. // jQuery UI.
  1199. $libraries['ui'] = array(
  1200. 'title' => 'jQuery UI: Core',
  1201. 'website' => 'http://jqueryui.com',
  1202. 'version' => '1.8.7',
  1203. 'js' => array(
  1204. 'misc/ui/jquery.ui.core.min.js' => array('group' => JS_LIBRARY, 'weight' => -11),
  1205. ),
  1206. 'css' => array(
  1207. 'misc/ui/jquery.ui.core.css' => array(),
  1208. 'misc/ui/jquery.ui.theme.css' => array(),
  1209. ),
  1210. );
  1211. $libraries['ui.accordion'] = array(
  1212. 'title' => 'jQuery UI: Accordion',
  1213. 'website' => 'http://jqueryui.com/demos/accordion/',
  1214. 'version' => '1.8.7',
  1215. 'js' => array(
  1216. 'misc/ui/jquery.ui.accordion.min.js' => array(),
  1217. ),
  1218. 'css' => array(
  1219. 'misc/ui/jquery.ui.accordion.css' => array(),
  1220. ),
  1221. 'dependencies' => array(
  1222. array('system', 'ui.widget'),
  1223. ),
  1224. );
  1225. $libraries['ui.autocomplete'] = array(
  1226. 'title' => 'jQuery UI: Autocomplete',
  1227. 'website' => 'http://jqueryui.com/demos/autocomplete/',
  1228. 'version' => '1.8.7',
  1229. 'js' => array(
  1230. 'misc/ui/jquery.ui.autocomplete.min.js' => array(),
  1231. ),
  1232. 'css' => array(
  1233. 'misc/ui/jquery.ui.autocomplete.css' => array(),
  1234. ),
  1235. 'dependencies' => array(
  1236. array('system', 'ui.widget'),
  1237. array('system', 'ui.position'),
  1238. ),
  1239. );
  1240. $libraries['ui.button'] = array(
  1241. 'title' => 'jQuery UI: Button',
  1242. 'website' => 'http://jqueryui.com/demos/button/',
  1243. 'version' => '1.8.7',
  1244. 'js' => array(
  1245. 'misc/ui/jquery.ui.button.min.js' => array(),
  1246. ),
  1247. 'css' => array(
  1248. 'misc/ui/jquery.ui.button.css' => array(),
  1249. ),
  1250. 'dependencies' => array(
  1251. array('system', 'ui.widget'),
  1252. ),
  1253. );
  1254. $libraries['ui.datepicker'] = array(
  1255. 'title' => 'jQuery UI: Date Picker',
  1256. 'website' => 'http://jqueryui.com/demos/datepicker/',
  1257. 'version' => '1.8.7',
  1258. 'js' => array(
  1259. 'misc/ui/jquery.ui.datepicker.min.js' => array(),
  1260. ),
  1261. 'css' => array(
  1262. 'misc/ui/jquery.ui.datepicker.css' => array(),
  1263. ),
  1264. 'dependencies' => array(
  1265. array('system', 'ui'),
  1266. ),
  1267. );
  1268. $libraries['ui.dialog'] = array(
  1269. 'title' => 'jQuery UI: Dialog',
  1270. 'website' => 'http://jqueryui.com/demos/dialog/',
  1271. 'version' => '1.8.7',
  1272. 'js' => array(
  1273. 'misc/ui/jquery.ui.dialog.min.js' => array(),
  1274. ),
  1275. 'css' => array(
  1276. 'misc/ui/jquery.ui.dialog.css' => array(),
  1277. ),
  1278. 'dependencies' => array(
  1279. array('system', 'ui.widget'),
  1280. array('system', 'ui.button'),
  1281. array('system', 'ui.draggable'),
  1282. array('system', 'ui.mouse'),
  1283. array('system', 'ui.position'),
  1284. array('system', 'ui.resizable'),
  1285. ),
  1286. );
  1287. $libraries['ui.draggable'] = array(
  1288. 'title' => 'jQuery UI: Draggable',
  1289. 'website' => 'http://jqueryui.com/demos/draggable/',
  1290. 'version' => '1.8.7',
  1291. 'js' => array(
  1292. 'misc/ui/jquery.ui.draggable.min.js' => array(),
  1293. ),
  1294. 'dependencies' => array(
  1295. array('system', 'ui.widget'),
  1296. array('system', 'ui.mouse'),
  1297. ),
  1298. );
  1299. $libraries['ui.droppable'] = array(
  1300. 'title' => 'jQuery UI: Droppable',
  1301. 'website' => 'http://jqueryui.com/demos/droppable/',
  1302. 'version' => '1.8.7',
  1303. 'js' => array(
  1304. 'misc/ui/jquery.ui.droppable.min.js' => array(),
  1305. ),
  1306. 'dependencies' => array(
  1307. array('system', 'ui.widget'),
  1308. array('system', 'ui.mouse'),
  1309. array('system', 'ui.draggable'),
  1310. ),
  1311. );
  1312. $libraries['ui.mouse'] = array(
  1313. 'title' => 'jQuery UI: Mouse',
  1314. 'website' => 'http://docs.jquery.com/UI/Mouse',
  1315. 'version' => '1.8.7',
  1316. 'js' => array(
  1317. 'misc/ui/jquery.ui.mouse.min.js' => array(),
  1318. ),
  1319. 'dependencies' => array(
  1320. array('system', 'ui.widget'),
  1321. ),
  1322. );
  1323. $libraries['ui.position'] = array(
  1324. 'title' => 'jQuery UI: Position',
  1325. 'website' => 'http://jqueryui.com/demos/position/',
  1326. 'version' => '1.8.7',
  1327. 'js' => array(
  1328. 'misc/ui/jquery.ui.position.min.js' => array(),
  1329. ),
  1330. );
  1331. $libraries['ui.progressbar'] = array(
  1332. 'title' => 'jQuery UI: Progress Bar',
  1333. 'website' => 'http://jqueryui.com/demos/progressbar/',
  1334. 'version' => '1.8.7',
  1335. 'js' => array(
  1336. 'misc/ui/jquery.ui.progressbar.min.js' => array(),
  1337. ),
  1338. 'css' => array(
  1339. 'misc/ui/jquery.ui.progressbar.css' => array(),
  1340. ),
  1341. 'dependencies' => array(
  1342. array('system', 'ui.widget'),
  1343. ),
  1344. );
  1345. $libraries['ui.resizable'] = array(
  1346. 'title' => 'jQuery UI: Resizable',
  1347. 'website' => 'http://jqueryui.com/demos/resizable/',
  1348. 'version' => '1.8.7',
  1349. 'js' => array(
  1350. 'misc/ui/jquery.ui.resizable.min.js' => array(),
  1351. ),
  1352. 'css' => array(
  1353. 'misc/ui/jquery.ui.resizable.css' => array(),
  1354. ),
  1355. 'dependencies' => array(
  1356. array('system', 'ui.widget'),
  1357. array('system', 'ui.mouse'),
  1358. ),
  1359. );
  1360. $libraries['ui.selectable'] = array(
  1361. 'title' => 'jQuery UI: Selectable',
  1362. 'website' => 'http://jqueryui.com/demos/selectable/',
  1363. 'version' => '1.8.7',
  1364. 'js' => array(
  1365. 'misc/ui/jquery.ui.selectable.min.js' => array(),
  1366. ),
  1367. 'css' => array(
  1368. 'misc/ui/jquery.ui.selectable.css' => array(),
  1369. ),
  1370. 'dependencies' => array(
  1371. array('system', 'ui.widget'),
  1372. array('system', 'ui.mouse'),
  1373. ),
  1374. );
  1375. $libraries['ui.slider'] = array(
  1376. 'title' => 'jQuery UI: Slider',
  1377. 'website' => 'http://jqueryui.com/demos/slider/',
  1378. 'version' => '1.8.7',
  1379. 'js' => array(
  1380. 'misc/ui/jquery.ui.slider.min.js' => array(),
  1381. ),
  1382. 'css' => array(
  1383. 'misc/ui/jquery.ui.slider.css' => array(),
  1384. ),
  1385. 'dependencies' => array(
  1386. array('system', 'ui.widget'),
  1387. array('system', 'ui.mouse'),
  1388. ),
  1389. );
  1390. $libraries['ui.sortable'] = array(
  1391. 'title' => 'jQuery UI: Sortable',
  1392. 'website' => 'http://jqueryui.com/demos/sortable/',
  1393. 'version' => '1.8.7',
  1394. 'js' => array(
  1395. 'misc/ui/jquery.ui.sortable.min.js' => array(),
  1396. ),
  1397. 'dependencies' => array(
  1398. array('system', 'ui.widget'),
  1399. array('system', 'ui.mouse'),
  1400. ),
  1401. );
  1402. $libraries['ui.tabs'] = array(
  1403. 'title' => 'jQuery UI: Tabs',
  1404. 'website' => 'http://jqueryui.com/demos/tabs/',
  1405. 'version' => '1.8.7',
  1406. 'js' => array(
  1407. 'misc/ui/jquery.ui.tabs.min.js' => array(),
  1408. ),
  1409. 'css' => array(
  1410. 'misc/ui/jquery.ui.tabs.css' => array(),
  1411. ),
  1412. 'dependencies' => array(
  1413. array('system', 'ui.widget'),
  1414. ),
  1415. );
  1416. $libraries['ui.widget'] = array(
  1417. 'title' => 'jQuery UI: Widget',
  1418. 'website' => 'http://docs.jquery.com/UI/Widget',
  1419. 'version' => '1.8.7',
  1420. 'js' => array(
  1421. 'misc/ui/jquery.ui.widget.min.js' => array('group' => JS_LIBRARY, 'weight' => -10),
  1422. ),
  1423. 'dependencies' => array(
  1424. array('system', 'ui'),
  1425. ),
  1426. );
  1427. $libraries['effects'] = array(
  1428. 'title' => 'jQuery UI: Effects',
  1429. 'website' => 'http://jqueryui.com/demos/effect/',
  1430. 'version' => '1.8.7',
  1431. 'js' => array(
  1432. 'misc/ui/jquery.effects.core.min.js' => array('group' => JS_LIBRARY, 'weight' => -9),
  1433. ),
  1434. );
  1435. $libraries['effects.blind'] = array(
  1436. 'title' => 'jQuery UI: Effects Blind',
  1437. 'website' => 'http://jqueryui.com/demos/effect/',
  1438. 'version' => '1.8.7',
  1439. 'js' => array(
  1440. 'misc/ui/jquery.effects.blind.min.js' => array(),
  1441. ),
  1442. 'dependencies' => array(
  1443. array('system', 'effects'),
  1444. ),
  1445. );
  1446. $libraries['effects.bounce'] = array(
  1447. 'title' => 'jQuery UI: Effects Bounce',
  1448. 'website' => 'http://jqueryui.com/demos/effect/',
  1449. 'version' => '1.8.7',
  1450. 'js' => array(
  1451. 'misc/ui/jquery.effects.bounce.min.js' => array(),
  1452. ),
  1453. 'dependencies' => array(
  1454. array('system', 'effects'),
  1455. ),
  1456. );
  1457. $libraries['effects.clip'] = array(
  1458. 'title' => 'jQuery UI: Effects Clip',
  1459. 'website' => 'http://jqueryui.com/demos/effect/',
  1460. 'version' => '1.8.7',
  1461. 'js' => array(
  1462. 'misc/ui/jquery.effects.clip.min.js' => array(),
  1463. ),
  1464. 'dependencies' => array(
  1465. array('system', 'effects'),
  1466. ),
  1467. );
  1468. $libraries['effects.drop'] = array(
  1469. 'title' => 'jQuery UI: Effects Drop',
  1470. 'website' => 'http://jqueryui.com/demos/effect/',
  1471. 'version' => '1.8.7',
  1472. 'js' => array(
  1473. 'misc/ui/jquery.effects.drop.min.js' => array(),
  1474. ),
  1475. 'dependencies' => array(
  1476. array('system', 'effects'),
  1477. ),
  1478. );
  1479. $libraries['effects.explode'] = array(
  1480. 'title' => 'jQuery UI: Effects Explode',
  1481. 'website' => 'http://jqueryui.com/demos/effect/',
  1482. 'version' => '1.8.7',
  1483. 'js' => array(
  1484. 'misc/ui/jquery.effects.explode.min.js' => array(),
  1485. ),
  1486. 'dependencies' => array(
  1487. array('system', 'effects'),
  1488. ),
  1489. );
  1490. $libraries['effects.fade'] = array(
  1491. 'title' => 'jQuery UI: Effects Fade',
  1492. 'website' => 'http://jqueryui.com/demos/effect/',
  1493. 'version' => '1.8.7',
  1494. 'js' => array(
  1495. 'misc/ui/jquery.effects.fade.min.js' => array(),
  1496. ),
  1497. 'dependencies' => array(
  1498. array('system', 'effects'),
  1499. ),
  1500. );
  1501. $libraries['effects.fold'] = array(
  1502. 'title' => 'jQuery UI: Effects Fold',
  1503. 'website' => 'http://jqueryui.com/demos/effect/',
  1504. 'version' => '1.8.7',
  1505. 'js' => array(
  1506. 'misc/ui/jquery.effects.fold.min.js' => array(),
  1507. ),
  1508. 'dependencies' => array(
  1509. array('system', 'effects'),
  1510. ),
  1511. );
  1512. $libraries['effects.highlight'] = array(
  1513. 'title' => 'jQuery UI: Effects Highlight',
  1514. 'website' => 'http://jqueryui.com/demos/effect/',
  1515. 'version' => '1.8.7',
  1516. 'js' => array(
  1517. 'misc/ui/jquery.effects.highlight.min.js' => array(),
  1518. ),
  1519. 'dependencies' => array(
  1520. array('system', 'effects'),
  1521. ),
  1522. );
  1523. $libraries['effects.pulsate'] = array(
  1524. 'title' => 'jQuery UI: Effects Pulsate',
  1525. 'website' => 'http://jqueryui.com/demos/effect/',
  1526. 'version' => '1.8.7',
  1527. 'js' => array(
  1528. 'misc/ui/jquery.effects.pulsate.min.js' => array(),
  1529. ),
  1530. 'dependencies' => array(
  1531. array('system', 'effects'),
  1532. ),
  1533. );
  1534. $libraries['effects.scale'] = array(
  1535. 'title' => 'jQuery UI: Effects Scale',
  1536. 'website' => 'http://jqueryui.com/demos/effect/',
  1537. 'version' => '1.8.7',
  1538. 'js' => array(
  1539. 'misc/ui/jquery.effects.scale.min.js' => array(),
  1540. ),
  1541. 'dependencies' => array(
  1542. array('system', 'effects'),
  1543. ),
  1544. );
  1545. $libraries['effects.shake'] = array(
  1546. 'title' => 'jQuery UI: Effects Shake',
  1547. 'website' => 'http://jqueryui.com/demos/effect/',
  1548. 'version' => '1.8.7',
  1549. 'js' => array(
  1550. 'misc/ui/jquery.effects.shake.min.js' => array(),
  1551. ),
  1552. 'dependencies' => array(
  1553. array('system', 'effects'),
  1554. ),
  1555. );
  1556. $libraries['effects.slide'] = array(
  1557. 'title' => 'jQuery UI: Effects Slide',
  1558. 'website' => 'http://jqueryui.com/demos/effect/',
  1559. 'version' => '1.8.7',
  1560. 'js' => array(
  1561. 'misc/ui/jquery.effects.slide.min.js' => array(),
  1562. ),
  1563. 'dependencies' => array(
  1564. array('system', 'effects'),
  1565. ),
  1566. );
  1567. $libraries['effects.transfer'] = array(
  1568. 'title' => 'jQuery UI: Effects Transfer',
  1569. 'website' => 'http://jqueryui.com/demos/effect/',
  1570. 'version' => '1.8.7',
  1571. 'js' => array(
  1572. 'misc/ui/jquery.effects.transfer.min.js' => array(),
  1573. ),
  1574. 'dependencies' => array(
  1575. array('system', 'effects'),
  1576. ),
  1577. );
  1578. // These library names are deprecated. Earlier versions of Drupal 7 didn't
  1579. // consistently namespace their libraries, so these names are included for
  1580. // backwards compatibility with those versions.
  1581. $libraries['once'] = &$libraries['jquery.once'];
  1582. $libraries['form'] = &$libraries['jquery.form'];
  1583. $libraries['jquery-bbq'] = &$libraries['jquery.bbq'];
  1584. $libraries['vertical-tabs'] = &$libraries['drupal.vertical-tabs'];
  1585. $libraries['cookie'] = &$libraries['jquery.cookie'];
  1586. return $libraries;
  1587. }
  1588. /**
  1589. * Implements hook_stream_wrappers().
  1590. */
  1591. function system_stream_wrappers() {
  1592. $wrappers = array(
  1593. 'public' => array(
  1594. 'name' => t('Public files'),
  1595. 'class' => 'DrupalPublicStreamWrapper',
  1596. 'description' => t('Public local files served by the webserver.'),
  1597. 'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
  1598. ),
  1599. 'temporary' => array(
  1600. 'name' => t('Temporary files'),
  1601. 'class' => 'DrupalTemporaryStreamWrapper',
  1602. 'description' => t('Temporary local files for upload and previews.'),
  1603. 'type' => STREAM_WRAPPERS_LOCAL_HIDDEN,
  1604. ),
  1605. );
  1606. // Only register the private file stream wrapper if a file path has been set.
  1607. if (variable_get('file_private_path', FALSE)) {
  1608. $wrappers['private'] = array(
  1609. 'name' => t('Private files'),
  1610. 'class' => 'DrupalPrivateStreamWrapper',
  1611. 'description' => t('Private local files served by Drupal.'),
  1612. 'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
  1613. );
  1614. }
  1615. return $wrappers;
  1616. }
  1617. /**
  1618. * Retrieve a blocked IP address from the database.
  1619. *
  1620. * @param $iid integer
  1621. * The ID of the blocked IP address to retrieve.
  1622. *
  1623. * @return
  1624. * The blocked IP address from the database as an array.
  1625. */
  1626. function blocked_ip_load($iid) {
  1627. return db_query("SELECT * FROM {blocked_ips} WHERE iid = :iid", array(':iid' => $iid))->fetchAssoc();
  1628. }
  1629. /**
  1630. * Menu item access callback - only admin or enabled themes can be accessed.
  1631. */
  1632. function _system_themes_access($theme) {
  1633. return user_access('administer themes') && drupal_theme_access($theme);
  1634. }
  1635. /**
  1636. * @defgroup authorize Authorized operations
  1637. * @{
  1638. * Functions to run operations with elevated privileges via authorize.php.
  1639. *
  1640. * Because of the Update manager functionality included in Drupal core, there
  1641. * is a mechanism for running operations with elevated file system privileges,
  1642. * the top-level authorize.php script. This script runs at a reduced Drupal
  1643. * bootstrap level so that it is not reliant on the entire site being
  1644. * functional. The operations use a FileTransfer class to manipulate code
  1645. * installed on the system as the user that owns the files, not the user that
  1646. * the httpd is running as.
  1647. *
  1648. * The first setup is to define a callback function that should be authorized
  1649. * to run with the elevated privileges. This callback should take a
  1650. * FileTransfer as its first argument, although you can define an array of
  1651. * other arguments it should be invoked with. The callback should be placed in
  1652. * a separate .inc file that will be included by authorize.php.
  1653. *
  1654. * To run the operation, certain data must be saved into the SESSION, and then
  1655. * the flow of control should be redirected to the authorize.php script. There
  1656. * are two ways to do this, either to call system_authorized_run() directly,
  1657. * or to call system_authorized_init() and then redirect to authorize.php,
  1658. * using the URL from system_authorized_get_url(). Redirecting yourself is
  1659. * necessary when your authorized operation is being triggered by a form
  1660. * submit handler, since calling drupal_goto() in a submit handler is a bad
  1661. * idea, and you should instead set $form_state['redirect'].
  1662. *
  1663. * Once the SESSION is setup for the operation and the user is redirected to
  1664. * authorize.php, they will be prompted for their connection credentials (core
  1665. * provides FTP and SSH by default, although other connection classes can be
  1666. * added via contributed modules). With valid credentials, authorize.php will
  1667. * instantiate the appropriate FileTransfer object, and then invoke the
  1668. * desired operation passing in that object. The authorize.php script can act
  1669. * as a Batch API processing page, if the operation requires a batch.
  1670. *
  1671. * @see authorize.php
  1672. * @see FileTransfer
  1673. * @see hook_filetransfer_info()
  1674. */
  1675. /**
  1676. * Setup a given callback to run via authorize.php with elevated privileges.
  1677. *
  1678. * To use authorize.php, certain variables must be stashed into $_SESSION. This
  1679. * function sets up all the necessary $_SESSION variables. The calling function
  1680. * should then redirect to authorize.php, using the full path returned by
  1681. * system_authorized_get_url(). That initiates the workflow that will eventually
  1682. * lead to the callback being invoked. The callback will be invoked at a low
  1683. * bootstrap level, without all modules being invoked, so it needs to be careful
  1684. * not to assume any code exists. Example (system_authorized_run()):
  1685. * @code
  1686. * system_authorized_init($callback, $file, $arguments, $page_title);
  1687. * drupal_goto(system_authorized_get_url());
  1688. * @endcode
  1689. * Example (update_manager_install_form_submit()):
  1690. * @code
  1691. * system_authorized_init('update_authorize_run_install',
  1692. * drupal_get_path('module', 'update') . '/update.authorize.inc',
  1693. * $arguments, t('Update manager'));
  1694. * $form_state['redirect'] = system_authorized_get_url();
  1695. * @endcode
  1696. *
  1697. * @param $callback
  1698. * The name of the function to invoke once the user authorizes the operation.
  1699. * @param $file
  1700. * The full path to the file where the callback function is implemented.
  1701. * @param $arguments
  1702. * Optional array of arguments to pass into the callback when it is invoked.
  1703. * Note that the first argument to the callback is always the FileTransfer
  1704. * object created by authorize.php when the user authorizes the operation.
  1705. * @param $page_title
  1706. * Optional string to use as the page title once redirected to authorize.php.
  1707. * @return
  1708. * Nothing, this function just initializes variables in the user's session.
  1709. */
  1710. function system_authorized_init($callback, $file, $arguments = array(), $page_title = NULL) {
  1711. // First, figure out what file transfer backends the site supports, and put
  1712. // all of those in the SESSION so that authorize.php has access to all of
  1713. // them via the class autoloader, even without a full bootstrap.
  1714. $_SESSION['authorize_filetransfer_info'] = drupal_get_filetransfer_info();
  1715. // Now, define the callback to invoke.
  1716. $_SESSION['authorize_operation'] = array(
  1717. 'callback' => $callback,
  1718. 'file' => $file,
  1719. 'arguments' => $arguments,
  1720. );
  1721. if (isset($page_title)) {
  1722. $_SESSION['authorize_operation']['page_title'] = $page_title;
  1723. }
  1724. }
  1725. /**
  1726. * Return the URL for the authorize.php script.
  1727. *
  1728. * @param array $options
  1729. * Optional array of options to pass to url().
  1730. * @return
  1731. * The full URL to authorize.php, using HTTPS if available.
  1732. *
  1733. * @see system_authorized_init()
  1734. */
  1735. function system_authorized_get_url(array $options = array()) {
  1736. global $base_url;
  1737. // Force HTTPS if available, regardless of what the caller specifies.
  1738. $options['https'] = TRUE;
  1739. // We prefix with $base_url so we get a full path even if clean URLs are
  1740. // disabled.
  1741. return url($base_url . '/authorize.php', $options);
  1742. }
  1743. /**
  1744. * Returns the URL for the authorize.php script when it is processing a batch.
  1745. */
  1746. function system_authorized_batch_processing_url() {
  1747. return system_authorized_get_url(array('query' => array('batch' => '1')));
  1748. }
  1749. /**
  1750. * Setup and invoke an operation using authorize.php.
  1751. *
  1752. * @see system_authorized_init()
  1753. */
  1754. function system_authorized_run($callback, $file, $arguments = array(), $page_title = NULL) {
  1755. system_authorized_init($callback, $file, $arguments, $page_title);
  1756. drupal_goto(system_authorized_get_url());
  1757. }
  1758. /**
  1759. * Use authorize.php to run batch_process().
  1760. *
  1761. * @see batch_process()
  1762. */
  1763. function system_authorized_batch_process() {
  1764. $finish_url = system_authorized_get_url();
  1765. $process_url = system_authorized_batch_processing_url();
  1766. batch_process($finish_url, $process_url);
  1767. }
  1768. /**
  1769. * @} End of "defgroup authorize".
  1770. */
  1771. /**
  1772. * Implements hook_updater_info().
  1773. */
  1774. function system_updater_info() {
  1775. return array(
  1776. 'module' => array(
  1777. 'class' => 'ModuleUpdater',
  1778. 'name' => t('Update modules'),
  1779. 'weight' => 0,
  1780. ),
  1781. 'theme' => array(
  1782. 'class' => 'ThemeUpdater',
  1783. 'name' => t('Update themes'),
  1784. 'weight' => 0,
  1785. ),
  1786. );
  1787. }
  1788. /**
  1789. * Implements hook_filetransfer_info().
  1790. */
  1791. function system_filetransfer_info() {
  1792. $backends = array();
  1793. // This is the default, will be available on most systems.
  1794. if (function_exists('ftp_connect')) {
  1795. $backends['ftp'] = array(
  1796. 'title' => t('FTP'),
  1797. 'class' => 'FileTransferFTP',
  1798. 'file' => 'ftp.inc',
  1799. 'file path' => 'includes/filetransfer',
  1800. 'weight' => 0,
  1801. );
  1802. }
  1803. // SSH2 lib connection is only available if the proper PHP extension is
  1804. // installed.
  1805. if (function_exists('ssh2_connect')) {
  1806. $backends['ssh'] = array(
  1807. 'title' => t('SSH'),
  1808. 'class' => 'FileTransferSSH',
  1809. 'file' => 'ssh.inc',
  1810. 'file path' => 'includes/filetransfer',
  1811. 'weight' => 20,
  1812. );
  1813. }
  1814. return $backends;
  1815. }
  1816. /**
  1817. * Implements hook_init().
  1818. */
  1819. function system_init() {
  1820. $path = drupal_get_path('module', 'system');
  1821. // Add the CSS for this module. These aren't in system.info, because they
  1822. // need to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group.
  1823. drupal_add_css($path . '/system.base.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
  1824. if (path_is_admin(current_path())) {
  1825. drupal_add_css($path . '/system.admin.css', array('group' => CSS_SYSTEM));
  1826. }
  1827. drupal_add_css($path . '/system.menus.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
  1828. drupal_add_css($path . '/system.messages.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
  1829. drupal_add_css($path . '/system.theme.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
  1830. // Ignore slave database servers for this request.
  1831. //
  1832. // In Drupal's distributed database structure, new data is written to the
  1833. // master and then propagated to the slave servers. This means there is a
  1834. // lag between when data is written to the master and when it is available on
  1835. // the slave. At these times, we will want to avoid using a slave server
  1836. // temporarily. For example, if a user posts a new node then we want to
  1837. // disable the slave server for that user temporarily to allow the slave
  1838. // server to catch up. That way, that user will see their changes immediately
  1839. // while for other users we still get the benefits of having a slave server,
  1840. // just with slightly stale data. Code that wants to disable the slave
  1841. // server should use the db_ignore_slave() function to set
  1842. // $_SESSION['ignore_slave_server'] to the timestamp after which the slave
  1843. // can be re-enabled.
  1844. if (isset($_SESSION['ignore_slave_server'])) {
  1845. if ($_SESSION['ignore_slave_server'] >= REQUEST_TIME) {
  1846. Database::ignoreTarget('default', 'slave');
  1847. }
  1848. else {
  1849. unset($_SESSION['ignore_slave_server']);
  1850. }
  1851. }
  1852. // Add CSS/JS files from module .info files.
  1853. system_add_module_assets();
  1854. }
  1855. /**
  1856. * Adds CSS and JavaScript files declared in module .info files.
  1857. */
  1858. function system_add_module_assets() {
  1859. foreach (system_get_info('module') as $module => $info) {
  1860. if (!empty($info['stylesheets'])) {
  1861. foreach ($info['stylesheets'] as $media => $stylesheets) {
  1862. foreach ($stylesheets as $stylesheet) {
  1863. drupal_add_css($stylesheet, array('every_page' => TRUE, 'media' => $media));
  1864. }
  1865. }
  1866. }
  1867. if (!empty($info['scripts'])) {
  1868. foreach ($info['scripts'] as $script) {
  1869. drupal_add_js($script, array('every_page' => TRUE));
  1870. }
  1871. }
  1872. }
  1873. }
  1874. /**
  1875. * Implements hook_custom_theme().
  1876. */
  1877. function system_custom_theme() {
  1878. if (user_access('view the administration theme') && path_is_admin(current_path())) {
  1879. return variable_get('admin_theme');
  1880. }
  1881. }
  1882. /**
  1883. * Implements hook_form_FORM_ID_alter().
  1884. */
  1885. function system_form_user_profile_form_alter(&$form, &$form_state) {
  1886. if ($form['#user_category'] == 'account') {
  1887. if (variable_get('configurable_timezones', 1)) {
  1888. system_user_timezone($form, $form_state);
  1889. }
  1890. return $form;
  1891. }
  1892. }
  1893. /**
  1894. * Implements hook_form_FORM_ID_alter().
  1895. */
  1896. function system_form_user_register_form_alter(&$form, &$form_state) {
  1897. if (variable_get('configurable_timezones', 1)) {
  1898. if (variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) == DRUPAL_USER_TIMEZONE_SELECT) {
  1899. system_user_timezone($form, $form_state);
  1900. }
  1901. else {
  1902. $form['account']['timezone'] = array(
  1903. '#type' => 'hidden',
  1904. '#value' => variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) ? '' : variable_get('date_default_timezone', ''),
  1905. );
  1906. }
  1907. return $form;
  1908. }
  1909. }
  1910. /**
  1911. * Implements hook_user_login().
  1912. */
  1913. function system_user_login(&$edit, $account) {
  1914. // If the user has a NULL time zone, notify them to set a time zone.
  1915. if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
  1916. drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
  1917. }
  1918. }
  1919. /**
  1920. * Add the time zone field to the user edit and register forms.
  1921. */
  1922. function system_user_timezone(&$form, &$form_state) {
  1923. global $user;
  1924. $account = $form['#user'];
  1925. $form['timezone'] = array(
  1926. '#type' => 'fieldset',
  1927. '#title' => t('Locale settings'),
  1928. '#weight' => 6,
  1929. '#collapsible' => TRUE,
  1930. );
  1931. $form['timezone']['timezone'] = array(
  1932. '#type' => 'select',
  1933. '#title' => t('Time zone'),
  1934. '#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? variable_get('date_default_timezone', '') : ''),
  1935. '#options' => system_time_zones($account->uid != $user->uid),
  1936. '#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'),
  1937. );
  1938. if (!isset($account->timezone) && $account->uid == $user->uid && empty($form_state['input']['timezone'])) {
  1939. $form['timezone']['#description'] = t('Your time zone setting will be automatically detected if possible. Confirm the selection and click save.');
  1940. $form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect'));
  1941. drupal_add_js('misc/timezone.js');
  1942. }
  1943. }
  1944. /**
  1945. * Implements hook_block_info().
  1946. */
  1947. function system_block_info() {
  1948. $blocks['main'] = array(
  1949. 'info' => t('Main page content'),
  1950. // Cached elsewhere.
  1951. 'cache' => DRUPAL_NO_CACHE,
  1952. // Auto-enable in 'content' region by default, which always exists.
  1953. // @see system_themes_page(), drupal_render_page()
  1954. 'status' => 1,
  1955. 'region' => 'content',
  1956. );
  1957. $blocks['powered-by'] = array(
  1958. 'info' => t('Powered by Drupal'),
  1959. 'weight' => '10',
  1960. 'cache' => DRUPAL_NO_CACHE,
  1961. );
  1962. $blocks['help'] = array(
  1963. 'info' => t('System help'),
  1964. 'weight' => '5',
  1965. 'cache' => DRUPAL_NO_CACHE,
  1966. // Auto-enable in 'help' region by default, if the theme defines one.
  1967. 'status' => 1,
  1968. 'region' => 'help',
  1969. );
  1970. // System-defined menu blocks.
  1971. foreach (menu_list_system_menus() as $menu_name => $title) {
  1972. $blocks[$menu_name]['info'] = t($title);
  1973. // Menu blocks can't be cached because each menu item can have
  1974. // a custom access callback. menu.inc manages its own caching.
  1975. $blocks[$menu_name]['cache'] = DRUPAL_NO_CACHE;
  1976. }
  1977. return $blocks;
  1978. }
  1979. /**
  1980. * Implements hook_block_view().
  1981. *
  1982. * Generate a block with a promotional link to Drupal.org and
  1983. * all system menu blocks.
  1984. */
  1985. function system_block_view($delta = '') {
  1986. $block = array();
  1987. switch ($delta) {
  1988. case 'main':
  1989. $block['subject'] = NULL;
  1990. $block['content'] = drupal_set_page_content();
  1991. return $block;
  1992. case 'powered-by':
  1993. $block['subject'] = NULL;
  1994. $block['content'] = theme('system_powered_by');
  1995. return $block;
  1996. case 'help':
  1997. $block['subject'] = NULL;
  1998. $block['content'] = menu_get_active_help();
  1999. return $block;
  2000. default:
  2001. // All system menu blocks.
  2002. $system_menus = menu_list_system_menus();
  2003. if (isset($system_menus[$delta])) {
  2004. $block['subject'] = t($system_menus[$delta]);
  2005. $block['content'] = menu_tree($delta);
  2006. return $block;
  2007. }
  2008. break;
  2009. }
  2010. }
  2011. /**
  2012. * Implements hook_preprocess_block().
  2013. */
  2014. function system_preprocess_block(&$variables) {
  2015. // System menu blocks should get the same class as menu module blocks.
  2016. if ($variables['block']->module == 'system' && in_array($variables['block']->delta, array_keys(menu_list_system_menus()))) {
  2017. $variables['classes_array'][] = 'block-menu';
  2018. }
  2019. }
  2020. /**
  2021. * Provide a single block on the administration overview page.
  2022. *
  2023. * @param $item
  2024. * The menu item to be displayed.
  2025. */
  2026. function system_admin_menu_block($item) {
  2027. $cache = &drupal_static(__FUNCTION__, array());
  2028. // If we are calling this function for a menu item that corresponds to a
  2029. // local task (for example, admin/tasks), then we want to retrieve the
  2030. // parent item's child links, not this item's (since this item won't have
  2031. // any).
  2032. if ($item['tab_root'] != $item['path']) {
  2033. $item = menu_get_item($item['tab_root_href']);
  2034. }
  2035. if (!isset($item['mlid'])) {
  2036. $item += db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = :path AND module = 'system'", array(':path' => $item['path']))->fetchAssoc();
  2037. }
  2038. if (isset($cache[$item['mlid']])) {
  2039. return $cache[$item['mlid']];
  2040. }
  2041. $content = array();
  2042. $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
  2043. $query->join('menu_router', 'm', 'm.path = ml.router_path');
  2044. $query
  2045. ->fields('ml')
  2046. // Weight should be taken from {menu_links}, not {menu_router}.
  2047. ->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')))
  2048. ->condition('ml.plid', $item['mlid'])
  2049. ->condition('ml.menu_name', $item['menu_name'])
  2050. ->condition('ml.hidden', 0);
  2051. foreach ($query->execute() as $link) {
  2052. _menu_link_translate($link);
  2053. if ($link['access']) {
  2054. // The link description, either derived from 'description' in
  2055. // hook_menu() or customized via menu module is used as title attribute.
  2056. if (!empty($link['localized_options']['attributes']['title'])) {
  2057. $link['description'] = $link['localized_options']['attributes']['title'];
  2058. unset($link['localized_options']['attributes']['title']);
  2059. }
  2060. // Prepare for sorting as in function _menu_tree_check_access().
  2061. // The weight is offset so it is always positive, with a uniform 5-digits.
  2062. $key = (50000 + $link['weight']) . ' ' . drupal_strtolower($link['title']) . ' ' . $link['mlid'];
  2063. $content[$key] = $link;
  2064. }
  2065. }
  2066. ksort($content);
  2067. $cache[$item['mlid']] = $content;
  2068. return $content;
  2069. }
  2070. /**
  2071. * Checks the existence of the directory specified in $form_element.
  2072. *
  2073. * This function is called from the system_settings form to check all core
  2074. * file directories (file_public_path, file_private_path, file_temporary_path).
  2075. *
  2076. * @param $form_element
  2077. * The form element containing the name of the directory to check.
  2078. */
  2079. function system_check_directory($form_element) {
  2080. $directory = $form_element['#value'];
  2081. if (strlen($directory) == 0) {
  2082. return $form_element;
  2083. }
  2084. if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) {
  2085. // If the directory does not exists and cannot be created.
  2086. form_set_error($form_element['#parents'][0], t('The directory %directory does not exist and could not be created.', array('%directory' => $directory)));
  2087. watchdog('file system', 'The directory %directory does not exist and could not be created.', array('%directory' => $directory), WATCHDOG_ERROR);
  2088. }
  2089. if (is_dir($directory) && !is_writable($directory) && !drupal_chmod($directory)) {
  2090. // If the directory is not writable and cannot be made so.
  2091. form_set_error($form_element['#parents'][0], t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory)));
  2092. watchdog('file system', 'The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory), WATCHDOG_ERROR);
  2093. }
  2094. elseif (is_dir($directory)) {
  2095. if ($form_element['#name'] == 'file_public_path') {
  2096. // Create public .htaccess file.
  2097. file_create_htaccess($directory, FALSE);
  2098. }
  2099. else {
  2100. // Create private .htaccess file.
  2101. file_create_htaccess($directory);
  2102. }
  2103. }
  2104. return $form_element;
  2105. }
  2106. /**
  2107. * Retrieves the current status of an array of files in the system table.
  2108. *
  2109. * @param $files
  2110. * An array of files to check.
  2111. * @param $type
  2112. * The type of the files.
  2113. */
  2114. function system_get_files_database(&$files, $type) {
  2115. // Extract current files from database.
  2116. $result = db_query("SELECT filename, name, type, status, schema_version, weight FROM {system} WHERE type = :type", array(':type' => $type));
  2117. foreach ($result as $file) {
  2118. if (isset($files[$file->name]) && is_object($files[$file->name])) {
  2119. $file->uri = $file->filename;
  2120. foreach ($file as $key => $value) {
  2121. if (!isset($files[$file->name]->$key)) {
  2122. $files[$file->name]->$key = $value;
  2123. }
  2124. }
  2125. }
  2126. }
  2127. }
  2128. /**
  2129. * Updates the records in the system table based on the files array.
  2130. *
  2131. * @param $files
  2132. * An array of files.
  2133. * @param $type
  2134. * The type of the files.
  2135. */
  2136. function system_update_files_database(&$files, $type) {
  2137. $result = db_query("SELECT * FROM {system} WHERE type = :type", array(':type' => $type));
  2138. // Add all files that need to be deleted to a DatabaseCondition.
  2139. $delete = db_or();
  2140. foreach ($result as $file) {
  2141. if (isset($files[$file->name]) && is_object($files[$file->name])) {
  2142. // Keep the old filename from the database in case the file has moved.
  2143. $old_filename = $file->filename;
  2144. $updated_fields = array();
  2145. // Handle info specially, compare the serialized value.
  2146. $serialized_info = serialize($files[$file->name]->info);
  2147. if ($serialized_info != $file->info) {
  2148. $updated_fields['info'] = $serialized_info;
  2149. }
  2150. unset($file->info);
  2151. // Scan remaining fields to find only the updated values.
  2152. foreach ($file as $key => $value) {
  2153. if (isset($files[$file->name]->$key) && $files[$file->name]->$key != $value) {
  2154. $updated_fields[$key] = $files[$file->name]->$key;
  2155. }
  2156. }
  2157. // Update the record.
  2158. if (count($updated_fields)) {
  2159. db_update('system')
  2160. ->fields($updated_fields)
  2161. ->condition('filename', $old_filename)
  2162. ->execute();
  2163. }
  2164. // Indicate that the file exists already.
  2165. $files[$file->name]->exists = TRUE;
  2166. }
  2167. else {
  2168. // File is not found in file system, so delete record from the system table.
  2169. $delete->condition('filename', $file->filename);
  2170. }
  2171. }
  2172. if (count($delete) > 0) {
  2173. // Delete all missing files from the system table, but only if the plugin
  2174. // has never been installed.
  2175. db_delete('system')
  2176. ->condition($delete)
  2177. ->condition('schema_version', -1)
  2178. ->execute();
  2179. }
  2180. // All remaining files are not in the system table, so we need to add them.
  2181. $query = db_insert('system')->fields(array('filename', 'name', 'type', 'owner', 'info'));
  2182. foreach ($files as &$file) {
  2183. if (isset($file->exists)) {
  2184. unset($file->exists);
  2185. }
  2186. else {
  2187. $query->values(array(
  2188. 'filename' => $file->uri,
  2189. 'name' => $file->name,
  2190. 'type' => $type,
  2191. 'owner' => isset($file->owner) ? $file->owner : '',
  2192. 'info' => serialize($file->info),
  2193. ));
  2194. $file->type = $type;
  2195. $file->status = 0;
  2196. $file->schema_version = -1;
  2197. }
  2198. }
  2199. $query->execute();
  2200. // If any module or theme was moved to a new location, we need to reset the
  2201. // system_list() cache or we will continue to load the old copy, look for
  2202. // schema updates in the wrong place, etc.
  2203. system_list_reset();
  2204. }
  2205. /**
  2206. * Returns an array of information about enabled modules or themes.
  2207. *
  2208. * This function returns the information from the {system} table corresponding
  2209. * to the cached contents of the .info file for each active module or theme.
  2210. *
  2211. * @param $type
  2212. * Either 'module' or 'theme'.
  2213. * @param $name
  2214. * (optional) The name of a module or theme whose information shall be
  2215. * returned. If omitted, all records for the provided $type will be returned.
  2216. * If $name does not exist in the provided $type or is not enabled, an empty
  2217. * array will be returned.
  2218. *
  2219. * @return
  2220. * An associative array of module or theme information keyed by name, or only
  2221. * information for $name, if given. If no records are available, an empty
  2222. * array is returned.
  2223. *
  2224. * @see system_rebuild_module_data()
  2225. * @see system_rebuild_theme_data()
  2226. */
  2227. function system_get_info($type, $name = NULL) {
  2228. $info = array();
  2229. if ($type == 'module') {
  2230. $type = 'module_enabled';
  2231. }
  2232. $list = system_list($type);
  2233. foreach ($list as $shortname => $item) {
  2234. if (!empty($item->status)) {
  2235. $info[$shortname] = $item->info;
  2236. }
  2237. }
  2238. if (isset($name)) {
  2239. return isset($info[$name]) ? $info[$name] : array();
  2240. }
  2241. return $info;
  2242. }
  2243. /**
  2244. * Helper function to scan and collect module .info data.
  2245. *
  2246. * @return
  2247. * An associative array of module information.
  2248. */
  2249. function _system_rebuild_module_data() {
  2250. // Find modules
  2251. $modules = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0);
  2252. // Include the installation profile in modules that are loaded.
  2253. $profile = drupal_get_profile();
  2254. $modules[$profile] = new stdClass();
  2255. $modules[$profile]->name = $profile;
  2256. $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile';
  2257. $modules[$profile]->filename = $profile . '.profile';
  2258. // Installation profile hooks are always executed last.
  2259. $modules[$profile]->weight = 1000;
  2260. // Set defaults for module info.
  2261. $defaults = array(
  2262. 'dependencies' => array(),
  2263. 'description' => '',
  2264. 'package' => 'Other',
  2265. 'version' => NULL,
  2266. 'php' => DRUPAL_MINIMUM_PHP,
  2267. 'files' => array(),
  2268. 'bootstrap' => 0,
  2269. );
  2270. // Read info files for each module.
  2271. foreach ($modules as $key => $module) {
  2272. // The module system uses the key 'filename' instead of 'uri' so copy the
  2273. // value so it will be used by the modules system.
  2274. $modules[$key]->filename = $module->uri;
  2275. // Look for the info file.
  2276. $module->info = drupal_parse_info_file(dirname($module->uri) . '/' . $module->name . '.info');
  2277. // Skip modules that don't provide info.
  2278. if (empty($module->info)) {
  2279. unset($modules[$key]);
  2280. continue;
  2281. }
  2282. // Merge in defaults and save.
  2283. $modules[$key]->info = $module->info + $defaults;
  2284. // Prefix stylesheets and scripts with module path.
  2285. $path = dirname($module->uri);
  2286. if (isset($module->info['stylesheets'])) {
  2287. $module->info['stylesheets'] = _system_info_add_path($module->info['stylesheets'], $path);
  2288. }
  2289. if (isset($module->info['scripts'])) {
  2290. $module->info['scripts'] = _system_info_add_path($module->info['scripts'], $path);
  2291. }
  2292. // Installation profiles are hidden by default, unless explicitly specified
  2293. // otherwise in the .info file.
  2294. if ($key == $profile && !isset($modules[$key]->info['hidden'])) {
  2295. $modules[$key]->info['hidden'] = TRUE;
  2296. }
  2297. // Invoke hook_system_info_alter() to give installed modules a chance to
  2298. // modify the data in the .info files if necessary.
  2299. $type = 'module';
  2300. drupal_alter('system_info', $modules[$key]->info, $modules[$key], $type);
  2301. }
  2302. if (isset($modules[$profile])) {
  2303. // The installation profile is required, if it's a valid module.
  2304. $modules[$profile]->info['required'] = TRUE;
  2305. // Add a default distribution name if the profile did not provide one. This
  2306. // matches the default value used in install_profile_info().
  2307. if (!isset($modules[$profile]->info['distribution_name'])) {
  2308. $modules[$profile]->info['distribution_name'] = 'Drupal';
  2309. }
  2310. }
  2311. return $modules;
  2312. }
  2313. /**
  2314. * Rebuild, save, and return data about all currently available modules.
  2315. *
  2316. * @return
  2317. * Array of all available modules and their data.
  2318. */
  2319. function system_rebuild_module_data() {
  2320. $modules_cache = &drupal_static(__FUNCTION__);
  2321. // Only rebuild once per request. $modules and $modules_cache cannot be
  2322. // combined into one variable, because the $modules_cache variable is reset by
  2323. // reference from system_list_reset() during the rebuild.
  2324. if (!isset($modules_cache)) {
  2325. $modules = _system_rebuild_module_data();
  2326. ksort($modules);
  2327. system_get_files_database($modules, 'module');
  2328. system_update_files_database($modules, 'module');
  2329. $modules = _module_build_dependencies($modules);
  2330. $modules_cache = $modules;
  2331. }
  2332. return $modules_cache;
  2333. }
  2334. /**
  2335. * Refresh bootstrap column in the system table.
  2336. *
  2337. * This is called internally by module_enable/disable() to flag modules that
  2338. * implement hooks used during bootstrap, such as hook_boot(). These modules
  2339. * are loaded earlier to invoke the hooks.
  2340. */
  2341. function _system_update_bootstrap_status() {
  2342. $bootstrap_modules = array();
  2343. foreach (bootstrap_hooks() as $hook) {
  2344. foreach (module_implements($hook) as $module) {
  2345. $bootstrap_modules[] = $module;
  2346. }
  2347. }
  2348. $query = db_update('system')->fields(array('bootstrap' => 0));
  2349. if ($bootstrap_modules) {
  2350. db_update('system')
  2351. ->fields(array('bootstrap' => 1))
  2352. ->condition('name', $bootstrap_modules, 'IN')
  2353. ->execute();
  2354. $query->condition('name', $bootstrap_modules, 'NOT IN');
  2355. }
  2356. $query->execute();
  2357. // Reset the cached list of bootstrap modules.
  2358. system_list_reset();
  2359. }
  2360. /**
  2361. * Helper function to scan and collect theme .info data and their engines.
  2362. *
  2363. * @return
  2364. * An associative array of themes information.
  2365. */
  2366. function _system_rebuild_theme_data() {
  2367. // Find themes
  2368. $themes = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info$/', 'themes');
  2369. // Allow modules to add further themes.
  2370. if ($module_themes = module_invoke_all('system_theme_info')) {
  2371. foreach ($module_themes as $name => $uri) {
  2372. // @see file_scan_directory()
  2373. $themes[$name] = (object) array(
  2374. 'uri' => $uri,
  2375. 'filename' => pathinfo($uri, PATHINFO_FILENAME),
  2376. 'name' => $name,
  2377. );
  2378. }
  2379. }
  2380. // Find theme engines
  2381. $engines = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.engine$/', 'themes/engines');
  2382. // Set defaults for theme info.
  2383. $defaults = array(
  2384. 'engine' => 'phptemplate',
  2385. 'regions' => array(
  2386. 'sidebar_first' => 'Left sidebar',
  2387. 'sidebar_second' => 'Right sidebar',
  2388. 'content' => 'Content',
  2389. 'header' => 'Header',
  2390. 'footer' => 'Footer',
  2391. 'highlighted' => 'Highlighted',
  2392. 'help' => 'Help',
  2393. 'page_top' => 'Page top',
  2394. 'page_bottom' => 'Page bottom',
  2395. ),
  2396. 'description' => '',
  2397. 'features' => _system_default_theme_features(),
  2398. 'screenshot' => 'screenshot.png',
  2399. 'php' => DRUPAL_MINIMUM_PHP,
  2400. 'stylesheets' => array(),
  2401. 'scripts' => array(),
  2402. );
  2403. $sub_themes = array();
  2404. // Read info files for each theme
  2405. foreach ($themes as $key => $theme) {
  2406. $themes[$key]->filename = $theme->uri;
  2407. $themes[$key]->info = drupal_parse_info_file($theme->uri) + $defaults;
  2408. // Invoke hook_system_info_alter() to give installed modules a chance to
  2409. // modify the data in the .info files if necessary.
  2410. $type = 'theme';
  2411. drupal_alter('system_info', $themes[$key]->info, $themes[$key], $type);
  2412. if (!empty($themes[$key]->info['base theme'])) {
  2413. $sub_themes[] = $key;
  2414. }
  2415. if ($themes[$key]->info['engine'] == 'theme') {
  2416. $filename = dirname($themes[$key]->uri) . '/' . $themes[$key]->name . '.theme';
  2417. if (file_exists($filename)) {
  2418. $themes[$key]->owner = $filename;
  2419. $themes[$key]->prefix = $key;
  2420. }
  2421. }
  2422. else {
  2423. $engine = $themes[$key]->info['engine'];
  2424. if (isset($engines[$engine])) {
  2425. $themes[$key]->owner = $engines[$engine]->uri;
  2426. $themes[$key]->prefix = $engines[$engine]->name;
  2427. $themes[$key]->template = TRUE;
  2428. }
  2429. }
  2430. // Prefix stylesheets and scripts with module path.
  2431. $path = dirname($theme->uri);
  2432. $theme->info['stylesheets'] = _system_info_add_path($theme->info['stylesheets'], $path);
  2433. $theme->info['scripts'] = _system_info_add_path($theme->info['scripts'], $path);
  2434. // Give the screenshot proper path information.
  2435. if (!empty($themes[$key]->info['screenshot'])) {
  2436. $themes[$key]->info['screenshot'] = $path . '/' . $themes[$key]->info['screenshot'];
  2437. }
  2438. }
  2439. // Now that we've established all our master themes, go back and fill in data
  2440. // for subthemes.
  2441. foreach ($sub_themes as $key) {
  2442. $themes[$key]->base_themes = drupal_find_base_themes($themes, $key);
  2443. // Don't proceed if there was a problem with the root base theme.
  2444. if (!current($themes[$key]->base_themes)) {
  2445. continue;
  2446. }
  2447. $base_key = key($themes[$key]->base_themes);
  2448. foreach (array_keys($themes[$key]->base_themes) as $base_theme) {
  2449. $themes[$base_theme]->sub_themes[$key] = $themes[$key]->info['name'];
  2450. }
  2451. // Copy the 'owner' and 'engine' over if the top level theme uses a theme
  2452. // engine.
  2453. if (isset($themes[$base_key]->owner)) {
  2454. if (isset($themes[$base_key]->info['engine'])) {
  2455. $themes[$key]->info['engine'] = $themes[$base_key]->info['engine'];
  2456. $themes[$key]->owner = $themes[$base_key]->owner;
  2457. $themes[$key]->prefix = $themes[$base_key]->prefix;
  2458. }
  2459. else {
  2460. $themes[$key]->prefix = $key;
  2461. }
  2462. }
  2463. }
  2464. return $themes;
  2465. }
  2466. /**
  2467. * Rebuild, save, and return data about all currently available themes.
  2468. *
  2469. * @return
  2470. * Array of all available themes and their data.
  2471. */
  2472. function system_rebuild_theme_data() {
  2473. $themes = _system_rebuild_theme_data();
  2474. ksort($themes);
  2475. system_get_files_database($themes, 'theme');
  2476. system_update_files_database($themes, 'theme');
  2477. return $themes;
  2478. }
  2479. /**
  2480. * Prefixes all values in an .info file array with a given path.
  2481. *
  2482. * This helper function is mainly used to prefix all array values of an .info
  2483. * file property with a single given path (to the module or theme); e.g., to
  2484. * prefix all values of the 'stylesheets' or 'scripts' properties with the file
  2485. * path to the defining module/theme.
  2486. *
  2487. * @param $info
  2488. * A nested array of data of an .info file to be processed.
  2489. * @param $path
  2490. * A file path to prepend to each value in $info.
  2491. *
  2492. * @return
  2493. * The $info array with prefixed values.
  2494. *
  2495. * @see _system_rebuild_module_data()
  2496. * @see _system_rebuild_theme_data()
  2497. */
  2498. function _system_info_add_path($info, $path) {
  2499. foreach ($info as $key => $value) {
  2500. // Recurse into nested values until we reach the deepest level.
  2501. if (is_array($value)) {
  2502. $info[$key] = _system_info_add_path($info[$key], $path);
  2503. }
  2504. // Unset the original value's key and set the new value with prefix, using
  2505. // the original value as key, so original values can still be looked up.
  2506. else {
  2507. unset($info[$key]);
  2508. $info[$value] = $path . '/' . $value;
  2509. }
  2510. }
  2511. return $info;
  2512. }
  2513. /**
  2514. * Returns an array of default theme features.
  2515. */
  2516. function _system_default_theme_features() {
  2517. return array(
  2518. 'logo',
  2519. 'favicon',
  2520. 'name',
  2521. 'slogan',
  2522. 'node_user_picture',
  2523. 'comment_user_picture',
  2524. 'comment_user_verification',
  2525. 'main_menu',
  2526. 'secondary_menu',
  2527. );
  2528. }
  2529. /**
  2530. * Find all the base themes for the specified theme.
  2531. *
  2532. * This function has been deprecated in favor of drupal_find_base_themes().
  2533. */
  2534. function system_find_base_themes($themes, $key, $used_keys = array()) {
  2535. return drupal_find_base_themes($themes, $key, $used_keys);
  2536. }
  2537. /**
  2538. * Get a list of available regions from a specified theme.
  2539. *
  2540. * @param $theme_key
  2541. * The name of a theme.
  2542. * @param $show
  2543. * Possible values: REGIONS_ALL or REGIONS_VISIBLE. Visible excludes hidden
  2544. * regions.
  2545. * @return
  2546. * An array of regions in the form $region['name'] = 'description'.
  2547. */
  2548. function system_region_list($theme_key, $show = REGIONS_ALL) {
  2549. $themes = list_themes();
  2550. if (!isset($themes[$theme_key])) {
  2551. return array();
  2552. }
  2553. $list = array();
  2554. $info = $themes[$theme_key]->info;
  2555. // If requested, suppress hidden regions. See block_admin_display_form().
  2556. foreach ($info['regions'] as $name => $label) {
  2557. if ($show == REGIONS_ALL || !isset($info['regions_hidden']) || !in_array($name, $info['regions_hidden'])) {
  2558. $list[$name] = t($label);
  2559. }
  2560. }
  2561. return $list;
  2562. }
  2563. /**
  2564. * Implements hook_system_info_alter().
  2565. */
  2566. function system_system_info_alter(&$info, $file, $type) {
  2567. // Remove page-top and page-bottom from the blocks UI since they are reserved for
  2568. // modules to populate from outside the blocks system.
  2569. if ($type == 'theme') {
  2570. $info['regions_hidden'][] = 'page_top';
  2571. $info['regions_hidden'][] = 'page_bottom';
  2572. }
  2573. }
  2574. /**
  2575. * Get the name of the default region for a given theme.
  2576. *
  2577. * @param $theme
  2578. * The name of a theme.
  2579. * @return
  2580. * A string that is the region name.
  2581. */
  2582. function system_default_region($theme) {
  2583. $regions = array_keys(system_region_list($theme, REGIONS_VISIBLE));
  2584. return isset($regions[0]) ? $regions[0] : '';
  2585. }
  2586. /**
  2587. * Sets up a form to save information automatically.
  2588. *
  2589. * This function adds a submit handler and a submit button to a form array. The
  2590. * submit function saves all the data in the form, using variable_set(), to
  2591. * variables named the same as the keys in the form array. Note that this means
  2592. * you should normally prefix your form array keys with your module name, so
  2593. * that they are unique when passed into variable_set().
  2594. *
  2595. * If you need to manipulate the data in a custom manner, you can either put
  2596. * your own submission handler in the form array before calling this function,
  2597. * or just use your own submission handler instead of calling this function.
  2598. *
  2599. * @param $form
  2600. * An associative array containing the structure of the form.
  2601. *
  2602. * @return
  2603. * The form structure.
  2604. *
  2605. * @see system_settings_form_submit()
  2606. *
  2607. * @ingroup forms
  2608. */
  2609. function system_settings_form($form) {
  2610. $form['actions']['#type'] = 'actions';
  2611. $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
  2612. if (!empty($_POST) && form_get_errors()) {
  2613. drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
  2614. }
  2615. $form['#submit'][] = 'system_settings_form_submit';
  2616. // By default, render the form using theme_system_settings_form().
  2617. if (!isset($form['#theme'])) {
  2618. $form['#theme'] = 'system_settings_form';
  2619. }
  2620. return $form;
  2621. }
  2622. /**
  2623. * Form submission handler for system_settings_form().
  2624. *
  2625. * If you want node type configure style handling of your checkboxes,
  2626. * add an array_filter value to your form.
  2627. */
  2628. function system_settings_form_submit($form, &$form_state) {
  2629. // Exclude unnecessary elements.
  2630. form_state_values_clean($form_state);
  2631. foreach ($form_state['values'] as $key => $value) {
  2632. if (is_array($value) && isset($form_state['values']['array_filter'])) {
  2633. $value = array_keys(array_filter($value));
  2634. }
  2635. variable_set($key, $value);
  2636. }
  2637. drupal_set_message(t('The configuration options have been saved.'));
  2638. }
  2639. /**
  2640. * Helper function to sort requirements.
  2641. */
  2642. function _system_sort_requirements($a, $b) {
  2643. if (!isset($a['weight'])) {
  2644. if (!isset($b['weight'])) {
  2645. return strcmp($a['title'], $b['title']);
  2646. }
  2647. return -$b['weight'];
  2648. }
  2649. return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
  2650. }
  2651. /**
  2652. * Generates a form array for a confirmation form.
  2653. *
  2654. * This function returns a complete form array for confirming an action. The
  2655. * form contains a confirm button as well as a cancellation link that allows a
  2656. * user to abort the action.
  2657. *
  2658. * If the submit handler for a form that implements confirm_form() is invoked,
  2659. * the user successfully confirmed the action. You should never directly
  2660. * inspect $_POST to see if an action was confirmed.
  2661. *
  2662. * Note - if the parameters $question, $description, $yes, or $no could contain
  2663. * any user input (such as node titles or taxonomy terms), it is the
  2664. * responsibility of the code calling confirm_form() to sanitize them first with
  2665. * a function like check_plain() or filter_xss().
  2666. *
  2667. * @param $form
  2668. * Additional elements to add to the form. These can be regular form elements,
  2669. * #value elements, etc., and their values will be available to the submit
  2670. * handler.
  2671. * @param $question
  2672. * The question to ask the user (e.g. "Are you sure you want to delete the
  2673. * block <em>foo</em>?"). The page title will be set to this value.
  2674. * @param $path
  2675. * The page to go to if the user cancels the action. This can be either:
  2676. * - A string containing a Drupal path.
  2677. * - An associative array with a 'path' key. Additional array values are
  2678. * passed as the $options parameter to l().
  2679. * If the 'destination' query parameter is set in the URL when viewing a
  2680. * confirmation form, that value will be used instead of $path.
  2681. * @param $description
  2682. * Additional text to display. Defaults to t('This action cannot be undone.').
  2683. * @param $yes
  2684. * A caption for the button that confirms the action (e.g. "Delete",
  2685. * "Replace", ...). Defaults to t('Confirm').
  2686. * @param $no
  2687. * A caption for the link which cancels the action (e.g. "Cancel"). Defaults
  2688. * to t('Cancel').
  2689. * @param $name
  2690. * The internal name used to refer to the confirmation item.
  2691. *
  2692. * @return
  2693. * The form array.
  2694. */
  2695. function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
  2696. $description = isset($description) ? $description : t('This action cannot be undone.');
  2697. // Prepare cancel link.
  2698. if (isset($_GET['destination'])) {
  2699. $options = drupal_parse_url(urldecode($_GET['destination']));
  2700. }
  2701. elseif (is_array($path)) {
  2702. $options = $path;
  2703. }
  2704. else {
  2705. $options = array('path' => $path);
  2706. }
  2707. drupal_set_title($question, PASS_THROUGH);
  2708. $form['#attributes']['class'][] = 'confirmation';
  2709. $form['description'] = array('#markup' => $description);
  2710. $form[$name] = array('#type' => 'hidden', '#value' => 1);
  2711. $form['actions'] = array('#type' => 'actions');
  2712. $form['actions']['submit'] = array(
  2713. '#type' => 'submit',
  2714. '#value' => $yes ? $yes : t('Confirm'),
  2715. );
  2716. $form['actions']['cancel'] = array(
  2717. '#type' => 'link',
  2718. '#title' => $no ? $no : t('Cancel'),
  2719. '#href' => $options['path'],
  2720. '#options' => $options,
  2721. );
  2722. // By default, render the form using theme_confirm_form().
  2723. if (!isset($form['#theme'])) {
  2724. $form['#theme'] = 'confirm_form';
  2725. }
  2726. return $form;
  2727. }
  2728. /**
  2729. * Determines whether the current user is in compact mode.
  2730. *
  2731. * Compact mode shows certain administration pages with less description text,
  2732. * such as the configuration page and the permissions page.
  2733. *
  2734. * Whether the user is in compact mode is determined by a cookie, which is set
  2735. * for the user by system_admin_compact_page().
  2736. *
  2737. * If the user does not have the cookie, the default value is given by the
  2738. * system variable 'admin_compact_mode', which itself defaults to FALSE. This
  2739. * does not have a user interface to set it: it is a hidden variable which can
  2740. * be set in the settings.php file.
  2741. *
  2742. * @return
  2743. * TRUE when in compact mode, FALSE when in expanded mode.
  2744. */
  2745. function system_admin_compact_mode() {
  2746. // PHP converts dots into underscores in cookie names to avoid problems with
  2747. // its parser, so we use a converted cookie name.
  2748. return isset($_COOKIE['Drupal_visitor_admin_compact_mode']) ? $_COOKIE['Drupal_visitor_admin_compact_mode'] : variable_get('admin_compact_mode', FALSE);
  2749. }
  2750. /**
  2751. * Menu callback; Sets whether the admin menu is in compact mode or not.
  2752. *
  2753. * @param $mode
  2754. * Valid values are 'on' and 'off'.
  2755. */
  2756. function system_admin_compact_page($mode = 'off') {
  2757. user_cookie_save(array('admin_compact_mode' => ($mode == 'on')));
  2758. drupal_goto();
  2759. }
  2760. /**
  2761. * Generate a list of tasks offered by a specified module.
  2762. *
  2763. * @param $module
  2764. * Module name.
  2765. * @param $info
  2766. * The module's information, as provided by system_get_info().
  2767. *
  2768. * @return
  2769. * An array of task links.
  2770. */
  2771. function system_get_module_admin_tasks($module, $info) {
  2772. $links = &drupal_static(__FUNCTION__);
  2773. if (!isset($links)) {
  2774. $links = array();
  2775. $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
  2776. $query->join('menu_router', 'm', 'm.path = ml.router_path');
  2777. $query
  2778. ->fields('ml')
  2779. // Weight should be taken from {menu_links}, not {menu_router}.
  2780. ->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')))
  2781. ->condition('ml.link_path', 'admin/%', 'LIKE')
  2782. ->condition('ml.hidden', 0, '>=')
  2783. ->condition('ml.module', 'system')
  2784. ->condition('m.number_parts', 1, '>')
  2785. ->condition('m.page_callback', 'system_admin_menu_block_page', '<>');
  2786. foreach ($query->execute() as $link) {
  2787. _menu_link_translate($link);
  2788. if ($link['access']) {
  2789. $links[$link['router_path']] = $link;
  2790. }
  2791. }
  2792. }
  2793. $admin_tasks = array();
  2794. $titles = array();
  2795. if ($menu = module_invoke($module, 'menu')) {
  2796. foreach ($menu as $path => $item) {
  2797. if (isset($links[$path])) {
  2798. $task = $links[$path];
  2799. // The link description, either derived from 'description' in
  2800. // hook_menu() or customized via menu module is used as title attribute.
  2801. if (!empty($task['localized_options']['attributes']['title'])) {
  2802. $task['description'] = $task['localized_options']['attributes']['title'];
  2803. unset($task['localized_options']['attributes']['title']);
  2804. }
  2805. // Check the admin tasks for duplicate names. If one is found,
  2806. // append the parent menu item's title to differentiate.
  2807. $duplicate_path = array_search($task['title'], $titles);
  2808. if ($duplicate_path !== FALSE) {
  2809. if ($parent = menu_link_load($task['plid'])) {
  2810. // Append the parent item's title to this task's title.
  2811. $task['title'] = t('@original_title (@parent_title)', array('@original_title' => $task['title'], '@parent_title' => $parent['title']));
  2812. }
  2813. if ($parent = menu_link_load($admin_tasks[$duplicate_path]['plid'])) {
  2814. // Append the parent item's title to the duplicated task's title.
  2815. // We use $links[$duplicate_path] in case there are triplicates.
  2816. $admin_tasks[$duplicate_path]['title'] = t('@original_title (@parent_title)', array('@original_title' => $links[$duplicate_path]['title'], '@parent_title' => $parent['title']));
  2817. }
  2818. }
  2819. else {
  2820. $titles[$path] = $task['title'];
  2821. }
  2822. $admin_tasks[$path] = $task;
  2823. }
  2824. }
  2825. }
  2826. // Append link for permissions.
  2827. if (module_hook($module, 'permission')) {
  2828. $item = menu_get_item('admin/people/permissions');
  2829. if (!empty($item['access'])) {
  2830. $item['link_path'] = $item['href'];
  2831. $item['title'] = t('Configure @module permissions', array('@module' => $info['name']));
  2832. unset($item['description']);
  2833. $item['localized_options']['fragment'] = 'module-' . $module;
  2834. $admin_tasks["admin/people/permissions#module-$module"] = $item;
  2835. }
  2836. }
  2837. return $admin_tasks;
  2838. }
  2839. /**
  2840. * Implements hook_cron().
  2841. *
  2842. * Remove older rows from flood and batch table. Remove old temporary files.
  2843. */
  2844. function system_cron() {
  2845. // Cleanup the flood.
  2846. db_delete('flood')
  2847. ->condition('expiration', REQUEST_TIME, '<')
  2848. ->execute();
  2849. // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
  2850. // Use separate placeholders for the status to avoid a bug in some versions
  2851. // of PHP. See http://drupal.org/node/352956.
  2852. $result = db_query('SELECT fid FROM {file_managed} WHERE status <> :permanent AND timestamp < :timestamp', array(
  2853. ':permanent' => FILE_STATUS_PERMANENT,
  2854. ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE
  2855. ));
  2856. foreach ($result as $row) {
  2857. if ($file = file_load($row->fid)) {
  2858. $references = file_usage_list($file);
  2859. if (empty($references)) {
  2860. if (!file_delete($file)) {
  2861. watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->uri), WATCHDOG_ERROR);
  2862. }
  2863. }
  2864. else {
  2865. watchdog('file system', 'Did not delete temporary file "%path" during garbage collection, because it is in use by the following modules: %modules.', array('%path' => $file->uri, '%modules' => implode(', ', array_keys($references))), WATCHDOG_INFO);
  2866. }
  2867. }
  2868. }
  2869. $core = array('cache', 'cache_path', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu');
  2870. $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
  2871. foreach ($cache_tables as $table) {
  2872. cache_clear_all(NULL, $table);
  2873. }
  2874. // Cleanup the batch table and the queue for failed batches.
  2875. db_delete('batch')
  2876. ->condition('timestamp', REQUEST_TIME - 864000, '<')
  2877. ->execute();
  2878. db_delete('queue')
  2879. ->condition('created', REQUEST_TIME - 864000, '<')
  2880. ->condition('name', 'drupal_batch:%', 'LIKE')
  2881. ->execute();
  2882. // Reset expired items in the default queue implementation table. If that's
  2883. // not used, this will simply be a no-op.
  2884. db_update('queue')
  2885. ->fields(array(
  2886. 'expire' => 0,
  2887. ))
  2888. ->condition('expire', 0, '<>')
  2889. ->condition('expire', REQUEST_TIME, '<')
  2890. ->execute();
  2891. }
  2892. /**
  2893. * Implements hook_flush_caches().
  2894. */
  2895. function system_flush_caches() {
  2896. // Rebuild list of date formats.
  2897. system_date_formats_rebuild();
  2898. // Reset the menu static caches.
  2899. menu_reset_static_cache();
  2900. }
  2901. /**
  2902. * Implements hook_action_info().
  2903. */
  2904. function system_action_info() {
  2905. return array(
  2906. 'system_message_action' => array(
  2907. 'type' => 'system',
  2908. 'label' => t('Display a message to the user'),
  2909. 'configurable' => TRUE,
  2910. 'triggers' => array('any'),
  2911. ),
  2912. 'system_send_email_action' => array(
  2913. 'type' => 'system',
  2914. 'label' => t('Send e-mail'),
  2915. 'configurable' => TRUE,
  2916. 'triggers' => array('any'),
  2917. ),
  2918. 'system_block_ip_action' => array(
  2919. 'type' => 'user',
  2920. 'label' => t('Ban IP address of current user'),
  2921. 'configurable' => FALSE,
  2922. 'triggers' => array('any'),
  2923. ),
  2924. 'system_goto_action' => array(
  2925. 'type' => 'system',
  2926. 'label' => t('Redirect to URL'),
  2927. 'configurable' => TRUE,
  2928. 'triggers' => array('any'),
  2929. ),
  2930. );
  2931. }
  2932. /**
  2933. * Return a form definition so the Send email action can be configured.
  2934. *
  2935. * @param $context
  2936. * Default values (if we are editing an existing action instance).
  2937. *
  2938. * @return
  2939. * Form definition.
  2940. *
  2941. * @see system_send_email_action_validate()
  2942. * @see system_send_email_action_submit()
  2943. */
  2944. function system_send_email_action_form($context) {
  2945. // Set default values for form.
  2946. if (!isset($context['recipient'])) {
  2947. $context['recipient'] = '';
  2948. }
  2949. if (!isset($context['subject'])) {
  2950. $context['subject'] = '';
  2951. }
  2952. if (!isset($context['message'])) {
  2953. $context['message'] = '';
  2954. }
  2955. $form['recipient'] = array(
  2956. '#type' => 'textfield',
  2957. '#title' => t('Recipient'),
  2958. '#default_value' => $context['recipient'],
  2959. '#maxlength' => '254',
  2960. '#description' => t('The email address to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc. if you would like to send an e-mail to the author of the original post.'),
  2961. );
  2962. $form['subject'] = array(
  2963. '#type' => 'textfield',
  2964. '#title' => t('Subject'),
  2965. '#default_value' => $context['subject'],
  2966. '#maxlength' => '254',
  2967. '#description' => t('The subject of the message.'),
  2968. );
  2969. $form['message'] = array(
  2970. '#type' => 'textarea',
  2971. '#title' => t('Message'),
  2972. '#default_value' => $context['message'],
  2973. '#cols' => '80',
  2974. '#rows' => '20',
  2975. '#description' => t('The message that should be sent. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
  2976. );
  2977. return $form;
  2978. }
  2979. /**
  2980. * Validate system_send_email_action form submissions.
  2981. */
  2982. function system_send_email_action_validate($form, $form_state) {
  2983. $form_values = $form_state['values'];
  2984. // Validate the configuration form.
  2985. if (!valid_email_address($form_values['recipient']) && strpos($form_values['recipient'], ':mail') === FALSE) {
  2986. // We want the literal %author placeholder to be emphasized in the error message.
  2987. form_set_error('recipient', t('Enter a valid email address or use a token e-mail address such as %author.', array('%author' => '[node:author:mail]')));
  2988. }
  2989. }
  2990. /**
  2991. * Process system_send_email_action form submissions.
  2992. */
  2993. function system_send_email_action_submit($form, $form_state) {
  2994. $form_values = $form_state['values'];
  2995. // Process the HTML form to store configuration. The keyed array that
  2996. // we return will be serialized to the database.
  2997. $params = array(
  2998. 'recipient' => $form_values['recipient'],
  2999. 'subject' => $form_values['subject'],
  3000. 'message' => $form_values['message'],
  3001. );
  3002. return $params;
  3003. }
  3004. /**
  3005. * Sends an e-mail message.
  3006. *
  3007. * @param object $entity
  3008. * An optional node object, which will be added as $context['node'] if
  3009. * provided.
  3010. * @param array $context
  3011. * Array with the following elements:
  3012. * - 'recipient': E-mail message recipient. This will be passed through
  3013. * token_replace().
  3014. * - 'subject': The subject of the message. This will be passed through
  3015. * token_replace().
  3016. * - 'message': The message to send. This will be passed through
  3017. * token_replace().
  3018. * - Other elements will be used as the data for token replacement.
  3019. *
  3020. * @ingroup actions
  3021. */
  3022. function system_send_email_action($entity, $context) {
  3023. if (empty($context['node'])) {
  3024. $context['node'] = $entity;
  3025. }
  3026. $recipient = token_replace($context['recipient'], $context);
  3027. // If the recipient is a registered user with a language preference, use
  3028. // the recipient's preferred language. Otherwise, use the system default
  3029. // language.
  3030. $recipient_account = user_load_by_mail($recipient);
  3031. if ($recipient_account) {
  3032. $language = user_preferred_language($recipient_account);
  3033. }
  3034. else {
  3035. $language = language_default();
  3036. }
  3037. $params = array('context' => $context);
  3038. if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) {
  3039. watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
  3040. }
  3041. else {
  3042. watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
  3043. }
  3044. }
  3045. /**
  3046. * Implements hook_mail().
  3047. */
  3048. function system_mail($key, &$message, $params) {
  3049. $context = $params['context'];
  3050. $subject = token_replace($context['subject'], $context);
  3051. $body = token_replace($context['message'], $context);
  3052. $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
  3053. $message['body'][] = $body;
  3054. }
  3055. function system_message_action_form($context) {
  3056. $form['message'] = array(
  3057. '#type' => 'textarea',
  3058. '#title' => t('Message'),
  3059. '#default_value' => isset($context['message']) ? $context['message'] : '',
  3060. '#required' => TRUE,
  3061. '#rows' => '8',
  3062. '#description' => t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
  3063. );
  3064. return $form;
  3065. }
  3066. function system_message_action_submit($form, $form_state) {
  3067. return array('message' => $form_state['values']['message']);
  3068. }
  3069. /**
  3070. * Sends a message to the current user's screen.
  3071. *
  3072. * @param object $entity
  3073. * An optional node object, which will be added as $context['node'] if
  3074. * provided.
  3075. * @param array $context
  3076. * Array with the following elements:
  3077. * - 'message': The message to send. This will be passed through
  3078. * token_replace().
  3079. * - Other elements will be used as the data for token replacement in
  3080. * the message.
  3081. *
  3082. * @ingroup actions
  3083. */
  3084. function system_message_action(&$entity, $context = array()) {
  3085. if (empty($context['node'])) {
  3086. $context['node'] = $entity;
  3087. }
  3088. $context['message'] = token_replace(filter_xss_admin($context['message']), $context);
  3089. drupal_set_message($context['message']);
  3090. }
  3091. /**
  3092. * Settings form for system_goto_action().
  3093. */
  3094. function system_goto_action_form($context) {
  3095. $form['url'] = array(
  3096. '#type' => 'textfield',
  3097. '#title' => t('URL'),
  3098. '#description' => t('The URL to which the user should be redirected. This can be an internal URL like node/1234 or an external URL like http://drupal.org.'),
  3099. '#default_value' => isset($context['url']) ? $context['url'] : '',
  3100. '#required' => TRUE,
  3101. );
  3102. return $form;
  3103. }
  3104. function system_goto_action_submit($form, $form_state) {
  3105. return array(
  3106. 'url' => $form_state['values']['url']
  3107. );
  3108. }
  3109. /**
  3110. * Redirects to a different URL.
  3111. *
  3112. * @param $entity
  3113. * Ignored.
  3114. * @param array $context
  3115. * Array with the following elements:
  3116. * - 'url': URL to redirect to. This will be passed through
  3117. * token_replace().
  3118. * - Other elements will be used as the data for token replacement.
  3119. *
  3120. * @ingroup actions
  3121. */
  3122. function system_goto_action($entity, $context) {
  3123. drupal_goto(token_replace($context['url'], $context));
  3124. }
  3125. /**
  3126. * Blocks the current user's IP address.
  3127. *
  3128. * @ingroup actions
  3129. */
  3130. function system_block_ip_action() {
  3131. $ip = ip_address();
  3132. db_insert('blocked_ips')
  3133. ->fields(array('ip' => $ip))
  3134. ->execute();
  3135. watchdog('action', 'Banned IP address %ip', array('%ip' => $ip));
  3136. }
  3137. /**
  3138. * Generate an array of time zones and their local time&date.
  3139. *
  3140. * @param $blank
  3141. * If evaluates true, prepend an empty time zone option to the array.
  3142. */
  3143. function system_time_zones($blank = NULL) {
  3144. $zonelist = timezone_identifiers_list();
  3145. $zones = $blank ? array('' => t('- None selected -')) : array();
  3146. foreach ($zonelist as $zone) {
  3147. // Because many time zones exist in PHP only for backward compatibility
  3148. // reasons and should not be used, the list is filtered by a regular
  3149. // expression.
  3150. if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
  3151. $zones[$zone] = t('@zone: @date', array('@zone' => t(str_replace('_', ' ', $zone)), '@date' => format_date(REQUEST_TIME, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone)));
  3152. }
  3153. }
  3154. // Sort the translated time zones alphabetically.
  3155. asort($zones);
  3156. return $zones;
  3157. }
  3158. /**
  3159. * Checks whether the server is capable of issuing HTTP requests.
  3160. *
  3161. * The function sets the drupal_http_request_fail system variable to TRUE if
  3162. * drupal_http_request() does not work and then the system status report page
  3163. * will contain an error.
  3164. *
  3165. * @return
  3166. * TRUE if this installation can issue HTTP requests.
  3167. */
  3168. function system_check_http_request() {
  3169. // Try to get the content of the front page via drupal_http_request().
  3170. $result = drupal_http_request(url('', array('absolute' => TRUE)), array('max_redirects' => 0));
  3171. // We only care that we get a http response - this means that Drupal
  3172. // can make a http request.
  3173. $works = isset($result->code) && ($result->code >= 100) && ($result->code < 600);
  3174. variable_set('drupal_http_request_fails', !$works);
  3175. return $works;
  3176. }
  3177. /**
  3178. * Menu callback; Retrieve a JSON object containing a suggested time zone name.
  3179. */
  3180. function system_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) {
  3181. // An abbreviation of "0" passed in the callback arguments should be
  3182. // interpreted as the empty string.
  3183. $abbreviation = $abbreviation ? $abbreviation : '';
  3184. $timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time);
  3185. drupal_json_output($timezone);
  3186. }
  3187. /**
  3188. * Returns HTML for the Powered by Drupal text.
  3189. *
  3190. * @ingroup themeable
  3191. */
  3192. function theme_system_powered_by() {
  3193. return '<span>' . t('Powered by <a href="@poweredby">Drupal</a>', array('@poweredby' => 'http://drupal.org')) . '</span>';
  3194. }
  3195. /**
  3196. * Returns HTML for a link to show or hide inline help descriptions.
  3197. *
  3198. * @ingroup themeable
  3199. */
  3200. function theme_system_compact_link() {
  3201. $output = '<div class="compact-link">';
  3202. if (system_admin_compact_mode()) {
  3203. $output .= l(t('Show descriptions'), 'admin/compact/off', array('attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => drupal_get_destination()));
  3204. }
  3205. else {
  3206. $output .= l(t('Hide descriptions'), 'admin/compact/on', array('attributes' => array('title' => t('Compress layout by hiding descriptions.')), 'query' => drupal_get_destination()));
  3207. }
  3208. $output .= '</div>';
  3209. return $output;
  3210. }
  3211. /**
  3212. * Implements hook_image_toolkits().
  3213. */
  3214. function system_image_toolkits() {
  3215. include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'system') . '/' . 'image.gd.inc';
  3216. return array(
  3217. 'gd' => array(
  3218. 'title' => t('GD2 image manipulation toolkit'),
  3219. 'available' => function_exists('image_gd_check_settings') && image_gd_check_settings(),
  3220. ),
  3221. );
  3222. }
  3223. /**
  3224. * Attempts to get a file using drupal_http_request and to store it locally.
  3225. *
  3226. * @param string $url
  3227. * The URL of the file to grab.
  3228. * @param string $destination
  3229. * Stream wrapper URI specifying where the file should be placed. If a
  3230. * directory path is provided, the file is saved into that directory under
  3231. * its original name. If the path contains a filename as well, that one will
  3232. * be used instead.
  3233. * If this value is omitted, the site's default files scheme will be used,
  3234. * usually "public://".
  3235. * @param bool $managed
  3236. * If this is set to TRUE, the file API hooks will be invoked and the file is
  3237. * registered in the database.
  3238. * @param int $replace
  3239. * Replace behavior when the destination file already exists:
  3240. * - FILE_EXISTS_REPLACE: Replace the existing file.
  3241. * - FILE_EXISTS_RENAME: Append _{incrementing number} until the filename is
  3242. * unique.
  3243. * - FILE_EXISTS_ERROR: Do nothing and return FALSE.
  3244. *
  3245. * @return mixed
  3246. * One of these possibilities:
  3247. * - If it succeeds and $managed is FALSE, the location where the file was
  3248. * saved.
  3249. * - If it succeeds and $managed is TRUE, a \Drupal\file\FileInterface
  3250. * object which describes the file.
  3251. * - If it fails, FALSE.
  3252. */
  3253. function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FILE_EXISTS_RENAME) {
  3254. $parsed_url = parse_url($url);
  3255. if (!isset($destination)) {
  3256. $path = file_build_uri(drupal_basename($parsed_url['path']));
  3257. }
  3258. else {
  3259. if (is_dir(drupal_realpath($destination))) {
  3260. // Prevent URIs with triple slashes when glueing parts together.
  3261. $path = str_replace('///', '//', "$destination/") . drupal_basename($parsed_url['path']);
  3262. }
  3263. else {
  3264. $path = $destination;
  3265. }
  3266. }
  3267. $result = drupal_http_request($url);
  3268. if ($result->code != 200) {
  3269. drupal_set_message(t('HTTP error @errorcode occurred when trying to fetch @remote.', array('@errorcode' => $result->code, '@remote' => $url)), 'error');
  3270. return FALSE;
  3271. }
  3272. $local = $managed ? file_save_data($result->data, $path, $replace) : file_unmanaged_save_data($result->data, $path, $replace);
  3273. if (!$local) {
  3274. drupal_set_message(t('@remote could not be saved to @path.', array('@remote' => $url, '@path' => $path)), 'error');
  3275. }
  3276. return $local;
  3277. }
  3278. /**
  3279. * Implements hook_page_alter().
  3280. */
  3281. function system_page_alter(&$page) {
  3282. // Find all non-empty page regions, and add a theme wrapper function that
  3283. // allows them to be consistently themed.
  3284. $regions = system_region_list($GLOBALS['theme']);
  3285. foreach (array_keys($regions) as $region) {
  3286. if (!empty($page[$region])) {
  3287. $page[$region]['#theme_wrappers'][] = 'region';
  3288. $page[$region]['#region'] = $region;
  3289. }
  3290. }
  3291. }
  3292. /**
  3293. * Run the automated cron if enabled.
  3294. */
  3295. function system_run_automated_cron() {
  3296. // If the site is not fully installed, suppress the automated cron run.
  3297. // Otherwise it could be triggered prematurely by Ajax requests during
  3298. // installation.
  3299. if (($threshold = variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD)) > 0 && variable_get('install_task') == 'done') {
  3300. $cron_last = variable_get('cron_last', NULL);
  3301. if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) {
  3302. drupal_cron_run();
  3303. }
  3304. }
  3305. }
  3306. /**
  3307. * Gets the list of available date types and attributes.
  3308. *
  3309. * @param $type
  3310. * (optional) The date type name.
  3311. *
  3312. * @return
  3313. * An associative array of date type information keyed by the date type name.
  3314. * Each date type information array has the following elements:
  3315. * - type: The machine-readable name of the date type.
  3316. * - title: The human-readable name of the date type.
  3317. * - locked: A boolean indicating whether or not this date type should be
  3318. * configurable from the user interface.
  3319. * - module: The name of the module that defined this date type in its
  3320. * hook_date_format_types(). An empty string if the date type was
  3321. * user-defined.
  3322. * - is_new: A boolean indicating whether or not this date type is as of yet
  3323. * unsaved in the database.
  3324. * If $type was defined, only a single associative array with the above
  3325. * elements is returned.
  3326. */
  3327. function system_get_date_types($type = NULL) {
  3328. $types = &drupal_static(__FUNCTION__);
  3329. if (!isset($types)) {
  3330. $types = _system_date_format_types_build();
  3331. }
  3332. return $type ? (isset($types[$type]) ? $types[$type] : FALSE) : $types;
  3333. }
  3334. /**
  3335. * Implements hook_date_format_types().
  3336. */
  3337. function system_date_format_types() {
  3338. return array(
  3339. 'long' => t('Long'),
  3340. 'medium' => t('Medium'),
  3341. 'short' => t('Short'),
  3342. );
  3343. }
  3344. /**
  3345. * Implements hook_date_formats().
  3346. */
  3347. function system_date_formats() {
  3348. include_once DRUPAL_ROOT . '/includes/date.inc';
  3349. return system_default_date_formats();
  3350. }
  3351. /**
  3352. * Gets the list of defined date formats and attributes.
  3353. *
  3354. * @param $type
  3355. * (optional) The date type name.
  3356. *
  3357. * @return
  3358. * An associative array of date formats. The top-level keys are the names of
  3359. * the date types that the date formats belong to. The values are in turn
  3360. * associative arrays keyed by the format string, with the following keys:
  3361. * - dfid: The date format ID.
  3362. * - format: The format string.
  3363. * - type: The machine-readable name of the date type.
  3364. * - locales: An array of language codes. This can include both 2 character
  3365. * language codes like 'en and 'fr' and 5 character language codes like
  3366. * 'en-gb' and 'en-us'.
  3367. * - locked: A boolean indicating whether or not this date type should be
  3368. * configurable from the user interface.
  3369. * - module: The name of the module that defined this date format in its
  3370. * hook_date_formats(). An empty string if the format was user-defined.
  3371. * - is_new: A boolean indicating whether or not this date type is as of yet
  3372. * unsaved in the database.
  3373. * If $type was defined, only the date formats associated with the given date
  3374. * type are returned, in a single associative array keyed by format string.
  3375. */
  3376. function system_get_date_formats($type = NULL) {
  3377. $date_formats = &drupal_static(__FUNCTION__);
  3378. if (!isset($date_formats)) {
  3379. $date_formats = _system_date_formats_build();
  3380. }
  3381. return $type ? (isset($date_formats[$type]) ? $date_formats[$type] : FALSE) : $date_formats;
  3382. }
  3383. /**
  3384. * Gets the format details for a particular format ID.
  3385. *
  3386. * @param $dfid
  3387. * A date format ID.
  3388. *
  3389. * @return
  3390. * A date format object with the following properties:
  3391. * - dfid: The date format ID.
  3392. * - format: The date format string.
  3393. * - type: The name of the date type.
  3394. * - locked: Whether the date format can be changed or not.
  3395. */
  3396. function system_get_date_format($dfid) {
  3397. return db_query('SELECT df.dfid, df.format, df.type, df.locked FROM {date_formats} df WHERE df.dfid = :dfid', array(':dfid' => $dfid))->fetch();
  3398. }
  3399. /**
  3400. * Resets the database cache of date formats and saves all new date formats.
  3401. */
  3402. function system_date_formats_rebuild() {
  3403. drupal_static_reset('system_get_date_formats');
  3404. $date_formats = system_get_date_formats(NULL);
  3405. foreach ($date_formats as $type => $formats) {
  3406. foreach ($formats as $format => $info) {
  3407. system_date_format_save($info);
  3408. }
  3409. }
  3410. // Rebuild configured date formats locale list.
  3411. drupal_static_reset('system_date_format_locale');
  3412. system_date_format_locale();
  3413. _system_date_formats_build();
  3414. }
  3415. /**
  3416. * Gets the appropriate date format string for a date type and locale.
  3417. *
  3418. * @param $langcode
  3419. * (optional) Language code for the current locale. This can be a 2 character
  3420. * language code like 'en' and 'fr' or a 5 character language code like
  3421. * 'en-gb' and 'en-us'.
  3422. * @param $type
  3423. * (optional) The date type name.
  3424. *
  3425. * @return
  3426. * If $type and $langcode are specified, returns the corresponding date format
  3427. * string. If only $langcode is specified, returns an array of all date
  3428. * format strings for that locale, keyed by the date type. If neither is
  3429. * specified, or if no matching formats are found, returns FALSE.
  3430. */
  3431. function system_date_format_locale($langcode = NULL, $type = NULL) {
  3432. $formats = &drupal_static(__FUNCTION__);
  3433. if (empty($formats)) {
  3434. $formats = array();
  3435. $result = db_query("SELECT format, type, language FROM {date_format_locale}");
  3436. foreach ($result as $record) {
  3437. if (!isset($formats[$record->language])) {
  3438. $formats[$record->language] = array();
  3439. }
  3440. $formats[$record->language][$record->type] = $record->format;
  3441. }
  3442. }
  3443. if ($type && $langcode && !empty($formats[$langcode][$type])) {
  3444. return $formats[$langcode][$type];
  3445. }
  3446. elseif ($langcode && !empty($formats[$langcode])) {
  3447. return $formats[$langcode];
  3448. }
  3449. return FALSE;
  3450. }
  3451. /**
  3452. * Builds and returns information about available date types.
  3453. *
  3454. * @return
  3455. * An associative array of date type information keyed by name. Each date type
  3456. * information array has the following elements:
  3457. * - type: The machine-readable name of the date type.
  3458. * - title: The human-readable name of the date type.
  3459. * - locked: A boolean indicating whether or not this date type should be
  3460. * configurable from the user interface.
  3461. * - module: The name of the module that defined this format in its
  3462. * hook_date_format_types(). An empty string if the format was user-defined.
  3463. * - is_new: A boolean indicating whether or not this date type is as of yet
  3464. * unsaved in the database.
  3465. */
  3466. function _system_date_format_types_build() {
  3467. $types = array();
  3468. // Get list of modules that implement hook_date_format_types().
  3469. $modules = module_implements('date_format_types');
  3470. foreach ($modules as $module) {
  3471. $module_types = module_invoke($module, 'date_format_types');
  3472. foreach ($module_types as $module_type => $type_title) {
  3473. $type = array();
  3474. $type['module'] = $module;
  3475. $type['type'] = $module_type;
  3476. $type['title'] = $type_title;
  3477. $type['locked'] = 1;
  3478. // Will be over-ridden later if in the db.
  3479. $type['is_new'] = TRUE;
  3480. $types[$module_type] = $type;
  3481. }
  3482. }
  3483. // Get custom formats added to the database by the end user.
  3484. $result = db_query('SELECT dft.type, dft.title, dft.locked FROM {date_format_type} dft ORDER BY dft.title');
  3485. foreach ($result as $record) {
  3486. if (!isset($types[$record->type])) {
  3487. $type = array();
  3488. $type['is_new'] = FALSE;
  3489. $type['module'] = '';
  3490. $type['type'] = $record->type;
  3491. $type['title'] = $record->title;
  3492. $type['locked'] = $record->locked;
  3493. $types[$record->type] = $type;
  3494. }
  3495. else {
  3496. $type = array();
  3497. $type['is_new'] = FALSE; // Over-riding previous setting.
  3498. $types[$record->type] = array_merge($types[$record->type], $type);
  3499. }
  3500. }
  3501. // Allow other modules to modify these date types.
  3502. drupal_alter('date_format_types', $types);
  3503. return $types;
  3504. }
  3505. /**
  3506. * Builds and returns information about available date formats.
  3507. *
  3508. * @return
  3509. * An associative array of date formats. The top-level keys are the names of
  3510. * the date types that the date formats belong to. The values are in turn
  3511. * associative arrays keyed by format with the following keys:
  3512. * - dfid: The date format ID.
  3513. * - format: The PHP date format string.
  3514. * - type: The machine-readable name of the date type the format belongs to.
  3515. * - locales: An array of language codes. This can include both 2 character
  3516. * language codes like 'en and 'fr' and 5 character language codes like
  3517. * 'en-gb' and 'en-us'.
  3518. * - locked: A boolean indicating whether or not this date type should be
  3519. * configurable from the user interface.
  3520. * - module: The name of the module that defined this format in its
  3521. * hook_date_formats(). An empty string if the format was user-defined.
  3522. * - is_new: A boolean indicating whether or not this date type is as of yet
  3523. * unsaved in the database.
  3524. */
  3525. function _system_date_formats_build() {
  3526. $date_formats = array();
  3527. // First handle hook_date_format_types().
  3528. $types = _system_date_format_types_build();
  3529. foreach ($types as $type => $info) {
  3530. system_date_format_type_save($info);
  3531. }
  3532. // Get formats supplied by various contrib modules.
  3533. $module_formats = module_invoke_all('date_formats');
  3534. foreach ($module_formats as $module_format) {
  3535. // System types are locked.
  3536. $module_format['locked'] = 1;
  3537. // If no date type is specified, assign 'custom'.
  3538. if (!isset($module_format['type'])) {
  3539. $module_format['type'] = 'custom';
  3540. }
  3541. if (!in_array($module_format['type'], array_keys($types))) {
  3542. continue;
  3543. }
  3544. if (!isset($date_formats[$module_format['type']])) {
  3545. $date_formats[$module_format['type']] = array();
  3546. }
  3547. // If another module already set this format, merge in the new settings.
  3548. if (isset($date_formats[$module_format['type']][$module_format['format']])) {
  3549. $date_formats[$module_format['type']][$module_format['format']] = array_merge_recursive($date_formats[$module_format['type']][$module_format['format']], $module_format);
  3550. }
  3551. else {
  3552. // This setting will be overridden later if it already exists in the db.
  3553. $module_format['is_new'] = TRUE;
  3554. $date_formats[$module_format['type']][$module_format['format']] = $module_format;
  3555. }
  3556. }
  3557. // Get custom formats added to the database by the end user.
  3558. $result = db_query('SELECT df.dfid, df.format, df.type, df.locked, dfl.language FROM {date_formats} df LEFT JOIN {date_format_locale} dfl ON df.format = dfl.format AND df.type = dfl.type ORDER BY df.type, df.format');
  3559. foreach ($result as $record) {
  3560. // If this date type isn't set, initialise the array.
  3561. if (!isset($date_formats[$record->type])) {
  3562. $date_formats[$record->type] = array();
  3563. }
  3564. $format = (array) $record;
  3565. $format['is_new'] = FALSE; // It's in the db, so override this setting.
  3566. // If this format not already present, add it to the array.
  3567. if (!isset($date_formats[$record->type][$record->format])) {
  3568. $format['module'] = '';
  3569. $format['locales'] = array($record->language);
  3570. $date_formats[$record->type][$record->format] = $format;
  3571. }
  3572. // Format already present, so merge in settings.
  3573. else {
  3574. if (!empty($record->language)) {
  3575. $format['locales'] = array_merge($date_formats[$record->type][$record->format]['locales'], array($record->language));
  3576. }
  3577. $date_formats[$record->type][$record->format] = array_merge($date_formats[$record->type][$record->format], $format);
  3578. }
  3579. }
  3580. // Allow other modules to modify these formats.
  3581. drupal_alter('date_formats', $date_formats);
  3582. return $date_formats;
  3583. }
  3584. /**
  3585. * Saves a date type to the database.
  3586. *
  3587. * @param $type
  3588. * A date type array containing the following keys:
  3589. * - type: The machine-readable name of the date type.
  3590. * - title: The human-readable name of the date type.
  3591. * - locked: A boolean indicating whether or not this date type should be
  3592. * configurable from the user interface.
  3593. * - is_new: A boolean indicating whether or not this date type is as of yet
  3594. * unsaved in the database.
  3595. */
  3596. function system_date_format_type_save($type) {
  3597. $info = array();
  3598. $info['type'] = $type['type'];
  3599. $info['title'] = $type['title'];
  3600. $info['locked'] = $type['locked'];
  3601. // Update date_format table.
  3602. if (!empty($type['is_new'])) {
  3603. drupal_write_record('date_format_type', $info);
  3604. }
  3605. else {
  3606. drupal_write_record('date_format_type', $info, 'type');
  3607. }
  3608. }
  3609. /**
  3610. * Deletes a date type from the database.
  3611. *
  3612. * @param $type
  3613. * The machine-readable name of the date type.
  3614. */
  3615. function system_date_format_type_delete($type) {
  3616. db_delete('date_formats')
  3617. ->condition('type', $type)
  3618. ->execute();
  3619. db_delete('date_format_type')
  3620. ->condition('type', $type)
  3621. ->execute();
  3622. db_delete('date_format_locale')
  3623. ->condition('type', $type)
  3624. ->execute();
  3625. }
  3626. /**
  3627. * Saves a date format to the database.
  3628. *
  3629. * @param $date_format
  3630. * A date format array containing the following keys:
  3631. * - type: The name of the date type this format is associated with.
  3632. * - format: The PHP date format string.
  3633. * - locked: A boolean indicating whether or not this format should be
  3634. * configurable from the user interface.
  3635. * @param $dfid
  3636. * If set, replace the existing date format having this ID with the
  3637. * information specified in $date_format.
  3638. *
  3639. * @see system_get_date_types()
  3640. * @see http://php.net/date
  3641. */
  3642. function system_date_format_save($date_format, $dfid = 0) {
  3643. $info = array();
  3644. $info['dfid'] = $dfid;
  3645. $info['type'] = $date_format['type'];
  3646. $info['format'] = $date_format['format'];
  3647. $info['locked'] = $date_format['locked'];
  3648. // Update date_format table.
  3649. if (!empty($date_format['is_new'])) {
  3650. drupal_write_record('date_formats', $info);
  3651. }
  3652. else {
  3653. $keys = ($dfid ? array('dfid') : array('format', 'type'));
  3654. drupal_write_record('date_formats', $info, $keys);
  3655. }
  3656. // Retrieve an array of language objects for enabled languages.
  3657. $languages = language_list('enabled');
  3658. // This list is keyed off the value of $language->enabled; we want the ones
  3659. // that are enabled (value of 1).
  3660. $languages = $languages[1];
  3661. $locale_format = array();
  3662. $locale_format['type'] = $date_format['type'];
  3663. $locale_format['format'] = $date_format['format'];
  3664. // Check if the suggested language codes are configured and enabled.
  3665. if (!empty($date_format['locales'])) {
  3666. foreach ($date_format['locales'] as $langcode) {
  3667. // Only proceed if language is enabled.
  3668. if (isset($languages[$langcode])) {
  3669. $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE type = :type AND language = :language', 0, 1, array(':type' => $date_format['type'], ':language' => $langcode))->fetchField();
  3670. if (!$is_existing) {
  3671. $locale_format['language'] = $langcode;
  3672. drupal_write_record('date_format_locale', $locale_format);
  3673. }
  3674. }
  3675. }
  3676. }
  3677. }
  3678. /**
  3679. * Deletes a date format from the database.
  3680. *
  3681. * @param $dfid
  3682. * The date format ID.
  3683. */
  3684. function system_date_format_delete($dfid) {
  3685. db_delete('date_formats')
  3686. ->condition('dfid', $dfid)
  3687. ->execute();
  3688. }
  3689. /**
  3690. * Implements hook_archiver_info().
  3691. */
  3692. function system_archiver_info() {
  3693. $archivers['tar'] = array(
  3694. 'class' => 'ArchiverTar',
  3695. 'extensions' => array('tar', 'tgz', 'tar.gz', 'tar.bz2'),
  3696. );
  3697. if (function_exists('zip_open')) {
  3698. $archivers['zip'] = array(
  3699. 'class' => 'ArchiverZip',
  3700. 'extensions' => array('zip'),
  3701. );
  3702. }
  3703. return $archivers;
  3704. }
  3705. /**
  3706. * Returns HTML for a confirmation form.
  3707. *
  3708. * By default this does not alter the appearance of a form at all,
  3709. * but is provided as a convenience for themers.
  3710. *
  3711. * @param $variables
  3712. * An associative array containing:
  3713. * - form: A render element representing the form.
  3714. *
  3715. * @ingroup themeable
  3716. */
  3717. function theme_confirm_form($variables) {
  3718. return drupal_render_children($variables['form']);
  3719. }
  3720. /**
  3721. * Returns HTML for a system settings form.
  3722. *
  3723. * By default this does not alter the appearance of a form at all,
  3724. * but is provided as a convenience for themers.
  3725. *
  3726. * @param $variables
  3727. * An associative array containing:
  3728. * - form: A render element representing the form.
  3729. *
  3730. * @ingroup themeable
  3731. */
  3732. function theme_system_settings_form($variables) {
  3733. return drupal_render_children($variables['form']);
  3734. }
  3735. /**
  3736. * Returns HTML for an exposed filter form.
  3737. *
  3738. * @param $variables
  3739. * An associative array containing:
  3740. * - form: An associative array containing the structure of the form.
  3741. *
  3742. * @return
  3743. * A string containing an HTML-formatted form.
  3744. *
  3745. * @ingroup themeable
  3746. */
  3747. function theme_exposed_filters($variables) {
  3748. $form = $variables['form'];
  3749. $output = '';
  3750. if (isset($form['current'])) {
  3751. $items = array();
  3752. foreach (element_children($form['current']) as $key) {
  3753. $items[] = drupal_render($form['current'][$key]);
  3754. }
  3755. $output .= theme('item_list', array('items' => $items, 'attributes' => array('class' => array('clearfix', 'current-filters'))));
  3756. }
  3757. $output .= drupal_render_children($form);
  3758. return '<div class="exposed-filters">' . $output . '</div>';
  3759. }
  3760. /**
  3761. * Implements hook_admin_paths().
  3762. */
  3763. function system_admin_paths() {
  3764. $paths = array(
  3765. 'admin' => TRUE,
  3766. 'admin/*' => TRUE,
  3767. 'batch' => TRUE,
  3768. // This page should not be treated as administrative since it outputs its
  3769. // own content (outside of any administration theme).
  3770. 'admin/reports/status/php' => FALSE,
  3771. );
  3772. return $paths;
  3773. }