system.module 136 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996
  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.
  1679. * This function sets up all the necessary $_SESSION variables, then returns
  1680. * the full path to authorize.php so the caller can redirect to authorize.php.
  1681. * That initiates the workflow that will eventually lead to the callback being
  1682. * invoked. The callback will be invoked at a low bootstrap level, without all
  1683. * modules being invoked, so it needs to be careful not to assume any code
  1684. * exists.
  1685. *
  1686. * @param $callback
  1687. * The name of the function to invoke one the user authorizes the operation.
  1688. * @param $file
  1689. * The full path to the file where the callback function is implemented.
  1690. * @param $arguments
  1691. * Optional array of arguments to pass into the callback when it is invoked.
  1692. * Note that the first argument to the callback is always the FileTransfer
  1693. * object created by authorize.php when the user authorizes the operation.
  1694. * @param $page_title
  1695. * Optional string to use as the page title once redirected to authorize.php.
  1696. * @return
  1697. * Nothing, this function just initializes variables in the user's session.
  1698. */
  1699. function system_authorized_init($callback, $file, $arguments = array(), $page_title = NULL) {
  1700. // First, figure out what file transfer backends the site supports, and put
  1701. // all of those in the SESSION so that authorize.php has access to all of
  1702. // them via the class autoloader, even without a full bootstrap.
  1703. $_SESSION['authorize_filetransfer_info'] = drupal_get_filetransfer_info();
  1704. // Now, define the callback to invoke.
  1705. $_SESSION['authorize_operation'] = array(
  1706. 'callback' => $callback,
  1707. 'file' => $file,
  1708. 'arguments' => $arguments,
  1709. );
  1710. if (isset($page_title)) {
  1711. $_SESSION['authorize_operation']['page_title'] = $page_title;
  1712. }
  1713. }
  1714. /**
  1715. * Return the URL for the authorize.php script.
  1716. *
  1717. * @param array $options
  1718. * Optional array of options to pass to url().
  1719. * @return
  1720. * The full URL to authorize.php, using https if available.
  1721. */
  1722. function system_authorized_get_url(array $options = array()) {
  1723. global $base_url;
  1724. // Force https if available, regardless of what the caller specifies.
  1725. $options['https'] = TRUE;
  1726. // We prefix with $base_url so we get a full path even if clean URLs are
  1727. // disabled.
  1728. return url($base_url . '/authorize.php', $options);
  1729. }
  1730. /**
  1731. * Returns the URL for the authorize.php script when it is processing a batch.
  1732. */
  1733. function system_authorized_batch_processing_url() {
  1734. return system_authorized_get_url(array('query' => array('batch' => '1')));
  1735. }
  1736. /**
  1737. * Setup and invoke an operation using authorize.php.
  1738. *
  1739. * @see system_authorized_init()
  1740. */
  1741. function system_authorized_run($callback, $file, $arguments = array(), $page_title = NULL) {
  1742. system_authorized_init($callback, $file, $arguments, $page_title);
  1743. drupal_goto(system_authorized_get_url());
  1744. }
  1745. /**
  1746. * Use authorize.php to run batch_process().
  1747. *
  1748. * @see batch_process()
  1749. */
  1750. function system_authorized_batch_process() {
  1751. $finish_url = system_authorized_get_url();
  1752. $process_url = system_authorized_batch_processing_url();
  1753. batch_process($finish_url, $process_url);
  1754. }
  1755. /**
  1756. * @} End of "defgroup authorize".
  1757. */
  1758. /**
  1759. * Implements hook_updater_info().
  1760. */
  1761. function system_updater_info() {
  1762. return array(
  1763. 'module' => array(
  1764. 'class' => 'ModuleUpdater',
  1765. 'name' => t('Update modules'),
  1766. 'weight' => 0,
  1767. ),
  1768. 'theme' => array(
  1769. 'class' => 'ThemeUpdater',
  1770. 'name' => t('Update themes'),
  1771. 'weight' => 0,
  1772. ),
  1773. );
  1774. }
  1775. /**
  1776. * Implements hook_filetransfer_info().
  1777. */
  1778. function system_filetransfer_info() {
  1779. $backends = array();
  1780. // This is the default, will be available on most systems.
  1781. if (function_exists('ftp_connect')) {
  1782. $backends['ftp'] = array(
  1783. 'title' => t('FTP'),
  1784. 'class' => 'FileTransferFTP',
  1785. 'file' => 'ftp.inc',
  1786. 'file path' => 'includes/filetransfer',
  1787. 'weight' => 0,
  1788. );
  1789. }
  1790. // SSH2 lib connection is only available if the proper PHP extension is
  1791. // installed.
  1792. if (function_exists('ssh2_connect')) {
  1793. $backends['ssh'] = array(
  1794. 'title' => t('SSH'),
  1795. 'class' => 'FileTransferSSH',
  1796. 'file' => 'ssh.inc',
  1797. 'file path' => 'includes/filetransfer',
  1798. 'weight' => 20,
  1799. );
  1800. }
  1801. return $backends;
  1802. }
  1803. /**
  1804. * Implements hook_init().
  1805. */
  1806. function system_init() {
  1807. $path = drupal_get_path('module', 'system');
  1808. // Add the CSS for this module. These aren't in system.info, because they
  1809. // need to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group.
  1810. drupal_add_css($path . '/system.base.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
  1811. if (path_is_admin(current_path())) {
  1812. drupal_add_css($path . '/system.admin.css', array('group' => CSS_SYSTEM));
  1813. }
  1814. drupal_add_css($path . '/system.menus.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
  1815. drupal_add_css($path . '/system.messages.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
  1816. drupal_add_css($path . '/system.theme.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
  1817. // Ignore slave database servers for this request.
  1818. //
  1819. // In Drupal's distributed database structure, new data is written to the master
  1820. // and then propagated to the slave servers. This means there is a lag
  1821. // between when data is written to the master and when it is available on the slave.
  1822. // At these times, we will want to avoid using a slave server temporarily.
  1823. // For example, if a user posts a new node then we want to disable the slave
  1824. // server for that user temporarily to allow the slave server to catch up.
  1825. // That way, that user will see their changes immediately while for other
  1826. // users we still get the benefits of having a slave server, just with slightly
  1827. // stale data. Code that wants to disable the slave server should use the
  1828. // db_set_ignore_slave() function to set $_SESSION['ignore_slave_server'] to
  1829. // the timestamp after which the slave can be re-enabled.
  1830. if (isset($_SESSION['ignore_slave_server'])) {
  1831. if ($_SESSION['ignore_slave_server'] >= REQUEST_TIME) {
  1832. Database::ignoreTarget('default', 'slave');
  1833. }
  1834. else {
  1835. unset($_SESSION['ignore_slave_server']);
  1836. }
  1837. }
  1838. // Add CSS/JS files from module .info files.
  1839. system_add_module_assets();
  1840. }
  1841. /**
  1842. * Adds CSS and JavaScript files declared in module .info files.
  1843. */
  1844. function system_add_module_assets() {
  1845. foreach (system_get_info('module') as $module => $info) {
  1846. if (!empty($info['stylesheets'])) {
  1847. foreach ($info['stylesheets'] as $media => $stylesheets) {
  1848. foreach ($stylesheets as $stylesheet) {
  1849. drupal_add_css($stylesheet, array('every_page' => TRUE, 'media' => $media));
  1850. }
  1851. }
  1852. }
  1853. if (!empty($info['scripts'])) {
  1854. foreach ($info['scripts'] as $script) {
  1855. drupal_add_js($script, array('every_page' => TRUE));
  1856. }
  1857. }
  1858. }
  1859. }
  1860. /**
  1861. * Implements hook_custom_theme().
  1862. */
  1863. function system_custom_theme() {
  1864. if (user_access('view the administration theme') && path_is_admin(current_path())) {
  1865. return variable_get('admin_theme');
  1866. }
  1867. }
  1868. /**
  1869. * Implements hook_form_FORM_ID_alter().
  1870. */
  1871. function system_form_user_profile_form_alter(&$form, &$form_state) {
  1872. if ($form['#user_category'] == 'account') {
  1873. if (variable_get('configurable_timezones', 1)) {
  1874. system_user_timezone($form, $form_state);
  1875. }
  1876. return $form;
  1877. }
  1878. }
  1879. /**
  1880. * Implements hook_form_FORM_ID_alter().
  1881. */
  1882. function system_form_user_register_form_alter(&$form, &$form_state) {
  1883. if (variable_get('configurable_timezones', 1)) {
  1884. if (variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) == DRUPAL_USER_TIMEZONE_SELECT) {
  1885. system_user_timezone($form, $form_state);
  1886. }
  1887. else {
  1888. $form['account']['timezone'] = array(
  1889. '#type' => 'hidden',
  1890. '#value' => variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) ? '' : variable_get('date_default_timezone', ''),
  1891. );
  1892. }
  1893. return $form;
  1894. }
  1895. }
  1896. /**
  1897. * Implements hook_user_login().
  1898. */
  1899. function system_user_login(&$edit, $account) {
  1900. // If the user has a NULL time zone, notify them to set a time zone.
  1901. if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
  1902. 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')))));
  1903. }
  1904. }
  1905. /**
  1906. * Add the time zone field to the user edit and register forms.
  1907. */
  1908. function system_user_timezone(&$form, &$form_state) {
  1909. global $user;
  1910. $account = $form['#user'];
  1911. $form['timezone'] = array(
  1912. '#type' => 'fieldset',
  1913. '#title' => t('Locale settings'),
  1914. '#weight' => 6,
  1915. '#collapsible' => TRUE,
  1916. );
  1917. $form['timezone']['timezone'] = array(
  1918. '#type' => 'select',
  1919. '#title' => t('Time zone'),
  1920. '#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? variable_get('date_default_timezone', '') : ''),
  1921. '#options' => system_time_zones($account->uid != $user->uid),
  1922. '#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'),
  1923. );
  1924. if (!isset($account->timezone) && $account->uid == $user->uid && empty($form_state['input']['timezone'])) {
  1925. $form['timezone']['#description'] = t('Your time zone setting will be automatically detected if possible. Confirm the selection and click save.');
  1926. $form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect'));
  1927. drupal_add_js('misc/timezone.js');
  1928. }
  1929. }
  1930. /**
  1931. * Implements hook_block_info().
  1932. */
  1933. function system_block_info() {
  1934. $blocks['main'] = array(
  1935. 'info' => t('Main page content'),
  1936. // Cached elsewhere.
  1937. 'cache' => DRUPAL_NO_CACHE,
  1938. // Auto-enable in 'content' region by default, which always exists.
  1939. // @see system_themes_page(), drupal_render_page()
  1940. 'status' => 1,
  1941. 'region' => 'content',
  1942. );
  1943. $blocks['powered-by'] = array(
  1944. 'info' => t('Powered by Drupal'),
  1945. 'weight' => '10',
  1946. 'cache' => DRUPAL_NO_CACHE,
  1947. );
  1948. $blocks['help'] = array(
  1949. 'info' => t('System help'),
  1950. 'weight' => '5',
  1951. 'cache' => DRUPAL_NO_CACHE,
  1952. // Auto-enable in 'help' region by default, if the theme defines one.
  1953. 'status' => 1,
  1954. 'region' => 'help',
  1955. );
  1956. // System-defined menu blocks.
  1957. foreach (menu_list_system_menus() as $menu_name => $title) {
  1958. $blocks[$menu_name]['info'] = t($title);
  1959. // Menu blocks can't be cached because each menu item can have
  1960. // a custom access callback. menu.inc manages its own caching.
  1961. $blocks[$menu_name]['cache'] = DRUPAL_NO_CACHE;
  1962. }
  1963. return $blocks;
  1964. }
  1965. /**
  1966. * Implements hook_block_view().
  1967. *
  1968. * Generate a block with a promotional link to Drupal.org and
  1969. * all system menu blocks.
  1970. */
  1971. function system_block_view($delta = '') {
  1972. $block = array();
  1973. switch ($delta) {
  1974. case 'main':
  1975. $block['subject'] = NULL;
  1976. $block['content'] = drupal_set_page_content();
  1977. return $block;
  1978. case 'powered-by':
  1979. $block['subject'] = NULL;
  1980. $block['content'] = theme('system_powered_by');
  1981. return $block;
  1982. case 'help':
  1983. $block['subject'] = NULL;
  1984. $block['content'] = menu_get_active_help();
  1985. return $block;
  1986. default:
  1987. // All system menu blocks.
  1988. $system_menus = menu_list_system_menus();
  1989. if (isset($system_menus[$delta])) {
  1990. $block['subject'] = t($system_menus[$delta]);
  1991. $block['content'] = menu_tree($delta);
  1992. return $block;
  1993. }
  1994. break;
  1995. }
  1996. }
  1997. /**
  1998. * Implements hook_preprocess_block().
  1999. */
  2000. function system_preprocess_block(&$variables) {
  2001. // System menu blocks should get the same class as menu module blocks.
  2002. if ($variables['block']->module == 'system' && in_array($variables['block']->delta, array_keys(menu_list_system_menus()))) {
  2003. $variables['classes_array'][] = 'block-menu';
  2004. }
  2005. }
  2006. /**
  2007. * Provide a single block on the administration overview page.
  2008. *
  2009. * @param $item
  2010. * The menu item to be displayed.
  2011. */
  2012. function system_admin_menu_block($item) {
  2013. $cache = &drupal_static(__FUNCTION__, array());
  2014. // If we are calling this function for a menu item that corresponds to a
  2015. // local task (for example, admin/tasks), then we want to retrieve the
  2016. // parent item's child links, not this item's (since this item won't have
  2017. // any).
  2018. if ($item['tab_root'] != $item['path']) {
  2019. $item = menu_get_item($item['tab_root_href']);
  2020. }
  2021. if (!isset($item['mlid'])) {
  2022. $item += db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = :path AND module = 'system'", array(':path' => $item['path']))->fetchAssoc();
  2023. }
  2024. if (isset($cache[$item['mlid']])) {
  2025. return $cache[$item['mlid']];
  2026. }
  2027. $content = array();
  2028. $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
  2029. $query->join('menu_router', 'm', 'm.path = ml.router_path');
  2030. $query
  2031. ->fields('ml')
  2032. // Weight should be taken from {menu_links}, not {menu_router}.
  2033. ->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')))
  2034. ->condition('ml.plid', $item['mlid'])
  2035. ->condition('ml.menu_name', $item['menu_name'])
  2036. ->condition('ml.hidden', 0);
  2037. foreach ($query->execute() as $link) {
  2038. _menu_link_translate($link);
  2039. if ($link['access']) {
  2040. // The link description, either derived from 'description' in
  2041. // hook_menu() or customized via menu module is used as title attribute.
  2042. if (!empty($link['localized_options']['attributes']['title'])) {
  2043. $link['description'] = $link['localized_options']['attributes']['title'];
  2044. unset($link['localized_options']['attributes']['title']);
  2045. }
  2046. // Prepare for sorting as in function _menu_tree_check_access().
  2047. // The weight is offset so it is always positive, with a uniform 5-digits.
  2048. $key = (50000 + $link['weight']) . ' ' . drupal_strtolower($link['title']) . ' ' . $link['mlid'];
  2049. $content[$key] = $link;
  2050. }
  2051. }
  2052. ksort($content);
  2053. $cache[$item['mlid']] = $content;
  2054. return $content;
  2055. }
  2056. /**
  2057. * Checks the existence of the directory specified in $form_element.
  2058. *
  2059. * This function is called from the system_settings form to check all core
  2060. * file directories (file_public_path, file_private_path, file_temporary_path).
  2061. *
  2062. * @param $form_element
  2063. * The form element containing the name of the directory to check.
  2064. */
  2065. function system_check_directory($form_element) {
  2066. $directory = $form_element['#value'];
  2067. if (strlen($directory) == 0) {
  2068. return $form_element;
  2069. }
  2070. if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) {
  2071. // If the directory does not exists and cannot be created.
  2072. form_set_error($form_element['#parents'][0], t('The directory %directory does not exist and could not be created.', array('%directory' => $directory)));
  2073. watchdog('file system', 'The directory %directory does not exist and could not be created.', array('%directory' => $directory), WATCHDOG_ERROR);
  2074. }
  2075. if (is_dir($directory) && !is_writable($directory) && !drupal_chmod($directory)) {
  2076. // If the directory is not writable and cannot be made so.
  2077. 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)));
  2078. watchdog('file system', 'The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory), WATCHDOG_ERROR);
  2079. }
  2080. elseif (is_dir($directory)) {
  2081. if ($form_element['#name'] == 'file_public_path') {
  2082. // Create public .htaccess file.
  2083. file_create_htaccess($directory, FALSE);
  2084. }
  2085. else {
  2086. // Create private .htaccess file.
  2087. file_create_htaccess($directory);
  2088. }
  2089. }
  2090. return $form_element;
  2091. }
  2092. /**
  2093. * Retrieves the current status of an array of files in the system table.
  2094. *
  2095. * @param $files
  2096. * An array of files to check.
  2097. * @param $type
  2098. * The type of the files.
  2099. */
  2100. function system_get_files_database(&$files, $type) {
  2101. // Extract current files from database.
  2102. $result = db_query("SELECT filename, name, type, status, schema_version, weight FROM {system} WHERE type = :type", array(':type' => $type));
  2103. foreach ($result as $file) {
  2104. if (isset($files[$file->name]) && is_object($files[$file->name])) {
  2105. $file->uri = $file->filename;
  2106. foreach ($file as $key => $value) {
  2107. if (!isset($files[$file->name]->$key)) {
  2108. $files[$file->name]->$key = $value;
  2109. }
  2110. }
  2111. }
  2112. }
  2113. }
  2114. /**
  2115. * Updates the records in the system table based on the files array.
  2116. *
  2117. * @param $files
  2118. * An array of files.
  2119. * @param $type
  2120. * The type of the files.
  2121. */
  2122. function system_update_files_database(&$files, $type) {
  2123. $result = db_query("SELECT * FROM {system} WHERE type = :type", array(':type' => $type));
  2124. // Add all files that need to be deleted to a DatabaseCondition.
  2125. $delete = db_or();
  2126. foreach ($result as $file) {
  2127. if (isset($files[$file->name]) && is_object($files[$file->name])) {
  2128. // Keep the old filename from the database in case the file has moved.
  2129. $old_filename = $file->filename;
  2130. $updated_fields = array();
  2131. // Handle info specially, compare the serialized value.
  2132. $serialized_info = serialize($files[$file->name]->info);
  2133. if ($serialized_info != $file->info) {
  2134. $updated_fields['info'] = $serialized_info;
  2135. }
  2136. unset($file->info);
  2137. // Scan remaining fields to find only the updated values.
  2138. foreach ($file as $key => $value) {
  2139. if (isset($files[$file->name]->$key) && $files[$file->name]->$key != $value) {
  2140. $updated_fields[$key] = $files[$file->name]->$key;
  2141. }
  2142. }
  2143. // Update the record.
  2144. if (count($updated_fields)) {
  2145. db_update('system')
  2146. ->fields($updated_fields)
  2147. ->condition('filename', $old_filename)
  2148. ->execute();
  2149. }
  2150. // Indicate that the file exists already.
  2151. $files[$file->name]->exists = TRUE;
  2152. }
  2153. else {
  2154. // File is not found in file system, so delete record from the system table.
  2155. $delete->condition('filename', $file->filename);
  2156. }
  2157. }
  2158. if (count($delete) > 0) {
  2159. // Delete all missing files from the system table, but only if the plugin
  2160. // has never been installed.
  2161. db_delete('system')
  2162. ->condition($delete)
  2163. ->condition('schema_version', -1)
  2164. ->execute();
  2165. }
  2166. // All remaining files are not in the system table, so we need to add them.
  2167. $query = db_insert('system')->fields(array('filename', 'name', 'type', 'owner', 'info'));
  2168. foreach ($files as &$file) {
  2169. if (isset($file->exists)) {
  2170. unset($file->exists);
  2171. }
  2172. else {
  2173. $query->values(array(
  2174. 'filename' => $file->uri,
  2175. 'name' => $file->name,
  2176. 'type' => $type,
  2177. 'owner' => isset($file->owner) ? $file->owner : '',
  2178. 'info' => serialize($file->info),
  2179. ));
  2180. $file->type = $type;
  2181. $file->status = 0;
  2182. $file->schema_version = -1;
  2183. }
  2184. }
  2185. $query->execute();
  2186. // If any module or theme was moved to a new location, we need to reset the
  2187. // system_list() cache or we will continue to load the old copy, look for
  2188. // schema updates in the wrong place, etc.
  2189. system_list_reset();
  2190. }
  2191. /**
  2192. * Returns an array of information about enabled modules or themes.
  2193. *
  2194. * This function returns the information from the {system} table corresponding
  2195. * to the cached contents of the .info file for each active module or theme.
  2196. *
  2197. * @param $type
  2198. * Either 'module' or 'theme'.
  2199. * @param $name
  2200. * (optional) The name of a module or theme whose information shall be
  2201. * returned. If omitted, all records for the provided $type will be returned.
  2202. * If $name does not exist in the provided $type or is not enabled, an empty
  2203. * array will be returned.
  2204. *
  2205. * @return
  2206. * An associative array of module or theme information keyed by name, or only
  2207. * information for $name, if given. If no records are available, an empty
  2208. * array is returned.
  2209. *
  2210. * @see system_rebuild_module_data()
  2211. * @see system_rebuild_theme_data()
  2212. */
  2213. function system_get_info($type, $name = NULL) {
  2214. $info = array();
  2215. if ($type == 'module') {
  2216. $type = 'module_enabled';
  2217. }
  2218. $list = system_list($type);
  2219. foreach ($list as $shortname => $item) {
  2220. if (!empty($item->status)) {
  2221. $info[$shortname] = $item->info;
  2222. }
  2223. }
  2224. if (isset($name)) {
  2225. return isset($info[$name]) ? $info[$name] : array();
  2226. }
  2227. return $info;
  2228. }
  2229. /**
  2230. * Helper function to scan and collect module .info data.
  2231. *
  2232. * @return
  2233. * An associative array of module information.
  2234. */
  2235. function _system_rebuild_module_data() {
  2236. // Find modules
  2237. $modules = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0);
  2238. // Include the install profile in modules that are loaded.
  2239. $profile = drupal_get_profile();
  2240. $modules[$profile] = new stdClass();
  2241. $modules[$profile]->name = $profile;
  2242. $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile';
  2243. $modules[$profile]->filename = $profile . '.profile';
  2244. // Install profile hooks are always executed last.
  2245. $modules[$profile]->weight = 1000;
  2246. // Set defaults for module info.
  2247. $defaults = array(
  2248. 'dependencies' => array(),
  2249. 'description' => '',
  2250. 'package' => 'Other',
  2251. 'version' => NULL,
  2252. 'php' => DRUPAL_MINIMUM_PHP,
  2253. 'files' => array(),
  2254. 'bootstrap' => 0,
  2255. );
  2256. // Read info files for each module.
  2257. foreach ($modules as $key => $module) {
  2258. // The module system uses the key 'filename' instead of 'uri' so copy the
  2259. // value so it will be used by the modules system.
  2260. $modules[$key]->filename = $module->uri;
  2261. // Look for the info file.
  2262. $module->info = drupal_parse_info_file(dirname($module->uri) . '/' . $module->name . '.info');
  2263. // Skip modules that don't provide info.
  2264. if (empty($module->info)) {
  2265. unset($modules[$key]);
  2266. continue;
  2267. }
  2268. // Merge in defaults and save.
  2269. $modules[$key]->info = $module->info + $defaults;
  2270. // Prefix stylesheets and scripts with module path.
  2271. $path = dirname($module->uri);
  2272. if (isset($module->info['stylesheets'])) {
  2273. $module->info['stylesheets'] = _system_info_add_path($module->info['stylesheets'], $path);
  2274. }
  2275. if (isset($module->info['scripts'])) {
  2276. $module->info['scripts'] = _system_info_add_path($module->info['scripts'], $path);
  2277. }
  2278. // Install profiles are hidden by default, unless explicitly specified
  2279. // otherwise in the .info file.
  2280. if ($key == $profile && !isset($modules[$key]->info['hidden'])) {
  2281. $modules[$key]->info['hidden'] = TRUE;
  2282. }
  2283. // Invoke hook_system_info_alter() to give installed modules a chance to
  2284. // modify the data in the .info files if necessary.
  2285. $type = 'module';
  2286. drupal_alter('system_info', $modules[$key]->info, $modules[$key], $type);
  2287. }
  2288. if (isset($modules[$profile])) {
  2289. // The install profile is required, if it's a valid module.
  2290. $modules[$profile]->info['required'] = TRUE;
  2291. // Add a default distribution name if the profile did not provide one. This
  2292. // matches the default value used in install_profile_info().
  2293. if (!isset($modules[$profile]->info['distribution_name'])) {
  2294. $modules[$profile]->info['distribution_name'] = 'Drupal';
  2295. }
  2296. }
  2297. return $modules;
  2298. }
  2299. /**
  2300. * Rebuild, save, and return data about all currently available modules.
  2301. *
  2302. * @return
  2303. * Array of all available modules and their data.
  2304. */
  2305. function system_rebuild_module_data() {
  2306. $modules_cache = &drupal_static(__FUNCTION__);
  2307. // Only rebuild once per request. $modules and $modules_cache cannot be
  2308. // combined into one variable, because the $modules_cache variable is reset by
  2309. // reference from system_list_reset() during the rebuild.
  2310. if (!isset($modules_cache)) {
  2311. $modules = _system_rebuild_module_data();
  2312. ksort($modules);
  2313. system_get_files_database($modules, 'module');
  2314. system_update_files_database($modules, 'module');
  2315. $modules = _module_build_dependencies($modules);
  2316. $modules_cache = $modules;
  2317. }
  2318. return $modules_cache;
  2319. }
  2320. /**
  2321. * Refresh bootstrap column in the system table.
  2322. *
  2323. * This is called internally by module_enable/disable() to flag modules that
  2324. * implement hooks used during bootstrap, such as hook_boot(). These modules
  2325. * are loaded earlier to invoke the hooks.
  2326. */
  2327. function _system_update_bootstrap_status() {
  2328. $bootstrap_modules = array();
  2329. foreach (bootstrap_hooks() as $hook) {
  2330. foreach (module_implements($hook) as $module) {
  2331. $bootstrap_modules[] = $module;
  2332. }
  2333. }
  2334. $query = db_update('system')->fields(array('bootstrap' => 0));
  2335. if ($bootstrap_modules) {
  2336. db_update('system')
  2337. ->fields(array('bootstrap' => 1))
  2338. ->condition('name', $bootstrap_modules, 'IN')
  2339. ->execute();
  2340. $query->condition('name', $bootstrap_modules, 'NOT IN');
  2341. }
  2342. $query->execute();
  2343. // Reset the cached list of bootstrap modules.
  2344. system_list_reset();
  2345. }
  2346. /**
  2347. * Helper function to scan and collect theme .info data and their engines.
  2348. *
  2349. * @return
  2350. * An associative array of themes information.
  2351. */
  2352. function _system_rebuild_theme_data() {
  2353. // Find themes
  2354. $themes = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info$/', 'themes');
  2355. // Allow modules to add further themes.
  2356. if ($module_themes = module_invoke_all('system_theme_info')) {
  2357. foreach ($module_themes as $name => $uri) {
  2358. // @see file_scan_directory()
  2359. $themes[$name] = (object) array(
  2360. 'uri' => $uri,
  2361. 'filename' => pathinfo($uri, PATHINFO_FILENAME),
  2362. 'name' => $name,
  2363. );
  2364. }
  2365. }
  2366. // Find theme engines
  2367. $engines = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.engine$/', 'themes/engines');
  2368. // Set defaults for theme info.
  2369. $defaults = array(
  2370. 'engine' => 'phptemplate',
  2371. 'regions' => array(
  2372. 'sidebar_first' => 'Left sidebar',
  2373. 'sidebar_second' => 'Right sidebar',
  2374. 'content' => 'Content',
  2375. 'header' => 'Header',
  2376. 'footer' => 'Footer',
  2377. 'highlighted' => 'Highlighted',
  2378. 'help' => 'Help',
  2379. 'page_top' => 'Page top',
  2380. 'page_bottom' => 'Page bottom',
  2381. ),
  2382. 'description' => '',
  2383. 'features' => _system_default_theme_features(),
  2384. 'screenshot' => 'screenshot.png',
  2385. 'php' => DRUPAL_MINIMUM_PHP,
  2386. 'stylesheets' => array(),
  2387. 'scripts' => array(),
  2388. );
  2389. $sub_themes = array();
  2390. // Read info files for each theme
  2391. foreach ($themes as $key => $theme) {
  2392. $themes[$key]->filename = $theme->uri;
  2393. $themes[$key]->info = drupal_parse_info_file($theme->uri) + $defaults;
  2394. // Invoke hook_system_info_alter() to give installed modules a chance to
  2395. // modify the data in the .info files if necessary.
  2396. $type = 'theme';
  2397. drupal_alter('system_info', $themes[$key]->info, $themes[$key], $type);
  2398. if (!empty($themes[$key]->info['base theme'])) {
  2399. $sub_themes[] = $key;
  2400. }
  2401. if ($themes[$key]->info['engine'] == 'theme') {
  2402. $filename = dirname($themes[$key]->uri) . '/' . $themes[$key]->name . '.theme';
  2403. if (file_exists($filename)) {
  2404. $themes[$key]->owner = $filename;
  2405. $themes[$key]->prefix = $key;
  2406. }
  2407. }
  2408. else {
  2409. $engine = $themes[$key]->info['engine'];
  2410. if (isset($engines[$engine])) {
  2411. $themes[$key]->owner = $engines[$engine]->uri;
  2412. $themes[$key]->prefix = $engines[$engine]->name;
  2413. $themes[$key]->template = TRUE;
  2414. }
  2415. }
  2416. // Prefix stylesheets and scripts with module path.
  2417. $path = dirname($theme->uri);
  2418. $theme->info['stylesheets'] = _system_info_add_path($theme->info['stylesheets'], $path);
  2419. $theme->info['scripts'] = _system_info_add_path($theme->info['scripts'], $path);
  2420. // Give the screenshot proper path information.
  2421. if (!empty($themes[$key]->info['screenshot'])) {
  2422. $themes[$key]->info['screenshot'] = $path . '/' . $themes[$key]->info['screenshot'];
  2423. }
  2424. }
  2425. // Now that we've established all our master themes, go back and fill in data
  2426. // for subthemes.
  2427. foreach ($sub_themes as $key) {
  2428. $themes[$key]->base_themes = drupal_find_base_themes($themes, $key);
  2429. // Don't proceed if there was a problem with the root base theme.
  2430. if (!current($themes[$key]->base_themes)) {
  2431. continue;
  2432. }
  2433. $base_key = key($themes[$key]->base_themes);
  2434. foreach (array_keys($themes[$key]->base_themes) as $base_theme) {
  2435. $themes[$base_theme]->sub_themes[$key] = $themes[$key]->info['name'];
  2436. }
  2437. // Copy the 'owner' and 'engine' over if the top level theme uses a theme
  2438. // engine.
  2439. if (isset($themes[$base_key]->owner)) {
  2440. if (isset($themes[$base_key]->info['engine'])) {
  2441. $themes[$key]->info['engine'] = $themes[$base_key]->info['engine'];
  2442. $themes[$key]->owner = $themes[$base_key]->owner;
  2443. $themes[$key]->prefix = $themes[$base_key]->prefix;
  2444. }
  2445. else {
  2446. $themes[$key]->prefix = $key;
  2447. }
  2448. }
  2449. }
  2450. return $themes;
  2451. }
  2452. /**
  2453. * Rebuild, save, and return data about all currently available themes.
  2454. *
  2455. * @return
  2456. * Array of all available themes and their data.
  2457. */
  2458. function system_rebuild_theme_data() {
  2459. $themes = _system_rebuild_theme_data();
  2460. ksort($themes);
  2461. system_get_files_database($themes, 'theme');
  2462. system_update_files_database($themes, 'theme');
  2463. return $themes;
  2464. }
  2465. /**
  2466. * Prefixes all values in an .info file array with a given path.
  2467. *
  2468. * This helper function is mainly used to prefix all array values of an .info
  2469. * file property with a single given path (to the module or theme); e.g., to
  2470. * prefix all values of the 'stylesheets' or 'scripts' properties with the file
  2471. * path to the defining module/theme.
  2472. *
  2473. * @param $info
  2474. * A nested array of data of an .info file to be processed.
  2475. * @param $path
  2476. * A file path to prepend to each value in $info.
  2477. *
  2478. * @return
  2479. * The $info array with prefixed values.
  2480. *
  2481. * @see _system_rebuild_module_data()
  2482. * @see _system_rebuild_theme_data()
  2483. */
  2484. function _system_info_add_path($info, $path) {
  2485. foreach ($info as $key => $value) {
  2486. // Recurse into nested values until we reach the deepest level.
  2487. if (is_array($value)) {
  2488. $info[$key] = _system_info_add_path($info[$key], $path);
  2489. }
  2490. // Unset the original value's key and set the new value with prefix, using
  2491. // the original value as key, so original values can still be looked up.
  2492. else {
  2493. unset($info[$key]);
  2494. $info[$value] = $path . '/' . $value;
  2495. }
  2496. }
  2497. return $info;
  2498. }
  2499. /**
  2500. * Returns an array of default theme features.
  2501. */
  2502. function _system_default_theme_features() {
  2503. return array(
  2504. 'logo',
  2505. 'favicon',
  2506. 'name',
  2507. 'slogan',
  2508. 'node_user_picture',
  2509. 'comment_user_picture',
  2510. 'comment_user_verification',
  2511. 'main_menu',
  2512. 'secondary_menu',
  2513. );
  2514. }
  2515. /**
  2516. * Find all the base themes for the specified theme.
  2517. *
  2518. * This function has been deprecated in favor of drupal_find_base_themes().
  2519. */
  2520. function system_find_base_themes($themes, $key, $used_keys = array()) {
  2521. return drupal_find_base_themes($themes, $key, $used_keys);
  2522. }
  2523. /**
  2524. * Get a list of available regions from a specified theme.
  2525. *
  2526. * @param $theme_key
  2527. * The name of a theme.
  2528. * @param $show
  2529. * Possible values: REGIONS_ALL or REGIONS_VISIBLE. Visible excludes hidden
  2530. * regions.
  2531. * @return
  2532. * An array of regions in the form $region['name'] = 'description'.
  2533. */
  2534. function system_region_list($theme_key, $show = REGIONS_ALL) {
  2535. $themes = list_themes();
  2536. if (!isset($themes[$theme_key])) {
  2537. return array();
  2538. }
  2539. $list = array();
  2540. $info = $themes[$theme_key]->info;
  2541. // If requested, suppress hidden regions. See block_admin_display_form().
  2542. foreach ($info['regions'] as $name => $label) {
  2543. if ($show == REGIONS_ALL || !isset($info['regions_hidden']) || !in_array($name, $info['regions_hidden'])) {
  2544. $list[$name] = t($label);
  2545. }
  2546. }
  2547. return $list;
  2548. }
  2549. /**
  2550. * Implements hook_system_info_alter().
  2551. */
  2552. function system_system_info_alter(&$info, $file, $type) {
  2553. // Remove page-top and page-bottom from the blocks UI since they are reserved for
  2554. // modules to populate from outside the blocks system.
  2555. if ($type == 'theme') {
  2556. $info['regions_hidden'][] = 'page_top';
  2557. $info['regions_hidden'][] = 'page_bottom';
  2558. }
  2559. }
  2560. /**
  2561. * Get the name of the default region for a given theme.
  2562. *
  2563. * @param $theme
  2564. * The name of a theme.
  2565. * @return
  2566. * A string that is the region name.
  2567. */
  2568. function system_default_region($theme) {
  2569. $regions = array_keys(system_region_list($theme, REGIONS_VISIBLE));
  2570. return isset($regions[0]) ? $regions[0] : '';
  2571. }
  2572. /**
  2573. * Add default buttons to a form and set its prefix.
  2574. *
  2575. * @param $form
  2576. * An associative array containing the structure of the form.
  2577. *
  2578. * @return
  2579. * The form structure.
  2580. *
  2581. * @see system_settings_form_submit()
  2582. * @ingroup forms
  2583. */
  2584. function system_settings_form($form) {
  2585. $form['actions']['#type'] = 'actions';
  2586. $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
  2587. if (!empty($_POST) && form_get_errors()) {
  2588. drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
  2589. }
  2590. $form['#submit'][] = 'system_settings_form_submit';
  2591. // By default, render the form using theme_system_settings_form().
  2592. if (!isset($form['#theme'])) {
  2593. $form['#theme'] = 'system_settings_form';
  2594. }
  2595. return $form;
  2596. }
  2597. /**
  2598. * Execute the system_settings_form.
  2599. *
  2600. * If you want node type configure style handling of your checkboxes,
  2601. * add an array_filter value to your form.
  2602. */
  2603. function system_settings_form_submit($form, &$form_state) {
  2604. // Exclude unnecessary elements.
  2605. form_state_values_clean($form_state);
  2606. foreach ($form_state['values'] as $key => $value) {
  2607. if (is_array($value) && isset($form_state['values']['array_filter'])) {
  2608. $value = array_keys(array_filter($value));
  2609. }
  2610. variable_set($key, $value);
  2611. }
  2612. drupal_set_message(t('The configuration options have been saved.'));
  2613. }
  2614. /**
  2615. * Helper function to sort requirements.
  2616. */
  2617. function _system_sort_requirements($a, $b) {
  2618. if (!isset($a['weight'])) {
  2619. if (!isset($b['weight'])) {
  2620. return strcmp($a['title'], $b['title']);
  2621. }
  2622. return -$b['weight'];
  2623. }
  2624. return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
  2625. }
  2626. /**
  2627. * Generates a form array for a confirmation form.
  2628. *
  2629. * This function returns a complete form array for confirming an action. The
  2630. * form contains a confirm button as well as a cancellation link that allows a
  2631. * user to abort the action.
  2632. *
  2633. * If the submit handler for a form that implements confirm_form() is invoked,
  2634. * the user successfully confirmed the action. You should never directly
  2635. * inspect $_POST to see if an action was confirmed.
  2636. *
  2637. * Note - if the parameters $question, $description, $yes, or $no could contain
  2638. * any user input (such as node titles or taxonomy terms), it is the
  2639. * responsibility of the code calling confirm_form() to sanitize them first with
  2640. * a function like check_plain() or filter_xss().
  2641. *
  2642. * @param $form
  2643. * Additional elements to add to the form. These can be regular form elements,
  2644. * #value elements, etc., and their values will be available to the submit
  2645. * handler.
  2646. * @param $question
  2647. * The question to ask the user (e.g. "Are you sure you want to delete the
  2648. * block <em>foo</em>?"). The page title will be set to this value.
  2649. * @param $path
  2650. * The page to go to if the user cancels the action. This can be either:
  2651. * - A string containing a Drupal path.
  2652. * - An associative array with a 'path' key. Additional array values are
  2653. * passed as the $options parameter to l().
  2654. * If the 'destination' query parameter is set in the URL when viewing a
  2655. * confirmation form, that value will be used instead of $path.
  2656. * @param $description
  2657. * Additional text to display. Defaults to t('This action cannot be undone.').
  2658. * @param $yes
  2659. * A caption for the button that confirms the action (e.g. "Delete",
  2660. * "Replace", ...). Defaults to t('Confirm').
  2661. * @param $no
  2662. * A caption for the link which cancels the action (e.g. "Cancel"). Defaults
  2663. * to t('Cancel').
  2664. * @param $name
  2665. * The internal name used to refer to the confirmation item.
  2666. *
  2667. * @return
  2668. * The form array.
  2669. */
  2670. function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
  2671. $description = isset($description) ? $description : t('This action cannot be undone.');
  2672. // Prepare cancel link.
  2673. if (isset($_GET['destination'])) {
  2674. $options = drupal_parse_url(urldecode($_GET['destination']));
  2675. }
  2676. elseif (is_array($path)) {
  2677. $options = $path;
  2678. }
  2679. else {
  2680. $options = array('path' => $path);
  2681. }
  2682. drupal_set_title($question, PASS_THROUGH);
  2683. $form['#attributes']['class'][] = 'confirmation';
  2684. $form['description'] = array('#markup' => $description);
  2685. $form[$name] = array('#type' => 'hidden', '#value' => 1);
  2686. $form['actions'] = array('#type' => 'actions');
  2687. $form['actions']['submit'] = array(
  2688. '#type' => 'submit',
  2689. '#value' => $yes ? $yes : t('Confirm'),
  2690. );
  2691. $form['actions']['cancel'] = array(
  2692. '#type' => 'link',
  2693. '#title' => $no ? $no : t('Cancel'),
  2694. '#href' => $options['path'],
  2695. '#options' => $options,
  2696. );
  2697. // By default, render the form using theme_confirm_form().
  2698. if (!isset($form['#theme'])) {
  2699. $form['#theme'] = 'confirm_form';
  2700. }
  2701. return $form;
  2702. }
  2703. /**
  2704. * Determines whether the current user is in compact mode.
  2705. *
  2706. * Compact mode shows certain administration pages with less description text,
  2707. * such as the configuration page and the permissions page.
  2708. *
  2709. * Whether the user is in compact mode is determined by a cookie, which is set
  2710. * for the user by system_admin_compact_page().
  2711. *
  2712. * If the user does not have the cookie, the default value is given by the
  2713. * system variable 'admin_compact_mode', which itself defaults to FALSE. This
  2714. * does not have a user interface to set it: it is a hidden variable which can
  2715. * be set in the settings.php file.
  2716. *
  2717. * @return
  2718. * TRUE when in compact mode, FALSE when in expanded mode.
  2719. */
  2720. function system_admin_compact_mode() {
  2721. // PHP converts dots into underscores in cookie names to avoid problems with
  2722. // its parser, so we use a converted cookie name.
  2723. return isset($_COOKIE['Drupal_visitor_admin_compact_mode']) ? $_COOKIE['Drupal_visitor_admin_compact_mode'] : variable_get('admin_compact_mode', FALSE);
  2724. }
  2725. /**
  2726. * Menu callback; Sets whether the admin menu is in compact mode or not.
  2727. *
  2728. * @param $mode
  2729. * Valid values are 'on' and 'off'.
  2730. */
  2731. function system_admin_compact_page($mode = 'off') {
  2732. user_cookie_save(array('admin_compact_mode' => ($mode == 'on')));
  2733. drupal_goto();
  2734. }
  2735. /**
  2736. * Generate a list of tasks offered by a specified module.
  2737. *
  2738. * @param $module
  2739. * Module name.
  2740. * @param $info
  2741. * The module's information, as provided by system_get_info().
  2742. *
  2743. * @return
  2744. * An array of task links.
  2745. */
  2746. function system_get_module_admin_tasks($module, $info) {
  2747. $links = &drupal_static(__FUNCTION__);
  2748. if (!isset($links)) {
  2749. $links = array();
  2750. $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
  2751. $query->join('menu_router', 'm', 'm.path = ml.router_path');
  2752. $query
  2753. ->fields('ml')
  2754. // Weight should be taken from {menu_links}, not {menu_router}.
  2755. ->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')))
  2756. ->condition('ml.link_path', 'admin/%', 'LIKE')
  2757. ->condition('ml.hidden', 0, '>=')
  2758. ->condition('ml.module', 'system')
  2759. ->condition('m.number_parts', 1, '>')
  2760. ->condition('m.page_callback', 'system_admin_menu_block_page', '<>');
  2761. foreach ($query->execute() as $link) {
  2762. _menu_link_translate($link);
  2763. if ($link['access']) {
  2764. $links[$link['router_path']] = $link;
  2765. }
  2766. }
  2767. }
  2768. $admin_tasks = array();
  2769. $titles = array();
  2770. if ($menu = module_invoke($module, 'menu')) {
  2771. foreach ($menu as $path => $item) {
  2772. if (isset($links[$path])) {
  2773. $task = $links[$path];
  2774. // The link description, either derived from 'description' in
  2775. // hook_menu() or customized via menu module is used as title attribute.
  2776. if (!empty($task['localized_options']['attributes']['title'])) {
  2777. $task['description'] = $task['localized_options']['attributes']['title'];
  2778. unset($task['localized_options']['attributes']['title']);
  2779. }
  2780. // Check the admin tasks for duplicate names. If one is found,
  2781. // append the parent menu item's title to differentiate.
  2782. $duplicate_path = array_search($task['title'], $titles);
  2783. if ($duplicate_path !== FALSE) {
  2784. if ($parent = menu_link_load($task['plid'])) {
  2785. // Append the parent item's title to this task's title.
  2786. $task['title'] = t('@original_title (@parent_title)', array('@original_title' => $task['title'], '@parent_title' => $parent['title']));
  2787. }
  2788. if ($parent = menu_link_load($admin_tasks[$duplicate_path]['plid'])) {
  2789. // Append the parent item's title to the duplicated task's title.
  2790. // We use $links[$duplicate_path] in case there are triplicates.
  2791. $admin_tasks[$duplicate_path]['title'] = t('@original_title (@parent_title)', array('@original_title' => $links[$duplicate_path]['title'], '@parent_title' => $parent['title']));
  2792. }
  2793. }
  2794. else {
  2795. $titles[$path] = $task['title'];
  2796. }
  2797. $admin_tasks[$path] = $task;
  2798. }
  2799. }
  2800. }
  2801. // Append link for permissions.
  2802. if (module_hook($module, 'permission')) {
  2803. $item = menu_get_item('admin/people/permissions');
  2804. if (!empty($item['access'])) {
  2805. $item['link_path'] = $item['href'];
  2806. $item['title'] = t('Configure @module permissions', array('@module' => $info['name']));
  2807. unset($item['description']);
  2808. $item['localized_options']['fragment'] = 'module-' . $module;
  2809. $admin_tasks["admin/people/permissions#module-$module"] = $item;
  2810. }
  2811. }
  2812. return $admin_tasks;
  2813. }
  2814. /**
  2815. * Implements hook_cron().
  2816. *
  2817. * Remove older rows from flood and batch table. Remove old temporary files.
  2818. */
  2819. function system_cron() {
  2820. // Cleanup the flood.
  2821. db_delete('flood')
  2822. ->condition('expiration', REQUEST_TIME, '<')
  2823. ->execute();
  2824. // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
  2825. // Use separate placeholders for the status to avoid a bug in some versions
  2826. // of PHP. See http://drupal.org/node/352956.
  2827. $result = db_query('SELECT fid FROM {file_managed} WHERE status <> :permanent AND timestamp < :timestamp', array(
  2828. ':permanent' => FILE_STATUS_PERMANENT,
  2829. ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE
  2830. ));
  2831. foreach ($result as $row) {
  2832. if ($file = file_load($row->fid)) {
  2833. $references = file_usage_list($file);
  2834. if (empty($references)) {
  2835. if (!file_delete($file)) {
  2836. watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->uri), WATCHDOG_ERROR);
  2837. }
  2838. }
  2839. else {
  2840. 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);
  2841. }
  2842. }
  2843. }
  2844. $core = array('cache', 'cache_path', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu');
  2845. $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
  2846. foreach ($cache_tables as $table) {
  2847. cache_clear_all(NULL, $table);
  2848. }
  2849. // Cleanup the batch table and the queue for failed batches.
  2850. db_delete('batch')
  2851. ->condition('timestamp', REQUEST_TIME - 864000, '<')
  2852. ->execute();
  2853. db_delete('queue')
  2854. ->condition('created', REQUEST_TIME - 864000, '<')
  2855. ->condition('name', 'drupal_batch:%', 'LIKE')
  2856. ->execute();
  2857. // Reset expired items in the default queue implementation table. If that's
  2858. // not used, this will simply be a no-op.
  2859. db_update('queue')
  2860. ->fields(array(
  2861. 'expire' => 0,
  2862. ))
  2863. ->condition('expire', 0, '<>')
  2864. ->condition('expire', REQUEST_TIME, '<')
  2865. ->execute();
  2866. }
  2867. /**
  2868. * Implements hook_flush_caches().
  2869. */
  2870. function system_flush_caches() {
  2871. // Rebuild list of date formats.
  2872. system_date_formats_rebuild();
  2873. // Reset the menu static caches.
  2874. menu_reset_static_cache();
  2875. }
  2876. /**
  2877. * Implements hook_action_info().
  2878. */
  2879. function system_action_info() {
  2880. return array(
  2881. 'system_message_action' => array(
  2882. 'type' => 'system',
  2883. 'label' => t('Display a message to the user'),
  2884. 'configurable' => TRUE,
  2885. 'triggers' => array('any'),
  2886. ),
  2887. 'system_send_email_action' => array(
  2888. 'type' => 'system',
  2889. 'label' => t('Send e-mail'),
  2890. 'configurable' => TRUE,
  2891. 'triggers' => array('any'),
  2892. ),
  2893. 'system_block_ip_action' => array(
  2894. 'type' => 'user',
  2895. 'label' => t('Ban IP address of current user'),
  2896. 'configurable' => FALSE,
  2897. 'triggers' => array('any'),
  2898. ),
  2899. 'system_goto_action' => array(
  2900. 'type' => 'system',
  2901. 'label' => t('Redirect to URL'),
  2902. 'configurable' => TRUE,
  2903. 'triggers' => array('any'),
  2904. ),
  2905. );
  2906. }
  2907. /**
  2908. * Return a form definition so the Send email action can be configured.
  2909. *
  2910. * @param $context
  2911. * Default values (if we are editing an existing action instance).
  2912. *
  2913. * @return
  2914. * Form definition.
  2915. *
  2916. * @see system_send_email_action_validate()
  2917. * @see system_send_email_action_submit()
  2918. */
  2919. function system_send_email_action_form($context) {
  2920. // Set default values for form.
  2921. if (!isset($context['recipient'])) {
  2922. $context['recipient'] = '';
  2923. }
  2924. if (!isset($context['subject'])) {
  2925. $context['subject'] = '';
  2926. }
  2927. if (!isset($context['message'])) {
  2928. $context['message'] = '';
  2929. }
  2930. $form['recipient'] = array(
  2931. '#type' => 'textfield',
  2932. '#title' => t('Recipient'),
  2933. '#default_value' => $context['recipient'],
  2934. '#maxlength' => '254',
  2935. '#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.'),
  2936. );
  2937. $form['subject'] = array(
  2938. '#type' => 'textfield',
  2939. '#title' => t('Subject'),
  2940. '#default_value' => $context['subject'],
  2941. '#maxlength' => '254',
  2942. '#description' => t('The subject of the message.'),
  2943. );
  2944. $form['message'] = array(
  2945. '#type' => 'textarea',
  2946. '#title' => t('Message'),
  2947. '#default_value' => $context['message'],
  2948. '#cols' => '80',
  2949. '#rows' => '20',
  2950. '#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.'),
  2951. );
  2952. return $form;
  2953. }
  2954. /**
  2955. * Validate system_send_email_action form submissions.
  2956. */
  2957. function system_send_email_action_validate($form, $form_state) {
  2958. $form_values = $form_state['values'];
  2959. // Validate the configuration form.
  2960. if (!valid_email_address($form_values['recipient']) && strpos($form_values['recipient'], ':mail') === FALSE) {
  2961. // We want the literal %author placeholder to be emphasized in the error message.
  2962. 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]')));
  2963. }
  2964. }
  2965. /**
  2966. * Process system_send_email_action form submissions.
  2967. */
  2968. function system_send_email_action_submit($form, $form_state) {
  2969. $form_values = $form_state['values'];
  2970. // Process the HTML form to store configuration. The keyed array that
  2971. // we return will be serialized to the database.
  2972. $params = array(
  2973. 'recipient' => $form_values['recipient'],
  2974. 'subject' => $form_values['subject'],
  2975. 'message' => $form_values['message'],
  2976. );
  2977. return $params;
  2978. }
  2979. /**
  2980. * Sends an e-mail message.
  2981. *
  2982. * @param object $entity
  2983. * An optional node object, which will be added as $context['node'] if
  2984. * provided.
  2985. * @param array $context
  2986. * Array with the following elements:
  2987. * - 'recipient': E-mail message recipient. This will be passed through
  2988. * token_replace().
  2989. * - 'subject': The subject of the message. This will be passed through
  2990. * token_replace().
  2991. * - 'message': The message to send. This will be passed through
  2992. * token_replace().
  2993. * - Other elements will be used as the data for token replacement.
  2994. *
  2995. * @ingroup actions
  2996. */
  2997. function system_send_email_action($entity, $context) {
  2998. if (empty($context['node'])) {
  2999. $context['node'] = $entity;
  3000. }
  3001. $recipient = token_replace($context['recipient'], $context);
  3002. // If the recipient is a registered user with a language preference, use
  3003. // the recipient's preferred language. Otherwise, use the system default
  3004. // language.
  3005. $recipient_account = user_load_by_mail($recipient);
  3006. if ($recipient_account) {
  3007. $language = user_preferred_language($recipient_account);
  3008. }
  3009. else {
  3010. $language = language_default();
  3011. }
  3012. $params = array('context' => $context);
  3013. if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) {
  3014. watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
  3015. }
  3016. else {
  3017. watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
  3018. }
  3019. }
  3020. /**
  3021. * Implements hook_mail().
  3022. */
  3023. function system_mail($key, &$message, $params) {
  3024. $context = $params['context'];
  3025. $subject = token_replace($context['subject'], $context);
  3026. $body = token_replace($context['message'], $context);
  3027. $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
  3028. $message['body'][] = $body;
  3029. }
  3030. function system_message_action_form($context) {
  3031. $form['message'] = array(
  3032. '#type' => 'textarea',
  3033. '#title' => t('Message'),
  3034. '#default_value' => isset($context['message']) ? $context['message'] : '',
  3035. '#required' => TRUE,
  3036. '#rows' => '8',
  3037. '#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.'),
  3038. );
  3039. return $form;
  3040. }
  3041. function system_message_action_submit($form, $form_state) {
  3042. return array('message' => $form_state['values']['message']);
  3043. }
  3044. /**
  3045. * Sends a message to the current user's screen.
  3046. *
  3047. * @param object $entity
  3048. * An optional node object, which will be added as $context['node'] if
  3049. * provided.
  3050. * @param array $context
  3051. * Array with the following elements:
  3052. * - 'message': The message to send. This will be passed through
  3053. * token_replace().
  3054. * - Other elements will be used as the data for token replacement in
  3055. * the message.
  3056. *
  3057. * @ingroup actions
  3058. */
  3059. function system_message_action(&$entity, $context = array()) {
  3060. if (empty($context['node'])) {
  3061. $context['node'] = $entity;
  3062. }
  3063. $context['message'] = token_replace(filter_xss_admin($context['message']), $context);
  3064. drupal_set_message($context['message']);
  3065. }
  3066. /**
  3067. * Settings form for system_goto_action().
  3068. */
  3069. function system_goto_action_form($context) {
  3070. $form['url'] = array(
  3071. '#type' => 'textfield',
  3072. '#title' => t('URL'),
  3073. '#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.'),
  3074. '#default_value' => isset($context['url']) ? $context['url'] : '',
  3075. '#required' => TRUE,
  3076. );
  3077. return $form;
  3078. }
  3079. function system_goto_action_submit($form, $form_state) {
  3080. return array(
  3081. 'url' => $form_state['values']['url']
  3082. );
  3083. }
  3084. /**
  3085. * Redirects to a different URL.
  3086. *
  3087. * @param $entity
  3088. * Ignored.
  3089. * @param array $context
  3090. * Array with the following elements:
  3091. * - 'url': URL to redirect to. This will be passed through
  3092. * token_replace().
  3093. * - Other elements will be used as the data for token replacement.
  3094. *
  3095. * @ingroup actions
  3096. */
  3097. function system_goto_action($entity, $context) {
  3098. drupal_goto(token_replace($context['url'], $context));
  3099. }
  3100. /**
  3101. * Blocks the current user's IP address.
  3102. *
  3103. * @ingroup actions
  3104. */
  3105. function system_block_ip_action() {
  3106. $ip = ip_address();
  3107. db_insert('blocked_ips')
  3108. ->fields(array('ip' => $ip))
  3109. ->execute();
  3110. watchdog('action', 'Banned IP address %ip', array('%ip' => $ip));
  3111. }
  3112. /**
  3113. * Generate an array of time zones and their local time&date.
  3114. *
  3115. * @param $blank
  3116. * If evaluates true, prepend an empty time zone option to the array.
  3117. */
  3118. function system_time_zones($blank = NULL) {
  3119. $zonelist = timezone_identifiers_list();
  3120. $zones = $blank ? array('' => t('- None selected -')) : array();
  3121. foreach ($zonelist as $zone) {
  3122. // Because many time zones exist in PHP only for backward compatibility
  3123. // reasons and should not be used, the list is filtered by a regular
  3124. // expression.
  3125. if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
  3126. $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)));
  3127. }
  3128. }
  3129. // Sort the translated time zones alphabetically.
  3130. asort($zones);
  3131. return $zones;
  3132. }
  3133. /**
  3134. * Checks whether the server is capable of issuing HTTP requests.
  3135. *
  3136. * The function sets the drupal_http_request_fail system variable to TRUE if
  3137. * drupal_http_request() does not work and then the system status report page
  3138. * will contain an error.
  3139. *
  3140. * @return
  3141. * TRUE if this installation can issue HTTP requests.
  3142. */
  3143. function system_check_http_request() {
  3144. // Try to get the content of the front page via drupal_http_request().
  3145. $result = drupal_http_request(url('', array('absolute' => TRUE)), array('max_redirects' => 0));
  3146. // We only care that we get a http response - this means that Drupal
  3147. // can make a http request.
  3148. $works = isset($result->code) && ($result->code >= 100) && ($result->code < 600);
  3149. variable_set('drupal_http_request_fails', !$works);
  3150. return $works;
  3151. }
  3152. /**
  3153. * Menu callback; Retrieve a JSON object containing a suggested time zone name.
  3154. */
  3155. function system_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) {
  3156. // An abbreviation of "0" passed in the callback arguments should be
  3157. // interpreted as the empty string.
  3158. $abbreviation = $abbreviation ? $abbreviation : '';
  3159. $timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time);
  3160. drupal_json_output($timezone);
  3161. }
  3162. /**
  3163. * Returns HTML for the Powered by Drupal text.
  3164. *
  3165. * @ingroup themeable
  3166. */
  3167. function theme_system_powered_by() {
  3168. return '<span>' . t('Powered by <a href="@poweredby">Drupal</a>', array('@poweredby' => 'http://drupal.org')) . '</span>';
  3169. }
  3170. /**
  3171. * Returns HTML for a link to show or hide inline help descriptions.
  3172. *
  3173. * @ingroup themeable
  3174. */
  3175. function theme_system_compact_link() {
  3176. $output = '<div class="compact-link">';
  3177. if (system_admin_compact_mode()) {
  3178. $output .= l(t('Show descriptions'), 'admin/compact/off', array('attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => drupal_get_destination()));
  3179. }
  3180. else {
  3181. $output .= l(t('Hide descriptions'), 'admin/compact/on', array('attributes' => array('title' => t('Compress layout by hiding descriptions.')), 'query' => drupal_get_destination()));
  3182. }
  3183. $output .= '</div>';
  3184. return $output;
  3185. }
  3186. /**
  3187. * Implements hook_image_toolkits().
  3188. */
  3189. function system_image_toolkits() {
  3190. include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'system') . '/' . 'image.gd.inc';
  3191. return array(
  3192. 'gd' => array(
  3193. 'title' => t('GD2 image manipulation toolkit'),
  3194. 'available' => function_exists('image_gd_check_settings') && image_gd_check_settings(),
  3195. ),
  3196. );
  3197. }
  3198. /**
  3199. * Attempts to get a file using drupal_http_request and to store it locally.
  3200. *
  3201. * @param $url
  3202. * The URL of the file to grab.
  3203. *
  3204. * @param $destination
  3205. * Stream wrapper URI specifying where the file should be placed. If a
  3206. * directory path is provided, the file is saved into that directory under
  3207. * its original name. If the path contains a filename as well, that one will
  3208. * be used instead.
  3209. * If this value is omitted, the site's default files scheme will be used,
  3210. * usually "public://".
  3211. *
  3212. * @param $managed boolean
  3213. * If this is set to TRUE, the file API hooks will be invoked and the file is
  3214. * registered in the database.
  3215. *
  3216. * @param $replace boolean
  3217. * Replace behavior when the destination file already exists:
  3218. * - FILE_EXISTS_REPLACE: Replace the existing file.
  3219. * - FILE_EXISTS_RENAME: Append _{incrementing number} until the filename is
  3220. * unique.
  3221. * - FILE_EXISTS_ERROR: Do nothing and return FALSE.
  3222. *
  3223. * @return
  3224. * On success the location the file was saved to, FALSE on failure.
  3225. */
  3226. function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FILE_EXISTS_RENAME) {
  3227. $parsed_url = parse_url($url);
  3228. if (!isset($destination)) {
  3229. $path = file_build_uri(drupal_basename($parsed_url['path']));
  3230. }
  3231. else {
  3232. if (is_dir(drupal_realpath($destination))) {
  3233. // Prevent URIs with triple slashes when glueing parts together.
  3234. $path = str_replace('///', '//', "$destination/") . drupal_basename($parsed_url['path']);
  3235. }
  3236. else {
  3237. $path = $destination;
  3238. }
  3239. }
  3240. $result = drupal_http_request($url);
  3241. if ($result->code != 200) {
  3242. drupal_set_message(t('HTTP error @errorcode occurred when trying to fetch @remote.', array('@errorcode' => $result->code, '@remote' => $url)), 'error');
  3243. return FALSE;
  3244. }
  3245. $local = $managed ? file_save_data($result->data, $path, $replace) : file_unmanaged_save_data($result->data, $path, $replace);
  3246. if (!$local) {
  3247. drupal_set_message(t('@remote could not be saved to @path.', array('@remote' => $url, '@path' => $path)), 'error');
  3248. }
  3249. return $local;
  3250. }
  3251. /**
  3252. * Implements hook_page_alter().
  3253. */
  3254. function system_page_alter(&$page) {
  3255. // Find all non-empty page regions, and add a theme wrapper function that
  3256. // allows them to be consistently themed.
  3257. $regions = system_region_list($GLOBALS['theme']);
  3258. foreach (array_keys($regions) as $region) {
  3259. if (!empty($page[$region])) {
  3260. $page[$region]['#theme_wrappers'][] = 'region';
  3261. $page[$region]['#region'] = $region;
  3262. }
  3263. }
  3264. }
  3265. /**
  3266. * Run the automated cron if enabled.
  3267. */
  3268. function system_run_automated_cron() {
  3269. // If the site is not fully installed, suppress the automated cron run.
  3270. // Otherwise it could be triggered prematurely by Ajax requests during
  3271. // installation.
  3272. if (($threshold = variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD)) > 0 && variable_get('install_task') == 'done') {
  3273. $cron_last = variable_get('cron_last', NULL);
  3274. if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) {
  3275. drupal_cron_run();
  3276. }
  3277. }
  3278. }
  3279. /**
  3280. * Gets the list of available date types and attributes.
  3281. *
  3282. * @param $type
  3283. * (optional) The date type name.
  3284. *
  3285. * @return
  3286. * An associative array of date type information keyed by the date type name.
  3287. * Each date type information array has the following elements:
  3288. * - type: The machine-readable name of the date type.
  3289. * - title: The human-readable name of the date type.
  3290. * - locked: A boolean indicating whether or not this date type should be
  3291. * configurable from the user interface.
  3292. * - module: The name of the module that defined this date type in its
  3293. * hook_date_format_types(). An empty string if the date type was
  3294. * user-defined.
  3295. * - is_new: A boolean indicating whether or not this date type is as of yet
  3296. * unsaved in the database.
  3297. * If $type was defined, only a single associative array with the above
  3298. * elements is returned.
  3299. */
  3300. function system_get_date_types($type = NULL) {
  3301. $types = &drupal_static(__FUNCTION__);
  3302. if (!isset($types)) {
  3303. $types = _system_date_format_types_build();
  3304. }
  3305. return $type ? (isset($types[$type]) ? $types[$type] : FALSE) : $types;
  3306. }
  3307. /**
  3308. * Implements hook_date_format_types().
  3309. */
  3310. function system_date_format_types() {
  3311. return array(
  3312. 'long' => t('Long'),
  3313. 'medium' => t('Medium'),
  3314. 'short' => t('Short'),
  3315. );
  3316. }
  3317. /**
  3318. * Implements hook_date_formats().
  3319. */
  3320. function system_date_formats() {
  3321. include_once DRUPAL_ROOT . '/includes/date.inc';
  3322. return system_default_date_formats();
  3323. }
  3324. /**
  3325. * Gets the list of defined date formats and attributes.
  3326. *
  3327. * @param $type
  3328. * (optional) The date type name.
  3329. *
  3330. * @return
  3331. * An associative array of date formats. The top-level keys are the names of
  3332. * the date types that the date formats belong to. The values are in turn
  3333. * associative arrays keyed by the format string, with the following keys:
  3334. * - dfid: The date format ID.
  3335. * - format: The format string.
  3336. * - type: The machine-readable name of the date type.
  3337. * - locales: An array of language codes. This can include both 2 character
  3338. * language codes like 'en and 'fr' and 5 character language codes like
  3339. * 'en-gb' and 'en-us'.
  3340. * - locked: A boolean indicating whether or not this date type should be
  3341. * configurable from the user interface.
  3342. * - module: The name of the module that defined this date format in its
  3343. * hook_date_formats(). An empty string if the format was user-defined.
  3344. * - is_new: A boolean indicating whether or not this date type is as of yet
  3345. * unsaved in the database.
  3346. * If $type was defined, only the date formats associated with the given date
  3347. * type are returned, in a single associative array keyed by format string.
  3348. */
  3349. function system_get_date_formats($type = NULL) {
  3350. $date_formats = &drupal_static(__FUNCTION__);
  3351. if (!isset($date_formats)) {
  3352. $date_formats = _system_date_formats_build();
  3353. }
  3354. return $type ? (isset($date_formats[$type]) ? $date_formats[$type] : FALSE) : $date_formats;
  3355. }
  3356. /**
  3357. * Gets the format details for a particular format ID.
  3358. *
  3359. * @param $dfid
  3360. * A date format ID.
  3361. *
  3362. * @return
  3363. * A date format object with the following properties:
  3364. * - dfid: The date format ID.
  3365. * - format: The date format string.
  3366. * - type: The name of the date type.
  3367. * - locked: Whether the date format can be changed or not.
  3368. */
  3369. function system_get_date_format($dfid) {
  3370. return db_query('SELECT df.dfid, df.format, df.type, df.locked FROM {date_formats} df WHERE df.dfid = :dfid', array(':dfid' => $dfid))->fetch();
  3371. }
  3372. /**
  3373. * Resets the database cache of date formats and saves all new date formats.
  3374. */
  3375. function system_date_formats_rebuild() {
  3376. drupal_static_reset('system_get_date_formats');
  3377. $date_formats = system_get_date_formats(NULL);
  3378. foreach ($date_formats as $type => $formats) {
  3379. foreach ($formats as $format => $info) {
  3380. system_date_format_save($info);
  3381. }
  3382. }
  3383. // Rebuild configured date formats locale list.
  3384. drupal_static_reset('system_date_format_locale');
  3385. system_date_format_locale();
  3386. _system_date_formats_build();
  3387. }
  3388. /**
  3389. * Gets the appropriate date format string for a date type and locale.
  3390. *
  3391. * @param $langcode
  3392. * (optional) Language code for the current locale. This can be a 2 character
  3393. * language code like 'en' and 'fr' or a 5 character language code like
  3394. * 'en-gb' and 'en-us'.
  3395. * @param $type
  3396. * (optional) The date type name.
  3397. *
  3398. * @return
  3399. * If $type and $langcode are specified, returns the corresponding date format
  3400. * string. If only $langcode is specified, returns an array of all date
  3401. * format strings for that locale, keyed by the date type. If neither is
  3402. * specified, or if no matching formats are found, returns FALSE.
  3403. */
  3404. function system_date_format_locale($langcode = NULL, $type = NULL) {
  3405. $formats = &drupal_static(__FUNCTION__);
  3406. if (empty($formats)) {
  3407. $formats = array();
  3408. $result = db_query("SELECT format, type, language FROM {date_format_locale}");
  3409. foreach ($result as $record) {
  3410. if (!isset($formats[$record->language])) {
  3411. $formats[$record->language] = array();
  3412. }
  3413. $formats[$record->language][$record->type] = $record->format;
  3414. }
  3415. }
  3416. if ($type && $langcode && !empty($formats[$langcode][$type])) {
  3417. return $formats[$langcode][$type];
  3418. }
  3419. elseif ($langcode && !empty($formats[$langcode])) {
  3420. return $formats[$langcode];
  3421. }
  3422. return FALSE;
  3423. }
  3424. /**
  3425. * Builds and returns information about available date types.
  3426. *
  3427. * @return
  3428. * An associative array of date type information keyed by name. Each date type
  3429. * information array has the following elements:
  3430. * - type: The machine-readable name of the date type.
  3431. * - title: The human-readable name of the date type.
  3432. * - locked: A boolean indicating whether or not this date type should be
  3433. * configurable from the user interface.
  3434. * - module: The name of the module that defined this format in its
  3435. * hook_date_format_types(). An empty string if the format was user-defined.
  3436. * - is_new: A boolean indicating whether or not this date type is as of yet
  3437. * unsaved in the database.
  3438. */
  3439. function _system_date_format_types_build() {
  3440. $types = array();
  3441. // Get list of modules that implement hook_date_format_types().
  3442. $modules = module_implements('date_format_types');
  3443. foreach ($modules as $module) {
  3444. $module_types = module_invoke($module, 'date_format_types');
  3445. foreach ($module_types as $module_type => $type_title) {
  3446. $type = array();
  3447. $type['module'] = $module;
  3448. $type['type'] = $module_type;
  3449. $type['title'] = $type_title;
  3450. $type['locked'] = 1;
  3451. // Will be over-ridden later if in the db.
  3452. $type['is_new'] = TRUE;
  3453. $types[$module_type] = $type;
  3454. }
  3455. }
  3456. // Get custom formats added to the database by the end user.
  3457. $result = db_query('SELECT dft.type, dft.title, dft.locked FROM {date_format_type} dft ORDER BY dft.title');
  3458. foreach ($result as $record) {
  3459. if (!isset($types[$record->type])) {
  3460. $type = array();
  3461. $type['is_new'] = FALSE;
  3462. $type['module'] = '';
  3463. $type['type'] = $record->type;
  3464. $type['title'] = $record->title;
  3465. $type['locked'] = $record->locked;
  3466. $types[$record->type] = $type;
  3467. }
  3468. else {
  3469. $type = array();
  3470. $type['is_new'] = FALSE; // Over-riding previous setting.
  3471. $types[$record->type] = array_merge($types[$record->type], $type);
  3472. }
  3473. }
  3474. // Allow other modules to modify these date types.
  3475. drupal_alter('date_format_types', $types);
  3476. return $types;
  3477. }
  3478. /**
  3479. * Builds and returns information about available date formats.
  3480. *
  3481. * @return
  3482. * An associative array of date formats. The top-level keys are the names of
  3483. * the date types that the date formats belong to. The values are in turn
  3484. * associative arrays keyed by format with the following keys:
  3485. * - dfid: The date format ID.
  3486. * - format: The PHP date format string.
  3487. * - type: The machine-readable name of the date type the format belongs to.
  3488. * - locales: An array of language codes. This can include both 2 character
  3489. * language codes like 'en and 'fr' and 5 character language codes like
  3490. * 'en-gb' and 'en-us'.
  3491. * - locked: A boolean indicating whether or not this date type should be
  3492. * configurable from the user interface.
  3493. * - module: The name of the module that defined this format in its
  3494. * hook_date_formats(). An empty string if the format was user-defined.
  3495. * - is_new: A boolean indicating whether or not this date type is as of yet
  3496. * unsaved in the database.
  3497. */
  3498. function _system_date_formats_build() {
  3499. $date_formats = array();
  3500. // First handle hook_date_format_types().
  3501. $types = _system_date_format_types_build();
  3502. foreach ($types as $type => $info) {
  3503. system_date_format_type_save($info);
  3504. }
  3505. // Get formats supplied by various contrib modules.
  3506. $module_formats = module_invoke_all('date_formats');
  3507. foreach ($module_formats as $module_format) {
  3508. // System types are locked.
  3509. $module_format['locked'] = 1;
  3510. // If no date type is specified, assign 'custom'.
  3511. if (!isset($module_format['type'])) {
  3512. $module_format['type'] = 'custom';
  3513. }
  3514. if (!in_array($module_format['type'], array_keys($types))) {
  3515. continue;
  3516. }
  3517. if (!isset($date_formats[$module_format['type']])) {
  3518. $date_formats[$module_format['type']] = array();
  3519. }
  3520. // If another module already set this format, merge in the new settings.
  3521. if (isset($date_formats[$module_format['type']][$module_format['format']])) {
  3522. $date_formats[$module_format['type']][$module_format['format']] = array_merge_recursive($date_formats[$module_format['type']][$module_format['format']], $module_format);
  3523. }
  3524. else {
  3525. // This setting will be overridden later if it already exists in the db.
  3526. $module_format['is_new'] = TRUE;
  3527. $date_formats[$module_format['type']][$module_format['format']] = $module_format;
  3528. }
  3529. }
  3530. // Get custom formats added to the database by the end user.
  3531. $result = db_query('SELECT df.dfid, df.format, df.type, df.locked, dfl.language FROM {date_formats} df LEFT JOIN {date_format_type} dft ON df.type = dft.type LEFT JOIN {date_format_locale} dfl ON df.format = dfl.format AND df.type = dfl.type ORDER BY df.type, df.format');
  3532. foreach ($result as $record) {
  3533. // If this date type isn't set, initialise the array.
  3534. if (!isset($date_formats[$record->type])) {
  3535. $date_formats[$record->type] = array();
  3536. }
  3537. $format = (array) $record;
  3538. $format['is_new'] = FALSE; // It's in the db, so override this setting.
  3539. // If this format not already present, add it to the array.
  3540. if (!isset($date_formats[$record->type][$record->format])) {
  3541. $format['module'] = '';
  3542. $format['locales'] = array($record->language);
  3543. $date_formats[$record->type][$record->format] = $format;
  3544. }
  3545. // Format already present, so merge in settings.
  3546. else {
  3547. if (!empty($record->language)) {
  3548. $format['locales'] = array_merge($date_formats[$record->type][$record->format]['locales'], array($record->language));
  3549. }
  3550. $date_formats[$record->type][$record->format] = array_merge($date_formats[$record->type][$record->format], $format);
  3551. }
  3552. }
  3553. // Allow other modules to modify these formats.
  3554. drupal_alter('date_formats', $date_formats);
  3555. return $date_formats;
  3556. }
  3557. /**
  3558. * Saves a date type to the database.
  3559. *
  3560. * @param $type
  3561. * A date type array containing the following keys:
  3562. * - type: The machine-readable name of the date type.
  3563. * - title: The human-readable name of the date type.
  3564. * - locked: A boolean indicating whether or not this date type should be
  3565. * configurable from the user interface.
  3566. * - is_new: A boolean indicating whether or not this date type is as of yet
  3567. * unsaved in the database.
  3568. */
  3569. function system_date_format_type_save($type) {
  3570. $info = array();
  3571. $info['type'] = $type['type'];
  3572. $info['title'] = $type['title'];
  3573. $info['locked'] = $type['locked'];
  3574. // Update date_format table.
  3575. if (!empty($type['is_new'])) {
  3576. drupal_write_record('date_format_type', $info);
  3577. }
  3578. else {
  3579. drupal_write_record('date_format_type', $info, 'type');
  3580. }
  3581. }
  3582. /**
  3583. * Deletes a date type from the database.
  3584. *
  3585. * @param $type
  3586. * The machine-readable name of the date type.
  3587. */
  3588. function system_date_format_type_delete($type) {
  3589. db_delete('date_formats')
  3590. ->condition('type', $type)
  3591. ->execute();
  3592. db_delete('date_format_type')
  3593. ->condition('type', $type)
  3594. ->execute();
  3595. db_delete('date_format_locale')
  3596. ->condition('type', $type)
  3597. ->execute();
  3598. }
  3599. /**
  3600. * Saves a date format to the database.
  3601. *
  3602. * @param $date_format
  3603. * A date format array containing the following keys:
  3604. * - type: The name of the date type this format is associated with.
  3605. * - format: The PHP date format string.
  3606. * - locked: A boolean indicating whether or not this format should be
  3607. * configurable from the user interface.
  3608. * @param $dfid
  3609. * If set, replace the existing date format having this ID with the
  3610. * information specified in $date_format.
  3611. *
  3612. * @see system_get_date_types()
  3613. * @see http://php.net/date
  3614. */
  3615. function system_date_format_save($date_format, $dfid = 0) {
  3616. $info = array();
  3617. $info['dfid'] = $dfid;
  3618. $info['type'] = $date_format['type'];
  3619. $info['format'] = $date_format['format'];
  3620. $info['locked'] = $date_format['locked'];
  3621. // Update date_format table.
  3622. if (!empty($date_format['is_new'])) {
  3623. drupal_write_record('date_formats', $info);
  3624. }
  3625. else {
  3626. $keys = ($dfid ? array('dfid') : array('format', 'type'));
  3627. drupal_write_record('date_formats', $info, $keys);
  3628. }
  3629. // Retrieve an array of language objects for enabled languages.
  3630. $languages = language_list('enabled');
  3631. // This list is keyed off the value of $language->enabled; we want the ones
  3632. // that are enabled (value of 1).
  3633. $languages = $languages[1];
  3634. $locale_format = array();
  3635. $locale_format['type'] = $date_format['type'];
  3636. $locale_format['format'] = $date_format['format'];
  3637. // Check if the suggested language codes are configured and enabled.
  3638. if (!empty($date_format['locales'])) {
  3639. foreach ($date_format['locales'] as $langcode) {
  3640. // Only proceed if language is enabled.
  3641. if (isset($languages[$langcode])) {
  3642. $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();
  3643. if (!$is_existing) {
  3644. $locale_format['language'] = $langcode;
  3645. drupal_write_record('date_format_locale', $locale_format);
  3646. }
  3647. }
  3648. }
  3649. }
  3650. }
  3651. /**
  3652. * Deletes a date format from the database.
  3653. *
  3654. * @param $dfid
  3655. * The date format ID.
  3656. */
  3657. function system_date_format_delete($dfid) {
  3658. db_delete('date_formats')
  3659. ->condition('dfid', $dfid)
  3660. ->execute();
  3661. }
  3662. /**
  3663. * Implements hook_archiver_info().
  3664. */
  3665. function system_archiver_info() {
  3666. $archivers['tar'] = array(
  3667. 'class' => 'ArchiverTar',
  3668. 'extensions' => array('tar', 'tgz', 'tar.gz', 'tar.bz2'),
  3669. );
  3670. if (function_exists('zip_open')) {
  3671. $archivers['zip'] = array(
  3672. 'class' => 'ArchiverZip',
  3673. 'extensions' => array('zip'),
  3674. );
  3675. }
  3676. return $archivers;
  3677. }
  3678. /**
  3679. * Returns HTML for a confirmation form.
  3680. *
  3681. * By default this does not alter the appearance of a form at all,
  3682. * but is provided as a convenience for themers.
  3683. *
  3684. * @param $variables
  3685. * An associative array containing:
  3686. * - form: A render element representing the form.
  3687. *
  3688. * @ingroup themeable
  3689. */
  3690. function theme_confirm_form($variables) {
  3691. return drupal_render_children($variables['form']);
  3692. }
  3693. /**
  3694. * Returns HTML for a system settings form.
  3695. *
  3696. * By default this does not alter the appearance of a form at all,
  3697. * but is provided as a convenience for themers.
  3698. *
  3699. * @param $variables
  3700. * An associative array containing:
  3701. * - form: A render element representing the form.
  3702. *
  3703. * @ingroup themeable
  3704. */
  3705. function theme_system_settings_form($variables) {
  3706. return drupal_render_children($variables['form']);
  3707. }
  3708. /**
  3709. * Returns HTML for an exposed filter form.
  3710. *
  3711. * @param $variables
  3712. * An associative array containing:
  3713. * - form: An associative array containing the structure of the form.
  3714. *
  3715. * @return
  3716. * A string containing an HTML-formatted form.
  3717. *
  3718. * @ingroup themeable
  3719. */
  3720. function theme_exposed_filters($variables) {
  3721. $form = $variables['form'];
  3722. $output = '';
  3723. if (isset($form['current'])) {
  3724. $items = array();
  3725. foreach (element_children($form['current']) as $key) {
  3726. $items[] = drupal_render($form['current'][$key]);
  3727. }
  3728. $output .= theme('item_list', array('items' => $items, 'attributes' => array('class' => array('clearfix', 'current-filters'))));
  3729. }
  3730. $output .= drupal_render_children($form);
  3731. return '<div class="exposed-filters">' . $output . '</div>';
  3732. }
  3733. /**
  3734. * Implements hook_admin_paths().
  3735. */
  3736. function system_admin_paths() {
  3737. $paths = array(
  3738. 'admin' => TRUE,
  3739. 'admin/*' => TRUE,
  3740. 'batch' => TRUE,
  3741. // This page should not be treated as administrative since it outputs its
  3742. // own content (outside of any administration theme).
  3743. 'admin/reports/status/php' => FALSE,
  3744. );
  3745. return $paths;
  3746. }