Compare commits

...
1054 Commits
Author SHA1 Message Date
bachir 49a0944412 upadted i18n admin_theme 2020-11-09 14:47:59 +01:00
bachir d6e525465b repatched https://www.drupal.org/project/drupal/issues/1754162#comment-9737269 2020-11-09 10:18:41 +01:00
bachir 91e0ff102e updated core to 7.73 2020-11-09 10:18:07 +01:00
bachir be549a75f6 updated webform & faq 2020-03-27 14:25:57 +01:00
bachir 1e27fcca51 repatched https://www.drupal.org/project/drupal/issues/1754162#comment-9737269 2020-03-27 14:23:44 +01:00
bachir ab5d43a397 upadted core to 7.69 2020-03-27 14:22:44 +01:00
bachir 094d6ec86f added blabla block to home page 2019-11-05 16:51:50 +01:00
bachir 6475b0c126 updated gulp to V4 2019-11-05 15:48:28 +01:00
bachir a7f0bb7650 added account_sentinel contrib module 2019-10-21 14:56:57 +02:00
bachir 50d08c7efd added text_formats_report contrib module 2019-10-21 14:49:37 +02:00
bachir 4e780cb6d4 updated ubercart contrib module 2019-10-14 10:35:12 +02:00
bachir 26fadc74e4 upadted l10n_update contrib module 2019-10-14 10:31:06 +02:00
bachir 9f043d25e9 updated uuid contrib module 2019-10-14 10:30:39 +02:00
bachir 72e8abe604 repatched https://www.drupal.org/project/drupal/issues/1754162#comment-9737269 2019-10-14 10:23:48 +02:00
bachir 637ff76ca8 updated core to 7.67 2019-10-14 10:23:07 +02:00
bachir ad25acf851 redis bug
https://www.drupal.org/project/redis/issues/3074189
2019-08-22 15:45:45 +02:00
bachir 0f3912f6fd fixed tax country related bug in checkout 2019-07-11 21:52:12 +02:00
bachir 2553869978 blocked gulp to <4 in materiobasemodule, updated PATCHLIST 2019-07-11 19:12:25 +02:00
bachir d1290e31bc fixed checkout form display (billing form select country) 2019-07-11 18:37:59 +02:00
bachir 598f09bba5 fixed location on subscrition to checkout brige (added billing_zone) 2019-07-11 18:31:03 +02:00
bachir fb11eac920 fixed location on subscrition to checkout brige 2019-07-11 18:23:46 +02:00
bachir 0973d0afe5 fixed subscriptions webform interactivity 2019-07-08 12:20:31 +02:00
bachir 785eea77db fixed bug with subscription form submition 2019-06-05 17:41:08 +02:00
bachir 2e69e3fd4c updated search_api, search_api_solr_override, imce 2019-05-14 11:01:58 +02:00
bachir dc39ddbbea updated mailgun librarie 2019-05-14 10:47:30 +02:00
bachir c97e0f8ba1 updated i18n, views, imagestyleflush, field_group
patch views_rss_media
2019-05-14 10:14:51 +02:00
bachir 9adc940a67 updated webform, webform_localization, profile2, term_merge, search_api_saved_pages, rules, redirect, overide_node_options 2019-05-13 18:47:27 +02:00
bachir 58cd990c8c updated elysia_cron, elfinder, metatag, libraries, email_registration, migrate, nodeform_cols 2019-05-13 18:03:41 +02:00
bachir e08a2639c6 updated mailgun, mailsystem, honeypot, googleanalitycs, features, content_taxonomy 2019-05-13 17:55:28 +02:00
bachir 2ffad14939 updated etxlink, ctools, colorbox, computed_field 2019-05-13 17:51:14 +02:00
bachir 33210e10f2 updated admin_menu, entity_translation, addressfield, addressfield_token, autocomplete_deluxe 2019-05-13 17:41:56 +02:00
bachir 472762edfa fixed php warning 2019-05-07 17:56:46 +02:00
bachir 89287879bc fixed php warning 2019-05-07 17:38:52 +02:00
bachir 3411804c42 fixed php warning 2019-05-07 17:36:36 +02:00
bachir de0f246fb3 added error_log contrib module 2019-05-07 11:56:20 +02:00
bachir a180696fc7 patched views_rss_media 2019-05-07 11:22:38 +02:00
bachir ccd47590d5 added log_filter contrib module 2019-05-07 10:58:35 +02:00
bachir 5dd6874488 re-added composer.json for drush 2019-04-27 16:15:45 +02:00
bachir 514f3bd89e security update link,module_filters,search_api_solr,ubercart,views 2019-04-24 16:39:12 +02:00
bachir 0aea7a0db1 repatched https://www.drupal.org/project/drupal/issues/1754162#comment-9737269 2019-04-24 13:25:09 +02:00
bachir b2fe2731c2 updated core to 7.66 2019-04-24 13:24:00 +02:00
bachir f6e72bbe19 repatched https://www.drupal.org/project/drupal/issues/1754162#comment-9737269 2019-03-28 11:00:52 +01:00
bachir 6fb9e4806d updated core to 7.65 2019-03-28 10:59:04 +01:00
bachir b764ef206e updated print 2019-01-27 14:52:28 +01:00
bachir 0615369680 updated uuid 2019-01-27 14:45:55 +01:00
bachir 954fc9ead1 updated session_limite 2019-01-27 14:44:48 +01:00
bachir 79db3e3896 updated mimemail 2019-01-27 14:43:42 +01:00
bachir 5510ac0abf updated genpass 2019-01-27 14:42:15 +01:00
bachir 2d23821da4 updated composer drush to 8 2019-01-27 14:28:50 +01:00
bachir fca4395934 repatched https://www.drupal.org/project/drupal/issues/1754162#comment-9737269 2019-01-27 14:28:24 +01:00
bachir 31cfa90501 updated core to 7.63 2019-01-27 14:26:06 +01:00
bachir ccab226e12 added elfinder module 2018-12-04 20:35:06 +01:00
bachir 1b53514906 fixed solgan position 2018-11-05 17:54:37 +01:00
bachir 25b41d2a43 fixed header responsive 2018-11-05 17:45:17 +01:00
bachir eb20184257 updated npm package for aterio module and theme 2018-11-05 17:31:18 +01:00
bachir c285c6ccb8 added composer file to install drush when needed 2018-10-29 17:42:13 +01:00
bachir fa07acdd31 fixed flag nav bug 2018-09-04 13:12:20 +02:00
bachir 9ad0aa199f fix bug : deleted entities crash site when in usser flag_lists 2 2018-06-01 16:05:23 +02:00
bachir 7ab8742528 updated npm gulp packages 2018-06-01 15:53:55 +02:00
bachir 8ec6b54b6c fix bug : deleted entities crash site when in usser flag_lists 2018-06-01 15:51:09 +02:00
bachir f21817dec1 repatched https://www.drupal.org/project/drupal/issues/1754162#comment-9737269 2018-05-23 18:34:04 +02:00
bachir 4cb8f6aee1 updated core to 7.79 2018-05-23 18:32:16 +02:00
bachir b3e863e943 denied access to user/register via materio_admin.module hook_menu_halter 2018-04-21 11:55:58 +02:00
bachir 4aed87ebd0 updated colorbox library 2018-04-21 00:33:36 +02:00
bachir fafd439b26 repatched entity_reference 2018-04-21 00:04:42 +02:00
bachir 226561ffd4 security update for entity_reference 2018-04-21 00:03:39 +02:00
bachir 85772b4ca7 security update for views 2018-04-20 23:59:18 +02:00
bachir 57376251fa security update for entity api 2018-04-20 23:55:10 +02:00
bachir 8a05ca54b2 repatched https://www.drupal.org/project/drupal/issues/1754162#comment-9737269 2018-04-20 23:49:43 +02:00
bachir 9344a61b61 updated core to 7.58 (right after the site was hacked) 2018-04-20 23:48:40 +02:00
Bachir Soussi Chiadmi 18f4aba146 added redis contrib module 2018-02-21 14:07:00 +01:00
Bachir Soussi Chiadmi 1eb61fe020 fixed js bug Drupal.ajax undefined, fixe #81 2018-01-11 17:09:04 +01:00
Bachir Soussi Chiadmi a11650f2b4 fixed header height 2018-01-02 12:20:33 +01:00
Bachir Soussi Chiadmi f09e9563b2 Merge branch 'advanced-search' 2018-01-02 12:13:16 +01:00
Bachir Soussi Chiadmi c914e7e348 fixed header height 2018-01-02 12:11:58 +01:00
Bachir Soussi Chiadmi b5f3769416 new browser prefix ?? 2018-01-02 12:02:43 +01:00
Bachir Soussi Chiadmi 3133fd480b updated materio_personal_notes feature 2017-12-04 14:05:55 +01:00
Bachir Soussi Chiadmi b20732f9a8 personal note display for viewmode cardfull 2017-11-29 17:14:01 +01:00
Bachir Soussi Chiadmi 8b486ffc60 personal-notes display for card medium and cardfull is ok 2017-11-29 16:40:20 +01:00
Bachir Soussi Chiadmi 7d5bedcb0c personnale notes front ajax is working, remains to improve the display, do it like liked materiaux 2017-11-28 17:02:45 +01:00
Bachir Soussi Chiadmi 268c8b619b added link with query for target node id and prepopulated node form 2017-11-27 15:21:32 +01:00
Bachir Soussi Chiadmi bbeb5f01ac created materio personal notes feature 2017-11-27 12:28:46 +01:00
Bachir Soussi Chiadmi bd1a1de792 first commit of materio personal notes module : just displaying the icon button for now 2017-11-27 12:20:08 +01:00
Bachir Soussi Chiadmi af9630060a improved display of advanced search 2017-11-21 10:44:24 +01:00
Bachir Soussi Chiadmi 383ca8b173 improved display of advanced search 2017-11-21 10:38:27 +01:00
Bachir Soussi Chiadmi afc654c704 improved throbber display in advenced search 2017-11-21 09:58:45 +01:00
Bachir Soussi Chiadmi 106129c27c refined advanced search form display to be more explicite 2017-11-20 17:52:39 +01:00
Bachir Soussi Chiadmi 81810c5af4 fixed loading indicator for both search forms 2017-11-15 13:53:48 +01:00
Bachir Soussi Chiadmi 12c076c349 some comments cleaning 2017-11-07 20:00:55 +01:00
Bachir Soussi Chiadmi 9d45086951 fixed infinite scroll with advenced search 2017-11-06 16:45:40 +01:00
Bachir Soussi Chiadmi 8777adbe2e restored ajax search for filtered search 2017-11-06 16:28:05 +01:00
Bachir Soussi Chiadmi 82a22114d3 fixed one term search bug: no results 2017-11-06 16:20:03 +01:00
Bachir Soussi Chiadmi 098f083b8d fixed page title and performance display for filtered search by tids : displa term names instead of tids 2017-11-06 12:10:56 +01:00
Bachir Soussi Chiadmi e8586eb4da Sorl search based on term tid and scored is functional 2017-11-06 11:47:33 +01:00
Bachir Soussi Chiadmi 1e1a762b9b added settings for advanced search vocabulary choice and hidden terms 2017-10-31 12:47:28 +01:00
Bachir Soussi Chiadmi e9146c29ce handled ajax call for advanced search, handled permissions for advanced form display 2017-10-31 11:08:13 +01:00
Bachir Soussi Chiadmi 042e111bc4 created proper solr call for filtered search 2017-10-30 14:48:23 +01:00
Bachir Soussi Chiadmi 2f56697bb7 tabs interface for search forms is ready 2017-10-30 12:07:21 +01:00
Bachir Soussi Chiadmi 55700094a2 started to mix search form and advanced search form into one unique block, the idea is to switch to one from an other with tabs 2017-10-25 17:01:00 +02:00
Bachir Soussi Chiadmi 9bfbd861ca bugfix 2017-10-11 17:05:20 +02:00
Bachir Soussi Chiadmi 5f26b3e160 bugfix 2017-10-11 14:44:55 +02:00
Bachir Soussi Chiadmi 1b9f8e3ab4 first test of launch a research, read the url args and prepopulate the form, ajax add and remove filter are not working anymore 2017-10-10 16:51:22 +02:00
Bachir Soussi Chiadmi c90cfa63e4 advanced search : all ajax form behaviours are working 2017-10-10 12:43:45 +02:00
Bachir Soussi Chiadmi 7bc3c13ad6 fixed tode module php notice 2017-10-09 16:38:53 +02:00
Bachir Soussi Chiadmi 1ee4e95491 advanced search ajax callback for dynamic form building are almost working + started css 2017-10-09 16:38:18 +02:00
Bachir Soussi Chiadmi bf5f1a63ff updated gulp and bower files 2017-10-09 16:35:06 +02:00
Bachir Soussi Chiadmi 38648c1670 advenced search block is in place, remains to build the whole logic 2017-10-07 20:29:58 +02:00
Bachir Soussi Chiadmi 1d4fcf0d89 Merge branch 'master' into advanced-search 2017-10-07 20:05:52 +02:00
Bachir Soussi Chiadmi 73417de740 updated all features 2017-10-07 20:04:02 +02:00
Bachir Soussi Chiadmi 0edc6fd23a started advenced serch form block 2017-10-07 19:49:22 +02:00
Bachir Soussi Chiadmi abb106d7c2 optmized industriels esport 2017-09-18 16:04:53 +02:00
Bachir Soussi Chiadmi be2da7afe0 added the right export script for industriels users (not companies) 2017-09-18 15:46:40 +02:00
Bachir Soussi Chiadmi 243f5b689c fixed advanced search first rquest bug (bois+translucide) fix #31 2017-09-16 16:52:04 +02:00
Bachir Soussi Chiadmi 301d403887 fixed contactops export bug 2017-09-16 16:14:23 +02:00
Bachir Soussi Chiadmi 08e5ed7202 removed personnal script sync_uplaods from git tree 2017-09-16 16:06:39 +02:00
Bachir Soussi Chiadmi 4ca87255ab added export companies as csv file function 2017-09-16 16:03:43 +02:00
Bachir Soussi Chiadmi 4b2ab455c9 first draft of materio_contactops module : shows company taged materials for a user contactop 2017-07-25 22:32:52 +02:00
Bachir Soussi Chiadmi b9c809d2c7 updated webform, uuid, synonyms modules 2017-07-25 19:28:08 +02:00
Bachir Soussi Chiadmi ed483507e5 security update for smtp module 2017-07-25 19:17:08 +02:00
Bachir Soussi Chiadmi 8feebe3d1e repatched core with https://www.drupal.org/node/1754162#comment-9737269 2017-07-25 19:13:30 +02:00
Bachir Soussi Chiadmi 5c7f02554f updated core to 7.56, secutity update 2017-07-25 19:10:33 +02:00
Bachir Soussi Chiadmi 58161d2b57 fixed render function wrongly removed from industriel newsletter template 2017-07-06 17:46:22 +02:00
Bachir Soussi Chiadmi ce192b080e removed all html from industriel news template 2017-07-06 17:12:45 +02:00
Bachir Soussi Chiadmi aafe1c5460 added new template for industriels newsletter 2017-07-05 22:27:45 +02:00
Bachir Soussi Chiadmi 8539255353 optimzed some php code in admin views 2017-07-05 21:50:49 +02:00
Bachir Soussi Chiadmi 5706aea93b added some missing navigation menu items in admin feature 2017-07-05 21:39:11 +02:00
Bachir Soussi Chiadmi 9369b73118 added new light industriel view and indus. export list for simplenewsletter massive subscription 2017-07-05 21:29:03 +02:00
Bachir Soussi Chiadmi ab9f1d3cc4 added template for industriels simplenewletter 2017-07-05 18:34:56 +02:00
Bachir Soussi Chiadmi 8d0f110c50 fixe contact ops materiaux access, fixe #21 2017-07-04 20:56:25 +02:00
Bachir Soussi Chiadmi cedbce376b updated features 2017-07-04 20:02:56 +02:00
Bachir Soussi Chiadmi 6e2a36fe0c front : imporved location layout in fullcards
fix #6
2017-05-30 12:09:59 +02:00
Bachir Soussi Chiadmi d9f3677b98 applied security views modules updates
didn't repatched view module, keep it in mind, may be necessary
2017-05-24 19:35:05 +02:00
Bachir Soussi Chiadmi 5b82dfb691 repatched core with https://www.drupal.org/node/1754162#comment-9737269 2017-05-24 19:31:16 +02:00
Bachir Soussi Chiadmi 728f8e6d31 updated core to 7.54 2017-05-24 19:27:14 +02:00
Bachir Soussi Chiadmi 9acef9d37e updated ctools, panels, date, diff 2017-05-24 19:22:50 +02:00
Bachir Soussi Chiadmi 542ac42fca updated views_send views_bulk_update views_data_export 2017-05-24 19:09:09 +02:00
Bachir Soussi Chiadmi dbd7b88639 applied security contrib modules updates
didn't repatched view module, keep it in mind, may be necessary
2017-05-24 19:02:39 +02:00
Bachir Soussi Chiadmi 28c7a0965a updated search_api modules as indexation was not working localy
had to be tested in production
2017-05-24 18:57:04 +02:00
Bachir Soussi Chiadmi b5d76ec5e6 fixed home simplenews picture match 2017-05-24 15:28:00 +02:00
Bachir Soussi Chiadmi 83cbcefff9 re-added temporarly translate_perms 2016-12-20 12:22:42 +01:00
Bachir Soussi Chiadmi 0d940c99db updated features 2016-12-20 01:15:04 +01:00
Bachir Soussi Chiadmi 2334eb741b updated features for precedent commit 2016-12-20 00:18:28 +01:00
Bachir Soussi Chiadmi ddc28956c4 added string and field translation table for translators 2016-12-20 00:17:50 +01:00
Bachir Soussi Chiadmi abbcb19838 removed i18n_access from tree 2016-12-19 19:08:09 +01:00
Bachir Soussi Chiadmi 024afdfd3d Merge branch 'master' into translators 2016-12-19 18:15:12 +01:00
Bachir Soussi Chiadmi b9f2b16d24 modules security update
views_send, elysia_cron
2016-12-19 18:10:13 +01:00
Bachir Soussi Chiadmi 3f9ba49255 repatched core user module
language aware tokens
https://www.drupal.org/node/1754162
2016-12-19 17:06:32 +01:00
Bachir Soussi Chiadmi f01fdbdd9c security core update 2016-12-19 16:57:32 +01:00
Bachir Soussi Chiadmi 7563311a19 handled translation links from node edit 2016-12-19 00:39:20 +01:00
Bachir Soussi Chiadmi 669341f1d6 added forgoten materio_translators.install file 2016-12-13 13:01:55 +01:00
Bachir Soussi Chiadmi 13aafca7e4 moved the duplicatesmail menu 2016-12-13 13:00:59 +01:00
Bachir Soussi Chiadmi e24eec56e7 materio translator : Node overview DONE 2016-12-13 12:52:01 +01:00
Bachir Soussi Chiadmi eba58a57bf added the second patch to i18n_access BUT WE WONT USE THIS MODULE! 2016-12-13 12:50:01 +01:00
Bachir Soussi Chiadmi e190f5f47d improved original language on node form display 2016-12-13 12:49:02 +01:00
Bachir Soussi Chiadmi ec6f23e149 patched i18n_access module
https://www.drupal.org/node/2298475#comment-9419835
2016-12-12 16:01:17 +01:00
Bachir Soussi Chiadmi fdd842fe19 rolled back i18n_access to last dev version 2016-12-12 15:58:28 +01:00
Bachir Soussi Chiadmi 73ec6d3c1e fixed image for anonymous 2016-12-12 14:35:55 +01:00
Bachir Soussi Chiadmi dee5085c89 improved term field restoration batch script 2016-12-12 11:33:34 +01:00
Bachir Soussi Chiadmi c4ab89f177 trying to fix PHP Fatal error: Cannot use [] for reading 2016-12-12 11:30:20 +01:00
Bachir Soussi Chiadmi d1b069ad8b added term field restoration batch script 2016-12-12 11:24:20 +01:00
Bachir Soussi Chiadmi c56a523286 fixed showroom field form bug, removed ordering, fixed card js in node page 2016-12-11 19:50:48 +01:00
Bachir Soussi Chiadmi 8b5d721bfd fixed location field access for administrator, improved disbaled field display 2016-12-11 11:30:39 +01:00
Bachir Soussi Chiadmi 7ed9dc54bf fixed card print css display 2016-12-11 10:34:10 +01:00
Bachir Soussi Chiadmi adee2f54e3 fixed card print css display 2016-12-11 10:30:32 +01:00
Bachir Soussi Chiadmi 41e3e6dfb2 Location -> samples, fixed cs display, fixed empty field 2016-12-11 10:17:00 +01:00
Bachir Soussi Chiadmi 5f6a9ac5d1 fixed showroom location formatter and contentype display
remains css
2016-12-10 19:27:00 +01:00
Bachir Soussi Chiadmi 16d8adc672 trimed contentadminrelink 2016-12-10 18:31:21 +01:00
Bachir Soussi Chiadmi 138b68ac98 commited features for showroom release 2016-12-10 18:30:03 +01:00
Bachir Soussi Chiadmi 026a9bc241 commited custom modules for showroom release 2016-12-10 18:29:27 +01:00
Bachir Soussi Chiadmi adb1437a44 reseted old features as in prod 2016-12-10 11:10:49 +01:00
Bachir Soussi Chiadmi 5d17730143 added helpers scripts 2016-12-10 11:03:19 +01:00
Bachir Soussi Chiadmi 1ec80dc60e finished showroom migration batch function 2016-11-27 19:48:58 +01:00
Bachir Soussi Chiadmi 5423f6d3bc added per user showroom location field access 2016-11-27 12:27:57 +01:00
Bachir Soussi Chiadmi 1ccc5d07d6 coded the showroom field
still have to manage access
2016-11-26 21:18:06 +01:00
Bachir Soussi Chiadmi 597e6c9159 first draft of custom materio showroom location, recording values DOESN'T WORK 2016-11-22 19:12:02 +01:00
Bachir Soussi Chiadmi b26db27098 patched loggintobogan fixed bug against field_permissions
removed field_collection (gonna dev own custom modules for showroom
updated field-permissions to last dev
2016-11-22 19:05:44 +01:00
Bachir Soussi Chiadmi b9ac935de6 with last commit: contrib field_collection mod & custom showroom et translator mods 2016-11-21 19:42:00 +01:00
Bachir Soussi Chiadmi 091c01ce81 updated features : created showroom_localisation field. Perms with showroom role are still failing 2016-11-21 19:39:50 +01:00
Bachir Soussi Chiadmi 039f49aded updated amdin content-types showroom features 2016-11-21 15:32:15 +01:00
Bachir Soussi Chiadmi cc295255a1 Merge branch 'translators' into showroom 2016-11-21 10:50:21 +01:00
Bachir Soussi Chiadmi fedd8f4216 updated Fast permission admin module to last dev 2016-11-21 10:35:49 +01:00
Bachir Soussi Chiadmi 73f871cbcc added translate link to admin view 2016-11-07 17:29:00 +01:00
Bachir Soussi Chiadmi 0f286a2d78 css language switcher for more than 2 languages 2016-11-07 16:32:29 +01:00
Bachir Soussi Chiadmi ac87a57196 created translations feature 2016-11-07 16:31:32 +01:00
Bachir Soussi Chiadmi b00f897952 fixed images display bug in admin 2016-11-07 14:01:48 +01:00
Bachir Soussi Chiadmi 99f92edb37 updatedadmin feature 2016-11-07 13:15:03 +01:00
Bachir Soussi Chiadmi d0566a6155 tryig to fix admin feature 2016-11-07 13:12:59 +01:00
Bachir Soussi Chiadmi 0bf7b4a1c8 added companies views in admin feature 2016-11-07 13:00:45 +01:00
Bachir Soussi Chiadmi 2f02bb6485 fixed niouseletter on mobile 2016-11-07 12:18:15 +01:00
Bachir Soussi Chiadmi a477dbb8ec updated features 2016-11-07 10:51:20 +01:00
Bachir Soussi Chiadmi d4fee57337 removed TAC dependency form showroom feature 2016-11-07 09:56:29 +01:00
Bachir Soussi Chiadmi c97d1d7f75 updated features for showroom 2016-11-06 21:32:21 +01:00
Bachir Soussi Chiadmi c7e2de9e8b updated permission admin feature for showroom 2016-11-06 19:48:20 +01:00
Bachir Soussi Chiadmi cc000ce3d6 updated content admin views for showroom 2016-11-06 19:45:15 +01:00
Bachir Soussi Chiadmi 7abf64be00 Showroom feature 2016-11-06 19:40:18 +01:00
Bachir Soussi Chiadmi e8cadc31e1 patched link module to allow more tld
https://www.drupal.org/node/2299657#comment-11414075
http://studio.g-u-i.net/en/materio/node/1524#comment-2488
2016-11-05 19:53:24 +01:00
Bachir Soussi Chiadmi 7011e6c691 reverted node form columns du to scroll bug
http://studio.g-u-i.net/en/materio/node/1535
2016-11-05 19:22:53 +01:00
Bachir Soussi Chiadmi c70a4bed11 updated serial field 2016-11-05 17:58:43 +01:00
Bachir Soussi Chiadmi 252abe9b0e updated synonyms to 1.5 2016-11-05 17:54:56 +01:00
Bachir Soussi Chiadmi 773e7fbddd updated synonyms to 1.4 2016-11-05 17:53:45 +01:00
Bachir Soussi Chiadmi 8d24211bf5 updated synonyms to 1.3 2016-11-05 17:52:37 +01:00
Bachir Soussi Chiadmi 86c993f638 updated uc_termsofservice, session_limit 2016-11-05 17:26:29 +01:00
Bachir Soussi Chiadmi 08127672d6 updated wysiwyg_filter, video_filter 2016-11-05 17:23:03 +01:00
Bachir Soussi Chiadmi 66fa1d419d reverted webform_localization as it depends on webform 4.x 2016-11-05 17:19:33 +01:00
Bachir Soussi Chiadmi 0521608bb7 updated webform localization and phone, uuid, term_merge, spambot, performance 2016-11-05 17:14:57 +01:00
Bachir Soussi Chiadmi fdefc824d8 updated node_export, mimemail, menu_attributes 2016-11-05 17:09:40 +01:00
Bachir Soussi Chiadmi 2b028cf376 updated login-destination, libraries 2016-11-05 17:05:09 +01:00
Bachir Soussi Chiadmi d1963312a6 updated entity update 2016-11-05 16:55:34 +01:00
Bachir Soussi Chiadmi 3b6c7b914d updated view_send, vews_php, nodeformcols, email_registratio 2016-11-05 16:53:56 +01:00
Bachir Soussi Chiadmi 0bb339fc99 updated ubercart, faq 2016-11-05 16:50:18 +01:00
Bachir Soussi Chiadmi 3413d81bb8 updated context, metatag, imagestyleflush, browscap 2016-11-05 16:43:45 +01:00
Bachir Soussi Chiadmi 7aeabebddf updated imce, colorbox, admin_menu_source, honey_pot 2016-11-05 16:33:10 +01:00
Bachir Soussi Chiadmi 2e0abeed03 commented flag_lists failing updates
checked db table integrity, lokks like fine ...
2016-11-05 16:24:44 +01:00
Bachir Soussi Chiadmi 82bb633c3e updated contrib themes 2016-11-05 15:35:11 +01:00
Bachir Soussi Chiadmi 104fcaf970 removed unused search api page module 2016-11-05 14:59:48 +01:00
Bachir Soussi Chiadmi 34649ab98b finished security upadtes 2016-11-05 14:42:59 +01:00
Bachir Soussi Chiadmi 9c43ba2fc6 applied patch on user module
Implement language aware tokens for one time login link and cancel link
https://www.drupal.org/node/1754162
2016-11-01 18:24:53 +01:00
Bachir Soussi Chiadmi 1f780c974e updated drupal core to 7.51 2016-11-01 18:21:48 +01:00
Bachir Soussi Chiadmi 2ed8b48636 fixed compatibility with module flag_lists 3.x
converted materiobasemod js processor to gulp
2016-11-01 16:50:23 +01:00
Bachir Soussi Chiadmi d712e5881a load gui.js with module insted of theme 2016-11-01 16:47:25 +01:00
Bachir Soussi Chiadmi 253524c527 updated flag_list to 3.x version. ATTENTION DO NOT WORK ANYMORE create new folder broken 2016-10-25 20:12:36 +02:00
Bachir Soussi Chiadmi ae7349e811 updated entity translation, seems to don't need patch anymore 2016-10-25 18:32:11 +02:00
Bachir Soussi Chiadmi c64b25b261 repatched views module
is this realy necessary yet ?
didn't find where i found this fixe
2016-10-25 18:14:22 +02:00
Bachir Soussi Chiadmi 992c9a552a updated views 2016-10-25 17:59:47 +02:00
Bachir Soussi Chiadmi a2db826449 changed gitignore 2016-10-25 17:55:00 +02:00
Bachir Soussi Chiadmi b11abbed59 updated ctools, needed by panles 2016-10-25 17:47:45 +02:00
Bachir Soussi Chiadmi f6f7fd575f security updates of unpatched modules 2016-10-25 16:23:00 +02:00
Bachir Soussi Chiadmi 610760bedf updated features 2016-10-25 16:05:27 +02:00
Bachir Soussi Chiadmi 54399b169a created showroom feature 2016-10-25 16:05:07 +02:00
Bachir Soussi Chiadmi 598f3e8292 fixe email centering 2016-07-28 14:02:21 +02:00
Bachir Soussi Chiadmi 0347c5cb99 trying to fix daily mail not centered 2016-07-27 14:47:12 +02:00
Bachir Soussi Chiadmi 1f5092fb45 addded alt attribute on simplenews template img 2016-07-22 22:53:10 +02:00
Bachir Soussi Chiadmi 31d638cff7 addded alt attribute on simplenews template img 2016-07-22 22:52:36 +02:00
Bachir Soussi Chiadmi 31409daed2 added compser vendors for mailgun librarie 2016-07-19 20:40:37 +02:00
Bachir Soussi Chiadmi 42347006ff changed mailing feature 2016-07-19 20:17:47 +02:00
Bachir Soussi Chiadmi dd95b24f5b changed mailing feature 2016-07-19 20:14:04 +02:00
Bachir Soussi Chiadmi 507402d07b added mailing feature 2016-07-19 20:09:30 +02:00
Bachir Soussi Chiadmi e310490c7f added members sentence to simplenews daily template 2016-07-19 19:58:57 +02:00
Bachir Soussi Chiadmi 918b4cd5e1 added mailgun librarie 2016-07-19 19:58:07 +02:00
Bachir Soussi Chiadmi deae7e0b59 added mailgun module 2016-07-19 17:52:15 +02:00
Bachir Soussi Chiadmi c64551f50c removed the test.txt file as remote is working 2016-07-08 12:09:16 +02:00
Bachir Soussi Chiadmi 73793c9ba9 a commit to test the new remote prod serveur 2016-07-08 12:04:22 +02:00
Bachir Soussi Chiadmi d38e929be5 fixed img max-width on simplenews 2016-06-24 11:12:32 +02:00
Bachir Soussi Chiadmi 266fb10083 fixed img max-width on simplenews 2016-06-24 11:10:09 +02:00
Bachir Soussi Chiadmi 6fee348360 fixed mobile responsive display 2016-06-15 13:28:12 +02:00
Bachir Soussi Chiadmi 74f8c52af3 fixed mobile responsive display 2016-06-15 13:22:05 +02:00
Bachir Soussi Chiadmi 9c97849d78 added metatag feature 2016-06-13 19:53:16 +02:00
Bachir Soussi Chiadmi 2ca9694d84 added social links block 2016-06-13 19:14:58 +02:00
Bachir Soussi Chiadmi 422322c96d bug fix : print with only one image
http://studio.g-u-i.net/fr/materio/node/1523
2016-06-13 15:14:54 +02:00
Bachir Soussi Chiadmi aea9683c77 updated link module 2016-04-19 16:40:02 +02:00
Bachir Soussi Chiadmi e2fde76aff updated features 2016-04-19 16:32:54 +02:00
Bachir Soussi Chiadmi fb0666538c updated user_import 2016-04-19 16:29:53 +02:00
Bachir Soussi Chiadmi 3a55dcea49 fixed pager 2016-03-29 13:05:38 +02:00
Bachir Soussi Chiadmi 39dc81ad14 fixed and refactored solr search main function 2016-03-29 12:42:22 +02:00
Bachir Soussi Chiadmi 7b11f2794e fixed bug js missing gui.js function trace() 2016-03-16 18:01:53 +01:00
Bachir Soussi Chiadmi c23706f745 updated PATCH_LIST 2016-03-16 16:59:24 +01:00
Bachir Soussi Chiadmi c47d792cd1 field_group security update 2016-03-16 16:57:22 +01:00
Bachir Soussi Chiadmi d7697f0f76 repatched user module
https://www.drupal.org/node/1754162
2016-03-16 16:44:57 +01:00
Bachir Soussi Chiadmi b27aabe359 updated drupal core to 7.43 2016-03-16 16:41:44 +01:00
Bachir Soussi Chiadmi 8fb9c70e42 updated faq feature 2016-03-16 16:10:24 +01:00
Bachir Soussi Chiadmi 1658e609f8 updated materio_feature 2016-03-16 16:01:35 +01:00
Bachir Soussi Chiadmi e36279d8b1 changed materio_serach_api, query configuration by query 2016-03-16 12:35:55 +01:00
Bachir Soussi Chiadmi 0b6e0c10cb updated search feature 2016-03-02 10:15:50 +01:00
Bachir Soussi Chiadmi ba1ec7113e updated search_api and search_api_solr 2016-03-01 16:23:45 +01:00
Bachir Soussi Chiadmi deb2bff572 print fine tuning 2016-01-21 12:02:55 +01:00
Bachir Soussi Chiadmi 538c791bae fine tunning print fiche 2016-01-20 18:15:38 +01:00
Bachir Soussi Chiadmi df107a0443 fixed printed material
WARNING : we are nox using gulp instead of grunt, watch for bugs
2016-01-19 19:23:16 +01:00
Bachir Soussi Chiadmi c9b16289ef added remove duplicates modules 2016-01-19 15:10:33 +01:00
Bachir Soussi Chiadmi b4acd7d8bb updated video filter module to handle https on embeded videos 2015-12-20 10:56:50 +01:00
Bachir Soussi Chiadmi 3af02617b4 added html5 boiler plate mime headers to htaccess 2015-12-19 21:36:40 +01:00
Bachir Soussi Chiadmi 0fdb4abd71 ajax autocomplete fixe 2015-12-03 12:23:53 +01:00
Bachir Soussi Chiadmi 90be34eef1 updated htaccess 2015-12-02 17:17:06 +01:00
Bachir Soussi Chiadmi 3e984dc6c5 updated htaccess 2015-12-02 17:13:13 +01:00
Bachir Soussi Chiadmi a0cb0b2171 updated htaccess 2015-12-02 16:57:17 +01:00
Bachir Soussi Chiadmi f6346b0195 updated htaccess 2015-12-02 16:52:56 +01:00
Bachir Soussi Chiadmi 300f698989 updated htaccess 2015-12-02 16:46:36 +01:00
Bachir Soussi Chiadmi 8cbb5f8c4c updated htaccess 2015-12-02 16:45:51 +01:00
Bachir Soussi Chiadmi a106b98209 updated htaccess 2015-12-02 16:30:59 +01:00
Bachir Soussi Chiadmi 8fe92dbcc7 updated htaccess 2015-12-02 16:29:02 +01:00
Bachir Soussi Chiadmi 60f2c5c7fa updated htaccess 2015-12-02 15:20:02 +01:00
Bachir Soussi Chiadmi d96c17454b updated htaccess 2015-12-02 11:40:34 +01:00
Bachir Soussi Chiadmi ed6ae84181 added ubercart ssl module 2015-12-02 11:36:55 +01:00
Bachir Soussi Chiadmi 35e914df58 created admon taxo view 2015-11-25 11:34:49 +01:00
Bachir Soussi Chiadmi 6b46869a16 htaccess : all redirects are handle by claranet 2015-11-25 09:47:27 +01:00
Bachir Soussi Chiadmi 892dba801f added entity_translation_export_import module 2015-11-25 00:53:33 +01:00
Bachir Soussi Chiadmi 50dfd2d89b removed i18n_taxonomy module from features dependencies
fixed some bugs
2015-11-24 23:50:19 +01:00
Bachir Soussi Chiadmi 9a18821b7e fixed search api materio settings 2015-11-24 18:17:34 +01:00
Bachir Soussi Chiadmi 82bf36a5eb recreated features 2015-11-24 18:05:48 +01:00
Bachir Soussi Chiadmi 3eb20676ca search api autocomplet t() for transmlate term name 2015-11-24 16:51:48 +01:00
Bachir Soussi Chiadmi 2155a66eb1 added special menu items module 2015-11-24 15:29:54 +01:00
Bachir Soussi Chiadmi 62fef652fc removed redirects from htaccess, claranet will handle this on vhosts 2015-11-24 15:15:10 +01:00
Bachir Soussi Chiadmi 951c9114a2 added code for remove all http on file address 2015-11-24 13:42:37 +01:00
Bachir Soussi Chiadmi edba04f103 htaccess fixe 2015-11-24 13:23:18 +01:00
Bachir Soussi Chiadmi 26ab9aa56b htaccess fixe 2015-11-24 13:22:11 +01:00
Bachir Soussi Chiadmi 5716acf5bb htaccess fixe 2015-11-24 13:20:51 +01:00
Bachir Soussi Chiadmi 12fe570fbd htaccess fixe 2015-11-24 13:20:11 +01:00
Bachir Soussi Chiadmi 66ee9c6657 htaccess fixe 2015-11-24 13:19:01 +01:00
Bachir Soussi Chiadmi ca5231f1fe htaccess fixe 2015-11-24 13:09:04 +01:00
Bachir Soussi Chiadmi b9a8db8140 htaccess fixe 2015-11-24 13:08:22 +01:00
Bachir Soussi Chiadmi d25e7428bc htaccess fixe 2015-11-24 12:55:37 +01:00
Bachir Soussi Chiadmi 3027b3985b htaccess fixe 2015-11-24 12:55:09 +01:00
Bachir Soussi Chiadmi d214a44291 htaccess fixe 2015-11-24 12:49:06 +01:00
Bachir Soussi Chiadmi fc7753f7a0 htaccess fixe 2015-11-24 12:48:26 +01:00
Bachir Soussi Chiadmi 7c51b255fb htaccess fixe 2015-11-24 12:47:26 +01:00
Bachir Soussi Chiadmi 5e099d48de htaccess fixe 2015-11-24 12:35:16 +01:00
Bachir Soussi Chiadmi bf84ac06cd htaccess fixe 2015-11-24 12:34:56 +01:00
Bachir Soussi Chiadmi 87beabee92 htaccess fixe 2015-11-24 12:29:51 +01:00
Bachir Soussi Chiadmi f6ee366a71 htaccess fixe 2015-11-24 12:29:32 +01:00
Bachir Soussi Chiadmi b216e30f28 htaccess fixe 2015-11-24 12:28:04 +01:00
Bachir Soussi Chiadmi 0a863fc1bb htaccess ssl 2015-11-24 12:26:56 +01:00
Bachir Soussi Chiadmi a5edc41323 htaccess fixe 2015-11-24 12:12:57 +01:00
Bachir Soussi Chiadmi 1cc2c9af75 updated term csv files 2015-11-24 11:17:12 +01:00
Bachir Soussi Chiadmi cc653b73be bug fixe 2015-11-24 11:02:29 +01:00
Bachir Soussi Chiadmi 73993a539b added fr2en batch function 2015-11-24 10:59:13 +01:00
Bachir Soussi Chiadmi d7e7410950 added term_merge module 2015-11-24 10:56:30 +01:00
Bachir Soussi Chiadmi 7298235d4f added taxonomy wrangler module 2015-11-23 14:47:44 +01:00
Bachir Soussi Chiadmi fc0a779214 fixed bookmarks for students 2015-10-21 20:22:58 +02:00
Bachir Soussi Chiadmi 248c5ed3e1 added search form back bouton 2015-10-21 19:43:37 +02:00
Bachir Soussi Chiadmi ace9de07e2 started base home back btn 2015-10-21 17:44:29 +02:00
Bachir Soussi Chiadmi 7ad1f5dc67 patched i18n modules for node don't record chosen language on create
see https://www.drupal.org/node/1852102#comment-9612303
2015-10-14 17:15:19 +02:00
Bachir Soussi Chiadmi d5628cc78e updated entity_translation to last dev version 2015-10-14 17:09:13 +02:00
Bachir Soussi Chiadmi 81371521c7 updated gitignore to ignore .directory files 2015-10-14 17:03:08 +02:00
Bachir Soussi Chiadmi eb699f528d updated date pathauto addressfield honeypot features modules 2015-10-12 12:03:12 +02:00
Bachir Soussi Chiadmi 0ba0c21bb9 upadated colorbox andd prod_check 2015-10-12 11:52:36 +02:00
Bachir Soussi Chiadmi 50c3e1c7d7 added list of deleted entities from flag list content 2015-09-27 19:50:44 +02:00
Bachir Soussi Chiadmi f0cb6175c1 patched flag list to trigger remove entity from lists when this entity is deleted 2015-09-27 18:55:26 +02:00
Bachir Soussi Chiadmi e004b7a238 patched node-export module
https://www.drupal.org/node/1869918
https://www.drupal.org/node/1911638
2015-09-18 14:54:38 +02:00
Bachir Soussi Chiadmi f7cd9c0858 ran security updates on contrib modules
ctools, video_embed_field, migrate, views_bulk_operations
2015-09-17 14:44:25 +02:00
Bachir Soussi Chiadmi 5d30d9bcee repatched user module
Implement language aware tokens for one time login link and cancel link
https://www.drupal.org/node/1754162
2015-09-17 13:59:26 +02:00
Bachir Soussi Chiadmi c4f2e62697 core update from 7.37 to 7.38 2015-09-17 13:08:35 +02:00
Bachir Soussi Chiadmi a99f2d7aa6 fixed rss media notification
https://www.drupal.org/node/2472409
2015-09-16 16:34:31 +02:00
Bachir Soussi Chiadmi 4e8346e5e3 fixed weight field rights for admin 2015-07-21 18:04:54 +02:00
Bachir Soussi Chiadmi 5b281024a5 added database link on home for members 2015-07-21 15:58:56 +02:00
Bachir Soussi Chiadmi 96903cab02 fixed some header display 2015-07-17 18:18:01 +02:00
Bachir Soussi Chiadmi ce20bb3f0f fixed some header display 2015-07-17 18:05:02 +02:00
Bachir Soussi Chiadmi 19d3d90743 fixed publication node display 2015-07-17 17:56:35 +02:00
Bachir Soussi Chiadmi 62fec82217 fixed printed cards 2015-07-16 17:08:15 +02:00
Bachir Soussi Chiadmi f0295847f9 fixed icon alignement on header's blocks 2015-07-16 16:21:27 +02:00
Bachir Soussi Chiadmi cc657eaec4 added publications links and display of pubications pages 2015-07-16 15:46:48 +02:00
Bachir Soussi Chiadmi 54f496acad added contact footer on home V2 2015-07-16 15:02:15 +02:00
Bachir Soussi Chiadmi feef7951cd removed img max width on simplenews nodes 2015-07-07 22:32:49 +02:00
Bachir Soussi Chiadmi 8def2961ac updated user export materio module 2015-07-07 22:11:34 +02:00
Bachir Soussi Chiadmi 1c38e1b72a added fixed width for simplenews node type 2015-07-07 18:49:42 +02:00
Bachir Soussi Chiadmi 0446c17ad1 added home visibility field to simplenews content type and one more filtre on homeV2 view for news letter 2015-07-03 10:56:26 +02:00
Bachir Soussi Chiadmi 459335fee1 removed front-page module 2015-07-03 10:31:06 +02:00
Bachir Soussi Chiadmi 408251fd28 admin features remoced front-page dependencie 2015-07-03 10:28:35 +02:00
Bachir Soussi Chiadmi 98d1b5cb03 fixed front for member display 2015-07-02 20:14:15 +02:00
Bachir Soussi Chiadmi 141d1f4b5c added front by role 2015-07-02 20:08:33 +02:00
Bachir Soussi Chiadmi 100dce022a some display 2015-07-02 19:38:33 +02:00
Bachir Soussi Chiadmi 3220ed8e4b fixed login redirection from login block and improved design of this block 2015-07-02 19:24:43 +02:00
Bachir Soussi Chiadmi 22146c2778 fixed viewmode change bug 2015-07-02 18:34:27 +02:00
Bachir Soussi Chiadmi f4b8bfa249 removed newsletters which user doesn't have access to 2015-06-26 19:24:47 +02:00
Bachir Soussi Chiadmi 4c32c73321 added user export page for simplenews unsubscription 2015-06-26 18:42:45 +02:00
Bachir Soussi Chiadmi 09d1f06552 fixed some display bug 2015-06-24 17:20:14 +02:00
Bachir Soussi Chiadmi ade4a41f76 fixed user profile form display 2015-06-24 16:29:54 +02:00
Bachir Soussi Chiadmi 19b1d49a22 applied fixe width to all page exept /actuality and /explore 2015-06-24 16:00:38 +02:00
Bachir Soussi Chiadmi 4264a271b4 added simple_pass_reset module 2015-06-24 15:48:23 +02:00
Bachir Soussi Chiadmi de040b46ea re-add linked materials on actuality page for visitors, in big card viewmode 2015-06-23 16:33:05 +02:00
Bachir Soussi Chiadmi aa323869c3 display none links on home regarding logged-in or not 2015-06-18 18:34:20 +02:00
Bachir Soussi Chiadmi 22e93d650e added class field to page links field 2015-06-18 18:26:30 +02:00
Bachir Soussi Chiadmi 2664d2fcfd fixed localisation link display 2015-06-18 18:01:03 +02:00
Bachir Soussi Chiadmi feb93503b6 fixed hash encoding bug with chrome between tarifs page and register form 2015-06-18 17:43:16 +02:00
Bachir Soussi Chiadmi 2d5be00cf1 improved mobile display 2015-06-17 19:25:33 +02:00
Bachir Soussi Chiadmi a84cd67456 improved mobile display 2015-06-17 19:23:41 +02:00
Bachir Soussi Chiadmi 8a1f5cd116 improved mobile display 2015-06-17 19:21:32 +02:00
Bachir Soussi Chiadmi 65c7ab92b6 fixed skrollr for mobile, added skrollrbody option in init 2015-06-17 18:49:11 +02:00
Bachir Soussi Chiadmi 1c1de98039 bug fixe 2015-06-15 20:53:06 +02:00
Bachir Soussi Chiadmi 2e4a069036 fixed some display 2015-06-15 18:15:53 +02:00
Bachir Soussi Chiadmi cc8306bc14 fixed forms display 2015-06-15 17:47:06 +02:00
Bachir Soussi Chiadmi d107702f86 updated pricing page 2015-06-15 17:34:54 +02:00
Bachir Soussi Chiadmi f9144db774 removed linked materials from actuality page 2015-06-15 15:32:05 +02:00
Bachir Soussi Chiadmi 1ca1912fe2 added card behaviour to news on homeV2 2015-06-15 15:13:04 +02:00
Bachir Soussi Chiadmi 1657634e1a fixed the right color background for video home 2015-06-15 14:06:34 +02:00
Bachir Soussi Chiadmi a908bb02ca removed beta 2015-06-15 14:00:44 +02:00
Bachir Soussi Chiadmi 4eadc1b771 removed translation link from publications 2015-06-15 12:21:31 +02:00
Bachir Soussi Chiadmi ce2f811278 added new window option for page link field 2015-06-15 12:08:23 +02:00
Bachir Soussi Chiadmi 1c42c93c54 removed some dsm 2015-06-15 11:51:12 +02:00
Bachir Soussi Chiadmi 71744db508 added rights for simplenews subscriptions by roles 2015-06-15 11:48:45 +02:00
Bachir Soussi Chiadmi 3add8f6b96 added weight field to publications 2015-06-14 19:35:34 +02:00
Bachir Soussi Chiadmi 678343b0e9 home v2 2015-06-10 19:27:56 +02:00
Bachir Soussi Chiadmi 5485f80dae home v2 2015-06-10 19:26:56 +02:00
Bachir Soussi Chiadmi 6df0ebfa53 home v2 2015-06-10 19:25:08 +02:00
Bachir Soussi Chiadmi 9521fc1ce5 home v2 2015-06-10 19:22:26 +02:00
Bachir Soussi Chiadmi 1f1247a226 home v2 2015-06-10 19:21:34 +02:00
Bachir Soussi Chiadmi b05c9a53c5 home v2: upadted features 2015-06-10 19:18:11 +02:00
Bachir Soussi Chiadmi b2d9b7dbf7 home v2: fixed simple news sub display 2015-06-10 19:05:00 +02:00
Bachir Soussi Chiadmi 98bc1dfef8 home v2: fixed simple news sub display 2015-06-10 19:01:12 +02:00
Bachir Soussi Chiadmi d35191a96e home v2: hide simple news from register block 2015-06-10 18:59:23 +02:00
Bachir Soussi Chiadmi 2fd09f23e9 home v2: added register block and newsletter subscription 2015-06-10 18:50:27 +02:00
Bachir Soussi Chiadmi 181a28cd85 fixed link display home v2 2015-06-10 17:47:49 +02:00
Bachir Soussi Chiadmi d5155b3b31 added links to home v2 2015-06-10 17:01:47 +02:00
Bachir Soussi Chiadmi 32f26b4bf5 added links to home v2 2015-06-10 16:57:35 +02:00
Bachir Soussi Chiadmi 1b9752f495 updated admin for publication 2015-06-10 16:17:54 +02:00
Bachir Soussi Chiadmi afd3a90538 upadted home V2 2015-06-10 15:53:49 +02:00
Bachir Soussi Chiadmi 96aef8c128 home v2 fixed menu links display 2015-06-09 18:08:38 +02:00
Bachir Soussi Chiadmi 73741839ca home v2 update 2015-06-09 18:03:11 +02:00
Bachir Soussi Chiadmi 8a8ed4f929 updated publication feature 2015-06-03 20:09:11 +02:00
Bachir Soussi Chiadmi e12a664fa5 added publications and some skrollr animations to home v2 2015-06-03 20:06:35 +02:00
Bachir Soussi Chiadmi 6ceb7d6534 added workflow strongarm variable to admin feature 2015-06-03 17:12:25 +02:00
Bachir Soussi Chiadmi 3ffbc09c10 big update for home v2 2015-06-03 17:02:24 +02:00
Bachir Soussi Chiadmi 49004d7fee repatched views module 2015-05-26 20:01:49 +02:00
Bachir Soussi Chiadmi 706c96d663 updated modules
views friendly_register serial address_field i18n
2015-05-26 19:56:22 +02:00
Bachir Soussi Chiadmi c9f8dc21ed updated loggintobogan 2015-05-26 19:48:46 +02:00
Bachir Soussi Chiadmi 59cec97bcf updated patch lists 2015-05-26 19:45:37 +02:00
Bachir Soussi Chiadmi c2a05d8ab3 repatched user module
Implement language aware tokens for one time login link and cancel link
https://www.drupal.org/node/1754162
2015-05-26 19:34:57 +02:00
Bachir Soussi Chiadmi f75cb5562c updated core to 7.37 2015-05-26 19:28:47 +02:00
Bachir Soussi Chiadmi 342655bf2b updated publication feature 2015-05-26 18:45:25 +02:00
Bachir Soussi Chiadmi f9f0ce54ec Merge branch 'homeV2' of https://bitbucket.org/bachysoucy/materio-base-d7 into homeV2 2015-05-26 18:30:49 +02:00
Bachir Soussi Chiadmi 0c29476b3f updated features for home v2 2015-05-26 18:24:48 +02:00
sarah garcin c183a0b0dd add scrollto function 2015-05-26 18:14:30 +02:00
sarah garcin ea423f2146 add images funky 2015-05-26 16:15:22 +02:00
Bachir Soussi Chiadmi 580c97dc49 fixed frontend search field bad display 2015-05-26 12:39:32 +02:00
sarah garcin 95cbb13821 theming new materio Home css 2015-05-20 17:08:18 +02:00
Bachir Soussi Chiadmi ddae683ff3 removed pays filtre from admin view company 2015-05-19 19:52:31 +02:00
Bachir Soussi Chiadmi c90787212b materiau print page css 2015-05-19 19:14:40 +02:00
Bachir Soussi Chiadmi 81ea02bb3e Merge branch 'homeV2' into prod 2015-05-19 15:03:05 +02:00
Bachir Soussi Chiadmi d9f6370962 admin feature
added admin the right to add premium role
2015-05-19 14:11:04 +02:00
sarah garcin 40e4643644 start theming home v2 2015-05-19 14:01:51 +02:00
sarah garcin 76c59dc2a9 change home v2 feature, add class 2015-05-19 14:01:06 +02:00
Bachir Soussi Chiadmi ae3b3d3895 scss
added ascii art
fixed some media querys for mobile
2015-05-18 19:03:00 +02:00
Bachir Soussi Chiadmi d858f00e17 removed obsolete mixins
like pb() pl() mb() bgc() bgca()
2015-05-18 17:42:53 +02:00
Bachir Soussi Chiadmi f28719a994 fixed gruntfile, fixed modal buttons, fixed .gitignore .sass-cache folder 2015-05-18 16:32:24 +02:00
Bachir Soussi Chiadmi 922a2da1e5 Merge branch 'prod' into homeV2 2015-05-18 14:43:16 +02:00
Bachir Soussi Chiadmi 26bb2de5b8 updated feature admin
added materiau localisation exposed filtre
2015-05-18 14:33:58 +02:00
Bachir Soussi Chiadmi e4b76f4756 fixed libraries mis-path bug from theme refactoring 2015-05-16 15:29:08 +02:00
Bachir Soussi Chiadmi 2686166df2 Merge branch 'theme-refactoring' of https://bitbucket.org/bachysoucy/materio-base-d7 into homeV2 2015-05-16 14:51:57 +02:00
Bachir Soussi Chiadmi 1f211d5348 Merge branch 'prod' into homeV2 2015-05-16 14:51:35 +02:00
Bachir Soussi Chiadmi b3c85e79c6 improved mandrill callback 2015-05-16 14:50:28 +02:00
Bachir Soussi Chiadmi 2ffa37fefa updated home V2 feature 2015-05-16 14:24:02 +02:00
Bachir Soussi Chiadmi 70151f23e1 added home v2 feature 2015-05-15 09:44:14 +02:00
Bachir Soussi Chiadmi 79bd95aeec Merge branch 'theme-refactoring' into homeV2 2015-05-15 09:42:23 +02:00
Bachir Soussi Chiadmi 3a53525bf9 fixed title localisation display on admin views 2015-05-14 19:23:45 +02:00
Bachir Soussi Chiadmi 54787232fb upadted users admin view after uc_roles patch 2015-05-13 14:29:05 +02:00
Bachir Soussi Chiadmi 69c5b7ee5c patche ubercart to add expiration date field on views
https://www.drupal.org/node/419700
2015-05-13 13:18:06 +02:00
Bachir Soussi Chiadmi 8d141a61e0 updated navigation menu 2015-05-11 16:05:53 +02:00
Bachir Soussi Chiadmi 19a68f970e removed credit card from ubercart 2015-05-11 15:21:34 +02:00
Bachir Soussi Chiadmi de8f5e4ccc created materio rss feature 2015-05-11 15:13:37 +02:00
Bachir Soussi Chiadmi 442d89c948 updated and patched views_php to fixe the pager bug
https://www.drupal.org/node/2484407
2015-05-11 14:33:53 +02:00
Bachir Soussi Chiadmi 3adb83ccf7 added site/all/translations to .gitignore 2015-05-07 12:08:44 +02:00
Bachir Soussi Chiadmi 68b11d7a9b fix elysia_cron icons bug
see patch https://www.drupal.org/node/2096571
2015-05-07 12:05:46 +02:00
sarah garcin 58e171be01 clean directory 2015-05-06 15:48:01 +02:00
sarah garcin da4d135279 librairies to bower 2015-05-06 15:05:01 +02:00
sarah garcin 1313e1f0e2 debug css 2015-05-06 15:04:39 +02:00
sarah garcin e4885c3a5d add custom materio icon 2015-05-06 12:36:27 +02:00
Bachir Soussi Chiadmi f8a18606ba added watchdog mandrill result hook 2015-05-06 11:09:06 +02:00
Bachir Soussi Chiadmi 23b96ab26f grrrrr 2015-05-05 19:12:51 +02:00
Bachir Soussi Chiadmi 8c920e81df grrrrr 2015-05-05 19:10:25 +02:00
Bachir Soussi Chiadmi 202993e68e grrrrr 2015-05-05 19:08:05 +02:00
Bachir Soussi Chiadmi 8589ce7c28 grrrrr 2015-05-05 19:06:47 +02:00
Bachir Soussi Chiadmi 17580e8eba grrrrr 2015-05-05 19:06:01 +02:00
Bachir Soussi Chiadmi ca9530466a grrrrr 2015-05-05 18:42:39 +02:00
Bachir Soussi Chiadmi 31ede7287a grrrrr 2015-05-05 18:41:34 +02:00
Bachir Soussi Chiadmi be2054c163 grrrrr 2015-05-05 18:36:26 +02:00
Bachir Soussi Chiadmi a20d86efbf bug fixed 2015-05-05 18:32:32 +02:00
Bachir Soussi Chiadmi 0795a2a514 grrrrr 2015-05-05 18:27:34 +02:00
Bachir Soussi Chiadmi c92d7ed737 added simplenews_spool management to try to fix mandrill rejected bug 2015-05-05 18:26:12 +02:00
Bachir Soussi Chiadmi 923b407498 fixed mandatory address field on company nodes. + added node_modules to .gitignore 2015-05-05 12:08:23 +02:00
Bachir Soussi Chiadmi ceeefdd109 updated features (removed ubercart card payement dependencie) 2015-05-04 12:29:16 +02:00
sarah garcin a1fd56580b add icon 2015-05-01 16:31:29 +02:00
sarah garcin 23c085213e refactoring - transition + media queries - bug with icon and princing grid 2015-04-30 16:36:41 +02:00
sarah garcin 0ba300fe22 less to sass - need to integrate transition, button and media queries 2015-04-29 22:47:56 +02:00
sarah garcin 7763d08111 Merge branch 'theme-refactoring' of https://bitbucket.org/bachysoucy/materio-base-d7 into theme-refactoring 2015-04-29 11:12:19 +02:00
sarah garcin e1819172e9 clea, 2015-04-29 11:12:02 +02:00
Bachir Soussi Chiadmi 08b4b2dbbb installed grunt 2015-04-27 17:41:32 +02:00
sarah garcin 42940e2cff starting to convert style from less to sass 2015-04-27 14:51:27 +02:00
sarah garcin 9dfbaeb05a add bower 2015-04-27 14:50:11 +02:00
sarah garcin d69e29e3be gui.less to gui.scss 2015-04-27 14:49:40 +02:00
Bachir Soussi Chiadmi b85dc130d6 updated CER from 7.x-2.x-dev (2013-mai-01) to 7.x-2.x-dev (2014-aoû-08) 2015-04-20 20:26:13 +02:00
Bachir Soussi Chiadmi d8626dbb2d updated patched modules liste 2015-04-20 20:21:13 +02:00
Bachir Soussi Chiadmi 4d3a184a81 updated field_group from 1.3 to 7.x-1.4 2015-04-20 20:06:12 +02:00
Bachir Soussi Chiadmi eeb0df349d updated flag module to 7.x-3.6 (2015-mar-02) 2015-04-20 20:01:42 +02:00
Bachir Soussi Chiadmi 785dee0639 updated vieo_embed_field 2015-04-20 19:49:19 +02:00
Bachir Soussi Chiadmi 9afc105c7e updated nodeformcols module to 7.x-1.0 (2014-jan-15) 2015-04-20 19:39:05 +02:00
Bachir Soussi Chiadmi 0cd6215a32 upadted feedback module
didn't repatched it for email notification since rules hooks semmes to be added to the module
added the old patch for memory
2015-04-20 19:31:48 +02:00
Bachir Soussi Chiadmi c5028bffd3 updated and repatched search_api_solr module
no need for patch anymore
see https://www.drupal.org/node/1846860#comment-8137979
2015-04-20 19:22:33 +02:00
Bachir Soussi Chiadmi ca9413af4d updated and repatched search_api module
please check this thread : Decide on strategy for language aware search https://www.drupal.org/node/1393058
2015-04-20 19:18:35 +02:00
Bachir Soussi Chiadmi d3dcf44a1e updated features after last modules updates 2015-04-20 18:44:52 +02:00
Bachir Soussi Chiadmi 6737f9faa1 more module updates 2015-04-20 18:23:59 +02:00
Bachir Soussi Chiadmi 322dd995bf more module updates 2015-04-20 18:21:45 +02:00
Bachir Soussi Chiadmi cde7b73a73 more module updates 2015-04-20 18:19:49 +02:00
Bachir Soussi Chiadmi 2121a356b3 more module updates 2015-04-20 18:13:58 +02:00
Bachir Soussi Chiadmi 55b23a2cec more module updates 2015-04-20 18:07:22 +02:00
Bachir Soussi Chiadmi 134c8b8338 more module updates 2015-04-20 18:04:48 +02:00
Bachir Soussi Chiadmi 7c85261e56 more module updates 2015-04-20 18:02:17 +02:00
Bachir Soussi Chiadmi 37fbabab56 non security modules update 2015-04-20 16:32:07 +02:00
Bachir Soussi Chiadmi 6a8d30db08 updated print template for print module V2 2015-04-20 15:41:08 +02:00
Bachir Soussi Chiadmi d5a03170e4 upadted print module config 2015-04-20 15:36:24 +02:00
Bachir Soussi Chiadmi 36b5937b9e updated print module on contenttype feature 2015-04-20 15:17:51 +02:00
Bachir Soussi Chiadmi 49f9128c96 updated features 2015-04-20 15:10:48 +02:00
Bachir Soussi Chiadmi 46b448c2a2 removed editmenu module 2015-04-20 15:07:04 +02:00
Bachir Soussi Chiadmi 73186732c3 switch from edit menu to admin_menu with admin_menu_source for administrator 2015-04-20 14:57:52 +02:00
Bachir Soussi Chiadmi f71bfe281e bug fixe with print module V2 2015-04-20 13:09:47 +02:00
Bachir Soussi Chiadmi 9de02bab38 repatched includes/entity.inc
see https://www.drupal.org/node/1003788
2015-04-19 21:51:44 +02:00
Bachir Soussi Chiadmi 6719ca32c7 repatched user module
see https://www.drupal.org/node/1754162
2015-04-19 21:35:21 +02:00
Bachir Soussi Chiadmi e89afbf603 security update for addressfiled_token 2015-04-19 21:20:32 +02:00
Bachir Soussi Chiadmi a1856277e5 added patch to repos 2015-04-19 21:14:24 +02:00
Bachir Soussi Chiadmi 7becdeff92 repatched views module 2015-04-19 21:13:38 +02:00
Bachir Soussi Chiadmi f55c541343 added patch to repos 2015-04-19 21:13:13 +02:00
Bachir Soussi Chiadmi 1f82c4ef9b repatched entityrefeerence module 2015-04-19 21:04:36 +02:00
Bachir Soussi Chiadmi c0af9037e9 updated gitignore 2015-04-19 21:03:38 +02:00
Bachir Soussi Chiadmi b3221c71e2 security updates
have to check views and entityreference for custom patches
2015-04-19 20:45:16 +02:00
Bachir Soussi Chiadmi 802ec0c6f3 update core to 7.36 2015-04-19 19:33:23 +02:00
Bachir Soussi Chiadmi 6de56c702c added patched modules list 2015-04-19 17:46:58 +02:00
Bachir Soussi Chiadmi f2b8ace9b7 FINAL suepr merge step : added all modules to this super repos 2015-04-19 16:46:59 +02:00
Bachir Soussi Chiadmi 7b6bd36fea merged entity_translation_search_api submodule 2015-04-19 16:29:28 +02:00
Bachir Soussi Chiadmi 8dc0b20c89 merged idmaterio submodule 2015-04-19 16:23:19 +02:00
Bachir Soussi Chiadmi 87f453cf20 merged selectList submodule 2015-04-19 16:21:36 +02:00
Bachir Soussi Chiadmi 5594bacfa9 some js not commited a long time ago .... 2015-04-19 16:20:25 +02:00
Bachir Soussi Chiadmi 8d74b0bb06 merged filter_path_alias submodule 2015-04-19 16:18:02 +02:00
Bachir Soussi Chiadmi b285de8b3a merged migrate_materio submodule 2015-04-19 16:15:14 +02:00
Bachir Soussi Chiadmi 775d25dbcc merged contentadminrelink submodule 2015-04-19 16:12:49 +02:00
Bachir Soussi Chiadmi a181091a14 merged tode submodule 2015-04-19 16:10:08 +02:00
Bachir Soussi Chiadmi 72cf8934c3 merged editmenu submodule 2015-04-19 16:06:48 +02:00
Bachir Soussi Chiadmi 627216cb77 some css not commited a long time ago 2015-04-19 16:05:18 +02:00
Bachir Soussi Chiadmi 8ff8fcd8da merged search_api submodule 2015-04-19 16:01:08 +02:00
Bachir Soussi Chiadmi 178cfe05d0 merged search_api_solr submodule 2015-04-19 15:57:04 +02:00
Bachir Soussi Chiadmi 879cd137d5 merged search_api_page submodule 2015-04-19 15:54:49 +02:00
Bachir Soussi Chiadmi 7b975a5cab merged wysiwyg submodule 2015-04-19 15:51:20 +02:00
Bachir Soussi Chiadmi ad76968844 merged views submodule 2015-04-19 15:48:20 +02:00
Bachir Soussi Chiadmi c2252c8f9a merged term_reference_tree submodule 2015-04-19 15:37:07 +02:00
Bachir Soussi Chiadmi 1be1c89407 WARNING don't now where i am here :/ 2015-04-19 15:33:58 +02:00
Bachir Soussi Chiadmi aceb299147 merged entityreference submodule 2015-04-19 15:18:46 +02:00
Bachir Soussi Chiadmi 404757203b merged CER submodule 2015-04-19 15:13:02 +02:00
Bachir Soussi Chiadmi f0531608b7 merged field_group submodule. TODO test new version of field_group, IDs seem to be removed ... 2015-04-19 15:09:16 +02:00
Bachir Soussi Chiadmi 28db07faf7 merged flag_lists submodule. TODO a new version is officially available compatible with flag 3 branch, TEST IT! 2015-04-19 15:01:19 +02:00
Bachir Soussi Chiadmi 88c1012c48 merged feedback submodule 2015-04-19 13:55:49 +02:00
Bachir Soussi Chiadmi a494bb4627 merged materiobasemod submodule 2015-04-19 13:47:39 +02:00
Bachir Soussi Chiadmi 894a4849e0 aadded gui_ck_fw 2015-04-19 13:42:54 +02:00
Bachir Soussi Chiadmi 886114f49b merged features sudmodule 2015-04-19 13:34:58 +02:00
Bachir Soussi Chiadmi ae12eada47 changed gitignore first step of merging all subtrees second 2015-04-19 13:22:18 +02:00
Bachir Soussi Chiadmi 51cc1bb7b2 changed gitignore first step of merging all subtrees 2015-04-19 13:18:35 +02:00
Bachir Soussi Chiadmi f63556f674 new feature materio user import 2015-02-24 13:04:35 +01:00
Bachir Soussi Chiadmi 29079eeb84 updated all features with last database from inline 2015-02-23 11:27:47 +01:00
Bachir Soussi Chiadmi bf88fdf0b9 added RewriteBase to .htaccess 2014-12-08 11:59:20 +01:00
Bachir Soussi Chiadmi 265c4ab336 fixed vreve search for free users 2014-10-31 19:12:53 +01:00
Bachir Soussi Chiadmi c36797f2bb splited search in two steps, 1 only taxonomy, 2 full text less 1 2014-10-22 20:30:29 +02:00
Bachir Soussi Chiadmi e5b63e455f removed advanced search code 2014-10-21 19:08:52 +02:00
Bachir Soussi Chiadmi ab1e9ae0ff bugfixe : index on advanced search tree was wrong, wasn't tid 2014-10-03 17:28:16 +02:00
Bachir Soussi Chiadmi 6b3f29142b removed a dsm() 2014-10-03 17:22:06 +02:00
Bachir Soussi Chiadmi 77450f1aad removed a dsm() 2014-10-03 17:18:44 +02:00
Bachir Soussi Chiadmi 11617ec99c advanced search :
separate tree terms generation and form generation
fixed a php notice
2014-10-03 16:48:07 +02:00
Bachir Soussi Chiadmi d1b96a77a6 feature admin : added navigation menu link items 2014-10-01 19:01:43 +02:00
Bachir Soussi Chiadmi 077d83613e bugfixe : companies page fixe views bug (relation) 2014-10-01 18:54:10 +02:00
Bachir Soussi Chiadmi d2cffdeddd improved better search
activated terms filtration regarding useinadvancedsearch term field
added all children of level 2 terms
2014-09-27 13:02:00 +08:00
Bachir Soussi Chiadmi 4237cb8edb bugfixe
= []; is not working on production server
2014-09-27 10:03:18 +08:00
Bachir Soussi Chiadmi 88d4cf09dc Merge branch 'bettersearch' into prod
added advanced to prod branch for inline production
2014-09-27 09:58:24 +08:00
Bachir Soussi Chiadmi 1cc9a63c46 code cleaning 2014-09-27 09:58:09 +08:00
Bachir Soussi Chiadmi 0bba2d0657 bugfixe : i18n was filtrering to much terms with taxonomy_get_tree
fixed in materio_taxonomy module with query alter
2014-09-16 21:09:06 +08:00
Bachir Soussi Chiadmi 8e138e1153 bugfix 2014-09-16 16:51:00 +08:00
Bachir Soussi Chiadmi ccb121e83a bugfix: location change on webform adhesion block the form
-> do not fill default value if form is rebuilded
2014-09-16 16:48:13 +08:00
Bachir Soussi Chiadmi 8f54fcd944 some changes in the form structure 2014-09-16 16:46:55 +08:00
Bachir Soussi Chiadmi 98f738f951 cleaning : removed some whitespaces 2014-09-10 21:05:17 +08:00
Bachir Soussi Chiadmi ef50154a49 bugfixe : autocomplete and guillemets 2014-09-10 21:04:02 +08:00
Bachir Soussi Chiadmi 982122065e bugfix : floders on preview mode 2014-09-10 19:51:39 +08:00
Bachir Soussi Chiadmi 80e491f1d8 fixed country ID on uc_checkout_form 2014-09-05 16:10:29 +02:00
Bachir Soussi Chiadmi c5f5eb4f64 added some comments 2014-09-05 11:37:36 +02:00
Bachir Soussi Chiadmi 7d410e8393 updated subscription : removed coupons 2014-09-04 14:31:37 +02:00
Bachir Soussi Chiadmi afce4662bd fixe 2014-09-03 14:14:19 +02:00
Bachir Soussi Chiadmi ab40bcf861 commented some dsm 2014-09-02 17:04:04 +02:00
Bachir Soussi Chiadmi 497a0108ae added phone field to subbscription form and billing form 2014-08-28 16:42:57 +02:00
Bachir Soussi Chiadmi 9f3444676a features : Materio content type 2014-08-27 16:13:36 +02:00
Bachir Soussi Chiadmi 0545fabe49 features : updated permissions for User Test UC 2014-08-27 16:04:47 +02:00
Bachir Soussi Chiadmi 37ac75fc59 features : Materio Subscriptions
updated permissions for User Test UC
2014-08-27 15:54:13 +02:00
Bachir Soussi Chiadmi 6fdb4e0dc9 setup solr properties for advanced search 2014-08-27 15:27:15 +02:00
Bachir Soussi Chiadmi 124e1a7bc2 created advanced search form 2014-07-29 12:27:02 +02:00
Bachir Soussi Chiadmi 7ee6c9dc12 created advanced search block 2014-07-16 17:09:23 +02:00
Bachir Soussi Chiadmi e9a136db4c added admin settings for advanced search 2014-07-16 17:07:56 +02:00
Bachir Soussi Chiadmi f515e148f4 updated subscriptions 2014-07-15 20:40:46 +02:00
Bachir Soussi Chiadmi aed0b98da2 updated administration feature 2014-07-15 20:39:51 +02:00
Bachir Soussi Chiadmi ccd86a08a4 updated subscriptions 2014-07-15 20:21:38 +02:00
Bachir Soussi Chiadmi 8f32d4e98b fixed a message again 2014-07-15 20:02:50 +02:00
Bachir Soussi Chiadmi e82e3250b3 fixed a typo 2014-07-15 19:53:17 +02:00
Bachir Soussi Chiadmi 2e1e0cc05b improved the message to people who access to the serach tool without an account
cf link from daily materiO'
2014-07-15 19:45:08 +02:00
Bachir Soussi Chiadmi 488d4c19aa removed a dsm() 2014-07-15 19:43:43 +02:00
Bachir Soussi Chiadmi ce18a79a80 fixed materiaux liés display
added test utilisateur role
2014-07-15 17:36:36 +02:00
Bachir Soussi Chiadmi 41e7f80383 updated/sunc feautures betxeen local and online 2014-07-11 18:32:59 +02:00
Bachir Soussi Chiadmi 8aabfe2592 add marks to terms coming from autocompletion 2014-07-11 17:03:45 +02:00
Bachir Soussi Chiadmi 847eb41741 removed words and keep sentence search request 2014-07-11 16:43:40 +02:00
Bachir Soussi Chiadmi 6c4d1ed8f5 removed unusable watchdog 2014-07-11 16:29:32 +02:00
Bachir Soussi Chiadmi 854a6cc680 trying to fixe this fucking bug 2014-07-11 15:32:21 +02:00
Bachir Soussi Chiadmi 4691968631 fixed bundle_filters php notice 2014-07-11 15:00:35 +02:00
Bachir Soussi Chiadmi 10c50db9e2 fixed search index name bug 2014-07-11 14:55:19 +02:00
Bachir Soussi Chiadmi a645ef87b4 fixed search index name bug 2014-07-11 14:35:16 +02:00
Bachir Soussi Chiadmi d214a86eeb fixed address field bug 2014-07-10 20:29:00 +02:00
Bachir Soussi Chiadmi 5cbbf7cbf5 fixed address field bug 2014-07-10 20:27:17 +02:00
Bachir Soussi Chiadmi 3310c6fad6 cleaned maintenance/index.html 2014-07-10 20:03:34 +02:00
Bachir Soussi Chiadmi 4756fdaf77 add permission to access to payment
prefile webform 11186 with recorded user profile infos
2014-07-10 19:47:43 +02:00
Bachir Soussi Chiadmi 7580376050 repatched modules/user/user.module 2014-07-07 19:16:12 +02:00
Bachir Soussi Chiadmi acaa381d3d repatched misc/autocomplet.js 2014-07-07 19:06:13 +02:00
Bachir Soussi Chiadmi c3011cef61 drupal core updated to 7.28 2014-07-07 18:53:44 +02:00
Bachir Soussi Chiadmi 5835745cc2 merge sandbox with prod 2014-07-07 16:35:39 +02:00
Bachir Soussi Chiadmi bf41479abc added some comment on source code 2014-07-07 16:04:41 +02:00
Bachir Soussi Chiadmi f4ae3c9055 fixed results summary 2014-07-07 12:49:40 +02:00
Bachir Soussi Chiadmi 28deeac474 materio admin : created duplicate mails page admin 2014-07-03 18:52:20 +02:00
Bachir Soussi Chiadmi 0c71144833 disabled submit on registration to avoid duplicate account creation 2014-07-03 17:27:36 +02:00
Bachir Soussi Chiadmi f881f8b638 fixed mispelling 2014-07-03 16:13:44 +02:00
Bachir Soussi Chiadmi 1eb8bb9de8 change pricing to Pricing 2014-07-02 18:24:34 +02:00
Bachir Soussi Chiadmi 5b26e36355 highlighted the FOUND X RESULTS sentence 2014-07-02 18:21:39 +02:00
Bachir Soussi Chiadmi 9df43555ac restrict access to materials descriptions for free users 2014-07-02 16:24:54 +02:00
Bachir Soussi Chiadmi e2183f0a0d fixed viewmode block visibility
depending on permission as before but also on node type
visible only with materiaux and breves
2014-07-01 18:15:47 +02:00
Bachir Soussi Chiadmi c4d8c34e1a Viewmode block
restrict display on node page for materiau and breve
2014-04-30 10:41:52 +02:00
Bachir Soussi Chiadmi 748548f8f4 cleaned file 2014-04-30 10:41:24 +02:00
Bachir Soussi Chiadmi 5d0c233fec bug fixed 2014-04-28 17:20:50 +02:00
Bachir Soussi Chiadmi 05a41ebf3a bug fixe ? 2014-04-28 17:09:33 +02:00
Bachir Soussi Chiadmi a08a5287fc bug fixe ? 2014-04-28 17:05:27 +02:00
Bachir Soussi Chiadmi ae72f70488 bug fixe ? 2014-04-28 16:53:58 +02:00
Bachir Soussi Chiadmi c8a37f4255 Trailing slash + bug fixe
http://studio.g-u-i.net/fr/materio/node/1368
2014-04-28 16:29:17 +02:00
Bachir Soussi Chiadmi df548917f6 improved mail templates 2014-04-28 11:42:36 +02:00
Bachir Soussi Chiadmi 40fe76b2cf improved mail templates (wysiwyg filter) 2014-04-28 11:19:49 +02:00
Bachir Soussi Chiadmi 5b7b67573f updated simplenews templates 2014-04-25 18:54:36 +02:00
Bachir Soussi Chiadmi a613426482 updated simplenews templates 2014-04-25 18:48:28 +02:00
Bachir Soussi Chiadmi e371e746ff updated simplenews templates 2014-04-25 18:46:28 +02:00
Bachir Soussi Chiadmi 148e2db56e updated templates 2014-04-25 18:42:37 +02:00
Bachir Soussi Chiadmi 332c17c25c change body field height systematicaly 2014-04-25 17:25:48 +02:00
Bachir Soussi Chiadmi a64d6e34d8 upadted also test template 2014-04-25 17:12:19 +02:00
Bachir Soussi Chiadmi 6394330226 removed icons from body template
added to footer template on materiobasetheme theme
2014-04-25 16:57:33 +02:00
Bachir Soussi Chiadmi 76efcb0778 added simplenews local actions + change template selection from query to path 2014-04-25 16:13:11 +02:00
Bachir Soussi Chiadmi f6d5c40ae2 removed dsm() 2014-04-25 15:15:52 +02:00
Bachir Soussi Chiadmi 9d2fee4ddd simplenews prepopulation improvement 2014-04-25 15:11:39 +02:00
Bachir Soussi Chiadmi d7dddd5764 added template selection regarding simplenews categorie (trough url query) 2014-04-23 18:40:19 +02:00
Bachir Soussi Chiadmi 4d0605604f Simplenews default body content ofr content
daily materio html template through hook_form_alter
2014-04-23 16:49:49 +02:00
Bachir Soussi Chiadmi 100abc9a3a materio_search_api_ajax
add optional viewmode paramater for ajax call materio_search_api_ajax_node
2014-02-28 20:00:30 +01:00
Bachir Soussi Chiadmi 094eb50691 bug fixe 2014-02-21 21:06:23 +01:00
Bachir Soussi Chiadmi 7b99c14d96 bug fixe 2014-02-21 21:01:03 +01:00
Bachir Soussi Chiadmi c06be9a44e Icons
re-added icons, why they didn't be here, i don't know ...
2014-02-21 19:49:45 +01:00
Bachir Soussi Chiadmi 6ccf2ddb91 SOLR : autocompletion accent & companie tranlation
accent : added a custom term propertie which duplicate the term name to index it without accent
companie : replaced the custom term propertie by a node (materiau) property
           which retrieve the companie info frome the tode node
2014-02-19 16:59:29 +01:00
Bachir Soussi Chiadmi 3757a19ce7 materio_search_api
updated dynamic field definition
https://drupal.org/comment/8188439#comment-8188439
2014-02-07 11:27:33 +01:00
Bachir Soussi Chiadmi 891166f86e removed patch : own dynamic field types
since committed by drunken monkey
https://drupal.org/comment/8137979#comment-8137979
2014-02-07 10:43:46 +01:00
Bachir Soussi Chiadmi 85251183d6 NODE_PUBLISED : in previous patches i commented the next line, why ? maybe will have to do it again 2014-02-07 10:32:26 +01:00
Bachir Soussi Chiadmi 54ee5c7b3a taxo term translation bug : added reference to bug fix in comment 2014-02-07 10:29:08 +01:00
Bachir Soussi Chiadmi 6402fc7ab8 re-added own boosts 2014-02-07 10:10:15 +01:00
Bachir Soussi Chiadmi d7303905a0 updated to 7.x-1.4 2014-02-07 10:05:53 +01:00
Bachir Soussi Chiadmi cf03e9ca52 updated to 7.x-1.11 2014-02-07 10:01:18 +01:00
Bachir Soussi Chiadmi 60cc747699 materio_user :: set the definitive product NID in cartlink 2013-12-09 18:46:31 +01:00
Bachir Soussi Chiadmi d9298146fa materio_user change product id for matching with basebeta.materio.com /|\ WARNING will not work anymore on dev or prod /|\ have to backup prod to sandbox and dev AND reconfigure the store (recreate the product subscription) before set the definitive ID 2013-12-09 18:02:35 +01:00
Bachir Soussi Chiadmi 1cc99f26e1 bug fixe materio_user 2013-12-09 17:28:49 +01:00
Bachir Soussi Chiadmi 5cde537e0a updated features materio_subscrition and materio_user_profile 2013-12-09 17:22:25 +01:00
Bachir Soussi Chiadmi 0799729429 materio_user : membership form auto fill profil2 adherent fields, checkout form prepopulated with profile2 adherent fields 2013-12-08 20:02:06 +01:00
Bachir Soussi Chiadmi 3fe3dde8c2 membership webform submit fill cart then redirect to checkout, HO YEAH 2013-12-07 16:31:37 +01:00
Bachir Soussi Chiadmi 5d6f96ed0e start term search mode on materio_search_api_ajax, NOT FINISHED 2013-12-07 11:55:28 +01:00
Bachir Soussi Chiadmi 983f51e711 fixe @koala-prepend on materio_flag.js 2013-12-07 11:48:53 +01:00
Bachir Soussi Chiadmi 85be86a9e4 better error message on materio_user.js login/register ajax submit 2013-12-07 11:48:00 +01:00
Bachir Soussi Chiadmi ffff23584e removed trace from materio_user.js 2013-12-07 11:15:03 +01:00
Bachir Soussi Chiadmi 770e2155bb add some trace to materio_user.js for debigging 2013-12-07 11:12:32 +01:00
Bachir Soussi Chiadmi 90c6d5e6e9 fixe @koala-prepend 2013-12-06 12:46:57 +01:00
Bachir Soussi Chiadmi e1a04d9b8e commented trace 2013-12-06 12:41:06 +01:00
Bachir Soussi Chiadmi 3d36e980af json.return IE bug fixe suite + misc 2013-12-05 15:35:14 +01:00
Bachir Soussi Chiadmi acb87f238a repaced .return json property bye .rendered or other, because IE doesn't like return 2013-12-05 15:32:34 +01:00
Bachir Soussi Chiadmi 7230dafd5f replaced ch.js files by min.js" 2013-12-05 15:29:25 +01:00
Bachir Soussi Chiadmi 9af55b03bd deleted js-ck files 2013-12-05 15:26:10 +01:00
Bachir Soussi Chiadmi 10de06dd70 misc 2013-12-05 10:29:17 +01:00
Bachir Soussi Chiadmi 572f88b950 removed install files 2013-12-05 10:28:50 +01:00
Bachir Soussi Chiadmi 52d0c3b77e removed dsm from materio_admin 2013-11-10 14:38:13 +01:00
Bachir Soussi Chiadmi 794ccba61a created materio_admin module 2013-11-10 14:08:11 +01:00
Bachir Soussi Chiadmi 925324448b materio_user_rules typo fixe 2013-11-08 22:36:26 +01:00
Bachir Soussi Chiadmi 64ebb28c01 updated materio_user_rules : rules event on user validation+has subscribed works 2013-11-08 22:34:54 +01:00
Bachir Soussi Chiadmi d35f79e2cf created materio_user_rules module 2013-11-08 21:09:48 +01:00
Bachir Soussi Chiadmi c3c0c71945 fixe access mybookmarks block fixe 2013-11-03 16:11:14 +01:00
Bachir Soussi Chiadmi 91c826322e typo and strict php warning fixe 2013-11-03 15:33:11 +01:00
Bachir Soussi Chiadmi ab51102cd0 improve message after registration 2013-10-30 20:20:06 +01:00
Bachir Soussi Chiadmi 77414c7cb9 bug fixe 2013-10-30 20:05:27 +01:00
Bachir Soussi Chiadmi 7aa6dfe191 improve modale registration and login forms 2013-10-30 19:59:03 +01:00
Bachir Soussi Chiadmi ca6c5bd4fa improve modal register error display 2013-10-30 18:36:19 +01:00
Bachir Soussi Chiadmi e960755e20 avoid strict warnig php error 2013-10-30 18:18:02 +01:00
Bachir Soussi Chiadmi 09d80d2c63 modale register bug fix 2013-10-30 18:09:04 +01:00
Bachir Soussi Chiadmi 5daabaaf5a modale register bug fix 2013-10-30 18:03:56 +01:00
Bachir Soussi Chiadmi 8909491a12 new membership and account creation process : modal and form is in a separated page 2013-10-30 17:53:15 +01:00
Bachir Soussi Chiadmi 051455cd71 for simple users, search find news and related materiaux only if these materiaux also match with the search 2013-10-29 16:28:13 +01:00
Bachir Soussi Chiadmi 235e57d8e9 patched for email sending on each feedback creation https://drupal.org/node/353548#comment-7130746 2013-10-12 13:27:26 +02:00
Bachir Soussi Chiadmi ca63b9bbca updated to 7.x-2.x-dev (2013-Mar-04) 2013-10-12 13:24:57 +02:00
Bachir Soussi Chiadmi cb791f03ff fixe the 302 redirection cache probleme with headers in htaccess 2013-10-12 13:08:36 +02:00
Bachir Soussi Chiadmi 7a46e22394 refactoring of membership form 2013-10-08 17:44:53 +02:00
Bachir Soussi Chiadmi 3bdbc68690 replace register form to join us link on home login block 2013-10-08 14:26:08 +02:00
Bachir Soussi Chiadmi 33ce5d0e40 back in town 2013-10-07 18:39:04 +02:00
Bachir Soussi Chiadmi 8e478340a2 added materio's ip to maintenance authorized ips 2013-10-07 09:10:26 +02:00
Bachir Soussi Chiadmi 78fa0756a9 updated quentin's ip 2013-10-06 23:48:27 +02:00
Bachir Soussi Chiadmi 176b1c05d9 redirect multiple ip bug fix 2013-10-06 20:16:46 +02:00
Bachir Soussi Chiadmi acbf965c77 redirect multiple ip bug fix 2013-10-06 20:10:03 +02:00
Bachir Soussi Chiadmi bd98c3d7f6 redirect multiple ip bug fix 2013-10-06 20:07:37 +02:00
Bachir Soussi Chiadmi 1c56076189 added quentin ip to maintenance htaccess redirection 2013-10-06 20:03:48 +02:00
Bachir Soussi Chiadmi e0ab0fd0d5 cleaned maintenance/index.html : removed all js 2013-10-06 16:29:46 +02:00
Bachir Soussi Chiadmi b58a00a4c8 fixed htaccess rule 2013-10-06 16:16:40 +02:00
Bachir Soussi Chiadmi 4d81ea318d renamed 302 folder to maintenance 2013-10-06 16:15:28 +02:00
Bachir Soussi Chiadmi 77cb87b49d changed maintenance page redirection from 503 to 302 2013-10-06 16:13:23 +02:00
Bachir Soussi Chiadmi 5203118606 setup htaccess maintenace page as a 503 static html page 2013-10-06 16:06:47 +02:00
Bachir Soussi Chiadmi 39759425ce change dependencies infos to CER 2013-09-26 19:51:09 +02:00
Bachir Soussi Chiadmi 62b7436183 repatched for custom dynmaic field definition : https://drupal.org/node/1846860#comment-7805861 2013-09-26 16:46:14 +02:00
Bachir Soussi Chiadmi d8237ffb99 updated to 1.2 2013-09-26 16:23:17 +02:00
Bachir Soussi Chiadmi a30917d1d2 repatched for own boosts options & avoid published filter 2013-09-26 16:05:44 +02:00
Bachir Soussi Chiadmi e6aed1cba0 removed ids from div render 2013-09-26 15:58:19 +02:00
Bachir Soussi Chiadmi 16ed68abf6 first import 1.3 2013-09-26 15:57:13 +02:00
Bachir Soussi Chiadmi 128640cd15 upadted to 1.8 2013-09-26 15:49:26 +02:00
Bachir Soussi Chiadmi 7e3ef32d18 update for 2.x version 2013-09-26 15:31:44 +02:00
Bachir Soussi Chiadmi d4d5acf837 flag 3.2 compatibility 2013-09-25 15:25:25 +02:00
Bachir Soussi Chiadmi 2b45f07449 increase number of results for autocomplete searchapi 2013-09-24 10:16:21 +02:00
Bachir Soussi Chiadmi 9faad4a27d patched user module 2013-09-24 09:21:31 +02:00
Bachir Soussi Chiadmi 32e4448773 repatched includes/entity.inc 2013-09-24 09:13:51 +02:00
Bachir Soussi Chiadmi e539e701f8 update to drupal 7.23 2013-09-24 09:05:59 +02:00
Bachir Soussi Chiadmi db5f70501a renamed 2 patch and add one (entity patch) 2013-09-24 09:05:19 +02:00
Bachir Soussi Chiadmi f47c978520 user password bug fixe bis 2013-09-23 23:52:22 +02:00
Bachir Soussi Chiadmi 4362f6dc23 user password bug fixe 2013-09-23 23:49:50 +02:00
Bachir Soussi Chiadmi eeccd6a4d2 search field default value : search among our n cards 2013-09-20 12:46:38 +02:00
Bachir Soussi Chiadmi 8672e5eb9f changed premissions 2013-09-06 16:59:50 +02:00
Bachir Soussi Chiadmi f1c9615e4a changed permission 2013-09-06 16:15:44 +02:00
Bachir Soussi Chiadmi 9eb6fe8360 filter didactique on "who we are" page by field displayed_in_whoweare
Signed-off-by: bachy <git@g-u-i.net>
2013-07-02 11:25:37 +02:00
bachy 2d18c524eb responsive : viewmodes
Signed-off-by: bachy <git@g-u-i.net>
2013-06-08 18:58:18 +02:00
bachy afd4de26e7 added some spans
Signed-off-by: bachy <git@g-u-i.net>
2013-06-05 21:26:12 +02:00
bachy 7c486da7c5 deleted materio_title_access module files
Signed-off-by: bachy <git@g-u-i.net>
2013-06-01 20:41:18 +02:00
bachy 0ccaf2eeeb update materio_content_types
removed materio_title_access module dependency

Signed-off-by: bachy <git@g-u-i.net>
2013-06-01 20:36:56 +02:00
bachy 5fd46660b9 merged materio_title_access and materio_page_title into materio_page_title
Signed-off-by: bachy <git@g-u-i.net>
2013-06-01 20:20:54 +02:00
bachy 70b4f2279f added materio_taxonomy for term pages perms
Signed-off-by: bachy <git@g-u-i.net>
2013-05-31 18:34:47 +02:00
bachy 2f95c828e6 didactique page
Signed-off-by: bachy <git@g-u-i.net>
2013-05-29 20:29:27 +02:00
bachy 1923036d97 bug fix
Signed-off-by: bachy <git@g-u-i.net>
2013-05-28 16:20:11 +02:00
bachy 49db4b90be restrict page title for visitors
Signed-off-by: bachy <git@g-u-i.net>
2013-05-24 19:44:36 +02:00
bachy 6c85be6c6d restrict page title on materiau node page for visitors
Signed-off-by: bachy <git@g-u-i.net>
2013-05-24 19:27:13 +02:00
bachy ee27274830 page_node_view integration
Signed-off-by: bachy <git@g-u-i.net>
2013-05-24 17:58:29 +02:00
bachy 84542b241d repatch user module
Signed-off-by: bachy <git@g-u-i.net>
2013-05-24 13:11:25 +02:00
bachy e99ac67b73 repatch autocomplete for selet event
Signed-off-by: bachy <git@g-u-i.net>
2013-05-24 13:09:06 +02:00
bachy 5a4cadabf6 repatch entity.inc
Signed-off-by: bachy <git@g-u-i.net>
2013-05-24 13:07:53 +02:00
bachy 5658794f17 update to 7.22
Signed-off-by: bachy <git@g-u-i.net>
2013-05-24 13:03:57 +02:00
bachy df0ec71ac7 cleaning
Signed-off-by: bachy <git@g-u-i.net>
2013-05-07 12:19:41 +02:00
bachy 93c278c5e8 change image title from textfield to text area
Signed-off-by: bachy <git@g-u-i.net>
2013-05-07 12:19:25 +02:00
bachy 13d6d3b95b new custom entity property (term become text)
Signed-off-by: bachy <git@g-u-i.net>
2013-04-24 20:50:35 +02:00
bachy e0ae80791b changed boosts
Signed-off-by: bachy <git@g-u-i.net>
2013-04-24 20:32:41 +02:00
bachy dfe36ba913 added $(document).ready to js script
Signed-off-by: bachy <git@g-u-i.net>
2013-04-23 12:08:32 +02:00
bachy caf3bf662c materio admin fix
Signed-off-by: bachy <git@g-u-i.net>
2013-04-02 14:16:36 +02:00
bachy 66e87e0bf4 updated faq (perms)
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 19:03:05 +01:00
bachy b2873ad5b1 updated admin
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 18:51:11 +01:00
bachy f43260082d updated user profile
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 18:37:15 +01:00
bachy bef27e8258 updated feedback
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 18:37:01 +01:00
bachy 443e4fc138 updated admin
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 18:36:50 +01:00
bachy 09ac2a24ac added faq
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 18:36:32 +01:00
bachy 789d8708bf bug fixe : error message
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 17:20:21 +01:00
bachy 578adab53b update to 7.x-3.6
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 17:18:33 +01:00
bachy d5097a4bc6 rematch user module
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 16:58:46 +01:00
bachy 661765bde9 repatch autocomplete js
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 16:58:31 +01:00
bachy fde4f26165 repatch entity.inc
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 16:58:16 +01:00
bachy 8763bf01dd update to 7.21
Signed-off-by: bachy <git@g-u-i.net>
2013-03-29 16:53:05 +01:00
bachy 10c9d53c31 work around : comment query access condition
Signed-off-by: bachy <git@g-u-i.net>
2013-03-15 18:41:27 +01:00
bachy 29f7711833 added more boost 2013-03-15 17:34:17 +01:00
bachy 9cc5ba4cfa first import 7.x-1.4 2013-03-15 17:32:30 +01:00
bachy 644b7db597 fix header layout for 1024 width
Signed-off-by: bachy <git@g-u-i.net>
2013-03-13 16:18:41 +01:00
bachy 779d42d9bb entity props address for indexing fixed
Signed-off-by: bachy <git@g-u-i.net>
2013-03-13 14:56:56 +01:00
bachy 78b816920d added "address" field property to company taxonomy term, for indexation
http://studio.g-u-i.net/en/materio/node/1040
Signed-off-by: bachy <git@g-u-i.net>
2013-03-13 12:47:13 +01:00
bachy f5e39e1209 added custom field type for apache_solr (see patch against searchapi_solr)
Signed-off-by: bachy <git@g-u-i.net>
2013-03-13 12:45:44 +01:00
bachy c9912105d5 patch add custom field types
Signed-off-by: bachy <git@g-u-i.net>
2013-03-12 19:15:12 +01:00
bachy 6a402551d7 first import 2013-03-12 15:26:34 +01:00
bachy 5b845da277 flags update
Signed-off-by: bachy <git@g-u-i.net>
2013-03-12 12:46:56 +01:00
bachy 763ce99b95 bug fix
Signed-off-by: bachy <git@g-u-i.net>
2013-03-08 10:33:32 +01:00
bachy f207e56b2d bookmarks change view mode
Signed-off-by: bachy <git@g-u-i.net>
2013-03-08 10:17:19 +01:00
bachy 06a4d254c2 bookmarks fixing
Signed-off-by: bachy <git@g-u-i.net>
2013-03-07 19:04:15 +01:00
bachy 49fb38b169 re : one-time-login-url localized
Signed-off-by: bachy <git@g-u-i.net>
2013-03-06 15:03:43 +01:00
bachy de022d62e2 repatch misc/autocomplete.js
Signed-off-by: bachy <git@g-u-i.net>
2013-03-06 15:00:09 +01:00
bachy d9d092295b rematch includes/entity.inc
Signed-off-by: bachy <git@g-u-i.net>
2013-03-06 14:58:30 +01:00
bachy 8c47736b71 core update 7.20
Signed-off-by: bachy <git@g-u-i.net>
2013-03-06 14:55:44 +01:00
bachy de59738907 updates table tr colors
Signed-off-by: bachy <git@g-u-i.net>
2013-02-28 15:41:22 +01:00
bachy a575bce275 less compile to css
Signed-off-by: bachy <git@g-u-i.net>
2013-02-28 15:38:54 +01:00
bachy 2fdd8fb95c Merge branch '7.x' of https://bitbucket.org/bachysoucy/guibik into 7.x
Signed-off-by: bachy <git@g-u-i.net>

Conflicts:
	css/guibik.css
	less/guibik.less
2013-02-28 15:37:54 +01:00
bachy e573564b93 colors of updates table
Signed-off-by: bachy <git@g-u-i.net>
2013-02-28 15:32:55 +01:00
bachy 454adf9478 bug fix : communication between theme and module
Signed-off-by: bachy <git@g-u-i.net>
2013-02-23 12:31:22 +01:00
bachy b181133e60 t() fixe
Signed-off-by: bachy <git@g-u-i.net>
2013-02-14 23:51:01 +01:00
bachy e7d0e34651 micro text change
Signed-off-by: bachy <git@g-u-i.net>
2013-02-14 21:28:05 +01:00
bachy f0f9635e8b actuality bug fix
Signed-off-by: bachy <git@g-u-i.net>
2013-02-14 21:24:22 +01:00
bachy 7a3ee63d15 could results bug fix
Signed-off-by: bachy <git@g-u-i.net>
2013-02-14 20:56:43 +01:00
bachy 8f492c8b4e access view mode change bug fixe
Signed-off-by: bachy <git@g-u-i.net>
2013-02-14 20:32:51 +01:00
bachy 108f77c73d search "performance“ message for user with link to pricing page
Signed-off-by: bachy <git@g-u-i.net>
2013-02-14 20:00:16 +01:00
bachy 0db5022c47 !!! search api for breve
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 23:17:01 +01:00
bachy d01d0a2a7e deactivated hook_user_update for test
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 21:00:47 +01:00
bachy 2b137c6a19 added got to user/%uid/edit
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 20:48:20 +01:00
bachy cb6963919c give defined rôle on validate email
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 20:36:10 +01:00
bachy 39db0ed16d header : hide my folders if no flag list
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 19:40:42 +01:00
bachy 1aa3c4e9eb htaccess again
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 13:09:21 +01:00
bachy 1f662a2b40 annul htaccess
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 12:52:28 +01:00
bachy 83cf488d4a htaccess again
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 12:51:33 +01:00
bachy 1a145b8470 htaccess just basebeta
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 12:50:38 +01:00
bachy 8c09d74e68 htaccess again
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 12:49:47 +01:00
bachy 8e432ea544 htaccess again …
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 12:47:41 +01:00
bachy 2d4301ad40 htaccess
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 12:41:07 +01:00
bachy 662012976d htaccess rewrite url bug fix
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 12:39:17 +01:00
bachy cc526dd563 htaccess redirecte basebeta to www
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 12:33:43 +01:00
bachy 87edb46954 register block : login pass first, before register
Signed-off-by: bachy <git@g-u-i.net>
2013-02-13 11:01:08 +01:00
bachy f9a60fe62d Search api Solr onthologie bugfix
Signed-off-by: bachy <git@g-u-i.net>
2013-02-12 20:29:51 +01:00
bachy c60696ba2b home link block
Signed-off-by: bachy <git@g-u-i.net>
2013-02-12 14:18:13 +01:00
bachy 90adf0ad52 added icon-user to "user login" block title
Signed-off-by: bachy <git@g-u-i.net>
2013-02-11 20:38:23 +01:00
bachy 2506c8b8ac user login from membership redirect to membership : WONT WORK
Signed-off-by: bachy <git@g-u-i.net>
2013-02-11 20:37:41 +01:00
bachy d6bc2debdf membership web form validate
Signed-off-by: bachy <git@g-u-i.net>
2013-02-11 20:36:13 +01:00
bachy 438ebb75ad bug fix : disable user_register_alter for administrators
Signed-off-by: bachy <git@g-u-i.net>
2013-02-11 18:56:11 +01:00
bachy cb5ba1c633 TRANSLATABLE : "the materiO terms of services"
Signed-off-by: bachy <git@g-u-i.net>
2013-02-11 15:16:51 +01:00
bachy 432b8ee65e added login form to register block
Signed-off-by: bachy <git@g-u-i.net>
2013-02-11 15:11:27 +01:00
bachy 72e2d8a7f4 precedent bug fix was not a bug, it is incometibility with ajax_register
Signed-off-by: bachy <git@g-u-i.net>
2013-02-11 14:39:12 +01:00
bachy 2fff41d01d register block redirect bugfix
Signed-off-by: bachy <git@g-u-i.net>
2013-02-11 14:24:57 +01:00
bachy 83fbaa4669 change register-block title (more explicit)
Signed-off-by: bachy <git@g-u-i.net>
2013-02-11 13:08:40 +01:00
bachy 184a808558 update
Signed-off-by: bachy <git@g-u-i.net>
2013-02-10 22:18:51 +01:00
bachy 63465d9076 bug fix : error message
Signed-off-by: bachy <git@g-u-i.net>
2013-02-10 22:17:21 +01:00
bachy ca2ebbf0c8 register block : redirection to membership
register help messages

Signed-off-by: bachy <git@g-u-i.net>
2013-02-10 22:05:18 +01:00
bachy a59e01d581 first import
Signed-off-by: bachy <git@g-u-i.net>
2013-02-10 21:29:08 +01:00
bachy 5a82c8394d fix node link of terms of service
Signed-off-by: bachy <git@g-u-i.net>
2013-02-08 18:47:59 +01:00
bachy 1f9bef33b9 terms of service
Signed-off-by: bachy <git@g-u-i.net>
2013-02-08 18:28:25 +01:00
bachy 1e40a74e1a old database link
Signed-off-by: bachy <git@g-u-i.net>
2013-02-08 16:12:04 +01:00
bachy b8b7044eb3 register block
Signed-off-by: bachy <git@g-u-i.net>
2013-02-08 16:11:46 +01:00
bachy 739f52c1df user profiles : hide news letter from registration form
Signed-off-by: bachy <git@g-u-i.net>
2013-02-08 14:54:28 +01:00
bachy 64bf6b3fa2 content types : pages translatable
Signed-off-by: bachy <git@g-u-i.net>
2013-02-08 14:53:21 +01:00
bachy df986ba09a delete main menu feature
Signed-off-by: bachy <git@g-u-i.net>
2013-02-07 16:50:20 +01:00
bachy 1377500ccc new feature : main menu
Signed-off-by: bachy <git@g-u-i.net>
2013-02-07 16:09:28 +01:00
bachy 7bd9dd6d80 limit news to 6 month ago for visitors
Signed-off-by: bachy <git@g-u-i.net>
2013-01-31 17:41:24 +01:00
bachy e1d0639eee field localization perms 2
component added

Signed-off-by: bachy <git@g-u-i.net>
2013-01-31 17:31:44 +01:00
bachy 618d68bd70 field localization perms
Signed-off-by: bachy <git@g-u-i.net>
2013-01-31 17:17:32 +01:00
bachy 1bcda42052 display field localization
Signed-off-by: bachy <git@g-u-i.net>
2013-01-31 14:29:37 +01:00
bachy 6d0af35191 one-time-login-url localized
http://drupal.org/node/1754162#comment-6399678
Signed-off-by: bachy <git@g-u-i.net>
2013-01-31 12:48:00 +01:00
bachy 6a94814eaa repatch misc/autocomplete.js
Signed-off-by: bachy <git@g-u-i.net>
2013-01-31 11:41:15 +01:00
bachy 1b6b74ea40 repatch inc/entity.inc
http://drupal.org/node/1003788#comment-5195682
Signed-off-by: bachy <git@g-u-i.net>
2013-01-31 11:38:20 +01:00
bachy 00df84c69c update Drupal 7.19
Signed-off-by: bachy <git@g-u-i.net>
2013-01-31 11:32:52 +01:00
bachy 89e7b9de6e bug fixe for taxonomie terms
Signed-off-by: bachy <git@g-u-i.net>
2013-01-30 21:29:47 +01:00
bachy 4caa0c442b first import
Signed-off-by: bachy <git@g-u-i.net>
2013-01-30 18:30:33 +01:00
bachy 6c0f932603 removed install files
Signed-off-by: bachy <git@g-u-i.net>
2013-01-30 15:34:12 +01:00
bachy 18eea497c3 Merge branch 'refs/heads/7.x-solrmulticore' into 7.x 2013-01-30 14:49:12 +01:00
bachy c3f366a045 solr multicore
Signed-off-by: bachy <git@g-u-i.net>
2013-01-30 13:55:24 +01:00
bachy fc0253d9c2 print pdf
- set available print links for our view modes
- hide flags from print

Signed-off-by: bachy <git@g-u-i.net>
2013-01-15 15:57:54 +01:00
bachy a6f0f199b5 bug fix
next page with special char didn't work, added rawurldecode on keys

Signed-off-by: bachy <git@g-u-i.net>
2013-01-11 14:47:28 +01:00
bachy b20b38f514 first import
Signed-off-by: bachy <git@g-u-i.net>
2013-01-09 10:53:26 +01:00
bachy 12045fe181 one-time-login-url localized
http://drupal.org/node/1754162#comment-6399678
Signed-off-by: bachy <git@g-u-i.net>
2013-01-07 17:25:05 +01:00
bachy feae2e1f34 mini fixe
Signed-off-by: bachy <git@g-u-i.net>
2013-01-03 16:06:01 +01:00
bachy b0f5c3eae0 adhérent migration
Signed-off-by: bachy <git@g-u-i.net>
2013-01-03 16:04:59 +01:00
bachy bcf209570a conjunction OR ++
ajax : keys aren't args any more, because of a+b+c

Signed-off-by: bachy <git@g-u-i.net>
2013-01-03 16:04:25 +01:00
bachy b7ab35d6aa repatch for user role selection
Signed-off-by: bachy <git@g-u-i.net>
2012-12-08 12:08:37 +01:00
bachy 3b2eb43c8f rematch autocomplete search in fields
Signed-off-by: bachy <git@g-u-i.net>
2012-12-08 12:05:05 +01:00
bachy 4ef59776b0 update 7.1
Signed-off-by: bachy <git@g-u-i.net>
2012-12-08 11:59:44 +01:00
bachy f276e09115 patch url
Signed-off-by: bachy <git@g-u-i.net>
2012-12-08 11:57:58 +01:00
bachy 60ca2f9e72 rematch for js autocomplete submit
Signed-off-by: bachy <git@g-u-i.net>
2012-12-08 11:44:53 +01:00
bachy aa45d84855 repatch inc/entity.inc
http://drupal.org/node/1003788#comment-5195682
Signed-off-by: bachy <git@g-u-i.net>
2012-12-08 11:39:10 +01:00
bachy 5396b3e2b5 update to D 7.17
Signed-off-by: bachy <git@g-u-i.net>
2012-12-08 11:35:42 +01:00
bachy 3eaa5817e0 change readme.txt content
Signed-off-by: bachy <git@g-u-i.net>
2012-12-07 10:59:22 +01:00
bachy 975d758599 ignore sublimetext project files
Signed-off-by: bachy <git@g-u-i.net>
2012-12-06 18:55:10 +01:00
bachy 0600bf6674 with title module : empty entity_label fixed
http://drupal.org/node/1402000
Signed-off-by: bachy <git@g-u-i.net>
2012-11-30 13:27:16 +01:00
bachy 1cd7c773a5 notice php bug fixe
Signed-off-by: bachy <git@g-u-i.net>
2012-11-30 11:47:33 +01:00
bachy 2601c718c2 update
- added materio_user.module (add permission to view the profile page)
- materio_serach_api.pages : limit actu items for anonymous
- materio_search_api_ajax.pages & materio_flag.pages : redirect to real page if current page not corresponding on ajax request (solve the view mode block visibility on user edit profile page)
- materio_flag : added edit lists functionalities ++ get_list_page_title func

Signed-off-by: bachy <git@g-u-i.net>
2012-11-21 10:06:34 +01:00
bachy 61c83b5a75 removed history.js
Signed-off-by: bachy <git@g-u-i.net>
2012-11-21 09:56:38 +01:00
bachy a2b9816e52 update to 7.x-2.x-dev 10 nov 2012
Signed-off-by: bachy <git@g-u-i.net>
2012-11-20 16:30:11 +01:00
bachy f3be35fe5e first import 7.x-2.x-dev
Signed-off-by: bachy <git@g-u-i.net>
2012-11-20 16:21:31 +01:00
bachy 707403f8e7 PDF
Signed-off-by: bachy <git@g-u-i.net>
2012-11-16 22:23:59 +01:00
bachy d2285db42a New folders block nav
++
search field : select on focus

Signed-off-by: bachy <git@g-u-i.net>
2012-11-16 20:02:37 +01:00
bachy 7dafe10be1 $.event.trigger({type:'blabla
event = jQuery.Event('blabla')
…
become
$.event.trigger({type:'blabla
…

Signed-off-by: bachy <git@g-u-i.net>
2012-11-11 13:50:11 +01:00
bachy d97c0a2e45 event retriggering bug fixe
Signed-off-by: bachy <git@g-u-i.net>
2012-11-09 22:13:48 +01:00
bachy 63df1c8f3a google analytics ajax tracking
Signed-off-by: bachy <git@g-u-i.net>
2012-11-09 20:20:09 +01:00
bachy 6793ae61a6 port for flag 3.x suite : views
Signed-off-by: bachy <git@g-u-i.net>
2012-11-09 11:57:20 +01:00
bachy d3b84b7733 added .20; font size
Signed-off-by: bachy <git@g-u-i.net>
2012-11-09 11:54:34 +01:00
bachy 0e49c6cedf bug fixe : with entity translation
Signed-off-by: bachy <git@g-u-i.net>
2012-11-09 11:53:36 +01:00
bachy 948913bc82 Page title
Signed-off-by: bachy <git@g-u-i.net>
2012-11-09 11:51:55 +01:00
bachy b1bf1c9387 Flag list OK
all ajax OK

Signed-off-by: bachy <git@g-u-i.net>
2012-11-08 17:42:38 +01:00
bachy 1d11663ec4 début de modal sans ctools
Signed-off-by: bachy <git@g-u-i.net>
2012-11-01 01:10:02 +01:00
bachy df2c715315 new lists (ctools)
Signed-off-by: bachy <git@g-u-i.net>
2012-10-31 19:49:05 +01:00
bachy d77d7e5ef7 Flags :
- bookmarks OK
- flaglist DEV

Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:11:20 +01:00
bachy 8e956c857b didactique
Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:10:14 +01:00
bachy ef943eba75 actuality and filter templates
Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:09:48 +01:00
bachy b750ae41c4 materio title access
Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:09:14 +01:00
bachy 761ffba48d search results, check for access
Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:08:52 +01:00
bachy e218aeb4da ontologie pondération
hook_entity_property_info_alter

Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:08:24 +01:00
bachy 493d3bf780 actuality JS
Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:07:48 +01:00
bachy f8af96a85b actuality
Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:07:06 +01:00
bachy 2248bfd12e display search performances
Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:04:23 +01:00
bachy 65ea77dea2 change view mode ++ type filters
Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:03:56 +01:00
gaelg edc3e1f685 First try, should work. 2012-10-30 10:39:29 +01:00
gaelg 7022567394 Initial commit. 2012-10-30 10:35:25 +01:00
bachy 4b1685af04 EntityMalformedException PATCH
http://drupal.org/node/1595358
Signed-off-by: bachy <git@g-u-i.net>
2012-10-27 16:13:15 +02:00
bachy 7884444ec6 update 2.2 + precedent custom commits
Signed-off-by: bachy <git@g-u-i.net>
2012-10-27 15:06:38 +02:00
bachy aff5ecb650 titmice theme correction
Signed-off-by: bachy <git@g-u-i.net>
2012-10-27 15:04:07 +02:00
bachy 9a18131bcf first import 2.1
Signed-off-by: bachy <git@g-u-i.net>
2012-10-27 15:02:05 +02:00
bachy ce04398f78 message css (colors) + better-messages module
Signed-off-by: bachy <git@g-u-i.net>
2012-10-27 14:43:22 +02:00
bachy 6022c4547f User bundle filers for Roles and Status
http://drupal.org/node/1354482
Signed-off-by: bachy <git@g-u-i.net>
2012-10-27 12:42:48 +02:00
bachy a981ba0fcd Autocomplete is searching only on entity properties (not fields)
http://drupal.org/node/1691612
Signed-off-by: bachy <git@g-u-i.net>
2012-10-27 12:41:54 +02:00
bachy a3196f9486 first import 1.0-rc5
Signed-off-by: bachy <git@g-u-i.net>
2012-10-27 12:36:32 +02:00
bachy 4240ab47e8 7.16 less patch previous patches are preserved
Signed-off-by: bachy <git@g-u-i.net>
2012-10-26 21:57:49 +02:00
bachy c259bc4543 update for flag 3.x
- table flags becomes flag
- replace all content_type and content_id by entity_type and entity_id
- changed flag_lists.install (new rows name entity_type & entity_id) and flags table name become flag
- factory_by_content_type('node') became factory_by_entity_type('node')
- flag_lists.views_default.inc (entity_id & entity_type)

Signed-off-by: bachy <git@g-u-i.net>
2012-10-17 18:54:47 +02:00
bachy 04d628c609 first import from 7.x-1.1
Signed-off-by: bachy <git@g-u-i.net>
2012-10-17 15:19:21 +02:00
bachy 3faebabce1 update
Signed-off-by: bachy <git@g-u-i.net>
2012-10-13 11:12:14 +02:00
bachy a7b1a91c6f bug fix
Signed-off-by: bachy <git@g-u-i.net>
2012-10-11 18:54:11 +02:00
bachy 900155d078 Merge branch '7.x' of ssh://ssh.g-u-i.net/module-tode into 7.x 2012-10-11 18:25:43 +02:00
bachy aa8698232d field formatter "Tode" for term_reference
Signed-off-by: bachy <git@g-u-i.net>
2012-10-11 18:23:30 +02:00
bachy 2543d32599 add “people create" short cut on admin/user page
Signed-off-by: bachy <git@g-u-i.net>
2012-10-09 21:37:17 +02:00
bachy e5028b4522 htaccess file mime html5 boilerplate
Signed-off-by: bachy <git@g-u-i.net>
2012-10-09 21:35:32 +02:00
bachy 3b4f1e024f big big big update
Signed-off-by: bachy <git@g-u-i.net>
2012-10-09 21:30:27 +02:00
bachy 476ccd94fe theme able results
Signed-off-by: bachy <git@g-u-i.net>
2012-10-05 14:20:50 +02:00
bachy 86d0eb03f5 don't know
Signed-off-by: bachy <git@g-u-i.net>
2012-10-05 14:18:07 +02:00
bachy 789a40d106 JS
Signed-off-by: bachy <git@g-u-i.net>
2012-10-05 14:17:12 +02:00
bachy 2697ba8675 breves migration update
Signed-off-by: bachy <git@g-u-i.net>
2012-10-05 14:15:46 +02:00
bachy c811ffcb26 css header
Signed-off-by: bachy <git@g-u-i.net>
2012-10-05 14:14:12 +02:00
bachy 3a3a620cac autocomplete select event patch
Signed-off-by: bachy <git@g-u-i.net>
2012-10-05 14:07:20 +02:00
bachy 4f6a8d389b includes/entity.inc patch
http://drupal.org/node/1003788#comment-5195682
Signed-off-by: bachy <git@g-u-i.net>
2012-10-05 14:03:27 +02:00
bachy 95098773d5 first import
Signed-off-by: bachy <git@g-u-i.net>
2012-10-05 13:50:00 +02:00
bachy c952bd330f redirect node to term alpha
Signed-off-by: bachy <git@g-u-i.net>
2012-09-26 16:36:56 +02:00
bachy 6c13226969 terms
Signed-off-by: bachy <git@g-u-i.net>
2012-09-16 15:59:49 +02:00
bachy 3ca910cf34 files, video, materiau ref
Signed-off-by: bachy <git@g-u-i.net>
2012-09-16 15:47:54 +02:00
bachy 40b0b8bae2 change source query, got translation onprepare()
Signed-off-by: bachy <git@g-u-i.net>
2012-09-16 10:04:06 +02:00
bachy 0370c6233d breves migration starting point
Signed-off-by: bachy <git@g-u-i.net>
2012-09-15 18:52:56 +02:00
bachy fb30fe966e materiobaseajax module
first ajax geed results
+ 2 different custom autocomplete func (not used for now)
	- deselect
	- searchapi

Signed-off-by: bachy <git@g-u-i.net>
2012-07-23 23:02:09 +02:00
bachy 68126583b1 addtemplate patch
http://drupal.org/node/1313676#comment-6169000
Signed-off-by: bachy <git@g-u-i.net>
2012-07-23 17:53:59 +02:00
bachy 2030a6f810 bug fixe on édit page for precedent patch
Signed-off-by: bachy <git@g-u-i.net>
2012-07-22 17:02:31 +02:00
bachy 256475e716 disable form patch
http://drupal.org/node/1512086
Signed-off-by: bachy <git@g-u-i.net>
2012-07-22 16:27:00 +02:00
bachy 5e63575d94 first import from dev
Signed-off-by: bachy <git@g-u-i.net>
2012-07-22 16:25:09 +02:00
bachy ad7809415c first import :: search autocomplete form
Signed-off-by: bachy <git@g-u-i.net>
2012-07-19 18:31:59 +02:00
bachy 0685b2dc63 compatibility with entity_translation
change values from #default (only tids) to term object if field was not on the form.

Signed-off-by: bachy <git@g-u-i.net>
2012-07-11 17:35:47 +02:00
bachy 0ed294ff52 entity_translation compatibility
Signed-off-by: bachy <git@g-u-i.net>
2012-06-19 17:23:21 +02:00
bachy addf98f5ab first import
Signed-off-by: bachy <git@g-u-i.net>
2012-06-19 16:25:59 +02:00
bachy 89159da2cf usort bug fixe
Signed-off-by: bachy <git@g-u-i.net>
2012-05-30 17:14:36 +02:00
bachy 4cf9d7b2c6 debug
ordre non respect (js compare delatas as string and not numbers)
term disparaissant (car delta identiques)
translate (entity translate) delete terms

Signed-off-by: bachy <git@g-u-i.net>
2012-05-24 23:38:22 +02:00
bachy 35a5eb3a60 bug fixing tode_url_outbound_alter
Signed-off-by: bachy <git@g-u-i.net>
2012-05-22 22:40:31 +02:00
bachy c0a9653975 add shortcuts action to materiaux/breves & companies admin pages
Signed-off-by: bachy <git@g-u-i.net>
2012-05-21 17:52:04 +02:00
bachy b920153c13 V1 RC
Signed-off-by: bachy <git@g-u-i.net>
2012-05-21 17:50:56 +02:00
bachy 18982b6700 bug fixing
ccode
homonym companies terms
tel to long set to memo instead of phone field

Signed-off-by: bachy <git@g-u-i.net>
2012-05-21 17:50:22 +02:00
bachy 7ce8d94ed9 php notice fixing
Signed-off-by: bachy <git@g-u-i.net>
2012-05-21 17:46:20 +02:00
bachy 45c41b319d improve form css
Signed-off-by: bachy <git@g-u-i.net>
2012-05-21 17:45:24 +02:00
bachy 461c93d48a Merge branch 'refs/heads/7.x-1.9-order_tracklist' into 7.x-1.9 2012-05-21 16:06:37 +02:00
bachy 47348748c4 js new items bug fixed
Signed-off-by: bachy <git@g-u-i.net>
2012-05-21 16:03:16 +02:00
bachy e31dc0d4fc first RC
Signed-off-by: bachy <git@g-u-i.net>
2012-05-18 22:43:44 +02:00
bachy 9e85e7a105 id materio
materieau = fixe famille, identifiant (against computer filed)
company = fixe multiple comp. with same names
+ misc

Signed-off-by: bachy <git@g-u-i.net>
2012-05-18 22:43:06 +02:00
bachy b861d2da15 removed dsm()
Signed-off-by: bachy <git@g-u-i.net>
2012-05-18 18:38:48 +02:00
bachy 2a9aca944c Merge branch 'refs/heads/7.x-1.9-starting_dpeth' into 7.x-1.9 2012-05-18 18:32:50 +02:00
bachy 1896d11e80 Merge branch 'refs/heads/7.x-1.9-order_tracklist' into 7.x-1.9 2012-05-18 18:30:02 +02:00
bachy b4b346b8a5 order track list item done
Signed-off-by: bachy <git@g-u-i.net>
2012-05-18 18:15:49 +02:00
bachy 93b7db54fe debug
- company : dispatch address filed in premise and sub_premise if more than 255 char
- company : avoid and record on memo tel1 if number is more than 15 char
- materiau : move product_info query in prepareRow()

Signed-off-by: bachy <git@g-u-i.net>
2012-05-16 08:05:22 +02:00
bachy 760047e9fc materiaux companies ok
+ sql improvement

Signed-off-by: bachy <git@g-u-i.net>
2012-05-13 23:02:27 +02:00
bachy 94bf329b91 Industrials OK
Company CT
account, contact, admin, sample USERS

Signed-off-by: bachy <git@g-u-i.net>
2012-05-13 13:27:58 +02:00
bachy 93b353922e widget settings défaut values fixe
Signed-off-by: bachy <git@g-u-i.net>
2012-05-09 08:13:15 +02:00
bachy df91706e57 last commit of 0.x dev
Signed-off-by: bachy <git@g-u-i.net>
2012-05-09 07:49:20 +02:00
bachy 4eda04b2f0 improvement
Signed-off-by: bachy <git@g-u-i.net>
2012-05-06 22:50:02 +02:00
bachy f4fc36431c Added starting depth for selectable items
Signed-off-by: bachy <git@g-u-i.net>
2012-05-01 16:34:06 +02:00
bachy 292f704f37 first import
Signed-off-by: bachy <git@g-u-i.net>
2012-05-01 15:30:58 +02:00
bachy 420f792a08 css
Signed-off-by: bachy <git@g-u-i.net>
2012-04-28 11:27:51 +02:00
bachy 4a958da4df parent bug on node update fixed
parent selection used to works only on node creation, now works on node creation and update

add automatic node titles snippet fro term translation

Signed-off-by: bachy <git@g-u-i.net>
2012-04-16 23:07:27 +02:00
bachy 5b16446d2f design improvment
Signed-off-by: bachy <git@g-u-i.net>
2012-04-12 10:09:11 +02:00
bachy f62d12ba55 first import
Signed-off-by: bachy <git@g-u-i.net>
2012-04-12 10:06:24 +02:00
bachy 8b5f7c5ccb autocompletedeluxe compatibility
Signed-off-by: bachy <git@g-u-i.net>
2012-04-03 22:01:12 +02:00
bachy 11d4a60bfc misc
Signed-off-by: bachy <git@g-u-i.net>
2012-04-03 21:59:36 +02:00
bachy 6a13522171 simplemenu become editmenu
Signed-off-by: bachy <git@g-u-i.net>
2012-04-03 20:26:37 +02:00
bachy 9d97a0b7b7 tode_url_outbound_alter improvement (path_alias)
Signed-off-by: bachy <git@g-u-i.net>
2012-03-18 14:38:35 +01:00
bachy 746109f079 ctools modal css + description white on black
Signed-off-by: bachy <git@g-u-i.net>
2012-03-18 14:32:03 +01:00
bachy 20ad82694b modale Tode creation
Signed-off-by: bachy <git@g-u-i.net>
2012-03-13 17:24:52 +01:00
bachy 49bdef396b improve admin interface
Signed-off-by: bachy <git@g-u-i.net>
2012-03-12 13:32:00 +01:00
bachy 9d10e145b4 micro debug
Signed-off-by: bachy <git@g-u-i.net>
2012-02-10 19:53:00 +01:00
bachy e0eae18f29 JS views save keyboard shortcut
Signed-off-by: bachy <git@g-u-i.net>
2012-02-10 19:51:10 +01:00
bachy 6ab6fc916b views integration start, not sure to keep that
Signed-off-by: bachy <git@g-u-i.net>
2012-02-07 19:46:12 +01:00
bachy dcd5bf483e design improvement
table tr hover
views filter and vbo css
add pager on top of view

Signed-off-by: bachy <git@g-u-i.net>
2012-02-07 19:42:20 +01:00
bachy 0a062a5297 preprocess_html
add icons

Signed-off-by: bachy <git@g-u-i.net>
2012-02-04 20:44:28 +01:00
bachy f50849a3a3 first import
Signed-off-by: bachy <git@g-u-i.net>
2012-02-04 18:57:50 +01:00
bachy 7f1b21c912 elements less
less elements import
page preprocess

Signed-off-by: bachy <git@g-u-i.net>
2012-02-04 18:52:39 +01:00
bachy fbaa166db8 bug correction
Signed-off-by: bachy <git@g-u-i.net>
2012-02-04 12:29:28 +01:00
bachy 60518fcfc2 icon
Signed-off-by: bachy <git@g-u-i.net>
2012-02-04 12:20:05 +01:00
bachy 747fef9a0a added icon
Signed-off-by: bachy <git@g-u-i.net>
2012-02-04 12:19:45 +01:00
bachy 0c65f95fbb first import
Signed-off-by: bachy <git@g-u-i.net>
2012-02-04 11:55:38 +01:00
bachy 4fc8e542c3 fixed i18n_taxonomy missing
added module_exists('i18n_taxonomy')

Signed-off-by: bachy <git@g-u-i.net>
2012-02-04 11:47:59 +01:00
bachy 8690f4a165 càrrectif bug : term created even if node form validation fail
- remove taxonomy term save from tod, let taxonomy handle the term
- move all toed process from hook_node_validate to hook_node_submit
- handle node creation with hook_node_presave
- handle node update (with term form) in hook_node_submit

Signed-off-by: bachy <git@g-u-i.net>
2012-02-02 18:48:13 +01:00
bachy 26591bf350 ++
Signed-off-by: bachy <git@g-u-i.net>
2012-01-21 18:31:28 +01:00
bachy 66ff837039 RC
Signed-off-by: bachy <git@g-u-i.net>
2012-01-17 16:14:17 +01:00
bachy 40f34e2191 first import
Signed-off-by: bachy <git@g-u-i.net>
2012-01-09 11:08:29 +01:00
bachy f83a0b9aee follow simple menu maj
Signed-off-by: bachy <git@g-u-i.net>
2012-01-08 19:40:28 +01:00
bachy 626ec7eabc Parent term options
Signed-off-by: bachy <git@g-u-i.net>
2012-01-07 22:59:15 +01:00
julien c22eb6bc11 clean version 2011-11-16 14:57:44 +01:00
julien 01aecdfd57 test 2011-11-16 14:55:13 +01:00
julien d84e570b3c test 2011-11-16 14:53:39 +01:00
julien 7351bc66a0 debbug bach 2011-10-14 14:02:46 +02:00
bachy 691ecd7d61 add gui icon
Signed-off-by: bachy <git@g-u-i.net>
2011-10-04 11:37:57 +02:00
julien 09bea7c003 test
Signed-off-by: julien <julien@g-u-i.net>
2011-09-19 11:08:42 +02:00
julien d23f6ab12d màj test
Signed-off-by: julien <julien@g-u-i.net>
2011-09-19 11:07:08 +02:00
julien aa857c3a40 Ajout d’un thème perso.
Signed-off-by: julien <julien@g-u-i.net>
2011-09-19 10:56:34 +02:00
AlexisWilke 072342016d Issue [#1120980] by stephen Verdant: Simplemenu missing for roles other than root administrator 2011-07-04 12:44:50 -07:00
The Great Git MigrationandDrupal Git User (LDAP) 5427717666 Removing translation directories 2011-02-25 02:07:04 +00:00
The Great Git MigrationandDrupal Git User (LDAP) a19cf5aae0 Stripping CVS keywords 2011-02-25 02:07:04 +00:00
Alexis Wilke 000cc37f2f * Port from 6.x changes. Check that $(element) is not empty to proceed. 2010-06-01 21:09:27 +00:00
Alexis Wilke 4d9851e410 First stride at getting a version 7.x working... 2010-05-31 09:44:37 +00:00
Alexis Wilke 9cdd779930 Delete simplemenu Multi-menu variables on uninstall(). 2010-05-26 06:33:32 +00:00
Alexis Wilke e3e87a93d7 * Fixed which menu is presented according to the settings (duh!) [#809546] 2010-05-26 06:10:34 +00:00
Alexis Wilke ea30728ec8 * Added a white line at the top of the drop downs. 2010-05-24 20:37:12 +00:00
Alexis Wilke 8a187e010b The multi-menu module addition 2010-05-16 23:20:33 +00:00
Alexis Wilke 03cc8469dc * Moved the multi-menu in a separate module so we don't automatically get
those features (save time for many of us!)
* Fixed the inactive parent function names
* Mark the top links with 'simplemenu_multi_menu_root'
2010-05-16 23:20:01 +00:00
Alexis Wilke 4430806082 * Fixed the Inactive Parent anchor name so they all are unique.
* Fixed the Devel menu name and identifier.
* Added support for users to select multiple menus.
2010-05-16 10:45:25 +00:00
Alexis Wilke d9f856a075 Pretty major update to better support several options:
* Added a white border at the top of the drop-downs in original
* Optimized the "view" test for simplemenu
* Enhanced the init() function by creating sub-functions and
  moving the footer functionality in it
* The list of themes is now dynamically generated from the
  simplemenu themes folder
* The list of superfish now includes a 'custom' so the code may
  come from another module or theme
* The Simplemenu variable can now be moved to the header and
  cache in its own JS file
* Create a Devel and Inactive Parents modules for additional
  functionality
* Moved the simplemenu modules in the Menu package
* Changed the function generating the menu so other modules may
  tweak the menu if so they wish
* Moved the support for Devel in a separate sub-module.
  (this is with the new way of doing things & has a corresponding
  update hook to tell users about the change. It is actually a good
  example of using the new hook system!)
2010-05-16 09:10:28 +00:00
Alexis Wilke b50c953eeb Moving Simplemenu in the Menu package with the other two new modules. 2010-05-16 09:00:07 +00:00
Alexis Wilke 5109e619cc Changes to support a fixed position (i.e. does not scroll with the page.)
Put the menu inside a <div> block (so fixed position works.)
Added support to switch between versions of superfish.
Added support for z-index parameter in admin screen.
2010-05-15 10:47:59 +00:00
Alexis Wilke d5ce155335 Small fix for I changed (fixed) the name of a variable. 2010-05-15 10:43:12 +00:00
Alexis Wilke de47d2f980 Reformatted with spaces instead of tabs as expected in Drupal.
Removed the z-index which was moved to the CSS template instead.
2010-05-15 10:42:33 +00:00
Alexis Wilke b8566401fd Reformatted with spaces as expected in Drupal 2010-05-15 10:41:35 +00:00
Alexis Wilke 8008cecb85 Created a template CSS that can be tweaked from the simplemenu administration
screen. The other CSS file is still work and used as a backup in case the
software cannot create a .css in the sites/name/files/css/... folder.
2010-05-15 10:40:53 +00:00
Alexis Wilke 2281eac5c1 Renamed the existing superfish as 1.4.1
Added superfish 1.4.8
The interface let you choose the version.
2010-05-15 10:39:43 +00:00
Alexis Wilke 202280fa6b Do not add the id="simplemenu" in JavaScript. Do it in PHP instead.
Added a new superfish parameter added in 1.4.8 (not present in 1.4.1 so it
has not side effect to the old version.)
2010-05-15 10:38:40 +00:00
Alexis Wilke c198b6f75f Fixed the description. 2010-05-15 10:36:13 +00:00
Alexis Wilke 13e221324c * Fixed the title of the simplemenu settings fieldset 2010-04-22 23:04:06 +00:00
Alexis Wilke f3409f422e * Moved a few things around in the settings screen.
* Fixed a potential problem with themes.
2010-04-21 10:32:17 +00:00
Alexis Wilke 1e627725ac * Removed the info that is to be added by Drupal automatically. 2010-04-14 09:40:29 +00:00
Alexis Wilke 18f4b720a8 * Many fixes as found in many issues.
[#565736]
  [#412500]
  [#421732]
  [#766466]
* Passed through coder (fixed tabs, missing spaces)
* Added missing hook_uninstall() function to delete variables
* Fixed some formatting in code (.module, .inc, .css, .js)
2010-04-13 01:19:04 +00:00
Roger López b21bbdb14f #350111: German Translation 6.x, by XerraX 2009-04-02 00:41:22 +00:00
Roger López 0dbc7d7df4 #390968: Use Drupal 6's JavaScript API to load the JavaScript for the module, by remi 2009-04-01 00:23:46 +00:00
Roger López b2b3f7f0b4 #405904: simple menu behind navigation 2009-04-01 00:17:17 +00:00
Roger López 5c42f3c952 #285533: The word 'false' appears in the menu, by dellis, remi, Roger Lopez 2009-04-01 00:07:16 +00:00
Roger López cc52ea5af6 #332711: Menu not displaying on certain paths caused by theme exclusions 2008-12-12 05:25:07 +00:00
Roger López a570618597 #235464: simplemenu disappears when Zen theme is turned on 2008-12-06 18:04:45 +00:00
Roger López b6333de34e #245656: Blue and Black menu doesn't look good (at least in Garland) 2008-12-06 17:35:02 +00:00
Roger López cc43fb6fa3 #336119: Problems with administration theme displaying on block admin page 2008-12-06 17:12:22 +00:00
Roger López 53a2bce0bd #296822: Add admin setting to disable menu on certain paths 2008-10-17 01:08:12 +00:00
Roger López a42aa98302 - #311977: update function 2008-10-12 23:35:48 +00:00
Roger López c98cff88e7 - #247373: found untranslatable strings, by Takafumi 2008-10-12 22:44:40 +00:00
Roger López c3abc04ce2 #309572: Code review by wmostrey
#232308: Show devel links feature
2008-10-12 22:36:56 +00:00
Takafumi d8f75a77e1 Adds Japanese translation 2008-04-16 13:08:51 +00:00
Ted Serbinski 23a553dc8b update simplemenu to 6.x, patch by starbow, ax 2008-02-28 21:47:17 +00:00
Ted Serbinski d45e0979fa - #199882, new options for controlling menu effects and timing, patch by Steve McKenzie, modified by me 2008-01-26 23:08:39 +00:00
Ted Serbinski f0db5b9d05 - #199715, remove absolute positioning to improve theme and CSS attaching compatibility 2008-01-26 22:27:42 +00:00
Ted Serbinski 2f6f865e33 - #195972, better default CSS to avoid conflicts with themes, patch by Keyz 2008-01-26 22:18:40 +00:00
Ted Serbinski ebdc82203b #200086, don't load non-existent custom.css file 2008-01-26 22:08:52 +00:00
Ted Serbinski f55e651074 #199224, patch by Darren Oh, modified by me, fix IE6/7 display issues 2008-01-26 22:04:26 +00:00
Ted Serbinski 5ef33d2fa2 fix JS parse error when compressed 2007-11-23 00:32:52 +00:00
Ted Serbinski f3935ae423 update README 2007-11-22 19:34:55 +00:00
Ted Serbinski 0dd46f5214 new black and blue theme and other CSS fixes 2007-11-22 19:26:04 +00:00
Ted Serbinski 5c6bec1d8a remove dependency on menu module 2007-11-22 18:14:34 +00:00
Ted Serbinski 67bf2e51ad #144742 - don't show A titles 2007-11-22 05:11:47 +00:00
Ted Serbinski 71f74b5565 #180106 - fix missing translatable strings 2007-11-22 05:07:07 +00:00
Ted Serbinski f9b542c391 add missing theme, fix hardcoded CSS 2007-11-22 05:03:10 +00:00
Ted Serbinski 57a7629b29 #162860 remove replace, not valid jQuery 2007-11-22 04:52:15 +00:00
Ted Serbinski ebb1ab6ce1 ability to set new themes now 2007-11-22 04:43:47 +00:00
Ted Serbinski 3d8955fb48 downgrade to superfish 1.3 so it actually works 2007-11-22 03:41:53 +00:00
Ted Serbinski 36d7d5cf37 remove RTL support, now in D6 2007-11-22 02:00:10 +00:00
Ted Serbinski 778c49b92e update to superfish 1.3.2 and latest bgiframe 2007-11-22 01:53:28 +00:00
Ted Serbinski 31259736e3 update to superfish 1.3 2007-11-22 01:38:45 +00:00
Ted Serbinski 08fe6616f9 fix parse error when using with JS aggregator 2007-07-12 02:10:46 +00:00
Derek Wright 3ce126eb48 #152819: Module .info files should not define 'version' in CVS 2007-06-18 23:07:03 +00:00
Ted Serbinski d32378cf35 fix z-index issue with themes, guarantee simplemenu to be on top, thanks Junyor 2007-04-16 06:08:40 +00:00
Ted Serbinski 2ca8cc7e56 sync info file version number 2007-04-08 04:26:45 +00:00
Ted Serbinski 53f9178ff0 re-adding missing text align 2007-04-07 06:22:55 +00:00
Ted Serbinski a5276dfe41 fix javascript chaining preventing effects 2007-04-07 05:51:57 +00:00
Ted Serbinski 21563d09ce major rewrite of menu code, tons of bug and usability fixes, faster, and better cross browser integration, and RTL support 2007-04-07 05:41:34 +00:00
Ted Serbinski 4d03934230 #132453, keep menus left justified even if the theme is centered, patch by dericknwq 2007-04-07 03:59:43 +00:00
Ted Serbinski ec97ad2402 remove AJAX callback, pass menu structure to page directly, dramatically faster, 1 less HTTP request, clear your menu cache, can produce weirdness/infinit loops 2007-04-07 03:57:43 +00:00
Ted Serbinski ccd2494fb7 #133010, fix devel links, patch by dericknwq 2007-04-07 03:30:15 +00:00
Ted Serbinski 6b915cda88 bump the revision number 2007-03-01 00:11:38 +00:00
Ted Serbinski eb09ab5342 add new RTL advanced setting for themes that need that 2007-03-01 00:08:04 +00:00
Ted Serbinski cd38617398 #116317, disable simplemenu on a per theme basis, patch by jjeff 2007-02-28 23:43:42 +00:00
Ted Serbinski 659a21255a #123486 fix typo in readme, thanks scor 2007-02-28 23:02:53 +00:00
Ted Serbinski 4687549e89 #114803, fix textareas not working, patch by quicksketch 2007-02-28 23:00:59 +00:00
Ted Serbinski ba3b8e51d1 #114107, improved interface/colors, patch by quicksketch 2007-01-30 06:02:09 +00:00
Ted Serbinski 6085946d1d #114015, advanced menu settings to place menu anywhere on page, patch by Steve McKenzie, modified by me 2007-01-30 05:41:41 +00:00
Ted Serbinski a5022b38fc bring back fixed position menu, but fix it from overlapping the theme 2007-01-30 04:57:20 +00:00
Ted Serbinski 831fbf4e0f fix page scroll down, #108655 2007-01-30 04:53:45 +00:00
Ted Serbinski 7bbcc73ae8 removing unused icon 2007-01-30 04:46:49 +00:00
Ted Serbinski 6f6aef2e67 updated theme for menu, better usability, #113203 2007-01-30 04:45:40 +00:00
Ted Serbinski cb22790246 #108971, use any menu not just root menus, patch by ewhipple 2007-01-16 06:47:15 +00:00
Ted Serbinski cca7f982e4 capitalization fix 2007-01-11 04:14:29 +00:00
Ted Serbinski 50807fe40f add version info 2007-01-11 04:03:09 +00:00
Ted Serbinski 60cc6ae1a3 renaming menu bar module to SimpleMenu module 2007-01-11 03:25:24 +00:00
Ted Serbinski 1ed6151591 smooth initial loading of menu, thanks to craq for the tip 2007-01-10 06:13:00 +00:00
Ted Serbinski 0c661bcbd4 #103381 use negative margins for menus, gets rid of horizontal scrollbar, patch by quicksketch 2007-01-10 05:42:41 +00:00
Ted Serbinski 1251927952 #108098 fix cursor being hidden in firefox, patch by quicksketch. note, the menu no longer stays on top as you scroll, however forms are usable once again. this feature will return in version 3 when it's rewritten to be 100% jQuery. 2007-01-10 05:40:31 +00:00
Ted Serbinski 5ca8a4fc6c #102423 fix anchor title from interfering with links, patch by quicksketch 2007-01-10 05:36:57 +00:00
Ted Serbinski 44e1fc9296 fix default menu size to be a bit larger 2006-11-18 01:27:40 +00:00
Ted Serbinski 24bb9a57bb fix menu capitalization to be consistent with core 2006-11-18 01:26:44 +00:00
Ted Serbinski 911791b362 fix menu paths when mod_rewrite is not available 2006-11-18 01:22:58 +00:00
Ted Serbinski 44264836be new menu bar built with jquery 2006-09-18 21:54:19 +00:00
11841 changed files with 2622841 additions and 861 deletions
Executable
+31
View File
@@ -0,0 +1,31 @@
# Ignore configuration files that may contain sensitive information.
sites/*/settings*.php
sites/*/drushrc*
# Ignore paths that contain user-generated content.
#sites/*
sites/*/files
sites/*/private
sites/all/translations/*
_base_d7.tmproj
/_materio.sublime-project
/_materio.sublime-workspace
/_solr.sublime-project
/_solr.sublime-workspace
*.sublime-project
*.sublime-workspace
*.sublime-project*
node_modules
.sass-cache
typescript
.directory
*.old_patched
sync_uploads
vendor
Executable
+296
View File
@@ -0,0 +1,296 @@
#
# Apache/PHP/Drupal settings:
#
# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$">
Order allow,deny
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Follow symbolic links in this directory.
Options +FollowSymLinks
# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php index.html index.htm
# Override PHP settings that cannot be changed at runtime. See
# sites/default/default.settings.php and drupal_environment_initialize() in
# includes/bootstrap.inc for settings that can be changed at runtime.
# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_flag magic_quotes_gpc off
php_flag magic_quotes_sybase off
php_flag register_globals off
php_flag session.auto_start off
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_flag mbstring.encoding_translation off
</IfModule>
# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On
# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600
<FilesMatch \.php$>
# Do not allow PHP scripts to be cached unless they explicitly send cache
# headers themselves. Otherwise all scripts would have to overwrite the
# headers set by mod_expires if they want another caching behavior. This may
# fail if an error occurs early in the bootstrap process, and it may cause
# problems if a non-Drupal PHP file is installed in a subdirectory.
ExpiresActive Off
</FilesMatch>
</IfModule>
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# Set "protossl" to "s" if we were accessed via https://. This is used later
# if you enable "www." stripping or enforcement, in order to ensure that
# you don't bounce between http and https.
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
# Make sure Authorization HTTP header is available to PHP
# even when running as CGI or FastCGI.
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Block access to "hidden" directories whose names begin with a period. This
# includes directories used by version control systems such as Subversion or
# Git to store control files. Files whose names begin with a period, as well
# as the control files used by CVS, are protected by the FilesMatch directive
# above.
#
# NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
# not possible to block access to entire directories from .htaccess, because
# <DirectoryMatch> is not allowed here.
#
# If you do not have mod_rewrite installed, you should remove these
# directories from your webroot or otherwise protect them from being
# downloaded.
RewriteRule "(^|/)\." - [F]
# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} .
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
# redirect all materiau domains to materio.com
RewriteCond %{HTTP_HOST} ^basebeta\.materio\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.materio\.fr [OR]
RewriteCond %{HTTP_HOST} ^materio\.fr [OR]
RewriteCond %{HTTP_HOST} ^www\.materio\.net [OR]
RewriteCond %{HTTP_HOST} ^materio\.net [OR]
RewriteCond %{HTTP_HOST} ^www\.materio\.eu [OR]
RewriteCond %{HTTP_HOST} ^materio\.eu [OR]
RewriteCond %{HTTP_HOST} ^www\.materio\.com
# RewriteRule ^ http%{ENV:protossl}://materio.com%{REQUEST_URI} [L,R=301]
RewriteRule ^ https://materio.com%{REQUEST_URI} [L,R=301]
# Redirect to HTTPS
# RewriteCond %{HTTPS} off
# RewriteCond %{HTTP:X-Forwarded-Proto} !https
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
RewriteBase /
# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
# Rules to correctly serve gzip compressed CSS and JS files.
# Requires both mod_rewrite and mod_headers to be enabled.
<IfModule mod_headers.c>
# Serve gzip compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
# Serve gzip compressed JS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
# Serve correct content types, and prevent mod_deflate double gzip.
RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
<FilesMatch "(\.js\.gz|\.css\.gz)$">
# Serve correct encoding type.
Header set Content-Encoding gzip
# Force proxies to cache gzipped & non-gzipped css/js files separately.
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
</IfModule>
# Add headers to all responses.
<IfModule mod_headers.c>
# Disable content sniffing, since it's an attack vector.
Header always set X-Content-Type-Options nosniff
</IfModule>
# from boiler plate V5.02
# ######################################################################
# # MEDIA TYPES AND CHARACTER ENCODINGS #
# ######################################################################
# ----------------------------------------------------------------------
# | Media types |
# ----------------------------------------------------------------------
# Serve resources with the proper media types (f.k.a. MIME types).
#
# https://www.iana.org/assignments/media-types/media-types.xhtml
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype
<IfModule mod_mime.c>
# Data interchange
AddType application/atom+xml atom
AddType application/json json map topojson
AddType application/ld+json jsonld
AddType application/rss+xml rss
AddType application/vnd.geo+json geojson
AddType application/xml rdf xml
# JavaScript
# Normalize to standard type.
# https://tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript js
# Manifest files
AddType application/manifest+json webmanifest
AddType application/x-web-app-manifest+json webapp
AddType text/cache-manifest appcache
# Media files
AddType audio/mp4 f4a f4b m4a
AddType audio/ogg oga ogg opus
AddType image/bmp bmp
AddType image/svg+xml svg svgz
AddType image/webp webp
AddType video/mp4 f4v f4p m4v mp4
AddType video/ogg ogv
AddType video/webm webm
AddType video/x-flv flv
# Serving `.ico` image files with a different media type
# prevents Internet Explorer from displaying then as images:
# https://github.com/h5bp/html5-boilerplate/commit/37b5fec090d00f38de64b591bcddcb205aadf8ee
AddType image/x-icon cur ico
# Web fonts
AddType application/font-woff woff
AddType application/font-woff2 woff2
AddType application/vnd.ms-fontobject eot
# Browsers usually ignore the font media types and simply sniff
# the bytes to figure out the font type.
# https://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern
#
# However, Blink and WebKit based browsers will show a warning
# in the console if the following font types are served with any
# other media types.
AddType application/x-font-ttf ttc ttf
AddType font/opentype otf
# Other
AddType application/octet-stream safariextz
AddType application/x-bb-appworld bbaw
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-xpinstall xpi
AddType text/vcard vcard vcf
AddType text/vnd.rim.location.xloc xloc
AddType text/vtt vtt
AddType text/x-component htc
</IfModule>
# ----------------------------------------------------------------------
# | Character encodings |
# ----------------------------------------------------------------------
# Serve all resources labeled as `text/html` or `text/plain`
# with the media type `charset` parameter set to `UTF-8`.
#
# https://httpd.apache.org/docs/current/mod/core.html#adddefaultcharset
AddDefaultCharset utf-8
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Serve the following file types with the media type `charset`
# parameter set to `UTF-8`.
#
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addcharset
<IfModule mod_mime.c>
AddCharset utf-8 .atom \
.bbaw \
.css \
.geojson \
.js \
.json \
.jsonld \
.manifest \
.rdf \
.rss \
.topojson \
.vtt \
.webapp \
.webmanifest \
.xloc \
.xml
</IfModule>
@@ -0,0 +1,73 @@
From 1f82c4ef9b474a12d160813f767128d645f524cc Mon Sep 17 00:00:00 2001
From: Bachir Soussi Chiadmi <bachir@g-u-i.me>
Date: Sun, 19 Apr 2015 21:04:36 +0200
Subject: [PATCH] repatched entityrefeerence module
---
...ityReference_SelectionHandler_Generic.class.php | 43 +++++++++++++++++++---
1 file changed, 38 insertions(+), 5 deletions(-)
diff --git a/sites/all/modules/contrib/fields/entityreference/plugins/selection/EntityReference_SelectionHandler_Generic.class.php b/sites/all/modules/contrib/fields/entityreference/plugins/selection/EntityReference_SelectionHandler_Generic.class.php
index 444a74c..660fe3d 100644
--- a/sites/all/modules/contrib/fields/entityreference/plugins/selection/EntityReference_SelectionHandler_Generic.class.php
+++ b/sites/all/modules/contrib/fields/entityreference/plugins/selection/EntityReference_SelectionHandler_Generic.class.php
@@ -370,6 +370,28 @@ class EntityReference_SelectionHandler_Generic_node extends EntityReference_Sele
* This only exists to workaround core bugs.
*/
class EntityReference_SelectionHandler_Generic_user extends EntityReference_SelectionHandler_Generic {
+
+ /**
+ * Implements EntityReferenceHandler::settingsForm().
+ */
+ public static function settingsForm($field, $instance) {
+ $settings = $field['settings']['handler_settings'];
+ $form = parent::settingsForm($field, $instance);
+ $form['referenceable_roles'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('User roles that can be referenced'),
+ '#default_value' => isset($settings['referenceable_roles']) ? array_filter($settings['referenceable_roles']) : array(),
+ '#options' => user_roles(TRUE),
+ );
+ $form['referenceable_status'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('User status that can be referenced'),
+ '#default_value' => isset($settings['referenceable_status']) ? array_filter($settings['referenceable_status']) : array('active' => 'active'),
+ '#options' => array('active' => t('Active'), 'blocked' => t('Blocked')),
+ );
+ return $form;
+ }
+
public function buildEntityFieldQuery($match = NULL, $match_operator = 'CONTAINS') {
$query = parent::buildEntityFieldQuery($match, $match_operator);
@@ -378,11 +400,22 @@ class EntityReference_SelectionHandler_Generic_user extends EntityReference_Sele
$query->propertyCondition('name', $match, $match_operator);
}
- // Adding the 'user_access' tag is sadly insufficient for users: core
- // requires us to also know about the concept of 'blocked' and
- // 'active'.
- if (!user_access('administer users')) {
- $query->propertyCondition('status', 1);
+ $field = $this->field;
+ $settings = $field['settings']['handler_settings'];
+ $referenceable_roles = isset($settings['referenceable_roles']) ? array_filter($settings['referenceable_roles']) : array();
+ $referenceable_status = isset($settings['referenceable_status']) ? array_filter($settings['referenceable_status']) : array('active' => 'active');
+
+ // If this filter is not filled, use the users access permissions.
+ if (empty($referenceable_status)) {
+ // Adding the 'user_access' tag is sadly insufficient for users: core
+ // requires us to also know about the concept of 'blocked' and 'active'.
+ if (!user_access('administer users')) {
+ $query->propertyCondition('status', 1);
+ }
+ }
+ elseif (count($referenceable_status) == 1) {
+ $values = array('active' => 1, 'blocked' => 0);
+ $query->propertyCondition('status', $values[key($referenceable_status)]);
}
return $query;
}
--
2.3.5
+25
View File
@@ -0,0 +1,25 @@
From 7becdeff922748fb65a320903b0ee37268895dd1 Mon Sep 17 00:00:00 2001
From: Bachir Soussi Chiadmi <bachir@g-u-i.me>
Date: Sun, 19 Apr 2015 21:13:38 +0200
Subject: [PATCH] repatched views module
---
sites/all/modules/contrib/views/views/handlers/views_handler_field.inc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_field.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_field.inc
index 65210d9..c04fd46 100644
--- a/sites/all/modules/contrib/views/views/handlers/views_handler_field.inc
+++ b/sites/all/modules/contrib/views/views/handlers/views_handler_field.inc
@@ -372,7 +372,7 @@ class views_handler_field extends views_handler {
* Optional name of the field where the value is stored.
*/
function get_value($values, $field = NULL) {
- $alias = isset($field) ? $this->aliases[$field] : $this->field_alias;
+ $alias = isset($field) && isset($this->aliases[$field]) ? $this->aliases[$field] : $this->field_alias;
if (isset($values->{$alias})) {
return $values->{$alias};
}
--
2.3.5
View File
@@ -0,0 +1,155 @@
diff --git a/modules/user/user.module b/modules/user/user.module
index bdfd36f..d33a528 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -2328,14 +2328,26 @@ function user_external_login_register($name, $module) {
* following properties:
* - uid: The user ID number.
* - login: The UNIX timestamp of the user's last login.
+ * @param array $options
+ * (optional) A keyed array of settings. Supported options are:
+ * - langcode: A language code to be used when generating locale-sensitive
+ * urls. If langcode is NULL the users preferred language is used.
*
* @return
* A unique URL that provides a one-time log in for the user, from which
* they can change their password.
*/
-function user_pass_reset_url($account) {
+function user_pass_reset_url($account, $options = array()) {
$timestamp = REQUEST_TIME;
- return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), array('absolute' => TRUE));
+ $url_options = array('absolute' => TRUE);
+ if (isset($options['langcode'])) {
+ $languages = language_list();
+ $url_options['language'] = $languages[$options['langcode']];
+ }
+ else {
+ $url_options['language'] = user_preferred_language($account);
+ }
+ return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), $url_options);
}
/**
@@ -2347,6 +2359,10 @@ function user_pass_reset_url($account) {
* - uid: The user ID number.
* - pass: The hashed user password string.
* - login: The UNIX timestamp of the user's last login.
+ * @param array $options
+ * (optional) A keyed array of settings. Supported options are:
+ * - langcode: A language code to be used when generating locale-sensitive
+ * urls. If langcode is NULL the users preferred language is used.
*
* @return
* A unique URL that may be used to confirm the cancellation of the user
@@ -2355,9 +2371,17 @@ function user_pass_reset_url($account) {
* @see user_mail_tokens()
* @see user_cancel_confirm()
*/
-function user_cancel_url($account) {
+function user_cancel_url($account, $options = array()) {
$timestamp = REQUEST_TIME;
- return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), array('absolute' => TRUE));
+ $url_options = array('absolute' => TRUE);
+ if (isset($options['langcode'])) {
+ $languages = language_list();
+ $url_options['language'] = $languages[$options['langcode']];
+ }
+ else {
+ $url_options['language'] = user_preferred_language($account);
+ }
+ return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), $url_options);
}
/**
@@ -2843,7 +2867,7 @@ Your account on [site:name] has been canceled.
if ($replace) {
// We do not sanitize the token replacement, since the output of this
// replacement is intended for an e-mail message, not a web browser.
- return token_replace($text, $variables, array('language' => $language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
+ return token_replace($text, $variables, array('language' => $language, 'langcode' => $langcode, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
}
return $text;
@@ -2870,8 +2894,8 @@ Your account on [site:name] has been canceled.
*/
function user_mail_tokens(&$replacements, $data, $options) {
if (isset($data['user'])) {
- $replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user']);
- $replacements['[user:cancel-url]'] = user_cancel_url($data['user']);
+ $replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user'], $options);
+ $replacements['[user:cancel-url]'] = user_cancel_url($data['user'], $options);
}
}
diff --git a/modules/user/user.test b/modules/user/user.test
index 07be4c2..4536e0c 100644
--- a/modules/user/user.test
+++ b/modules/user/user.test
@@ -2145,6 +2145,26 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
);
}
+ public function setUp() {
+ parent::setUp('locale');
+
+ $account = $this->drupalCreateUser(array('access administration pages', 'administer languages'));
+ $this->drupalLogin($account);
+
+ // Add language.
+ $edit = array('langcode' => 'de');
+ $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
+
+ // Enable URL language detection and selection.
+ $edit = array('language[enabled][locale-url]' => 1);
+ $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
+
+ // Reset static caching.
+ drupal_static_reset('language_list');
+ drupal_static_reset('locale_url_outbound_alter');
+ drupal_static_reset('locale_language_url_rewrite_url');
+ }
+
/**
* Creates a user, then tests the tokens generated from it.
*/
@@ -2195,6 +2215,39 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
$output = token_replace($input, array('user' => $account), array('language' => $language, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, format_string('Unsanitized user token %token replaced.', array('%token' => $input)));
}
+
+ $languages = language_list();
+
+ // Generate login and cancel link.
+ $tests = array();
+ $tests['[user:one-time-login-url]'] = user_pass_reset_url($account);
+ $tests['[user:cancel-url]'] = user_cancel_url($account);
+
+ // Generate tokens with interface language.
+ $link = url('user', array('absolute' => TRUE));
+ foreach ($tests as $input => $expected) {
+ $output = token_replace($input, array('user' => $account), array('langcode' => $language->language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
+ $this->assertTrue(strpos($output, $link) === 0, 'Generated URL is in interface language.');
+ }
+
+ // Generate tokens with the user's preferred language.
+ $edit['language'] = 'de';
+ $account = user_save($account, $edit);
+ $link = url('user', array('language' => $languages[$account->language], 'absolute' => TRUE));
+ foreach ($tests as $input => $expected) {
+ $output = token_replace($input, array('user' => $account), array('callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
+ $this->assertTrue(strpos($output, $link) === 0, "Generated URL is in the user's preferred language.");
+ }
+
+ // Generate tokens with one specific language.
+ $link = url('user', array('language' => $languages['de'], 'absolute' => TRUE));
+ foreach ($tests as $input => $expected) {
+ foreach (array($user1, $user2) as $account) {
+ $output = token_replace($input, array('user' => $account), array('langcode' => 'de', 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
+ $this->assertTrue(strpos($output, $link) === 0, "Generated URL in in the requested language.");
+ }
+ }
+
}
}
+2414
View File
File diff suppressed because it is too large Load Diff
+44
View File
@@ -0,0 +1,44 @@
All Drupal code is Copyright 2001 - 2013 by the original authors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with this program as the file LICENSE.txt; if not, please see
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
Drupal is a registered trademark of Dries Buytaert.
Drupal includes works under other copyright notices and distributed
according to the terms of the GNU General Public License or a compatible
license, including:
Javascript
Farbtastic - Copyright (c) 2010 Matt Farina
jQuery - Copyright (c) 2010 John Resig
jQuery BBQ - Copyright (c) 2010 "Cowboy" Ben Alman
jQuery Cookie - Copyright (c) 2006 Klaus Hartl
jQuery Form - Copyright (c) 2010 Mike Alsup
jQuery Once - Copyright (c) 2009 Konstantin Kfer
jQuery UI - Copyright (c) 2010 by the original authors
(http://jqueryui.com/about)
Sizzle.js - Copyright (c) 2010 The Dojo Foundation (http://sizzlejs.com/)
PHP
ArchiveTar - Copyright (c) 1997 - 2008 Vincent Blavet
+45
View File
@@ -0,0 +1,45 @@
CREATE THE MySQL DATABASE
--------------------------
This step is only necessary if you don't already have a database set up (e.g.,
by your host). In the following examples, 'username' is an example MySQL user
which has the CREATE and GRANT privileges. Use the appropriate user name for
your system.
First, you must create a new database for your Drupal site (here, 'databasename'
is the name of the new database):
mysqladmin -u username -p create databasename
MySQL will prompt for the 'username' database password and then create the
initial database files. Next you must log in and set the access database rights:
mysql -u username -p
Again, you will be asked for the 'username' database password. At the MySQL
prompt, enter the following command:
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
CREATE TEMPORARY TABLES ON databasename.*
TO 'username'@'localhost' IDENTIFIED BY 'password';
where:
'databasename' is the name of your database
'username' is the username of your MySQL account
'localhost' is the web server host where Drupal is installed
'password' is the password required for that username
Note: Unless the database user/host combination for your Drupal installation
has all of the privileges listed above (except possibly CREATE TEMPORARY TABLES,
which is currently only used by Drupal core automated tests and some
contributed modules), you will not be able to install or run Drupal.
If successful, MySQL will reply with:
Query OK, 0 rows affected
If the InnoDB storage engine is available, it will be used for all database
tables. InnoDB provides features over MyISAM such as transaction support,
row-level locks, and consistent non-locking reads.
+44
View File
@@ -0,0 +1,44 @@
CREATE THE PostgreSQL DATABASE
------------------------------
Note that the database must be created with UTF-8 (Unicode) encoding.
1. CREATE DATABASE USER
This step is only necessary if you don't already have a user set up (e.g., by
your host), or want to create a new user for use with Drupal only. The
following command creates a new user named 'username' and asks for a password
for that user:
createuser --pwprompt --encrypted --no-createrole --no-createdb username
If there are no errors, then the command was successful.
2. CREATE DRUPAL DATABASE
This step is only necessary if you don't already have a database set up
(e.g., by your host) or want to create a new database for use with Drupal
only. The following command creates a new database named 'databasename',
which is owned by the previously created 'username':
createdb --encoding=UTF8 --owner=username databasename
If there are no errors, then the command was successful.
3. CREATE SCHEMA OR SCHEMAS (Optional advanced step)
Drupal will run across different schemas within your database if you so wish.
By default, Drupal runs inside the 'public' schema but you can use $db_prefix
inside settings.php to define a schema for Drupal to run inside of, or
specify tables that are shared inside of a separate schema. Drupal will not
create schemas for you. In fact, the user that Drupal runs as should not be
allowed to do this. You'll need to execute the SQL below as a superuser,
replace 'username' with the username that Drupal uses to connect to
PostgreSQL, and replace 'schema_name' with a schema name you wish to use,
such as 'shared':
CREATE SCHEMA schema_name AUTHORIZATION username;
Do this for as many schemas as you need. See default.settings.php for
instructions on how to set which tables use which schemas.
+31
View File
@@ -0,0 +1,31 @@
SQLITE REQUIREMENTS
-------------------
To use SQLite with your Drupal installation, the following requirements must be
met: Server has PHP 5.2 or later with PDO, and the PDO SQLite driver must be
enabled.
SQLITE DATABASE CREATION
------------------------
The Drupal installer will create the SQLite database for you. The only
requirement is that the installer must have write permissions to the directory
where the database file resides. This directory (not just the database file) also
has to remain writeable by the web server going forward for SQLite to continue to
be able to operate.
On the "Database configuration" form in the "Database file" field, you must
supply the exact path to where you wish your database file to reside. It is
strongly suggested that you choose a path that is outside of the webroot, yet
ensure that the directory is writeable by the web server.
If you must place your database file in your webroot, you could try using the
following in your "Database file" field:
sites/default/files/.ht.sqlite
Note: The .ht in the name will tell Apache to prevent the database from being
downloaded. Please check that the file is, indeed, protected by your webserver.
If not, please consult the documentation of your webserver on how to protect a
file from downloading.
+400
View File
@@ -0,0 +1,400 @@
CONTENTS OF THIS FILE
---------------------
* Requirements and notes
* Optional server requirements
* Installation
* Building and customizing your site
* Multisite configuration
* More information
REQUIREMENTS AND NOTES
----------------------
Drupal requires:
- A web server. Apache (version 2.0 or greater) is recommended.
- PHP 5.2.4 (or greater) (http://www.php.net/).
- One of the following databases:
- MySQL 5.0.15 (or greater) (http://www.mysql.com/).
- MariaDB 5.1.44 (or greater) (http://mariadb.org/). MariaDB is a fully
compatible drop-in replacement for MySQL.
- Percona Server 5.1.70 (or greater) (http://www.percona.com/). Percona
Server is a backwards-compatible replacement for MySQL.
- PostgreSQL 8.3 (or greater) (http://www.postgresql.org/).
- SQLite 3.3.7 (or greater) (http://www.sqlite.org/).
For more detailed information about Drupal requirements, including a list of
PHP extensions and configurations that are required, see "System requirements"
(http://drupal.org/requirements) in the Drupal.org online documentation.
For detailed information on how to configure a test server environment using a
variety of operating systems and web servers, see "Local server setup"
(http://drupal.org/node/157602) in the Drupal.org online documentation.
Note that all directories mentioned in this document are always relative to the
directory of your Drupal installation, and commands are meant to be run from
this directory (except for the initial commands that create that directory).
OPTIONAL SERVER REQUIREMENTS
----------------------------
- If you want to use Drupal's "Clean URLs" feature on an Apache web server, you
will need the mod_rewrite module and the ability to use local .htaccess
files. For Clean URLs support on IIS, see "Clean URLs with IIS"
(http://drupal.org/node/3854) in the Drupal.org online documentation.
- If you plan to use XML-based services such as RSS aggregation, you will need
PHP's XML extension. This extension is enabled by default on most PHP
installations.
- To serve gzip compressed CSS and JS files on an Apache web server, you will
need the mod_headers module and the ability to use local .htaccess files.
- Some Drupal functionality (e.g., checking whether Drupal and contributed
modules need updates, RSS aggregation, etc.) require that the web server be
able to go out to the web and download information. If you want to use this
functionality, you need to verify that your hosting provider or server
configuration allows the web server to initiate outbound connections. Most web
hosting setups allow this.
INSTALLATION
------------
1. Download and extract Drupal.
You can obtain the latest Drupal release from http://drupal.org -- the files
are available in .tar.gz and .zip formats and can be extracted using most
compression tools.
To download and extract the files, on a typical Unix/Linux command line, use
the following commands (assuming you want version x.y of Drupal in .tar.gz
format):
wget http://drupal.org/files/projects/drupal-x.y.tar.gz
tar -zxvf drupal-x.y.tar.gz
This will create a new directory drupal-x.y/ containing all Drupal files and
directories. Then, to move the contents of that directory into a directory
within your web server's document root or your public HTML directory,
continue with this command:
mv drupal-x.y/* drupal-x.y/.htaccess /path/to/your/installation
2. Optionally, download a translation.
By default, Drupal is installed in English, and further languages may be
installed later. If you prefer to install Drupal in another language
initially:
- Download a translation file for the correct Drupal version and language
from the translation server: http://localize.drupal.org/translate/downloads
- Place the file into your installation profile's translations directory.
For instance, if you are using the Standard installation profile,
move the .po file into the directory:
profiles/standard/translations/
For detailed instructions, visit http://drupal.org/localize
3. Create the Drupal database.
Because Drupal stores all site information in a database, you must create
this database in order to install Drupal, and grant Drupal certain database
privileges (such as the ability to create tables). For details, consult
INSTALL.mysql.txt, INSTALL.pgsql.txt, or INSTALL.sqlite.txt. You may also
need to consult your web hosting provider for instructions specific to your
web host.
Take note of the username, password, database name, and hostname as you
create the database. You will enter this information during the install.
4. Run the install script.
To run the install script, point your browser to the base URL of your
website (e.g., http://www.example.com).
You will be guided through several screens to set up the database, add the
site maintenance account (the first user, also known as user/1), and provide
basic web site settings.
During installation, several files and directories need to be created, which
the install script will try to do automatically. However, on some hosting
environments, manual steps are required, and the install script will tell
you that it cannot proceed until you fix certain issues. This is normal and
does not indicate a problem with your server.
The most common steps you may need to perform are:
a. Missing files directory.
The install script will attempt to create a file storage directory in
the default location at sites/default/files (the location of the files
directory may be changed after Drupal is installed).
If auto-creation fails, you can make it work by changing permissions on
the sites/default directory so that the web server can create the files
directory within it for you. (If you are creating a multisite
installation, substitute the correct sites directory for sites/default;
see the Multisite Configuration section of this file, below.)
For example, on a Unix/Linux command line, you can grant everyone
(including the web server) permission to write to the sites/default
directory with this command:
chmod a+w sites/default
Be sure to set the permissions back after the installation is finished!
Sample command:
chmod go-w sites/default
Alternatively, instead of allowing the web server to create the files
directory for you as described above, you can create it yourself. Sample
commands from a Unix/Linux command line:
mkdir sites/default/files
chmod a+w sites/default/files
b. Missing settings file.
Drupal will try to automatically create a settings.php configuration file,
which is normally in the directory sites/default (to avoid problems when
upgrading, Drupal is not packaged with this file). If auto-creation fails,
you will need to create this file yourself, using the file
sites/default/default.settings.php as a template.
For example, on a Unix/Linux command line, you can make a copy of the
default.settings.php file with the command:
cp sites/default/default.settings.php sites/default/settings.php
Next, grant write privileges to the file to everyone (including the web
server) with the command:
chmod a+w sites/default/settings.php
Be sure to set the permissions back after the installation is finished!
Sample command:
chmod go-w sites/default/settings.php
c. Write permissions after install.
The install script will attempt to write-protect the settings.php file and
the sites/default directory after saving your configuration. If this
fails, you will be notified, and you can do it manually. Sample commands
from a Unix/Linux command line:
chmod go-w sites/default/settings.php
chmod go-w sites/default
5. Verify that the site is working.
When the install script finishes, you will be logged in with the site
maintenance account on a "Welcome" page. If the default Drupal theme is not
displaying properly and links on the page result in "Page Not Found" errors,
you may be experiencing problems with clean URLs. Visit
http://drupal.org/getting-started/clean-urls to troubleshoot.
6. Change file system storage settings (optional).
The files directory created in step 4 is the default file system path used to
store all uploaded files, as well as some temporary files created by
Drupal. After installation, you can modify the file system path to store
uploaded files in a different location.
It is not necessary to modify this path, but you may wish to change it if:
- Your site runs multiple Drupal installations from a single codebase (modify
the file system path of each installation to a different directory so that
uploads do not overlap between installations).
- Your site runs on a number of web servers behind a load balancer or reverse
proxy (modify the file system path on each server to point to a shared file
repository).
- You want to restrict access to uploaded files.
To modify the file system path:
a. Ensure that the new location for the path exists and is writable by the
web server. For example, to create a new directory named uploads and grant
write permissions, use the following commands on a Unix/Linux command
line:
mkdir uploads
chmod a+w uploads
b. Navigate to Administration > Configuration > Media > File system, and
enter the desired path. Note that if you want to use private file storage,
you need to first enter the path for private files and save the
configuration, and then change the "Default download method" setting and
save again.
Changing the file system path after files have been uploaded may cause
unexpected problems on an existing site. If you modify the file system path
on an existing site, remember to copy all files from the original location
to the new location.
7. Revoke documentation file permissions (optional).
Some administrators suggest making the documentation files, especially
CHANGELOG.txt, non-readable so that the exact version of Drupal you are
running is slightly more difficult to determine. If you wish to implement
this optional security measure, from a Unix/Linux command line you can use
the following command:
chmod a-r CHANGELOG.txt
Note that the example only affects CHANGELOG.txt. To completely hide all
documentation files from public view, repeat this command for each of the
Drupal documentation files in the installation directory, substituting the
name of each file for CHANGELOG.txt in the example.
For more information on setting file permissions, see "Modifying Linux,
Unix, and Mac file permissions" (http://drupal.org/node/202483) or
"Modifying Windows file permissions" (http://drupal.org/node/202491) in the
Drupal.org online documentation.
8. Set up independent "cron" maintenance jobs.
Many Drupal modules have tasks that must be run periodically, including the
Search module (building and updating the index used for keyword searching),
the Aggregator module (retrieving feeds from other sites), and the System
module (performing routine maintenance and pruning of database tables). These
tasks are known as "cron maintenance tasks", named after the Unix/Linux
"cron" utility.
When you install Drupal, its built-in cron feature is enabled, which
automatically runs the cron tasks periodically, triggered by people visiting
pages of your site. You can configure the built-in cron feature by navigating
to Administration > Configuration > System > Cron.
It is also possible to run the cron tasks independent of site visits; this is
recommended for most sites. To do this, you will need to set up an automated
process to visit the page cron.php on your site, which executes the cron
tasks.
The URL of the cron.php page requires a "cron key" to protect against
unauthorized access. Your site's cron key is automatically generated during
installation and is specific to your site. The full URL of the page, with the
cron key, is available in the "Cron maintenance tasks" section of the Status
report page at Administration > Reports > Status report.
As an example for how to set up this automated process, you can use the
crontab utility on Unix/Linux systems. The following crontab line uses the
wget command to visit the cron.php page, and runs each hour, on the hour:
0 * * * * wget -O - -q -t 1 http://example.com/cron.php?cron_key=YOURKEY
Replace the text "http://example.com/cron.php?cron_key=YOURKEY" in the
example with the full URL displayed under "Cron maintenance tasks" on the
"Status report" page.
More information about cron maintenance tasks is available at
http://drupal.org/cron, and sample cron shell scripts can be found in the
scripts/ directory. (Note that these scripts must be customized like the
above example, to add your site-specific cron key and domain name.)
BUILDING AND CUSTOMIZING YOUR SITE
----------------------------------
A new installation of Drupal defaults to a very basic configuration. To extend
your site, you use "modules" and "themes". A module is a plugin that adds
functionality to Drupal, while a theme changes the look of your site. The core
of Drupal provides several optional modules and themes, and you can download
more at http://drupal.org/project/modules and http://drupal.org/project/themes
Do not mix downloaded or custom modules and themes with Drupal's core modules
and themes. Drupal's modules and themes are located in the top-level modules and
themes directories, while the modules and themes you add to Drupal are normally
placed in the sites/all/modules and sites/all/themes directories. If you run a
multisite installation, you can also place modules and themes in the
site-specific directories -- see the Multisite Configuration section, below.
Never edit Drupal's core modules and themes; instead, use the hooks available in
the Drupal API. To modify the behavior of Drupal, develop a module as described
at http://drupal.org/developing/modules. To modify the look of Drupal, create a
subtheme as described at http://drupal.org/node/225125, or a completely new
theme as described at http://drupal.org/documentation/theme
MULTISITE CONFIGURATION
-----------------------
A single Drupal installation can host several Drupal-powered sites, each with
its own individual configuration.
Additional site configurations are created in subdirectories within the 'sites'
directory. Each subdirectory must have a 'settings.php' file, which specifies
the configuration settings. The easiest way to create additional sites is to
copy the 'default' directory and modify the 'settings.php' file as appropriate.
The new directory name is constructed from the site's URL. The configuration for
www.example.com could be in 'sites/example.com/settings.php' (note that 'www.'
should be omitted if users can access your site at http://example.com/).
Sites do not have to have a different domain. You can also use subdomains and
subdirectories for Drupal sites. For example, example.com, sub.example.com, and
sub.example.com/site3 can all be defined as independent Drupal sites. The setup
for a configuration such as this would look like the following:
sites/default/settings.php
sites/example.com/settings.php
sites/sub.example.com/settings.php
sites/sub.example.com.site3/settings.php
When searching for a site configuration (for example www.sub.example.com/site3),
Drupal will search for configuration files in the following order, using the
first configuration it finds:
sites/www.sub.example.com.site3/settings.php
sites/sub.example.com.site3/settings.php
sites/example.com.site3/settings.php
sites/www.sub.example.com/settings.php
sites/sub.example.com/settings.php
sites/example.com/settings.php
sites/default/settings.php
If you are installing on a non-standard port, the port number is treated as the
deepest subdomain. For example: http://www.example.com:8080/ could be loaded
from sites/8080.www.example.com/. The port number will be removed according to
the pattern above if no port-specific configuration is found, just like a real
subdomain.
Each site configuration can have its own site-specific modules and themes in
addition to those installed in the standard 'modules' and 'themes' directories.
To use site-specific modules or themes, simply create a 'modules' or 'themes'
directory within the site configuration directory. For example, if
sub.example.com has a custom theme and a custom module that should not be
accessible to other sites, the setup would look like this:
sites/sub.example.com/
settings.php
themes/custom_theme
modules/custom_module
NOTE: for more information about multiple virtual hosts or the configuration
settings, consult http://drupal.org/getting-started/6/install/multi-site
For more information on configuring Drupal's file system path in a multisite
configuration, see step 6 above.
MORE INFORMATION
----------------
- See the Drupal.org online documentation:
http://drupal.org/documentation
- For a list of security announcements, see the "Security advisories" page at
http://drupal.org/security (available as an RSS feed). This page also
describes how to subscribe to these announcements via e-mail.
- For information about the Drupal security process, or to find out how to
report a potential security issue to the Drupal security team, see the
"Security team" page at http://drupal.org/security-team
- For information about the wide range of available support options, visit
http://drupal.org and click on Community and Support in the top or bottom
navigation.
+293 -228
View File
@@ -1,274 +1,339 @@
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
verbatim copies of this license document, but changing it is not allowed.
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
The licenses for most software are designed to take away your freedom to
share and change it. By contrast, the GNU General Public License is
intended to guarantee your freedom to share and change free software--to
make sure the software is free for all its users. This General Public License
applies to most of the Free Software Foundation's software and to any other
program whose authors commit to using it. (Some other Free Software
Foundation software is covered by the GNU Library General Public License
instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the
freedom to distribute copies of free software (and charge for this service if
you wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of the
software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
For example, if you distribute copies of such a program, whether gratis or for
a fee, you must give the recipients all the rights that you have. You must make
sure that they, too, receive or can get the source code. And you must show
them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If the
software is modified by someone else and passed on, we want its recipients
to know that what they have is not the original, so that any problems
introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will individually
obtain patent licenses, in effect making the program proprietary. To prevent
this, we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
The precise terms and conditions for copying, distribution and modification
follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms
of this General Public License. The "Program", below, refers to any such
program or work, and a "work based on the Program" means either the
Program or any derivative work under copyright law: that is to say, a work
containing the Program or a portion of it, either verbatim or with
modifications and/or translated into another language. (Hereinafter, translation
is included without limitation in the term "modification".) Each licensee is
addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running the Program is
not restricted, and the output from the Program is covered only if its contents
constitute a work based on the Program (independent of having been made
by running the Program). Whether that is true depends on what the Program
does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this License
and to the absence of any warranty; and give any other recipients of the
Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
2. You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute such
modifications or work under the terms of Section 1 above, provided that you
also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
a) You must cause the modified files to carry prominent notices stating that
you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
b) You must cause any work that you distribute or publish, that in whole or in
part contains or is derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties under the terms of this
License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
c) If the modified program normally reads commands interactively when run,
you must cause it, when started running for such interactive use in the most
ordinary way, to print or display an announcement including an appropriate
copyright notice and a notice that there is no warranty (or else, saying that
you provide a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this License.
(Exception: if the Program itself is interactive but does not normally print such
an announcement, your work based on the Program is not required to print
an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be
reasonably considered independent and separate works in themselves, then
this License, and its terms, do not apply to those sections when you distribute
them as separate works. But when you distribute the same sections as part
of a whole which is a work based on the Program, the distribution of the
whole must be on the terms of this License, whose permissions for other
licensees extend to the entire whole, and thus to each and every part
regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to
work written entirely by you; rather, the intent is to exercise the right to
control the distribution of derivative or collective works based on the
Program.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of a
storage or distribution medium does not bring the other work under the scope
of this License.
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under
Section 2) in object code or executable form under the terms of Sections 1
and 2 above provided that you also do one of the following:
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source
code, which must be distributed under the terms of Sections 1 and 2 above
on a medium customarily used for software interchange; or,
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give
any third party, for a charge no more than your cost of physically performing
source distribution, a complete machine-readable copy of the corresponding
source code, to be distributed under the terms of Sections 1 and 2 above on
a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute
corresponding source code. (This alternative is allowed only for
noncommercial distribution and only if you received the program in object
code or executable form with such an offer, in accord with Subsection b
above.)
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source code
means all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation and
installation of the executable. However, as a special exception, the source
code distributed need not include anything that is normally distributed (in
either source or binary form) with the major components (compiler, kernel,
and so on) of the operating system on which the executable runs, unless that
component itself accompanies the executable.
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering access to
copy from a designated place, then offering equivalent access to copy the
source code from the same place counts as distribution of the source code,
even though third parties are not compelled to copy the source along with the
object code.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as
expressly provided under this License. Any attempt otherwise to copy,
modify, sublicense or distribute the Program is void, and will automatically
terminate your rights under this License. However, parties who have received
copies, or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it.
However, nothing else grants you permission to modify or distribute the
Program or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the
Program (or any work based on the Program), you indicate your acceptance
of this License to do so, and all its terms and conditions for copying,
distributing or modifying the Program or works based on it.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these terms and
conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), conditions
are imposed on you (whether by court order, agreement or otherwise) that
contradict the conditions of this License, they do not excuse you from the
conditions of this License. If you cannot distribute so as to satisfy
simultaneously your obligations under this License and any other pertinent
obligations, then as a consequence you may not distribute the Program at all.
For example, if a patent license would not permit royalty-free redistribution
of the Program by all those who receive copies directly or indirectly through
you, then the only way you could satisfy both it and this License would be to
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and
the section as a whole is intended to apply in other circumstances.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any patents or
other property right claims or to contest validity of any such claims; this
section has the sole purpose of protecting the integrity of the free software
distribution system, which is implemented by public license practices. Many
people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Program under this License may add an explicit
geographical distribution limitation excluding those countries, so that
distribution is permitted only in or among countries not thus excluded. In such
case, this License incorporates the limitation as if written in the body of this
License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will be
similar in spirit to the present version, but may differ in detail to address new
problems or concerns.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that
version or of any later version published by the Free Software Foundation. If
the Program does not specify a version number of this License, you may
choose any version ever published by the Free Software Foundation.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make
exceptions for this. Our decision will be guided by the two goals of
preserving the free status of all derivatives of our free software and of
promoting the sharing and reuse of software generally.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR OR CORRECTION.
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OR INABILITY TO USE THE
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES
SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
THE POSSIBILITY OF SUCH DAMAGES.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
+304
View File
@@ -0,0 +1,304 @@
Drupal core is built and maintained by the Drupal project community. Everyone is
encouraged to submit issues and changes (patches) to improve Drupal, and to
contribute in other ways -- see https://www.drupal.org/contribute to find out
how.
Branch maintainers
------------------
The Drupal Core branch maintainers oversee the development of Drupal as a whole.
The branch maintainers for Drupal 7 are:
- Dries Buytaert 'dries' https://www.drupal.org/u/dries
- Fabian Franz 'Fabianx' https://www.drupal.org/u/fabianx
- (provisional) Drew Webber 'mcdruid' https://www.drupal.org/u/mcdruid
Component maintainers
---------------------
The Drupal Core component maintainers oversee the development of Drupal
subsystems. See https://www.drupal.org/contribute/core-maintainers for more
information on their responsibilities, and to find out how to become a component
maintainer. Current component maintainers for Drupal 7:
Ajax system
- Alex Bronstein 'effulgentsia' https://www.drupal.org/u/effulgentsia
- Earl Miles 'merlinofchaos' https://www.drupal.org/u/merlinofchaos
Base system
- Damien Tournoud 'DamZ' https://www.drupal.org/u/damien-tournoud
- Moshe Weitzman 'moshe weitzman' https://www.drupal.org/u/moshe-weitzman
Batch system
- Yves Chedemois 'yched' https://www.drupal.org/u/yched
Cache system
- Damien Tournoud 'DamZ' https://www.drupal.org/u/damien-tournoud
- Nathaniel Catchpole 'catch' https://www.drupal.org/u/catch
Cron system
- Derek Wright 'dww' https://www.drupal.org/u/dww
Database system
- ?
- MySQL driver
- David Strauss 'David Strauss' https://www.drupal.org/u/david-strauss
- PostgreSQL driver
- Damien Tournoud 'DamZ' https://www.drupal.org/u/damien-tournoud
- Josh Waihi 'fiasco' https://www.drupal.org/u/josh-waihi
- Sqlite driver
- Damien Tournoud 'DamZ' https://www.drupal.org/u/damien-tournoud
Database update system
- Ashok Modi 'BTMash' https://www.drupal.org/u/btmash
Entity system
- Wolfgang Ziegler 'fago' https://www.drupal.org/u/fago
- Nathaniel Catchpole 'catch' https://www.drupal.org/u/catch
- Franz Heinzmann 'Frando' https://www.drupal.org/u/frando
File system
- Andrew Morton 'drewish' https://www.drupal.org/u/drewish
- Aaron Winborn 'aaron' https://www.drupal.org/u/aaron
Form system
- Alex Bronstein 'effulgentsia' https://www.drupal.org/u/effulgentsia
- Wolfgang Ziegler 'fago' https://www.drupal.org/u/fago
- Daniel F. Kudwien 'sun' https://www.drupal.org/u/sun
- Franz Heinzmann 'Frando' https://www.drupal.org/u/frando
Image system
- Andrew Morton 'drewish' https://www.drupal.org/u/drewish
- Nathan Haug 'quicksketch' https://www.drupal.org/u/quicksketch
Install system
- David Rothstein 'David_Rothstein' https://www.drupal.org/u/david_rothstein
JavaScript
- Théodore Biadala 'nod_' https://www.drupal.org/u/nod_
- Steve De Jonghe 'seutje' https://www.drupal.org/u/seutje
Language system
- Francesco Placella 'plach' https://www.drupal.org/u/plach
- Daniel F. Kudwien 'sun' https://www.drupal.org/u/sun
Lock system
- Damien Tournoud 'DamZ' https://www.drupal.org/u/damien-tournoud
Mail system
- ?
Markup
- Jacine Luisi 'Jacine' https://www.drupal.org/u/jacine
- Daniel F. Kudwien 'sun' https://www.drupal.org/u/sun
Menu system
- Peter Wolanin 'pwolanin' https://www.drupal.org/u/pwolanin
Path system
- Dave Reid 'davereid' https://www.drupal.org/u/dave-reid
- Nathaniel Catchpole 'catch' https://www.drupal.org/u/catch
Render system
- Moshe Weitzman 'moshe weitzman' https://www.drupal.org/u/moshe-weitzman
- Alex Bronstein 'effulgentsia' https://www.drupal.org/u/effulgentsia
- Franz Heinzmann 'Frando' https://www.drupal.org/u/frando
Theme system
- Earl Miles 'merlinofchaos' https://www.drupal.org/u/merlinofchaos
- Alex Bronstein 'effulgentsia' https://www.drupal.org/u/effulgentsia
- Joon Park 'dvessel' https://www.drupal.org/u/dvessel
- John Albin Wilkins 'JohnAlbin' https://www.drupal.org/u/johnalbin
Token system
- Dave Reid 'davereid' https://www.drupal.org/u/dave-reid
XML-RPC system
- Frederic G. Marand 'fgm' https://www.drupal.org/u/fgm
Topic coordinators
------------------
Accessibility
- Everett Zufelt 'Everett Zufelt' https://www.drupal.org/u/everett-zufelt
- Brandon Bowersox-Johnson 'bowersox' https://www.drupal.org/u/bowersox
Documentation
- Jennifer Hodgdon 'jhodgdon' https://www.drupal.org/u/jhodgdon
Translations
- Gerhard Killesreiter 'killes' https://www.drupal.org/u/gerhard-killesreiter
User experience and usability
- Roy Scholten 'yoroy' https://www.drupal.org/u/yoroy
- Bojhan Somers 'Bojhan' https://www.drupal.org/u/bojhan
Node Access
- Moshe Weitzman 'moshe weitzman' https://www.drupal.org/u/moshe-weitzman
- Ken Rickard 'agentrickard' https://www.drupal.org/u/agentrickard
Security team
-----------------
To report a security issue, see: https://www.drupal.org/security-team/report-issue
The Drupal security team provides Security Advisories for vulnerabilities,
assists developers in resolving security issues, and provides security
documentation. See https://www.drupal.org/security-team for more information.
The security team lead is:
- Michael Hess 'mlhess' https://www.drupal.org/u/mlhess
Module maintainers
------------------
Aggregator module
- ?
Block module
- John Albin Wilkins 'JohnAlbin' https://www.drupal.org/u/johnalbin
Blog module
- ?
Book module
- Peter Wolanin 'pwolanin' https://www.drupal.org/u/pwolanin
Color module
- ?
Comment module
- Nathaniel Catchpole 'catch' https://www.drupal.org/u/catch
Contact module
- Dave Reid 'davereid' https://www.drupal.org/u/dave-reid
Contextual module
- Daniel F. Kudwien 'sun' https://www.drupal.org/u/sun
Dashboard module
- ?
Database logging module
- Khalid Baheyeldin 'kbahey' https://www.drupal.org/u/kbahey
Field module
- Yves Chedemois 'yched' https://www.drupal.org/u/yched
- Barry Jaspan 'bjaspan' https://www.drupal.org/u/bjaspan
Field UI module
- Yves Chedemois 'yched' https://www.drupal.org/u/yched
File module
- Aaron Winborn 'aaron' https://www.drupal.org/u/aaron
Filter module
- Daniel F. Kudwien 'sun' https://www.drupal.org/u/sun
Forum module
- Lee Rowlands 'larowlan' https://www.drupal.org/u/larowlan
Help module
- ?
Image module
- Nathan Haug 'quicksketch' https://www.drupal.org/u/quicksketch
Locale module
- Gábor Hojtsy 'Gábor Hojtsy' https://www.drupal.org/u/gábor-hojtsy
Menu module
- ?
Node module
- Moshe Weitzman 'moshe weitzman' https://www.drupal.org/u/moshe-weitzman
- David Strauss 'David Strauss' https://www.drupal.org/u/david-strauss
OpenID module
- Vojtech Kusy 'wojtha' https://www.drupal.org/u/wojtha
- Christian Schmidt 'c960657' https://www.drupal.org/u/c960657
- Damien Tournoud 'DamZ' https://www.drupal.org/u/damien-tournoud
Overlay module
- Katherine Senzee 'ksenzee' https://www.drupal.org/u/ksenzee
Path module
- Dave Reid 'davereid' https://www.drupal.org/u/dave-reid
PHP module
- ?
Poll module
- Andrei Mateescu 'amateescu' https://www.drupal.org/u/amateescu
Profile module
- ?
RDF module
- Stéphane Corlosquet 'scor' https://www.drupal.org/u/scor
Search module
- Doug Green 'douggreen' https://www.drupal.org/u/douggreen
Shortcut module
- David Rothstein 'David_Rothstein' https://www.drupal.org/u/david_rothstein
Simpletest module
- Jimmy Berry 'boombatower' https://www.drupal.org/u/boombatower
Statistics module
- Tim Millwood 'timmillwood' https://www.drupal.org/u/timmillwood
Syslog module
- Khalid Baheyeldin 'kbahey' https://www.drupal.org/u/kbahey
System module
- ?
Taxonomy module
- Nathaniel Catchpole 'catch' https://www.drupal.org/u/catch
- Benjamin Doherty 'bangpound' https://www.drupal.org/u/bangpound
Toolbar module
- ?
Tracker module
- David Strauss 'David Strauss' https://www.drupal.org/u/david-strauss
Translation module
- Francesco Placella 'plach' https://www.drupal.org/u/plach
Trigger module
- ?
Update module
- Derek Wright 'dww' https://www.drupal.org/u/dww
User module
- Moshe Weitzman 'moshe weitzman' https://www.drupal.org/u/moshe-weitzman
- David Strauss 'David Strauss' https://www.drupal.org/u/david-strauss
Theme maintainers
-----------------
Bartik theme
- Jen Simmons 'jensimmons' https://www.drupal.org/u/jensimmons
- Jeff Burns 'Jeff Burnz' https://www.drupal.org/u/jeff-burnz
Garland theme
- John Albin Wilkins 'JohnAlbin' https://www.drupal.org/u/johnalbin
Seven theme
- Jeff Burns 'Jeff Burnz' https://www.drupal.org/u/jeff-burnz
Stark theme
- John Albin Wilkins 'JohnAlbin' https://www.drupal.org/u/johnalbin
+31
View File
@@ -0,0 +1,31 @@
# Core Patches :
- Implement language aware tokens for one time login link and cancel link
https://www.drupal.org/node/1754162
//- est-ce que je dois faire ce patch ???
//includes/entity.inc
//see https://www.drupal.org/node/1003788
# Modules :
Redis
- https://www.drupal.org/project/redis/issues/3074189
cer
contentadminrelink
entityreference
feedback
filter_path_alias
flag_lists
- https://www.drupal.org/project/flag_lists/issues/2114731
login_tobogan (pd with field permission et donc field collection)
- https://www.drupal.org/node/1365764#comment-10286257
- logintoboggan-exempting_lt_preauth_role_from_user_permissions_js-1365764-52.patch
- interdiff-1365764-23-52-do-not-test.diff
node_export :
- https://www.drupal.org/node/1869918
- https://www.drupal.org/node/1911638
termreferencetree
?? views
views_rss_media
- https://www.drupal.org/node/2472409
- https://www.drupal.org/project/views_rss_media/issues/2149287
wysiwyg
+123 -1
View File
@@ -1 +1,123 @@
!!! this module is not ready tu use !!!
CONTENTS OF THIS FILE
---------------------
* About Drupal
* Configuration and features
* Installation profiles
* Appearance
* Developing for Drupal
ABOUT DRUPAL
------------
Drupal is an open source content management platform supporting a variety of
websites ranging from personal weblogs to large community-driven websites. For
more information, see the Drupal website at http://drupal.org/, and join the
Drupal community at http://drupal.org/community.
Legal information about Drupal:
* Know your rights when using Drupal:
See LICENSE.txt in the same directory as this document.
* Learn about the Drupal trademark and logo policy:
http://drupal.com/trademark
CONFIGURATION AND FEATURES
--------------------------
Drupal core (what you get when you download and extract a drupal-x.y.tar.gz or
drupal-x.y.zip file from http://drupal.org/project/drupal) has what you need to
get started with your website. It includes several modules (extensions that add
functionality) for common website features, such as managing content, user
accounts, image uploading, and search. Core comes with many options that allow
site-specific configuration. In addition to the core modules, there are
thousands of contributed modules (for functionality not included with Drupal
core) available for download.
More about configuration:
* Install, upgrade, and maintain Drupal:
See INSTALL.txt and UPGRADE.txt in the same directory as this document.
* Learn about how to use Drupal to create your site:
http://drupal.org/documentation
* Download contributed modules to sites/all/modules to extend Drupal's
functionality:
http://drupal.org/project/modules
* See also: "Developing for Drupal" for writing your own modules, below.
INSTALLATION PROFILES
---------------------
Installation profiles define additional steps (such as enabling modules,
defining content types, etc.) that run after the base installation provided
by core when Drupal is first installed. There are two basic installation
profiles provided with Drupal core.
Installation profiles from the Drupal community modify the installation process
to provide a website for a specific use case, such as a CMS for media
publishers, a web-based project tracking tool, or a full-fledged CRM for
non-profit organizations raising money and accepting donations. They can be
distributed as bare installation profiles or as "distributions". Distributions
include Drupal core, the installation profile, and all other required
extensions, such as contributed and custom modules, themes, and third-party
libraries. Bare installation profiles require you to download Drupal Core and
the required extensions separately; place the downloaded profile in the
/profiles directory before you start the installation process. Note that the
contents of this directory may be overwritten during updates of Drupal core;
it is advised to keep code backups or use a version control system.
Additionally, modules and themes may be placed inside subdirectories in a
specific installation profile such as profiles/your_site_profile/modules and
profiles/your_site_profile/themes respectively to restrict their usage to only
sites that were installed with that specific profile.
More about installation profiles and distributions:
* Read about the difference between installation profiles and distributions:
http://drupal.org/node/1089736
* Download contributed installation profiles and distributions:
http://drupal.org/project/distributions
* Develop your own installation profile or distribution:
http://drupal.org/developing/distributions
APPEARANCE
----------
In Drupal, the appearance of your site is set by the theme (themes are
extensions that set fonts, colors, and layout). Drupal core comes with several
themes. More themes are available for download, and you can also create your own
custom theme.
More about themes:
* Download contributed themes to sites/all/themes to modify Drupal's
appearance:
http://drupal.org/project/themes
* Develop your own theme:
http://drupal.org/documentation/theme
DEVELOPING FOR DRUPAL
---------------------
Drupal contains an extensive API that allows you to add to and modify the
functionality of your site. The API consists of "hooks", which allow modules to
react to system events and customize Drupal's behavior, and functions that
standardize common operations such as database queries and form generation. The
flexible hook architecture means that you should never need to directly modify
the files that come with Drupal core to achieve the functionality you want;
instead, functionality modifications take the form of modules.
When you need new functionality for your Drupal site, search for existing
contributed modules. If you find a module that matches except for a bug or an
additional needed feature, change the module and contribute your improvements
back to the project in the form of a "patch". Create new custom modules only
when nothing existing comes close to what you need.
More about developing:
* Search for existing contributed modules:
http://drupal.org/project/modules
* Contribute a patch:
http://drupal.org/patch/submit
* Develop your own module:
http://drupal.org/developing/modules
* Follow best practices:
http://drupal.org/best-practices
* Refer to the API documentation:
http://api.drupal.org/api/drupal/7
+246
View File
@@ -0,0 +1,246 @@
INTRODUCTION
------------
This document describes how to:
* Update your Drupal site from one minor 7.x version to another minor 7.x
version; for example, from 7.8 to 7.9, or from 7.6 to 7.10.
* Upgrade your Drupal site's major version from 6.x to 7.x.
First steps and definitions:
* If you are upgrading to Drupal version x.y, then x is known as the major
version number, and y is known as the minor version number. The download
file will be named drupal-x.y.tar.gz (or drupal-x.y.zip).
* All directories mentioned in this document are relative to the directory of
your Drupal installation.
* Make a full backup of all files, directories, and your database(s) before
starting, and save it outside your Drupal installation directory.
Instructions may be found at http://drupal.org/upgrade/backing-up-the-db
* It is wise to try an update or upgrade on a test copy of your site before
applying it to your live site. Even minor updates can cause your site's
behavior to change.
* Each new release of Drupal has release notes, which explain the changes made
since the previous version and any special instructions needed to update or
upgrade to the new version. You can find a link to the release notes for the
version you are upgrading or updating to on the Drupal project page
(http://drupal.org/project/drupal).
UPGRADE PROBLEMS
----------------
If you encounter errors during this process,
* Note any error messages you see.
* Restore your site to its previous state, using the file and database backups
you created before you started the upgrade process. Do not attempt to do
further upgrades on a site that had update problems.
* Consult one of the support options listed on http://drupal.org/support
More in-depth information on upgrading can be found at http://drupal.org/upgrade
MINOR VERSION UPDATES
---------------------
To update from one minor 7.x version of Drupal to any later 7.x version, after
following the instructions in the INTRODUCTION section at the top of this file:
1. Log in as a user with the permission "Administer software updates".
2. Go to Administration > Configuration > Development > Maintenance mode.
Enable the "Put site into maintenance mode" checkbox and save the
configuration.
3. Remove all old core files and directories, except for the 'sites' directory
and any custom files you added elsewhere.
If you made modifications to files like .htaccess or robots.txt, you will
need to re-apply them from your backup, after the new files are in place.
Sometimes an update includes changes to default.settings.php (this will be
noted in the release notes). If that's the case, follow these steps:
- Locate your settings.php file in the /sites/* directory. (Typically
sites/default.)
- Make a backup copy of your settings.php file, with a different file name.
- Make a copy of the new default.settings.php file, and name the copy
settings.php (overwriting your previous settings.php file).
- Copy the custom and site-specific entries from the backup you made into the
new settings.php file. You will definitely need the lines giving the
database information, and you will also want to copy in any other
customizations you have added.
You can find the release notes for your version at
https://www.drupal.org/project/drupal. At bottom of the project page under
"Downloads" use the link for your version of Drupal to view the release
notes. If your version is not listed, use the 'View all releases' link. From
this page you can scroll down or use the filter to find your version and its
release notes.
4. Download the latest Drupal 7.x release from http://drupal.org to a
directory outside of your web root. Extract the archive and copy the files
into your Drupal directory.
On a typical Unix/Linux command line, use the following commands to download
and extract:
wget http://drupal.org/files/projects/drupal-x.y.tar.gz
tar -zxvf drupal-x.y.tar.gz
This creates a new directory drupal-x.y/ containing all Drupal files and
directories. Copy the files into your Drupal installation directory:
cp -R drupal-x.y/* drupal-x.y/.htaccess /path/to/your/installation
If you do not have command line access to your server, download the archive
from http://drupal.org using your web browser, extract it, and then use an
FTP client to upload the files to your web root.
5. Re-apply any modifications to files such as .htaccess or robots.txt.
6. Run update.php by visiting http://www.example.com/update.php (replace
www.example.com with your domain name). This will update the core database
tables.
If you are unable to access update.php do the following:
- Open settings.php with a text editor.
- Find the line that says:
$update_free_access = FALSE;
- Change it into:
$update_free_access = TRUE;
- Once the upgrade is done, $update_free_access must be reverted to FALSE.
7. Go to Administration > Reports > Status report. Verify that everything is
working as expected.
8. Ensure that $update_free_access is FALSE in settings.php.
9. Go to Administration > Configuration > Development > Maintenance mode.
Disable the "Put site into maintenance mode" checkbox and save the
configuration.
MAJOR VERSION UPGRADE
---------------------
To upgrade from a previous major version of Drupal to Drupal 7.x, after
following the instructions in the INTRODUCTION section at the top of this file:
1. Check on the Drupal 7 status of your contributed and custom modules and
themes. See http://drupal.org/node/948216 for information on upgrading
contributed modules and themes. See http://drupal.org/node/895314 for a list
of modules that have been moved into core for Drupal 7, and instructions on
how to update them. See http://drupal.org/update/modules for information on
how to update your custom modules, and http://drupal.org/update/theme for
custom themes.
You may decide at this point that you cannot upgrade your site, because
needed modules or themes are not ready for Drupal 7.
2. Update to the latest available version of Drupal 6.x (if your current version
is Drupal 5.x, you have to upgrade to 6.x first). If you need to update,
download Drupal 6.x and follow the instructions in its UPGRADE.txt. This
document only applies for upgrades from 6.x to 7.x.
3. In addition to updating to the latest available version of Drupal 6.x core,
you must also upgrade all of your contributed modules for Drupal to their
latest Drupal 6.x versions.
4. Log in as user ID 1 (the site maintenance user).
5. Go to Administer > Site configuration > Site maintenance. Select
"Off-line" and save the configuration.
6. Go to Administer > Site building > Themes. Enable "Garland" and select it as
the default theme.
7. Go to Administer > Site building > Modules. Disable all modules that are not
listed under "Core - required" or "Core - optional". It is possible that some
modules cannot be disabled, because others depend on them. Repeat this step
until all non-core modules are disabled.
If you know that you will not re-enable some modules for Drupal 7.x and you
no longer need their data, then you can uninstall them under the Uninstall
tab after disabling them.
8. On the command line or in your FTP client, remove the file
sites/default/default.settings.php
9. Remove all old core files and directories, except for the 'sites' directory
and any custom files you added elsewhere.
If you made modifications to files like .htaccess or robots.txt, you will
need to re-apply them from your backup, after the new files are in place.
10. If you uninstalled any modules, remove them from the sites/all/modules and
other sites/*/modules directories. Leave other modules in place, even though
they are incompatible with Drupal 7.x.
11. Download the latest Drupal 7.x release from http://drupal.org to a
directory outside of your web root. Extract the archive and copy the files
into your Drupal directory.
On a typical Unix/Linux command line, use the following commands to download
and extract:
wget http://drupal.org/files/projects/drupal-x.y.tar.gz
tar -zxvf drupal-x.y.tar.gz
This creates a new directory drupal-x.y/ containing all Drupal files and
directories. Copy the files into your Drupal installation directory:
cp -R drupal-x.y/* drupal-x.y/.htaccess /path/to/your/installation
If you do not have command line access to your server, download the archive
from http://drupal.org using your web browser, extract it, and then use an
FTP client to upload the files to your web root.
12. Re-apply any modifications to files such as .htaccess or robots.txt.
13. Make your settings.php file writeable, so that the update process can
convert it to the format of Drupal 7.x. settings.php is usually located in
sites/default/settings.php
14. Run update.php by visiting http://www.example.com/update.php (replace
www.example.com with your domain name). This will update the core database
tables.
If you are unable to access update.php do the following:
- Open settings.php with a text editor.
- Find the line that says:
$update_free_access = FALSE;
- Change it into:
$update_free_access = TRUE;
- Once the upgrade is done, $update_free_access must be reverted to FALSE.
15. Backup your database after the core upgrade has run.
16. Replace and update your non-core modules and themes, following the
procedures at http://drupal.org/node/948216
17. Go to Administration > Reports > Status report. Verify that everything is
working as expected.
18. Ensure that $update_free_access is FALSE in settings.php.
19. Go to Administration > Configuration > Development > Maintenance mode.
Disable the "Put site into maintenance mode" checkbox and save the
configuration.
To get started with Drupal 7 administration, visit
http://drupal.org/getting-started/7/admin
+174
View File
@@ -0,0 +1,174 @@
<?php
/**
* @file
* Administrative script for running authorized file operations.
*
* Using this script, the site owner (the user actually owning the files on the
* webserver) can authorize certain file-related operations to proceed with
* elevated privileges, for example to deploy and upgrade modules or themes.
* Users should not visit this page directly, but instead use an administrative
* user interface which knows how to redirect the user to this script as part of
* a multistep process. This script actually performs the selected operations
* without loading all of Drupal, to be able to more gracefully recover from
* errors. Access to the script is controlled by a global killswitch in
* settings.php ('allow_authorize_operations') and via the 'administer software
* updates' permission.
*
* There are helper functions for setting up an operation to run via this
* system in modules/system/system.module. For more information, see:
* @link authorize Authorized operation helper functions @endlink
*/
/**
* Defines the root directory of the Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
/**
* Global flag to identify update.php and authorize.php runs.
*
* Identifies update.php and authorize.php runs, avoiding unwanted operations
* such as hook_init() and hook_exit() invokes, css/js preprocessing and
* translation, and solves some theming issues. The flag is checked in other
* places in Drupal code (not just authorize.php).
*/
define('MAINTENANCE_MODE', 'update');
/**
* Renders a 403 access denied page for authorize.php.
*/
function authorize_access_denied_page() {
drupal_add_http_header('Status', '403 Forbidden');
watchdog('access denied', 'authorize.php', NULL, WATCHDOG_WARNING);
drupal_set_title('Access denied');
return t('You are not allowed to access this page.');
}
/**
* Determines if the current user is allowed to run authorize.php.
*
* The killswitch in settings.php overrides all else, otherwise, the user must
* have access to the 'administer software updates' permission.
*
* @return
* TRUE if the current user can run authorize.php, and FALSE if not.
*/
function authorize_access_allowed() {
return variable_get('allow_authorize_operations', TRUE) && user_access('administer software updates');
}
// *** Real work of the script begins here. ***
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
require_once DRUPAL_ROOT . '/includes/common.inc';
require_once DRUPAL_ROOT . '/includes/file.inc';
require_once DRUPAL_ROOT . '/includes/module.inc';
require_once DRUPAL_ROOT . '/includes/ajax.inc';
// We prepare only a minimal bootstrap. This includes the database and
// variables, however, so we have access to the class autoloader registry.
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
// This must go after drupal_bootstrap(), which unsets globals!
global $conf;
// We have to enable the user and system modules, even to check access and
// display errors via the maintenance theme.
$module_list['system']['filename'] = 'modules/system/system.module';
$module_list['user']['filename'] = 'modules/user/user.module';
module_list(TRUE, FALSE, FALSE, $module_list);
drupal_load('module', 'system');
drupal_load('module', 'user');
// We also want to have the language system available, but we do *NOT* want to
// actually call drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE), since that would
// also force us through the DRUPAL_BOOTSTRAP_PAGE_HEADER phase, which loads
// all the modules, and that's exactly what we're trying to avoid.
drupal_language_initialize();
// Initialize the maintenance theme for this administrative script.
drupal_maintenance_theme();
$output = '';
$show_messages = TRUE;
if (authorize_access_allowed()) {
// Load both the Form API and Batch API.
require_once DRUPAL_ROOT . '/includes/form.inc';
require_once DRUPAL_ROOT . '/includes/batch.inc';
// Load the code that drives the authorize process.
require_once DRUPAL_ROOT . '/includes/authorize.inc';
// For the sake of Batch API and a few other low-level functions, we need to
// initialize the URL path into $_GET['q']. However, we do not want to raise
// our bootstrap level, nor do we want to call drupal_initialize_path(),
// since that is assuming that modules are loaded and invoking hooks.
// However, all we really care is if we're in the middle of a batch, in which
// case $_GET['q'] will already be set, we just initialize it to an empty
// string if it's not already defined.
if (!isset($_GET['q'])) {
$_GET['q'] = '';
}
if (isset($_SESSION['authorize_operation']['page_title'])) {
drupal_set_title($_SESSION['authorize_operation']['page_title']);
}
else {
drupal_set_title(t('Authorize file system changes'));
}
// See if we've run the operation and need to display a report.
if (isset($_SESSION['authorize_results']) && $results = $_SESSION['authorize_results']) {
// Clear the session out.
unset($_SESSION['authorize_results']);
unset($_SESSION['authorize_operation']);
unset($_SESSION['authorize_filetransfer_info']);
if (!empty($results['page_title'])) {
drupal_set_title($results['page_title']);
}
if (!empty($results['page_message'])) {
drupal_set_message($results['page_message']['message'], $results['page_message']['type']);
}
$output = theme('authorize_report', array('messages' => $results['messages']));
$links = array();
if (is_array($results['tasks'])) {
$links += $results['tasks'];
}
else {
$links = array_merge($links, array(
l(t('Administration pages'), 'admin'),
l(t('Front page'), '<front>'),
));
}
$output .= theme('item_list', array('items' => $links, 'title' => t('Next steps')));
}
// If a batch is running, let it run.
elseif (isset($_GET['batch'])) {
$output = _batch_page();
}
else {
if (empty($_SESSION['authorize_operation']) || empty($_SESSION['authorize_filetransfer_info'])) {
$output = t('It appears you have reached this page in error.');
}
elseif (!$batch = batch_get()) {
// We have a batch to process, show the filetransfer form.
$elements = drupal_get_form('authorize_filetransfer_form');
$output = drupal_render($elements);
}
}
// We defer the display of messages until all operations are done.
$show_messages = !(($batch = batch_get()) && isset($batch['running']));
}
else {
$output = authorize_access_denied_page();
}
if (!empty($output)) {
print theme('update_page', array('content' => $output, 'show_messages' => $show_messages));
}
+10
View File
@@ -0,0 +1,10 @@
{
"require": {
"drush/drush": "8.*"
},
"extra": {
"installer-paths": {
"core": ["type:drupal-core"]
}
}
}
Generated
+1354
View File
File diff suppressed because it is too large Load Diff
+26
View File
@@ -0,0 +1,26 @@
<?php
/**
* @file
* Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).
*/
/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
if (!isset($_GET['cron_key']) || variable_get('cron_key', 'drupal') != $_GET['cron_key']) {
watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
drupal_access_denied();
}
elseif (variable_get('maintenance_mode', 0)) {
watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE);
drupal_access_denied();
}
else {
drupal_cron_run();
}
+23
View File
@@ -0,0 +1,23 @@
diff --git a/includes/entity.inc b/includes/entity.inc
index 2fefd59..0b80d53 100644
--- a/includes/entity.inc
+++ b/includes/entity.inc
@@ -159,6 +159,18 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
*/
public function load($ids = array(), $conditions = array()) {
$entities = array();
+
+ # PATCH http://drupal.org/node/1003788#comment-5195682
+ // Clean the $ids array to remove non-integer values that can be passed
+ // in from various sources, including menu callbacks.
+ if (is_array($ids)) {
+ foreach ($ids as $key => $id) {
+ if (empty($id) || ((string) $id !== (string) (int) $id)) {
+ unset($ids[$key]);
+ }
+ }
+ }
+ # endpatch
// Revisions are not statically cached, and require a different query to
// other conditions, so separate the revision id into its own variable.
+4
View File
@@ -0,0 +1,4 @@
#! /bin/bash
sudo chown -R $USER:http sites/all/modules/features/
sudo chmod -R g+w sites/all/modules/features/
@@ -0,0 +1,55 @@
diff --git a/flag_lists.module b/flag_lists.module
index d829113..b3c04f0 100644
--- a/flag_lists.module
+++ b/flag_lists.module
@@ -1587,6 +1587,32 @@ function flag_lists_fix_link(&$link, $action) {
return $fcid;
}
+
+ /**
+ * Remove all entries of entity_id and type
+ *
+ * @param $entity_id
+ * Entity id which has been flagged.
+ * @param $type
+ * The entity type.
+ */
+ function _flag_lists_remove_entity($entity_id, $type) {
+ $query = db_select('flag_lists_content')
+ ->condition('entity_id', $entity_id)
+ ->condition('entity_type', $type);
+ $query->fields('flag_lists_content', array('fcid', 'fid', 'uid', 'sid'));
+ $items = $query->execute()->fetchAll();
+
+ if ($items) {
+ foreach ($items as $key => $value) {
+ db_delete('flag_lists_content')
+ ->condition('fcid', $value->fcid)
+ ->execute();
+ watchdog('flag_lists', t('Deleted entry @fcid from flat_lists_content', array('@fcid' => $value->fcid)));
+ }
+ }
+ }
+
/**
* Updates the flag count for this content
*/
@@ -1766,3 +1792,17 @@ function flag_lists_views_form_substitutions() {
$select_all_placeholder => drupal_render($select_all),
);
}
+
+
+/**
+ * Implements hook_entity_delete
+ */
+function flag_lists_entity_delete($entity, $type) {
+ foreach (flag_get_flags($type) as $flag) {
+ if (isset($entity->vid)) {
+ $items = _flag_lists_remove_entity($entity->vid, $type);
+ }
+ }
+}
+
+
Executable
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

+388
View File
@@ -0,0 +1,388 @@
<?php
/**
* @file
* This is the actions engine for executing stored actions.
*/
/**
* @defgroup actions Actions
* @{
* Functions that perform an action on a certain system object.
*
* Action functions are declared by modules by implementing hook_action_info().
* Modules can cause action functions to run by calling actions_do(), and
* trigger.module provides a user interface that lets administrators define
* events that cause action functions to run.
*
* Each action function takes two to four arguments:
* - $entity: The object that the action acts on, such as a node, comment, or
* user.
* - $context: Array of additional information about what triggered the action.
* - $a1, $a2: Optional additional information, which can be passed into
* actions_do() and will be passed along to the action function.
*
* @}
*/
/**
* Performs a given list of actions by executing their callback functions.
*
* Given the IDs of actions to perform, this function finds out what the
* callback functions for the actions are by querying the database. Then
* it calls each callback using the function call $function($object, $context,
* $a1, $a2), passing the input arguments of this function (see below) to the
* action function.
*
* @param $action_ids
* The IDs of the actions to perform. Can be a single action ID or an array
* of IDs. IDs of configurable actions must be given as numeric action IDs;
* IDs of non-configurable actions may be given as action function names.
* @param $object
* The object that the action will act on: a node, user, or comment object.
* @param $context
* Associative array containing extra information about what triggered
* the action call, with $context['hook'] giving the name of the hook
* that resulted in this call to actions_do().
* @param $a1
* Passed along to the callback.
* @param $a2
* Passed along to the callback.
*
* @return
* An associative array containing the results of the functions that
* perform the actions, keyed on action ID.
*
* @ingroup actions
*/
function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a2 = NULL) {
// $stack tracks the number of recursive calls.
static $stack;
$stack++;
if ($stack > variable_get('actions_max_stack', 35)) {
watchdog('actions', 'Stack overflow: too many calls to actions_do(). Aborting to prevent infinite recursion.', array(), WATCHDOG_ERROR);
return;
}
$actions = array();
$available_actions = actions_list();
$actions_result = array();
if (is_array($action_ids)) {
$conditions = array();
foreach ($action_ids as $action_id) {
if (is_numeric($action_id)) {
$conditions[] = $action_id;
}
elseif (isset($available_actions[$action_id])) {
$actions[$action_id] = $available_actions[$action_id];
}
}
// When we have action instances we must go to the database to retrieve
// instance data.
if (!empty($conditions)) {
$query = db_select('actions');
$query->addField('actions', 'aid');
$query->addField('actions', 'type');
$query->addField('actions', 'callback');
$query->addField('actions', 'parameters');
$query->condition('aid', $conditions, 'IN');
$result = $query->execute();
foreach ($result as $action) {
$actions[$action->aid] = $action->parameters ? unserialize($action->parameters) : array();
$actions[$action->aid]['callback'] = $action->callback;
$actions[$action->aid]['type'] = $action->type;
}
}
// Fire actions, in no particular order.
foreach ($actions as $action_id => $params) {
// Configurable actions need parameters.
if (is_numeric($action_id)) {
$function = $params['callback'];
if (function_exists($function)) {
$context = array_merge($context, $params);
$actions_result[$action_id] = $function($object, $context, $a1, $a2);
}
else {
$actions_result[$action_id] = FALSE;
}
}
// Singleton action; $action_id is the function name.
else {
$actions_result[$action_id] = $action_id($object, $context, $a1, $a2);
}
}
}
// Optimized execution of a single action.
else {
// If it's a configurable action, retrieve stored parameters.
if (is_numeric($action_ids)) {
$action = db_query("SELECT callback, parameters FROM {actions} WHERE aid = :aid", array(':aid' => $action_ids))->fetchObject();
$function = $action->callback;
if (function_exists($function)) {
$context = array_merge($context, unserialize($action->parameters));
$actions_result[$action_ids] = $function($object, $context, $a1, $a2);
}
else {
$actions_result[$action_ids] = FALSE;
}
}
// Singleton action; $action_ids is the function name.
else {
if (function_exists($action_ids)) {
$actions_result[$action_ids] = $action_ids($object, $context, $a1, $a2);
}
else {
// Set to avoid undefined index error messages later.
$actions_result[$action_ids] = FALSE;
}
}
}
$stack--;
return $actions_result;
}
/**
* Discovers all available actions by invoking hook_action_info().
*
* This function contrasts with actions_get_all_actions(); see the
* documentation of actions_get_all_actions() for an explanation.
*
* @param $reset
* Reset the action info static cache.
*
* @return
* An associative array keyed on action function name, with the same format
* as the return value of hook_action_info(), containing all
* modules' hook_action_info() return values as modified by any
* hook_action_info_alter() implementations.
*
* @see hook_action_info()
*/
function actions_list($reset = FALSE) {
$actions = &drupal_static(__FUNCTION__);
if (!isset($actions) || $reset) {
$actions = module_invoke_all('action_info');
drupal_alter('action_info', $actions);
}
// See module_implements() for an explanation of this cast.
return (array) $actions;
}
/**
* Retrieves all action instances from the database.
*
* This function differs from the actions_list() function, which gathers
* actions by invoking hook_action_info(). The actions returned by this
* function and the actions returned by actions_list() are partially
* synchronized. Non-configurable actions from hook_action_info()
* implementations are put into the database when actions_synchronize() is
* called, which happens when admin/config/system/actions is visited.
* Configurable actions are not added to the database until they are configured
* in the user interface, in which case a database row is created for each
* configuration of each action.
*
* @return
* Associative array keyed by numeric action ID. Each value is an associative
* array with keys 'callback', 'label', 'type' and 'configurable'.
*/
function actions_get_all_actions() {
$actions = db_query("SELECT aid, type, callback, parameters, label FROM {actions}")->fetchAllAssoc('aid', PDO::FETCH_ASSOC);
foreach ($actions as &$action) {
$action['configurable'] = (bool) $action['parameters'];
unset($action['parameters']);
unset($action['aid']);
}
return $actions;
}
/**
* Creates an associative array keyed by hashes of function names or IDs.
*
* Hashes are used to prevent actual function names from going out into HTML
* forms and coming back.
*
* @param $actions
* An associative array with function names or action IDs as keys
* and associative arrays with keys 'label', 'type', etc. as values.
* This is usually the output of actions_list() or actions_get_all_actions().
*
* @return
* An associative array whose keys are hashes of the input array keys, and
* whose corresponding values are associative arrays with components
* 'callback', 'label', 'type', and 'configurable' from the input array.
*/
function actions_actions_map($actions) {
$actions_map = array();
foreach ($actions as $callback => $array) {
$key = drupal_hash_base64($callback);
$actions_map[$key]['callback'] = isset($array['callback']) ? $array['callback'] : $callback;
$actions_map[$key]['label'] = $array['label'];
$actions_map[$key]['type'] = $array['type'];
$actions_map[$key]['configurable'] = $array['configurable'];
}
return $actions_map;
}
/**
* Returns an action array key (function or ID), given its hash.
*
* Faster than actions_actions_map() when you only need the function name or ID.
*
* @param $hash
* Hash of a function name or action ID array key. The array key
* is a key into the return value of actions_list() (array key is the action
* function name) or actions_get_all_actions() (array key is the action ID).
*
* @return
* The corresponding array key, or FALSE if no match is found.
*/
function actions_function_lookup($hash) {
// Check for a function name match.
$actions_list = actions_list();
foreach ($actions_list as $function => $array) {
if (drupal_hash_base64($function) == $hash) {
return $function;
}
}
$aid = FALSE;
// Must be a configurable action; check database.
$result = db_query("SELECT aid FROM {actions} WHERE parameters <> ''")->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
if (drupal_hash_base64($row['aid']) == $hash) {
$aid = $row['aid'];
break;
}
}
return $aid;
}
/**
* Synchronizes actions that are provided by modules in hook_action_info().
*
* Actions provided by modules in hook_action_info() implementations are
* synchronized with actions that are stored in the actions database table.
* This is necessary so that actions that do not require configuration can
* receive action IDs.
*
* @param $delete_orphans
* If TRUE, any actions that exist in the database but are no longer
* found in the code (for example, because the module that provides them has
* been disabled) will be deleted.
*/
function actions_synchronize($delete_orphans = FALSE) {
$actions_in_code = actions_list(TRUE);
$actions_in_db = db_query("SELECT aid, callback, label FROM {actions} WHERE parameters = ''")->fetchAllAssoc('callback', PDO::FETCH_ASSOC);
// Go through all the actions provided by modules.
foreach ($actions_in_code as $callback => $array) {
// Ignore configurable actions since their instances get put in when the
// user adds the action.
if (!$array['configurable']) {
// If we already have an action ID for this action, no need to assign aid.
if (isset($actions_in_db[$callback])) {
unset($actions_in_db[$callback]);
}
else {
// This is a new singleton that we don't have an aid for; assign one.
db_insert('actions')
->fields(array(
'aid' => $callback,
'type' => $array['type'],
'callback' => $callback,
'parameters' => '',
'label' => $array['label'],
))
->execute();
watchdog('actions', "Action '%action' added.", array('%action' => $array['label']));
}
}
}
// Any actions that we have left in $actions_in_db are orphaned.
if ($actions_in_db) {
$orphaned = array_keys($actions_in_db);
if ($delete_orphans) {
$actions = db_query('SELECT aid, label FROM {actions} WHERE callback IN (:orphaned)', array(':orphaned' => $orphaned))->fetchAll();
foreach ($actions as $action) {
actions_delete($action->aid);
watchdog('actions', "Removed orphaned action '%action' from database.", array('%action' => $action->label));
}
}
else {
$link = l(t('Remove orphaned actions'), 'admin/config/system/actions/orphan');
$count = count($actions_in_db);
$orphans = implode(', ', $orphaned);
watchdog('actions', '@count orphaned actions (%orphans) exist in the actions table. !link', array('@count' => $count, '%orphans' => $orphans, '!link' => $link), WATCHDOG_INFO);
}
}
}
/**
* Saves an action and its user-supplied parameter values to the database.
*
* @param $function
* The name of the function to be called when this action is performed.
* @param $type
* The type of action, to describe grouping and/or context, e.g., 'node',
* 'user', 'comment', or 'system'.
* @param $params
* An associative array with parameter names as keys and parameter values as
* values.
* @param $label
* A user-supplied label of this particular action, e.g., 'Send e-mail
* to Jim'.
* @param $aid
* The ID of this action. If omitted, a new action is created.
*
* @return
* The ID of the action.
*/
function actions_save($function, $type, $params, $label, $aid = NULL) {
// aid is the callback for singleton actions so we need to keep a separate
// table for numeric aids.
if (!$aid) {
$aid = db_next_id();
}
db_merge('actions')
->key(array('aid' => $aid))
->fields(array(
'callback' => $function,
'type' => $type,
'parameters' => serialize($params),
'label' => $label,
))
->execute();
watchdog('actions', 'Action %action saved.', array('%action' => $label));
return $aid;
}
/**
* Retrieves a single action from the database.
*
* @param $aid
* The ID of the action to retrieve.
*
* @return
* The appropriate action row from the database as an object.
*/
function actions_load($aid) {
return db_query("SELECT aid, type, callback, parameters, label FROM {actions} WHERE aid = :aid", array(':aid' => $aid))->fetchObject();
}
/**
* Deletes a single action from the database.
*
* @param $aid
* The ID of the action to delete.
*/
function actions_delete($aid) {
db_delete('actions')
->condition('aid', $aid)
->execute();
module_invoke_all('actions_delete', $aid);
}
+1318
View File
File diff suppressed because it is too large Load Diff
+68
View File
@@ -0,0 +1,68 @@
<?php
/**
* @file
* Shared classes and interfaces for the archiver system.
*/
/**
* Defines the common interface for all Archiver classes.
*/
interface ArchiverInterface {
/**
* Constructs a new archiver instance.
*
* @param $file_path
* The full system path of the archive to manipulate. Only local files
* are supported. If the file does not yet exist, it will be created if
* appropriate.
*/
public function __construct($file_path);
/**
* Adds the specified file or directory to the archive.
*
* @param $file_path
* The full system path of the file or directory to add. Only local files
* and directories are supported.
*
* @return ArchiverInterface
* The called object.
*/
public function add($file_path);
/**
* Removes the specified file from the archive.
*
* @param $path
* The file name relative to the root of the archive to remove.
*
* @return ArchiverInterface
* The called object.
*/
public function remove($path);
/**
* Extracts multiple files in the archive to the specified path.
*
* @param $path
* A full system path of the directory to which to extract files.
* @param $files
* Optionally specify a list of files to be extracted. Files are
* relative to the root of the archive. If not specified, all files
* in the archive will be extracted.
*
* @return ArchiverInterface
* The called object.
*/
public function extract($path, array $files = array());
/**
* Lists all files in the archive.
*
* @return
* An array of file names relative to the root of the archive.
*/
public function listContents();
}
+334
View File
@@ -0,0 +1,334 @@
<?php
/**
* @file
* Helper functions and form handlers used for the authorize.php script.
*/
/**
* Form constructor for the file transfer authorization form.
*
* Allows the user to choose a FileTransfer type and supply credentials.
*
* @see authorize_filetransfer_form_validate()
* @see authorize_filetransfer_form_submit()
* @ingroup forms
*/
function authorize_filetransfer_form($form, &$form_state) {
global $base_url, $is_https;
$form = array();
// If possible, we want to post this form securely via HTTPS.
$form['#https'] = TRUE;
// CSS we depend on lives in modules/system/maintenance.css, which is loaded
// via the default maintenance theme.
$form['#attached']['js'][] = $base_url . '/misc/authorize.js';
// Get all the available ways to transfer files.
if (empty($_SESSION['authorize_filetransfer_info'])) {
drupal_set_message(t('Unable to continue, no available methods of file transfer'), 'error');
return array();
}
$available_backends = $_SESSION['authorize_filetransfer_info'];
if (!$is_https) {
$form['information']['https_warning'] = array(
'#prefix' => '<div class="messages error">',
'#markup' => t('WARNING: You are not using an encrypted connection, so your password will be sent in plain text. <a href="@https-link">Learn more</a>.', array('@https-link' => 'http://drupal.org/https-information')),
'#suffix' => '</div>',
);
}
// Decide on a default backend.
if (isset($form_state['values']['connection_settings']['authorize_filetransfer_default'])) {
$authorize_filetransfer_default = $form_state['values']['connection_settings']['authorize_filetransfer_default'];
}
elseif ($authorize_filetransfer_default = variable_get('authorize_filetransfer_default', NULL));
else {
$authorize_filetransfer_default = key($available_backends);
}
$form['information']['main_header'] = array(
'#prefix' => '<h3>',
'#markup' => t('To continue, provide your server connection details'),
'#suffix' => '</h3>',
);
$form['connection_settings']['#tree'] = TRUE;
$form['connection_settings']['authorize_filetransfer_default'] = array(
'#type' => 'select',
'#title' => t('Connection method'),
'#default_value' => $authorize_filetransfer_default,
'#weight' => -10,
);
/*
* Here we create two submit buttons. For a JS enabled client, they will
* only ever see submit_process. However, if a client doesn't have JS
* enabled, they will see submit_connection on the first form (when picking
* what filetransfer type to use, and submit_process on the second one (which
* leads to the actual operation).
*/
$form['submit_connection'] = array(
'#prefix' => "<br style='clear:both'/>",
'#name' => 'enter_connection_settings',
'#type' => 'submit',
'#value' => t('Enter connection settings'),
'#weight' => 100,
);
$form['submit_process'] = array(
'#name' => 'process_updates',
'#type' => 'submit',
'#value' => t('Continue'),
'#weight' => 100,
'#attributes' => array('style' => 'display:none'),
);
// Build a container for each connection type.
foreach ($available_backends as $name => $backend) {
$form['connection_settings']['authorize_filetransfer_default']['#options'][$name] = $backend['title'];
$form['connection_settings'][$name] = array(
'#type' => 'container',
'#attributes' => array('class' => array("filetransfer-$name", 'filetransfer')),
);
// We can't use #prefix on the container itself since then the header won't
// be hidden and shown when the containers are being manipulated via JS.
$form['connection_settings'][$name]['header'] = array(
'#markup' => '<h4>' . t('@backend connection settings', array('@backend' => $backend['title'])) . '</h4>',
);
$form['connection_settings'][$name] += _authorize_filetransfer_connection_settings($name);
// Start non-JS code.
if (isset($form_state['values']['connection_settings']['authorize_filetransfer_default']) && $form_state['values']['connection_settings']['authorize_filetransfer_default'] == $name) {
// If the user switches from JS to non-JS, Drupal (and Batch API) will
// barf. This is a known bug: http://drupal.org/node/229825.
setcookie('has_js', '', time() - 3600, '/');
unset($_COOKIE['has_js']);
// Change the submit button to the submit_process one.
$form['submit_process']['#attributes'] = array();
unset($form['submit_connection']);
// Activate the proper filetransfer settings form.
$form['connection_settings'][$name]['#attributes']['style'] = 'display:block';
// Disable the select box.
$form['connection_settings']['authorize_filetransfer_default']['#disabled'] = TRUE;
// Create a button for changing the type of connection.
$form['connection_settings']['change_connection_type'] = array(
'#name' => 'change_connection_type',
'#type' => 'submit',
'#value' => t('Change connection type'),
'#weight' => -5,
'#attributes' => array('class' => array('filetransfer-change-connection-type')),
);
}
// End non-JS code.
}
return $form;
}
/**
* Generates the Form API array for a given connection backend's settings.
*
* @param $backend
* The name of the backend (e.g. 'ftp', 'ssh', etc).
*
* @return
* Form API array of connection settings for the given backend.
*
* @see hook_filetransfer_backends()
*/
function _authorize_filetransfer_connection_settings($backend) {
$defaults = variable_get('authorize_filetransfer_connection_settings_' . $backend, array());
$form = array();
// Create an instance of the file transfer class to get its settings form.
$filetransfer = authorize_get_filetransfer($backend);
if ($filetransfer) {
$form = $filetransfer->getSettingsForm();
}
// Fill in the defaults based on the saved settings, if any.
_authorize_filetransfer_connection_settings_set_defaults($form, NULL, $defaults);
return $form;
}
/**
* Sets the default settings on a file transfer connection form recursively.
*
* The default settings for the file transfer connection forms are saved in
* the database. The settings are stored as a nested array in the case of a
* settings form that has fieldsets or otherwise uses a nested structure.
* Therefore, to properly add defaults, we need to walk through all the
* children form elements and process those defaults recursively.
*
* @param $element
* Reference to the Form API form element we're operating on.
* @param $key
* The key for our current form element, if any.
* @param array $defaults
* The default settings for the file transfer backend we're operating on.
*/
function _authorize_filetransfer_connection_settings_set_defaults(&$element, $key, array $defaults) {
// If we're operating on a form element which isn't a fieldset, and we have
// a default setting saved, stash it in #default_value.
if (!empty($key) && isset($defaults[$key]) && isset($element['#type']) && $element['#type'] != 'fieldset') {
$element['#default_value'] = $defaults[$key];
}
// Now, we walk through all the child elements, and recursively invoke
// ourself on each one. Since the $defaults settings array can be nested
// (because of #tree, any values inside fieldsets will be nested), if
// there's a subarray of settings for the form key we're currently
// processing, pass in that subarray to the recursive call. Otherwise, just
// pass on the whole $defaults array.
foreach (element_children($element) as $child_key) {
_authorize_filetransfer_connection_settings_set_defaults($element[$child_key], $child_key, ((isset($defaults[$key]) && is_array($defaults[$key])) ? $defaults[$key] : $defaults));
}
}
/**
* Form validation handler for authorize_filetransfer_form().
*
* @see authorize_filetransfer_form()
* @see authorize_filetransfer_submit()
*/
function authorize_filetransfer_form_validate($form, &$form_state) {
// Only validate the form if we have collected all of the user input and are
// ready to proceed with updating or installing.
if ($form_state['triggering_element']['#name'] != 'process_updates') {
return;
}
if (isset($form_state['values']['connection_settings'])) {
$backend = $form_state['values']['connection_settings']['authorize_filetransfer_default'];
$filetransfer = authorize_get_filetransfer($backend, $form_state['values']['connection_settings'][$backend]);
try {
if (!$filetransfer) {
throw new Exception(t('Error, this type of connection protocol (%backend) does not exist.', array('%backend' => $backend)));
}
$filetransfer->connect();
}
catch (Exception $e) {
// The format of this error message is similar to that used on the
// database connection form in the installer.
form_set_error('connection_settings', t('Failed to connect to the server. The server reports the following message: !message For more help installing or updating code on your server, see the <a href="@handbook_url">handbook</a>.', array(
'!message' => '<p class="error">' . $e->getMessage() . '</p>',
'@handbook_url' => 'http://drupal.org/documentation/install/modules-themes',
)));
}
}
}
/**
* Form submission handler for authorize_filetransfer_form().
*
* @see authorize_filetransfer_form()
* @see authorize_filetransfer_validate()
*/
function authorize_filetransfer_form_submit($form, &$form_state) {
global $base_url;
switch ($form_state['triggering_element']['#name']) {
case 'process_updates':
// Save the connection settings to the DB.
$filetransfer_backend = $form_state['values']['connection_settings']['authorize_filetransfer_default'];
// If the database is available then try to save our settings. We have
// to make sure it is available since this code could potentially (will
// likely) be called during the installation process, before the
// database is set up.
try {
$connection_settings = array();
foreach ($form_state['values']['connection_settings'][$filetransfer_backend] as $key => $value) {
// We do *not* want to store passwords in the database, unless the
// backend explicitly says so via the magic #filetransfer_save form
// property. Otherwise, we store everything that's not explicitly
// marked with #filetransfer_save set to FALSE.
if (!isset($form['connection_settings'][$filetransfer_backend][$key]['#filetransfer_save'])) {
if ($form['connection_settings'][$filetransfer_backend][$key]['#type'] != 'password') {
$connection_settings[$key] = $value;
}
}
// The attribute is defined, so only save if set to TRUE.
elseif ($form['connection_settings'][$filetransfer_backend][$key]['#filetransfer_save']) {
$connection_settings[$key] = $value;
}
}
// Set this one as the default authorize method.
variable_set('authorize_filetransfer_default', $filetransfer_backend);
// Save the connection settings minus the password.
variable_set('authorize_filetransfer_connection_settings_' . $filetransfer_backend, $connection_settings);
$filetransfer = authorize_get_filetransfer($filetransfer_backend, $form_state['values']['connection_settings'][$filetransfer_backend]);
// Now run the operation.
authorize_run_operation($filetransfer);
}
catch (Exception $e) {
// If there is no database available, we don't care and just skip
// this part entirely.
}
break;
case 'enter_connection_settings':
$form_state['rebuild'] = TRUE;
break;
case 'change_connection_type':
$form_state['rebuild'] = TRUE;
unset($form_state['values']['connection_settings']['authorize_filetransfer_default']);
break;
}
}
/**
* Runs the operation specified in $_SESSION['authorize_operation'].
*
* @param $filetransfer
* The FileTransfer object to use for running the operation.
*/
function authorize_run_operation($filetransfer) {
$operation = $_SESSION['authorize_operation'];
unset($_SESSION['authorize_operation']);
if (!empty($operation['page_title'])) {
drupal_set_title($operation['page_title']);
}
require_once DRUPAL_ROOT . '/' . $operation['file'];
call_user_func_array($operation['callback'], array_merge(array($filetransfer), $operation['arguments']));
}
/**
* Gets a FileTransfer class for a specific transfer method and settings.
*
* @param $backend
* The FileTransfer backend to get the class for.
* @param $settings
* Array of settings for the FileTransfer.
*
* @return
* An instantiated FileTransfer object for the requested method and settings,
* or FALSE if there was an error finding or instantiating it.
*/
function authorize_get_filetransfer($backend, $settings = array()) {
$filetransfer = FALSE;
if (!empty($_SESSION['authorize_filetransfer_info'][$backend])) {
$backend_info = $_SESSION['authorize_filetransfer_info'][$backend];
if (!empty($backend_info['file'])) {
$file = $backend_info['file path'] . '/' . $backend_info['file'];
require_once $file;
}
if (class_exists($backend_info['class'])) {
// PHP 5.2 doesn't support $class::factory() syntax, so we have to
// use call_user_func_array() until we can require PHP 5.3.
$filetransfer = call_user_func_array(array($backend_info['class'], 'factory'), array(DRUPAL_ROOT, $settings));
}
}
return $filetransfer;
}
+538
View File
@@ -0,0 +1,538 @@
<?php
/**
* @file
* Batch processing API for processes to run in multiple HTTP requests.
*
* Note that batches are usually invoked by form submissions, which is
* why the core interaction functions of the batch processing API live in
* form.inc.
*
* @see form.inc
* @see batch_set()
* @see batch_process()
* @see batch_get()
*/
/**
* Loads a batch from the database.
*
* @param $id
* The ID of the batch to load. When a progressive batch is being processed,
* the relevant ID is found in $_REQUEST['id'].
*
* @return
* An array representing the batch, or FALSE if no batch was found.
*/
function batch_load($id) {
$batch = db_query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", array(
':bid' => $id,
':token' => drupal_get_token($id),
))->fetchField();
if ($batch) {
return unserialize($batch);
}
return FALSE;
}
/**
* Renders the batch processing page based on the current state of the batch.
*
* @see _batch_shutdown()
*/
function _batch_page() {
$batch = &batch_get();
if (!isset($_REQUEST['id'])) {
return FALSE;
}
// Retrieve the current state of the batch.
if (!$batch) {
$batch = batch_load($_REQUEST['id']);
if (!$batch) {
drupal_set_message(t('No active batch.'), 'error');
drupal_goto();
}
}
// Register database update for the end of processing.
drupal_register_shutdown_function('_batch_shutdown');
// Add batch-specific CSS.
foreach ($batch['sets'] as $batch_set) {
if (isset($batch_set['css'])) {
foreach ($batch_set['css'] as $css) {
drupal_add_css($css);
}
}
}
$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
$output = NULL;
switch ($op) {
case 'start':
$output = _batch_start();
break;
case 'do':
// JavaScript-based progress page callback.
_batch_do();
break;
case 'do_nojs':
// Non-JavaScript-based progress page.
$output = _batch_progress_page_nojs();
break;
case 'finished':
$output = _batch_finished();
break;
}
return $output;
}
/**
* Initializes the batch processing.
*
* JavaScript-enabled clients are identified by the 'has_js' cookie set in
* drupal.js. If no JavaScript-enabled page has been visited during the current
* user's browser session, the non-JavaScript version is returned.
*/
function _batch_start() {
if (isset($_COOKIE['has_js']) && $_COOKIE['has_js']) {
return _batch_progress_page_js();
}
else {
return _batch_progress_page_nojs();
}
}
/**
* Outputs a batch processing page with JavaScript support.
*
* This initializes the batch and error messages. Note that in JavaScript-based
* processing, the batch processing page is displayed only once and updated via
* AHAH requests, so only the first batch set gets to define the page title.
* Titles specified by subsequent batch sets are not displayed.
*
* @see batch_set()
* @see _batch_do()
*/
function _batch_progress_page_js() {
$batch = batch_get();
$current_set = _batch_current_set();
drupal_set_title($current_set['title'], PASS_THROUGH);
// Merge required query parameters for batch processing into those provided by
// batch_set() or hook_batch_alter().
$batch['url_options']['query']['id'] = $batch['id'];
$js_setting = array(
'batch' => array(
'errorMessage' => $current_set['error_message'] . '<br />' . $batch['error_message'],
'initMessage' => $current_set['init_message'],
'uri' => url($batch['url'], $batch['url_options']),
),
);
drupal_add_js($js_setting, 'setting');
drupal_add_library('system', 'drupal.batch');
return '<div id="progress"></div>';
}
/**
* Does one execution pass with JavaScript and returns progress to the browser.
*
* @see _batch_progress_page_js()
* @see _batch_process()
*/
function _batch_do() {
// HTTP POST required.
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
drupal_set_message(t('HTTP POST is required.'), 'error');
drupal_set_title(t('Error'));
return '';
}
// Perform actual processing.
list($percentage, $message) = _batch_process();
drupal_json_output(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message));
}
/**
* Outputs a batch processing page without JavaScript support.
*
* @see _batch_process()
*/
function _batch_progress_page_nojs() {
$batch = &batch_get();
$current_set = _batch_current_set();
drupal_set_title($current_set['title'], PASS_THROUGH);
$new_op = 'do_nojs';
if (!isset($batch['running'])) {
// This is the first page so we return some output immediately.
$percentage = 0;
$message = $current_set['init_message'];
$batch['running'] = TRUE;
}
else {
// This is one of the later requests; do some processing first.
// Error handling: if PHP dies due to a fatal error (e.g. a nonexistent
// function), it will output whatever is in the output buffer, followed by
// the error message.
ob_start();
$fallback = $current_set['error_message'] . '<br />' . $batch['error_message'];
$fallback = theme('maintenance_page', array('content' => $fallback, 'show_messages' => FALSE));
// We strip the end of the page using a marker in the template, so any
// additional HTML output by PHP shows up inside the page rather than below
// it. While this causes invalid HTML, the same would be true if we didn't,
// as content is not allowed to appear after </html> anyway.
list($fallback) = explode('<!--partial-->', $fallback);
print $fallback;
// Perform actual processing.
list($percentage, $message) = _batch_process($batch);
if ($percentage == 100) {
$new_op = 'finished';
}
// PHP did not die; remove the fallback output.
ob_end_clean();
}
// Merge required query parameters for batch processing into those provided by
// batch_set() or hook_batch_alter().
$batch['url_options']['query']['id'] = $batch['id'];
$batch['url_options']['query']['op'] = $new_op;
$url = url($batch['url'], $batch['url_options']);
$element = array(
'#tag' => 'meta',
'#attributes' => array(
'http-equiv' => 'Refresh',
'content' => '0; URL=' . $url,
),
);
drupal_add_html_head($element, 'batch_progress_meta_refresh');
return theme('progress_bar', array('percent' => $percentage, 'message' => $message));
}
/**
* Processes sets in a batch.
*
* If the batch was marked for progressive execution (default), this executes as
* many operations in batch sets until an execution time of 1 second has been
* exceeded. It will continue with the next operation of the same batch set in
* the next request.
*
* @return
* An array containing a completion value (in percent) and a status message.
*/
function _batch_process() {
$batch = &batch_get();
$current_set = &_batch_current_set();
// Indicate that this batch set needs to be initialized.
$set_changed = TRUE;
// If this batch was marked for progressive execution (e.g. forms submitted by
// drupal_form_submit()), initialize a timer to determine whether we need to
// proceed with the same batch phase when a processing time of 1 second has
// been exceeded.
if ($batch['progressive']) {
timer_start('batch_processing');
}
if (empty($current_set['start'])) {
$current_set['start'] = microtime(TRUE);
}
$queue = _batch_queue($current_set);
while (!$current_set['success']) {
// If this is the first time we iterate this batch set in the current
// request, we check if it requires an additional file for functions
// definitions.
if ($set_changed && isset($current_set['file']) && is_file($current_set['file'])) {
include_once DRUPAL_ROOT . '/' . $current_set['file'];
}
$task_message = '';
// Assume a single pass operation and set the completion level to 1 by
// default.
$finished = 1;
if ($item = $queue->claimItem()) {
list($function, $args) = $item->data;
// Build the 'context' array and execute the function call.
$batch_context = array(
'sandbox' => &$current_set['sandbox'],
'results' => &$current_set['results'],
'finished' => &$finished,
'message' => &$task_message,
);
call_user_func_array($function, array_merge($args, array(&$batch_context)));
if ($finished >= 1) {
// Make sure this step is not counted twice when computing $current.
$finished = 0;
// Remove the processed operation and clear the sandbox.
$queue->deleteItem($item);
$current_set['count']--;
$current_set['sandbox'] = array();
}
}
// When all operations in the current batch set are completed, browse
// through the remaining sets, marking them 'successfully processed'
// along the way, until we find a set that contains operations.
// _batch_next_set() executes form submit handlers stored in 'control'
// sets (see form_execute_handlers()), which can in turn add new sets to
// the batch.
$set_changed = FALSE;
$old_set = $current_set;
while (empty($current_set['count']) && ($current_set['success'] = TRUE) && _batch_next_set()) {
$current_set = &_batch_current_set();
$current_set['start'] = microtime(TRUE);
$set_changed = TRUE;
}
// At this point, either $current_set contains operations that need to be
// processed or all sets have been completed.
$queue = _batch_queue($current_set);
// If we are in progressive mode, break processing after 1 second.
if ($batch['progressive'] && timer_read('batch_processing') > 1000) {
// Record elapsed wall clock time.
$current_set['elapsed'] = round((microtime(TRUE) - $current_set['start']) * 1000, 2);
break;
}
}
if ($batch['progressive']) {
// Gather progress information.
// Reporting 100% progress will cause the whole batch to be considered
// processed. If processing was paused right after moving to a new set,
// we have to use the info from the new (unprocessed) set.
if ($set_changed && isset($current_set['queue'])) {
// Processing will continue with a fresh batch set.
$remaining = $current_set['count'];
$total = $current_set['total'];
$progress_message = $current_set['init_message'];
$task_message = '';
}
else {
// Processing will continue with the current batch set.
$remaining = $old_set['count'];
$total = $old_set['total'];
$progress_message = $old_set['progress_message'];
}
// Total progress is the number of operations that have fully run plus the
// completion level of the current operation.
$current = $total - $remaining + $finished;
$percentage = _batch_api_percentage($total, $current);
$elapsed = isset($current_set['elapsed']) ? $current_set['elapsed'] : 0;
$values = array(
'@remaining' => $remaining,
'@total' => $total,
'@current' => floor($current),
'@percentage' => $percentage,
'@elapsed' => format_interval($elapsed / 1000),
// If possible, estimate remaining processing time.
'@estimate' => ($current > 0) ? format_interval(($elapsed * ($total - $current) / $current) / 1000) : '-',
);
$message = strtr($progress_message, $values);
if (!empty($message)) {
$message .= '<br />';
}
if (!empty($task_message)) {
$message .= $task_message;
}
return array($percentage, $message);
}
else {
// If we are not in progressive mode, the entire batch has been processed.
return _batch_finished();
}
}
/**
* Formats the percent completion for a batch set.
*
* @param $total
* The total number of operations.
* @param $current
* The number of the current operation. This may be a floating point number
* rather than an integer in the case of a multi-step operation that is not
* yet complete; in that case, the fractional part of $current represents the
* fraction of the operation that has been completed.
*
* @return
* The properly formatted percentage, as a string. We output percentages
* using the correct number of decimal places so that we never print "100%"
* until we are finished, but we also never print more decimal places than
* are meaningful.
*
* @see _batch_process()
*/
function _batch_api_percentage($total, $current) {
if (!$total || $total == $current) {
// If $total doesn't evaluate as true or is equal to the current set, then
// we're finished, and we can return "100".
$percentage = "100";
}
else {
// We add a new digit at 200, 2000, etc. (since, for example, 199/200
// would round up to 100% if we didn't).
$decimal_places = max(0, floor(log10($total / 2.0)) - 1);
do {
// Calculate the percentage to the specified number of decimal places.
$percentage = sprintf('%01.' . $decimal_places . 'f', round($current / $total * 100, $decimal_places));
// When $current is an integer, the above calculation will always be
// correct. However, if $current is a floating point number (in the case
// of a multi-step batch operation that is not yet complete), $percentage
// may be erroneously rounded up to 100%. To prevent that, we add one
// more decimal place and try again.
$decimal_places++;
} while ($percentage == '100');
}
return $percentage;
}
/**
* Returns the batch set being currently processed.
*/
function &_batch_current_set() {
$batch = &batch_get();
return $batch['sets'][$batch['current_set']];
}
/**
* Retrieves the next set in a batch.
*
* If there is a subsequent set in this batch, assign it as the new set to
* process and execute its form submit handler (if defined), which may add
* further sets to this batch.
*
* @return
* TRUE if a subsequent set was found in the batch.
*/
function _batch_next_set() {
$batch = &batch_get();
if (isset($batch['sets'][$batch['current_set'] + 1])) {
$batch['current_set']++;
$current_set = &_batch_current_set();
if (isset($current_set['form_submit']) && ($function = $current_set['form_submit']) && function_exists($function)) {
// We use our stored copies of $form and $form_state to account for
// possible alterations by previous form submit handlers.
$function($batch['form_state']['complete form'], $batch['form_state']);
}
return TRUE;
}
}
/**
* Ends the batch processing.
*
* Call the 'finished' callback of each batch set to allow custom handling of
* the results and resolve page redirection.
*/
function _batch_finished() {
$batch = &batch_get();
// Execute the 'finished' callbacks for each batch set, if defined.
foreach ($batch['sets'] as $batch_set) {
if (isset($batch_set['finished'])) {
// Check if the set requires an additional file for function definitions.
if (isset($batch_set['file']) && is_file($batch_set['file'])) {
include_once DRUPAL_ROOT . '/' . $batch_set['file'];
}
if (is_callable($batch_set['finished'])) {
$queue = _batch_queue($batch_set);
$operations = $queue->getAllItems();
call_user_func($batch_set['finished'], $batch_set['success'], $batch_set['results'], $operations, format_interval($batch_set['elapsed'] / 1000));
}
}
}
// Clean up the batch table and unset the static $batch variable.
if ($batch['progressive']) {
db_delete('batch')
->condition('bid', $batch['id'])
->execute();
foreach ($batch['sets'] as $batch_set) {
if ($queue = _batch_queue($batch_set)) {
$queue->deleteQueue();
}
}
// Clean-up the session. Not needed for CLI updates.
if (isset($_SESSION)) {
unset($_SESSION['batches'][$batch['id']]);
if (empty($_SESSION['batches'])) {
unset($_SESSION['batches']);
}
}
}
$_batch = $batch;
$batch = NULL;
// Redirect if needed.
if ($_batch['progressive']) {
// Revert the 'destination' that was saved in batch_process().
if (isset($_batch['destination'])) {
$_GET['destination'] = $_batch['destination'];
}
// Determine the target path to redirect to.
if (!isset($_batch['form_state']['redirect'])) {
if (isset($_batch['redirect'])) {
$_batch['form_state']['redirect'] = $_batch['redirect'];
}
else {
$_batch['form_state']['redirect'] = $_batch['source_url'];
}
}
// Use drupal_redirect_form() to handle the redirection logic.
drupal_redirect_form($_batch['form_state']);
// If no redirection happened, redirect to the originating page. In case the
// form needs to be rebuilt, save the final $form_state for
// drupal_build_form().
if (!empty($_batch['form_state']['rebuild'])) {
$_SESSION['batch_form_state'] = $_batch['form_state'];
}
$function = $_batch['redirect_callback'];
if (function_exists($function)) {
$function($_batch['source_url'], array('query' => array('op' => 'finish', 'id' => $_batch['id'])));
}
}
}
/**
* Shutdown function: Stores the current batch data for the next request.
*
* @see _batch_page()
* @see drupal_register_shutdown_function()
*/
function _batch_shutdown() {
if ($batch = batch_get()) {
db_update('batch')
->fields(array('batch' => serialize($batch)))
->condition('bid', $batch['id'])
->execute();
}
}
+84
View File
@@ -0,0 +1,84 @@
<?php
/**
* @file
* Queue handlers used by the Batch API.
*
* These implementations:
* - Ensure FIFO ordering.
* - Allow an item to be repeatedly claimed until it is actually deleted (no
* notion of lease time or 'expire' date), to allow multipass operations.
*/
/**
* Defines a batch queue.
*
* Stale items from failed batches are cleaned from the {queue} table on cron
* using the 'created' date.
*/
class BatchQueue extends SystemQueue {
/**
* Overrides SystemQueue::claimItem().
*
* Unlike SystemQueue::claimItem(), this method provides a default lease
* time of 0 (no expiration) instead of 30. This allows the item to be
* claimed repeatedly until it is deleted.
*/
public function claimItem($lease_time = 0) {
$item = db_query_range('SELECT data, item_id FROM {queue} q WHERE name = :name ORDER BY item_id ASC', 0, 1, array(':name' => $this->name))->fetchObject();
if ($item) {
$item->data = unserialize($item->data);
return $item;
}
return FALSE;
}
/**
* Retrieves all remaining items in the queue.
*
* This is specific to Batch API and is not part of the DrupalQueueInterface.
*/
public function getAllItems() {
$result = array();
$items = db_query('SELECT data FROM {queue} q WHERE name = :name ORDER BY item_id ASC', array(':name' => $this->name))->fetchAll();
foreach ($items as $item) {
$result[] = unserialize($item->data);
}
return $result;
}
}
/**
* Defines a batch queue for non-progressive batches.
*/
class BatchMemoryQueue extends MemoryQueue {
/**
* Overrides MemoryQueue::claimItem().
*
* Unlike MemoryQueue::claimItem(), this method provides a default lease
* time of 0 (no expiration) instead of 30. This allows the item to be
* claimed repeatedly until it is deleted.
*/
public function claimItem($lease_time = 0) {
if (!empty($this->queue)) {
reset($this->queue);
return current($this->queue);
}
return FALSE;
}
/**
* Retrieves all remaining items in the queue.
*
* This is specific to Batch API and is not part of the DrupalQueueInterface.
*/
public function getAllItems() {
$result = array();
foreach ($this->queue as $item) {
$result[] = $item->data;
}
return $result;
}
}
File diff suppressed because it is too large Load Diff
+74
View File
@@ -0,0 +1,74 @@
<?php
/**
* @file
* Provides a stub cache implementation to be used during installation.
*/
/**
* Defines a stub cache implementation to be used during installation.
*
* The stub implementation is needed when database access is not yet available.
* Because Drupal's caching system never requires that cached data be present,
* these stub functions can short-circuit the process and sidestep the need for
* any persistent storage. Obviously, using this cache implementation during
* normal operations would have a negative impact on performance.
*/
class DrupalFakeCache extends DrupalDatabaseCache implements DrupalCacheInterface {
/**
* Overrides DrupalDatabaseCache::get().
*/
function get($cid) {
return FALSE;
}
/**
* Overrides DrupalDatabaseCache::getMultiple().
*/
function getMultiple(&$cids) {
return array();
}
/**
* Overrides DrupalDatabaseCache::set().
*/
function set($cid, $data, $expire = CACHE_PERMANENT) {
}
/**
* Overrides DrupalDatabaseCache::clear().
*/
function clear($cid = NULL, $wildcard = FALSE) {
// If there is a database cache, attempt to clear it whenever possible. The
// reason for doing this is that the database cache can accumulate data
// during installation due to any full bootstraps that may occur at the
// same time (for example, Ajax requests triggered by the installer). If we
// didn't try to clear it whenever this function is called, the data in the
// cache would become stale; for example, the installer sometimes calls
// variable_set(), which updates the {variable} table and then clears the
// cache to make sure that the next page request picks up the new value.
// Not actually clearing the cache here therefore leads old variables to be
// loaded on the first page requests after installation, which can cause
// subtle bugs, some of which would not be fixed unless the site
// administrator cleared the cache manually.
try {
if (class_exists('Database')) {
parent::clear($cid, $wildcard);
}
}
// If the attempt at clearing the cache causes an error, that means that
// either the database connection is not set up yet or the relevant cache
// table in the database has not yet been created, so we can safely do
// nothing here.
catch (Exception $e) {
}
}
/**
* Overrides DrupalDatabaseCache::isEmpty().
*/
function isEmpty() {
return TRUE;
}
}
+590
View File
@@ -0,0 +1,590 @@
<?php
/**
* @file
* Functions and interfaces for cache handling.
*/
/**
* Gets the cache object for a cache bin.
*
* By default, this returns an instance of the DrupalDatabaseCache class.
* Classes implementing DrupalCacheInterface can register themselves both as a
* default implementation and for specific bins.
*
* @param $bin
* The cache bin for which the cache object should be returned.
*
* @return DrupalCacheInterface
* The cache object associated with the specified bin.
*
* @see DrupalCacheInterface
*/
function _cache_get_object($bin) {
// We do not use drupal_static() here because we do not want to change the
// storage of a cache bin mid-request.
static $cache_objects;
if (!isset($cache_objects[$bin])) {
$class = variable_get('cache_class_' . $bin);
if (!isset($class)) {
$class = variable_get('cache_default_class', 'DrupalDatabaseCache');
}
$cache_objects[$bin] = new $class($bin);
}
return $cache_objects[$bin];
}
/**
* Returns data from the persistent cache.
*
* Data may be stored as either plain text or as serialized data. cache_get
* will automatically return unserialized objects and arrays.
*
* @param $cid
* The cache ID of the data to retrieve.
* @param $bin
* The cache bin to store the data in. Valid core values are 'cache_block',
* 'cache_bootstrap', 'cache_field', 'cache_filter', 'cache_form',
* 'cache_menu', 'cache_page', 'cache_path', 'cache_update' or 'cache' for
* the default cache.
*
* @return
* The cache or FALSE on failure.
*
* @see cache_set()
*/
function cache_get($cid, $bin = 'cache') {
return _cache_get_object($bin)->get($cid);
}
/**
* Returns data from the persistent cache when given an array of cache IDs.
*
* @param $cids
* An array of cache IDs for the data to retrieve. This is passed by
* reference, and will have the IDs successfully returned from cache removed.
* @param $bin
* The cache bin where the data is stored.
*
* @return
* An array of the items successfully returned from cache indexed by cid.
*/
function cache_get_multiple(array &$cids, $bin = 'cache') {
return _cache_get_object($bin)->getMultiple($cids);
}
/**
* Stores data in the persistent cache.
*
* The persistent cache is split up into several cache bins. In the default
* cache implementation, each cache bin corresponds to a database table by the
* same name. Other implementations might want to store several bins in data
* structures that get flushed together. While it is not a problem for most
* cache bins if the entries in them are flushed before their expire time, some
* might break functionality or are extremely expensive to recalculate. The
* other bins are expired automatically by core. Contributed modules can add
* additional bins and get them expired automatically by implementing
* hook_flush_caches().
*
* The reasons for having several bins are as follows:
* - Smaller bins mean smaller database tables and allow for faster selects and
* inserts.
* - We try to put fast changing cache items and rather static ones into
* different bins. The effect is that only the fast changing bins will need a
* lot of writes to disk. The more static bins will also be better cacheable
* with MySQL's query cache.
*
* @param $cid
* The cache ID of the data to store.
* @param $data
* The data to store in the cache. Complex data types will be automatically
* serialized before insertion. Strings will be stored as plain text and are
* not serialized. Some storage engines only allow objects up to a maximum of
* 1MB in size to be stored by default. When caching large arrays or similar,
* take care to ensure $data does not exceed this size.
* @param $bin
* (optional) The cache bin to store the data in. Valid core values are:
* - cache: (default) Generic cache storage bin (used for theme registry,
* locale date, list of simpletest tests, etc.).
* - cache_block: Stores the content of various blocks.
* - cache_bootstrap: Stores the class registry, the system list of modules,
* the list of which modules implement which hooks, and the Drupal variable
* list.
* - cache_field: Stores the field data belonging to a given object.
* - cache_filter: Stores filtered pieces of content.
* - cache_form: Stores multistep forms. Flushing this bin means that some
* forms displayed to users lose their state and the data already submitted
* to them. This bin should not be flushed before its expired time.
* - cache_menu: Stores the structure of visible navigation menus per page.
* - cache_page: Stores generated pages for anonymous users. It is flushed
* very often, whenever a page changes, at least for every node and comment
* submission. This is the only bin affected by the page cache setting on
* the administrator panel.
* - cache_path: Stores the system paths that have an alias.
* @param $expire
* (optional) Controls the maximum lifetime of this cache entry. Note that
* caches might be subject to clearing at any time, so this setting does not
* guarantee a minimum lifetime. With this in mind, the cache should not be
* used for data that must be kept during a cache clear, like sessions.
*
* Use one of the following values:
* - CACHE_PERMANENT: Indicates that the item should never be removed unless
* explicitly told to using cache_clear_all() with a cache ID.
* - CACHE_TEMPORARY: Indicates that the item should be removed at the next
* general cache wipe.
* - A Unix timestamp: Indicates that the item should be kept at least until
* the given time, after which it behaves like CACHE_TEMPORARY.
*
* @see _update_cache_set()
* @see cache_get()
*/
function cache_set($cid, $data, $bin = 'cache', $expire = CACHE_PERMANENT) {
return _cache_get_object($bin)->set($cid, $data, $expire);
}
/**
* Expires data from the cache.
*
* If called with the arguments $cid and $bin set to NULL or omitted, then
* expirable entries will be cleared from the cache_page and cache_block bins,
* and the $wildcard argument is ignored.
*
* @param $cid
* If set, the cache ID or an array of cache IDs. Otherwise, all cache entries
* that can expire are deleted. The $wildcard argument will be ignored if set
* to NULL.
* @param $bin
* If set, the cache bin to delete from. Mandatory argument if $cid is set.
* @param $wildcard
* If TRUE, the $cid argument must contain a string value and cache IDs
* starting with $cid are deleted in addition to the exact cache ID specified
* by $cid. If $wildcard is TRUE and $cid is '*', the entire cache is emptied.
*/
function cache_clear_all($cid = NULL, $bin = NULL, $wildcard = FALSE) {
if (!isset($cid) && !isset($bin)) {
// Clear the block cache first, so stale data will
// not end up in the page cache.
if (module_exists('block')) {
cache_clear_all(NULL, 'cache_block');
}
cache_clear_all(NULL, 'cache_page');
return;
}
return _cache_get_object($bin)->clear($cid, $wildcard);
}
/**
* Checks if a cache bin is empty.
*
* A cache bin is considered empty if it does not contain any valid data for any
* cache ID.
*
* @param $bin
* The cache bin to check.
*
* @return
* TRUE if the cache bin specified is empty.
*/
function cache_is_empty($bin) {
return _cache_get_object($bin)->isEmpty();
}
/**
* Defines an interface for cache implementations.
*
* All cache implementations have to implement this interface.
* DrupalDatabaseCache provides the default implementation, which can be
* consulted as an example.
*
* To make Drupal use your implementation for a certain cache bin, you have to
* set a variable with the name of the cache bin as its key and the name of
* your class as its value. For example, if your implementation of
* DrupalCacheInterface was called MyCustomCache, the following line would make
* Drupal use it for the 'cache_page' bin:
* @code
* variable_set('cache_class_cache_page', 'MyCustomCache');
* @endcode
*
* Additionally, you can register your cache implementation to be used by
* default for all cache bins by setting the variable 'cache_default_class' to
* the name of your implementation of the DrupalCacheInterface, e.g.
* @code
* variable_set('cache_default_class', 'MyCustomCache');
* @endcode
*
* To implement a completely custom cache bin, use the same variable format:
* @code
* variable_set('cache_class_custom_bin', 'MyCustomCache');
* @endcode
* To access your custom cache bin, specify the name of the bin when storing
* or retrieving cached data:
* @code
* cache_set($cid, $data, 'custom_bin', $expire);
* cache_get($cid, 'custom_bin');
* @endcode
*
* @see _cache_get_object()
* @see DrupalDatabaseCache
*/
interface DrupalCacheInterface {
/**
* Returns data from the persistent cache.
*
* Data may be stored as either plain text or as serialized data. cache_get()
* will automatically return unserialized objects and arrays.
*
* @param $cid
* The cache ID of the data to retrieve.
*
* @return
* The cache or FALSE on failure.
*/
function get($cid);
/**
* Returns data from the persistent cache when given an array of cache IDs.
*
* @param $cids
* An array of cache IDs for the data to retrieve. This is passed by
* reference, and will have the IDs successfully returned from cache
* removed.
*
* @return
* An array of the items successfully returned from cache indexed by cid.
*/
function getMultiple(&$cids);
/**
* Stores data in the persistent cache.
*
* @param $cid
* The cache ID of the data to store.
* @param $data
* The data to store in the cache. Complex data types will be automatically
* serialized before insertion. Strings will be stored as plain text and not
* serialized. Some storage engines only allow objects up to a maximum of
* 1MB in size to be stored by default. When caching large arrays or
* similar, take care to ensure $data does not exceed this size.
* @param $expire
* (optional) Controls the maximum lifetime of this cache entry. Note that
* caches might be subject to clearing at any time, so this setting does not
* guarantee a minimum lifetime. With this in mind, the cache should not be
* used for data that must be kept during a cache clear, like sessions.
*
* Use one of the following values:
* - CACHE_PERMANENT: Indicates that the item should never be removed unless
* explicitly told to using cache_clear_all() with a cache ID.
* - CACHE_TEMPORARY: Indicates that the item should be removed at the next
* general cache wipe.
* - A Unix timestamp: Indicates that the item should be kept at least until
* the given time, after which it behaves like CACHE_TEMPORARY.
*/
function set($cid, $data, $expire = CACHE_PERMANENT);
/**
* Expires data from the cache.
*
* If called without arguments, expirable entries will be cleared from the
* cache_page and cache_block bins.
*
* @param $cid
* If set, the cache ID or an array of cache IDs. Otherwise, all cache
* entries that can expire are deleted. The $wildcard argument will be
* ignored if set to NULL.
* @param $wildcard
* If TRUE, the $cid argument must contain a string value and cache IDs
* starting with $cid are deleted in addition to the exact cache ID
* specified by $cid. If $wildcard is TRUE and $cid is '*', the entire
* cache is emptied.
*/
function clear($cid = NULL, $wildcard = FALSE);
/**
* Checks if a cache bin is empty.
*
* A cache bin is considered empty if it does not contain any valid data for
* any cache ID.
*
* @return
* TRUE if the cache bin specified is empty.
*/
function isEmpty();
}
/**
* Defines a default cache implementation.
*
* This is Drupal's default cache implementation. It uses the database to store
* cached data. Each cache bin corresponds to a database table by the same name.
*/
class DrupalDatabaseCache implements DrupalCacheInterface {
protected $bin;
/**
* Constructs a DrupalDatabaseCache object.
*
* @param $bin
* The cache bin for which the object is created.
*/
function __construct($bin) {
$this->bin = $bin;
}
/**
* Implements DrupalCacheInterface::get().
*/
function get($cid) {
$cids = array($cid);
$cache = $this->getMultiple($cids);
return reset($cache);
}
/**
* Implements DrupalCacheInterface::getMultiple().
*/
function getMultiple(&$cids) {
try {
// Garbage collection necessary when enforcing a minimum cache lifetime.
$this->garbageCollection($this->bin);
// When serving cached pages, the overhead of using db_select() was found
// to add around 30% overhead to the request. Since $this->bin is a
// variable, this means the call to db_query() here uses a concatenated
// string. This is highly discouraged under any other circumstances, and
// is used here only due to the performance overhead we would incur
// otherwise. When serving an uncached page, the overhead of using
// db_select() is a much smaller proportion of the request.
$result = db_query('SELECT cid, data, created, expire, serialized FROM {' . db_escape_table($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => $cids));
$cache = array();
foreach ($result as $item) {
$item = $this->prepareItem($item);
if ($item) {
$cache[$item->cid] = $item;
}
}
$cids = array_diff($cids, array_keys($cache));
return $cache;
}
catch (Exception $e) {
// If the database is never going to be available, cache requests should
// return FALSE in order to allow exception handling to occur.
return array();
}
}
/**
* Garbage collection for get() and getMultiple().
*
* @param $bin
* The bin being requested.
*/
protected function garbageCollection() {
$cache_lifetime = variable_get('cache_lifetime', 0);
// Clean-up the per-user cache expiration session data, so that the session
// handler can properly clean-up the session data for anonymous users.
if (isset($_SESSION['cache_expiration'])) {
$expire = REQUEST_TIME - $cache_lifetime;
foreach ($_SESSION['cache_expiration'] as $bin => $timestamp) {
if ($timestamp < $expire) {
unset($_SESSION['cache_expiration'][$bin]);
}
}
if (!$_SESSION['cache_expiration']) {
unset($_SESSION['cache_expiration']);
}
}
// Garbage collection of temporary items is only necessary when enforcing
// a minimum cache lifetime.
if (!$cache_lifetime) {
return;
}
// When cache lifetime is in force, avoid running garbage collection too
// often since this will remove temporary cache items indiscriminately.
$cache_flush = variable_get('cache_flush_' . $this->bin, 0);
if ($cache_flush && ($cache_flush + $cache_lifetime <= REQUEST_TIME)) {
// Reset the variable immediately to prevent a meltdown in heavy load situations.
variable_set('cache_flush_' . $this->bin, 0);
// Time to flush old cache data
db_delete($this->bin)
->condition('expire', CACHE_PERMANENT, '<>')
->condition('expire', $cache_flush, '<=')
->execute();
}
}
/**
* Prepares a cached item.
*
* Checks that items are either permanent or did not expire, and unserializes
* data as appropriate.
*
* @param $cache
* An item loaded from cache_get() or cache_get_multiple().
*
* @return
* The item with data unserialized as appropriate or FALSE if there is no
* valid item to load.
*/
protected function prepareItem($cache) {
global $user;
if (!isset($cache->data)) {
return FALSE;
}
// If the cached data is temporary and subject to a per-user minimum
// lifetime, compare the cache entry timestamp with the user session
// cache_expiration timestamp. If the cache entry is too old, ignore it.
if ($cache->expire != CACHE_PERMANENT && variable_get('cache_lifetime', 0) && isset($_SESSION['cache_expiration'][$this->bin]) && $_SESSION['cache_expiration'][$this->bin] > $cache->created) {
// Ignore cache data that is too old and thus not valid for this user.
return FALSE;
}
// If the data is permanent or not subject to a minimum cache lifetime,
// unserialize and return the cached data.
if ($cache->serialized) {
$cache->data = unserialize($cache->data);
}
return $cache;
}
/**
* Implements DrupalCacheInterface::set().
*/
function set($cid, $data, $expire = CACHE_PERMANENT) {
$fields = array(
'serialized' => 0,
'created' => REQUEST_TIME,
'expire' => $expire,
);
if (!is_string($data)) {
$fields['data'] = serialize($data);
$fields['serialized'] = 1;
}
else {
$fields['data'] = $data;
$fields['serialized'] = 0;
}
try {
db_merge($this->bin)
->key(array('cid' => $cid))
->fields($fields)
->execute();
}
catch (Exception $e) {
// The database may not be available, so we'll ignore cache_set requests.
}
}
/**
* Implements DrupalCacheInterface::clear().
*/
function clear($cid = NULL, $wildcard = FALSE) {
global $user;
if (empty($cid)) {
if (variable_get('cache_lifetime', 0)) {
// We store the time in the current user's session. We then simulate
// that the cache was flushed for this user by not returning cached
// data that was cached before the timestamp.
$_SESSION['cache_expiration'][$this->bin] = REQUEST_TIME;
$cache_flush = variable_get('cache_flush_' . $this->bin, 0);
if ($cache_flush == 0) {
// This is the first request to clear the cache, start a timer.
variable_set('cache_flush_' . $this->bin, REQUEST_TIME);
}
elseif (REQUEST_TIME > ($cache_flush + variable_get('cache_lifetime', 0))) {
// Clear the cache for everyone, cache_lifetime seconds have
// passed since the first request to clear the cache.
db_delete($this->bin)
->condition('expire', CACHE_PERMANENT, '<>')
->condition('expire', REQUEST_TIME, '<')
->execute();
variable_set('cache_flush_' . $this->bin, 0);
}
}
else {
// No minimum cache lifetime, flush all temporary cache entries now.
db_delete($this->bin)
->condition('expire', CACHE_PERMANENT, '<>')
->condition('expire', REQUEST_TIME, '<')
->execute();
}
}
else {
if ($wildcard) {
if ($cid == '*') {
// Check if $this->bin is a cache table before truncating. Other
// cache_clear_all() operations throw a PDO error in this situation,
// so we don't need to verify them first. This ensures that non-cache
// tables cannot be truncated accidentally.
if ($this->isValidBin()) {
db_truncate($this->bin)->execute();
}
else {
throw new Exception(t('Invalid or missing cache bin specified: %bin', array('%bin' => $this->bin)));
}
}
else {
db_delete($this->bin)
->condition('cid', db_like($cid) . '%', 'LIKE')
->execute();
}
}
elseif (is_array($cid)) {
// Delete in chunks when a large array is passed.
do {
db_delete($this->bin)
->condition('cid', array_splice($cid, 0, 1000), 'IN')
->execute();
}
while (count($cid));
}
else {
db_delete($this->bin)
->condition('cid', $cid)
->execute();
}
}
}
/**
* Implements DrupalCacheInterface::isEmpty().
*/
function isEmpty() {
$this->garbageCollection();
$query = db_select($this->bin);
$query->addExpression('1');
$result = $query->range(0, 1)
->execute()
->fetchField();
return empty($result);
}
/**
* Checks if $this->bin represents a valid cache table.
*
* This check is required to ensure that non-cache tables are not truncated
* accidentally when calling cache_clear_all().
*
* @return boolean
*/
function isValidBin() {
if ($this->bin == 'cache' || substr($this->bin, 0, 6) == 'cache_') {
// Skip schema check for bins with standard table names.
return TRUE;
}
// These fields are required for any cache table.
$fields = array('cid', 'data', 'expire', 'created', 'serialized');
// Load the table schema.
$schema = drupal_get_schema($this->bin);
// Confirm that all fields are present.
return isset($schema['fields']) && !array_diff($fields, array_keys($schema['fields']));
}
}
+8562
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+161
View File
@@ -0,0 +1,161 @@
<?php
/**
* @file
* Logging classes for the database layer.
*/
/**
* Database query logger.
*
* We log queries in a separate object rather than in the connection object
* because we want to be able to see all queries sent to a given database, not
* database target. If we logged the queries in each connection object we
* would not be able to track what queries went to which target.
*
* Every connection has one and only one logging object on it for all targets
* and logging keys.
*/
class DatabaseLog {
/**
* Cache of logged queries. This will only be used if the query logger is enabled.
*
* The structure for the logging array is as follows:
*
* array(
* $logging_key = array(
* array(query => '', args => array(), caller => '', target => '', time => 0),
* array(query => '', args => array(), caller => '', target => '', time => 0),
* ),
* );
*
* @var array
*/
protected $queryLog = array();
/**
* The connection key for which this object is logging.
*
* @var string
*/
protected $connectionKey = 'default';
/**
* Constructor.
*
* @param $key
* The database connection key for which to enable logging.
*/
public function __construct($key = 'default') {
$this->connectionKey = $key;
}
/**
* Begin logging queries to the specified connection and logging key.
*
* If the specified logging key is already running this method does nothing.
*
* @param $logging_key
* The identification key for this log request. By specifying different
* logging keys we are able to start and stop multiple logging runs
* simultaneously without them colliding.
*/
public function start($logging_key) {
if (empty($this->queryLog[$logging_key])) {
$this->clear($logging_key);
}
}
/**
* Retrieve the query log for the specified logging key so far.
*
* @param $logging_key
* The logging key to fetch.
* @return
* An indexed array of all query records for this logging key.
*/
public function get($logging_key) {
return $this->queryLog[$logging_key];
}
/**
* Empty the query log for the specified logging key.
*
* This method does not stop logging, it simply clears the log. To stop
* logging, use the end() method.
*
* @param $logging_key
* The logging key to empty.
*/
public function clear($logging_key) {
$this->queryLog[$logging_key] = array();
}
/**
* Stop logging for the specified logging key.
*
* @param $logging_key
* The logging key to stop.
*/
public function end($logging_key) {
unset($this->queryLog[$logging_key]);
}
/**
* Log a query to all active logging keys.
*
* @param $statement
* The prepared statement object to log.
* @param $args
* The arguments passed to the statement object.
* @param $time
* The time in milliseconds the query took to execute.
*/
public function log(DatabaseStatementInterface $statement, $args, $time) {
foreach (array_keys($this->queryLog) as $key) {
$this->queryLog[$key][] = array(
'query' => $statement->getQueryString(),
'args' => $args,
'target' => $statement->dbh->getTarget(),
'caller' => $this->findCaller(),
'time' => $time,
);
}
}
/**
* Determine the routine that called this query.
*
* We define "the routine that called this query" as the first entry in
* the call stack that is not inside includes/database and does have a file
* (which excludes call_user_func_array(), anonymous functions and similar).
* That makes the climbing logic very simple, and handles the variable stack
* depth caused by the query builders.
*
* @link http://www.php.net/debug_backtrace
* @return
* This method returns a stack trace entry similar to that generated by
* debug_backtrace(). However, it flattens the trace entry and the trace
* entry before it so that we get the function and args of the function that
* called into the database system, not the function and args of the
* database call itself.
*/
public function findCaller() {
$stack = debug_backtrace();
$stack_count = count($stack);
for ($i = 0; $i < $stack_count; ++$i) {
if (!empty($stack[$i]['file']) && strpos($stack[$i]['file'], 'includes' . DIRECTORY_SEPARATOR . 'database') === FALSE) {
$stack[$i] += array('args' => array());
return array(
'file' => $stack[$i]['file'],
'line' => $stack[$i]['line'],
'function' => $stack[$i + 1]['function'],
'class' => isset($stack[$i + 1]['class']) ? $stack[$i + 1]['class'] : NULL,
'type' => isset($stack[$i + 1]['type']) ? $stack[$i + 1]['type'] : NULL,
'args' => $stack[$i + 1]['args'],
);
}
}
}
}
+256
View File
@@ -0,0 +1,256 @@
<?php
/**
* @file
* Database interface code for MySQL database servers.
*/
/**
* @addtogroup database
* @{
*/
class DatabaseConnection_mysql extends DatabaseConnection {
/**
* Flag to indicate if the cleanup function in __destruct() should run.
*
* @var boolean
*/
protected $needsCleanup = FALSE;
public function __construct(array $connection_options = array()) {
// This driver defaults to transaction support, except if explicitly passed FALSE.
$this->transactionSupport = !isset($connection_options['transactions']) || ($connection_options['transactions'] !== FALSE);
// MySQL never supports transactional DDL.
$this->transactionalDDLSupport = FALSE;
$this->connectionOptions = $connection_options;
$charset = 'utf8';
// Check if the charset is overridden to utf8mb4 in settings.php.
if ($this->utf8mb4IsActive()) {
$charset = 'utf8mb4';
}
// The DSN should use either a socket or a host/port.
if (isset($connection_options['unix_socket'])) {
$dsn = 'mysql:unix_socket=' . $connection_options['unix_socket'];
}
else {
// Default to TCP connection on port 3306.
$dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . (empty($connection_options['port']) ? 3306 : $connection_options['port']);
}
// Character set is added to dsn to ensure PDO uses the proper character
// set when escaping. This has security implications. See
// https://www.drupal.org/node/1201452 for further discussion.
$dsn .= ';charset=' . $charset;
$dsn .= ';dbname=' . $connection_options['database'];
// Allow PDO options to be overridden.
$connection_options += array(
'pdo' => array(),
);
$connection_options['pdo'] += array(
// So we don't have to mess around with cursors and unbuffered queries by default.
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE,
// Because MySQL's prepared statements skip the query cache, because it's dumb.
PDO::ATTR_EMULATE_PREPARES => TRUE,
);
if (defined('PDO::MYSQL_ATTR_MULTI_STATEMENTS')) {
// An added connection option in PHP 5.5.21+ to optionally limit SQL to a
// single statement like mysqli.
$connection_options['pdo'] += array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => FALSE);
}
parent::__construct($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
// Force MySQL to use the UTF-8 character set. Also set the collation, if a
// certain one has been set; otherwise, MySQL defaults to 'utf8_general_ci'
// for UTF-8.
if (!empty($connection_options['collation'])) {
$this->exec('SET NAMES ' . $charset . ' COLLATE ' . $connection_options['collation']);
}
else {
$this->exec('SET NAMES ' . $charset);
}
// Set MySQL init_commands if not already defined. Default Drupal's MySQL
// behavior to conform more closely to SQL standards. This allows Drupal
// to run almost seamlessly on many different kinds of database systems.
// These settings force MySQL to behave the same as postgresql, or sqlite
// in regards to syntax interpretation and invalid data handling. See
// http://drupal.org/node/344575 for further discussion. Also, as MySQL 5.5
// changed the meaning of TRADITIONAL we need to spell out the modes one by
// one.
$connection_options += array(
'init_commands' => array(),
);
$connection_options['init_commands'] += array(
'sql_mode' => "SET sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER'",
);
// Execute initial commands.
foreach ($connection_options['init_commands'] as $sql) {
$this->exec($sql);
}
}
public function __destruct() {
if ($this->needsCleanup) {
$this->nextIdDelete();
}
}
public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
return $this->query($query . ' LIMIT ' . (int) $from . ', ' . (int) $count, $args, $options);
}
public function queryTemporary($query, array $args = array(), array $options = array()) {
$tablename = $this->generateTemporaryTableName();
$this->query('CREATE TEMPORARY TABLE {' . $tablename . '} Engine=MEMORY ' . $query, $args, $options);
return $tablename;
}
public function driver() {
return 'mysql';
}
public function databaseType() {
return 'mysql';
}
public function mapConditionOperator($operator) {
// We don't want to override any of the defaults.
return NULL;
}
public function nextId($existing_id = 0) {
$new_id = $this->query('INSERT INTO {sequences} () VALUES ()', array(), array('return' => Database::RETURN_INSERT_ID));
// This should only happen after an import or similar event.
if ($existing_id >= $new_id) {
// If we INSERT a value manually into the sequences table, on the next
// INSERT, MySQL will generate a larger value. However, there is no way
// of knowing whether this value already exists in the table. MySQL
// provides an INSERT IGNORE which would work, but that can mask problems
// other than duplicate keys. Instead, we use INSERT ... ON DUPLICATE KEY
// UPDATE in such a way that the UPDATE does not do anything. This way,
// duplicate keys do not generate errors but everything else does.
$this->query('INSERT INTO {sequences} (value) VALUES (:value) ON DUPLICATE KEY UPDATE value = value', array(':value' => $existing_id));
$new_id = $this->query('INSERT INTO {sequences} () VALUES ()', array(), array('return' => Database::RETURN_INSERT_ID));
}
$this->needsCleanup = TRUE;
return $new_id;
}
public function nextIdDelete() {
// While we want to clean up the table to keep it up from occupying too
// much storage and memory, we must keep the highest value in the table
// because InnoDB uses an in-memory auto-increment counter as long as the
// server runs. When the server is stopped and restarted, InnoDB
// reinitializes the counter for each table for the first INSERT to the
// table based solely on values from the table so deleting all values would
// be a problem in this case. Also, TRUNCATE resets the auto increment
// counter.
try {
$max_id = $this->query('SELECT MAX(value) FROM {sequences}')->fetchField();
// We know we are using MySQL here, no need for the slower db_delete().
$this->query('DELETE FROM {sequences} WHERE value < :value', array(':value' => $max_id));
}
// During testing, this function is called from shutdown with the
// simpletest prefix stored in $this->connection, and those tables are gone
// by the time shutdown is called so we need to ignore the database
// errors. There is no problem with completely ignoring errors here: if
// these queries fail, the sequence will work just fine, just use a bit
// more database storage and memory.
catch (PDOException $e) {
}
}
/**
* Overridden to work around issues to MySQL not supporting transactional DDL.
*/
protected function popCommittableTransactions() {
// Commit all the committable layers.
foreach (array_reverse($this->transactionLayers) as $name => $active) {
// Stop once we found an active transaction.
if ($active) {
break;
}
// If there are no more layers left then we should commit.
unset($this->transactionLayers[$name]);
if (empty($this->transactionLayers)) {
if (!PDO::commit()) {
throw new DatabaseTransactionCommitFailedException();
}
}
else {
// Attempt to release this savepoint in the standard way.
try {
$this->query('RELEASE SAVEPOINT ' . $name);
}
catch (PDOException $e) {
// However, in MySQL (InnoDB), savepoints are automatically committed
// when tables are altered or created (DDL transactions are not
// supported). This can cause exceptions due to trying to release
// savepoints which no longer exist.
//
// To avoid exceptions when no actual error has occurred, we silently
// succeed for MySQL error code 1305 ("SAVEPOINT does not exist").
if ($e->errorInfo[1] == '1305') {
// If one SAVEPOINT was released automatically, then all were.
// Therefore, clean the transaction stack.
$this->transactionLayers = array();
// We also have to explain to PDO that the transaction stack has
// been cleaned-up.
PDO::commit();
}
else {
throw $e;
}
}
}
}
}
public function utf8mb4IsConfigurable() {
return TRUE;
}
public function utf8mb4IsActive() {
return isset($this->connectionOptions['charset']) && $this->connectionOptions['charset'] === 'utf8mb4';
}
public function utf8mb4IsSupported() {
// Ensure that the MySQL driver supports utf8mb4 encoding.
$version = $this->getAttribute(PDO::ATTR_CLIENT_VERSION);
if (strpos($version, 'mysqlnd') !== FALSE) {
// The mysqlnd driver supports utf8mb4 starting at version 5.0.9.
$version = preg_replace('/^\D+([\d.]+).*/', '$1', $version);
if (version_compare($version, '5.0.9', '<')) {
return FALSE;
}
}
else {
// The libmysqlclient driver supports utf8mb4 starting at version 5.5.3.
if (version_compare($version, '5.5.3', '<')) {
return FALSE;
}
}
// Ensure that the MySQL server supports large prefixes and utf8mb4.
try {
$this->query("CREATE TABLE {drupal_utf8mb4_test} (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB");
}
catch (Exception $e) {
return FALSE;
}
$this->query("DROP TABLE {drupal_utf8mb4_test}");
return TRUE;
}
}
/**
* @} End of "addtogroup database".
*/
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* @file
* Installation code for MySQL embedded database engine.
*/
/**
* Specifies installation tasks for MySQL and equivalent databases.
*/
class DatabaseTasks_mysql extends DatabaseTasks {
/**
* The PDO driver name for MySQL and equivalent databases.
*
* @var string
*/
protected $pdoDriver = 'mysql';
/**
* Returns a human-readable name string for MySQL and equivalent databases.
*/
public function name() {
return st('MySQL, MariaDB, or equivalent');
}
/**
* Returns the minimum version for MySQL.
*/
public function minimumVersion() {
return '5.0.15';
}
}
+94
View File
@@ -0,0 +1,94 @@
<?php
/**
* @addtogroup database
* @{
*/
/**
* @file
* Query code for MySQL embedded database engine.
*/
class InsertQuery_mysql extends InsertQuery {
public function execute() {
if (!$this->preExecute()) {
return NULL;
}
// If we're selecting from a SelectQuery, finish building the query and
// pass it back, as any remaining options are irrelevant.
if (empty($this->fromQuery)) {
$max_placeholder = 0;
$values = array();
foreach ($this->insertValues as $insert_values) {
foreach ($insert_values as $value) {
$values[':db_insert_placeholder_' . $max_placeholder++] = $value;
}
}
}
else {
$values = $this->fromQuery->getArguments();
}
$last_insert_id = $this->connection->query((string) $this, $values, $this->queryOptions);
// Re-initialize the values array so that we can re-use this query.
$this->insertValues = array();
return $last_insert_id;
}
public function __toString() {
// Create a sanitized comment string to prepend to the query.
$comments = $this->connection->makeComment($this->comments);
// Default fields are always placed first for consistency.
$insert_fields = array_merge($this->defaultFields, $this->insertFields);
// If we're selecting from a SelectQuery, finish building the query and
// pass it back, as any remaining options are irrelevant.
if (!empty($this->fromQuery)) {
$insert_fields_string = $insert_fields ? ' (' . implode(', ', $insert_fields) . ') ' : ' ';
return $comments . 'INSERT INTO {' . $this->table . '}' . $insert_fields_string . $this->fromQuery;
}
$query = $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES ';
$max_placeholder = 0;
$values = array();
if (count($this->insertValues)) {
foreach ($this->insertValues as $insert_values) {
$placeholders = array();
// Default fields aren't really placeholders, but this is the most convenient
// way to handle them.
$placeholders = array_pad($placeholders, count($this->defaultFields), 'default');
$new_placeholder = $max_placeholder + count($insert_values);
for ($i = $max_placeholder; $i < $new_placeholder; ++$i) {
$placeholders[] = ':db_insert_placeholder_' . $i;
}
$max_placeholder = $new_placeholder;
$values[] = '(' . implode(', ', $placeholders) . ')';
}
}
else {
// If there are no values, then this is a default-only query. We still need to handle that.
$placeholders = array_fill(0, count($this->defaultFields), 'default');
$values[] = '(' . implode(', ', $placeholders) . ')';
}
$query .= implode(', ', $values);
return $query;
}
}
class TruncateQuery_mysql extends TruncateQuery { }
/**
* @} End of "addtogroup database".
*/
+544
View File
@@ -0,0 +1,544 @@
<?php
/**
* @file
* Database schema code for MySQL database servers.
*/
/**
* @addtogroup schemaapi
* @{
*/
class DatabaseSchema_mysql extends DatabaseSchema {
/**
* Maximum length of a table comment in MySQL.
*/
const COMMENT_MAX_TABLE = 60;
/**
* Maximum length of a column comment in MySQL.
*/
const COMMENT_MAX_COLUMN = 255;
/**
* Get information about the table and database name from the prefix.
*
* @return
* A keyed array with information about the database, table name and prefix.
*/
protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) {
$info = array('prefix' => $this->connection->tablePrefix($table));
if ($add_prefix) {
$table = $info['prefix'] . $table;
}
if (($pos = strpos($table, '.')) !== FALSE) {
$info['database'] = substr($table, 0, $pos);
$info['table'] = substr($table, ++$pos);
}
else {
$db_info = $this->connection->getConnectionOptions();
$info['database'] = $db_info['database'];
$info['table'] = $table;
}
return $info;
}
/**
* Build a condition to match a table name against a standard information_schema.
*
* MySQL uses databases like schemas rather than catalogs so when we build
* a condition to query the information_schema.tables, we set the default
* database as the schema unless specified otherwise, and exclude table_catalog
* from the condition criteria.
*/
protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) {
$info = $this->connection->getConnectionOptions();
$table_info = $this->getPrefixInfo($table_name, $add_prefix);
$condition = new DatabaseCondition('AND');
$condition->condition('table_schema', $table_info['database']);
$condition->condition('table_name', $table_info['table'], $operator);
return $condition;
}
/**
* Generate SQL to create a new table from a Drupal schema definition.
*
* @param $name
* The name of the table to create.
* @param $table
* A Schema API table definition array.
* @return
* An array of SQL statements to create the table.
*/
protected function createTableSql($name, $table) {
$info = $this->connection->getConnectionOptions();
// Provide defaults if needed.
$table += array(
'mysql_engine' => 'InnoDB',
// Allow the default charset to be overridden in settings.php.
'mysql_character_set' => $this->connection->utf8mb4IsActive() ? 'utf8mb4' : 'utf8',
);
$sql = "CREATE TABLE {" . $name . "} (\n";
// Add the SQL statement for each field.
foreach ($table['fields'] as $field_name => $field) {
$sql .= $this->createFieldSql($field_name, $this->processField($field)) . ", \n";
}
// Process keys & indexes.
$keys = $this->createKeysSql($table);
if (count($keys)) {
$sql .= implode(", \n", $keys) . ", \n";
}
// Remove the last comma and space.
$sql = substr($sql, 0, -3) . "\n) ";
$sql .= 'ENGINE = ' . $table['mysql_engine'] . ' DEFAULT CHARACTER SET ' . $table['mysql_character_set'];
// By default, MySQL uses the default collation for new tables, which is
// 'utf8_general_ci' for utf8. If an alternate collation has been set, it
// needs to be explicitly specified.
// @see DatabaseConnection_mysql
if (!empty($info['collation'])) {
$sql .= ' COLLATE ' . $info['collation'];
}
// The row format needs to be either DYNAMIC or COMPRESSED in order to allow
// for the innodb_large_prefix setting to take effect, see
// https://dev.mysql.com/doc/refman/5.6/en/create-table.html
if ($this->connection->utf8mb4IsActive()) {
$sql .= ' ROW_FORMAT=DYNAMIC';
}
// Add table comment.
if (!empty($table['description'])) {
$sql .= ' COMMENT ' . $this->prepareComment($table['description'], self::COMMENT_MAX_TABLE);
}
return array($sql);
}
/**
* Create an SQL string for a field to be used in table creation or alteration.
*
* Before passing a field out of a schema definition into this function it has
* to be processed by _db_process_field().
*
* @param $name
* Name of the field.
* @param $spec
* The field specification, as per the schema data structure format.
*/
protected function createFieldSql($name, $spec) {
$sql = "`" . $name . "` " . $spec['mysql_type'];
if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT'))) {
if (isset($spec['length'])) {
$sql .= '(' . $spec['length'] . ')';
}
if (!empty($spec['binary'])) {
$sql .= ' BINARY';
}
}
elseif (isset($spec['precision']) && isset($spec['scale'])) {
$sql .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')';
}
if (!empty($spec['unsigned'])) {
$sql .= ' unsigned';
}
if (isset($spec['not null'])) {
if ($spec['not null']) {
$sql .= ' NOT NULL';
}
else {
$sql .= ' NULL';
}
}
if (!empty($spec['auto_increment'])) {
$sql .= ' auto_increment';
}
// $spec['default'] can be NULL, so we explicitly check for the key here.
if (array_key_exists('default', $spec)) {
if (is_string($spec['default'])) {
$spec['default'] = "'" . $spec['default'] . "'";
}
elseif (!isset($spec['default'])) {
$spec['default'] = 'NULL';
}
$sql .= ' DEFAULT ' . $spec['default'];
}
if (empty($spec['not null']) && !isset($spec['default'])) {
$sql .= ' DEFAULT NULL';
}
// Add column comment.
if (!empty($spec['description'])) {
$sql .= ' COMMENT ' . $this->prepareComment($spec['description'], self::COMMENT_MAX_COLUMN);
}
return $sql;
}
/**
* Set database-engine specific properties for a field.
*
* @param $field
* A field description array, as specified in the schema documentation.
*/
protected function processField($field) {
if (!isset($field['size'])) {
$field['size'] = 'normal';
}
// Set the correct database-engine specific datatype.
// In case one is already provided, force it to uppercase.
if (isset($field['mysql_type'])) {
$field['mysql_type'] = drupal_strtoupper($field['mysql_type']);
}
else {
$map = $this->getFieldTypeMap();
$field['mysql_type'] = $map[$field['type'] . ':' . $field['size']];
}
if (isset($field['type']) && $field['type'] == 'serial') {
$field['auto_increment'] = TRUE;
}
return $field;
}
public function getFieldTypeMap() {
// Put :normal last so it gets preserved by array_flip. This makes
// it much easier for modules (such as schema.module) to map
// database types back into schema types.
// $map does not use drupal_static as its value never changes.
static $map = array(
'varchar:normal' => 'VARCHAR',
'char:normal' => 'CHAR',
'text:tiny' => 'TINYTEXT',
'text:small' => 'TINYTEXT',
'text:medium' => 'MEDIUMTEXT',
'text:big' => 'LONGTEXT',
'text:normal' => 'TEXT',
'serial:tiny' => 'TINYINT',
'serial:small' => 'SMALLINT',
'serial:medium' => 'MEDIUMINT',
'serial:big' => 'BIGINT',
'serial:normal' => 'INT',
'int:tiny' => 'TINYINT',
'int:small' => 'SMALLINT',
'int:medium' => 'MEDIUMINT',
'int:big' => 'BIGINT',
'int:normal' => 'INT',
'float:tiny' => 'FLOAT',
'float:small' => 'FLOAT',
'float:medium' => 'FLOAT',
'float:big' => 'DOUBLE',
'float:normal' => 'FLOAT',
'numeric:normal' => 'DECIMAL',
'blob:big' => 'LONGBLOB',
'blob:normal' => 'BLOB',
);
return $map;
}
protected function createKeysSql($spec) {
$keys = array();
if (!empty($spec['primary key'])) {
$keys[] = 'PRIMARY KEY (' . $this->createKeysSqlHelper($spec['primary key']) . ')';
}
if (!empty($spec['unique keys'])) {
foreach ($spec['unique keys'] as $key => $fields) {
$keys[] = 'UNIQUE KEY `' . $key . '` (' . $this->createKeysSqlHelper($fields) . ')';
}
}
if (!empty($spec['indexes'])) {
foreach ($spec['indexes'] as $index => $fields) {
$keys[] = 'INDEX `' . $index . '` (' . $this->createKeysSqlHelper($fields) . ')';
}
}
return $keys;
}
protected function createKeySql($fields) {
$return = array();
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = '`' . $field[0] . '`(' . $field[1] . ')';
}
else {
$return[] = '`' . $field . '`';
}
}
return implode(', ', $return);
}
protected function createKeysSqlHelper($fields) {
$return = array();
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = '`' . $field[0] . '`(' . $field[1] . ')';
}
else {
$return[] = '`' . $field . '`';
}
}
return implode(', ', $return);
}
public function renameTable($table, $new_name) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name)));
}
if ($this->tableExists($new_name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", array('@table' => $table, '@table_new' => $new_name)));
}
$info = $this->getPrefixInfo($new_name);
return $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO `' . $info['table'] . '`');
}
public function dropTable($table) {
if (!$this->tableExists($table)) {
return FALSE;
}
$this->connection->query('DROP TABLE {' . $table . '}');
return TRUE;
}
public function addField($table, $field, $spec, $keys_new = array()) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", array('@field' => $field, '@table' => $table)));
}
if ($this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", array('@field' => $field, '@table' => $table)));
}
$fixnull = FALSE;
if (!empty($spec['not null']) && !isset($spec['default'])) {
$fixnull = TRUE;
$spec['not null'] = FALSE;
}
$query = 'ALTER TABLE {' . $table . '} ADD ';
$query .= $this->createFieldSql($field, $this->processField($spec));
if ($keys_sql = $this->createKeysSql($keys_new)) {
$query .= ', ADD ' . implode(', ADD ', $keys_sql);
}
$this->connection->query($query);
if (isset($spec['initial'])) {
$this->connection->update($table)
->fields(array($field => $spec['initial']))
->execute();
}
if ($fixnull) {
$spec['not null'] = TRUE;
$this->changeField($table, $field, $field, $spec);
}
}
public function dropField($table, $field) {
if (!$this->fieldExists($table, $field)) {
return FALSE;
}
$this->connection->query('ALTER TABLE {' . $table . '} DROP `' . $field . '`');
return TRUE;
}
public function fieldSetDefault($table, $field, $default) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
}
if (!isset($default)) {
$default = 'NULL';
}
else {
$default = is_string($default) ? "'$default'" : $default;
}
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` SET DEFAULT ' . $default);
}
public function fieldSetNoDefault($table, $field) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` DROP DEFAULT');
}
public function indexExists($table, $name) {
// Returns one row for each column in the index. Result is string or FALSE.
// Details at http://dev.mysql.com/doc/refman/5.0/en/show-index.html
$row = $this->connection->query('SHOW INDEX FROM {' . $table . "} WHERE key_name = '$name'")->fetchAssoc();
return isset($row['Key_name']);
}
public function addPrimaryKey($table, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", array('@table' => $table)));
}
if ($this->indexExists($table, 'PRIMARY')) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", array('@table' => $table)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')');
}
public function dropPrimaryKey($table) {
if (!$this->indexExists($table, 'PRIMARY')) {
return FALSE;
}
$this->connection->query('ALTER TABLE {' . $table . '} DROP PRIMARY KEY');
return TRUE;
}
public function addUniqueKey($table, $name, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
}
if ($this->indexExists($table, $name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", array('@table' => $table, '@name' => $name)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD UNIQUE KEY `' . $name . '` (' . $this->createKeySql($fields) . ')');
}
public function dropUniqueKey($table, $name) {
if (!$this->indexExists($table, $name)) {
return FALSE;
}
$this->connection->query('ALTER TABLE {' . $table . '} DROP KEY `' . $name . '`');
return TRUE;
}
public function addIndex($table, $name, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
}
if ($this->indexExists($table, $name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", array('@table' => $table, '@name' => $name)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD INDEX `' . $name . '` (' . $this->createKeySql($fields) . ')');
}
public function dropIndex($table, $name) {
if (!$this->indexExists($table, $name)) {
return FALSE;
}
$this->connection->query('ALTER TABLE {' . $table . '} DROP INDEX `' . $name . '`');
return TRUE;
}
public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field)));
}
if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new)));
}
$sql = 'ALTER TABLE {' . $table . '} CHANGE `' . $field . '` ' . $this->createFieldSql($field_new, $this->processField($spec));
if ($keys_sql = $this->createKeysSql($keys_new)) {
$sql .= ', ADD ' . implode(', ADD ', $keys_sql);
}
$this->connection->query($sql);
}
public function prepareComment($comment, $length = NULL) {
// Work around a bug in some versions of PDO, see http://bugs.php.net/bug.php?id=41125
$comment = str_replace("'", '', $comment);
// Truncate comment to maximum comment length.
if (isset($length)) {
// Add table prefixes before truncating.
$comment = truncate_utf8($this->connection->prefixTables($comment), $length, TRUE, TRUE);
}
return $this->connection->quote($comment);
}
/**
* Retrieve a table or column comment.
*/
public function getComment($table, $column = NULL) {
$condition = $this->buildTableNameCondition($table);
if (isset($column)) {
$condition->condition('column_name', $column);
$condition->compile($this->connection, $this);
// Don't use {} around information_schema.columns table.
return $this->connection->query("SELECT column_comment FROM information_schema.columns WHERE " . (string) $condition, $condition->arguments())->fetchField();
}
$condition->compile($this->connection, $this);
// Don't use {} around information_schema.tables table.
$comment = $this->connection->query("SELECT table_comment FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments())->fetchField();
// Work-around for MySQL 5.0 bug http://bugs.mysql.com/bug.php?id=11379
return preg_replace('/; InnoDB free:.*$/', '', $comment);
}
public function tableExists($table) {
// The information_schema table is very slow to query under MySQL 5.0.
// Instead, we try to select from the table in question. If it fails,
// the most likely reason is that it does not exist. That is dramatically
// faster than using information_schema.
// @link http://bugs.mysql.com/bug.php?id=19588
// @todo: This override should be removed once we require a version of MySQL
// that has that bug fixed.
try {
$this->connection->queryRange("SELECT 1 FROM {" . $table . "}", 0, 1);
return TRUE;
}
catch (Exception $e) {
return FALSE;
}
}
public function fieldExists($table, $column) {
// The information_schema table is very slow to query under MySQL 5.0.
// Instead, we try to select from the table and field in question. If it
// fails, the most likely reason is that it does not exist. That is
// dramatically faster than using information_schema.
// @link http://bugs.mysql.com/bug.php?id=19588
// @todo: This override should be removed once we require a version of MySQL
// that has that bug fixed.
try {
$this->connection->queryRange("SELECT $column FROM {" . $table . "}", 0, 1);
return TRUE;
}
catch (Exception $e) {
return FALSE;
}
}
}
/**
* @} End of "addtogroup schemaapi".
*/
+231
View File
@@ -0,0 +1,231 @@
<?php
/**
* @file
* Database interface code for PostgreSQL database servers.
*/
/**
* @addtogroup database
* @{
*/
/**
* The name by which to obtain a lock for retrieving the next insert id.
*/
define('POSTGRESQL_NEXTID_LOCK', 1000);
class DatabaseConnection_pgsql extends DatabaseConnection {
public function __construct(array $connection_options = array()) {
// This driver defaults to transaction support, except if explicitly passed FALSE.
$this->transactionSupport = !isset($connection_options['transactions']) || ($connection_options['transactions'] !== FALSE);
// Transactional DDL is always available in PostgreSQL,
// but we'll only enable it if standard transactions are.
$this->transactionalDDLSupport = $this->transactionSupport;
// Default to TCP connection on port 5432.
if (empty($connection_options['port'])) {
$connection_options['port'] = 5432;
}
// PostgreSQL in trust mode doesn't require a password to be supplied.
if (empty($connection_options['password'])) {
$connection_options['password'] = NULL;
}
// If the password contains a backslash it is treated as an escape character
// http://bugs.php.net/bug.php?id=53217
// so backslashes in the password need to be doubled up.
// The bug was reported against pdo_pgsql 1.0.2, backslashes in passwords
// will break on this doubling up when the bug is fixed, so check the version
//elseif (phpversion('pdo_pgsql') < 'version_this_was_fixed_in') {
else {
$connection_options['password'] = str_replace('\\', '\\\\', $connection_options['password']);
}
$this->connectionOptions = $connection_options;
$dsn = 'pgsql:host=' . $connection_options['host'] . ' dbname=' . $connection_options['database'] . ' port=' . $connection_options['port'];
// Allow PDO options to be overridden.
$connection_options += array(
'pdo' => array(),
);
$connection_options['pdo'] += array(
// Prepared statements are most effective for performance when queries
// are recycled (used several times). However, if they are not re-used,
// prepared statements become inefficient. Since most of Drupal's
// prepared queries are not re-used, it should be faster to emulate
// the preparation than to actually ready statements for re-use. If in
// doubt, reset to FALSE and measure performance.
PDO::ATTR_EMULATE_PREPARES => TRUE,
// Convert numeric values to strings when fetching.
PDO::ATTR_STRINGIFY_FETCHES => TRUE,
);
parent::__construct($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
// Force PostgreSQL to use the UTF-8 character set by default.
$this->exec("SET NAMES 'UTF8'");
// Execute PostgreSQL init_commands.
if (isset($connection_options['init_commands'])) {
$this->exec(implode('; ', $connection_options['init_commands']));
}
}
public function prepareQuery($query) {
// mapConditionOperator converts LIKE operations to ILIKE for consistency
// with MySQL. However, Postgres does not support ILIKE on bytea (blobs)
// fields.
// To make the ILIKE operator work, we type-cast bytea fields into text.
// @todo This workaround only affects bytea fields, but the involved field
// types involved in the query are unknown, so there is no way to
// conditionally execute this for affected queries only.
return parent::prepareQuery(preg_replace('/ ([^ ]+) +(I*LIKE|NOT +I*LIKE) /i', ' ${1}::text ${2} ', $query));
}
public function query($query, array $args = array(), $options = array()) {
$options += $this->defaultOptions();
// The PDO PostgreSQL driver has a bug which
// doesn't type cast booleans correctly when
// parameters are bound using associative
// arrays.
// See http://bugs.php.net/bug.php?id=48383
foreach ($args as &$value) {
if (is_bool($value)) {
$value = (int) $value;
}
}
try {
if ($query instanceof DatabaseStatementInterface) {
$stmt = $query;
$stmt->execute(NULL, $options);
}
else {
$this->expandArguments($query, $args);
$stmt = $this->prepareQuery($query);
$stmt->execute($args, $options);
}
switch ($options['return']) {
case Database::RETURN_STATEMENT:
return $stmt;
case Database::RETURN_AFFECTED:
return $stmt->rowCount();
case Database::RETURN_INSERT_ID:
return $this->lastInsertId($options['sequence_name']);
case Database::RETURN_NULL:
return;
default:
throw new PDOException('Invalid return directive: ' . $options['return']);
}
}
catch (PDOException $e) {
if ($options['throw_exception']) {
// Add additional debug information.
if ($query instanceof DatabaseStatementInterface) {
$e->query_string = $stmt->getQueryString();
}
else {
$e->query_string = $query;
}
$e->args = $args;
throw $e;
}
return NULL;
}
}
public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
return $this->query($query . ' LIMIT ' . (int) $count . ' OFFSET ' . (int) $from, $args, $options);
}
public function queryTemporary($query, array $args = array(), array $options = array()) {
$tablename = $this->generateTemporaryTableName();
$this->query('CREATE TEMPORARY TABLE {' . $tablename . '} AS ' . $query, $args, $options);
return $tablename;
}
public function driver() {
return 'pgsql';
}
public function databaseType() {
return 'pgsql';
}
public function mapConditionOperator($operator) {
static $specials;
// Function calls not allowed in static declarations, thus this method.
if (!isset($specials)) {
$specials = array(
// In PostgreSQL, 'LIKE' is case-sensitive. For case-insensitive LIKE
// statements, we need to use ILIKE instead.
'LIKE' => array('operator' => 'ILIKE'),
'NOT LIKE' => array('operator' => 'NOT ILIKE'),
);
}
return isset($specials[$operator]) ? $specials[$operator] : NULL;
}
/**
* Retrieve the next id in a sequence.
*
* PostgreSQL has built in sequences. We'll use these instead of inserting
* and updating a sequences table.
*/
public function nextId($existing = 0) {
// Retrieve the name of the sequence. This information cannot be cached
// because the prefix may change, for example, like it does in simpletests.
$sequence_name = $this->makeSequenceName('sequences', 'value');
// When PostgreSQL gets a value too small then it will lock the table,
// retry the INSERT and if it's still too small then alter the sequence.
$id = $this->query("SELECT nextval('" . $sequence_name . "')")->fetchField();
if ($id > $existing) {
return $id;
}
// PostgreSQL advisory locks are simply locks to be used by an
// application such as Drupal. This will prevent other Drupal processes
// from altering the sequence while we are.
$this->query("SELECT pg_advisory_lock(" . POSTGRESQL_NEXTID_LOCK . ")");
// While waiting to obtain the lock, the sequence may have been altered
// so lets try again to obtain an adequate value.
$id = $this->query("SELECT nextval('" . $sequence_name . "')")->fetchField();
if ($id > $existing) {
$this->query("SELECT pg_advisory_unlock(" . POSTGRESQL_NEXTID_LOCK . ")");
return $id;
}
// Reset the sequence to a higher value than the existing id.
$this->query("ALTER SEQUENCE " . $sequence_name . " RESTART WITH " . ($existing + 1));
// Retrieve the next id. We know this will be as high as we want it.
$id = $this->query("SELECT nextval('" . $sequence_name . "')")->fetchField();
$this->query("SELECT pg_advisory_unlock(" . POSTGRESQL_NEXTID_LOCK . ")");
return $id;
}
public function utf8mb4IsActive() {
return TRUE;
}
public function utf8mb4IsSupported() {
return TRUE;
}
}
/**
* @} End of "addtogroup database".
*/
+197
View File
@@ -0,0 +1,197 @@
<?php
/**
* @file
* Install functions for PostgreSQL embedded database engine.
*/
// PostgreSQL specific install functions
class DatabaseTasks_pgsql extends DatabaseTasks {
protected $pdoDriver = 'pgsql';
public function __construct() {
$this->tasks[] = array(
'function' => 'checkEncoding',
'arguments' => array(),
);
$this->tasks[] = array(
'function' => 'checkPHPVersion',
'arguments' => array(),
);
$this->tasks[] = array(
'function' => 'checkBinaryOutput',
'arguments' => array(),
);
$this->tasks[] = array(
'function' => 'initializeDatabase',
'arguments' => array(),
);
}
public function name() {
return st('PostgreSQL');
}
public function minimumVersion() {
return '8.3';
}
/**
* Check encoding is UTF8.
*/
protected function checkEncoding() {
try {
if (db_query('SHOW server_encoding')->fetchField() == 'UTF8') {
$this->pass(st('Database is encoded in UTF-8'));
}
else {
$replacements = array(
'%encoding' => 'UTF8',
'%driver' => $this->name(),
'!link' => '<a href="INSTALL.pgsql.txt">INSTALL.pgsql.txt</a>'
);
$text = 'The %driver database must use %encoding encoding to work with Drupal.';
$text .= 'Recreate the database with %encoding encoding. See !link for more details.';
$this->fail(st($text, $replacements));
}
}
catch (Exception $e) {
$this->fail(st('Drupal could not determine the encoding of the database was set to UTF-8'));
}
}
/**
* Check PHP version.
*
* There are two bugs in PDO_pgsql affecting Drupal:
*
* - in versions < 5.2.7, PDO_pgsql refuses to insert an empty string into
* a NOT NULL BLOB column. See: http://bugs.php.net/bug.php?id=46249
* - in versions < 5.2.11 and < 5.3.1 that prevents inserting integer values
* into numeric columns that exceed the PHP_INT_MAX value.
* See: http://bugs.php.net/bug.php?id=48924
*/
function checkPHPVersion() {
if (!version_compare(PHP_VERSION, '5.2.11', '>=') || (version_compare(PHP_VERSION, '5.3.0', '>=') && !version_compare(PHP_VERSION, '5.3.1', '>='))) {
$this->fail(st('The version of PHP you are using has known issues with PostgreSQL. You need to upgrade PHP to 5.2.11, 5.3.1 or greater.'));
};
}
/**
* Check Binary Output.
*
* Unserializing does not work on Postgresql 9 when bytea_output is 'hex'.
*/
function checkBinaryOutput() {
// PostgreSQL < 9 doesn't support bytea_output, so verify we are running
// at least PostgreSQL 9.
$database_connection = Database::getConnection();
if (version_compare($database_connection->version(), '9') >= 0) {
if (!$this->checkBinaryOutputSuccess()) {
// First try to alter the database. If it fails, raise an error telling
// the user to do it themselves.
$connection_options = $database_connection->getConnectionOptions();
// It is safe to include the database name directly here, because this
// code is only called when a connection to the database is already
// established, thus the database name is guaranteed to be a correct
// value.
$query = "ALTER DATABASE \"" . $connection_options['database'] . "\" SET bytea_output = 'escape';";
try {
db_query($query);
}
catch (Exception $e) {
// Ignore possible errors when the user doesn't have the necessary
// privileges to ALTER the database.
}
// Close the database connection so that the configuration parameter
// is applied to the current connection.
db_close();
// Recheck, if it fails, finally just rely on the end user to do the
// right thing.
if (!$this->checkBinaryOutputSuccess()) {
$replacements = array(
'%setting' => 'bytea_output',
'%current_value' => 'hex',
'%needed_value' => 'escape',
'!query' => "<code>" . $query . "</code>",
);
$this->fail(st("The %setting setting is currently set to '%current_value', but needs to be '%needed_value'. Change this by running the following query: !query", $replacements));
}
}
}
}
/**
* Verify that a binary data roundtrip returns the original string.
*/
protected function checkBinaryOutputSuccess() {
$bytea_output = db_query("SELECT 'encoding'::bytea AS output")->fetchField();
return ($bytea_output == 'encoding');
}
/**
* Make PostgreSQL Drupal friendly.
*/
function initializeDatabase() {
// We create some functions using global names instead of prefixing them
// like we do with table names. This is so that we don't double up if more
// than one instance of Drupal is running on a single database. We therefore
// avoid trying to create them again in that case.
try {
// Create functions.
db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric) RETURNS numeric AS
\'SELECT CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 ELSE $2 END;\'
LANGUAGE \'sql\''
);
db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric AS
\'SELECT greatest($1, greatest($2, $3));\'
LANGUAGE \'sql\''
);
// Don't use {} around pg_proc table.
if (!db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'rand'")->fetchField()) {
db_query('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS
\'SELECT random();\'
LANGUAGE \'sql\''
);
}
db_query('CREATE OR REPLACE FUNCTION "substring_index"(text, text, integer) RETURNS text AS
\'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\'
LANGUAGE \'sql\''
);
// Using || to concatenate in Drupal is not recommended because there are
// database drivers for Drupal that do not support the syntax, however
// they do support CONCAT(item1, item2) which we can replicate in
// PostgreSQL. PostgreSQL requires the function to be defined for each
// different argument variation the function can handle.
db_query('CREATE OR REPLACE FUNCTION "concat"(anynonarray, anynonarray) RETURNS text AS
\'SELECT CAST($1 AS text) || CAST($2 AS text);\'
LANGUAGE \'sql\'
');
db_query('CREATE OR REPLACE FUNCTION "concat"(text, anynonarray) RETURNS text AS
\'SELECT $1 || CAST($2 AS text);\'
LANGUAGE \'sql\'
');
db_query('CREATE OR REPLACE FUNCTION "concat"(anynonarray, text) RETURNS text AS
\'SELECT CAST($1 AS text) || $2;\'
LANGUAGE \'sql\'
');
db_query('CREATE OR REPLACE FUNCTION "concat"(text, text) RETURNS text AS
\'SELECT $1 || $2;\'
LANGUAGE \'sql\'
');
$this->pass(st('PostgreSQL has initialized itself.'));
}
catch (Exception $e) {
$this->fail(st('Drupal could not be correctly setup with the existing database. Revise any errors.'));
}
}
}
+210
View File
@@ -0,0 +1,210 @@
<?php
/**
* @ingroup database
* @{
*/
/**
* @file
* Query code for PostgreSQL embedded database engine.
*/
class InsertQuery_pgsql extends InsertQuery {
public function execute() {
if (!$this->preExecute()) {
return NULL;
}
$stmt = $this->connection->prepareQuery((string) $this);
// Fetch the list of blobs and sequences used on that table.
$table_information = $this->connection->schema()->queryTableInformation($this->table);
$max_placeholder = 0;
$blobs = array();
$blob_count = 0;
foreach ($this->insertValues as $insert_values) {
foreach ($this->insertFields as $idx => $field) {
if (isset($table_information->blob_fields[$field])) {
$blobs[$blob_count] = fopen('php://memory', 'a');
fwrite($blobs[$blob_count], $insert_values[$idx]);
rewind($blobs[$blob_count]);
$stmt->bindParam(':db_insert_placeholder_' . $max_placeholder++, $blobs[$blob_count], PDO::PARAM_LOB);
// Pre-increment is faster in PHP than increment.
++$blob_count;
}
else {
$stmt->bindParam(':db_insert_placeholder_' . $max_placeholder++, $insert_values[$idx]);
}
}
// Check if values for a serial field has been passed.
if (!empty($table_information->serial_fields)) {
foreach ($table_information->serial_fields as $index => $serial_field) {
$serial_key = array_search($serial_field, $this->insertFields);
if ($serial_key !== FALSE) {
$serial_value = $insert_values[$serial_key];
// Force $last_insert_id to the specified value. This is only done
// if $index is 0.
if ($index == 0) {
$last_insert_id = $serial_value;
}
// Set the sequence to the bigger value of either the passed
// value or the max value of the column. It can happen that another
// thread calls nextval() which could lead to a serial number being
// used twice. However, trying to insert a value into a serial
// column should only be done in very rare cases and is not thread
// safe by definition.
$this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", array(':serial_value' => (int)$serial_value));
}
}
}
}
if (!empty($this->fromQuery)) {
// bindParam stores only a reference to the variable that is followed when
// the statement is executed. We pass $arguments[$key] instead of $value
// because the second argument to bindParam is passed by reference and
// the foreach statement assigns the element to the existing reference.
$arguments = $this->fromQuery->getArguments();
foreach ($arguments as $key => $value) {
$stmt->bindParam($key, $arguments[$key]);
}
}
// PostgreSQL requires the table name to be specified explicitly
// when requesting the last insert ID, so we pass that in via
// the options array.
$options = $this->queryOptions;
if (!empty($table_information->sequences)) {
$options['sequence_name'] = $table_information->sequences[0];
}
// If there are no sequences then we can't get a last insert id.
elseif ($options['return'] == Database::RETURN_INSERT_ID) {
$options['return'] = Database::RETURN_NULL;
}
// Only use the returned last_insert_id if it is not already set.
if (!empty($last_insert_id)) {
$this->connection->query($stmt, array(), $options);
}
else {
$last_insert_id = $this->connection->query($stmt, array(), $options);
}
// Re-initialize the values array so that we can re-use this query.
$this->insertValues = array();
return $last_insert_id;
}
public function __toString() {
// Create a sanitized comment string to prepend to the query.
$comments = $this->connection->makeComment($this->comments);
// Default fields are always placed first for consistency.
$insert_fields = array_merge($this->defaultFields, $this->insertFields);
// If we're selecting from a SelectQuery, finish building the query and
// pass it back, as any remaining options are irrelevant.
if (!empty($this->fromQuery)) {
$insert_fields_string = $insert_fields ? ' (' . implode(', ', $insert_fields) . ') ' : ' ';
return $comments . 'INSERT INTO {' . $this->table . '}' . $insert_fields_string . $this->fromQuery;
}
$query = $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES ';
$max_placeholder = 0;
$values = array();
if (count($this->insertValues)) {
foreach ($this->insertValues as $insert_values) {
$placeholders = array();
// Default fields aren't really placeholders, but this is the most convenient
// way to handle them.
$placeholders = array_pad($placeholders, count($this->defaultFields), 'default');
$new_placeholder = $max_placeholder + count($insert_values);
for ($i = $max_placeholder; $i < $new_placeholder; ++$i) {
$placeholders[] = ':db_insert_placeholder_' . $i;
}
$max_placeholder = $new_placeholder;
$values[] = '(' . implode(', ', $placeholders) . ')';
}
}
else {
// If there are no values, then this is a default-only query. We still need to handle that.
$placeholders = array_fill(0, count($this->defaultFields), 'default');
$values[] = '(' . implode(', ', $placeholders) . ')';
}
$query .= implode(', ', $values);
return $query;
}
}
class UpdateQuery_pgsql extends UpdateQuery {
public function execute() {
$max_placeholder = 0;
$blobs = array();
$blob_count = 0;
// Because we filter $fields the same way here and in __toString(), the
// placeholders will all match up properly.
$stmt = $this->connection->prepareQuery((string) $this);
// Fetch the list of blobs and sequences used on that table.
$table_information = $this->connection->schema()->queryTableInformation($this->table);
// Expressions take priority over literal fields, so we process those first
// and remove any literal fields that conflict.
$fields = $this->fields;
$expression_fields = array();
foreach ($this->expressionFields as $field => $data) {
if (!empty($data['arguments'])) {
foreach ($data['arguments'] as $placeholder => $argument) {
// We assume that an expression will never happen on a BLOB field,
// which is a fairly safe assumption to make since in most cases
// it would be an invalid query anyway.
$stmt->bindParam($placeholder, $data['arguments'][$placeholder]);
}
}
unset($fields[$field]);
}
foreach ($fields as $field => $value) {
$placeholder = ':db_update_placeholder_' . ($max_placeholder++);
if (isset($table_information->blob_fields[$field])) {
$blobs[$blob_count] = fopen('php://memory', 'a');
fwrite($blobs[$blob_count], $value);
rewind($blobs[$blob_count]);
$stmt->bindParam($placeholder, $blobs[$blob_count], PDO::PARAM_LOB);
++$blob_count;
}
else {
$stmt->bindParam($placeholder, $fields[$field]);
}
}
if (count($this->condition)) {
$this->condition->compile($this->connection, $this);
$arguments = $this->condition->arguments();
foreach ($arguments as $placeholder => $value) {
$stmt->bindParam($placeholder, $arguments[$placeholder]);
}
}
$options = $this->queryOptions;
$options['already_prepared'] = TRUE;
$this->connection->query($stmt, $options);
return $stmt->rowCount();
}
}
+617
View File
@@ -0,0 +1,617 @@
<?php
/**
* @file
* Database schema code for PostgreSQL database servers.
*/
/**
* @ingroup schemaapi
* @{
*/
class DatabaseSchema_pgsql extends DatabaseSchema {
/**
* A cache of information about blob columns and sequences of tables.
*
* This is collected by DatabaseConnection_pgsql->queryTableInformation(),
* by introspecting the database.
*
* @see DatabaseConnection_pgsql->queryTableInformation()
* @var array
*/
protected $tableInformation = array();
/**
* Fetch the list of blobs and sequences used on a table.
*
* We introspect the database to collect the information required by insert
* and update queries.
*
* @param $table_name
* The non-prefixed name of the table.
* @return
* An object with two member variables:
* - 'blob_fields' that lists all the blob fields in the table.
* - 'sequences' that lists the sequences used in that table.
*/
public function queryTableInformation($table) {
// Generate a key to reference this table's information on.
$key = $this->connection->prefixTables('{' . $table . '}');
if (!strpos($key, '.')) {
$key = 'public.' . $key;
}
if (!isset($this->tableInformation[$key])) {
// Split the key into schema and table for querying.
list($schema, $table_name) = explode('.', $key);
$table_information = (object) array(
'blob_fields' => array(),
'sequences' => array(),
);
// Don't use {} around information_schema.columns table.
$result = $this->connection->query("SELECT column_name, data_type, column_default FROM information_schema.columns WHERE table_schema = :schema AND table_name = :table AND (data_type = 'bytea' OR (numeric_precision IS NOT NULL AND column_default LIKE :default))", array(
':schema' => $schema,
':table' => $table_name,
':default' => '%nextval%',
));
foreach ($result as $column) {
if ($column->data_type == 'bytea') {
$table_information->blob_fields[$column->column_name] = TRUE;
}
elseif (preg_match("/nextval\('([^']+)'/", $column->column_default, $matches)) {
// We must know of any sequences in the table structure to help us
// return the last insert id. If there is more than 1 sequences the
// first one (index 0 of the sequences array) will be used.
$table_information->sequences[] = $matches[1];
$table_information->serial_fields[] = $column->column_name;
}
}
$this->tableInformation[$key] = $table_information;
}
return $this->tableInformation[$key];
}
/**
* Fetch the list of CHECK constraints used on a field.
*
* We introspect the database to collect the information required by field
* alteration.
*
* @param $table
* The non-prefixed name of the table.
* @param $field
* The name of the field.
* @return
* An array of all the checks for the field.
*/
public function queryFieldInformation($table, $field) {
$prefixInfo = $this->getPrefixInfo($table, TRUE);
// Split the key into schema and table for querying.
$schema = $prefixInfo['schema'];
$table_name = $prefixInfo['table'];
$field_information = (object) array(
'checks' => array(),
);
$checks = $this->connection->query("SELECT conname FROM pg_class cl INNER JOIN pg_constraint co ON co.conrelid = cl.oid INNER JOIN pg_attribute attr ON attr.attrelid = cl.oid AND attr.attnum = ANY (co.conkey) INNER JOIN pg_namespace ns ON cl.relnamespace = ns.oid WHERE co.contype = 'c' AND ns.nspname = :schema AND cl.relname = :table AND attr.attname = :column", array(
':schema' => $schema,
':table' => $table_name,
':column' => $field,
));
$field_information = $checks->fetchCol();
return $field_information;
}
/**
* Generate SQL to create a new table from a Drupal schema definition.
*
* @param $name
* The name of the table to create.
* @param $table
* A Schema API table definition array.
* @return
* An array of SQL statements to create the table.
*/
protected function createTableSql($name, $table) {
$sql_fields = array();
foreach ($table['fields'] as $field_name => $field) {
$sql_fields[] = $this->createFieldSql($field_name, $this->processField($field));
}
$sql_keys = array();
if (isset($table['primary key']) && is_array($table['primary key'])) {
$sql_keys[] = 'PRIMARY KEY (' . implode(', ', $table['primary key']) . ')';
}
if (isset($table['unique keys']) && is_array($table['unique keys'])) {
foreach ($table['unique keys'] as $key_name => $key) {
$sql_keys[] = 'CONSTRAINT ' . $this->prefixNonTable($name, $key_name, 'key') . ' UNIQUE (' . implode(', ', $key) . ')';
}
}
$sql = "CREATE TABLE {" . $name . "} (\n\t";
$sql .= implode(",\n\t", $sql_fields);
if (count($sql_keys) > 0) {
$sql .= ",\n\t";
}
$sql .= implode(",\n\t", $sql_keys);
$sql .= "\n)";
$statements[] = $sql;
if (isset($table['indexes']) && is_array($table['indexes'])) {
foreach ($table['indexes'] as $key_name => $key) {
$statements[] = $this->_createIndexSql($name, $key_name, $key);
}
}
// Add table comment.
if (!empty($table['description'])) {
$statements[] = 'COMMENT ON TABLE {' . $name . '} IS ' . $this->prepareComment($table['description']);
}
// Add column comments.
foreach ($table['fields'] as $field_name => $field) {
if (!empty($field['description'])) {
$statements[] = 'COMMENT ON COLUMN {' . $name . '}.' . $field_name . ' IS ' . $this->prepareComment($field['description']);
}
}
return $statements;
}
/**
* Create an SQL string for a field to be used in table creation or
* alteration.
*
* Before passing a field out of a schema definition into this
* function it has to be processed by _db_process_field().
*
* @param $name
* Name of the field.
* @param $spec
* The field specification, as per the schema data structure format.
*/
protected function createFieldSql($name, $spec) {
$sql = $name . ' ' . $spec['pgsql_type'];
if (isset($spec['type']) && $spec['type'] == 'serial') {
unset($spec['not null']);
}
if (in_array($spec['pgsql_type'], array('varchar', 'character', 'text')) && isset($spec['length'])) {
$sql .= '(' . $spec['length'] . ')';
}
elseif (isset($spec['precision']) && isset($spec['scale'])) {
$sql .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')';
}
if (!empty($spec['unsigned'])) {
$sql .= " CHECK ($name >= 0)";
}
if (isset($spec['not null'])) {
if ($spec['not null']) {
$sql .= ' NOT NULL';
}
else {
$sql .= ' NULL';
}
}
if (isset($spec['default'])) {
$default = is_string($spec['default']) ? "'" . $spec['default'] . "'" : $spec['default'];
$sql .= " default $default";
}
return $sql;
}
/**
* Set database-engine specific properties for a field.
*
* @param $field
* A field description array, as specified in the schema documentation.
*/
protected function processField($field) {
if (!isset($field['size'])) {
$field['size'] = 'normal';
}
// Set the correct database-engine specific datatype.
// In case one is already provided, force it to lowercase.
if (isset($field['pgsql_type'])) {
$field['pgsql_type'] = drupal_strtolower($field['pgsql_type']);
}
else {
$map = $this->getFieldTypeMap();
$field['pgsql_type'] = $map[$field['type'] . ':' . $field['size']];
}
if (!empty($field['unsigned'])) {
// Unsigned datatypes are not supported in PostgreSQL 8.3. In MySQL,
// they are used to ensure a positive number is inserted and it also
// doubles the maximum integer size that can be stored in a field.
// The PostgreSQL schema in Drupal creates a check constraint
// to ensure that a value inserted is >= 0. To provide the extra
// integer capacity, here, we bump up the column field size.
if (!isset($map)) {
$map = $this->getFieldTypeMap();
}
switch ($field['pgsql_type']) {
case 'smallint':
$field['pgsql_type'] = $map['int:medium'];
break;
case 'int' :
$field['pgsql_type'] = $map['int:big'];
break;
}
}
if (isset($field['type']) && $field['type'] == 'serial') {
unset($field['not null']);
}
return $field;
}
/**
* This maps a generic data type in combination with its data size
* to the engine-specific data type.
*/
function getFieldTypeMap() {
// Put :normal last so it gets preserved by array_flip. This makes
// it much easier for modules (such as schema.module) to map
// database types back into schema types.
// $map does not use drupal_static as its value never changes.
static $map = array(
'varchar:normal' => 'varchar',
'char:normal' => 'character',
'text:tiny' => 'text',
'text:small' => 'text',
'text:medium' => 'text',
'text:big' => 'text',
'text:normal' => 'text',
'int:tiny' => 'smallint',
'int:small' => 'smallint',
'int:medium' => 'int',
'int:big' => 'bigint',
'int:normal' => 'int',
'float:tiny' => 'real',
'float:small' => 'real',
'float:medium' => 'real',
'float:big' => 'double precision',
'float:normal' => 'real',
'numeric:normal' => 'numeric',
'blob:big' => 'bytea',
'blob:normal' => 'bytea',
'serial:tiny' => 'serial',
'serial:small' => 'serial',
'serial:medium' => 'serial',
'serial:big' => 'bigserial',
'serial:normal' => 'serial',
);
return $map;
}
protected function _createKeySql($fields) {
$return = array();
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = 'substr(' . $field[0] . ', 1, ' . $field[1] . ')';
}
else {
$return[] = '"' . $field . '"';
}
}
return implode(', ', $return);
}
function renameTable($table, $new_name) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name)));
}
if ($this->tableExists($new_name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", array('@table' => $table, '@table_new' => $new_name)));
}
// Get the schema and tablename for the old table.
$old_full_name = $this->connection->prefixTables('{' . $table . '}');
list($old_schema, $old_table_name) = strpos($old_full_name, '.') ? explode('.', $old_full_name) : array('public', $old_full_name);
// Index names and constraint names are global in PostgreSQL, so we need to
// rename them when renaming the table.
$indexes = $this->connection->query('SELECT indexname FROM pg_indexes WHERE schemaname = :schema AND tablename = :table', array(':schema' => $old_schema, ':table' => $old_table_name));
foreach ($indexes as $index) {
if (preg_match('/^' . preg_quote($old_full_name) . '_(.*)$/', $index->indexname, $matches)) {
$index_name = $matches[1];
$this->connection->query('ALTER INDEX ' . $index->indexname . ' RENAME TO {' . $new_name . '}_' . $index_name);
}
}
// Now rename the table.
// Ensure the new table name does not include schema syntax.
$prefixInfo = $this->getPrefixInfo($new_name);
$this->connection->query('ALTER TABLE {' . $table . '} RENAME TO ' . $prefixInfo['table']);
}
public function dropTable($table) {
if (!$this->tableExists($table)) {
return FALSE;
}
$this->connection->query('DROP TABLE {' . $table . '}');
return TRUE;
}
public function addField($table, $field, $spec, $new_keys = array()) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", array('@field' => $field, '@table' => $table)));
}
if ($this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", array('@field' => $field, '@table' => $table)));
}
$fixnull = FALSE;
if (!empty($spec['not null']) && !isset($spec['default'])) {
$fixnull = TRUE;
$spec['not null'] = FALSE;
}
$query = 'ALTER TABLE {' . $table . '} ADD COLUMN ';
$query .= $this->createFieldSql($field, $this->processField($spec));
$this->connection->query($query);
if (isset($spec['initial'])) {
$this->connection->update($table)
->fields(array($field => $spec['initial']))
->execute();
}
if ($fixnull) {
$this->connection->query("ALTER TABLE {" . $table . "} ALTER $field SET NOT NULL");
}
if (isset($new_keys)) {
$this->_createKeys($table, $new_keys);
}
// Add column comment.
if (!empty($spec['description'])) {
$this->connection->query('COMMENT ON COLUMN {' . $table . '}.' . $field . ' IS ' . $this->prepareComment($spec['description']));
}
}
public function dropField($table, $field) {
if (!$this->fieldExists($table, $field)) {
return FALSE;
}
$this->connection->query('ALTER TABLE {' . $table . '} DROP COLUMN "' . $field . '"');
return TRUE;
}
public function fieldSetDefault($table, $field, $default) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
}
if (!isset($default)) {
$default = 'NULL';
}
else {
$default = is_string($default) ? "'$default'" : $default;
}
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN "' . $field . '" SET DEFAULT ' . $default);
}
public function fieldSetNoDefault($table, $field) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN "' . $field . '" DROP DEFAULT');
}
public function indexExists($table, $name) {
// Details http://www.postgresql.org/docs/8.3/interactive/view-pg-indexes.html
$index_name = '{' . $table . '}_' . $name . '_idx';
return (bool) $this->connection->query("SELECT 1 FROM pg_indexes WHERE indexname = '$index_name'")->fetchField();
}
/**
* Helper function: check if a constraint (PK, FK, UK) exists.
*
* @param $table
* The name of the table.
* @param $name
* The name of the constraint (typically 'pkey' or '[constraint]_key').
*/
protected function constraintExists($table, $name) {
$constraint_name = '{' . $table . '}_' . $name;
return (bool) $this->connection->query("SELECT 1 FROM pg_constraint WHERE conname = '$constraint_name'")->fetchField();
}
public function addPrimaryKey($table, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", array('@table' => $table)));
}
if ($this->constraintExists($table, 'pkey')) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", array('@table' => $table)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . implode(',', $fields) . ')');
}
public function dropPrimaryKey($table) {
if (!$this->constraintExists($table, 'pkey')) {
return FALSE;
}
$this->connection->query('ALTER TABLE {' . $table . '} DROP CONSTRAINT ' . $this->prefixNonTable($table, 'pkey'));
return TRUE;
}
function addUniqueKey($table, $name, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
}
if ($this->constraintExists($table, $name . '_key')) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", array('@table' => $table, '@name' => $name)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT "' . $this->prefixNonTable($table, $name, 'key') . '" UNIQUE (' . implode(',', $fields) . ')');
}
public function dropUniqueKey($table, $name) {
if (!$this->constraintExists($table, $name . '_key')) {
return FALSE;
}
$this->connection->query('ALTER TABLE {' . $table . '} DROP CONSTRAINT "' . $this->prefixNonTable($table, $name, 'key') . '"');
return TRUE;
}
public function addIndex($table, $name, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
}
if ($this->indexExists($table, $name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", array('@table' => $table, '@name' => $name)));
}
$this->connection->query($this->_createIndexSql($table, $name, $fields));
}
public function dropIndex($table, $name) {
if (!$this->indexExists($table, $name)) {
return FALSE;
}
$this->connection->query('DROP INDEX ' . $this->prefixNonTable($table, $name, 'idx'));
return TRUE;
}
public function changeField($table, $field, $field_new, $spec, $new_keys = array()) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field)));
}
if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new)));
}
$spec = $this->processField($spec);
// We need to typecast the new column to best be able to transfer the data
// Schema_pgsql::getFieldTypeMap() will return possibilities that are not
// 'cast-able' such as 'serial' - so they need to be casted int instead.
if (in_array($spec['pgsql_type'], array('serial', 'bigserial', 'numeric'))) {
$typecast = 'int';
}
else {
$typecast = $spec['pgsql_type'];
}
if (in_array($spec['pgsql_type'], array('varchar', 'character', 'text')) && isset($spec['length'])) {
$typecast .= '(' . $spec['length'] . ')';
}
elseif (isset($spec['precision']) && isset($spec['scale'])) {
$typecast .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')';
}
// Remove old check constraints.
$field_info = $this->queryFieldInformation($table, $field);
foreach ($field_info as $check) {
$this->connection->query('ALTER TABLE {' . $table . '} DROP CONSTRAINT "' . $check . '"');
}
// Remove old default.
$this->fieldSetNoDefault($table, $field);
$this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" TYPE ' . $typecast . ' USING "' . $field . '"::' . $typecast);
if (isset($spec['not null'])) {
if ($spec['not null']) {
$nullaction = 'SET NOT NULL';
}
else {
$nullaction = 'DROP NOT NULL';
}
$this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" ' . $nullaction);
}
if (in_array($spec['pgsql_type'], array('serial', 'bigserial'))) {
// Type "serial" is known to PostgreSQL, but *only* during table creation,
// not when altering. Because of that, the sequence needs to be created
// and initialized by hand.
$seq = "{" . $table . "}_" . $field_new . "_seq";
$this->connection->query("CREATE SEQUENCE " . $seq);
// Set sequence to maximal field value to not conflict with existing
// entries.
$this->connection->query("SELECT setval('" . $seq . "', MAX(\"" . $field . '")) FROM {' . $table . "}");
$this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" SET DEFAULT nextval(\'' . $seq . '\')');
}
// Rename the column if necessary.
if ($field != $field_new) {
$this->connection->query('ALTER TABLE {' . $table . '} RENAME "' . $field . '" TO "' . $field_new . '"');
}
// Add unsigned check if necessary.
if (!empty($spec['unsigned'])) {
$this->connection->query('ALTER TABLE {' . $table . '} ADD CHECK ("' . $field_new . '" >= 0)');
}
// Add default if necessary.
if (isset($spec['default'])) {
$this->fieldSetDefault($table, $field_new, $spec['default']);
}
// Change description if necessary.
if (!empty($spec['description'])) {
$this->connection->query('COMMENT ON COLUMN {' . $table . '}."' . $field_new . '" IS ' . $this->prepareComment($spec['description']));
}
if (isset($new_keys)) {
$this->_createKeys($table, $new_keys);
}
}
protected function _createIndexSql($table, $name, $fields) {
$query = 'CREATE INDEX "' . $this->prefixNonTable($table, $name, 'idx') . '" ON {' . $table . '} (';
$query .= $this->_createKeySql($fields) . ')';
return $query;
}
protected function _createKeys($table, $new_keys) {
if (isset($new_keys['primary key'])) {
$this->addPrimaryKey($table, $new_keys['primary key']);
}
if (isset($new_keys['unique keys'])) {
foreach ($new_keys['unique keys'] as $name => $fields) {
$this->addUniqueKey($table, $name, $fields);
}
}
if (isset($new_keys['indexes'])) {
foreach ($new_keys['indexes'] as $name => $fields) {
$this->addIndex($table, $name, $fields);
}
}
}
/**
* Retrieve a table or column comment.
*/
public function getComment($table, $column = NULL) {
$info = $this->getPrefixInfo($table);
// Don't use {} around pg_class, pg_attribute tables.
if (isset($column)) {
return $this->connection->query('SELECT col_description(oid, attnum) FROM pg_class, pg_attribute WHERE attrelid = oid AND relname = ? AND attname = ?', array($info['table'], $column))->fetchField();
}
else {
return $this->connection->query('SELECT obj_description(oid, ?) FROM pg_class WHERE relname = ?', array('pg_class', $info['table']))->fetchField();
}
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
/**
* @file
* Select builder for PostgreSQL database engine.
*/
/**
* @addtogroup database
* @{
*/
class SelectQuery_pgsql extends SelectQuery {
public function orderRandom() {
$alias = $this->addExpression('RANDOM()', 'random_field');
$this->orderBy($alias);
return $this;
}
/**
* Overrides SelectQuery::orderBy().
*
* PostgreSQL adheres strictly to the SQL-92 standard and requires that when
* using DISTINCT or GROUP BY conditions, fields and expressions that are
* ordered on also need to be selected. This is a best effort implementation
* to handle the cases that can be automated by adding the field if it is not
* yet selected.
*
* @code
* $query = db_select('node', 'n');
* $query->join('node_revision', 'nr', 'n.vid = nr.vid');
* $query
* ->distinct()
* ->fields('n')
* ->orderBy('timestamp');
* @endcode
*
* In this query, it is not possible (without relying on the schema) to know
* whether timestamp belongs to node_revisions and needs to be added or
* belongs to node and is already selected. Queries like this will need to be
* corrected in the original query by adding an explicit call to
* SelectQuery::addField() or SelectQuery::fields().
*
* Since this has a small performance impact, both by the additional
* processing in this function and in the database that needs to return the
* additional fields, this is done as an override instead of implementing it
* directly in SelectQuery::orderBy().
*/
public function orderBy($field, $direction = 'ASC') {
// Call parent function to order on this.
$return = parent::orderBy($field, $direction);
// If there is a table alias specified, split it up.
if (strpos($field, '.') !== FALSE) {
list($table, $table_field) = explode('.', $field);
}
// Figure out if the field has already been added.
foreach ($this->fields as $existing_field) {
if (!empty($table)) {
// If table alias is given, check if field and table exists.
if ($existing_field['table'] == $table && $existing_field['field'] == $table_field) {
return $return;
}
}
else {
// If there is no table, simply check if the field exists as a field or
// an aliased field.
if ($existing_field['alias'] == $field) {
return $return;
}
}
}
// Also check expression aliases.
foreach ($this->expressions as $expression) {
if ($expression['alias'] == $field) {
return $return;
}
}
// If a table loads all fields, it can not be added again. It would
// result in an ambiguous alias error because that field would be loaded
// twice: Once through table_alias.* and once directly. If the field
// actually belongs to a different table, it must be added manually.
foreach ($this->tables as $table) {
if (!empty($table['all_fields'])) {
return $return;
}
}
// If $field contains an characters which are not allowed in a field name
// it is considered an expression, these can't be handled automatically
// either.
if ($this->connection->escapeField($field) != $field) {
return $return;
}
// This is a case that can be handled automatically, add the field.
$this->addField(NULL, $field);
return $return;
}
}
/**
* @} End of "addtogroup database".
*/
+507
View File
@@ -0,0 +1,507 @@
<?php
/**
* @file
* Database interface code for engines that need complete control over their
* result sets. For example, SQLite will prefix some column names by the name
* of the table. We post-process the data, by renaming the column names
* using the same convention as MySQL and PostgreSQL.
*/
/**
* @addtogroup database
* @{
*/
/**
* An implementation of DatabaseStatementInterface that prefetches all data.
*
* This class behaves very similar to a PDOStatement but as it always fetches
* every row it is possible to manipulate those results.
*/
class DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface {
/**
* The query string.
*
* @var string
*/
protected $queryString;
/**
* Driver-specific options. Can be used by child classes.
*
* @var Array
*/
protected $driverOptions;
/**
* Reference to the database connection object for this statement.
*
* The name $dbh is inherited from PDOStatement.
*
* @var DatabaseConnection
*/
public $dbh;
/**
* Main data store.
*
* @var Array
*/
protected $data = array();
/**
* The current row, retrieved in PDO::FETCH_ASSOC format.
*
* @var Array
*/
protected $currentRow = NULL;
/**
* The key of the current row.
*
* @var int
*/
protected $currentKey = NULL;
/**
* The list of column names in this result set.
*
* @var Array
*/
protected $columnNames = NULL;
/**
* The number of rows affected by the last query.
*
* @var int
*/
protected $rowCount = NULL;
/**
* The number of rows in this result set.
*
* @var int
*/
protected $resultRowCount = 0;
/**
* Holds the current fetch style (which will be used by the next fetch).
* @see PDOStatement::fetch()
*
* @var int
*/
protected $fetchStyle = PDO::FETCH_OBJ;
/**
* Holds supplementary current fetch options (which will be used by the next fetch).
*
* @var Array
*/
protected $fetchOptions = array(
'class' => 'stdClass',
'constructor_args' => array(),
'object' => NULL,
'column' => 0,
);
/**
* Holds the default fetch style.
*
* @var int
*/
protected $defaultFetchStyle = PDO::FETCH_OBJ;
/**
* Holds supplementary default fetch options.
*
* @var Array
*/
protected $defaultFetchOptions = array(
'class' => 'stdClass',
'constructor_args' => array(),
'object' => NULL,
'column' => 0,
);
public function __construct(DatabaseConnection $connection, $query, array $driver_options = array()) {
$this->dbh = $connection;
$this->queryString = $query;
$this->driverOptions = $driver_options;
}
/**
* Executes a prepared statement.
*
* @param $args
* An array of values with as many elements as there are bound parameters in the SQL statement being executed.
* @param $options
* An array of options for this query.
* @return
* TRUE on success, or FALSE on failure.
*/
public function execute($args = array(), $options = array()) {
if (isset($options['fetch'])) {
if (is_string($options['fetch'])) {
// Default to an object. Note: db fields will be added to the object
// before the constructor is run. If you need to assign fields after
// the constructor is run, see http://drupal.org/node/315092.
$this->setFetchMode(PDO::FETCH_CLASS, $options['fetch']);
}
else {
$this->setFetchMode($options['fetch']);
}
}
$logger = $this->dbh->getLogger();
if (!empty($logger)) {
$query_start = microtime(TRUE);
}
// Prepare the query.
$statement = $this->getStatement($this->queryString, $args);
if (!$statement) {
$this->throwPDOException();
}
$return = $statement->execute($args);
if (!$return) {
$this->throwPDOException();
}
// Fetch all the data from the reply, in order to release any lock
// as soon as possible.
$this->rowCount = $statement->rowCount();
$this->data = $statement->fetchAll(PDO::FETCH_ASSOC);
// Destroy the statement as soon as possible. See
// DatabaseConnection_sqlite::PDOPrepare() for explanation.
unset($statement);
$this->resultRowCount = count($this->data);
if ($this->resultRowCount) {
$this->columnNames = array_keys($this->data[0]);
}
else {
$this->columnNames = array();
}
if (!empty($logger)) {
$query_end = microtime(TRUE);
$logger->log($this, $args, $query_end - $query_start);
}
// Initialize the first row in $this->currentRow.
$this->next();
return $return;
}
/**
* Throw a PDO Exception based on the last PDO error.
*/
protected function throwPDOException() {
$error_info = $this->dbh->errorInfo();
// We rebuild a message formatted in the same way as PDO.
$exception = new PDOException("SQLSTATE[" . $error_info[0] . "]: General error " . $error_info[1] . ": " . $error_info[2]);
$exception->errorInfo = $error_info;
throw $exception;
}
/**
* Grab a PDOStatement object from a given query and its arguments.
*
* Some drivers (including SQLite) will need to perform some preparation
* themselves to get the statement right.
*
* @param $query
* The query.
* @param array $args
* An array of arguments.
* @return PDOStatement
* A PDOStatement object.
*/
protected function getStatement($query, &$args = array()) {
return $this->dbh->prepare($query);
}
/**
* Return the object's SQL query string.
*/
public function getQueryString() {
return $this->queryString;
}
/**
* @see PDOStatement::setFetchMode()
*/
public function setFetchMode($fetchStyle, $a2 = NULL, $a3 = NULL) {
$this->defaultFetchStyle = $fetchStyle;
switch ($fetchStyle) {
case PDO::FETCH_CLASS:
$this->defaultFetchOptions['class'] = $a2;
if ($a3) {
$this->defaultFetchOptions['constructor_args'] = $a3;
}
break;
case PDO::FETCH_COLUMN:
$this->defaultFetchOptions['column'] = $a2;
break;
case PDO::FETCH_INTO:
$this->defaultFetchOptions['object'] = $a2;
break;
}
// Set the values for the next fetch.
$this->fetchStyle = $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
}
/**
* Return the current row formatted according to the current fetch style.
*
* This is the core method of this class. It grabs the value at the current
* array position in $this->data and format it according to $this->fetchStyle
* and $this->fetchMode.
*
* @return
* The current row formatted as requested.
*/
public function current() {
if (isset($this->currentRow)) {
switch ($this->fetchStyle) {
case PDO::FETCH_ASSOC:
return $this->currentRow;
case PDO::FETCH_BOTH:
// PDO::FETCH_BOTH returns an array indexed by both the column name
// and the column number.
return $this->currentRow + array_values($this->currentRow);
case PDO::FETCH_NUM:
return array_values($this->currentRow);
case PDO::FETCH_LAZY:
// We do not do lazy as everything is fetched already. Fallback to
// PDO::FETCH_OBJ.
case PDO::FETCH_OBJ:
return (object) $this->currentRow;
case PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE:
$class_name = array_unshift($this->currentRow);
// Deliberate no break.
case PDO::FETCH_CLASS:
if (!isset($class_name)) {
$class_name = $this->fetchOptions['class'];
}
if (count($this->fetchOptions['constructor_args'])) {
$reflector = new ReflectionClass($class_name);
$result = $reflector->newInstanceArgs($this->fetchOptions['constructor_args']);
}
else {
$result = new $class_name();
}
foreach ($this->currentRow as $k => $v) {
$result->$k = $v;
}
return $result;
case PDO::FETCH_INTO:
foreach ($this->currentRow as $k => $v) {
$this->fetchOptions['object']->$k = $v;
}
return $this->fetchOptions['object'];
case PDO::FETCH_COLUMN:
if (isset($this->columnNames[$this->fetchOptions['column']])) {
return $this->currentRow[$k][$this->columnNames[$this->fetchOptions['column']]];
}
else {
return;
}
}
}
}
/* Implementations of Iterator. */
public function key() {
return $this->currentKey;
}
public function rewind() {
// Nothing to do: our DatabaseStatement can't be rewound.
}
public function next() {
if (!empty($this->data)) {
$this->currentRow = reset($this->data);
$this->currentKey = key($this->data);
unset($this->data[$this->currentKey]);
}
else {
$this->currentRow = NULL;
}
}
public function valid() {
return isset($this->currentRow);
}
/* Implementations of DatabaseStatementInterface. */
public function rowCount() {
return $this->rowCount;
}
public function fetch($fetch_style = NULL, $cursor_orientation = PDO::FETCH_ORI_NEXT, $cursor_offset = NULL) {
if (isset($this->currentRow)) {
// Set the fetch parameter.
$this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
// Grab the row in the format specified above.
$return = $this->current();
// Advance the cursor.
$this->next();
// Reset the fetch parameters to the value stored using setFetchMode().
$this->fetchStyle = $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
return $return;
}
else {
return FALSE;
}
}
public function fetchColumn($index = 0) {
if (isset($this->currentRow) && isset($this->columnNames[$index])) {
// We grab the value directly from $this->data, and format it.
$return = $this->currentRow[$this->columnNames[$index]];
$this->next();
return $return;
}
else {
return FALSE;
}
}
public function fetchField($index = 0) {
return $this->fetchColumn($index);
}
public function fetchObject($class_name = NULL, $constructor_args = array()) {
if (isset($this->currentRow)) {
if (!isset($class_name)) {
// Directly cast to an object to avoid a function call.
$result = (object) $this->currentRow;
}
else {
$this->fetchStyle = PDO::FETCH_CLASS;
$this->fetchOptions = array('constructor_args' => $constructor_args);
// Grab the row in the format specified above.
$result = $this->current();
// Reset the fetch parameters to the value stored using setFetchMode().
$this->fetchStyle = $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
}
$this->next();
return $result;
}
else {
return FALSE;
}
}
public function fetchAssoc() {
if (isset($this->currentRow)) {
$result = $this->currentRow;
$this->next();
return $result;
}
else {
return FALSE;
}
}
public function fetchAll($fetch_style = NULL, $fetch_column = NULL, $constructor_args = NULL) {
$this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
if (isset($fetch_column)) {
$this->fetchOptions['column'] = $fetch_column;
}
if (isset($constructor_args)) {
$this->fetchOptions['constructor_args'] = $constructor_args;
}
$result = array();
// Traverse the array as PHP would have done.
while (isset($this->currentRow)) {
// Grab the row in the format specified above.
$result[] = $this->current();
$this->next();
}
// Reset the fetch parameters to the value stored using setFetchMode().
$this->fetchStyle = $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
return $result;
}
public function fetchCol($index = 0) {
if (isset($this->columnNames[$index])) {
$column = $this->columnNames[$index];
$result = array();
// Traverse the array as PHP would have done.
while (isset($this->currentRow)) {
$result[] = $this->currentRow[$this->columnNames[$index]];
$this->next();
}
return $result;
}
else {
return array();
}
}
public function fetchAllKeyed($key_index = 0, $value_index = 1) {
if (!isset($this->columnNames[$key_index]) || !isset($this->columnNames[$value_index]))
return array();
$key = $this->columnNames[$key_index];
$value = $this->columnNames[$value_index];
$result = array();
// Traverse the array as PHP would have done.
while (isset($this->currentRow)) {
$result[$this->currentRow[$key]] = $this->currentRow[$value];
$this->next();
}
return $result;
}
public function fetchAllAssoc($key, $fetch_style = NULL) {
$this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
$result = array();
// Traverse the array as PHP would have done.
while (isset($this->currentRow)) {
// Grab the row in its raw PDO::FETCH_ASSOC format.
$row = $this->currentRow;
// Grab the row in the format specified above.
$result_row = $this->current();
$result[$this->currentRow[$key]] = $result_row;
$this->next();
}
// Reset the fetch parameters to the value stored using setFetchMode().
$this->fetchStyle = $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
return $result;
}
}
/**
* @} End of "addtogroup database".
*/
File diff suppressed because it is too large Load Diff
+733
View File
@@ -0,0 +1,733 @@
<?php
/**
* @file
* Generic Database schema code.
*/
require_once dirname(__FILE__) . '/query.inc';
/**
* @defgroup schemaapi Schema API
* @{
* API to handle database schemas.
*
* A Drupal schema definition is an array structure representing one or
* more tables and their related keys and indexes. A schema is defined by
* hook_schema(), which usually lives in a modulename.install file.
*
* By implementing hook_schema() and specifying the tables your module
* declares, you can easily create and drop these tables on all
* supported database engines. You don't have to deal with the
* different SQL dialects for table creation and alteration of the
* supported database engines.
*
* hook_schema() should return an array with a key for each table that
* the module defines.
*
* The following keys are defined:
* - 'description': A string in non-markup plain text describing this table
* and its purpose. References to other tables should be enclosed in
* curly-brackets. For example, the node_revisions table
* description field might contain "Stores per-revision title and
* body data for each {node}."
* - 'fields': An associative array ('fieldname' => specification)
* that describes the table's database columns. The specification
* is also an array. The following specification parameters are defined:
* - 'description': A string in non-markup plain text describing this field
* and its purpose. References to other tables should be enclosed in
* curly-brackets. For example, the node table vid field
* description might contain "Always holds the largest (most
* recent) {node_revision}.vid value for this nid."
* - 'type': The generic datatype: 'char', 'varchar', 'text', 'blob', 'int',
* 'float', 'numeric', or 'serial'. Most types just map to the according
* database engine specific datatypes. Use 'serial' for auto incrementing
* fields. This will expand to 'INT auto_increment' on MySQL.
* - 'mysql_type', 'pgsql_type', 'sqlite_type', etc.: If you need to
* use a record type not included in the officially supported list
* of types above, you can specify a type for each database
* backend. In this case, you can leave out the type parameter,
* but be advised that your schema will fail to load on backends that
* do not have a type specified. A possible solution can be to
* use the "text" type as a fallback.
* - 'serialize': A boolean indicating whether the field will be stored as
* a serialized string.
* - 'size': The data size: 'tiny', 'small', 'medium', 'normal',
* 'big'. This is a hint about the largest value the field will
* store and determines which of the database engine specific
* datatypes will be used (e.g. on MySQL, TINYINT vs. INT vs. BIGINT).
* 'normal', the default, selects the base type (e.g. on MySQL,
* INT, VARCHAR, BLOB, etc.).
* Not all sizes are available for all data types. See
* DatabaseSchema::getFieldTypeMap() for possible combinations.
* - 'not null': If true, no NULL values will be allowed in this
* database column. Defaults to false.
* - 'default': The field's default value. The PHP type of the
* value matters: '', '0', and 0 are all different. If you
* specify '0' as the default value for a type 'int' field it
* will not work because '0' is a string containing the
* character "zero", not an integer.
* - 'length': The maximal length of a type 'char', 'varchar' or 'text'
* field. Ignored for other field types.
* - 'unsigned': A boolean indicating whether a type 'int', 'float'
* and 'numeric' only is signed or unsigned. Defaults to
* FALSE. Ignored for other field types.
* - 'precision', 'scale': For type 'numeric' fields, indicates
* the precision (total number of significant digits) and scale
* (decimal digits right of the decimal point). Both values are
* mandatory. Ignored for other field types.
* - 'binary': A boolean indicating that MySQL should force 'char',
* 'varchar' or 'text' fields to use case-sensitive binary collation.
* This has no effect on other database types for which case sensitivity
* is already the default behavior.
* All parameters apart from 'type' are optional except that type
* 'numeric' columns must specify 'precision' and 'scale', and type
* 'varchar' must specify the 'length' parameter.
* - 'primary key': An array of one or more key column specifiers (see below)
* that form the primary key.
* - 'unique keys': An associative array of unique keys ('keyname' =>
* specification). Each specification is an array of one or more
* key column specifiers (see below) that form a unique key on the table.
* - 'foreign keys': An associative array of relations ('my_relation' =>
* specification). Each specification is an array containing the name of
* the referenced table ('table'), and an array of column mappings
* ('columns'). Column mappings are defined by key pairs ('source_column' =>
* 'referenced_column'). This key is for documentation purposes only; foreign
* keys are not created in the database, nor are they enforced by Drupal.
* - 'indexes': An associative array of indexes ('indexname' =>
* specification). Each specification is an array of one or more
* key column specifiers (see below) that form an index on the
* table.
*
* A key column specifier is either a string naming a column or an
* array of two elements, column name and length, specifying a prefix
* of the named column.
*
* As an example, here is a SUBSET of the schema definition for
* Drupal's 'node' table. It show four fields (nid, vid, type, and
* title), the primary key on field 'nid', a unique key named 'vid' on
* field 'vid', and two indexes, one named 'nid' on field 'nid' and
* one named 'node_title_type' on the field 'title' and the first four
* bytes of the field 'type':
*
* @code
* $schema['node'] = array(
* 'description' => 'The base table for nodes.',
* 'fields' => array(
* 'nid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
* 'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,'default' => 0),
* 'type' => array('type' => 'varchar','length' => 32,'not null' => TRUE, 'default' => ''),
* 'language' => array('type' => 'varchar','length' => 12,'not null' => TRUE,'default' => ''),
* 'title' => array('type' => 'varchar','length' => 255,'not null' => TRUE, 'default' => ''),
* 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'status' => array('type' => 'int', 'not null' => TRUE, 'default' => 1),
* 'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'changed' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'comment' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'promote' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'moderate' => array('type' => 'int', 'not null' => TRUE,'default' => 0),
* 'sticky' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'tnid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
* 'translate' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* ),
* 'indexes' => array(
* 'node_changed' => array('changed'),
* 'node_created' => array('created'),
* 'node_moderate' => array('moderate'),
* 'node_frontpage' => array('promote', 'status', 'sticky', 'created'),
* 'node_status_type' => array('status', 'type', 'nid'),
* 'node_title_type' => array('title', array('type', 4)),
* 'node_type' => array(array('type', 4)),
* 'uid' => array('uid'),
* 'tnid' => array('tnid'),
* 'translate' => array('translate'),
* ),
* 'unique keys' => array(
* 'vid' => array('vid'),
* ),
* // For documentation purposes only; foreign keys are not created in the
* // database.
* 'foreign keys' => array(
* 'node_revision' => array(
* 'table' => 'node_revision',
* 'columns' => array('vid' => 'vid'),
* ),
* 'node_author' => array(
* 'table' => 'users',
* 'columns' => array('uid' => 'uid'),
* ),
* ),
* 'primary key' => array('nid'),
* );
* @endcode
*
* @see drupal_install_schema()
*/
/**
* Base class for database schema definitions.
*/
abstract class DatabaseSchema implements QueryPlaceholderInterface {
protected $connection;
/**
* The placeholder counter.
*/
protected $placeholder = 0;
/**
* Definition of prefixInfo array structure.
*
* Rather than redefining DatabaseSchema::getPrefixInfo() for each driver,
* by defining the defaultSchema variable only MySQL has to re-write the
* method.
*
* @see DatabaseSchema::getPrefixInfo()
*/
protected $defaultSchema = 'public';
/**
* A unique identifier for this query object.
*/
protected $uniqueIdentifier;
public function __construct($connection) {
$this->uniqueIdentifier = uniqid('', TRUE);
$this->connection = $connection;
}
/**
* Implements the magic __clone function.
*/
public function __clone() {
$this->uniqueIdentifier = uniqid('', TRUE);
}
/**
* Implements QueryPlaceHolderInterface::uniqueIdentifier().
*/
public function uniqueIdentifier() {
return $this->uniqueIdentifier;
}
/**
* Implements QueryPlaceHolderInterface::nextPlaceholder().
*/
public function nextPlaceholder() {
return $this->placeholder++;
}
/**
* Get information about the table name and schema from the prefix.
*
* @param
* Name of table to look prefix up for. Defaults to 'default' because thats
* default key for prefix.
* @param $add_prefix
* Boolean that indicates whether the given table name should be prefixed.
*
* @return
* A keyed array with information about the schema, table name and prefix.
*/
protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) {
$info = array(
'schema' => $this->defaultSchema,
'prefix' => $this->connection->tablePrefix($table),
);
if ($add_prefix) {
$table = $info['prefix'] . $table;
}
// If the prefix contains a period in it, then that means the prefix also
// contains a schema reference in which case we will change the schema key
// to the value before the period in the prefix. Everything after the dot
// will be prefixed onto the front of the table.
if (($pos = strpos($table, '.')) !== FALSE) {
// Grab everything before the period.
$info['schema'] = substr($table, 0, $pos);
// Grab everything after the dot.
$info['table'] = substr($table, ++$pos);
}
else {
$info['table'] = $table;
}
return $info;
}
/**
* Create names for indexes, primary keys and constraints.
*
* This prevents using {} around non-table names like indexes and keys.
*/
function prefixNonTable($table) {
$args = func_get_args();
$info = $this->getPrefixInfo($table);
$args[0] = $info['table'];
return implode('_', $args);
}
/**
* Build a condition to match a table name against a standard information_schema.
*
* The information_schema is a SQL standard that provides information about the
* database server and the databases, schemas, tables, columns and users within
* it. This makes information_schema a useful tool to use across the drupal
* database drivers and is used by a few different functions. The function below
* describes the conditions to be meet when querying information_schema.tables
* for drupal tables or information associated with drupal tables. Even though
* this is the standard method, not all databases follow standards and so this
* method should be overwritten by a database driver if the database provider
* uses alternate methods. Because information_schema.tables is used in a few
* different functions, a database driver will only need to override this function
* to make all the others work. For example see includes/databases/mysql/schema.inc.
*
* @param $table_name
* The name of the table in question.
* @param $operator
* The operator to apply on the 'table' part of the condition.
* @param $add_prefix
* Boolean to indicate whether the table name needs to be prefixed.
*
* @return QueryConditionInterface
* A DatabaseCondition object.
*/
protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) {
$info = $this->connection->getConnectionOptions();
// Retrieve the table name and schema
$table_info = $this->getPrefixInfo($table_name, $add_prefix);
$condition = new DatabaseCondition('AND');
$condition->condition('table_catalog', $info['database']);
$condition->condition('table_schema', $table_info['schema']);
$condition->condition('table_name', $table_info['table'], $operator);
return $condition;
}
/**
* Check if a table exists.
*
* @param $table
* The name of the table in drupal (no prefixing).
*
* @return
* TRUE if the given table exists, otherwise FALSE.
*/
public function tableExists($table) {
$condition = $this->buildTableNameCondition($table);
$condition->compile($this->connection, $this);
// Normally, we would heartily discourage the use of string
// concatenation for conditionals like this however, we
// couldn't use db_select() here because it would prefix
// information_schema.tables and the query would fail.
// Don't use {} around information_schema.tables table.
return (bool) $this->connection->query("SELECT 1 FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments())->fetchField();
}
/**
* Find all tables that are like the specified base table name.
*
* @param $table_expression
* An SQL expression, for example "simpletest%" (without the quotes).
* BEWARE: this is not prefixed, the caller should take care of that.
*
* @return
* Array, both the keys and the values are the matching tables.
*/
public function findTables($table_expression) {
$condition = $this->buildTableNameCondition($table_expression, 'LIKE', FALSE);
$condition->compile($this->connection, $this);
// Normally, we would heartily discourage the use of string
// concatenation for conditionals like this however, we
// couldn't use db_select() here because it would prefix
// information_schema.tables and the query would fail.
// Don't use {} around information_schema.tables table.
return $this->connection->query("SELECT table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments())->fetchAllKeyed(0, 0);
}
/**
* Check if a column exists in the given table.
*
* @param $table
* The name of the table in drupal (no prefixing).
* @param $name
* The name of the column.
*
* @return
* TRUE if the given column exists, otherwise FALSE.
*/
public function fieldExists($table, $column) {
$condition = $this->buildTableNameCondition($table);
$condition->condition('column_name', $column);
$condition->compile($this->connection, $this);
// Normally, we would heartily discourage the use of string
// concatenation for conditionals like this however, we
// couldn't use db_select() here because it would prefix
// information_schema.tables and the query would fail.
// Don't use {} around information_schema.columns table.
return (bool) $this->connection->query("SELECT 1 FROM information_schema.columns WHERE " . (string) $condition, $condition->arguments())->fetchField();
}
/**
* Returns a mapping of Drupal schema field names to DB-native field types.
*
* Because different field types do not map 1:1 between databases, Drupal has
* its own normalized field type names. This function returns a driver-specific
* mapping table from Drupal names to the native names for each database.
*
* @return array
* An array of Schema API field types to driver-specific field types.
*/
abstract public function getFieldTypeMap();
/**
* Rename a table.
*
* @param $table
* The table to be renamed.
* @param $new_name
* The new name for the table.
*
* @throws DatabaseSchemaObjectDoesNotExistException
* If the specified table doesn't exist.
* @throws DatabaseSchemaObjectExistsException
* If a table with the specified new name already exists.
*/
abstract public function renameTable($table, $new_name);
/**
* Drop a table.
*
* @param $table
* The table to be dropped.
*
* @return
* TRUE if the table was successfully dropped, FALSE if there was no table
* by that name to begin with.
*/
abstract public function dropTable($table);
/**
* Add a new field to a table.
*
* @param $table
* Name of the table to be altered.
* @param $field
* Name of the field to be added.
* @param $spec
* The field specification array, as taken from a schema definition.
* The specification may also contain the key 'initial', the newly
* created field will be set to the value of the key in all rows.
* This is most useful for creating NOT NULL columns with no default
* value in existing tables.
* @param $keys_new
* (optional) Keys and indexes specification to be created on the
* table along with adding the field. The format is the same as a
* table specification but without the 'fields' element. If you are
* adding a type 'serial' field, you MUST specify at least one key
* or index including it in this array. See db_change_field() for more
* explanation why.
*
* @throws DatabaseSchemaObjectDoesNotExistException
* If the specified table doesn't exist.
* @throws DatabaseSchemaObjectExistsException
* If the specified table already has a field by that name.
*/
abstract public function addField($table, $field, $spec, $keys_new = array());
/**
* Drop a field.
*
* @param $table
* The table to be altered.
* @param $field
* The field to be dropped.
*
* @return
* TRUE if the field was successfully dropped, FALSE if there was no field
* by that name to begin with.
*/
abstract public function dropField($table, $field);
/**
* Set the default value for a field.
*
* @param $table
* The table to be altered.
* @param $field
* The field to be altered.
* @param $default
* Default value to be set. NULL for 'default NULL'.
*
* @throws DatabaseSchemaObjectDoesNotExistException
* If the specified table or field doesn't exist.
*/
abstract public function fieldSetDefault($table, $field, $default);
/**
* Set a field to have no default value.
*
* @param $table
* The table to be altered.
* @param $field
* The field to be altered.
*
* @throws DatabaseSchemaObjectDoesNotExistException
* If the specified table or field doesn't exist.
*/
abstract public function fieldSetNoDefault($table, $field);
/**
* Checks if an index exists in the given table.
*
* @param $table
* The name of the table in drupal (no prefixing).
* @param $name
* The name of the index in drupal (no prefixing).
*
* @return
* TRUE if the given index exists, otherwise FALSE.
*/
abstract public function indexExists($table, $name);
/**
* Add a primary key.
*
* @param $table
* The table to be altered.
* @param $fields
* Fields for the primary key.
*
* @throws DatabaseSchemaObjectDoesNotExistException
* If the specified table doesn't exist.
* @throws DatabaseSchemaObjectExistsException
* If the specified table already has a primary key.
*/
abstract public function addPrimaryKey($table, $fields);
/**
* Drop the primary key.
*
* @param $table
* The table to be altered.
*
* @return
* TRUE if the primary key was successfully dropped, FALSE if there was no
* primary key on this table to begin with.
*/
abstract public function dropPrimaryKey($table);
/**
* Add a unique key.
*
* @param $table
* The table to be altered.
* @param $name
* The name of the key.
* @param $fields
* An array of field names.
*
* @throws DatabaseSchemaObjectDoesNotExistException
* If the specified table doesn't exist.
* @throws DatabaseSchemaObjectExistsException
* If the specified table already has a key by that name.
*/
abstract public function addUniqueKey($table, $name, $fields);
/**
* Drop a unique key.
*
* @param $table
* The table to be altered.
* @param $name
* The name of the key.
*
* @return
* TRUE if the key was successfully dropped, FALSE if there was no key by
* that name to begin with.
*/
abstract public function dropUniqueKey($table, $name);
/**
* Add an index.
*
* @param $table
* The table to be altered.
* @param $name
* The name of the index.
* @param $fields
* An array of field names.
*
* @throws DatabaseSchemaObjectDoesNotExistException
* If the specified table doesn't exist.
* @throws DatabaseSchemaObjectExistsException
* If the specified table already has an index by that name.
*/
abstract public function addIndex($table, $name, $fields);
/**
* Drop an index.
*
* @param $table
* The table to be altered.
* @param $name
* The name of the index.
*
* @return
* TRUE if the index was successfully dropped, FALSE if there was no index
* by that name to begin with.
*/
abstract public function dropIndex($table, $name);
/**
* Change a field definition.
*
* IMPORTANT NOTE: To maintain database portability, you have to explicitly
* recreate all indices and primary keys that are using the changed field.
*
* That means that you have to drop all affected keys and indexes with
* db_drop_{primary_key,unique_key,index}() before calling db_change_field().
* To recreate the keys and indices, pass the key definitions as the
* optional $keys_new argument directly to db_change_field().
*
* For example, suppose you have:
* @code
* $schema['foo'] = array(
* 'fields' => array(
* 'bar' => array('type' => 'int', 'not null' => TRUE)
* ),
* 'primary key' => array('bar')
* );
* @endcode
* and you want to change foo.bar to be type serial, leaving it as the
* primary key. The correct sequence is:
* @code
* db_drop_primary_key('foo');
* db_change_field('foo', 'bar', 'bar',
* array('type' => 'serial', 'not null' => TRUE),
* array('primary key' => array('bar')));
* @endcode
*
* The reasons for this are due to the different database engines:
*
* On PostgreSQL, changing a field definition involves adding a new field
* and dropping an old one which* causes any indices, primary keys and
* sequences (from serial-type fields) that use the changed field to be dropped.
*
* On MySQL, all type 'serial' fields must be part of at least one key
* or index as soon as they are created. You cannot use
* db_add_{primary_key,unique_key,index}() for this purpose because
* the ALTER TABLE command will fail to add the column without a key
* or index specification. The solution is to use the optional
* $keys_new argument to create the key or index at the same time as
* field.
*
* You could use db_add_{primary_key,unique_key,index}() in all cases
* unless you are converting a field to be type serial. You can use
* the $keys_new argument in all cases.
*
* @param $table
* Name of the table.
* @param $field
* Name of the field to change.
* @param $field_new
* New name for the field (set to the same as $field if you don't want to change the name).
* @param $spec
* The field specification for the new field.
* @param $keys_new
* (optional) Keys and indexes specification to be created on the
* table along with changing the field. The format is the same as a
* table specification but without the 'fields' element.
*
* @throws DatabaseSchemaObjectDoesNotExistException
* If the specified table or source field doesn't exist.
* @throws DatabaseSchemaObjectExistsException
* If the specified destination field already exists.
*/
abstract public function changeField($table, $field, $field_new, $spec, $keys_new = array());
/**
* Create a new table from a Drupal table definition.
*
* @param $name
* The name of the table to create.
* @param $table
* A Schema API table definition array.
*
* @throws DatabaseSchemaObjectExistsException
* If the specified table already exists.
*/
public function createTable($name, $table) {
if ($this->tableExists($name)) {
throw new DatabaseSchemaObjectExistsException(t('Table @name already exists.', array('@name' => $name)));
}
$statements = $this->createTableSql($name, $table);
foreach ($statements as $statement) {
$this->connection->query($statement);
}
}
/**
* Return an array of field names from an array of key/index column specifiers.
*
* This is usually an identity function but if a key/index uses a column prefix
* specification, this function extracts just the name.
*
* @param $fields
* An array of key/index column specifiers.
*
* @return
* An array of field names.
*/
public function fieldNames($fields) {
$return = array();
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = $field[0];
}
else {
$return[] = $field;
}
}
return $return;
}
/**
* Prepare a table or column comment for database query.
*
* @param $comment
* The comment string to prepare.
* @param $length
* Optional upper limit on the returned string length.
*
* @return
* The prepared comment.
*/
public function prepareComment($comment, $length = NULL) {
return $this->connection->quote($comment);
}
}
/**
* Exception thrown if an object being created already exists.
*
* For example, this exception should be thrown whenever there is an attempt to
* create a new database table, field, or index that already exists in the
* database schema.
*/
class DatabaseSchemaObjectExistsException extends Exception {}
/**
* Exception thrown if an object being modified doesn't exist yet.
*
* For example, this exception should be thrown whenever there is an attempt to
* modify a database table, field, or index that does not currently exist in
* the database schema.
*/
class DatabaseSchemaObjectDoesNotExistException extends Exception {}
/**
* @} End of "defgroup schemaapi".
*/
File diff suppressed because it is too large Load Diff
+527
View File
@@ -0,0 +1,527 @@
<?php
/**
* @file
* Database interface code for SQLite embedded database engine.
*/
/**
* @addtogroup database
* @{
*/
include_once DRUPAL_ROOT . '/includes/database/prefetch.inc';
/**
* Specific SQLite implementation of DatabaseConnection.
*/
class DatabaseConnection_sqlite extends DatabaseConnection {
/**
* Whether this database connection supports savepoints.
*
* Version of sqlite lower then 3.6.8 can't use savepoints.
* See http://www.sqlite.org/releaselog/3_6_8.html
*
* @var boolean
*/
protected $savepointSupport = FALSE;
/**
* Whether or not the active transaction (if any) will be rolled back.
*
* @var boolean
*/
protected $willRollback;
/**
* All databases attached to the current database. This is used to allow
* prefixes to be safely handled without locking the table
*
* @var array
*/
protected $attachedDatabases = array();
/**
* Whether or not a table has been dropped this request: the destructor will
* only try to get rid of unnecessary databases if there is potential of them
* being empty.
*
* This variable is set to public because DatabaseSchema_sqlite needs to
* access it. However, it should not be manually set.
*
* @var boolean
*/
var $tableDropped = FALSE;
public function __construct(array $connection_options = array()) {
// We don't need a specific PDOStatement class here, we simulate it below.
$this->statementClass = NULL;
// This driver defaults to transaction support, except if explicitly passed FALSE.
$this->transactionSupport = $this->transactionalDDLSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE;
$this->connectionOptions = $connection_options;
// Allow PDO options to be overridden.
$connection_options += array(
'pdo' => array(),
);
$connection_options['pdo'] += array(
// Convert numeric values to strings when fetching.
PDO::ATTR_STRINGIFY_FETCHES => TRUE,
);
parent::__construct('sqlite:' . $connection_options['database'], '', '', $connection_options['pdo']);
// Attach one database for each registered prefix.
$prefixes = $this->prefixes;
foreach ($prefixes as $table => &$prefix) {
// Empty prefix means query the main database -- no need to attach anything.
if (!empty($prefix)) {
// Only attach the database once.
if (!isset($this->attachedDatabases[$prefix])) {
$this->attachedDatabases[$prefix] = $prefix;
$this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'] . '-' . $prefix, ':prefix' => $prefix));
}
// Add a ., so queries become prefix.table, which is proper syntax for
// querying an attached database.
$prefix .= '.';
}
}
// Regenerate the prefixes replacement table.
$this->setPrefix($prefixes);
// Detect support for SAVEPOINT.
$version = $this->query('SELECT sqlite_version()')->fetchField();
$this->savepointSupport = (version_compare($version, '3.6.8') >= 0);
// Create functions needed by SQLite.
$this->sqliteCreateFunction('if', array($this, 'sqlFunctionIf'));
$this->sqliteCreateFunction('greatest', array($this, 'sqlFunctionGreatest'));
$this->sqliteCreateFunction('pow', 'pow', 2);
$this->sqliteCreateFunction('length', 'strlen', 1);
$this->sqliteCreateFunction('md5', 'md5', 1);
$this->sqliteCreateFunction('concat', array($this, 'sqlFunctionConcat'));
$this->sqliteCreateFunction('substring', array($this, 'sqlFunctionSubstring'), 3);
$this->sqliteCreateFunction('substring_index', array($this, 'sqlFunctionSubstringIndex'), 3);
$this->sqliteCreateFunction('rand', array($this, 'sqlFunctionRand'));
// Execute sqlite init_commands.
if (isset($connection_options['init_commands'])) {
$this->exec(implode('; ', $connection_options['init_commands']));
}
}
/**
* Destructor for the SQLite connection.
*
* We prune empty databases on destruct, but only if tables have been
* dropped. This is especially needed when running the test suite, which
* creates and destroy databases several times in a row.
*/
public function __destruct() {
if ($this->tableDropped && !empty($this->attachedDatabases)) {
foreach ($this->attachedDatabases as $prefix) {
// Check if the database is now empty, ignore the internal SQLite tables.
try {
$count = $this->query('SELECT COUNT(*) FROM ' . $prefix . '.sqlite_master WHERE type = :type AND name NOT LIKE :pattern', array(':type' => 'table', ':pattern' => 'sqlite_%'))->fetchField();
// We can prune the database file if it doesn't have any tables.
if ($count == 0) {
// Detach the database.
$this->query('DETACH DATABASE :schema', array(':schema' => $prefix));
// Destroy the database file.
unlink($this->connectionOptions['database'] . '-' . $prefix);
}
}
catch (Exception $e) {
// Ignore the exception and continue. There is nothing we can do here
// to report the error or fail safe.
}
}
}
}
/**
* SQLite compatibility implementation for the IF() SQL function.
*/
public function sqlFunctionIf($condition, $expr1, $expr2 = NULL) {
return $condition ? $expr1 : $expr2;
}
/**
* SQLite compatibility implementation for the GREATEST() SQL function.
*/
public function sqlFunctionGreatest() {
$args = func_get_args();
foreach ($args as $k => $v) {
if (!isset($v)) {
unset($args);
}
}
if (count($args)) {
return max($args);
}
else {
return NULL;
}
}
/**
* SQLite compatibility implementation for the CONCAT() SQL function.
*/
public function sqlFunctionConcat() {
$args = func_get_args();
return implode('', $args);
}
/**
* SQLite compatibility implementation for the SUBSTRING() SQL function.
*/
public function sqlFunctionSubstring($string, $from, $length) {
return substr($string, $from - 1, $length);
}
/**
* SQLite compatibility implementation for the SUBSTRING_INDEX() SQL function.
*/
public function sqlFunctionSubstringIndex($string, $delimiter, $count) {
// If string is empty, simply return an empty string.
if (empty($string)) {
return '';
}
$end = 0;
for ($i = 0; $i < $count; $i++) {
$end = strpos($string, $delimiter, $end + 1);
if ($end === FALSE) {
$end = strlen($string);
}
}
return substr($string, 0, $end);
}
/**
* SQLite compatibility implementation for the RAND() SQL function.
*/
public function sqlFunctionRand($seed = NULL) {
if (isset($seed)) {
mt_srand($seed);
}
return mt_rand() / mt_getrandmax();
}
/**
* SQLite-specific implementation of DatabaseConnection::prepare().
*
* We don't use prepared statements at all at this stage. We just create
* a DatabaseStatement_sqlite object, that will create a PDOStatement
* using the semi-private PDOPrepare() method below.
*/
public function prepare($query, $options = array()) {
return new DatabaseStatement_sqlite($this, $query, $options);
}
/**
* NEVER CALL THIS FUNCTION: YOU MIGHT DEADLOCK YOUR PHP PROCESS.
*
* This is a wrapper around the parent PDO::prepare method. However, as
* the PDO SQLite driver only closes SELECT statements when the PDOStatement
* destructor is called and SQLite does not allow data change (INSERT,
* UPDATE etc) on a table which has open SELECT statements, you should never
* call this function and keep a PDOStatement object alive as that can lead
* to a deadlock. This really, really should be private, but as
* DatabaseStatement_sqlite needs to call it, we have no other choice but to
* expose this function to the world.
*/
public function PDOPrepare($query, array $options = array()) {
return parent::prepare($query, $options);
}
public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
return $this->query($query . ' LIMIT ' . (int) $from . ', ' . (int) $count, $args, $options);
}
public function queryTemporary($query, array $args = array(), array $options = array()) {
// Generate a new temporary table name and protect it from prefixing.
// SQLite requires that temporary tables to be non-qualified.
$tablename = $this->generateTemporaryTableName();
$prefixes = $this->prefixes;
$prefixes[$tablename] = '';
$this->setPrefix($prefixes);
$this->query('CREATE TEMPORARY TABLE ' . $tablename . ' AS ' . $query, $args, $options);
return $tablename;
}
public function driver() {
return 'sqlite';
}
public function databaseType() {
return 'sqlite';
}
public function mapConditionOperator($operator) {
// We don't want to override any of the defaults.
static $specials = array(
'LIKE' => array('postfix' => " ESCAPE '\\'"),
'NOT LIKE' => array('postfix' => " ESCAPE '\\'"),
);
return isset($specials[$operator]) ? $specials[$operator] : NULL;
}
public function prepareQuery($query) {
return $this->prepare($this->prefixTables($query));
}
public function nextId($existing_id = 0) {
$transaction = $this->startTransaction();
// We can safely use literal queries here instead of the slower query
// builder because if a given database breaks here then it can simply
// override nextId. However, this is unlikely as we deal with short strings
// and integers and no known databases require special handling for those
// simple cases. If another transaction wants to write the same row, it will
// wait until this transaction commits.
$stmt = $this->query('UPDATE {sequences} SET value = GREATEST(value, :existing_id) + 1', array(
':existing_id' => $existing_id,
));
if (!$stmt->rowCount()) {
$this->query('INSERT INTO {sequences} (value) VALUES (:existing_id + 1)', array(
':existing_id' => $existing_id,
));
}
// The transaction gets committed when the transaction object gets destroyed
// because it gets out of scope.
return $this->query('SELECT value FROM {sequences}')->fetchField();
}
public function rollback($savepoint_name = 'drupal_transaction') {
if ($this->savepointSupport) {
return parent::rollBack($savepoint_name);
}
if (!$this->inTransaction()) {
throw new DatabaseTransactionNoActiveException();
}
// A previous rollback to an earlier savepoint may mean that the savepoint
// in question has already been rolled back.
if (!in_array($savepoint_name, $this->transactionLayers)) {
return;
}
// We need to find the point we're rolling back to, all other savepoints
// before are no longer needed.
while ($savepoint = array_pop($this->transactionLayers)) {
if ($savepoint == $savepoint_name) {
// Mark whole stack of transactions as needed roll back.
$this->willRollback = TRUE;
// If it is the last the transaction in the stack, then it is not a
// savepoint, it is the transaction itself so we will need to roll back
// the transaction rather than a savepoint.
if (empty($this->transactionLayers)) {
break;
}
return;
}
}
if ($this->supportsTransactions()) {
PDO::rollBack();
}
}
public function pushTransaction($name) {
if ($this->savepointSupport) {
return parent::pushTransaction($name);
}
if (!$this->supportsTransactions()) {
return;
}
if (isset($this->transactionLayers[$name])) {
throw new DatabaseTransactionNameNonUniqueException($name . " is already in use.");
}
if (!$this->inTransaction()) {
PDO::beginTransaction();
}
$this->transactionLayers[$name] = $name;
}
public function popTransaction($name) {
if ($this->savepointSupport) {
return parent::popTransaction($name);
}
if (!$this->supportsTransactions()) {
return;
}
if (!$this->inTransaction()) {
throw new DatabaseTransactionNoActiveException();
}
// Commit everything since SAVEPOINT $name.
while($savepoint = array_pop($this->transactionLayers)) {
if ($savepoint != $name) continue;
// If there are no more layers left then we should commit or rollback.
if (empty($this->transactionLayers)) {
// If there was any rollback() we should roll back whole transaction.
if ($this->willRollback) {
$this->willRollback = FALSE;
PDO::rollBack();
}
elseif (!PDO::commit()) {
throw new DatabaseTransactionCommitFailedException();
}
}
else {
break;
}
}
}
public function utf8mb4IsActive() {
return TRUE;
}
public function utf8mb4IsSupported() {
return TRUE;
}
}
/**
* Specific SQLite implementation of DatabaseConnection.
*
* See DatabaseConnection_sqlite::PDOPrepare() for reasons why we must prefetch
* the data instead of using PDOStatement.
*
* @see DatabaseConnection_sqlite::PDOPrepare()
*/
class DatabaseStatement_sqlite extends DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface {
/**
* SQLite specific implementation of getStatement().
*
* The PDO SQLite layer doesn't replace numeric placeholders in queries
* correctly, and this makes numeric expressions (such as COUNT(*) >= :count)
* fail. We replace numeric placeholders in the query ourselves to work
* around this bug.
*
* See http://bugs.php.net/bug.php?id=45259 for more details.
*/
protected function getStatement($query, &$args = array()) {
if (count($args)) {
// Check if $args is a simple numeric array.
if (range(0, count($args) - 1) === array_keys($args)) {
// In that case, we have unnamed placeholders.
$count = 0;
$new_args = array();
foreach ($args as $value) {
if (is_float($value) || is_int($value)) {
if (is_float($value)) {
// Force the conversion to float so as not to loose precision
// in the automatic cast.
$value = sprintf('%F', $value);
}
$query = substr_replace($query, $value, strpos($query, '?'), 1);
}
else {
$placeholder = ':db_statement_placeholder_' . $count++;
$query = substr_replace($query, $placeholder, strpos($query, '?'), 1);
$new_args[$placeholder] = $value;
}
}
$args = $new_args;
}
else {
// Else, this is using named placeholders.
foreach ($args as $placeholder => $value) {
if (is_float($value) || is_int($value)) {
if (is_float($value)) {
// Force the conversion to float so as not to loose precision
// in the automatic cast.
$value = sprintf('%F', $value);
}
// We will remove this placeholder from the query as PDO throws an
// exception if the number of placeholders in the query and the
// arguments does not match.
unset($args[$placeholder]);
// PDO allows placeholders to not be prefixed by a colon. See
// http://marc.info/?l=php-internals&m=111234321827149&w=2 for
// more.
if ($placeholder[0] != ':') {
$placeholder = ":$placeholder";
}
// When replacing the placeholders, make sure we search for the
// exact placeholder. For example, if searching for
// ':db_placeholder_1', do not replace ':db_placeholder_11'.
$query = preg_replace('/' . preg_quote($placeholder) . '\b/', $value, $query);
}
}
}
}
return $this->dbh->PDOPrepare($query);
}
public function execute($args = array(), $options = array()) {
try {
$return = parent::execute($args, $options);
}
catch (PDOException $e) {
if (!empty($e->errorInfo[1]) && $e->errorInfo[1] === 17) {
// The schema has changed. SQLite specifies that we must resend the query.
$return = parent::execute($args, $options);
}
else {
// Rethrow the exception.
throw $e;
}
}
// In some weird cases, SQLite will prefix some column names by the name
// of the table. We post-process the data, by renaming the column names
// using the same convention as MySQL and PostgreSQL.
$rename_columns = array();
foreach ($this->columnNames as $k => $column) {
// In some SQLite versions, SELECT DISTINCT(field) will return "(field)"
// instead of "field".
if (preg_match("/^\((.*)\)$/", $column, $matches)) {
$rename_columns[$column] = $matches[1];
$this->columnNames[$k] = $matches[1];
$column = $matches[1];
}
// Remove "table." prefixes.
if (preg_match("/^.*\.(.*)$/", $column, $matches)) {
$rename_columns[$column] = $matches[1];
$this->columnNames[$k] = $matches[1];
}
}
if ($rename_columns) {
// DatabaseStatementPrefetch already extracted the first row,
// put it back into the result set.
if (isset($this->currentRow)) {
$this->data[0] = &$this->currentRow;
}
// Then rename all the columns across the result set.
foreach ($this->data as $k => $row) {
foreach ($rename_columns as $old_column => $new_column) {
$this->data[$k][$new_column] = $this->data[$k][$old_column];
unset($this->data[$k][$old_column]);
}
}
// Finally, extract the first row again.
$this->currentRow = $this->data[0];
unset($this->data[0]);
}
return $return;
}
}
/**
* @} End of "addtogroup database".
*/
+49
View File
@@ -0,0 +1,49 @@
<?php
/**
* @file
* SQLite specific install functions
*/
class DatabaseTasks_sqlite extends DatabaseTasks {
protected $pdoDriver = 'sqlite';
public function name() {
return st('SQLite');
}
/**
* Minimum engine version.
*/
public function minimumVersion() {
return '3.3.7';
}
public function getFormOptions($database) {
$form = parent::getFormOptions($database);
// Remove the options that only apply to client/server style databases.
unset($form['username'], $form['password'], $form['advanced_options']['host'], $form['advanced_options']['port']);
// Make the text more accurate for SQLite.
$form['database']['#title'] = st('Database file');
$form['database']['#description'] = st('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name()));
$default_database = conf_path(FALSE, TRUE) . '/files/.ht.sqlite';
$form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database'];
return $form;
}
public function validateDatabaseSettings($database) {
// Perform standard validation.
$errors = parent::validateDatabaseSettings($database);
// Verify the database is writable.
$db_directory = new SplFileInfo(dirname($database['database']));
if (!$db_directory->isWritable()) {
$errors[$database['driver'] . '][database'] = st('The directory you specified is not writable by the web server.');
}
return $errors;
}
}
+139
View File
@@ -0,0 +1,139 @@
<?php
/**
* @file
* Query code for SQLite embedded database engine.
*/
/**
* @addtogroup database
* @{
*/
/**
* SQLite specific implementation of InsertQuery.
*
* We ignore all the default fields and use the clever SQLite syntax:
* INSERT INTO table DEFAULT VALUES
* for degenerated "default only" queries.
*/
class InsertQuery_sqlite extends InsertQuery {
public function execute() {
if (!$this->preExecute()) {
return NULL;
}
if (count($this->insertFields)) {
return parent::execute();
}
else {
return $this->connection->query('INSERT INTO {' . $this->table . '} DEFAULT VALUES', array(), $this->queryOptions);
}
}
public function __toString() {
// Create a sanitized comment string to prepend to the query.
$comments = $this->connection->makeComment($this->comments);
// Produce as many generic placeholders as necessary.
$placeholders = array_fill(0, count($this->insertFields), '?');
// If we're selecting from a SelectQuery, finish building the query and
// pass it back, as any remaining options are irrelevant.
if (!empty($this->fromQuery)) {
$insert_fields_string = $this->insertFields ? ' (' . implode(', ', $this->insertFields) . ') ' : ' ';
return $comments . 'INSERT INTO {' . $this->table . '}' . $insert_fields_string . $this->fromQuery;
}
return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $this->insertFields) . ') VALUES (' . implode(', ', $placeholders) . ')';
}
}
/**
* SQLite specific implementation of UpdateQuery.
*
* SQLite counts all the rows that match the conditions as modified, even if they
* will not be affected by the query. We workaround this by ensuring that
* we don't select those rows.
*
* A query like this one:
* UPDATE test SET col1 = 'newcol1', col2 = 'newcol2' WHERE tid = 1
* will become:
* UPDATE test SET col1 = 'newcol1', col2 = 'newcol2' WHERE tid = 1 AND (col1 <> 'newcol1' OR col2 <> 'newcol2')
*/
class UpdateQuery_sqlite extends UpdateQuery {
public function execute() {
if (!empty($this->queryOptions['sqlite_return_matched_rows'])) {
return parent::execute();
}
// Get the fields used in the update query.
$fields = $this->expressionFields + $this->fields;
// Add the inverse of the fields to the condition.
$condition = new DatabaseCondition('OR');
foreach ($fields as $field => $data) {
if (is_array($data)) {
// The field is an expression.
$condition->where($field . ' <> ' . $data['expression']);
$condition->isNull($field);
}
elseif (!isset($data)) {
// The field will be set to NULL.
$condition->isNotNull($field);
}
else {
$condition->condition($field, $data, '<>');
$condition->isNull($field);
}
}
if (count($condition)) {
$condition->compile($this->connection, $this);
$this->condition->where((string) $condition, $condition->arguments());
}
return parent::execute();
}
}
/**
* SQLite specific implementation of DeleteQuery.
*/
class DeleteQuery_sqlite extends DeleteQuery {
public function execute() {
// When the WHERE is omitted from a DELETE statement and the table being
// deleted has no triggers, SQLite uses an optimization to erase the entire
// table content without having to visit each row of the table individually.
// Prior to SQLite 3.6.5, SQLite does not return the actual number of rows
// deleted by that optimized "truncate" optimization. But we want to return
// the number of rows affected, so we calculate it directly.
if (!count($this->condition)) {
$total_rows = $this->connection->query('SELECT COUNT(*) FROM {' . $this->connection->escapeTable($this->table) . '}')->fetchField();
parent::execute();
return $total_rows;
}
else {
return parent::execute();
}
}
}
/**
* SQLite specific implementation of TruncateQuery.
*
* SQLite doesn't support TRUNCATE, but a DELETE query with no condition has
* exactly the effect (it is implemented by DROPing the table).
*/
class TruncateQuery_sqlite extends TruncateQuery {
public function __toString() {
// Create a sanitized comment string to prepend to the query.
$comments = $this->connection->makeComment($this->comments);
return $comments . 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '} ';
}
}
/**
* @} End of "addtogroup database".
*/
+683
View File
@@ -0,0 +1,683 @@
<?php
/**
* @file
* Database schema code for SQLite databases.
*/
/**
* @ingroup schemaapi
* @{
*/
class DatabaseSchema_sqlite extends DatabaseSchema {
/**
* Override DatabaseSchema::$defaultSchema
*/
protected $defaultSchema = 'main';
public function tableExists($table) {
$info = $this->getPrefixInfo($table);
// Don't use {} around sqlite_master table.
return (bool) $this->connection->query('SELECT 1 FROM ' . $info['schema'] . '.sqlite_master WHERE type = :type AND name = :name', array(':type' => 'table', ':name' => $info['table']))->fetchField();
}
public function fieldExists($table, $column) {
$schema = $this->introspectSchema($table);
return !empty($schema['fields'][$column]);
}
/**
* Generate SQL to create a new table from a Drupal schema definition.
*
* @param $name
* The name of the table to create.
* @param $table
* A Schema API table definition array.
* @return
* An array of SQL statements to create the table.
*/
public function createTableSql($name, $table) {
$sql = array();
$sql[] = "CREATE TABLE {" . $name . "} (\n" . $this->createColumsSql($name, $table) . "\n);\n";
return array_merge($sql, $this->createIndexSql($name, $table));
}
/**
* Build the SQL expression for indexes.
*/
protected function createIndexSql($tablename, $schema) {
$sql = array();
$info = $this->getPrefixInfo($tablename);
if (!empty($schema['unique keys'])) {
foreach ($schema['unique keys'] as $key => $fields) {
$sql[] = 'CREATE UNIQUE INDEX ' . $info['schema'] . '.' . $info['table'] . '_' . $key . ' ON ' . $info['table'] . ' (' . $this->createKeySql($fields) . "); \n";
}
}
if (!empty($schema['indexes'])) {
foreach ($schema['indexes'] as $key => $fields) {
$sql[] = 'CREATE INDEX ' . $info['schema'] . '.' . $info['table'] . '_' . $key . ' ON ' . $info['table'] . ' (' . $this->createKeySql($fields) . "); \n";
}
}
return $sql;
}
/**
* Build the SQL expression for creating columns.
*/
protected function createColumsSql($tablename, $schema) {
$sql_array = array();
// Add the SQL statement for each field.
foreach ($schema['fields'] as $name => $field) {
if (isset($field['type']) && $field['type'] == 'serial') {
if (isset($schema['primary key']) && ($key = array_search($name, $schema['primary key'])) !== FALSE) {
unset($schema['primary key'][$key]);
}
}
$sql_array[] = $this->createFieldSql($name, $this->processField($field));
}
// Process keys.
if (!empty($schema['primary key'])) {
$sql_array[] = " PRIMARY KEY (" . $this->createKeySql($schema['primary key']) . ")";
}
return implode(", \n", $sql_array);
}
/**
* Build the SQL expression for keys.
*/
protected function createKeySql($fields) {
$return = array();
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = $field[0];
}
else {
$return[] = $field;
}
}
return implode(', ', $return);
}
/**
* Set database-engine specific properties for a field.
*
* @param $field
* A field description array, as specified in the schema documentation.
*/
protected function processField($field) {
if (!isset($field['size'])) {
$field['size'] = 'normal';
}
// Set the correct database-engine specific datatype.
// In case one is already provided, force it to uppercase.
if (isset($field['sqlite_type'])) {
$field['sqlite_type'] = drupal_strtoupper($field['sqlite_type']);
}
else {
$map = $this->getFieldTypeMap();
$field['sqlite_type'] = $map[$field['type'] . ':' . $field['size']];
}
if (isset($field['type']) && $field['type'] == 'serial') {
$field['auto_increment'] = TRUE;
}
return $field;
}
/**
* Create an SQL string for a field to be used in table creation or alteration.
*
* Before passing a field out of a schema definition into this function it has
* to be processed by db_processField().
*
* @param $name
* Name of the field.
* @param $spec
* The field specification, as per the schema data structure format.
*/
protected function createFieldSql($name, $spec) {
if (!empty($spec['auto_increment'])) {
$sql = $name . " INTEGER PRIMARY KEY AUTOINCREMENT";
if (!empty($spec['unsigned'])) {
$sql .= ' CHECK (' . $name . '>= 0)';
}
}
else {
$sql = $name . ' ' . $spec['sqlite_type'];
if (in_array($spec['sqlite_type'], array('VARCHAR', 'TEXT')) && isset($spec['length'])) {
$sql .= '(' . $spec['length'] . ')';
}
if (isset($spec['not null'])) {
if ($spec['not null']) {
$sql .= ' NOT NULL';
}
else {
$sql .= ' NULL';
}
}
if (!empty($spec['unsigned'])) {
$sql .= ' CHECK (' . $name . '>= 0)';
}
if (isset($spec['default'])) {
if (is_string($spec['default'])) {
$spec['default'] = "'" . $spec['default'] . "'";
}
$sql .= ' DEFAULT ' . $spec['default'];
}
if (empty($spec['not null']) && !isset($spec['default'])) {
$sql .= ' DEFAULT NULL';
}
}
return $sql;
}
/**
* This maps a generic data type in combination with its data size
* to the engine-specific data type.
*/
public function getFieldTypeMap() {
// Put :normal last so it gets preserved by array_flip. This makes
// it much easier for modules (such as schema.module) to map
// database types back into schema types.
// $map does not use drupal_static as its value never changes.
static $map = array(
'varchar:normal' => 'VARCHAR',
'char:normal' => 'CHAR',
'text:tiny' => 'TEXT',
'text:small' => 'TEXT',
'text:medium' => 'TEXT',
'text:big' => 'TEXT',
'text:normal' => 'TEXT',
'serial:tiny' => 'INTEGER',
'serial:small' => 'INTEGER',
'serial:medium' => 'INTEGER',
'serial:big' => 'INTEGER',
'serial:normal' => 'INTEGER',
'int:tiny' => 'INTEGER',
'int:small' => 'INTEGER',
'int:medium' => 'INTEGER',
'int:big' => 'INTEGER',
'int:normal' => 'INTEGER',
'float:tiny' => 'FLOAT',
'float:small' => 'FLOAT',
'float:medium' => 'FLOAT',
'float:big' => 'FLOAT',
'float:normal' => 'FLOAT',
'numeric:normal' => 'NUMERIC',
'blob:big' => 'BLOB',
'blob:normal' => 'BLOB',
);
return $map;
}
public function renameTable($table, $new_name) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name)));
}
if ($this->tableExists($new_name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", array('@table' => $table, '@table_new' => $new_name)));
}
$schema = $this->introspectSchema($table);
// SQLite doesn't allow you to rename tables outside of the current
// database. So the syntax '...RENAME TO database.table' would fail.
// So we must determine the full table name here rather than surrounding
// the table with curly braces incase the db_prefix contains a reference
// to a database outside of our existing database.
$info = $this->getPrefixInfo($new_name);
$this->connection->query('ALTER TABLE {' . $table . '} RENAME TO ' . $info['table']);
// Drop the indexes, there is no RENAME INDEX command in SQLite.
if (!empty($schema['unique keys'])) {
foreach ($schema['unique keys'] as $key => $fields) {
$this->dropIndex($table, $key);
}
}
if (!empty($schema['indexes'])) {
foreach ($schema['indexes'] as $index => $fields) {
$this->dropIndex($table, $index);
}
}
// Recreate the indexes.
$statements = $this->createIndexSql($new_name, $schema);
foreach ($statements as $statement) {
$this->connection->query($statement);
}
}
public function dropTable($table) {
if (!$this->tableExists($table)) {
return FALSE;
}
$this->connection->tableDropped = TRUE;
$this->connection->query('DROP TABLE {' . $table . '}');
return TRUE;
}
public function addField($table, $field, $specification, $keys_new = array()) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", array('@field' => $field, '@table' => $table)));
}
if ($this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", array('@field' => $field, '@table' => $table)));
}
// SQLite doesn't have a full-featured ALTER TABLE statement. It only
// supports adding new fields to a table, in some simple cases. In most
// cases, we have to create a new table and copy the data over.
if (empty($keys_new) && (empty($specification['not null']) || isset($specification['default']))) {
// When we don't have to create new keys and we are not creating a
// NOT NULL column without a default value, we can use the quicker version.
$query = 'ALTER TABLE {' . $table . '} ADD ' . $this->createFieldSql($field, $this->processField($specification));
$this->connection->query($query);
// Apply the initial value if set.
if (isset($specification['initial'])) {
$this->connection->update($table)
->fields(array($field => $specification['initial']))
->execute();
}
}
else {
// We cannot add the field directly. Use the slower table alteration
// method, starting from the old schema.
$old_schema = $this->introspectSchema($table);
$new_schema = $old_schema;
// Add the new field.
$new_schema['fields'][$field] = $specification;
// Build the mapping between the old fields and the new fields.
$mapping = array();
if (isset($specification['initial'])) {
// If we have a initial value, copy it over.
$mapping[$field] = array(
'expression' => ':newfieldinitial',
'arguments' => array(':newfieldinitial' => $specification['initial']),
);
}
else {
// Else use the default of the field.
$mapping[$field] = NULL;
}
// Add the new indexes.
$new_schema += $keys_new;
$this->alterTable($table, $old_schema, $new_schema, $mapping);
}
}
/**
* Create a table with a new schema containing the old content.
*
* As SQLite does not support ALTER TABLE (with a few exceptions) it is
* necessary to create a new table and copy over the old content.
*
* @param $table
* Name of the table to be altered.
* @param $old_schema
* The old schema array for the table.
* @param $new_schema
* The new schema array for the table.
* @param $mapping
* An optional mapping between the fields of the old specification and the
* fields of the new specification. An associative array, whose keys are
* the fields of the new table, and values can take two possible forms:
* - a simple string, which is interpreted as the name of a field of the
* old table,
* - an associative array with two keys 'expression' and 'arguments',
* that will be used as an expression field.
*/
protected function alterTable($table, $old_schema, $new_schema, array $mapping = array()) {
$i = 0;
do {
$new_table = $table . '_' . $i++;
} while ($this->tableExists($new_table));
$this->createTable($new_table, $new_schema);
// Build a SQL query to migrate the data from the old table to the new.
$select = $this->connection->select($table);
// Complete the mapping.
$possible_keys = array_keys($new_schema['fields']);
$mapping += array_combine($possible_keys, $possible_keys);
// Now add the fields.
foreach ($mapping as $field_alias => $field_source) {
// Just ignore this field (ie. use it's default value).
if (!isset($field_source)) {
continue;
}
if (is_array($field_source)) {
$select->addExpression($field_source['expression'], $field_alias, $field_source['arguments']);
}
else {
$select->addField($table, $field_source, $field_alias);
}
}
// Execute the data migration query.
$this->connection->insert($new_table)
->from($select)
->execute();
$old_count = $this->connection->query('SELECT COUNT(*) FROM {' . $table . '}')->fetchField();
$new_count = $this->connection->query('SELECT COUNT(*) FROM {' . $new_table . '}')->fetchField();
if ($old_count == $new_count) {
$this->dropTable($table);
$this->renameTable($new_table, $table);
}
}
/**
* Find out the schema of a table.
*
* This function uses introspection methods provided by the database to
* create a schema array. This is useful, for example, during update when
* the old schema is not available.
*
* @param $table
* Name of the table.
* @return
* An array representing the schema, from drupal_get_schema().
* @see drupal_get_schema()
*/
protected function introspectSchema($table) {
$mapped_fields = array_flip($this->getFieldTypeMap());
$schema = array(
'fields' => array(),
'primary key' => array(),
'unique keys' => array(),
'indexes' => array(),
);
$info = $this->getPrefixInfo($table);
$result = $this->connection->query('PRAGMA ' . $info['schema'] . '.table_info(' . $info['table'] . ')');
foreach ($result as $row) {
if (preg_match('/^([^(]+)\((.*)\)$/', $row->type, $matches)) {
$type = $matches[1];
$length = $matches[2];
}
else {
$type = $row->type;
$length = NULL;
}
if (isset($mapped_fields[$type])) {
list($type, $size) = explode(':', $mapped_fields[$type]);
$schema['fields'][$row->name] = array(
'type' => $type,
'size' => $size,
'not null' => !empty($row->notnull),
'default' => trim($row->dflt_value, "'"),
);
if ($length) {
$schema['fields'][$row->name]['length'] = $length;
}
if ($row->pk) {
$schema['primary key'][] = $row->name;
}
}
else {
new Exception("Unable to parse the column type " . $row->type);
}
}
$indexes = array();
$result = $this->connection->query('PRAGMA ' . $info['schema'] . '.index_list(' . $info['table'] . ')');
foreach ($result as $row) {
if (strpos($row->name, 'sqlite_autoindex_') !== 0) {
$indexes[] = array(
'schema_key' => $row->unique ? 'unique keys' : 'indexes',
'name' => $row->name,
);
}
}
foreach ($indexes as $index) {
$name = $index['name'];
// Get index name without prefix.
$index_name = substr($name, strlen($info['table']) + 1);
$result = $this->connection->query('PRAGMA ' . $info['schema'] . '.index_info(' . $name . ')');
foreach ($result as $row) {
$schema[$index['schema_key']][$index_name][] = $row->name;
}
}
return $schema;
}
public function dropField($table, $field) {
if (!$this->fieldExists($table, $field)) {
return FALSE;
}
$old_schema = $this->introspectSchema($table);
$new_schema = $old_schema;
unset($new_schema['fields'][$field]);
foreach ($new_schema['indexes'] as $index => $fields) {
foreach ($fields as $key => $field_name) {
if ($field_name == $field) {
unset($new_schema['indexes'][$index][$key]);
}
}
// If this index has no more fields then remove it.
if (empty($new_schema['indexes'][$index])) {
unset($new_schema['indexes'][$index]);
}
}
$this->alterTable($table, $old_schema, $new_schema);
return TRUE;
}
public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field)));
}
if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new)));
}
$old_schema = $this->introspectSchema($table);
$new_schema = $old_schema;
// Map the old field to the new field.
if ($field != $field_new) {
$mapping[$field_new] = $field;
}
else {
$mapping = array();
}
// Remove the previous definition and swap in the new one.
unset($new_schema['fields'][$field]);
$new_schema['fields'][$field_new] = $spec;
// Map the former indexes to the new column name.
$new_schema['primary key'] = $this->mapKeyDefinition($new_schema['primary key'], $mapping);
foreach (array('unique keys', 'indexes') as $k) {
foreach ($new_schema[$k] as &$key_definition) {
$key_definition = $this->mapKeyDefinition($key_definition, $mapping);
}
}
// Add in the keys from $keys_new.
if (isset($keys_new['primary key'])) {
$new_schema['primary key'] = $keys_new['primary key'];
}
foreach (array('unique keys', 'indexes') as $k) {
if (!empty($keys_new[$k])) {
$new_schema[$k] = $keys_new[$k] + $new_schema[$k];
}
}
$this->alterTable($table, $old_schema, $new_schema, $mapping);
}
/**
* Utility method: rename columns in an index definition according to a new mapping.
*
* @param $key_definition
* The key definition.
* @param $mapping
* The new mapping.
*/
protected function mapKeyDefinition(array $key_definition, array $mapping) {
foreach ($key_definition as &$field) {
// The key definition can be an array($field, $length).
if (is_array($field)) {
$field = &$field[0];
}
if (isset($mapping[$field])) {
$field = $mapping[$field];
}
}
return $key_definition;
}
public function addIndex($table, $name, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
}
if ($this->indexExists($table, $name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", array('@table' => $table, '@name' => $name)));
}
$schema['indexes'][$name] = $fields;
$statements = $this->createIndexSql($table, $schema);
foreach ($statements as $statement) {
$this->connection->query($statement);
}
}
public function indexExists($table, $name) {
$info = $this->getPrefixInfo($table);
return $this->connection->query('PRAGMA ' . $info['schema'] . '.index_info(' . $info['table'] . '_' . $name . ')')->fetchField() != '';
}
public function dropIndex($table, $name) {
if (!$this->indexExists($table, $name)) {
return FALSE;
}
$info = $this->getPrefixInfo($table);
$this->connection->query('DROP INDEX ' . $info['schema'] . '.' . $info['table'] . '_' . $name);
return TRUE;
}
public function addUniqueKey($table, $name, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
}
if ($this->indexExists($table, $name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", array('@table' => $table, '@name' => $name)));
}
$schema['unique keys'][$name] = $fields;
$statements = $this->createIndexSql($table, $schema);
foreach ($statements as $statement) {
$this->connection->query($statement);
}
}
public function dropUniqueKey($table, $name) {
if (!$this->indexExists($table, $name)) {
return FALSE;
}
$info = $this->getPrefixInfo($table);
$this->connection->query('DROP INDEX ' . $info['schema'] . '.' . $info['table'] . '_' . $name);
return TRUE;
}
public function addPrimaryKey($table, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", array('@table' => $table)));
}
$old_schema = $this->introspectSchema($table);
$new_schema = $old_schema;
if (!empty($new_schema['primary key'])) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", array('@table' => $table)));
}
$new_schema['primary key'] = $fields;
$this->alterTable($table, $old_schema, $new_schema);
}
public function dropPrimaryKey($table) {
$old_schema = $this->introspectSchema($table);
$new_schema = $old_schema;
if (empty($new_schema['primary key'])) {
return FALSE;
}
unset($new_schema['primary key']);
$this->alterTable($table, $old_schema, $new_schema);
return TRUE;
}
public function fieldSetDefault($table, $field, $default) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
}
$old_schema = $this->introspectSchema($table);
$new_schema = $old_schema;
$new_schema['fields'][$field]['default'] = $default;
$this->alterTable($table, $old_schema, $new_schema);
}
public function fieldSetNoDefault($table, $field) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
}
$old_schema = $this->introspectSchema($table);
$new_schema = $old_schema;
unset($new_schema['fields'][$field]['default']);
$this->alterTable($table, $old_schema, $new_schema);
}
public function findTables($table_expression) {
// Don't add the prefix, $table_expression already includes the prefix.
$info = $this->getPrefixInfo($table_expression, FALSE);
// Can't use query placeholders for the schema because the query would have
// to be :prefixsqlite_master, which does not work.
$result = db_query("SELECT name FROM " . $info['schema'] . ".sqlite_master WHERE type = :type AND name LIKE :table_name", array(
':type' => 'table',
':table_name' => $info['table'],
));
return $result->fetchAllKeyed(0, 0);
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* @file
* Select builder for SQLite embedded database engine.
*/
/**
* @addtogroup database
* @{
*/
/**
* SQLite specific query builder for SELECT statements.
*/
class SelectQuery_sqlite extends SelectQuery {
public function forUpdate($set = TRUE) {
// SQLite does not support FOR UPDATE so nothing to do.
return $this;
}
}
/**
* @} End of "addtogroup database".
*/
+196
View File
@@ -0,0 +1,196 @@
<?php
/**
* @file
* Initializes the list of date formats and their locales.
*/
/**
* Provides a default system list of date formats for system_date_formats().
*/
function system_default_date_formats() {
$formats = array();
// Short date formats.
$formats[] = array(
'type' => 'short',
'format' => 'm/d/Y - H:i',
'locales' => array('en-us'),
);
$formats[] = array(
'type' => 'short',
'format' => 'd/m/Y - H:i',
'locales' => array('en-gb', 'en-hk', 'en-ie', 'el-gr', 'es-es', 'fr-be', 'fr-fr', 'fr-lu', 'it-it', 'nl-be', 'pt-pt'),
);
$formats[] = array(
'type' => 'short',
'format' => 'Y/m/d - H:i',
'locales' => array('en-ca', 'fr-ca', 'no-no', 'sv-se'),
);
$formats[] = array(
'type' => 'short',
'format' => 'd.m.Y - H:i',
'locales' => array('de-ch', 'de-de', 'de-lu', 'fi-fi', 'fr-ch', 'is-is', 'pl-pl', 'ro-ro', 'ru-ru'),
);
$formats[] = array(
'type' => 'short',
'format' => 'Y-m-d H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'short',
'format' => 'm/d/Y - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'short',
'format' => 'd/m/Y - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'short',
'format' => 'Y/m/d - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'short',
'format' => 'M j Y - H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'short',
'format' => 'j M Y - H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'short',
'format' => 'Y M j - H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'short',
'format' => 'M j Y - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'short',
'format' => 'j M Y - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'short',
'format' => 'Y M j - g:ia',
'locales' => array(),
);
// Medium date formats.
$formats[] = array(
'type' => 'medium',
'format' => 'D, m/d/Y - H:i',
'locales' => array('en-us'),
);
$formats[] = array(
'type' => 'medium',
'format' => 'D, d/m/Y - H:i',
'locales' => array('en-gb', 'en-hk', 'en-ie', 'el-gr', 'es-es', 'fr-be', 'fr-fr', 'fr-lu', 'it-it', 'nl-be', 'pt-pt'),
);
$formats[] = array(
'type' => 'medium',
'format' => 'D, Y/m/d - H:i',
'locales' => array('en-ca', 'fr-ca', 'no-no', 'sv-se'),
);
$formats[] = array(
'type' => 'medium',
'format' => 'D, Y-m-d H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'medium',
'format' => 'F j, Y - H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'medium',
'format' => 'j F, Y - H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'medium',
'format' => 'Y, F j - H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'medium',
'format' => 'D, m/d/Y - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'medium',
'format' => 'D, d/m/Y - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'medium',
'format' => 'D, Y/m/d - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'medium',
'format' => 'F j, Y - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'medium',
'format' => 'j F Y - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'medium',
'format' => 'Y, F j - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'medium',
'format' => 'j. F Y - G:i',
'locales' => array(),
);
// Long date formats.
$formats[] = array(
'type' => 'long',
'format' => 'l, F j, Y - H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'long',
'format' => 'l, j F, Y - H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'long',
'format' => 'l, Y, F j - H:i',
'locales' => array(),
);
$formats[] = array(
'type' => 'long',
'format' => 'l, F j, Y - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'long',
'format' => 'l, j F Y - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'long',
'format' => 'l, Y, F j - g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'long',
'format' => 'l, j. F Y - G:i',
'locales' => array(),
);
return $formats;
}
+1436
View File
File diff suppressed because it is too large Load Diff
+295
View File
@@ -0,0 +1,295 @@
<?php
/**
* @file
* Functions for error handling.
*/
/**
* Maps PHP error constants to watchdog severity levels.
*
* The error constants are documented at
* http://php.net/manual/errorfunc.constants.php
*
* @ingroup logging_severity_levels
*/
function drupal_error_levels() {
$types = array(
E_ERROR => array('Error', WATCHDOG_ERROR),
E_WARNING => array('Warning', WATCHDOG_WARNING),
E_PARSE => array('Parse error', WATCHDOG_ERROR),
E_NOTICE => array('Notice', WATCHDOG_NOTICE),
E_CORE_ERROR => array('Core error', WATCHDOG_ERROR),
E_CORE_WARNING => array('Core warning', WATCHDOG_WARNING),
E_COMPILE_ERROR => array('Compile error', WATCHDOG_ERROR),
E_COMPILE_WARNING => array('Compile warning', WATCHDOG_WARNING),
E_USER_ERROR => array('User error', WATCHDOG_ERROR),
E_USER_WARNING => array('User warning', WATCHDOG_WARNING),
E_USER_NOTICE => array('User notice', WATCHDOG_NOTICE),
E_STRICT => array('Strict warning', WATCHDOG_DEBUG),
E_RECOVERABLE_ERROR => array('Recoverable fatal error', WATCHDOG_ERROR),
);
// E_DEPRECATED and E_USER_DEPRECATED were added in PHP 5.3.0.
if (defined('E_DEPRECATED')) {
$types[E_DEPRECATED] = array('Deprecated function', WATCHDOG_DEBUG);
$types[E_USER_DEPRECATED] = array('User deprecated function', WATCHDOG_DEBUG);
}
return $types;
}
/**
* Provides custom PHP error handling.
*
* @param $error_level
* The level of the error raised.
* @param $message
* The error message.
* @param $filename
* The filename that the error was raised in.
* @param $line
* The line number the error was raised at.
* @param $context
* An array that points to the active symbol table at the point the error
* occurred.
*/
function _drupal_error_handler_real($error_level, $message, $filename, $line, $context) {
if ($error_level & error_reporting()) {
$types = drupal_error_levels();
list($severity_msg, $severity_level) = $types[$error_level];
$caller = _drupal_get_last_caller(debug_backtrace());
if (!function_exists('filter_xss_admin')) {
require_once DRUPAL_ROOT . '/includes/common.inc';
}
// We treat recoverable errors as fatal.
_drupal_log_error(array(
'%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
// The standard PHP error handler considers that the error messages
// are HTML. We mimic this behavior here.
'!message' => filter_xss_admin($message),
'%function' => $caller['function'],
'%file' => $caller['file'],
'%line' => $caller['line'],
'severity_level' => $severity_level,
), $error_level == E_RECOVERABLE_ERROR);
}
}
/**
* Decodes an exception and retrieves the correct caller.
*
* @param $exception
* The exception object that was thrown.
*
* @return
* An error in the format expected by _drupal_log_error().
*/
function _drupal_decode_exception($exception) {
$message = $exception->getMessage();
$backtrace = $exception->getTrace();
// Add the line throwing the exception to the backtrace.
array_unshift($backtrace, array('line' => $exception->getLine(), 'file' => $exception->getFile()));
// For PDOException errors, we try to return the initial caller,
// skipping internal functions of the database layer.
if ($exception instanceof PDOException) {
// The first element in the stack is the call, the second element gives us the caller.
// We skip calls that occurred in one of the classes of the database layer
// or in one of its global functions.
$db_functions = array('db_query', 'db_query_range');
while (!empty($backtrace[1]) && ($caller = $backtrace[1]) &&
((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE)) ||
in_array($caller['function'], $db_functions))) {
// We remove that call.
array_shift($backtrace);
}
if (isset($exception->query_string, $exception->args)) {
$message .= ": " . $exception->query_string . "; " . print_r($exception->args, TRUE);
}
}
$caller = _drupal_get_last_caller($backtrace);
return array(
'%type' => get_class($exception),
// The standard PHP exception handler considers that the exception message
// is plain-text. We mimic this behavior here.
'!message' => check_plain($message),
'%function' => $caller['function'],
'%file' => $caller['file'],
'%line' => $caller['line'],
'severity_level' => WATCHDOG_ERROR,
);
}
/**
* Renders an exception error message without further exceptions.
*
* @param $exception
* The exception object that was thrown.
* @return
* An error message.
*/
function _drupal_render_exception_safe($exception) {
return check_plain(strtr('%type: !message in %function (line %line of %file).', _drupal_decode_exception($exception)));
}
/**
* Determines whether an error should be displayed.
*
* When in maintenance mode or when error_level is ERROR_REPORTING_DISPLAY_ALL,
* all errors should be displayed. For ERROR_REPORTING_DISPLAY_SOME, $error
* will be examined to determine if it should be displayed.
*
* @param $error
* Optional error to examine for ERROR_REPORTING_DISPLAY_SOME.
*
* @return
* TRUE if an error should be displayed.
*/
function error_displayable($error = NULL) {
$error_level = variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL);
$updating = (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update');
$all_errors_displayed = ($error_level == ERROR_REPORTING_DISPLAY_ALL);
$error_needs_display = ($error_level == ERROR_REPORTING_DISPLAY_SOME &&
isset($error) && $error['%type'] != 'Notice' && $error['%type'] != 'Strict warning');
return ($updating || $all_errors_displayed || $error_needs_display);
}
/**
* Logs a PHP error or exception and displays an error page in fatal cases.
*
* @param $error
* An array with the following keys: %type, !message, %function, %file, %line
* and severity_level. All the parameters are plain-text, with the exception
* of !message, which needs to be a safe HTML string.
* @param $fatal
* TRUE if the error is fatal.
*/
function _drupal_log_error($error, $fatal = FALSE) {
// Initialize a maintenance theme if the bootstrap was not complete.
// Do it early because drupal_set_message() triggers a drupal_theme_initialize().
if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
unset($GLOBALS['theme']);
if (!defined('MAINTENANCE_MODE')) {
define('MAINTENANCE_MODE', 'error');
}
drupal_maintenance_theme();
}
// When running inside the testing framework, we relay the errors
// to the tested site by the way of HTTP headers.
$test_info = &$GLOBALS['drupal_test_info'];
if (!empty($test_info['in_child_site']) && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
// $number does not use drupal_static as it should not be reset
// as it uniquely identifies each PHP error.
static $number = 0;
$assertion = array(
$error['!message'],
$error['%type'],
array(
'function' => $error['%function'],
'file' => $error['%file'],
'line' => $error['%line'],
),
);
header('X-Drupal-Assertion-' . $number . ': ' . rawurlencode(serialize($assertion)));
$number++;
}
// Log the error immediately, unless this is a non-fatal error which has been
// triggered via drupal_trigger_error_with_delayed_logging(); in that case
// trigger it in a shutdown function. Fatal errors are always triggered
// immediately since for a fatal error the page request will end here anyway.
if (!$fatal && drupal_static('_drupal_trigger_error_with_delayed_logging')) {
drupal_register_shutdown_function('watchdog', 'php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
}
else {
watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
}
if ($fatal) {
drupal_add_http_header('Status', '500 Service unavailable (with message)');
}
if (drupal_is_cli()) {
if ($fatal) {
// When called from CLI, simply output a plain text message.
print html_entity_decode(strip_tags(t('%type: !message in %function (line %line of %file).', $error))). "\n";
exit;
}
}
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
if ($fatal) {
if (error_displayable($error)) {
// When called from JavaScript, simply output the error message.
print t('%type: !message in %function (line %line of %file).', $error);
}
exit;
}
}
else {
// Display the message if the current error reporting level allows this type
// of message to be displayed, and unconditionally in update.php.
if (error_displayable($error)) {
$class = 'error';
// If error type is 'User notice' then treat it as debug information
// instead of an error message, see dd().
if ($error['%type'] == 'User notice') {
$error['%type'] = 'Debug';
$class = 'status';
}
drupal_set_message(t('%type: !message in %function (line %line of %file).', $error), $class);
}
if ($fatal) {
drupal_set_title(t('Error'));
// We fallback to a maintenance page at this point, because the page generation
// itself can generate errors.
print theme('maintenance_page', array('content' => t('The website encountered an unexpected error. Please try again later.')));
exit;
}
}
}
/**
* Gets the last caller from a backtrace.
*
* @param $backtrace
* A standard PHP backtrace.
*
* @return
* An associative array with keys 'file', 'line' and 'function'.
*/
function _drupal_get_last_caller($backtrace) {
// Errors that occur inside PHP internal functions do not generate
// information about file and line. Ignore black listed functions.
$blacklist = array('debug', '_drupal_error_handler', '_drupal_exception_handler');
while (($backtrace && !isset($backtrace[0]['line'])) ||
(isset($backtrace[1]['function']) && in_array($backtrace[1]['function'], $blacklist))) {
array_shift($backtrace);
}
// The first trace is the call itself.
// It gives us the line and the file of the last call.
$call = $backtrace[0];
// The second call give us the function where the call originated.
if (isset($backtrace[1])) {
if (isset($backtrace[1]['class'])) {
$call['function'] = $backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . '()';
}
else {
$call['function'] = $backtrace[1]['function'] . '()';
}
}
else {
$call['function'] = 'main()';
}
return $call;
}
+2639
View File
File diff suppressed because it is too large Load Diff
+879
View File
@@ -0,0 +1,879 @@
<?php
/**
* @file
* Provides mimetype mappings.
*/
/**
* Return an array of MIME extension mappings.
*
* Returns the mapping after modules have altered the default mapping.
*
* @return
* Array of mimetypes correlated to the extensions that relate to them.
*
* @see file_get_mimetype()
*/
function file_mimetype_mapping() {
$mapping = &drupal_static(__FUNCTION__);
if (!isset($mapping)) {
$mapping = file_default_mimetype_mapping();
// Allow modules to alter the default mapping.
drupal_alter('file_mimetype_mapping', $mapping);
}
return $mapping;
}
/**
* Default MIME extension mapping.
*
* @return
* Array of mimetypes correlated to the extensions that relate to them.
*
* @see file_get_mimetype()
*/
function file_default_mimetype_mapping() {
return array(
'mimetypes' => array(
0 => 'application/andrew-inset',
1 => 'application/atom',
2 => 'application/atomcat+xml',
3 => 'application/atomserv+xml',
4 => 'application/cap',
5 => 'application/cu-seeme',
6 => 'application/dsptype',
350 => 'application/epub+zip',
7 => 'application/hta',
8 => 'application/java-archive',
9 => 'application/java-serialized-object',
10 => 'application/java-vm',
11 => 'application/mac-binhex40',
12 => 'application/mathematica',
13 => 'application/msaccess',
14 => 'application/msword',
15 => 'application/octet-stream',
16 => 'application/oda',
17 => 'application/ogg',
18 => 'application/pdf',
19 => 'application/pgp-keys',
20 => 'application/pgp-signature',
21 => 'application/pics-rules',
22 => 'application/postscript',
23 => 'application/rar',
24 => 'application/rdf+xml',
25 => 'application/rss+xml',
26 => 'application/rtf',
27 => 'application/smil',
349 => 'application/vnd.amazon.ebook',
28 => 'application/vnd.cinderella',
29 => 'application/vnd.google-earth.kml+xml',
30 => 'application/vnd.google-earth.kmz',
31 => 'application/vnd.mozilla.xul+xml',
32 => 'application/vnd.ms-excel',
33 => 'application/vnd.ms-excel.addin.macroEnabled.12',
34 => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
35 => 'application/vnd.ms-excel.sheet.macroEnabled.12',
36 => 'application/vnd.ms-excel.template.macroEnabled.12',
37 => 'application/vnd.ms-pki.seccat',
38 => 'application/vnd.ms-pki.stl',
39 => 'application/vnd.ms-powerpoint',
40 => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
41 => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
42 => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
43 => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
44 => 'application/vnd.ms-word.document.macroEnabled.12',
45 => 'application/vnd.ms-word.template.macroEnabled.12',
46 => 'application/vnd.ms-xpsdocument',
47 => 'application/vnd.oasis.opendocument.chart',
48 => 'application/vnd.oasis.opendocument.database',
49 => 'application/vnd.oasis.opendocument.formula',
50 => 'application/vnd.oasis.opendocument.graphics',
51 => 'application/vnd.oasis.opendocument.graphics-template',
52 => 'application/vnd.oasis.opendocument.image',
53 => 'application/vnd.oasis.opendocument.presentation',
54 => 'application/vnd.oasis.opendocument.presentation-template',
55 => 'application/vnd.oasis.opendocument.spreadsheet',
56 => 'application/vnd.oasis.opendocument.spreadsheet-template',
57 => 'application/vnd.oasis.opendocument.text',
58 => 'application/vnd.oasis.opendocument.text-master',
59 => 'application/vnd.oasis.opendocument.text-template',
60 => 'application/vnd.oasis.opendocument.text-web',
61 => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
62 => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
63 => 'application/vnd.openxmlformats-officedocument.presentationml.template',
64 => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
65 => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
66 => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
67 => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
68 => 'application/vnd.rim.cod',
69 => 'application/vnd.smaf',
70 => 'application/vnd.stardivision.calc',
71 => 'application/vnd.stardivision.chart',
72 => 'application/vnd.stardivision.draw',
73 => 'application/vnd.stardivision.impress',
74 => 'application/vnd.stardivision.math',
75 => 'application/vnd.stardivision.writer',
76 => 'application/vnd.stardivision.writer-global',
77 => 'application/vnd.sun.xml.calc',
78 => 'application/vnd.sun.xml.calc.template',
79 => 'application/vnd.sun.xml.draw',
80 => 'application/vnd.sun.xml.draw.template',
81 => 'application/vnd.sun.xml.impress',
82 => 'application/vnd.sun.xml.impress.template',
83 => 'application/vnd.sun.xml.math',
84 => 'application/vnd.sun.xml.writer',
85 => 'application/vnd.sun.xml.writer.global',
86 => 'application/vnd.sun.xml.writer.template',
87 => 'application/vnd.symbian.install',
88 => 'application/vnd.visio',
89 => 'application/vnd.wap.wbxml',
90 => 'application/vnd.wap.wmlc',
91 => 'application/vnd.wap.wmlscriptc',
92 => 'application/wordperfect',
93 => 'application/wordperfect5.1',
94 => 'application/x-123',
95 => 'application/x-7z-compressed',
96 => 'application/x-abiword',
97 => 'application/x-apple-diskimage',
98 => 'application/x-bcpio',
99 => 'application/x-bittorrent',
100 => 'application/x-cab',
101 => 'application/x-cbr',
102 => 'application/x-cbz',
103 => 'application/x-cdf',
104 => 'application/x-cdlink',
105 => 'application/x-chess-pgn',
106 => 'application/x-cpio',
107 => 'application/x-debian-package',
108 => 'application/x-director',
109 => 'application/x-dms',
110 => 'application/x-doom',
111 => 'application/x-dvi',
112 => 'application/x-flac',
113 => 'application/x-font',
114 => 'application/x-freemind',
115 => 'application/x-futuresplash',
116 => 'application/x-gnumeric',
117 => 'application/x-go-sgf',
118 => 'application/x-graphing-calculator',
119 => 'application/x-gtar',
120 => 'application/x-hdf',
121 => 'application/x-httpd-eruby',
122 => 'application/x-httpd-php',
123 => 'application/x-httpd-php-source',
124 => 'application/x-httpd-php3',
125 => 'application/x-httpd-php3-preprocessed',
126 => 'application/x-httpd-php4',
127 => 'application/x-ica',
128 => 'application/x-internet-signup',
129 => 'application/x-iphone',
130 => 'application/x-iso9660-image',
131 => 'application/x-java-jnlp-file',
132 => 'application/x-javascript',
133 => 'application/x-jmol',
134 => 'application/x-kchart',
135 => 'application/x-killustrator',
136 => 'application/x-koan',
137 => 'application/x-kpresenter',
138 => 'application/x-kspread',
139 => 'application/x-kword',
140 => 'application/x-latex',
141 => 'application/x-lha',
142 => 'application/x-lyx',
143 => 'application/x-lzh',
144 => 'application/x-lzx',
145 => 'application/x-maker',
146 => 'application/x-mif',
351 => 'application/x-mobipocket-ebook',
352 => 'application/x-mobipocket-ebook',
147 => 'application/x-ms-wmd',
148 => 'application/x-ms-wmz',
149 => 'application/x-msdos-program',
150 => 'application/x-msi',
151 => 'application/x-netcdf',
152 => 'application/x-ns-proxy-autoconfig',
153 => 'application/x-nwc',
154 => 'application/x-object',
155 => 'application/x-oz-application',
156 => 'application/x-pkcs7-certreqresp',
157 => 'application/x-pkcs7-crl',
158 => 'application/x-python-code',
159 => 'application/x-quicktimeplayer',
160 => 'application/x-redhat-package-manager',
161 => 'application/x-shar',
162 => 'application/x-shockwave-flash',
163 => 'application/x-stuffit',
164 => 'application/x-sv4cpio',
165 => 'application/x-sv4crc',
166 => 'application/x-tar',
167 => 'application/x-tcl',
168 => 'application/x-tex-gf',
169 => 'application/x-tex-pk',
170 => 'application/x-texinfo',
171 => 'application/x-trash',
172 => 'application/x-troff',
173 => 'application/x-troff-man',
174 => 'application/x-troff-me',
175 => 'application/x-troff-ms',
176 => 'application/x-ustar',
177 => 'application/x-wais-source',
178 => 'application/x-wingz',
179 => 'application/x-x509-ca-cert',
180 => 'application/x-xcf',
181 => 'application/x-xfig',
182 => 'application/x-xpinstall',
183 => 'application/xhtml+xml',
184 => 'application/xml',
185 => 'application/zip',
186 => 'audio/basic',
187 => 'audio/midi',
346 => 'audio/mp4',
188 => 'audio/mpeg',
189 => 'audio/ogg',
190 => 'audio/prs.sid',
356 => 'audio/webm',
191 => 'audio/x-aiff',
192 => 'audio/x-gsm',
354 => 'audio/x-matroska',
193 => 'audio/x-mpegurl',
194 => 'audio/x-ms-wax',
195 => 'audio/x-ms-wma',
196 => 'audio/x-pn-realaudio',
197 => 'audio/x-realaudio',
198 => 'audio/x-scpls',
199 => 'audio/x-sd2',
200 => 'audio/x-wav',
201 => 'chemical/x-alchemy',
202 => 'chemical/x-cache',
203 => 'chemical/x-cache-csf',
204 => 'chemical/x-cactvs-binary',
205 => 'chemical/x-cdx',
206 => 'chemical/x-cerius',
207 => 'chemical/x-chem3d',
208 => 'chemical/x-chemdraw',
209 => 'chemical/x-cif',
210 => 'chemical/x-cmdf',
211 => 'chemical/x-cml',
212 => 'chemical/x-compass',
213 => 'chemical/x-crossfire',
214 => 'chemical/x-csml',
215 => 'chemical/x-ctx',
216 => 'chemical/x-cxf',
217 => 'chemical/x-embl-dl-nucleotide',
218 => 'chemical/x-galactic-spc',
219 => 'chemical/x-gamess-input',
220 => 'chemical/x-gaussian-checkpoint',
221 => 'chemical/x-gaussian-cube',
222 => 'chemical/x-gaussian-input',
223 => 'chemical/x-gaussian-log',
224 => 'chemical/x-gcg8-sequence',
225 => 'chemical/x-genbank',
226 => 'chemical/x-hin',
227 => 'chemical/x-isostar',
228 => 'chemical/x-jcamp-dx',
229 => 'chemical/x-kinemage',
230 => 'chemical/x-macmolecule',
231 => 'chemical/x-macromodel-input',
232 => 'chemical/x-mdl-molfile',
233 => 'chemical/x-mdl-rdfile',
234 => 'chemical/x-mdl-rxnfile',
235 => 'chemical/x-mdl-sdfile',
236 => 'chemical/x-mdl-tgf',
237 => 'chemical/x-mmcif',
238 => 'chemical/x-mol2',
239 => 'chemical/x-molconn-Z',
240 => 'chemical/x-mopac-graph',
241 => 'chemical/x-mopac-input',
242 => 'chemical/x-mopac-out',
243 => 'chemical/x-mopac-vib',
244 => 'chemical/x-ncbi-asn1-ascii',
245 => 'chemical/x-ncbi-asn1-binary',
246 => 'chemical/x-ncbi-asn1-spec',
247 => 'chemical/x-pdb',
248 => 'chemical/x-rosdal',
249 => 'chemical/x-swissprot',
250 => 'chemical/x-vamas-iso14976',
251 => 'chemical/x-vmd',
252 => 'chemical/x-xtel',
253 => 'chemical/x-xyz',
254 => 'image/gif',
255 => 'image/ief',
256 => 'image/jpeg',
257 => 'image/pcx',
258 => 'image/png',
259 => 'image/svg+xml',
260 => 'image/tiff',
261 => 'image/vnd.djvu',
262 => 'image/vnd.microsoft.icon',
263 => 'image/vnd.wap.wbmp',
355 => 'image/webp',
264 => 'image/x-cmu-raster',
265 => 'image/x-coreldraw',
266 => 'image/x-coreldrawpattern',
267 => 'image/x-coreldrawtemplate',
268 => 'image/x-corelphotopaint',
269 => 'image/x-jg',
270 => 'image/x-jng',
271 => 'image/x-ms-bmp',
272 => 'image/x-photoshop',
273 => 'image/x-portable-anymap',
274 => 'image/x-portable-bitmap',
275 => 'image/x-portable-graymap',
276 => 'image/x-portable-pixmap',
277 => 'image/x-rgb',
278 => 'image/x-xbitmap',
279 => 'image/x-xpixmap',
280 => 'image/x-xwindowdump',
281 => 'message/rfc822',
282 => 'model/iges',
283 => 'model/mesh',
284 => 'model/vrml',
285 => 'text/calendar',
286 => 'text/css',
287 => 'text/csv',
288 => 'text/h323',
289 => 'text/html',
290 => 'text/iuls',
291 => 'text/mathml',
292 => 'text/plain',
293 => 'text/richtext',
294 => 'text/scriptlet',
295 => 'text/tab-separated-values',
296 => 'text/texmacs',
297 => 'text/vnd.sun.j2me.app-descriptor',
298 => 'text/vnd.wap.wml',
299 => 'text/vnd.wap.wmlscript',
358 => 'text/vtt',
300 => 'text/x-bibtex',
301 => 'text/x-boo',
302 => 'text/x-c++hdr',
303 => 'text/x-c++src',
304 => 'text/x-chdr',
305 => 'text/x-component',
306 => 'text/x-csh',
307 => 'text/x-csrc',
308 => 'text/x-diff',
309 => 'text/x-dsrc',
310 => 'text/x-haskell',
311 => 'text/x-java',
312 => 'text/x-literate-haskell',
313 => 'text/x-moc',
314 => 'text/x-pascal',
315 => 'text/x-pcs-gcd',
316 => 'text/x-perl',
317 => 'text/x-python',
318 => 'text/x-setext',
319 => 'text/x-sh',
320 => 'text/x-tcl',
321 => 'text/x-tex',
322 => 'text/x-vcalendar',
323 => 'text/x-vcard',
324 => 'video/3gpp',
325 => 'video/dl',
326 => 'video/dv',
327 => 'video/fli',
328 => 'video/gl',
329 => 'video/mp4',
330 => 'video/mpeg',
331 => 'video/ogg',
332 => 'video/quicktime',
333 => 'video/vnd.mpegurl',
357 => 'video/webm',
347 => 'video/x-flv',
334 => 'video/x-la-asf',
348 => 'video/x-m4v',
353 => 'video/x-matroska',
335 => 'video/x-mng',
336 => 'video/x-ms-asf',
337 => 'video/x-ms-wm',
338 => 'video/x-ms-wmv',
339 => 'video/x-ms-wmx',
340 => 'video/x-ms-wvx',
341 => 'video/x-msvideo',
342 => 'video/x-sgi-movie',
343 => 'x-conference/x-cooltalk',
344 => 'x-epoc/x-sisx-app',
345 => 'x-world/x-vrml',
),
// Extensions added to this list MUST be lower-case.
'extensions' => array(
'ez' => 0,
'atom' => 1,
'atomcat' => 2,
'atomsrv' => 3,
'cap' => 4,
'pcap' => 4,
'cu' => 5,
'tsp' => 6,
'hta' => 7,
'jar' => 8,
'ser' => 9,
'class' => 10,
'hqx' => 11,
'nb' => 12,
'mdb' => 13,
'dot' => 14,
'doc' => 14,
'bin' => 15,
'oda' => 16,
'ogx' => 17,
'pdf' => 18,
'key' => 19,
'pgp' => 20,
'prf' => 21,
'eps' => 22,
'ai' => 22,
'ps' => 22,
'rar' => 23,
'rdf' => 24,
'rss' => 25,
'rtf' => 26,
'smi' => 27,
'smil' => 27,
'cdy' => 28,
'kml' => 29,
'kmz' => 30,
'xul' => 31,
'xlb' => 32,
'xlt' => 32,
'xls' => 32,
'xlam' => 33,
'xlsb' => 34,
'xlsm' => 35,
'xltm' => 36,
'cat' => 37,
'stl' => 38,
'pps' => 39,
'ppt' => 39,
'ppam' => 40,
'pptm' => 41,
'ppsm' => 42,
'potm' => 43,
'docm' => 44,
'dotm' => 45,
'xps' => 46,
'odc' => 47,
'odb' => 48,
'odf' => 49,
'odg' => 50,
'otg' => 51,
'odi' => 52,
'odp' => 53,
'otp' => 54,
'ods' => 55,
'ots' => 56,
'odt' => 57,
'odm' => 58,
'ott' => 59,
'oth' => 60,
'pptx' => 61,
'ppsx' => 62,
'potx' => 63,
'xlsx' => 64,
'xltx' => 65,
'docx' => 66,
'dotx' => 67,
'cod' => 68,
'mmf' => 69,
'sdc' => 70,
'sds' => 71,
'sda' => 72,
'sdd' => 73,
'sdw' => 75,
'sgl' => 76,
'sxc' => 77,
'stc' => 78,
'sxd' => 79,
'std' => 80,
'sxi' => 81,
'sti' => 82,
'sxm' => 83,
'sxw' => 84,
'sxg' => 85,
'stw' => 86,
'sis' => 87,
'vsd' => 88,
'wbxml' => 89,
'wmlc' => 90,
'wmlsc' => 91,
'wpd' => 92,
'wp5' => 93,
'wk' => 94,
'7z' => 95,
'abw' => 96,
'dmg' => 97,
'bcpio' => 98,
'torrent' => 99,
'cab' => 100,
'cbr' => 101,
'cbz' => 102,
'cdf' => 103,
'vcd' => 104,
'pgn' => 105,
'cpio' => 106,
'udeb' => 107,
'deb' => 107,
'dir' => 108,
'dxr' => 108,
'dcr' => 108,
'dms' => 109,
'wad' => 110,
'dvi' => 111,
'flac' => 112,
'pfa' => 113,
'pfb' => 113,
'pcf' => 113,
'gsf' => 113,
'pcf.z' => 113,
'mm' => 114,
'spl' => 115,
'gnumeric' => 116,
'sgf' => 117,
'gcf' => 118,
'taz' => 119,
'gtar' => 119,
'tgz' => 119,
'hdf' => 120,
'rhtml' => 121,
'phtml' => 122,
'pht' => 122,
'php' => 122,
'phps' => 123,
'php3' => 124,
'php3p' => 125,
'php4' => 126,
'ica' => 127,
'ins' => 128,
'isp' => 128,
'iii' => 129,
'iso' => 130,
'jnlp' => 131,
'js' => 132,
'jmz' => 133,
'chrt' => 134,
'kil' => 135,
'skp' => 136,
'skd' => 136,
'skm' => 136,
'skt' => 136,
'kpr' => 137,
'kpt' => 137,
'ksp' => 138,
'kwd' => 139,
'kwt' => 139,
'latex' => 140,
'lha' => 141,
'lyx' => 142,
'lzh' => 143,
'lzx' => 144,
'maker' => 145,
'frm' => 145,
'frame' => 145,
'fm' => 145,
'book' => 145,
'fb' => 145,
'fbdoc' => 145,
'mif' => 146,
'wmd' => 147,
'wmz' => 148,
'dll' => 149,
'bat' => 149,
'exe' => 149,
'com' => 149,
'msi' => 150,
'nc' => 151,
'pac' => 152,
'nwc' => 153,
'o' => 154,
'oza' => 155,
'p7r' => 156,
'crl' => 157,
'pyo' => 158,
'pyc' => 158,
'qtl' => 159,
'rpm' => 160,
'shar' => 161,
'swf' => 162,
'swfl' => 162,
'sitx' => 163,
'sit' => 163,
'sv4cpio' => 164,
'sv4crc' => 165,
'tar' => 166,
'gf' => 168,
'pk' => 169,
'texi' => 170,
'texinfo' => 170,
'sik' => 171,
'~' => 171,
'bak' => 171,
'%' => 171,
'old' => 171,
't' => 172,
'roff' => 172,
'tr' => 172,
'man' => 173,
'me' => 174,
'ms' => 175,
'ustar' => 176,
'src' => 177,
'wz' => 178,
'crt' => 179,
'xcf' => 180,
'fig' => 181,
'xpi' => 182,
'xht' => 183,
'xhtml' => 183,
'xml' => 184,
'xsl' => 184,
'zip' => 185,
'au' => 186,
'snd' => 186,
'mid' => 187,
'midi' => 187,
'kar' => 187,
'mpega' => 188,
'mpga' => 188,
'm4a' => 188,
'mp3' => 188,
'mp2' => 188,
'ogg' => 189,
'oga' => 189,
'spx' => 189,
'sid' => 190,
'aif' => 191,
'aiff' => 191,
'aifc' => 191,
'gsm' => 192,
'm3u' => 193,
'wax' => 194,
'wma' => 195,
'rm' => 196,
'ram' => 196,
'ra' => 197,
'pls' => 198,
'sd2' => 199,
'wav' => 200,
'alc' => 201,
'cac' => 202,
'cache' => 202,
'csf' => 203,
'cascii' => 204,
'cbin' => 204,
'ctab' => 204,
'cdx' => 205,
'cer' => 206,
'c3d' => 207,
'chm' => 208,
'cif' => 209,
'cmdf' => 210,
'cml' => 211,
'cpa' => 212,
'bsd' => 213,
'csml' => 214,
'csm' => 214,
'ctx' => 215,
'cxf' => 216,
'cef' => 216,
'emb' => 217,
'embl' => 217,
'spc' => 218,
'gam' => 219,
'inp' => 219,
'gamin' => 219,
'fchk' => 220,
'fch' => 220,
'cub' => 221,
'gau' => 222,
'gjf' => 222,
'gjc' => 222,
'gal' => 223,
'gcg' => 224,
'gen' => 225,
'hin' => 226,
'istr' => 227,
'ist' => 227,
'dx' => 228,
'jdx' => 228,
'kin' => 229,
'mcm' => 230,
'mmd' => 231,
'mmod' => 231,
'mol' => 232,
'rd' => 233,
'rxn' => 234,
'sdf' => 235,
'sd' => 235,
'tgf' => 236,
'mcif' => 237,
'mol2' => 238,
'b' => 239,
'gpt' => 240,
'mopcrt' => 241,
'zmt' => 241,
'mpc' => 241,
'dat' => 241,
'mop' => 241,
'moo' => 242,
'mvb' => 243,
'prt' => 244,
'aso' => 245,
'val' => 245,
'asn' => 246,
'ent' => 247,
'pdb' => 247,
'ros' => 248,
'sw' => 249,
'vms' => 250,
'vmd' => 251,
'xtel' => 252,
'xyz' => 253,
'gif' => 254,
'ief' => 255,
'jpeg' => 256,
'jpe' => 256,
'jpg' => 256,
'pcx' => 257,
'png' => 258,
'svgz' => 259,
'svg' => 259,
'tif' => 260,
'tiff' => 260,
'djvu' => 261,
'djv' => 261,
'ico' => 262,
'wbmp' => 263,
'ras' => 264,
'cdr' => 265,
'pat' => 266,
'cdt' => 267,
'cpt' => 268,
'art' => 269,
'jng' => 270,
'bmp' => 271,
'psd' => 272,
'pnm' => 273,
'pbm' => 274,
'pgm' => 275,
'ppm' => 276,
'rgb' => 277,
'xbm' => 278,
'xpm' => 279,
'xwd' => 280,
'eml' => 281,
'igs' => 282,
'iges' => 282,
'silo' => 283,
'msh' => 283,
'mesh' => 283,
'icz' => 285,
'ics' => 285,
'css' => 286,
'csv' => 287,
'323' => 288,
'html' => 289,
'htm' => 289,
'shtml' => 289,
'uls' => 290,
'mml' => 291,
'txt' => 292,
'pot' => 292,
'text' => 292,
'asc' => 292,
'rtx' => 293,
'wsc' => 294,
'sct' => 294,
'tsv' => 295,
'ts' => 296,
'tm' => 296,
'jad' => 297,
'wml' => 298,
'wmls' => 299,
'bib' => 300,
'boo' => 301,
'hpp' => 302,
'hh' => 302,
'h++' => 302,
'hxx' => 302,
'cxx' => 303,
'cc' => 303,
'cpp' => 303,
'c++' => 303,
'h' => 304,
'htc' => 305,
'csh' => 306,
'c' => 307,
'patch' => 308,
'diff' => 308,
'd' => 309,
'hs' => 310,
'java' => 311,
'lhs' => 312,
'moc' => 313,
'pas' => 314,
'p' => 314,
'gcd' => 315,
'pm' => 316,
'pl' => 316,
'py' => 317,
'etx' => 318,
'sh' => 319,
'tk' => 320,
'tcl' => 320,
'cls' => 321,
'ltx' => 321,
'sty' => 321,
'tex' => 321,
'vcs' => 322,
'vcf' => 323,
'3gp' => 324,
'dl' => 325,
'dif' => 326,
'dv' => 326,
'fli' => 327,
'gl' => 328,
'mp4' => 329,
'f4v' => 329,
'f4p' => 329,
'mpe' => 330,
'mpeg' => 330,
'mpg' => 330,
'ogv' => 331,
'qt' => 332,
'mov' => 332,
'mxu' => 333,
'lsf' => 334,
'lsx' => 334,
'mng' => 335,
'asx' => 336,
'asf' => 336,
'wm' => 337,
'wmv' => 338,
'wmx' => 339,
'wvx' => 340,
'avi' => 341,
'movie' => 342,
'ice' => 343,
'sisx' => 344,
'wrl' => 345,
'vrm' => 345,
'vrml' => 345,
'f4a' => 346,
'f4b' => 346,
'flv' => 347,
'm4v' => 348,
'azw' => 349,
'epub' => 350,
'mobi' => 351,
'prc' => 352,
'mkv' => 353,
'mka' => 354,
'webp' => 355,
'weba' => 356,
'webm' => 357,
'vtt' => 358,
),
);
}
+55
View File
@@ -0,0 +1,55 @@
<?php
use Drupal\Core\Security\PharExtensionInterceptor;
use TYPO3\PharStreamWrapper\Manager as PharStreamWrapperManager;
use TYPO3\PharStreamWrapper\Behavior as PharStreamWrapperBehavior;
use TYPO3\PharStreamWrapper\PharStreamWrapper;
/**
* Registers a phar stream wrapper that is more secure than PHP's built-in one.
*
* @see file_get_stream_wrappers()
*/
function file_register_phar_wrapper() {
$directory = DRUPAL_ROOT . '/misc/typo3/phar-stream-wrapper/src';
include_once $directory . '/Assertable.php';
include_once $directory . '/Behavior.php';
include_once $directory . '/Exception.php';
include_once $directory . '/Helper.php';
include_once $directory . '/Manager.php';
include_once $directory . '/PharStreamWrapper.php';
include_once $directory . '/Collectable.php';
include_once $directory . '/Interceptor/ConjunctionInterceptor.php';
include_once $directory . '/Interceptor/PharMetaDataInterceptor.php';
include_once $directory . '/Phar/Container.php';
include_once $directory . '/Phar/DeserializationException.php';
include_once $directory . '/Phar/Manifest.php';
include_once $directory . '/Phar/Reader.php';
include_once $directory . '/Phar/ReaderException.php';
include_once $directory . '/Phar/Stub.php';
include_once $directory . '/Resolvable.php';
include_once $directory . '/Resolver/PharInvocation.php';
include_once $directory . '/Resolver/PharInvocationCollection.php';
include_once $directory . '/Resolver/PharInvocationResolver.php';
include_once DRUPAL_ROOT . '/misc/typo3/drupal-security/PharExtensionInterceptor.php';
include_once DRUPAL_ROOT . '/misc/brumann/polyfill-unserialize/src/Unserialize.php';
// Set up a stream wrapper to handle insecurities due to PHP's built-in
// phar stream wrapper.
try {
$behavior = new PharStreamWrapperBehavior();
PharStreamWrapperManager::initialize(
$behavior->withAssertion(new PharExtensionInterceptor())
);
}
catch (\LogicException $e) {
// Continue if the PharStreamWrapperManager is already initialized.
// For example, this occurs following a drupal_static_reset(), such
// as during tests.
};
// To prevent file_stream_wrapper_valid_scheme() treating "phar" as a valid
// scheme, this is registered with PHP only, not with hook_stream_wrappers()
// or the internal storage of file_get_stream_wrappers().
stream_wrapper_register('phar', '\\TYPO3\\PharStreamWrapper\\PharStreamWrapper');
}
+427
View File
@@ -0,0 +1,427 @@
<?php
/*
* Base FileTransfer class.
*
* Classes extending this class perform file operations on directories not
* writable by the webserver. To achieve this, the class should connect back
* to the server using some backend (for example FTP or SSH). To keep security,
* the password should always be asked from the user and never stored. For
* safety, all methods operate only inside a "jail", by default the Drupal root.
*/
abstract class FileTransfer {
protected $username;
protected $password;
protected $hostname = 'localhost';
protected $port;
/**
* The constructor for the UpdateConnection class. This method is also called
* from the classes that extend this class and override this method.
*/
function __construct($jail) {
$this->jail = $jail;
}
/**
* Classes that extend this class must override the factory() static method.
*
* @param string $jail
* The full path where all file operations performed by this object will
* be restricted to. This prevents the FileTransfer classes from being
* able to touch other parts of the filesystem.
* @param array $settings
* An array of connection settings for the FileTransfer subclass. If the
* getSettingsForm() method uses any nested settings, the same structure
* will be assumed here.
* @return object
* New instance of the appropriate FileTransfer subclass.
*/
static function factory($jail, $settings) {
throw new FileTransferException('FileTransfer::factory() static method not overridden by FileTransfer subclass.');
}
/**
* Implementation of the magic __get() method.
*
* If the connection isn't set to anything, this will call the connect() method
* and set it to and return the result; afterwards, the connection will be
* returned directly without using this method.
*/
function __get($name) {
if ($name == 'connection') {
$this->connect();
return $this->connection;
}
if ($name == 'chroot') {
$this->setChroot();
return $this->chroot;
}
}
/**
* Connect to the server.
*/
abstract protected function connect();
/**
* Copies a directory.
*
* @param $source
* The source path.
* @param $destination
* The destination path.
*/
public final function copyDirectory($source, $destination) {
$source = $this->sanitizePath($source);
$destination = $this->fixRemotePath($destination);
$this->checkPath($destination);
$this->copyDirectoryJailed($source, $destination);
}
/**
* @see http://php.net/chmod
*
* @param string $path
* @param long $mode
* @param bool $recursive
*/
public final function chmod($path, $mode, $recursive = FALSE) {
if (!in_array('FileTransferChmodInterface', class_implements(get_class($this)))) {
throw new FileTransferException('Unable to change file permissions');
}
$path = $this->sanitizePath($path);
$path = $this->fixRemotePath($path);
$this->checkPath($path);
$this->chmodJailed($path, $mode, $recursive);
}
/**
* Creates a directory.
*
* @param $directory
* The directory to be created.
*/
public final function createDirectory($directory) {
$directory = $this->fixRemotePath($directory);
$this->checkPath($directory);
$this->createDirectoryJailed($directory);
}
/**
* Removes a directory.
*
* @param $directory
* The directory to be removed.
*/
public final function removeDirectory($directory) {
$directory = $this->fixRemotePath($directory);
$this->checkPath($directory);
$this->removeDirectoryJailed($directory);
}
/**
* Copies a file.
*
* @param $source
* The source file.
* @param $destination
* The destination file.
*/
public final function copyFile($source, $destination) {
$source = $this->sanitizePath($source);
$destination = $this->fixRemotePath($destination);
$this->checkPath($destination);
$this->copyFileJailed($source, $destination);
}
/**
* Removes a file.
*
* @param $destination
* The destination file to be removed.
*/
public final function removeFile($destination) {
$destination = $this->fixRemotePath($destination);
$this->checkPath($destination);
$this->removeFileJailed($destination);
}
/**
* Checks that the path is inside the jail and throws an exception if not.
*
* @param $path
* A path to check against the jail.
*/
protected final function checkPath($path) {
$full_jail = $this->chroot . $this->jail;
$full_path = drupal_realpath(substr($this->chroot . $path, 0, strlen($full_jail)));
$full_path = $this->fixRemotePath($full_path, FALSE);
if ($full_jail !== $full_path) {
throw new FileTransferException('@directory is outside of the @jail', NULL, array('@directory' => $path, '@jail' => $this->jail));
}
}
/**
* Returns a modified path suitable for passing to the server.
* If a path is a windows path, makes it POSIX compliant by removing the drive letter.
* If $this->chroot has a value, it is stripped from the path to allow for
* chroot'd filetransfer systems.
*
* @param $path
* @param $strip_chroot
*
* @return string
*/
protected final function fixRemotePath($path, $strip_chroot = TRUE) {
$path = $this->sanitizePath($path);
$path = preg_replace('|^([a-z]{1}):|i', '', $path); // Strip out windows driveletter if its there.
if ($strip_chroot) {
if ($this->chroot && strpos($path, $this->chroot) === 0) {
$path = ($path == $this->chroot) ? '' : substr($path, strlen($this->chroot));
}
}
return $path;
}
/**
* Changes backslashes to slashes, also removes a trailing slash.
*
* @param string $path
* @return string
*/
function sanitizePath($path) {
$path = str_replace('\\', '/', $path); // Windows path sanitization.
if (substr($path, -1) == '/') {
$path = substr($path, 0, -1);
}
return $path;
}
/**
* Copies a directory.
*
* We need a separate method to make the $destination is in the jail.
*
* @param $source
* The source path.
* @param $destination
* The destination path.
*/
protected function copyDirectoryJailed($source, $destination) {
if ($this->isDirectory($destination)) {
$destination = $destination . '/' . drupal_basename($source);
}
$this->createDirectory($destination);
foreach (new RecursiveIteratorIterator(new SkipDotsRecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
$relative_path = substr($filename, strlen($source));
if ($file->isDir()) {
$this->createDirectory($destination . $relative_path);
}
else {
$this->copyFile($file->getPathName(), $destination . $relative_path);
}
}
}
/**
* Creates a directory.
*
* @param $directory
* The directory to be created.
*/
abstract protected function createDirectoryJailed($directory);
/**
* Removes a directory.
*
* @param $directory
* The directory to be removed.
*/
abstract protected function removeDirectoryJailed($directory);
/**
* Copies a file.
*
* @param $source
* The source file.
* @param $destination
* The destination file.
*/
abstract protected function copyFileJailed($source, $destination);
/**
* Removes a file.
*
* @param $destination
* The destination file to be removed.
*/
abstract protected function removeFileJailed($destination);
/**
* Checks if a particular path is a directory
*
* @param $path
* The path to check
*
* @return boolean
*/
abstract public function isDirectory($path);
/**
* Checks if a particular path is a file (not a directory).
*
* @param $path
* The path to check
*
* @return boolean
*/
abstract public function isFile($path);
/**
* Return the chroot property for this connection.
*
* It does this by moving up the tree until it finds itself. If successful,
* it will return the chroot, otherwise FALSE.
*
* @return
* The chroot path for this connection or FALSE.
*/
function findChroot() {
// If the file exists as is, there is no chroot.
$path = __FILE__;
$path = $this->fixRemotePath($path, FALSE);
if ($this->isFile($path)) {
return FALSE;
}
$path = dirname(__FILE__);
$path = $this->fixRemotePath($path, FALSE);
$parts = explode('/', $path);
$chroot = '';
while (count($parts)) {
$check = implode('/', $parts);
if ($this->isFile($check . '/' . drupal_basename(__FILE__))) {
// Remove the trailing slash.
return substr($chroot, 0, -1);
}
$chroot .= array_shift($parts) . '/';
}
return FALSE;
}
/**
* Sets the chroot and changes the jail to match the correct path scheme
*
*/
function setChroot() {
$this->chroot = $this->findChroot();
$this->jail = $this->fixRemotePath($this->jail);
}
/**
* Returns a form to collect connection settings credentials.
*
* Implementing classes can either extend this form with fields collecting the
* specific information they need, or override it entirely.
*/
public function getSettingsForm() {
$form['username'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
);
$form['password'] = array(
'#type' => 'password',
'#title' => t('Password'),
'#description' => t('Your password is not saved in the database and is only used to establish a connection.'),
);
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['advanced']['hostname'] = array(
'#type' => 'textfield',
'#title' => t('Host'),
'#default_value' => 'localhost',
'#description' => t('The connection will be created between your web server and the machine hosting the web server files. In the vast majority of cases, this will be the same machine, and "localhost" is correct.'),
);
$form['advanced']['port'] = array(
'#type' => 'textfield',
'#title' => t('Port'),
'#default_value' => NULL,
);
return $form;
}
}
/**
* FileTransferException class.
*/
class FileTransferException extends Exception {
public $arguments;
function __construct($message, $code = 0, $arguments = array()) {
parent::__construct($message, $code);
$this->arguments = $arguments;
}
}
/**
* A FileTransfer Class implementing this interface can be used to chmod files.
*/
interface FileTransferChmodInterface {
/**
* Changes the permissions of the file / directory specified in $path
*
* @param string $path
* Path to change permissions of.
* @param long $mode
* The new file permission mode to be passed to chmod().
* @param boolean $recursive
* Pass TRUE to recursively chmod the entire directory specified in $path.
*/
function chmodJailed($path, $mode, $recursive);
}
/**
* Provides an interface for iterating recursively over filesystem directories.
*
* Manually skips '.' and '..' directories, since no existing method is
* available in PHP 5.2.
*
* @todo Depreciate in favor of RecursiveDirectoryIterator::SKIP_DOTS once PHP
* 5.3 or later is required.
*/
class SkipDotsRecursiveDirectoryIterator extends RecursiveDirectoryIterator {
/**
* Constructs a SkipDotsRecursiveDirectoryIterator
*
* @param $path
* The path of the directory to be iterated over.
*/
function __construct($path) {
parent::__construct($path);
$this->skipdots();
}
function rewind() {
parent::rewind();
$this->skipdots();
}
function next() {
parent::next();
$this->skipdots();
}
protected function skipdots() {
while ($this->isDot()) {
parent::next();
}
}
}
+144
View File
@@ -0,0 +1,144 @@
<?php
/**
* Base class for FTP implementations.
*/
abstract class FileTransferFTP extends FileTransfer {
public function __construct($jail, $username, $password, $hostname, $port) {
$this->username = $username;
$this->password = $password;
$this->hostname = $hostname;
$this->port = $port;
parent::__construct($jail);
}
/**
* Return an object which can implement the FTP protocol.
*
* @param string $jail
* @param array $settings
* @return FileTransferFTP
* The appropriate FileTransferFTP subclass based on the available
* options. If the FTP PHP extension is available, use it.
*/
static function factory($jail, $settings) {
$username = empty($settings['username']) ? '' : $settings['username'];
$password = empty($settings['password']) ? '' : $settings['password'];
$hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname'];
$port = empty($settings['advanced']['port']) ? 21 : $settings['advanced']['port'];
if (function_exists('ftp_connect')) {
$class = 'FileTransferFTPExtension';
}
else {
throw new FileTransferException('No FTP backend available.');
}
return new $class($jail, $username, $password, $hostname, $port);
}
/**
* Returns the form to configure the FileTransfer class for FTP.
*/
public function getSettingsForm() {
$form = parent::getSettingsForm();
$form['advanced']['port']['#default_value'] = 21;
return $form;
}
}
class FileTransferFTPExtension extends FileTransferFTP implements FileTransferChmodInterface {
public function connect() {
$this->connection = ftp_connect($this->hostname, $this->port);
if (!$this->connection) {
throw new FileTransferException("Cannot connect to FTP Server, check settings");
}
if (!ftp_login($this->connection, $this->username, $this->password)) {
throw new FileTransferException("Cannot log in to FTP server. Check username and password");
}
}
protected function copyFileJailed($source, $destination) {
if (!@ftp_put($this->connection, $destination, $source, FTP_BINARY)) {
throw new FileTransferException("Cannot move @source to @destination", NULL, array("@source" => $source, "@destination" => $destination));
}
}
protected function createDirectoryJailed($directory) {
if (!ftp_mkdir($this->connection, $directory)) {
throw new FileTransferException("Cannot create directory @directory", NULL, array("@directory" => $directory));
}
}
protected function removeDirectoryJailed($directory) {
$pwd = ftp_pwd($this->connection);
if (!ftp_chdir($this->connection, $directory)) {
throw new FileTransferException("Unable to change to directory @directory", NULL, array('@directory' => $directory));
}
$list = @ftp_nlist($this->connection, '.');
if (!$list) {
$list = array();
}
foreach ($list as $item) {
if ($item == '.' || $item == '..') {
continue;
}
if (@ftp_chdir($this->connection, $item)) {
ftp_cdup($this->connection);
$this->removeDirectory(ftp_pwd($this->connection) . '/' . $item);
}
else {
$this->removeFile(ftp_pwd($this->connection) . '/' . $item);
}
}
ftp_chdir($this->connection, $pwd);
if (!ftp_rmdir($this->connection, $directory)) {
throw new FileTransferException("Unable to remove to directory @directory", NULL, array('@directory' => $directory));
}
}
protected function removeFileJailed($destination) {
if (!ftp_delete($this->connection, $destination)) {
throw new FileTransferException("Unable to remove to file @file", NULL, array('@file' => $destination));
}
}
public function isDirectory($path) {
$result = FALSE;
$curr = ftp_pwd($this->connection);
if (@ftp_chdir($this->connection, $path)) {
$result = TRUE;
}
ftp_chdir($this->connection, $curr);
return $result;
}
public function isFile($path) {
return ftp_size($this->connection, $path) != -1;
}
function chmodJailed($path, $mode, $recursive) {
if (!ftp_chmod($this->connection, $mode, $path)) {
throw new FileTransferException("Unable to set permissions on %file", NULL, array('%file' => $path));
}
if ($this->isDirectory($path) && $recursive) {
$filelist = @ftp_nlist($this->connection, $path);
if (!$filelist) {
//empty directory - returns false
return;
}
foreach ($filelist as $file) {
$this->chmodJailed($file, $mode, $recursive);
}
}
}
}
if (!function_exists('ftp_chmod')) {
function ftp_chmod($ftp_stream, $mode, $filename) {
return ftp_site($ftp_stream, sprintf('CHMOD %o %s', $mode, $filename));
}
}
+76
View File
@@ -0,0 +1,76 @@
<?php
/**
* The local connection class for copying files as the httpd user.
*/
class FileTransferLocal extends FileTransfer implements FileTransferChmodInterface {
function connect() {
// No-op
}
static function factory($jail, $settings) {
return new FileTransferLocal($jail);
}
protected function copyFileJailed($source, $destination) {
if (@!copy($source, $destination)) {
throw new FileTransferException('Cannot copy %source to %destination.', NULL, array('%source' => $source, '%destination' => $destination));
}
}
protected function createDirectoryJailed($directory) {
if (!is_dir($directory) && @!mkdir($directory, 0777, TRUE)) {
throw new FileTransferException('Cannot create directory %directory.', NULL, array('%directory' => $directory));
}
}
protected function removeDirectoryJailed($directory) {
if (!is_dir($directory)) {
// Programmer error assertion, not something we expect users to see.
throw new FileTransferException('removeDirectoryJailed() called with a path (%directory) that is not a directory.', NULL, array('%directory' => $directory));
}
foreach (new RecursiveIteratorIterator(new SkipDotsRecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) {
if ($file->isDir()) {
if (@!drupal_rmdir($filename)) {
throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $filename));
}
}
elseif ($file->isFile()) {
if (@!drupal_unlink($filename)) {
throw new FileTransferException('Cannot remove file %file.', NULL, array('%file' => $filename));
}
}
}
if (@!drupal_rmdir($directory)) {
throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $directory));
}
}
protected function removeFileJailed($file) {
if (@!drupal_unlink($file)) {
throw new FileTransferException('Cannot remove file %file.', NULL, array('%file' => $file));
}
}
public function isDirectory($path) {
return is_dir($path);
}
public function isFile($path) {
return is_file($path);
}
public function chmodJailed($path, $mode, $recursive) {
if ($recursive && is_dir($path)) {
foreach (new RecursiveIteratorIterator(new SkipDotsRecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
if (@!chmod($filename, $mode)) {
throw new FileTransferException('Cannot chmod %path.', NULL, array('%path' => $filename));
}
}
}
elseif (@!chmod($path, $mode)) {
throw new FileTransferException('Cannot chmod %path.', NULL, array('%path' => $path));
}
}
}
+110
View File
@@ -0,0 +1,110 @@
<?php
/**
* The SSH connection class for the update module.
*/
class FileTransferSSH extends FileTransfer implements FileTransferChmodInterface {
function __construct($jail, $username, $password, $hostname = "localhost", $port = 22) {
$this->username = $username;
$this->password = $password;
$this->hostname = $hostname;
$this->port = $port;
parent::__construct($jail);
}
function connect() {
$this->connection = @ssh2_connect($this->hostname, $this->port);
if (!$this->connection) {
throw new FileTransferException('SSH Connection failed to @host:@port', NULL, array('@host' => $this->hostname, '@port' => $this->port));
}
if (!@ssh2_auth_password($this->connection, $this->username, $this->password)) {
throw new FileTransferException('The supplied username/password combination was not accepted.');
}
}
static function factory($jail, $settings) {
$username = empty($settings['username']) ? '' : $settings['username'];
$password = empty($settings['password']) ? '' : $settings['password'];
$hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname'];
$port = empty($settings['advanced']['port']) ? 22 : $settings['advanced']['port'];
return new FileTransferSSH($jail, $username, $password, $hostname, $port);
}
protected function copyFileJailed($source, $destination) {
if (!@ssh2_scp_send($this->connection, $source, $destination)) {
throw new FileTransferException('Cannot copy @source_file to @destination_file.', NULL, array('@source' => $source, '@destination' => $destination));
}
}
protected function copyDirectoryJailed($source, $destination) {
if (@!ssh2_exec($this->connection, 'cp -Rp ' . escapeshellarg($source) . ' ' . escapeshellarg($destination))) {
throw new FileTransferException('Cannot copy directory @directory.', NULL, array('@directory' => $source));
}
}
protected function createDirectoryJailed($directory) {
if (@!ssh2_exec($this->connection, 'mkdir ' . escapeshellarg($directory))) {
throw new FileTransferException('Cannot create directory @directory.', NULL, array('@directory' => $directory));
}
}
protected function removeDirectoryJailed($directory) {
if (@!ssh2_exec($this->connection, 'rm -Rf ' . escapeshellarg($directory))) {
throw new FileTransferException('Cannot remove @directory.', NULL, array('@directory' => $directory));
}
}
protected function removeFileJailed($destination) {
if (!@ssh2_exec($this->connection, 'rm ' . escapeshellarg($destination))) {
throw new FileTransferException('Cannot remove @directory.', NULL, array('@directory' => $destination));
}
}
/**
* WARNING: This is untested. It is not currently used, but should do the trick.
*/
public function isDirectory($path) {
$directory = escapeshellarg($path);
$cmd = "[ -d {$directory} ] && echo 'yes'";
if ($output = @ssh2_exec($this->connection, $cmd)) {
if ($output == 'yes') {
return TRUE;
}
return FALSE;
}
else {
throw new FileTransferException('Cannot check @path.', NULL, array('@path' => $path));
}
}
public function isFile($path) {
$file = escapeshellarg($path);
$cmd = "[ -f {$file} ] && echo 'yes'";
if ($output = @ssh2_exec($this->connection, $cmd)) {
if ($output == 'yes') {
return TRUE;
}
return FALSE;
}
else {
throw new FileTransferException('Cannot check @path.', NULL, array('@path' => $path));
}
}
function chmodJailed($path, $mode, $recursive) {
$cmd = sprintf("chmod %s%o %s", $recursive ? '-R ' : '', $mode, escapeshellarg($path));
if (@!ssh2_exec($this->connection, $cmd)) {
throw new FileTransferException('Cannot change permissions of @path.', NULL, array('@path' => $path));
}
}
/**
* Returns the form to configure the FileTransfer class for SSH.
*/
public function getSettingsForm() {
$form = parent::getSettingsForm();
$form['advanced']['port']['#default_value'] = 22;
return $form;
}
}
+4809
View File
File diff suppressed because it is too large Load Diff
+145
View File
@@ -0,0 +1,145 @@
<?php
/**
* @file
* Directed acyclic graph manipulation.
*/
/**
* Performs a depth-first search and sort on a directed acyclic graph.
*
* @param $graph
* A three dimensional associated array, with the first keys being the names
* of the vertices, these can be strings or numbers. The second key is
* 'edges' and the third one are again vertices, each such key representing
* an edge. Values of array elements are copied over.
*
* Example:
* @code
* $graph[1]['edges'][2] = 1;
* $graph[2]['edges'][3] = 1;
* $graph[2]['edges'][4] = 1;
* $graph[3]['edges'][4] = 1;
* @endcode
*
* On return you will also have:
* @code
* $graph[1]['paths'][2] = 1;
* $graph[1]['paths'][3] = 1;
* $graph[2]['reverse_paths'][1] = 1;
* $graph[3]['reverse_paths'][1] = 1;
* @endcode
*
* @return
* The passed-in $graph with more secondary keys filled in:
* - 'paths': Contains a list of vertices than can be reached on a path from
* this vertex.
* - 'reverse_paths': Contains a list of vertices that has a path from them
* to this vertex.
* - 'weight': If there is a path from a vertex to another then the weight of
* the latter is higher.
* - 'component': Vertices in the same component have the same component
* identifier.
*
* @see _drupal_depth_first_search()
*/
function drupal_depth_first_search(&$graph) {
$state = array(
// The order of last visit of the depth first search. This is the reverse
// of the topological order if the graph is acyclic.
'last_visit_order' => array(),
// The components of the graph.
'components' => array(),
);
// Perform the actual search.
foreach ($graph as $start => $data) {
_drupal_depth_first_search($graph, $state, $start);
}
// We do such a numbering that every component starts with 0. This is useful
// for module installs as we can install every 0 weighted module in one
// request, and then every 1 weighted etc.
$component_weights = array();
foreach ($state['last_visit_order'] as $vertex) {
$component = $graph[$vertex]['component'];
if (!isset($component_weights[$component])) {
$component_weights[$component] = 0;
}
$graph[$vertex]['weight'] = $component_weights[$component]--;
}
}
/**
* Performs a depth-first search on a graph.
*
* @param $graph
* A three dimensional associated graph array.
* @param $state
* An associative array. The key 'last_visit_order' stores a list of the
* vertices visited. The key components stores list of vertices belonging
* to the same the component.
* @param $start
* An arbitrary vertex where we started traversing the graph.
* @param $component
* The component of the last vertex.
*
* @see drupal_depth_first_search()
*/
function _drupal_depth_first_search(&$graph, &$state, $start, &$component = NULL) {
// Assign new component for each new vertex, i.e. when not called recursively.
if (!isset($component)) {
$component = $start;
}
// Nothing to do, if we already visited this vertex.
if (isset($graph[$start]['paths'])) {
return;
}
// Mark $start as visited.
$graph[$start]['paths'] = array();
// Assign $start to the current component.
$graph[$start]['component'] = $component;
$state['components'][$component][] = $start;
// Visit edges of $start.
if (isset($graph[$start]['edges'])) {
foreach ($graph[$start]['edges'] as $end => $v) {
// Mark that $start can reach $end.
$graph[$start]['paths'][$end] = $v;
if (isset($graph[$end]['component']) && $component != $graph[$end]['component']) {
// This vertex already has a component, use that from now on and
// reassign all the previously explored vertices.
$new_component = $graph[$end]['component'];
foreach ($state['components'][$component] as $vertex) {
$graph[$vertex]['component'] = $new_component;
$state['components'][$new_component][] = $vertex;
}
unset($state['components'][$component]);
$component = $new_component;
}
// Only visit existing vertices.
if (isset($graph[$end])) {
// Visit the connected vertex.
_drupal_depth_first_search($graph, $state, $end, $component);
// All vertices reachable by $end are also reachable by $start.
$graph[$start]['paths'] += $graph[$end]['paths'];
}
}
}
// Now that any other subgraph has been explored, add $start to all reverse
// paths.
foreach ($graph[$start]['paths'] as $end => $v) {
if (isset($graph[$end])) {
$graph[$end]['reverse_paths'][$start] = $v;
}
}
// Record the order of the last visit. This is the reverse of the
// topological order if the graph is acyclic.
$state['last_visit_order'][] = $start;
}
+435
View File
@@ -0,0 +1,435 @@
<?php
/**
* @file
* API for manipulating images.
*/
/**
* @defgroup image Image toolkits
* @{
* Functions for image file manipulations.
*
* Drupal's image toolkits provide an abstraction layer for common image file
* manipulations like scaling, cropping, and rotating. The abstraction frees
* module authors from the need to support multiple image libraries, and it
* allows site administrators to choose the library that's best for them.
*
* PHP includes the GD library by default so a GD toolkit is installed with
* Drupal. Other toolkits like ImageMagick are available from contrib modules.
* GD works well for small images, but using it with larger files may cause PHP
* to run out of memory. In contrast the ImageMagick library does not suffer
* from this problem, but it requires the ISP to have installed additional
* software.
*
* Image toolkits are discovered based on the associated module's
* hook_image_toolkits. Additionally the image toolkit include file
* must be identified in the files array in the module.info file. The
* toolkit must then be enabled using the admin/config/media/image-toolkit
* form.
*
* Only one toolkit may be selected at a time. If a module author wishes to call
* a specific toolkit they can check that it is installed by calling
* image_get_available_toolkits(), and then calling its functions directly.
*/
/**
* Gets a list of available toolkits.
*
* @return
* An array with the toolkit names as keys and the descriptions as values.
*/
function image_get_available_toolkits() {
// hook_image_toolkits returns an array of toolkit names.
$toolkits = module_invoke_all('image_toolkits');
$output = array();
foreach ($toolkits as $name => $info) {
// Only allow modules that aren't marked as unavailable.
if ($info['available']) {
$output[$name] = $info['title'];
}
}
return $output;
}
/**
* Gets the name of the currently used toolkit.
*
* @return
* String containing the name of the selected toolkit, or FALSE on error.
*/
function image_get_toolkit() {
static $toolkit;
if (!isset($toolkit)) {
$toolkits = image_get_available_toolkits();
$toolkit = variable_get('image_toolkit', 'gd');
if (!isset($toolkits[$toolkit]) || !function_exists('image_' . $toolkit . '_load')) {
// The selected toolkit isn't available so return the first one found. If
// none are available this will return FALSE.
reset($toolkits);
$toolkit = key($toolkits);
}
}
return $toolkit;
}
/**
* Invokes the given method using the currently selected toolkit.
*
* @param $method
* A string containing the method to invoke.
* @param $image
* An image object returned by image_load().
* @param $params
* An optional array of parameters to pass to the toolkit method.
*
* @return
* Mixed values (typically Boolean indicating successful operation).
*/
function image_toolkit_invoke($method, stdClass $image, array $params = array()) {
$function = 'image_' . $image->toolkit . '_' . $method;
if (function_exists($function)) {
array_unshift($params, $image);
return call_user_func_array($function, $params);
}
watchdog('image', 'The selected image handling toolkit %toolkit can not correctly process %function.', array('%toolkit' => $image->toolkit, '%function' => $function), WATCHDOG_ERROR);
return FALSE;
}
/**
* Gets details about an image.
*
* Drupal supports GIF, JPG and PNG file formats when used with the GD
* toolkit, and may support others, depending on which toolkits are
* installed.
*
* @param $filepath
* String specifying the path of the image file.
* @param $toolkit
* An optional image toolkit name to override the default.
*
* @return
* FALSE, if the file could not be found or is not an image. Otherwise, a
* keyed array containing information about the image:
* - "width": Width, in pixels.
* - "height": Height, in pixels.
* - "extension": Commonly used file extension for the image.
* - "mime_type": MIME type ('image/jpeg', 'image/gif', 'image/png').
* - "file_size": File size in bytes.
*/
function image_get_info($filepath, $toolkit = FALSE) {
$details = FALSE;
if (!is_file($filepath) && !is_uploaded_file($filepath)) {
return $details;
}
if (!$toolkit) {
$toolkit = image_get_toolkit();
}
if ($toolkit) {
$image = new stdClass();
$image->source = $filepath;
$image->toolkit = $toolkit;
$details = image_toolkit_invoke('get_info', $image);
if (isset($details) && is_array($details)) {
$details['file_size'] = filesize($filepath);
}
}
return $details;
}
/**
* Scales an image to the exact width and height given.
*
* This function achieves the target aspect ratio by cropping the original image
* equally on both sides, or equally on the top and bottom. This function is
* useful to create uniform sized avatars from larger images.
*
* The resulting image always has the exact target dimensions.
*
* @param $image
* An image object returned by image_load().
* @param $width
* The target width, in pixels.
* @param $height
* The target height, in pixels.
*
* @return
* TRUE on success, FALSE on failure.
*
* @see image_load()
* @see image_resize()
* @see image_crop()
*/
function image_scale_and_crop(stdClass $image, $width, $height) {
$scale = max($width / $image->info['width'], $height / $image->info['height']);
$x = ($image->info['width'] * $scale - $width) / 2;
$y = ($image->info['height'] * $scale - $height) / 2;
if (image_resize($image, $image->info['width'] * $scale, $image->info['height'] * $scale)) {
return image_crop($image, $x, $y, $width, $height);
}
return FALSE;
}
/**
* Scales image dimensions while maintaining aspect ratio.
*
* The resulting dimensions can be smaller for one or both target dimensions.
*
* @param $dimensions
* Dimensions to be modified - an array with components width and height, in
* pixels.
* @param $width
* The target width, in pixels. If this value is NULL then the scaling will be
* based only on the height value.
* @param $height
* The target height, in pixels. If this value is NULL then the scaling will
* be based only on the width value.
* @param $upscale
* Boolean indicating that images smaller than the target dimensions will be
* scaled up. This generally results in a low quality image.
*
* @return
* TRUE if $dimensions was modified, FALSE otherwise.
*
* @see image_scale()
*/
function image_dimensions_scale(array &$dimensions, $width = NULL, $height = NULL, $upscale = FALSE) {
$aspect = $dimensions['height'] / $dimensions['width'];
// Calculate one of the dimensions from the other target dimension,
// ensuring the same aspect ratio as the source dimensions. If one of the
// target dimensions is missing, that is the one that is calculated. If both
// are specified then the dimension calculated is the one that would not be
// calculated to be bigger than its target.
if (($width && !$height) || ($width && $height && $aspect < $height / $width)) {
$height = (int) round($width * $aspect);
}
else {
$width = (int) round($height / $aspect);
}
// Don't upscale if the option isn't enabled.
if (!$upscale && ($width >= $dimensions['width'] || $height >= $dimensions['height'])) {
return FALSE;
}
$dimensions['width'] = $width;
$dimensions['height'] = $height;
return TRUE;
}
/**
* Scales an image while maintaining aspect ratio.
*
* The resulting image can be smaller for one or both target dimensions.
*
* @param $image
* An image object returned by image_load().
* @param $width
* The target width, in pixels. If this value is NULL then the scaling will
* be based only on the height value.
* @param $height
* The target height, in pixels. If this value is NULL then the scaling will
* be based only on the width value.
* @param $upscale
* Boolean indicating that files smaller than the dimensions will be scaled
* up. This generally results in a low quality image.
*
* @return
* TRUE on success, FALSE on failure.
*
* @see image_dimensions_scale()
* @see image_load()
* @see image_scale_and_crop()
*/
function image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale = FALSE) {
$dimensions = $image->info;
// Scale the dimensions - if they don't change then just return success.
if (!image_dimensions_scale($dimensions, $width, $height, $upscale)) {
return TRUE;
}
return image_resize($image, $dimensions['width'], $dimensions['height']);
}
/**
* Resizes an image to the given dimensions (ignoring aspect ratio).
*
* @param $image
* An image object returned by image_load().
* @param $width
* The target width, in pixels.
* @param $height
* The target height, in pixels.
*
* @return
* TRUE on success, FALSE on failure.
*
* @see image_load()
* @see image_gd_resize()
*/
function image_resize(stdClass $image, $width, $height) {
$width = (int) round($width);
$height = (int) round($height);
return image_toolkit_invoke('resize', $image, array($width, $height));
}
/**
* Rotates an image by the given number of degrees.
*
* @param $image
* An image object returned by image_load().
* @param $degrees
* The number of (clockwise) degrees to rotate the image.
* @param $background
* An hexadecimal integer specifying the background color to use for the
* uncovered area of the image after the rotation. E.g. 0x000000 for black,
* 0xff00ff for magenta, and 0xffffff for white. For images that support
* transparency, this will default to transparent. Otherwise it will
* be white.
*
* @return
* TRUE on success, FALSE on failure.
*
* @see image_load()
* @see image_gd_rotate()
*/
function image_rotate(stdClass $image, $degrees, $background = NULL) {
return image_toolkit_invoke('rotate', $image, array($degrees, $background));
}
/**
* Crops an image to a rectangle specified by the given dimensions.
*
* @param $image
* An image object returned by image_load().
* @param $x
* The top left coordinate, in pixels, of the crop area (x axis value).
* @param $y
* The top left coordinate, in pixels, of the crop area (y axis value).
* @param $width
* The target width, in pixels.
* @param $height
* The target height, in pixels.
*
* @return
* TRUE on success, FALSE on failure.
*
* @see image_load()
* @see image_scale_and_crop()
* @see image_gd_crop()
*/
function image_crop(stdClass $image, $x, $y, $width, $height) {
$aspect = $image->info['height'] / $image->info['width'];
if (empty($height)) $height = $width / $aspect;
if (empty($width)) $width = $height * $aspect;
$width = (int) round($width);
$height = (int) round($height);
return image_toolkit_invoke('crop', $image, array($x, $y, $width, $height));
}
/**
* Converts an image to grayscale.
*
* @param $image
* An image object returned by image_load().
*
* @return
* TRUE on success, FALSE on failure.
*
* @see image_load()
* @see image_gd_desaturate()
*/
function image_desaturate(stdClass $image) {
return image_toolkit_invoke('desaturate', $image);
}
/**
* Loads an image file and returns an image object.
*
* Any changes to the file are not saved until image_save() is called.
*
* @param $file
* Path to an image file.
* @param $toolkit
* An optional, image toolkit name to override the default.
*
* @return
* An image object or FALSE if there was a problem loading the file. The
* image object has the following properties:
* - 'source' - The original file path.
* - 'info' - The array of information returned by image_get_info()
* - 'toolkit' - The name of the image toolkit requested when the image was
* loaded.
* Image toolkits may add additional properties. The caller is advised not to
* monkey about with them.
*
* @see image_save()
* @see image_get_info()
* @see image_get_available_toolkits()
* @see image_gd_load()
*/
function image_load($file, $toolkit = FALSE) {
if (!$toolkit) {
$toolkit = image_get_toolkit();
}
if ($toolkit) {
$image = new stdClass();
$image->source = $file;
$image->info = image_get_info($file, $toolkit);
if (isset($image->info) && is_array($image->info)) {
$image->toolkit = $toolkit;
if (image_toolkit_invoke('load', $image)) {
return $image;
}
}
}
return FALSE;
}
/**
* Closes the image and saves the changes to a file.
*
* @param $image
* An image object returned by image_load(). The object's 'info' property
* will be updated if the file is saved successfully.
* @param $destination
* Destination path where the image should be saved. If it is empty the
* original image file will be overwritten.
*
* @return
* TRUE on success, FALSE on failure.
*
* @see image_load()
* @see image_gd_save()
*/
function image_save(stdClass $image, $destination = NULL) {
if (empty($destination)) {
$destination = $image->source;
}
if ($return = image_toolkit_invoke('save', $image, array($destination))) {
// Clear the cached file size and refresh the image information.
clearstatcache();
$image->info = image_get_info($destination, $image->toolkit);
if (drupal_chmod($destination)) {
return $return;
}
}
return FALSE;
}
/**
* @} End of "defgroup image".
*/
File diff suppressed because it is too large Load Diff
+1340
View File
File diff suppressed because it is too large Load Diff
+486
View File
@@ -0,0 +1,486 @@
<?php
/**
* @file
* Provides a list of countries and languages based on ISO standards.
*/
/**
* Get an array of all country code => country name pairs.
*
* Get an array of all country code => country name pairs as laid out
* in ISO 3166-1 alpha-2.
* Grabbed from location project (http://drupal.org/project/location).
* @return
* An array of all country code => country name pairs.
*/
function _country_get_predefined_list() {
static $countries;
if (isset($countries)) {
return $countries;
}
$t = get_t();
$countries = array(
'AD' => $t('Andorra'),
'AE' => $t('United Arab Emirates'),
'AF' => $t('Afghanistan'),
'AG' => $t('Antigua and Barbuda'),
'AI' => $t('Anguilla'),
'AL' => $t('Albania'),
'AM' => $t('Armenia'),
'AN' => $t('Netherlands Antilles'),
'AO' => $t('Angola'),
'AQ' => $t('Antarctica'),
'AR' => $t('Argentina'),
'AS' => $t('American Samoa'),
'AT' => $t('Austria'),
'AU' => $t('Australia'),
'AW' => $t('Aruba'),
'AX' => $t('Aland Islands'),
'AZ' => $t('Azerbaijan'),
'BA' => $t('Bosnia and Herzegovina'),
'BB' => $t('Barbados'),
'BD' => $t('Bangladesh'),
'BE' => $t('Belgium'),
'BF' => $t('Burkina Faso'),
'BG' => $t('Bulgaria'),
'BH' => $t('Bahrain'),
'BI' => $t('Burundi'),
'BJ' => $t('Benin'),
'BL' => $t('Saint Barthélemy'),
'BM' => $t('Bermuda'),
'BN' => $t('Brunei'),
'BO' => $t('Bolivia'),
'BQ' => $t('Caribbean Netherlands'),
'BR' => $t('Brazil'),
'BS' => $t('Bahamas'),
'BT' => $t('Bhutan'),
'BV' => $t('Bouvet Island'),
'BW' => $t('Botswana'),
'BY' => $t('Belarus'),
'BZ' => $t('Belize'),
'CA' => $t('Canada'),
'CC' => $t('Cocos (Keeling) Islands'),
'CD' => $t('Congo (Kinshasa)'),
'CF' => $t('Central African Republic'),
'CG' => $t('Congo (Brazzaville)'),
'CH' => $t('Switzerland'),
'CI' => $t('Ivory Coast'),
'CK' => $t('Cook Islands'),
'CL' => $t('Chile'),
'CM' => $t('Cameroon'),
'CN' => $t('China'),
'CO' => $t('Colombia'),
'CR' => $t('Costa Rica'),
'CU' => $t('Cuba'),
'CV' => $t('Cape Verde'),
'CW' => $t('Curaçao'),
'CX' => $t('Christmas Island'),
'CY' => $t('Cyprus'),
'CZ' => $t('Czech Republic'),
'DE' => $t('Germany'),
'DJ' => $t('Djibouti'),
'DK' => $t('Denmark'),
'DM' => $t('Dominica'),
'DO' => $t('Dominican Republic'),
'DZ' => $t('Algeria'),
'EC' => $t('Ecuador'),
'EE' => $t('Estonia'),
'EG' => $t('Egypt'),
'EH' => $t('Western Sahara'),
'ER' => $t('Eritrea'),
'ES' => $t('Spain'),
'ET' => $t('Ethiopia'),
'FI' => $t('Finland'),
'FJ' => $t('Fiji'),
'FK' => $t('Falkland Islands'),
'FM' => $t('Micronesia'),
'FO' => $t('Faroe Islands'),
'FR' => $t('France'),
'GA' => $t('Gabon'),
'GB' => $t('United Kingdom'),
'GD' => $t('Grenada'),
'GE' => $t('Georgia'),
'GF' => $t('French Guiana'),
'GG' => $t('Guernsey'),
'GH' => $t('Ghana'),
'GI' => $t('Gibraltar'),
'GL' => $t('Greenland'),
'GM' => $t('Gambia'),
'GN' => $t('Guinea'),
'GP' => $t('Guadeloupe'),
'GQ' => $t('Equatorial Guinea'),
'GR' => $t('Greece'),
'GS' => $t('South Georgia and the South Sandwich Islands'),
'GT' => $t('Guatemala'),
'GU' => $t('Guam'),
'GW' => $t('Guinea-Bissau'),
'GY' => $t('Guyana'),
'HK' => $t('Hong Kong S.A.R., China'),
'HM' => $t('Heard Island and McDonald Islands'),
'HN' => $t('Honduras'),
'HR' => $t('Croatia'),
'HT' => $t('Haiti'),
'HU' => $t('Hungary'),
'ID' => $t('Indonesia'),
'IE' => $t('Ireland'),
'IL' => $t('Israel'),
'IM' => $t('Isle of Man'),
'IN' => $t('India'),
'IO' => $t('British Indian Ocean Territory'),
'IQ' => $t('Iraq'),
'IR' => $t('Iran'),
'IS' => $t('Iceland'),
'IT' => $t('Italy'),
'JE' => $t('Jersey'),
'JM' => $t('Jamaica'),
'JO' => $t('Jordan'),
'JP' => $t('Japan'),
'KE' => $t('Kenya'),
'KG' => $t('Kyrgyzstan'),
'KH' => $t('Cambodia'),
'KI' => $t('Kiribati'),
'KM' => $t('Comoros'),
'KN' => $t('Saint Kitts and Nevis'),
'KP' => $t('North Korea'),
'KR' => $t('South Korea'),
'KW' => $t('Kuwait'),
'KY' => $t('Cayman Islands'),
'KZ' => $t('Kazakhstan'),
'LA' => $t('Laos'),
'LB' => $t('Lebanon'),
'LC' => $t('Saint Lucia'),
'LI' => $t('Liechtenstein'),
'LK' => $t('Sri Lanka'),
'LR' => $t('Liberia'),
'LS' => $t('Lesotho'),
'LT' => $t('Lithuania'),
'LU' => $t('Luxembourg'),
'LV' => $t('Latvia'),
'LY' => $t('Libya'),
'MA' => $t('Morocco'),
'MC' => $t('Monaco'),
'MD' => $t('Moldova'),
'ME' => $t('Montenegro'),
'MF' => $t('Saint Martin (French part)'),
'MG' => $t('Madagascar'),
'MH' => $t('Marshall Islands'),
'MK' => $t('Macedonia'),
'ML' => $t('Mali'),
'MM' => $t('Myanmar'),
'MN' => $t('Mongolia'),
'MO' => $t('Macao S.A.R., China'),
'MP' => $t('Northern Mariana Islands'),
'MQ' => $t('Martinique'),
'MR' => $t('Mauritania'),
'MS' => $t('Montserrat'),
'MT' => $t('Malta'),
'MU' => $t('Mauritius'),
'MV' => $t('Maldives'),
'MW' => $t('Malawi'),
'MX' => $t('Mexico'),
'MY' => $t('Malaysia'),
'MZ' => $t('Mozambique'),
'NA' => $t('Namibia'),
'NC' => $t('New Caledonia'),
'NE' => $t('Niger'),
'NF' => $t('Norfolk Island'),
'NG' => $t('Nigeria'),
'NI' => $t('Nicaragua'),
'NL' => $t('Netherlands'),
'NO' => $t('Norway'),
'NP' => $t('Nepal'),
'NR' => $t('Nauru'),
'NU' => $t('Niue'),
'NZ' => $t('New Zealand'),
'OM' => $t('Oman'),
'PA' => $t('Panama'),
'PE' => $t('Peru'),
'PF' => $t('French Polynesia'),
'PG' => $t('Papua New Guinea'),
'PH' => $t('Philippines'),
'PK' => $t('Pakistan'),
'PL' => $t('Poland'),
'PM' => $t('Saint Pierre and Miquelon'),
'PN' => $t('Pitcairn'),
'PR' => $t('Puerto Rico'),
'PS' => $t('Palestinian Territory'),
'PT' => $t('Portugal'),
'PW' => $t('Palau'),
'PY' => $t('Paraguay'),
'QA' => $t('Qatar'),
'RE' => $t('Reunion'),
'RO' => $t('Romania'),
'RS' => $t('Serbia'),
'RU' => $t('Russia'),
'RW' => $t('Rwanda'),
'SA' => $t('Saudi Arabia'),
'SB' => $t('Solomon Islands'),
'SC' => $t('Seychelles'),
'SD' => $t('Sudan'),
'SE' => $t('Sweden'),
'SG' => $t('Singapore'),
'SH' => $t('Saint Helena'),
'SI' => $t('Slovenia'),
'SJ' => $t('Svalbard and Jan Mayen'),
'SK' => $t('Slovakia'),
'SL' => $t('Sierra Leone'),
'SM' => $t('San Marino'),
'SN' => $t('Senegal'),
'SO' => $t('Somalia'),
'SR' => $t('Suriname'),
'SS' => $t('South Sudan'),
'ST' => $t('Sao Tome and Principe'),
'SV' => $t('El Salvador'),
'SX' => $t('Sint Maarten'),
'SY' => $t('Syria'),
'SZ' => $t('Swaziland'),
'TC' => $t('Turks and Caicos Islands'),
'TD' => $t('Chad'),
'TF' => $t('French Southern Territories'),
'TG' => $t('Togo'),
'TH' => $t('Thailand'),
'TJ' => $t('Tajikistan'),
'TK' => $t('Tokelau'),
'TL' => $t('Timor-Leste'),
'TM' => $t('Turkmenistan'),
'TN' => $t('Tunisia'),
'TO' => $t('Tonga'),
'TR' => $t('Turkey'),
'TT' => $t('Trinidad and Tobago'),
'TV' => $t('Tuvalu'),
'TW' => $t('Taiwan'),
'TZ' => $t('Tanzania'),
'UA' => $t('Ukraine'),
'UG' => $t('Uganda'),
'UM' => $t('United States Minor Outlying Islands'),
'US' => $t('United States'),
'UY' => $t('Uruguay'),
'UZ' => $t('Uzbekistan'),
'VA' => $t('Vatican'),
'VC' => $t('Saint Vincent and the Grenadines'),
'VE' => $t('Venezuela'),
'VG' => $t('British Virgin Islands'),
'VI' => $t('U.S. Virgin Islands'),
'VN' => $t('Vietnam'),
'VU' => $t('Vanuatu'),
'WF' => $t('Wallis and Futuna'),
'WS' => $t('Samoa'),
'YE' => $t('Yemen'),
'YT' => $t('Mayotte'),
'ZA' => $t('South Africa'),
'ZM' => $t('Zambia'),
'ZW' => $t('Zimbabwe'),
);
// Sort the list.
natcasesort($countries);
return $countries;
}
/**
* @ingroup locale-api-predefined List of predefined languages
* @{
*/
/**
* Some of the common languages with their English and native names
*
* Based on ISO 639 and http://people.w3.org/rishida/names/languages.html
*/
function _locale_get_predefined_list() {
return array(
'aa' => array('Afar'),
'ab' => array('Abkhazian', 'аҧсуа бызшәа'),
'ae' => array('Avestan'),
'af' => array('Afrikaans'),
'ak' => array('Akan'),
'am' => array('Amharic', 'አማርኛ'),
'ar' => array('Arabic', /* Left-to-right marker "" */ 'العربية', LANGUAGE_RTL),
'as' => array('Assamese'),
'ast' => array('Asturian'),
'av' => array('Avar'),
'ay' => array('Aymara'),
'az' => array('Azerbaijani', 'azərbaycan'),
'ba' => array('Bashkir'),
'be' => array('Belarusian', 'Беларуская'),
'bg' => array('Bulgarian', 'Български'),
'bh' => array('Bihari'),
'bi' => array('Bislama'),
'bm' => array('Bambara', 'Bamanankan'),
'bn' => array('Bengali'),
'bo' => array('Tibetan'),
'br' => array('Breton'),
'bs' => array('Bosnian', 'Bosanski'),
'ca' => array('Catalan', 'Català'),
'ce' => array('Chechen'),
'ch' => array('Chamorro'),
'co' => array('Corsican'),
'cr' => array('Cree'),
'cs' => array('Czech', 'Čeština'),
'cu' => array('Old Slavonic'),
'cv' => array('Chuvash'),
'cy' => array('Welsh', 'Cymraeg'),
'da' => array('Danish', 'Dansk'),
'de' => array('German', 'Deutsch'),
'dv' => array('Maldivian'),
'dz' => array('Bhutani'),
'ee' => array('Ewe', 'Ɛʋɛ'),
'el' => array('Greek', 'Ελληνικά'),
'en' => array('English'),
'en-gb' => array('English, British'),
'eo' => array('Esperanto'),
'es' => array('Spanish', 'Español'),
'et' => array('Estonian', 'Eesti'),
'eu' => array('Basque', 'Euskera'),
'fa' => array('Persian', /* Left-to-right marker "" */ 'فارسی', LANGUAGE_RTL),
'ff' => array('Fulah', 'Fulfulde'),
'fi' => array('Finnish', 'Suomi'),
'fil' => array('Filipino'),
'fj' => array('Fiji'),
'fo' => array('Faeroese'),
'fr' => array('French', 'Français'),
'fy' => array('Frisian', 'Frysk'),
'ga' => array('Irish', 'Gaeilge'),
'gd' => array('Scots Gaelic'),
'gl' => array('Galician', 'Galego'),
'gn' => array('Guarani'),
'gsw-berne' => array('Swiss German'),
'gu' => array('Gujarati'),
'gv' => array('Manx'),
'ha' => array('Hausa'),
'he' => array('Hebrew', /* Left-to-right marker "" */ 'עברית', LANGUAGE_RTL),
'hi' => array('Hindi', 'हिन्दी'),
'ho' => array('Hiri Motu'),
'hr' => array('Croatian', 'Hrvatski'),
'ht' => array('Haitian Creole'),
'hu' => array('Hungarian', 'Magyar'),
'hy' => array('Armenian', 'Հայերեն'),
'hz' => array('Herero'),
'ia' => array('Interlingua'),
'id' => array('Indonesian', 'Bahasa Indonesia'),
'ie' => array('Interlingue'),
'ig' => array('Igbo'),
'ik' => array('Inupiak'),
'is' => array('Icelandic', 'Íslenska'),
'it' => array('Italian', 'Italiano'),
'iu' => array('Inuktitut'),
'ja' => array('Japanese', '日本語'),
'jv' => array('Javanese'),
'ka' => array('Georgian'),
'kg' => array('Kongo'),
'ki' => array('Kikuyu'),
'kj' => array('Kwanyama'),
'kk' => array('Kazakh', 'Қазақ'),
'kl' => array('Greenlandic'),
'km' => array('Cambodian'),
'kn' => array('Kannada', 'ಕನ್ನಡ'),
'ko' => array('Korean', '한국어'),
'kr' => array('Kanuri'),
'ks' => array('Kashmiri'),
'ku' => array('Kurdish', 'Kurdî'),
'kv' => array('Komi'),
'kw' => array('Cornish'),
'ky' => array('Kyrgyz', 'Кыргызча'),
'la' => array('Latin', 'Latina'),
'lb' => array('Luxembourgish'),
'lg' => array('Luganda'),
'ln' => array('Lingala'),
'lo' => array('Laothian'),
'lt' => array('Lithuanian', 'Lietuvių'),
'lv' => array('Latvian', 'Latviešu'),
'mg' => array('Malagasy'),
'mh' => array('Marshallese'),
'mi' => array('Māori'),
'mk' => array('Macedonian', 'Македонски'),
'ml' => array('Malayalam', 'മലയാളം'),
'mn' => array('Mongolian'),
'mo' => array('Moldavian'),
'mr' => array('Marathi'),
'ms' => array('Malay', 'Bahasa Melayu'),
'mt' => array('Maltese', 'Malti'),
'my' => array('Burmese'),
'na' => array('Nauru'),
'nd' => array('North Ndebele'),
'ne' => array('Nepali'),
'ng' => array('Ndonga'),
'nl' => array('Dutch', 'Nederlands'),
'nb' => array('Norwegian Bokmål', 'Bokmål'),
'nn' => array('Norwegian Nynorsk', 'Nynorsk'),
'nr' => array('South Ndebele'),
'nv' => array('Navajo'),
'ny' => array('Chichewa'),
'oc' => array('Occitan'),
'om' => array('Oromo'),
'or' => array('Oriya'),
'os' => array('Ossetian'),
'pa' => array('Punjabi'),
'pi' => array('Pali'),
'pl' => array('Polish', 'Polski'),
'ps' => array('Pashto', /* Left-to-right marker "" */ 'پښتو', LANGUAGE_RTL),
'pt' => array('Portuguese, International'),
'pt-pt' => array('Portuguese, Portugal', 'Português'),
'pt-br' => array('Portuguese, Brazil', 'Português'),
'qu' => array('Quechua'),
'rm' => array('Rhaeto-Romance'),
'rn' => array('Kirundi'),
'ro' => array('Romanian', 'Română'),
'ru' => array('Russian', 'Русский'),
'rw' => array('Kinyarwanda'),
'sa' => array('Sanskrit'),
'sc' => array('Sardinian'),
'sco' => array('Scots'),
'sd' => array('Sindhi'),
'se' => array('Northern Sami'),
'sg' => array('Sango'),
'sh' => array('Serbo-Croatian'),
'si' => array('Sinhala', 'සිංහල'),
'sk' => array('Slovak', 'Slovenčina'),
'sl' => array('Slovenian', 'Slovenščina'),
'sm' => array('Samoan'),
'sn' => array('Shona'),
'so' => array('Somali'),
'sq' => array('Albanian', 'Shqip'),
'sr' => array('Serbian', 'Српски'),
'ss' => array('Siswati'),
'st' => array('Sesotho'),
'su' => array('Sudanese'),
'sv' => array('Swedish', 'Svenska'),
'sw' => array('Swahili', 'Kiswahili'),
'ta' => array('Tamil', 'தமிழ்'),
'te' => array('Telugu', 'తెలుగు'),
'tg' => array('Tajik'),
'th' => array('Thai', 'ภาษาไทย'),
'ti' => array('Tigrinya'),
'tk' => array('Turkmen'),
'tl' => array('Tagalog'),
'tn' => array('Setswana'),
'to' => array('Tonga'),
'tr' => array('Turkish', 'Türkçe'),
'ts' => array('Tsonga'),
'tt' => array('Tatar', 'Tatarça'),
'tw' => array('Twi'),
'ty' => array('Tahitian'),
'ug' => array('Uyghur'),
'uk' => array('Ukrainian', 'Українська'),
'ur' => array('Urdu', /* Left-to-right marker "" */ 'اردو', LANGUAGE_RTL),
'uz' => array('Uzbek', "o'zbek"),
've' => array('Venda'),
'vi' => array('Vietnamese', 'Tiếng Việt'),
'wo' => array('Wolof'),
'xh' => array('Xhosa', 'isiXhosa'),
'xx-lolspeak' => array('Lolspeak'),
'yi' => array('Yiddish'),
'yo' => array('Yoruba', 'Yorùbá'),
'za' => array('Zhuang'),
'zh-hans' => array('Chinese, Simplified', '简体中文'),
'zh-hant' => array('Chinese, Traditional', '繁體中文'),
'zu' => array('Zulu', 'isiZulu'),
);
}
/**
* @} End of "locale-api-languages-predefined"
*/
+102
View File
@@ -0,0 +1,102 @@
<?php
/**
* @file
* Provides a helper to properly encode HTML-safe JSON prior to PHP 5.3.0.
*/
/**
* Encodes a PHP variable to HTML-safe JSON for PHP versions below 5.3.0.
*
* @see drupal_json_encode()
*/
function drupal_json_encode_helper($var) {
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false'; // Lowercase necessary!
case 'integer':
case 'double':
return $var;
case 'resource':
case 'string':
// Always use Unicode escape sequences (\u0022) over JSON escape
// sequences (\") to prevent browsers interpreting these as
// special characters.
$replace_pairs = array(
// ", \ and U+0000 - U+001F must be escaped according to RFC 4627.
'\\' => '\u005C',
'"' => '\u0022',
"\x00" => '\u0000',
"\x01" => '\u0001',
"\x02" => '\u0002',
"\x03" => '\u0003',
"\x04" => '\u0004',
"\x05" => '\u0005',
"\x06" => '\u0006',
"\x07" => '\u0007',
"\x08" => '\u0008',
"\x09" => '\u0009',
"\x0a" => '\u000A',
"\x0b" => '\u000B',
"\x0c" => '\u000C',
"\x0d" => '\u000D',
"\x0e" => '\u000E',
"\x0f" => '\u000F',
"\x10" => '\u0010',
"\x11" => '\u0011',
"\x12" => '\u0012',
"\x13" => '\u0013',
"\x14" => '\u0014',
"\x15" => '\u0015',
"\x16" => '\u0016',
"\x17" => '\u0017',
"\x18" => '\u0018',
"\x19" => '\u0019',
"\x1a" => '\u001A',
"\x1b" => '\u001B',
"\x1c" => '\u001C',
"\x1d" => '\u001D',
"\x1e" => '\u001E',
"\x1f" => '\u001F',
// Prevent browsers from interpreting these as as special.
"'" => '\u0027',
'<' => '\u003C',
'>' => '\u003E',
'&' => '\u0026',
// Prevent browsers from interpreting the solidus as special and
// non-compliant JSON parsers from interpreting // as a comment.
'/' => '\u002F',
// While these are allowed unescaped according to ECMA-262, section
// 15.12.2, they cause problems in some JSON parsers.
"\xe2\x80\xa8" => '\u2028', // U+2028, Line Separator.
"\xe2\x80\xa9" => '\u2029', // U+2029, Paragraph Separator.
);
return '"' . strtr($var, $replace_pairs) . '"';
case 'array':
// Arrays in JSON can't be associative. If the array is empty or if it
// has sequential whole number keys starting with 0, it's not associative
// so we can go ahead and convert it as an array.
if (empty($var) || array_keys($var) === range(0, sizeof($var) - 1)) {
$output = array();
foreach ($var as $v) {
$output[] = drupal_json_encode_helper($v);
}
return '[ ' . implode(', ', $output) . ' ]';
}
// Otherwise, fall through to convert the array as an object.
case 'object':
$output = array();
foreach ($var as $k => $v) {
$output[] = drupal_json_encode_helper(strval($k)) . ':' . drupal_json_encode_helper($v);
}
return '{' . implode(', ', $output) . '}';
default:
return 'null';
}
}
+580
View File
@@ -0,0 +1,580 @@
<?php
/**
* @file
* Language Negotiation API.
*
* @see http://drupal.org/node/1497272
*/
/**
* No language negotiation. The default language is used.
*/
define('LANGUAGE_NEGOTIATION_DEFAULT', 'language-default');
/**
* @defgroup language_negotiation Language Negotiation API functionality
* @{
* Functions to customize the language types and the negotiation process.
*
* The language negotiation API is based on two major concepts:
* - Language types: types of translatable data (the types of data that a user
* can view or request).
* - Language negotiation providers: functions for determining which language to
* use to present a particular piece of data to the user.
* Both language types and language negotiation providers are customizable.
*
* Drupal defines three built-in language types:
* - Interface language: The page's main language, used to present translated
* user interface elements such as titles, labels, help text, and messages.
* - Content language: The language used to present content that is available
* in more than one language (see
* @link field_language Field Language API @endlink for details).
* - URL language: The language associated with URLs. When generating a URL,
* this value will be used by url() as a default if no explicit preference is
* provided.
* Modules can define additional language types through
* hook_language_types_info(), and alter existing language type definitions
* through hook_language_types_info_alter().
*
* Language types may be configurable or fixed. The language negotiation
* providers associated with a configurable language type can be explicitly
* set through the user interface. A fixed language type has predetermined
* (module-defined) language negotiation settings and, thus, does not appear in
* the configuration page. Here is a code snippet that makes the content
* language (which by default inherits the interface language's values)
* configurable:
* @code
* function mymodule_language_types_info_alter(&$language_types) {
* unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']);
* }
* @endcode
*
* Every language type can have a different set of language negotiation
* providers assigned to it. Different language types often share the same
* language negotiation settings, but they can have independent settings if
* needed. If two language types are configured the same way, their language
* switcher configuration will be functionally identical and the same settings
* will act on both language types.
*
* Drupal defines the following built-in language negotiation providers:
* - URL: Determine the language from the URL (path prefix or domain).
* - Session: Determine the language from a request/session parameter.
* - User: Follow the user's language preference.
* - Browser: Determine the language from the browser's language settings.
* - Default language: Use the default site language.
* Language negotiation providers are simple callback functions that implement a
* particular logic to return a language code. For instance, the URL provider
* searches for a valid path prefix or domain name in the current request URL.
* If a language negotiation provider does not return a valid language code, the
* next provider associated to the language type (based on provider weight) is
* invoked.
*
* Modules can define additional language negotiation providers through
* hook_language_negotiation_info(), and alter existing providers through
* hook_language_negotiation_info_alter(). Here is an example snippet that lets
* path prefixes be ignored for administrative paths:
* @code
* function mymodule_language_negotiation_info_alter(&$negotiation_info) {
* // Replace the core function with our own function.
* module_load_include('language', 'inc', 'language.negotiation');
* $negotiation_info[LANGUAGE_NEGOTIATION_URL]['callbacks']['language'] = 'mymodule_from_url';
* $negotiation_info[LANGUAGE_NEGOTIATION_URL]['file'] = drupal_get_path('module', 'mymodule') . '/mymodule.module';
* }
*
* function mymodule_from_url($languages) {
* // Use the core URL language negotiation provider to get a valid language
* // code.
* module_load_include('language', 'inc', 'language.negotiation');
* $langcode = language_from_url($languages);
*
* // If we are on an administrative path, override with the default language.
* if (isset($_GET['q']) && strtok($_GET['q'], '/') == 'admin') {
* return language_default()->langcode;
* }
* return $langcode;
* }
* @endcode
*
* For more information, see
* @link http://drupal.org/node/1497272 Language Negotiation API @endlink
*/
/**
* Returns all the defined language types.
*
* @return
* An array of language type names. The name will be used as the global
* variable name the language value will be stored in.
*/
function language_types_info() {
$language_types = &drupal_static(__FUNCTION__);
if (!isset($language_types)) {
$language_types = module_invoke_all('language_types_info');
// Let other modules alter the list of language types.
drupal_alter('language_types_info', $language_types);
}
return $language_types;
}
/**
* Returns only the configurable language types.
*
* A language type maybe configurable or fixed. A fixed language type is a type
* whose language negotiation providers are module-defined and not altered
* through the user interface.
*
* @param $stored
* Optional. By default retrieves values from the 'language_types' variable to
* avoid unnecessary hook invocations.
* If set to FALSE retrieves values from the actual language type definitions.
* This allows to react to alterations performed on the definitions by modules
* installed after the 'language_types' variable is set.
*
* @return
* An array of language type names.
*/
function language_types_configurable($stored = TRUE) {
$configurable = &drupal_static(__FUNCTION__);
if ($stored && !isset($configurable)) {
$types = variable_get('language_types', drupal_language_types());
$configurable = array_keys(array_filter($types));
}
if (!$stored) {
$result = array();
foreach (language_types_info() as $type => $info) {
if (!isset($info['fixed'])) {
$result[] = $type;
}
}
return $result;
}
return $configurable;
}
/**
* Disables the given language types.
*
* @param $types
* An array of language types.
*/
function language_types_disable($types) {
$enabled_types = variable_get('language_types', drupal_language_types());
foreach ($types as $type) {
unset($enabled_types[$type]);
}
variable_set('language_types', $enabled_types);
}
/**
* Updates the language type configuration.
*/
function language_types_set() {
// Ensure that we are getting the defined language negotiation information. An
// invocation of module_enable() or module_disable() could outdate the cached
// information.
drupal_static_reset('language_types_info');
drupal_static_reset('language_negotiation_info');
// Determine which language types are configurable and which not by checking
// whether the 'fixed' key is defined. Non-configurable (fixed) language types
// have their language negotiation settings stored there.
$defined_providers = language_negotiation_info();
foreach (language_types_info() as $type => $info) {
if (isset($info['fixed'])) {
$language_types[$type] = FALSE;
$negotiation = array();
foreach ($info['fixed'] as $weight => $id) {
if (isset($defined_providers[$id])) {
$negotiation[$id] = $weight;
}
}
language_negotiation_set($type, $negotiation);
}
else {
$language_types[$type] = TRUE;
}
}
// Save language types.
variable_set('language_types', $language_types);
// Ensure that subsequent calls of language_types_configurable() return the
// updated language type information.
drupal_static_reset('language_types_configurable');
}
/**
* Checks whether a language negotiation provider is enabled for a language type.
*
* This has two possible behaviors:
* - If $provider_id is given return its ID if enabled, FALSE otherwise.
* - If no ID is passed the first enabled language negotiation provider is
* returned.
*
* @param $type
* The language negotiation provider type.
* @param $provider_id
* The language negotiation provider ID.
*
* @return
* The provider ID if it is enabled, FALSE otherwise.
*/
function language_negotiation_get($type, $provider_id = NULL) {
$negotiation = variable_get("language_negotiation_$type", array());
if (empty($negotiation)) {
return empty($provider_id) ? LANGUAGE_NEGOTIATION_DEFAULT : FALSE;
}
if (empty($provider_id)) {
return key($negotiation);
}
if (isset($negotiation[$provider_id])) {
return $provider_id;
}
return FALSE;
}
/**
* Checks if the language negotiation provider is enabled for any language type.
*
* @param $provider_id
* The language negotiation provider ID.
*
* @return
* TRUE if there is at least one language type for which the given language
* provider is enabled, FALSE otherwise.
*/
function language_negotiation_get_any($provider_id) {
foreach (language_types_configurable() as $type) {
if (language_negotiation_get($type, $provider_id)) {
return TRUE;
}
}
return FALSE;
}
/**
* Returns the language switch links for the given language.
*
* @param $type
* The language negotiation type.
* @param $path
* The internal path the switch links will be relative to.
*
* @return
* A keyed array of links ready to be themed.
*/
function language_negotiation_get_switch_links($type, $path) {
$links = FALSE;
$negotiation = variable_get("language_negotiation_$type", array());
// Only get the languages if we have more than one.
if (count(language_list()) >= 2) {
$language = language_initialize($type);
}
foreach ($negotiation as $id => $provider) {
if (isset($provider['callbacks']['switcher'])) {
if (isset($provider['file'])) {
require_once DRUPAL_ROOT . '/' . $provider['file'];
}
$callback = $provider['callbacks']['switcher'];
$result = $callback($type, $path);
// Add support for WCAG 2.0's Language of Parts to add language identifiers.
// http://www.w3.org/TR/UNDERSTANDING-WCAG20/meaning-other-lang-id.html
foreach ($result as $langcode => $link) {
$result[$langcode]['attributes']['xml:lang'] = $langcode;
}
if (!empty($result)) {
// Allow modules to provide translations for specific links.
drupal_alter('language_switch_links', $result, $type, $path);
$links = (object) array('links' => $result, 'provider' => $id);
break;
}
}
}
return $links;
}
/**
* Removes any unused language negotiation providers from the configuration.
*/
function language_negotiation_purge() {
// Ensure that we are getting the defined language negotiation information. An
// invocation of module_enable() or module_disable() could outdate the cached
// information.
drupal_static_reset('language_negotiation_info');
drupal_static_reset('language_types_info');
$defined_providers = language_negotiation_info();
foreach (language_types_info() as $type => $type_info) {
$weight = 0;
$negotiation = array();
foreach (variable_get("language_negotiation_$type", array()) as $id => $provider) {
if (isset($defined_providers[$id])) {
$negotiation[$id] = $weight++;
}
}
language_negotiation_set($type, $negotiation);
}
}
/**
* Saves a list of language negotiation providers.
*
* @param $type
* The language negotiation type.
* @param $language_providers
* An array of language negotiation provider weights keyed by provider ID.
* @see language_provider_weight()
*/
function language_negotiation_set($type, $language_providers) {
// Save only the necessary fields.
$provider_fields = array('callbacks', 'file', 'cache');
$negotiation = array();
$providers_weight = array();
$defined_providers = language_negotiation_info();
$default_types = language_types_configurable(FALSE);
// Initialize the providers weight list.
foreach ($language_providers as $id => $provider) {
$providers_weight[$id] = language_provider_weight($provider);
}
// Order providers list by weight.
asort($providers_weight);
foreach ($providers_weight as $id => $weight) {
if (isset($defined_providers[$id])) {
$provider = $defined_providers[$id];
// If the provider does not express any preference about types, make it
// available for any configurable type.
$types = array_flip(isset($provider['types']) ? $provider['types'] : $default_types);
// Check whether the provider is defined and has the right type.
if (isset($types[$type])) {
$provider_data = array();
foreach ($provider_fields as $field) {
if (isset($provider[$field])) {
$provider_data[$field] = $provider[$field];
}
}
$negotiation[$id] = $provider_data;
}
}
}
variable_set("language_negotiation_$type", $negotiation);
}
/**
* Returns all the defined language negotiation providers.
*
* @return
* An array of language negotiation providers.
*/
function language_negotiation_info() {
$language_providers = &drupal_static(__FUNCTION__);
if (!isset($language_providers)) {
// Collect all the module-defined language negotiation providers.
$language_providers = module_invoke_all('language_negotiation_info');
// Add the default language negotiation provider.
$language_providers[LANGUAGE_NEGOTIATION_DEFAULT] = array(
'callbacks' => array('language' => 'language_from_default'),
'weight' => 10,
'name' => t('Default'),
'description' => t('Use the default site language (@language_name).', array('@language_name' => language_default()->native)),
);
// Let other modules alter the list of language negotiation providers.
drupal_alter('language_negotiation_info', $language_providers);
}
return $language_providers;
}
/**
* Helper function used to cache the language negotiation providers results.
*
* @param $provider_id
* The language negotiation provider's identifier.
* @param $provider
* (optional) An associative array of information about the provider to be
* invoked (see hook_language_negotiation_info() for details). If not passed
* in, it will be loaded through language_negotiation_info().
*
* @return
* A language object representing the language chosen by the provider.
*/
function language_provider_invoke($provider_id, $provider = NULL) {
$results = &drupal_static(__FUNCTION__);
if (!isset($results[$provider_id])) {
global $user;
// Get languages grouped by status and select only the enabled ones.
$languages = language_list('enabled');
$languages = $languages[1];
if (!isset($provider)) {
$providers = language_negotiation_info();
$provider = $providers[$provider_id];
}
if (isset($provider['file'])) {
require_once DRUPAL_ROOT . '/' . $provider['file'];
}
// If the language negotiation provider has no cache preference or this is
// satisfied we can execute the callback.
$cache = !isset($provider['cache']) || $user->uid || $provider['cache'] == variable_get('cache', 0);
$callback = isset($provider['callbacks']['language']) ? $provider['callbacks']['language'] : FALSE;
$langcode = $cache && function_exists($callback) ? $callback($languages) : FALSE;
$results[$provider_id] = isset($languages[$langcode]) ? $languages[$langcode] : FALSE;
}
// Since objects are resources, we need to return a clone to prevent the
// language negotiation provider cache from being unintentionally altered. The
// same providers might be used with different language types based on
// configuration.
return !empty($results[$provider_id]) ? clone($results[$provider_id]) : $results[$provider_id];
}
/**
* Returns the passed language negotiation provider weight or a default value.
*
* @param $provider
* A language negotiation provider data structure.
*
* @return
* A numeric weight.
*/
function language_provider_weight($provider) {
$default = is_numeric($provider) ? $provider : 0;
return isset($provider['weight']) && is_numeric($provider['weight']) ? $provider['weight'] : $default;
}
/**
* Chooses a language based on language negotiation provider settings.
*
* @param $type
* The language type key to find the language for.
*
* @return
* The negotiated language object.
*/
function language_initialize($type) {
// Execute the language negotiation providers in the order they were set up and return the
// first valid language found.
$negotiation = variable_get("language_negotiation_$type", array());
foreach ($negotiation as $provider_id => $provider) {
$language = language_provider_invoke($provider_id, $provider);
if ($language) {
$language->provider = $provider_id;
return $language;
}
}
// If no other language was found use the default one.
$language = language_default();
$language->provider = LANGUAGE_NEGOTIATION_DEFAULT;
return $language;
}
/**
* Returns the default language negotiation provider.
*
* @return
* The default language code.
*/
function language_from_default() {
return language_default()->language;
}
/**
* Splits the given path into prefix and actual path.
*
* Parse the given path and return the language object identified by the prefix
* and the actual path.
*
* @param $path
* The path to split.
* @param $languages
* An array of valid languages.
*
* @return
* An array composed of:
* - A language object corresponding to the identified prefix on success,
* FALSE otherwise.
* - The path without the prefix on success, the given path otherwise.
*/
function language_url_split_prefix($path, $languages) {
$args = empty($path) ? array() : explode('/', $path);
$prefix = array_shift($args);
// Search prefix within enabled languages.
foreach ($languages as $language) {
if (!empty($language->prefix) && $language->prefix == $prefix) {
// Rebuild $path with the language removed.
return array($language, implode('/', $args));
}
}
return array(FALSE, $path);
}
/**
* Returns the possible fallback languages ordered by language weight.
*
* @param
* (optional) The language type. Defaults to LANGUAGE_TYPE_CONTENT.
*
* @return
* An array of language codes.
*/
function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) {
$fallback_candidates = &drupal_static(__FUNCTION__);
if (!isset($fallback_candidates)) {
$fallback_candidates = array();
// Get languages ordered by weight.
// Use array keys to avoid duplicated entries.
foreach (language_list('weight') as $languages) {
foreach ($languages as $language) {
$fallback_candidates[$language->language] = NULL;
}
}
$fallback_candidates = array_keys($fallback_candidates);
$fallback_candidates[] = LANGUAGE_NONE;
// Let other modules hook in and add/change candidates.
drupal_alter('language_fallback_candidates', $fallback_candidates);
}
return $fallback_candidates;
}
/**
* @} End of "language_negotiation"
*/
+2492
View File
File diff suppressed because it is too large Load Diff
+274
View File
@@ -0,0 +1,274 @@
<?php
/**
* @file
* A database-mediated implementation of a locking mechanism.
*/
/**
* @defgroup lock Locking mechanisms
* @{
* Functions to coordinate long-running operations across requests.
*
* In most environments, multiple Drupal page requests (a.k.a. threads or
* processes) will execute in parallel. This leads to potential conflicts or
* race conditions when two requests execute the same code at the same time. A
* common example of this is a rebuild like menu_rebuild() where we invoke many
* hook implementations to get and process data from all active modules, and
* then delete the current data in the database to insert the new afterwards.
*
* This is a cooperative, advisory lock system. Any long-running operation
* that could potentially be attempted in parallel by multiple requests should
* try to acquire a lock before proceeding. By obtaining a lock, one request
* notifies any other requests that a specific operation is in progress which
* must not be executed in parallel.
*
* To use this API, pick a unique name for the lock. A sensible choice is the
* name of the function performing the operation. A very simple example use of
* this API:
* @code
* function mymodule_long_operation() {
* if (lock_acquire('mymodule_long_operation')) {
* // Do the long operation here.
* // ...
* lock_release('mymodule_long_operation');
* }
* }
* @endcode
*
* If a function acquires a lock it should always release it when the
* operation is complete by calling lock_release(), as in the example.
*
* A function that has acquired a lock may attempt to renew a lock (extend the
* duration of the lock) by calling lock_acquire() again during the operation.
* Failure to renew a lock is indicative that another request has acquired
* the lock, and that the current operation may need to be aborted.
*
* If a function fails to acquire a lock it may either immediately return, or
* it may call lock_wait() if the rest of the current page request requires
* that the operation in question be complete. After lock_wait() returns,
* the function may again attempt to acquire the lock, or may simply allow the
* page request to proceed on the assumption that a parallel request completed
* the operation.
*
* lock_acquire() and lock_wait() will automatically break (delete) a lock
* whose duration has exceeded the timeout specified when it was acquired.
*
* Alternative implementations of this API (such as APC) may be substituted
* by setting the 'lock_inc' variable to an alternate include filepath. Since
* this is an API intended to support alternative implementations, code using
* this API should never rely upon specific implementation details (for example
* no code should look for or directly modify a lock in the {semaphore} table).
*/
/**
* Initialize the locking system.
*/
function lock_initialize() {
global $locks;
$locks = array();
}
/**
* Helper function to get this request's unique id.
*/
function _lock_id() {
// Do not use drupal_static(). This identifier refers to the current
// client request, and must not be changed under any circumstances
// else the shutdown handler may fail to release our locks.
static $lock_id;
if (!isset($lock_id)) {
// Assign a unique id.
$lock_id = uniqid(mt_rand(), TRUE);
// We only register a shutdown function if a lock is used.
drupal_register_shutdown_function('lock_release_all', $lock_id);
}
return $lock_id;
}
/**
* Acquire (or renew) a lock, but do not block if it fails.
*
* @param $name
* The name of the lock. Limit of name's length is 255 characters.
* @param $timeout
* A number of seconds (float) before the lock expires (minimum of 0.001).
*
* @return
* TRUE if the lock was acquired, FALSE if it failed.
*/
function lock_acquire($name, $timeout = 30.0) {
global $locks;
// Insure that the timeout is at least 1 ms.
$timeout = max($timeout, 0.001);
$expire = microtime(TRUE) + $timeout;
if (isset($locks[$name])) {
// Try to extend the expiration of a lock we already acquired.
$success = (bool) db_update('semaphore')
->fields(array('expire' => $expire))
->condition('name', $name)
->condition('value', _lock_id())
->execute();
if (!$success) {
// The lock was broken.
unset($locks[$name]);
}
return $success;
}
else {
// Optimistically try to acquire the lock, then retry once if it fails.
// The first time through the loop cannot be a retry.
$retry = FALSE;
// We always want to do this code at least once.
do {
try {
db_insert('semaphore')
->fields(array(
'name' => $name,
'value' => _lock_id(),
'expire' => $expire,
))
->execute();
// We track all acquired locks in the global variable.
$locks[$name] = TRUE;
// We never need to try again.
$retry = FALSE;
}
catch (PDOException $e) {
// Suppress the error. If this is our first pass through the loop,
// then $retry is FALSE. In this case, the insert must have failed
// meaning some other request acquired the lock but did not release it.
// We decide whether to retry by checking lock_may_be_available()
// Since this will break the lock in case it is expired.
$retry = $retry ? FALSE : lock_may_be_available($name);
}
// We only retry in case the first attempt failed, but we then broke
// an expired lock.
} while ($retry);
}
return isset($locks[$name]);
}
/**
* Check if lock acquired by a different process may be available.
*
* If an existing lock has expired, it is removed.
*
* @param $name
* The name of the lock.
*
* @return
* TRUE if there is no lock or it was removed, FALSE otherwise.
*/
function lock_may_be_available($name) {
$lock = db_query('SELECT expire, value FROM {semaphore} WHERE name = :name', array(':name' => $name))->fetchAssoc();
if (!$lock) {
return TRUE;
}
$expire = (float) $lock['expire'];
$now = microtime(TRUE);
if ($now > $expire) {
// We check two conditions to prevent a race condition where another
// request acquired the lock and set a new expire time. We add a small
// number to $expire to avoid errors with float to string conversion.
return (bool) db_delete('semaphore')
->condition('name', $name)
->condition('value', $lock['value'])
->condition('expire', 0.0001 + $expire, '<=')
->execute();
}
return FALSE;
}
/**
* Wait for a lock to be available.
*
* This function may be called in a request that fails to acquire a desired
* lock. This will block further execution until the lock is available or the
* specified delay in seconds is reached. This should not be used with locks
* that are acquired very frequently, since the lock is likely to be acquired
* again by a different request while waiting.
*
* @param $name
* The name of the lock.
* @param $delay
* The maximum number of seconds to wait, as an integer.
*
* @return
* TRUE if the lock holds, FALSE if it is available.
*/
function lock_wait($name, $delay = 30) {
// Pause the process for short periods between calling
// lock_may_be_available(). This prevents hitting the database with constant
// database queries while waiting, which could lead to performance issues.
// However, if the wait period is too long, there is the potential for a
// large number of processes to be blocked waiting for a lock, especially
// if the item being rebuilt is commonly requested. To address both of these
// concerns, begin waiting for 25ms, then add 25ms to the wait period each
// time until it reaches 500ms. After this point polling will continue every
// 500ms until $delay is reached.
// $delay is passed in seconds, but we will be using usleep(), which takes
// microseconds as a parameter. Multiply it by 1 million so that all
// further numbers are equivalent.
$delay = (int) $delay * 1000000;
// Begin sleeping at 25ms.
$sleep = 25000;
while ($delay > 0) {
// This function should only be called by a request that failed to get a
// lock, so we sleep first to give the parallel request a chance to finish
// and release the lock.
usleep($sleep);
// After each sleep, increase the value of $sleep until it reaches
// 500ms, to reduce the potential for a lock stampede.
$delay = $delay - $sleep;
$sleep = min(500000, $sleep + 25000, $delay);
if (lock_may_be_available($name)) {
// No longer need to wait.
return FALSE;
}
}
// The caller must still wait longer to get the lock.
return TRUE;
}
/**
* Release a lock previously acquired by lock_acquire().
*
* This will release the named lock if it is still held by the current request.
*
* @param $name
* The name of the lock.
*/
function lock_release($name) {
global $locks;
unset($locks[$name]);
db_delete('semaphore')
->condition('name', $name)
->condition('value', _lock_id())
->execute();
}
/**
* Release all previously acquired locks.
*/
function lock_release_all($lock_id = NULL) {
global $locks;
$locks = array();
if (empty($lock_id)) {
$lock_id = _lock_id();
}
db_delete('semaphore')
->condition('value', $lock_id)
->execute();
}
/**
* @} End of "defgroup lock".
*/
+623
View File
@@ -0,0 +1,623 @@
<?php
/**
* @file
* API functions for processing and sending e-mail.
*/
/**
* Auto-detect appropriate line endings for e-mails.
*
* $conf['mail_line_endings'] will override this setting.
*/
define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE) ? "\r\n" : "\n");
/**
* Composes and optionally sends an e-mail message.
*
* Sending an e-mail works with defining an e-mail template (subject, text
* and possibly e-mail headers) and the replacement values to use in the
* appropriate places in the template. Processed e-mail templates are
* requested from hook_mail() from the module sending the e-mail. Any module
* can modify the composed e-mail message array using hook_mail_alter().
* Finally drupal_mail_system()->mail() sends the e-mail, which can
* be reused if the exact same composed e-mail is to be sent to multiple
* recipients.
*
* Finding out what language to send the e-mail with needs some consideration.
* If you send e-mail to a user, her preferred language should be fine, so
* use user_preferred_language(). If you send email based on form values
* filled on the page, there are two additional choices if you are not
* sending the e-mail to a user on the site. You can either use the language
* used to generate the page ($language global variable) or the site default
* language. See language_default(). The former is good if sending e-mail to
* the person filling the form, the later is good if you send e-mail to an
* address previously set up (like contact addresses in a contact form).
*
* Taking care of always using the proper language is even more important
* when sending e-mails in a row to multiple users. Hook_mail() abstracts
* whether the mail text comes from an administrator setting or is
* static in the source code. It should also deal with common mail tokens,
* only receiving $params which are unique to the actual e-mail at hand.
*
* An example:
*
* @code
* function example_notify($accounts) {
* foreach ($accounts as $account) {
* $params['account'] = $account;
* // example_mail() will be called based on the first drupal_mail() parameter.
* drupal_mail('example', 'notice', $account->mail, user_preferred_language($account), $params);
* }
* }
*
* function example_mail($key, &$message, $params) {
* $data['user'] = $params['account'];
* $options['language'] = $message['language'];
* user_mail_tokens($variables, $data, $options);
* switch($key) {
* case 'notice':
* // If the recipient can receive such notices by instant-message, do
* // not send by email.
* if (example_im_send($key, $message, $params)) {
* $message['send'] = FALSE;
* break;
* }
* $langcode = $message['language']->language;
* $message['subject'] = t('Notification from !site', $variables, array('langcode' => $langcode));
* $message['body'][] = t("Dear !username\n\nThere is new content available on the site.", $variables, array('langcode' => $langcode));
* break;
* }
* }
* @endcode
*
* Another example, which uses drupal_mail() to format a message for sending
* later:
*
* @code
* $params = array('current_conditions' => $data);
* $to = 'user@example.com';
* $message = drupal_mail('example', 'notice', $to, $language, $params, FALSE);
* // Only add to the spool if sending was not canceled.
* if ($message['send']) {
* example_spool_message($message);
* }
* @endcode
*
* @param $module
* A module name to invoke hook_mail() on. The {$module}_mail() hook will be
* called to complete the $message structure which will already contain common
* defaults.
* @param $key
* A key to identify the e-mail sent. The final e-mail id for e-mail altering
* will be {$module}_{$key}.
* @param $to
* The e-mail address or addresses where the message will be sent to. The
* formatting of this string will be validated with the
* @link http://php.net/manual/filter.filters.validate.php PHP e-mail validation filter. @endlink
* Some examples are:
* - user@example.com
* - user@example.com, anotheruser@example.com
* - User <user@example.com>
* - User <user@example.com>, Another User <anotheruser@example.com>
* @param $language
* Language object to use to compose the e-mail.
* @param $params
* Optional parameters to build the e-mail.
* @param $from
* Sets From to this value, if given.
* @param $send
* If TRUE, drupal_mail() will call drupal_mail_system()->mail() to deliver
* the message, and store the result in $message['result']. Modules
* implementing hook_mail_alter() may cancel sending by setting
* $message['send'] to FALSE.
*
* @return
* The $message array structure containing all details of the
* message. If already sent ($send = TRUE), then the 'result' element
* will contain the success indicator of the e-mail, failure being already
* written to the watchdog. (Success means nothing more than the message being
* accepted at php-level, which still doesn't guarantee it to be delivered.)
*/
function drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE) {
$default_from = variable_get('site_mail', ini_get('sendmail_from'));
// Bundle up the variables into a structured array for altering.
$message = array(
'id' => $module . '_' . $key,
'module' => $module,
'key' => $key,
'to' => $to,
'from' => isset($from) ? $from : $default_from,
'language' => $language,
'params' => $params,
'send' => TRUE,
'subject' => '',
'body' => array()
);
// Build the default headers
$headers = array(
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal'
);
if ($default_from) {
// To prevent e-mail from looking like spam, the addresses in the Sender and
// Return-Path headers should have a domain authorized to use the originating
// SMTP server.
$headers['From'] = $headers['Sender'] = $headers['Return-Path'] = $default_from;
}
if ($from) {
$headers['From'] = $from;
}
$message['headers'] = $headers;
// Build the e-mail (get subject and body, allow additional headers) by
// invoking hook_mail() on this module. We cannot use module_invoke() as
// we need to have $message by reference in hook_mail().
if (function_exists($function = $module . '_mail')) {
$function($key, $message, $params);
}
// Invoke hook_mail_alter() to allow all modules to alter the resulting e-mail.
drupal_alter('mail', $message);
// Retrieve the responsible implementation for this message.
$system = drupal_mail_system($module, $key);
// Format the message body.
$message = $system->format($message);
// Optionally send e-mail.
if ($send) {
// The original caller requested sending. Sending was canceled by one or
// more hook_mail_alter() implementations. We set 'result' to NULL, because
// FALSE indicates an error in sending.
if (empty($message['send'])) {
$message['result'] = NULL;
}
// Sending was originally requested and was not canceled.
else {
$message['result'] = $system->mail($message);
// Log errors.
if (!$message['result']) {
watchdog('mail', 'Error sending e-mail (from %from to %to).', array('%from' => $message['from'], '%to' => $message['to']), WATCHDOG_ERROR);
drupal_set_message(t('Unable to send e-mail. Contact the site administrator if the problem persists.'), 'error');
}
}
}
return $message;
}
/**
* Returns an object that implements the MailSystemInterface interface.
*
* Allows for one or more custom mail backends to format and send mail messages
* composed using drupal_mail().
*
* An implementation needs to implement the following methods:
* - format: Allows to preprocess, format, and postprocess a mail
* message before it is passed to the sending system. By default, all messages
* may contain HTML and are converted to plain-text by the DefaultMailSystem
* implementation. For example, an alternative implementation could override
* the default implementation and additionally sanitize the HTML for usage in
* a MIME-encoded e-mail, but still invoking the DefaultMailSystem
* implementation to generate an alternate plain-text version for sending.
* - mail: Sends a message through a custom mail sending engine.
* By default, all messages are sent via PHP's mail() function by the
* DefaultMailSystem implementation.
*
* The selection of a particular implementation is controlled via the variable
* 'mail_system', which is a keyed array. The default implementation
* is the class whose name is the value of 'default-system' key. A more specific
* match first to key and then to module will be used in preference to the
* default. To specify a different class for all mail sent by one module, set
* the class name as the value for the key corresponding to the module name. To
* specify a class for a particular message sent by one module, set the class
* name as the value for the array key that is the message id, which is
* "${module}_${key}".
*
* For example to debug all mail sent by the user module by logging it to a
* file, you might set the variable as something like:
*
* @code
* array(
* 'default-system' => 'DefaultMailSystem',
* 'user' => 'DevelMailLog',
* );
* @endcode
*
* Finally, a different system can be specified for a specific e-mail ID (see
* the $key param), such as one of the keys used by the contact module:
*
* @code
* array(
* 'default-system' => 'DefaultMailSystem',
* 'user' => 'DevelMailLog',
* 'contact_page_autoreply' => 'DrupalDevNullMailSend',
* );
* @endcode
*
* Other possible uses for system include a mail-sending class that actually
* sends (or duplicates) each message to SMS, Twitter, instant message, etc, or
* a class that queues up a large number of messages for more efficient bulk
* sending or for sending via a remote gateway so as to reduce the load
* on the local server.
*
* @param $module
* The module name which was used by drupal_mail() to invoke hook_mail().
* @param $key
* A key to identify the e-mail sent. The final e-mail ID for the e-mail
* alter hook in drupal_mail() would have been {$module}_{$key}.
*
* @return MailSystemInterface
*/
function drupal_mail_system($module, $key) {
$instances = &drupal_static(__FUNCTION__, array());
$id = $module . '_' . $key;
$configuration = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
// Look for overrides for the default class, starting from the most specific
// id, and falling back to the module name.
if (isset($configuration[$id])) {
$class = $configuration[$id];
}
elseif (isset($configuration[$module])) {
$class = $configuration[$module];
}
else {
$class = $configuration['default-system'];
}
if (empty($instances[$class])) {
$interfaces = class_implements($class);
if (isset($interfaces['MailSystemInterface'])) {
$instances[$class] = new $class();
}
else {
throw new Exception(t('Class %class does not implement interface %interface', array('%class' => $class, '%interface' => 'MailSystemInterface')));
}
}
return $instances[$class];
}
/**
* An interface for pluggable mail back-ends.
*/
interface MailSystemInterface {
/**
* Format a message composed by drupal_mail() prior sending.
*
* @param $message
* A message array, as described in hook_mail_alter().
*
* @return
* The formatted $message.
*/
public function format(array $message);
/**
* Send a message composed by drupal_mail().
*
* @param $message
* Message array with at least the following elements:
* - id: A unique identifier of the e-mail type. Examples: 'contact_user_copy',
* 'user_password_reset'.
* - to: The mail address or addresses where the message will be sent to.
* The formatting of this string will be validated with the
* @link http://php.net/manual/filter.filters.validate.php PHP e-mail validation filter. @endlink
* Some examples are:
* - user@example.com
* - user@example.com, anotheruser@example.com
* - User <user@example.com>
* - User <user@example.com>, Another User <anotheruser@example.com>
* - subject: Subject of the e-mail to be sent. This must not contain any
* newline characters, or the mail may not be sent properly.
* - body: Message to be sent. Accepts both CRLF and LF line-endings.
* E-mail bodies must be wrapped. You can use drupal_wrap_mail() for
* smart plain text wrapping.
* - headers: Associative array containing all additional mail headers not
* defined by one of the other parameters. PHP's mail() looks for Cc and
* Bcc headers and sends the mail to addresses in these headers too.
*
* @return
* TRUE if the mail was successfully accepted for delivery, otherwise FALSE.
*/
public function mail(array $message);
}
/**
* Performs format=flowed soft wrapping for mail (RFC 3676).
*
* We use delsp=yes wrapping, but only break non-spaced languages when
* absolutely necessary to avoid compatibility issues.
*
* We deliberately use LF rather than CRLF, see drupal_mail().
*
* @param string $text
* The plain text to process.
* @param string $indent (optional)
* A string to indent the text with. Only '>' characters are repeated on
* subsequent wrapped lines. Others are replaced by spaces.
*
* @return string
* The content of the email as a string with formatting applied.
*/
function drupal_wrap_mail($text, $indent = '') {
// Convert CRLF into LF.
$text = str_replace("\r", '', $text);
// See if soft-wrapping is allowed.
$clean_indent = _drupal_html_to_text_clean($indent);
$soft = strpos($clean_indent, ' ') === FALSE;
// Check if the string has line breaks.
if (strpos($text, "\n") !== FALSE) {
// Remove trailing spaces to make existing breaks hard, but leave signature
// marker untouched (RFC 3676, Section 4.3).
$text = preg_replace('/(?(?<!^--) +\n| +\n)/m', "\n", $text);
// Wrap each line at the needed width.
$lines = explode("\n", $text);
array_walk($lines, '_drupal_wrap_mail_line', array('soft' => $soft, 'length' => strlen($indent)));
$text = implode("\n", $lines);
}
else {
// Wrap this line.
_drupal_wrap_mail_line($text, 0, array('soft' => $soft, 'length' => strlen($indent)));
}
// Empty lines with nothing but spaces.
$text = preg_replace('/^ +\n/m', "\n", $text);
// Space-stuff special lines.
$text = preg_replace('/^(>| |From)/m', ' $1', $text);
// Apply indentation. We only include non-'>' indentation on the first line.
$text = $indent . substr(preg_replace('/^/m', $clean_indent, $text), strlen($indent));
return $text;
}
/**
* Transforms an HTML string into plain text, preserving its structure.
*
* The output will be suitable for use as 'format=flowed; delsp=yes' text
* (RFC 3676) and can be passed directly to drupal_mail() for sending.
*
* We deliberately use LF rather than CRLF, see drupal_mail().
*
* This function provides suitable alternatives for the following tags:
* <a> <em> <i> <strong> <b> <br> <p> <blockquote> <ul> <ol> <li> <dl> <dt>
* <dd> <h1> <h2> <h3> <h4> <h5> <h6> <hr>
*
* @param $string
* The string to be transformed.
* @param $allowed_tags (optional)
* If supplied, a list of tags that will be transformed. If omitted, all
* all supported tags are transformed.
*
* @return
* The transformed string.
*/
function drupal_html_to_text($string, $allowed_tags = NULL) {
// Cache list of supported tags.
static $supported_tags;
if (empty($supported_tags)) {
$supported_tags = array('a', 'em', 'i', 'strong', 'b', 'br', 'p', 'blockquote', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr');
}
// Make sure only supported tags are kept.
$allowed_tags = isset($allowed_tags) ? array_intersect($supported_tags, $allowed_tags) : $supported_tags;
// Make sure tags, entities and attributes are well-formed and properly nested.
$string = _filter_htmlcorrector(filter_xss($string, $allowed_tags));
// Apply inline styles.
$string = preg_replace('!</?(em|i)((?> +)[^>]*)?>!i', '/', $string);
$string = preg_replace('!</?(strong|b)((?> +)[^>]*)?>!i', '*', $string);
// Replace inline <a> tags with the text of link and a footnote.
// 'See <a href="http://drupal.org">the Drupal site</a>' becomes
// 'See the Drupal site [1]' with the URL included as a footnote.
_drupal_html_to_mail_urls(NULL, TRUE);
$pattern = '@(<a[^>]+?href="([^"]*)"[^>]*?>(.+?)</a>)@i';
$string = preg_replace_callback($pattern, '_drupal_html_to_mail_urls', $string);
$urls = _drupal_html_to_mail_urls();
$footnotes = '';
if (count($urls)) {
$footnotes .= "\n";
for ($i = 0, $max = count($urls); $i < $max; $i++) {
$footnotes .= '[' . ($i + 1) . '] ' . $urls[$i] . "\n";
}
}
// Split tags from text.
$split = preg_split('/<([^>]+?)>/', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
// Note: PHP ensures the array consists of alternating delimiters and literals
// and begins and ends with a literal (inserting $null as required).
$tag = FALSE; // Odd/even counter (tag or no tag)
$casing = NULL; // Case conversion function
$output = '';
$indent = array(); // All current indentation string chunks
$lists = array(); // Array of counters for opened lists
foreach ($split as $value) {
$chunk = NULL; // Holds a string ready to be formatted and output.
// Process HTML tags (but don't output any literally).
if ($tag) {
list($tagname) = explode(' ', strtolower($value), 2);
switch ($tagname) {
// List counters
case 'ul':
array_unshift($lists, '*');
break;
case 'ol':
array_unshift($lists, 1);
break;
case '/ul':
case '/ol':
array_shift($lists);
$chunk = ''; // Ensure blank new-line.
break;
// Quotation/list markers, non-fancy headers
case 'blockquote':
// Format=flowed indentation cannot be mixed with lists.
$indent[] = count($lists) ? ' "' : '>';
break;
case 'li':
$indent[] = isset($lists[0]) && is_numeric($lists[0]) ? ' ' . $lists[0]++ . ') ' : ' * ';
break;
case 'dd':
$indent[] = ' ';
break;
case 'h3':
$indent[] = '.... ';
break;
case 'h4':
$indent[] = '.. ';
break;
case '/blockquote':
if (count($lists)) {
// Append closing quote for inline quotes (immediately).
$output = rtrim($output, "> \n") . "\"\n";
$chunk = ''; // Ensure blank new-line.
}
// Fall-through
case '/li':
case '/dd':
array_pop($indent);
break;
case '/h3':
case '/h4':
array_pop($indent);
case '/h5':
case '/h6':
$chunk = ''; // Ensure blank new-line.
break;
// Fancy headers
case 'h1':
$indent[] = '======== ';
$casing = 'drupal_strtoupper';
break;
case 'h2':
$indent[] = '-------- ';
$casing = 'drupal_strtoupper';
break;
case '/h1':
case '/h2':
$casing = NULL;
// Pad the line with dashes.
$output = _drupal_html_to_text_pad($output, ($tagname == '/h1') ? '=' : '-', ' ');
array_pop($indent);
$chunk = ''; // Ensure blank new-line.
break;
// Horizontal rulers
case 'hr':
// Insert immediately.
$output .= drupal_wrap_mail('', implode('', $indent)) . "\n";
$output = _drupal_html_to_text_pad($output, '-');
break;
// Paragraphs and definition lists
case '/p':
case '/dl':
$chunk = ''; // Ensure blank new-line.
break;
}
}
// Process blocks of text.
else {
// Convert inline HTML text to plain text; not removing line-breaks or
// white-space, since that breaks newlines when sanitizing plain-text.
$value = trim(decode_entities($value));
if (drupal_strlen($value)) {
$chunk = $value;
}
}
// See if there is something waiting to be output.
if (isset($chunk)) {
// Apply any necessary case conversion.
if (isset($casing)) {
$chunk = $casing($chunk);
}
// Format it and apply the current indentation.
$output .= drupal_wrap_mail($chunk, implode('', $indent)) . MAIL_LINE_ENDINGS;
// Remove non-quotation markers from indentation.
$indent = array_map('_drupal_html_to_text_clean', $indent);
}
$tag = !$tag;
}
return $output . $footnotes;
}
/**
* Wraps words on a single line.
*
* Callback for array_walk() winthin drupal_wrap_mail().
*/
function _drupal_wrap_mail_line(&$line, $key, $values) {
// Use soft-breaks only for purely quoted or unindented text.
$line = wordwrap($line, 77 - $values['length'], $values['soft'] ? " \n" : "\n");
// Break really long words at the maximum width allowed.
$line = wordwrap($line, 996 - $values['length'], $values['soft'] ? " \n" : "\n", TRUE);
}
/**
* Keeps track of URLs and replaces them with placeholder tokens.
*
* Callback for preg_replace_callback() within drupal_html_to_text().
*/
function _drupal_html_to_mail_urls($match = NULL, $reset = FALSE) {
global $base_url, $base_path;
static $urls = array(), $regexp;
if ($reset) {
// Reset internal URL list.
$urls = array();
}
else {
if (empty($regexp)) {
$regexp = '@^' . preg_quote($base_path, '@') . '@';
}
if ($match) {
list(, , $url, $label) = $match;
// Ensure all URLs are absolute.
$urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url . '/', $url);
return $label . ' [' . count($urls) . ']';
}
}
return $urls;
}
/**
* Replaces non-quotation markers from a given piece of indentation with spaces.
*
* Callback for array_map() within drupal_html_to_text().
*/
function _drupal_html_to_text_clean($indent) {
return preg_replace('/[^>]/', ' ', $indent);
}
/**
* Pads the last line with the given character.
*
* @see drupal_html_to_text()
*/
function _drupal_html_to_text_pad($text, $pad, $prefix = '') {
// Remove last line break.
$text = substr($text, 0, -1);
// Calculate needed padding space and add it.
if (($p = strrpos($text, "\n")) === FALSE) {
$p = -1;
}
$n = max(0, 79 - (strlen($text) - $p) - strlen($prefix));
// Add prefix and padding, and restore linebreak.
return $text . $prefix . str_repeat($pad, $n) . "\n";
}
+3958
View File
File diff suppressed because it is too large Load Diff
+1173
View File
File diff suppressed because it is too large Load Diff
+694
View File
@@ -0,0 +1,694 @@
<?php
/**
* @file
* Functions to aid in presenting database results as a set of pages.
*/
/**
* Query extender for pager queries.
*
* This is the "default" pager mechanism. It creates a paged query with a fixed
* number of entries per page.
*/
class PagerDefault extends SelectQueryExtender {
/**
* The highest element we've autogenerated so far.
*
* @var int
*/
static $maxElement = 0;
/**
* The number of elements per page to allow.
*
* @var int
*/
protected $limit = 10;
/**
* The unique ID of this pager on this page.
*
* @var int
*/
protected $element = NULL;
/**
* The count query that will be used for this pager.
*
* @var SelectQueryInterface
*/
protected $customCountQuery = FALSE;
public function __construct(SelectQueryInterface $query, DatabaseConnection $connection) {
parent::__construct($query, $connection);
// Add pager tag. Do this here to ensure that it is always added before
// preExecute() is called.
$this->addTag('pager');
}
/**
* Override the execute method.
*
* Before we run the query, we need to add pager-based range() instructions
* to it.
*/
public function execute() {
// Add convenience tag to mark that this is an extended query. We have to
// do this in the constructor to ensure that it is set before preExecute()
// gets called.
if (!$this->preExecute($this)) {
return NULL;
}
// A NULL limit is the "kill switch" for pager queries.
if (empty($this->limit)) {
return;
}
$this->ensureElement();
$total_items = $this->getCountQuery()->execute()->fetchField();
$current_page = pager_default_initialize($total_items, $this->limit, $this->element);
$this->range($current_page * $this->limit, $this->limit);
// Now that we've added our pager-based range instructions, run the query normally.
return $this->query->execute();
}
/**
* Ensure that there is an element associated with this query.
* If an element was not specified previously, then the value of the
* $maxElement counter is taken, after which the counter is incremented.
*
* After running this method, access $this->element to get the element for this
* query.
*/
protected function ensureElement() {
if (!isset($this->element)) {
$this->element = self::$maxElement++;
}
}
/**
* Specify the count query object to use for this pager.
*
* You will rarely need to specify a count query directly. If not specified,
* one is generated off of the pager query itself.
*
* @param SelectQueryInterface $query
* The count query object. It must return a single row with a single column,
* which is the total number of records.
*/
public function setCountQuery(SelectQueryInterface $query) {
$this->customCountQuery = $query;
}
/**
* Retrieve the count query for this pager.
*
* The count query may be specified manually or, by default, taken from the
* query we are extending.
*
* @return SelectQueryInterface
* A count query object.
*/
public function getCountQuery() {
if ($this->customCountQuery) {
return $this->customCountQuery;
}
else {
return $this->query->countQuery();
}
}
/**
* Specify the maximum number of elements per page for this query.
*
* The default if not specified is 10 items per page.
*
* @param $limit
* An integer specifying the number of elements per page. If passed a false
* value (FALSE, 0, NULL), the pager is disabled.
*/
public function limit($limit = 10) {
$this->limit = $limit;
return $this;
}
/**
* Specify the element ID for this pager query.
*
* The element is used to differentiate different pager queries on the same
* page so that they may be operated independently. If you do not specify an
* element, every pager query on the page will get a unique element. If for
* whatever reason you want to explicitly define an element for a given query,
* you may do so here.
*
* Setting the element here also increments the static $maxElement counter,
* which is used for determining the $element when there's none specified.
*
* Note that no collision detection is done when setting an element ID
* explicitly, so it is possible for two pagers to end up using the same ID
* if both are set explicitly.
*
* @param $element
*/
public function element($element) {
$this->element = $element;
if ($element >= self::$maxElement) {
self::$maxElement = $element + 1;
}
return $this;
}
}
/**
* Returns the current page being requested for display within a pager.
*
* @param $element
* An optional integer to distinguish between multiple pagers on one page.
*
* @return
* The number of the current requested page, within the pager represented by
* $element. This is determined from the URL query parameter $_GET['page'], or
* 0 by default. Note that this number may differ from the actual page being
* displayed. For example, if a search for "example text" brings up three
* pages of results, but a users visits search/node/example+text?page=10, this
* function will return 10, even though the default pager implementation
* adjusts for this and still displays the third page of search results at
* that URL.
*
* @see pager_default_initialize()
*/
function pager_find_page($element = 0) {
$page = isset($_GET['page']) ? $_GET['page'] : '';
$page_array = explode(',', $page);
if (!isset($page_array[$element])) {
$page_array[$element] = 0;
}
return (int) $page_array[$element];
}
/**
* Initializes a pager for theme('pager').
*
* This function sets up the necessary global variables so that future calls
* to theme('pager') will render a pager that correctly corresponds to the
* items being displayed.
*
* If the items being displayed result from a database query performed using
* Drupal's database API, and if you have control over the construction of the
* database query, you do not need to call this function directly; instead, you
* can simply extend the query object with the 'PagerDefault' extender before
* executing it. For example:
* @code
* $query = db_select('some_table')->extend('PagerDefault');
* @endcode
*
* However, if you are using a different method for generating the items to be
* paged through, then you should call this function in preparation.
*
* The following example shows how this function can be used in a page callback
* that invokes an external datastore with an SQL-like syntax:
* @code
* // First find the total number of items and initialize the pager.
* $where = "status = 1";
* $total = mymodule_select("SELECT COUNT(*) FROM data " . $where)->result();
* $num_per_page = variable_get('mymodule_num_per_page', 10);
* $page = pager_default_initialize($total, $num_per_page);
*
* // Next, retrieve and display the items for the current page.
* $offset = $num_per_page * $page;
* $result = mymodule_select("SELECT * FROM data " . $where . " LIMIT %d, %d", $offset, $num_per_page)->fetchAll();
* $output = theme('mymodule_results', array('result' => $result));
*
* // Finally, display the pager controls, and return.
* $output .= theme('pager');
* return $output;
* @endcode
*
* A second example involves a page callback that invokes an external search
* service where the total number of matching results is provided as part of
* the returned set (so that we do not need a separate query in order to obtain
* this information). Here, we call pager_find_page() to calculate the desired
* offset before the search is invoked:
* @code
* // Perform the query, using the requested offset from pager_find_page().
* // This comes from a URL parameter, so here we are assuming that the URL
* // parameter corresponds to an actual page of results that will exist
* // within the set.
* $page = pager_find_page();
* $num_per_page = variable_get('mymodule_num_per_page', 10);
* $offset = $num_per_page * $page;
* $result = mymodule_remote_search($keywords, $offset, $num_per_page);
*
* // Now that we have the total number of results, initialize the pager.
* pager_default_initialize($result->total, $num_per_page);
*
* // Display the search results.
* $output = theme('search_results', array('results' => $result->data, 'type' => 'remote'));
*
* // Finally, display the pager controls, and return.
* $output .= theme('pager');
* return $output;
* @endcode
*
* @param $total
* The total number of items to be paged.
* @param $limit
* The number of items the calling code will display per page.
* @param $element
* An optional integer to distinguish between multiple pagers on one page.
*
* @return
* The number of the current page, within the pager represented by $element.
* This is determined from the URL query parameter $_GET['page'], or 0 by
* default. However, if a page that does not correspond to the actual range
* of the result set was requested, this function will return the closest
* page actually within the result set.
*/
function pager_default_initialize($total, $limit, $element = 0) {
global $pager_page_array, $pager_total, $pager_total_items, $pager_limits;
$page = pager_find_page($element);
// We calculate the total of pages as ceil(items / limit).
$pager_total_items[$element] = $total;
$pager_total[$element] = ceil($pager_total_items[$element] / $limit);
$pager_page_array[$element] = max(0, min($page, ((int) $pager_total[$element]) - 1));
$pager_limits[$element] = $limit;
return $pager_page_array[$element];
}
/**
* Compose a URL query parameter array for pager links.
*
* @return
* A URL query parameter array that consists of all components of the current
* page request except for those pertaining to paging.
*/
function pager_get_query_parameters() {
$query = &drupal_static(__FUNCTION__);
if (!isset($query)) {
$query = drupal_get_query_parameters($_GET, array('q', 'page'));
}
return $query;
}
/**
* Returns HTML for a query pager.
*
* Menu callbacks that display paged query results should call theme('pager') to
* retrieve a pager control so that users can view other results. Format a list
* of nearby pages with additional query results.
*
* @param $variables
* An associative array containing:
* - tags: An array of labels for the controls in the pager.
* - element: An optional integer to distinguish between multiple pagers on
* one page.
* - parameters: An associative array of query string parameters to append to
* the pager links.
* - quantity: The number of pages in the list.
*
* @ingroup themeable
*/
function theme_pager($variables) {
$tags = $variables['tags'];
$element = $variables['element'];
$parameters = $variables['parameters'];
$quantity = empty($variables['quantity']) ? 0 : $variables['quantity'];
global $pager_page_array, $pager_total;
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element]) || !isset($pager_total[$element])) {
return;
}
// Nothing to do if there is only one page.
if ($pager_total[$element] <= 1) {
return;
}
// Calculate various markers within this pager piece:
// Middle is used to "center" pages around the current page.
$pager_middle = ceil($quantity / 2);
// current is the page we are currently paged to
$pager_current = $pager_page_array[$element] + 1;
// first is the first page listed by this pager piece (re quantity)
$pager_first = $pager_current - $pager_middle + 1;
// last is the last page listed by this pager piece (re quantity)
$pager_last = $pager_current + $quantity - $pager_middle;
// max is the maximum page number
$pager_max = $pager_total[$element];
// End of marker calculations.
// Prepare for generation loop.
$i = $pager_first;
if ($pager_last > $pager_max) {
// Adjust "center" if at end of query.
$i = $i + ($pager_max - $pager_last);
$pager_last = $pager_max;
}
if ($i <= 0) {
// Adjust "center" if at start of query.
$pager_last = $pager_last + (1 - $i);
$i = 1;
}
// End of generation loop preparation.
$li_first = theme('pager_first', array('text' => (isset($tags[0]) ? $tags[0] : t('« first')), 'element' => $element, 'parameters' => $parameters));
$li_previous = theme('pager_previous', array('text' => (isset($tags[1]) ? $tags[1] : t(' previous')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters));
$li_next = theme('pager_next', array('text' => (isset($tags[3]) ? $tags[3] : t('next ')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters));
$li_last = theme('pager_last', array('text' => (isset($tags[4]) ? $tags[4] : t('last »')), 'element' => $element, 'parameters' => $parameters));
if ($pager_total[$element] > 1) {
if ($li_first) {
$items[] = array(
'class' => array('pager-first'),
'data' => $li_first,
);
}
if ($li_previous) {
$items[] = array(
'class' => array('pager-previous'),
'data' => $li_previous,
);
}
// When there is more than one page, create the pager list.
if ($i != $pager_max) {
if ($i > 1) {
$items[] = array(
'class' => array('pager-ellipsis'),
'data' => '…',
);
}
// Now generate the actual pager piece.
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
if ($i < $pager_current) {
$items[] = array(
'class' => array('pager-item'),
'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($pager_current - $i), 'parameters' => $parameters)),
);
}
if ($i == $pager_current) {
$items[] = array(
'class' => array('pager-current'),
'data' => $i,
);
}
if ($i > $pager_current) {
$items[] = array(
'class' => array('pager-item'),
'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $pager_current), 'parameters' => $parameters)),
);
}
}
if ($i < $pager_max) {
$items[] = array(
'class' => array('pager-ellipsis'),
'data' => '…',
);
}
}
// End generation.
if ($li_next) {
$items[] = array(
'class' => array('pager-next'),
'data' => $li_next,
);
}
if ($li_last) {
$items[] = array(
'class' => array('pager-last'),
'data' => $li_last,
);
}
return '<h2 class="element-invisible">' . t('Pages') . '</h2>' . theme('item_list', array(
'items' => $items,
'attributes' => array('class' => array('pager')),
));
}
}
/**
* @defgroup pagerpieces Pager pieces
* @{
* Theme functions for customizing pager elements.
*
* Note that you should NOT modify this file to customize your pager.
*/
/**
* Returns HTML for the "first page" link in a query pager.
*
* @param $variables
* An associative array containing:
* - text: The name (or image) of the link.
* - element: An optional integer to distinguish between multiple pagers on
* one page.
* - parameters: An associative array of query string parameters to append to
* the pager links.
*
* @ingroup themeable
*/
function theme_pager_first($variables) {
$text = $variables['text'];
$element = $variables['element'];
$parameters = $variables['parameters'];
global $pager_page_array;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element])) {
return;
}
// If we are anywhere but the first page
if ($pager_page_array[$element] > 0) {
$output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array(0, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters));
}
return $output;
}
/**
* Returns HTML for the "previous page" link in a query pager.
*
* @param $variables
* An associative array containing:
* - text: The name (or image) of the link.
* - element: An optional integer to distinguish between multiple pagers on
* one page.
* - interval: The number of pages to move backward when the link is clicked.
* - parameters: An associative array of query string parameters to append to
* the pager links.
*
* @ingroup themeable
*/
function theme_pager_previous($variables) {
$text = $variables['text'];
$element = $variables['element'];
$interval = $variables['interval'];
$parameters = $variables['parameters'];
global $pager_page_array;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element])) {
return;
}
// If we are anywhere but the first page
if ($pager_page_array[$element] > 0) {
$page_new = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array);
// If the previous page is the first page, mark the link as such.
if ($page_new[$element] == 0) {
$output = theme('pager_first', array('text' => $text, 'element' => $element, 'parameters' => $parameters));
}
// The previous page is not the first page.
else {
$output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters));
}
}
return $output;
}
/**
* Returns HTML for the "next page" link in a query pager.
*
* @param $variables
* An associative array containing:
* - text: The name (or image) of the link.
* - element: An optional integer to distinguish between multiple pagers on
* one page.
* - interval: The number of pages to move forward when the link is clicked.
* - parameters: An associative array of query string parameters to append to
* the pager links.
*
* @ingroup themeable
*/
function theme_pager_next($variables) {
$text = $variables['text'];
$element = $variables['element'];
$interval = $variables['interval'];
$parameters = $variables['parameters'];
global $pager_page_array, $pager_total;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element]) || !isset($pager_total[$element])) {
return;
}
// If we are anywhere but the last page
if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
$page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
// If the next page is the last page, mark the link as such.
if ($page_new[$element] == ($pager_total[$element] - 1)) {
$output = theme('pager_last', array('text' => $text, 'element' => $element, 'parameters' => $parameters));
}
// The next page is not the last page.
else {
$output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters));
}
}
return $output;
}
/**
* Returns HTML for the "last page" link in query pager.
*
* @param $variables
* An associative array containing:
* - text: The name (or image) of the link.
* - element: An optional integer to distinguish between multiple pagers on
* one page.
* - parameters: An associative array of query string parameters to append to
* the pager links.
*
* @ingroup themeable
*/
function theme_pager_last($variables) {
$text = $variables['text'];
$element = $variables['element'];
$parameters = $variables['parameters'];
global $pager_page_array, $pager_total;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element]) || !isset($pager_total[$element])) {
return;
}
// If we are anywhere but the last page
if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
$output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array($pager_total[$element] - 1, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters));
}
return $output;
}
/**
* Returns HTML for a link to a specific query result page.
*
* @param $variables
* An associative array containing:
* - text: The link text. Also used to figure out the title attribute of the
* link, if it is not provided in $variables['attributes']['title']; in
* this case, $variables['text'] must be one of the standard pager link
* text strings that would be generated by the pager theme functions, such
* as a number or t('« first').
* - page_new: The first result to display on the linked page.
* - element: An optional integer to distinguish between multiple pagers on
* one page.
* - parameters: An associative array of query string parameters to append to
* the pager link.
* - attributes: An associative array of HTML attributes to apply to the
* pager link.
*
* @see theme_pager()
*
* @ingroup themeable
*/
function theme_pager_link($variables) {
$text = $variables['text'];
$page_new = $variables['page_new'];
$element = $variables['element'];
$parameters = $variables['parameters'];
$attributes = $variables['attributes'];
$page = isset($_GET['page']) ? $_GET['page'] : '';
if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
$parameters['page'] = $new_page;
}
$query = array();
if (count($parameters)) {
$query = drupal_get_query_parameters($parameters, array());
}
if ($query_pager = pager_get_query_parameters()) {
$query = array_merge($query, $query_pager);
}
// Set each pager link title
if (!isset($attributes['title'])) {
static $titles = NULL;
if (!isset($titles)) {
$titles = array(
t('« first') => t('Go to first page'),
t(' previous') => t('Go to previous page'),
t('next ') => t('Go to next page'),
t('last »') => t('Go to last page'),
);
}
if (isset($titles[$text])) {
$attributes['title'] = $titles[$text];
}
elseif (is_numeric($text)) {
$attributes['title'] = t('Go to page @number', array('@number' => $text));
}
}
// @todo l() cannot be used here, since it adds an 'active' class based on the
// path only (which is always the current path for pager links). Apparently,
// none of the pager links is active at any time - but it should still be
// possible to use l() here.
// @see http://drupal.org/node/1410574
$attributes['href'] = url($_GET['q'], array('query' => $query));
return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
}
/**
* @} End of "Pager pieces".
*/
/**
* Helper function
*
* Copies $old_array to $new_array and sets $new_array[$element] = $value
* Fills in $new_array[0 .. $element - 1] = 0
*/
function pager_load_array($value, $element, $old_array) {
$new_array = $old_array;
// Look for empty elements.
for ($i = 0; $i < $element; $i++) {
if (empty($new_array[$i])) {
// Load found empty element with 0.
$new_array[$i] = 0;
}
}
// Update the changed element.
$new_array[$element] = (int) $value;
return $new_array;
}
+291
View File
@@ -0,0 +1,291 @@
<?php
/**
* @file
* Secure password hashing functions for user authentication.
*
* Based on the Portable PHP password hashing framework.
* @see http://www.openwall.com/phpass/
*
* An alternative or custom version of this password hashing API may be
* used by setting the variable password_inc to the name of the PHP file
* containing replacement user_hash_password(), user_check_password(), and
* user_needs_new_hash() functions.
*/
/**
* The standard log2 number of iterations for password stretching. This should
* increase by 1 every Drupal version in order to counteract increases in the
* speed and power of computers available to crack the hashes.
*/
define('DRUPAL_HASH_COUNT', 15);
/**
* The minimum allowed log2 number of iterations for password stretching.
*/
define('DRUPAL_MIN_HASH_COUNT', 7);
/**
* The maximum allowed log2 number of iterations for password stretching.
*/
define('DRUPAL_MAX_HASH_COUNT', 30);
/**
* The expected (and maximum) number of characters in a hashed password.
*/
define('DRUPAL_HASH_LENGTH', 55);
/**
* Returns a string for mapping an int to the corresponding base 64 character.
*/
function _password_itoa64() {
return './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
}
/**
* Encodes bytes into printable base 64 using the *nix standard from crypt().
*
* @param $input
* The string containing bytes to encode.
* @param $count
* The number of characters (bytes) to encode.
*
* @return
* Encoded string
*/
function _password_base64_encode($input, $count) {
$output = '';
$i = 0;
$itoa64 = _password_itoa64();
do {
$value = ord($input[$i++]);
$output .= $itoa64[$value & 0x3f];
if ($i < $count) {
$value |= ord($input[$i]) << 8;
}
$output .= $itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count) {
break;
}
if ($i < $count) {
$value |= ord($input[$i]) << 16;
}
$output .= $itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count) {
break;
}
$output .= $itoa64[($value >> 18) & 0x3f];
} while ($i < $count);
return $output;
}
/**
* Generates a random base 64-encoded salt prefixed with settings for the hash.
*
* Proper use of salts may defeat a number of attacks, including:
* - The ability to try candidate passwords against multiple hashes at once.
* - The ability to use pre-hashed lists of candidate passwords.
* - The ability to determine whether two users have the same (or different)
* password without actually having to guess one of the passwords.
*
* @param $count_log2
* Integer that determines the number of iterations used in the hashing
* process. A larger value is more secure, but takes more time to complete.
*
* @return
* A 12 character string containing the iteration count and a random salt.
*/
function _password_generate_salt($count_log2) {
$output = '$S$';
// Ensure that $count_log2 is within set bounds.
$count_log2 = _password_enforce_log2_boundaries($count_log2);
// We encode the final log2 iteration count in base 64.
$itoa64 = _password_itoa64();
$output .= $itoa64[$count_log2];
// 6 bytes is the standard salt for a portable phpass hash.
$output .= _password_base64_encode(drupal_random_bytes(6), 6);
return $output;
}
/**
* Ensures that $count_log2 is within set bounds.
*
* @param $count_log2
* Integer that determines the number of iterations used in the hashing
* process. A larger value is more secure, but takes more time to complete.
*
* @return
* Integer within set bounds that is closest to $count_log2.
*/
function _password_enforce_log2_boundaries($count_log2) {
if ($count_log2 < DRUPAL_MIN_HASH_COUNT) {
return DRUPAL_MIN_HASH_COUNT;
}
elseif ($count_log2 > DRUPAL_MAX_HASH_COUNT) {
return DRUPAL_MAX_HASH_COUNT;
}
return (int) $count_log2;
}
/**
* Hash a password using a secure stretched hash.
*
* By using a salt and repeated hashing the password is "stretched". Its
* security is increased because it becomes much more computationally costly
* for an attacker to try to break the hash by brute-force computation of the
* hashes of a large number of plain-text words or strings to find a match.
*
* @param $algo
* The string name of a hashing algorithm usable by hash(), like 'sha256'.
* @param $password
* Plain-text password up to 512 bytes (128 to 512 UTF-8 characters) to hash.
* @param $setting
* An existing hash or the output of _password_generate_salt(). Must be
* at least 12 characters (the settings and salt).
*
* @return
* A string containing the hashed password (and salt) or FALSE on failure.
* The return string will be truncated at DRUPAL_HASH_LENGTH characters max.
*/
function _password_crypt($algo, $password, $setting) {
// Prevent DoS attacks by refusing to hash large passwords.
if (strlen($password) > 512) {
return FALSE;
}
// The first 12 characters of an existing hash are its setting string.
$setting = substr($setting, 0, 12);
if ($setting[0] != '$' || $setting[2] != '$') {
return FALSE;
}
$count_log2 = _password_get_count_log2($setting);
// Hashes may be imported from elsewhere, so we allow != DRUPAL_HASH_COUNT
if ($count_log2 < DRUPAL_MIN_HASH_COUNT || $count_log2 > DRUPAL_MAX_HASH_COUNT) {
return FALSE;
}
$salt = substr($setting, 4, 8);
// Hashes must have an 8 character salt.
if (strlen($salt) != 8) {
return FALSE;
}
// Convert the base 2 logarithm into an integer.
$count = 1 << $count_log2;
// We rely on the hash() function being available in PHP 5.2+.
$hash = hash($algo, $salt . $password, TRUE);
do {
$hash = hash($algo, $hash . $password, TRUE);
} while (--$count);
$len = strlen($hash);
$output = $setting . _password_base64_encode($hash, $len);
// _password_base64_encode() of a 16 byte MD5 will always be 22 characters.
// _password_base64_encode() of a 64 byte sha512 will always be 86 characters.
$expected = 12 + ceil((8 * $len) / 6);
return (strlen($output) == $expected) ? substr($output, 0, DRUPAL_HASH_LENGTH) : FALSE;
}
/**
* Parse the log2 iteration count from a stored hash or setting string.
*/
function _password_get_count_log2($setting) {
$itoa64 = _password_itoa64();
return strpos($itoa64, $setting[3]);
}
/**
* Hash a password using a secure hash.
*
* @param $password
* A plain-text password.
* @param $count_log2
* Optional integer to specify the iteration count. Generally used only during
* mass operations where a value less than the default is needed for speed.
*
* @return
* A string containing the hashed password (and a salt), or FALSE on failure.
*/
function user_hash_password($password, $count_log2 = 0) {
if (empty($count_log2)) {
// Use the standard iteration count.
$count_log2 = variable_get('password_count_log2', DRUPAL_HASH_COUNT);
}
return _password_crypt('sha512', $password, _password_generate_salt($count_log2));
}
/**
* Check whether a plain text password matches a stored hashed password.
*
* Alternative implementations of this function may use other data in the
* $account object, for example the uid to look up the hash in a custom table
* or remote database.
*
* @param $password
* A plain-text password
* @param $account
* A user object with at least the fields from the {users} table.
*
* @return
* TRUE or FALSE.
*/
function user_check_password($password, $account) {
if (substr($account->pass, 0, 2) == 'U$') {
// This may be an updated password from user_update_7000(). Such hashes
// have 'U' added as the first character and need an extra md5().
$stored_hash = substr($account->pass, 1);
$password = md5($password);
}
else {
$stored_hash = $account->pass;
}
$type = substr($stored_hash, 0, 3);
switch ($type) {
case '$S$':
// A normal Drupal 7 password using sha512.
$hash = _password_crypt('sha512', $password, $stored_hash);
break;
case '$H$':
// phpBB3 uses "$H$" for the same thing as "$P$".
case '$P$':
// A phpass password generated using md5. This is an
// imported password or from an earlier Drupal version.
$hash = _password_crypt('md5', $password, $stored_hash);
break;
default:
return FALSE;
}
return ($hash && $stored_hash == $hash);
}
/**
* Check whether a user's hashed password needs to be replaced with a new hash.
*
* This is typically called during the login process when the plain text
* password is available. A new hash is needed when the desired iteration count
* has changed through a change in the variable password_count_log2 or
* DRUPAL_HASH_COUNT or if the user's password hash was generated in an update
* like user_update_7000().
*
* Alternative implementations of this function might use other criteria based
* on the fields in $account.
*
* @param $account
* A user object with at least the fields from the {users} table.
*
* @return
* TRUE or FALSE.
*/
function user_needs_new_hash($account) {
// Check whether this was an updated password.
if ((substr($account->pass, 0, 3) != '$S$') || (strlen($account->pass) != DRUPAL_HASH_LENGTH)) {
return TRUE;
}
// Ensure that $count_log2 is within set bounds.
$count_log2 = _password_enforce_log2_boundaries(variable_get('password_count_log2', DRUPAL_HASH_COUNT));
// Check whether the iteration count used differs from the standard number.
return (_password_get_count_log2($account->pass) !== $count_log2);
}
+590
View File
@@ -0,0 +1,590 @@
<?php
/**
* @file
* Functions to handle paths in Drupal, including path aliasing.
*
* These functions are not loaded for cached pages, but modules that need
* to use them in hook_boot() or hook exit() can make them available, by
* executing "drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);".
*/
/**
* Initialize the $_GET['q'] variable to the proper normal path.
*/
function drupal_path_initialize() {
// Ensure $_GET['q'] is set before calling drupal_normal_path(), to support
// path caching with hook_url_inbound_alter().
if (empty($_GET['q'])) {
$_GET['q'] = variable_get('site_frontpage', 'node');
}
$_GET['q'] = drupal_get_normal_path($_GET['q']);
}
/**
* Given an alias, return its Drupal system URL if one exists. Given a Drupal
* system URL return one of its aliases if such a one exists. Otherwise,
* return FALSE.
*
* @param $action
* One of the following values:
* - wipe: delete the alias cache.
* - alias: return an alias for a given Drupal system path (if one exists).
* - source: return the Drupal system URL for a path alias (if one exists).
* @param $path
* The path to investigate for corresponding aliases or system URLs.
* @param $path_language
* Optional language code to search the path with. Defaults to the page language.
* If there's no path defined for that language it will search paths without
* language.
*
* @return
* Either a Drupal system path, an aliased path, or FALSE if no path was
* found.
*/
function drupal_lookup_path($action, $path = '', $path_language = NULL) {
global $language_url;
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['cache'] = &drupal_static(__FUNCTION__);
}
$cache = &$drupal_static_fast['cache'];
if (!isset($cache)) {
$cache = array(
'map' => array(),
'no_source' => array(),
'whitelist' => NULL,
'system_paths' => array(),
'no_aliases' => array(),
'first_call' => TRUE,
);
}
// Retrieve the path alias whitelist.
if (!isset($cache['whitelist'])) {
$cache['whitelist'] = variable_get('path_alias_whitelist', NULL);
if (!isset($cache['whitelist'])) {
$cache['whitelist'] = drupal_path_alias_whitelist_rebuild();
}
}
// If no language is explicitly specified we default to the current URL
// language. If we used a language different from the one conveyed by the
// requested URL, we might end up being unable to check if there is a path
// alias matching the URL path.
$path_language = $path_language ? $path_language : $language_url->language;
if ($action == 'wipe') {
$cache = array();
$cache['whitelist'] = drupal_path_alias_whitelist_rebuild();
}
elseif ($cache['whitelist'] && $path != '') {
if ($action == 'alias') {
// During the first call to drupal_lookup_path() per language, load the
// expected system paths for the page from cache.
if (!empty($cache['first_call'])) {
$cache['first_call'] = FALSE;
$cache['map'][$path_language] = array();
// Load system paths from cache.
$cid = current_path();
if ($cached = cache_get($cid, 'cache_path')) {
$cache['system_paths'] = $cached->data;
// Now fetch the aliases corresponding to these system paths.
$args = array(
':system' => $cache['system_paths'],
':language' => $path_language,
':language_none' => LANGUAGE_NONE,
);
// Always get the language-specific alias before the language-neutral
// one. For example 'de' is less than 'und' so the order needs to be
// ASC, while 'xx-lolspeak' is more than 'und' so the order needs to
// be DESC. We also order by pid ASC so that fetchAllKeyed() returns
// the most recently created alias for each source. Subsequent queries
// using fetchField() must use pid DESC to have the same effect.
// For performance reasons, the query builder is not used here.
if ($path_language == LANGUAGE_NONE) {
// Prevent PDO from complaining about a token the query doesn't use.
unset($args[':language']);
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language = :language_none ORDER BY pid ASC', $args);
}
elseif ($path_language < LANGUAGE_NONE) {
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, :language_none) ORDER BY language ASC, pid ASC', $args);
}
else {
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, :language_none) ORDER BY language DESC, pid ASC', $args);
}
$cache['map'][$path_language] = $result->fetchAllKeyed();
// Keep a record of paths with no alias to avoid querying twice.
$cache['no_aliases'][$path_language] = array_flip(array_diff_key($cache['system_paths'], array_keys($cache['map'][$path_language])));
}
}
// If the alias has already been loaded, return it.
if (isset($cache['map'][$path_language][$path])) {
return $cache['map'][$path_language][$path];
}
// Check the path whitelist, if the top_level part before the first /
// is not in the list, then there is no need to do anything further,
// it is not in the database.
elseif (!isset($cache['whitelist'][strtok($path, '/')])) {
return FALSE;
}
// For system paths which were not cached, query aliases individually.
elseif (!isset($cache['no_aliases'][$path_language][$path])) {
$args = array(
':source' => $path,
':language' => $path_language,
':language_none' => LANGUAGE_NONE,
);
// See the queries above.
if ($path_language == LANGUAGE_NONE) {
unset($args[':language']);
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language = :language_none ORDER BY pid DESC", $args)->fetchField();
}
elseif ($path_language > LANGUAGE_NONE) {
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", $args)->fetchField();
}
else {
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, :language_none) ORDER BY language ASC, pid DESC", $args)->fetchField();
}
$cache['map'][$path_language][$path] = $alias;
return $alias;
}
}
// Check $no_source for this $path in case we've already determined that there
// isn't a path that has this alias
elseif ($action == 'source' && !isset($cache['no_source'][$path_language][$path])) {
// Look for the value $path within the cached $map
$source = FALSE;
if (!isset($cache['map'][$path_language]) || !($source = array_search($path, $cache['map'][$path_language]))) {
$args = array(
':alias' => $path,
':language' => $path_language,
':language_none' => LANGUAGE_NONE,
);
// See the queries above.
if ($path_language == LANGUAGE_NONE) {
unset($args[':language']);
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language = :language_none ORDER BY pid DESC", $args);
}
elseif ($path_language > LANGUAGE_NONE) {
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", $args);
}
else {
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language ASC, pid DESC", $args);
}
if ($source = $result->fetchField()) {
$cache['map'][$path_language][$source] = $path;
}
else {
// We can't record anything into $map because we do not have a valid
// index and there is no need because we have not learned anything
// about any Drupal path. Thus cache to $no_source.
$cache['no_source'][$path_language][$path] = TRUE;
}
}
return $source;
}
}
return FALSE;
}
/**
* Cache system paths for a page.
*
* Cache an array of the system paths available on each page. We assume
* that aliases will be needed for the majority of these paths during
* subsequent requests, and load them in a single query during
* drupal_lookup_path().
*/
function drupal_cache_system_paths() {
// Check if the system paths for this page were loaded from cache in this
// request to avoid writing to cache on every request.
$cache = &drupal_static('drupal_lookup_path', array());
if (empty($cache['system_paths']) && !empty($cache['map'])) {
// Generate a cache ID (cid) specifically for this page.
$cid = current_path();
// The static $map array used by drupal_lookup_path() includes all
// system paths for the page request.
if ($paths = current($cache['map'])) {
$data = array_keys($paths);
$expire = REQUEST_TIME + (60 * 60 * 24);
cache_set($cid, $data, 'cache_path', $expire);
}
}
}
/**
* Given an internal Drupal path, return the alias set by the administrator.
*
* If no path is provided, the function will return the alias of the current
* page.
*
* @param $path
* An internal Drupal path.
* @param $path_language
* An optional language code to look up the path in.
*
* @return
* An aliased path if one was found, or the original path if no alias was
* found.
*/
function drupal_get_path_alias($path = NULL, $path_language = NULL) {
// If no path is specified, use the current page's path.
if ($path == NULL) {
$path = $_GET['q'];
}
$result = $path;
if ($alias = drupal_lookup_path('alias', $path, $path_language)) {
$result = $alias;
}
return $result;
}
/**
* Given a path alias, return the internal path it represents.
*
* @param $path
* A Drupal path alias.
* @param $path_language
* An optional language code to look up the path in.
*
* @return
* The internal path represented by the alias, or the original alias if no
* internal path was found.
*/
function drupal_get_normal_path($path, $path_language = NULL) {
$original_path = $path;
// Lookup the path alias first.
if ($source = drupal_lookup_path('source', $path, $path_language)) {
$path = $source;
}
// Allow other modules to alter the inbound URL. We cannot use drupal_alter()
// here because we need to run hook_url_inbound_alter() in the reverse order
// of hook_url_outbound_alter().
foreach (array_reverse(module_implements('url_inbound_alter')) as $module) {
$function = $module . '_url_inbound_alter';
$function($path, $original_path, $path_language);
}
return $path;
}
/**
* Check if the current page is the front page.
*
* @return
* Boolean value: TRUE if the current page is the front page; FALSE if otherwise.
*/
function drupal_is_front_page() {
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['is_front_page'] = &drupal_static(__FUNCTION__);
}
$is_front_page = &$drupal_static_fast['is_front_page'];
if (!isset($is_front_page)) {
// As drupal_path_initialize updates $_GET['q'] with the 'site_frontpage' path,
// we can check it against the 'site_frontpage' variable.
$is_front_page = ($_GET['q'] == variable_get('site_frontpage', 'node'));
}
return $is_front_page;
}
/**
* Check if a path matches any pattern in a set of patterns.
*
* @param $path
* The path to match.
* @param $patterns
* String containing a set of patterns separated by \n, \r or \r\n.
*
* @return
* Boolean value: TRUE if the path matches a pattern, FALSE otherwise.
*/
function drupal_match_path($path, $patterns) {
$regexps = &drupal_static(__FUNCTION__);
if (!isset($regexps[$patterns])) {
// Convert path settings to a regular expression.
// Therefore replace newlines with a logical or, /* with asterisks and the <front> with the frontpage.
$to_replace = array(
'/(\r\n?|\n)/', // newlines
'/\\\\\*/', // asterisks
'/(^|\|)\\\\<front\\\\>($|\|)/' // <front>
);
$replacements = array(
'|',
'.*',
'\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\2'
);
$patterns_quoted = preg_quote($patterns, '/');
$regexps[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
}
return (bool)preg_match($regexps[$patterns], $path);
}
/**
* Return the current URL path of the page being viewed.
*
* Examples:
* - http://example.com/node/306 returns "node/306".
* - http://example.com/drupalfolder/node/306 returns "node/306" while
* base_path() returns "/drupalfolder/".
* - http://example.com/path/alias (which is a path alias for node/306) returns
* "node/306" as opposed to the path alias.
*
* This function is not available in hook_boot() so use $_GET['q'] instead.
* However, be careful when doing that because in the case of Example #3
* $_GET['q'] will contain "path/alias". If "node/306" is needed, calling
* drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) makes this function available.
*
* @return
* The current Drupal URL path. The path is untrusted user input and must be
* treated as such.
*
* @see request_path()
*/
function current_path() {
return $_GET['q'];
}
/**
* Rebuild the path alias white list.
*
* @param $source
* An optional system path for which an alias is being inserted.
*
* @return
* An array containing a white list of path aliases.
*/
function drupal_path_alias_whitelist_rebuild($source = NULL) {
// When paths are inserted, only rebuild the whitelist if the system path
// has a top level component which is not already in the whitelist.
if (!empty($source)) {
$whitelist = variable_get('path_alias_whitelist', NULL);
if (isset($whitelist[strtok($source, '/')])) {
return $whitelist;
}
}
// For each alias in the database, get the top level component of the system
// path it corresponds to. This is the portion of the path before the first
// '/', if present, otherwise the whole path itself.
$whitelist = array();
$result = db_query("SELECT DISTINCT SUBSTRING_INDEX(source, '/', 1) AS path FROM {url_alias}");
foreach ($result as $row) {
$whitelist[$row->path] = TRUE;
}
variable_set('path_alias_whitelist', $whitelist);
return $whitelist;
}
/**
* Fetches a specific URL alias from the database.
*
* @param $conditions
* A string representing the source, a number representing the pid, or an
* array of query conditions.
*
* @return
* FALSE if no alias was found or an associative array containing the
* following keys:
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - language: The language of the alias.
*/
function path_load($conditions) {
if (is_numeric($conditions)) {
$conditions = array('pid' => $conditions);
}
elseif (is_string($conditions)) {
$conditions = array('source' => $conditions);
}
elseif (!is_array($conditions)) {
return FALSE;
}
$select = db_select('url_alias');
foreach ($conditions as $field => $value) {
$select->condition($field, $value);
}
return $select
->fields('url_alias')
->execute()
->fetchAssoc();
}
/**
* Save a path alias to the database.
*
* @param $path
* An associative array containing the following keys:
* - source: The internal system path.
* - alias: The URL alias.
* - pid: (optional) Unique path alias identifier.
* - language: (optional) The language of the alias.
*/
function path_save(&$path) {
$path += array('language' => LANGUAGE_NONE);
// Load the stored alias, if any.
if (!empty($path['pid']) && !isset($path['original'])) {
$path['original'] = path_load($path['pid']);
}
if (empty($path['pid'])) {
drupal_write_record('url_alias', $path);
module_invoke_all('path_insert', $path);
}
else {
drupal_write_record('url_alias', $path, array('pid'));
module_invoke_all('path_update', $path);
}
// Clear internal properties.
unset($path['original']);
// Clear the static alias cache.
drupal_clear_path_cache($path['source']);
}
/**
* Delete a URL alias.
*
* @param $criteria
* A number representing the pid or an array of criteria.
*/
function path_delete($criteria) {
if (!is_array($criteria)) {
$criteria = array('pid' => $criteria);
}
$path = path_load($criteria);
if (isset($path['source'])) {
$query = db_delete('url_alias');
foreach ($criteria as $field => $value) {
$query->condition($field, $value);
}
$query->execute();
module_invoke_all('path_delete', $path);
drupal_clear_path_cache($path['source']);
}
}
/**
* Determines whether a path is in the administrative section of the site.
*
* By default, paths are considered to be non-administrative. If a path does
* not match any of the patterns in path_get_admin_paths(), or if it matches
* both administrative and non-administrative patterns, it is considered
* non-administrative.
*
* @param $path
* A Drupal path.
*
* @return
* TRUE if the path is administrative, FALSE otherwise.
*
* @see path_get_admin_paths()
* @see hook_admin_paths()
* @see hook_admin_paths_alter()
*/
function path_is_admin($path) {
$path_map = &drupal_static(__FUNCTION__);
if (!isset($path_map['admin'][$path])) {
$patterns = path_get_admin_paths();
$path_map['admin'][$path] = drupal_match_path($path, $patterns['admin']);
$path_map['non_admin'][$path] = drupal_match_path($path, $patterns['non_admin']);
}
return $path_map['admin'][$path] && !$path_map['non_admin'][$path];
}
/**
* Gets a list of administrative and non-administrative paths.
*
* @return array
* An associative array containing the following keys:
* 'admin': An array of administrative paths and regular expressions
* in a format suitable for drupal_match_path().
* 'non_admin': An array of non-administrative paths and regular expressions.
*
* @see hook_admin_paths()
* @see hook_admin_paths_alter()
*/
function path_get_admin_paths() {
$patterns = &drupal_static(__FUNCTION__);
if (!isset($patterns)) {
$paths = module_invoke_all('admin_paths');
drupal_alter('admin_paths', $paths);
// Combine all admin paths into one array, and likewise for non-admin paths,
// for easier handling.
$patterns = array();
$patterns['admin'] = array();
$patterns['non_admin'] = array();
foreach ($paths as $path => $enabled) {
if ($enabled) {
$patterns['admin'][] = $path;
}
else {
$patterns['non_admin'][] = $path;
}
}
$patterns['admin'] = implode("\n", $patterns['admin']);
$patterns['non_admin'] = implode("\n", $patterns['non_admin']);
}
return $patterns;
}
/**
* Checks a path exists and the current user has access to it.
*
* @param $path
* The path to check.
* @param $dynamic_allowed
* Whether paths with menu wildcards (like user/%) should be allowed.
*
* @return
* TRUE if it is a valid path AND the current user has access permission,
* FALSE otherwise.
*/
function drupal_valid_path($path, $dynamic_allowed = FALSE) {
global $menu_admin;
// We indicate that a menu administrator is running the menu access check.
$menu_admin = TRUE;
if ($path == '<front>' || url_is_external($path)) {
$item = array('access' => TRUE);
}
elseif ($dynamic_allowed && preg_match('/\/\%/', $path)) {
// Path is dynamic (ie 'user/%'), so check directly against menu_router table.
if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(':path' => $path))->fetchAssoc()) {
$item['link_path'] = $item['path'];
$item['link_title'] = $item['title'];
$item['external'] = FALSE;
$item['options'] = '';
_menu_link_translate($item);
}
}
else {
$item = menu_get_item($path);
}
$menu_admin = FALSE;
return $item && $item['access'];
}
/**
* Clear the path cache.
*
* @param $source
* An optional system path for which an alias is being changed.
*/
function drupal_clear_path_cache($source = NULL) {
// Clear the drupal_lookup_path() static cache.
drupal_static_reset('drupal_lookup_path');
drupal_path_alias_whitelist_rebuild($source);
}
+217
View File
@@ -0,0 +1,217 @@
<?php
/**
* @file
* This file contains the code registry parser engine.
*/
/**
* @defgroup registry Code registry
* @{
* The code registry engine.
*
* Drupal maintains an internal registry of all interfaces or classes in the
* system, allowing it to lazy-load code files as needed (reducing the amount
* of code that must be parsed on each request).
*/
/**
* Does the work for registry_update().
*/
function _registry_update() {
// The registry serves as a central autoloader for all classes, including
// the database query builders. However, the registry rebuild process
// requires write ability to the database, which means having access to the
// query builders that require the registry in order to be loaded. That
// causes a fatal race condition. Therefore we manually include the
// appropriate query builders for the currently active database before the
// registry rebuild process runs.
$connection_info = Database::getConnectionInfo();
$driver = $connection_info['default']['driver'];
require_once DRUPAL_ROOT . '/includes/database/query.inc';
require_once DRUPAL_ROOT . '/includes/database/select.inc';
require_once DRUPAL_ROOT . '/includes/database/' . $driver . '/query.inc';
// During the first registry rebuild in a request, we check all the files.
// During subsequent rebuilds, we only add new files. It makes the rebuilding
// process faster during installation of modules.
static $check_existing_files = TRUE;
// Get current list of modules and their files.
$modules = db_query("SELECT * FROM {system} WHERE type = 'module'")->fetchAll();
// Get the list of files we are going to parse.
$files = array();
foreach ($modules as &$module) {
$module->info = unserialize($module->info);
$dir = dirname($module->filename);
// Store the module directory for use in hook_registry_files_alter().
$module->dir = $dir;
if ($module->status) {
// Add files for enabled modules to the registry.
foreach ($module->info['files'] as $file) {
$files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight);
}
}
}
foreach (file_scan_directory('includes', '/\.inc$/') as $filename => $file) {
$files["$filename"] = array('module' => '', 'weight' => 0);
}
// Initialize an empty array for the unchanged files.
$unchanged_files = array();
$transaction = db_transaction();
try {
// Allow modules to manually modify the list of files before the registry
// parses them. The $modules array provides the .info file information, which
// includes the list of files registered to each module. Any files in the
// list can then be added to the list of files that the registry will parse,
// or modify attributes of a file.
drupal_alter('registry_files', $files, $modules);
foreach (registry_get_parsed_files() as $filename => $file) {
// Add the hash for those files we have already parsed.
if (isset($files[$filename])) {
if ($check_existing_files === TRUE) {
$files[$filename]['hash'] = $file['hash'];
}
else {
// Ignore that file for this request, it has been parsed previously
// and it is unlikely it has changed.
unset($files[$filename]);
$unchanged_files[$filename] = $file;
}
}
else {
// Flush the registry of resources in files that are no longer on disc
// or are in files that no installed modules require to be parsed.
db_delete('registry')
->condition('filename', $filename)
->execute();
db_delete('registry_file')
->condition('filename', $filename)
->execute();
}
}
$parsed_files = _registry_parse_files($files);
// Add unchanged files to the files.
$files += $unchanged_files;
$unchanged_resources = array();
$lookup_cache = array();
if ($cache = cache_get('lookup_cache', 'cache_bootstrap')) {
$lookup_cache = $cache->data;
}
foreach ($lookup_cache as $key => $file) {
// If the file for this cached resource is carried over unchanged from
// the last registry build, then we can safely re-cache it.
if ($file && isset($files[$file]) && !in_array($file, $parsed_files, TRUE)) {
$unchanged_resources[$key] = $file;
}
}
}
catch (Exception $e) {
$transaction->rollback();
watchdog_exception('registry', $e);
throw $e;
}
module_implements('', FALSE, TRUE);
_registry_check_code(REGISTRY_RESET_LOOKUP_CACHE);
// During the next run in this request, don't bother re-checking existing
// files.
$check_existing_files = FALSE;
// We have some unchanged resources, warm up the cache - no need to pay
// for looking them up again.
if (count($unchanged_resources) > 0) {
cache_set('lookup_cache', $unchanged_resources, 'cache_bootstrap');
}
}
/**
* Return the list of files in registry_file
*/
function registry_get_parsed_files() {
$files = array();
// We want the result as a keyed array.
$files = db_query("SELECT * FROM {registry_file}")->fetchAllAssoc('filename', PDO::FETCH_ASSOC);
return $files;
}
/**
* Parse all changed files and save their interface and class listings.
*
* Parse all files that have changed since the registry was last built, and save
* their interface and class listings.
*
* @param $files
* The list of files to check and parse.
*/
function _registry_parse_files($files) {
$parsed_files = array();
foreach ($files as $filename => $file) {
if (file_exists($filename)) {
$hash = hash_file('sha256', $filename);
if (empty($file['hash']) || $file['hash'] != $hash) {
$file['hash'] = $hash;
$parsed_files[$filename] = $file;
}
}
}
foreach ($parsed_files as $filename => $file) {
_registry_parse_file($filename, file_get_contents($filename), $file['module'], $file['weight']);
db_merge('registry_file')
->key(array('filename' => $filename))
->fields(array(
'hash' => $file['hash'],
))
->execute();
}
return array_keys($parsed_files);
}
/**
* Parse a file and save its interface and class listings.
*
* @param $filename
* Name of the file we are going to parse.
* @param $contents
* Contents of the file we are going to parse as a string.
* @param $module
* (optional) Name of the module this file belongs to.
* @param $weight
* (optional) Weight of the module.
*/
function _registry_parse_file($filename, $contents, $module = '', $weight = 0) {
if (preg_match_all('/^\s*(?:abstract|final)?\s*(class|interface|trait)\s+([a-zA-Z0-9_]+)/m', $contents, $matches)) {
foreach ($matches[2] as $key => $name) {
db_merge('registry')
->key(array(
'name' => $name,
'type' => $matches[1][$key],
))
->fields(array(
'filename' => $filename,
'module' => $module,
'weight' => $weight,
))
->execute();
}
// Delete any resources for this file where the name is not in the list
// we just merged in.
db_delete('registry')
->condition('filename', $filename)
->condition('name', $matches[2], 'NOT IN')
->execute();
}
}
/**
* @} End of "defgroup registry".
*/
+114
View File
@@ -0,0 +1,114 @@
<?php
/**
* @file
* Contains code for sanitizing user input from the request.
*/
/**
* Sanitizes user input from the request.
*/
class DrupalRequestSanitizer {
/**
* Tracks whether the request was already sanitized.
*/
protected static $sanitized = FALSE;
/**
* Modifies the request to strip dangerous keys from user input.
*/
public static function sanitize() {
if (!self::$sanitized) {
$whitelist = variable_get('sanitize_input_whitelist', array());
$log_sanitized_keys = variable_get('sanitize_input_logging', FALSE);
// Process query string parameters.
$get_sanitized_keys = array();
$_GET = self::stripDangerousValues($_GET, $whitelist, $get_sanitized_keys);
if ($log_sanitized_keys && $get_sanitized_keys) {
_drupal_trigger_error_with_delayed_logging(format_string('Potentially unsafe keys removed from query string parameters (GET): @keys', array('@keys' => implode(', ', $get_sanitized_keys))), E_USER_NOTICE);
}
// Process request body parameters.
$post_sanitized_keys = array();
$_POST = self::stripDangerousValues($_POST, $whitelist, $post_sanitized_keys);
if ($log_sanitized_keys && $post_sanitized_keys) {
_drupal_trigger_error_with_delayed_logging(format_string('Potentially unsafe keys removed from request body parameters (POST): @keys', array('@keys' => implode(', ', $post_sanitized_keys))), E_USER_NOTICE);
}
// Process cookie parameters.
$cookie_sanitized_keys = array();
$_COOKIE = self::stripDangerousValues($_COOKIE, $whitelist, $cookie_sanitized_keys);
if ($log_sanitized_keys && $cookie_sanitized_keys) {
_drupal_trigger_error_with_delayed_logging(format_string('Potentially unsafe keys removed from cookie parameters (COOKIE): @keys', array('@keys' => implode(', ', $cookie_sanitized_keys))), E_USER_NOTICE);
}
$request_sanitized_keys = array();
$_REQUEST = self::stripDangerousValues($_REQUEST, $whitelist, $request_sanitized_keys);
self::$sanitized = TRUE;
}
}
/**
* Removes the destination if it is dangerous.
*
* Note this can only be called after common.inc has been included.
*
* @return bool
* TRUE if the destination has been removed from $_GET, FALSE if not.
*/
public static function cleanDestination() {
$dangerous_keys = array();
$log_sanitized_keys = variable_get('sanitize_input_logging', FALSE);
$parts = drupal_parse_url($_GET['destination']);
// If there is a query string, check its query parameters.
if (!empty($parts['query'])) {
$whitelist = variable_get('sanitize_input_whitelist', array());
self::stripDangerousValues($parts['query'], $whitelist, $dangerous_keys);
if (!empty($dangerous_keys)) {
// The destination is removed rather than sanitized to mirror the
// handling of external destinations.
unset($_GET['destination']);
unset($_REQUEST['destination']);
if ($log_sanitized_keys) {
trigger_error(format_string('Potentially unsafe destination removed from query string parameters (GET) because it contained the following keys: @keys', array('@keys' => implode(', ', $dangerous_keys))));
}
return TRUE;
}
}
return FALSE;
}
/**
* Strips dangerous keys from the provided input.
*
* @param mixed $input
* The input to sanitize.
* @param string[] $whitelist
* An array of keys to whitelist as safe.
* @param string[] $sanitized_keys
* An array of keys that have been removed.
*
* @return mixed
* The sanitized input.
*/
protected static function stripDangerousValues($input, array $whitelist, array &$sanitized_keys) {
if (is_array($input)) {
foreach ($input as $key => $value) {
if ($key !== '' && is_string($key) && $key[0] === '#' && !in_array($key, $whitelist, TRUE)) {
unset($input[$key]);
$sanitized_keys[] = $key;
}
else {
$input[$key] = self::stripDangerousValues($input[$key], $whitelist, $sanitized_keys);
}
}
}
return $input;
}
}
+558
View File
@@ -0,0 +1,558 @@
<?php
/**
* @file
* User session handling functions.
*
* The user-level session storage handlers:
* - _drupal_session_open()
* - _drupal_session_close()
* - _drupal_session_read()
* - _drupal_session_write()
* - _drupal_session_destroy()
* - _drupal_session_garbage_collection()
* are assigned by session_set_save_handler() in bootstrap.inc and are called
* automatically by PHP. These functions should not be called directly. Session
* data should instead be accessed via the $_SESSION superglobal.
*/
/**
* Session handler assigned by session_set_save_handler().
*
* This function is used to handle any initialization, such as file paths or
* database connections, that is needed before accessing session data. Drupal
* does not need to initialize anything in this function.
*
* This function should not be called directly.
*
* @return
* This function will always return TRUE.
*/
function _drupal_session_open() {
return TRUE;
}
/**
* Session handler assigned by session_set_save_handler().
*
* This function is used to close the current session. Because Drupal stores
* session data in the database immediately on write, this function does
* not need to do anything.
*
* This function should not be called directly.
*
* @return
* This function will always return TRUE.
*/
function _drupal_session_close() {
return TRUE;
}
/**
* Reads an entire session from the database (internal use only).
*
* Also initializes the $user object for the user associated with the session.
* This function is registered with session_set_save_handler() to support
* database-backed sessions. It is called on every page load when PHP sets
* up the $_SESSION superglobal.
*
* This function is an internal function and must not be called directly.
* Doing so may result in logging out the current user, corrupting session data
* or other unexpected behavior. Session data must always be accessed via the
* $_SESSION superglobal.
*
* @param $sid
* The session ID of the session to retrieve.
*
* @return
* The user's session, or an empty string if no session exists.
*/
function _drupal_session_read($sid) {
global $user, $is_https;
// Write and Close handlers are called after destructing objects
// since PHP 5.0.5.
// Thus destructors can use sessions but session handler can't use objects.
// So we are moving session closure before destructing objects.
drupal_register_shutdown_function('session_write_close');
// Handle the case of first time visitors and clients that don't store
// cookies (eg. web crawlers).
$insecure_session_name = substr(session_name(), 1);
if (empty($sid) || (!isset($_COOKIE[session_name()]) && !isset($_COOKIE[$insecure_session_name]))) {
$user = drupal_anonymous_user();
return '';
}
// Otherwise, if the session is still active, we have a record of the
// client's session in the database. If it's HTTPS then we are either have
// a HTTPS session or we are about to log in so we check the sessions table
// for an anonymous session with the non-HTTPS-only cookie.
if ($is_https) {
$user = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.ssid = :ssid", array(':ssid' => $sid))->fetchObject();
if (!$user) {
if (isset($_COOKIE[$insecure_session_name])) {
$user = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid AND s.uid = 0", array(
':sid' => $_COOKIE[$insecure_session_name]))
->fetchObject();
}
}
}
else {
$user = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid", array(':sid' => $sid))->fetchObject();
}
// We found the client's session record and they are an authenticated,
// active user.
if ($user && $user->uid > 0 && $user->status == 1) {
// This is done to unserialize the data member of $user.
$user->data = unserialize($user->data);
// Add roles element to $user.
$user->roles = array();
$user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
$user->roles += db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = :uid", array(':uid' => $user->uid))->fetchAllKeyed(0, 1);
}
elseif ($user) {
// The user is anonymous or blocked. Only preserve two fields from the
// {sessions} table.
$account = drupal_anonymous_user();
$account->session = $user->session;
$account->timestamp = $user->timestamp;
$user = $account;
}
else {
// The session has expired.
$user = drupal_anonymous_user();
$user->session = '';
}
// Store the session that was read for comparison in _drupal_session_write().
$last_read = &drupal_static('drupal_session_last_read');
$last_read = array(
'sid' => $sid,
'value' => $user->session,
);
return $user->session;
}
/**
* Writes an entire session to the database (internal use only).
*
* This function is registered with session_set_save_handler() to support
* database-backed sessions.
*
* This function is an internal function and must not be called directly.
* Doing so may result in corrupted session data or other unexpected behavior.
* Session data must always be accessed via the $_SESSION superglobal.
*
* @param $sid
* The session ID of the session to write to.
* @param $value
* Session data to write as a serialized string.
*
* @return
* Always returns TRUE.
*/
function _drupal_session_write($sid, $value) {
global $user, $is_https;
// The exception handler is not active at this point, so we need to do it
// manually.
try {
if (!drupal_save_session()) {
// We don't have anything to do if we are not allowed to save the session.
return TRUE;
}
// Check whether $_SESSION has been changed in this request.
$last_read = &drupal_static('drupal_session_last_read');
$is_changed = !isset($last_read) || $last_read['sid'] != $sid || $last_read['value'] !== $value;
// For performance reasons, do not update the sessions table, unless
// $_SESSION has changed or more than 180 has passed since the last update.
if ($is_changed || !isset($user->timestamp) || REQUEST_TIME - $user->timestamp > variable_get('session_write_interval', 180)) {
// Either ssid or sid or both will be added from $key below.
$fields = array(
'uid' => $user->uid,
'cache' => isset($user->cache) ? $user->cache : 0,
'hostname' => ip_address(),
'session' => $value,
'timestamp' => REQUEST_TIME,
);
// Use the session ID as 'sid' and an empty string as 'ssid' by default.
// _drupal_session_read() does not allow empty strings so that's a safe
// default.
$key = array('sid' => $sid, 'ssid' => '');
// On HTTPS connections, use the session ID as both 'sid' and 'ssid'.
if ($is_https) {
$key['ssid'] = $sid;
// The "secure pages" setting allows a site to simultaneously use both
// secure and insecure session cookies. If enabled and both cookies are
// presented then use both keys.
if (variable_get('https', FALSE)) {
$insecure_session_name = substr(session_name(), 1);
if (isset($_COOKIE[$insecure_session_name])) {
$key['sid'] = $_COOKIE[$insecure_session_name];
}
}
}
elseif (variable_get('https', FALSE)) {
unset($key['ssid']);
}
db_merge('sessions')
->key($key)
->fields($fields)
->execute();
}
// Likewise, do not update access time more than once per 180 seconds.
if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) {
db_update('users')
->fields(array(
'access' => REQUEST_TIME
))
->condition('uid', $user->uid)
->execute();
}
return TRUE;
}
catch (Exception $exception) {
require_once DRUPAL_ROOT . '/includes/errors.inc';
// If we are displaying errors, then do so with no possibility of a further
// uncaught exception being thrown.
if (error_displayable()) {
print '<h1>Uncaught exception thrown in session handler.</h1>';
print '<p>' . _drupal_render_exception_safe($exception) . '</p><hr />';
}
return FALSE;
}
}
/**
* Initializes the session handler, starting a session if needed.
*/
function drupal_session_initialize() {
global $user, $is_https;
session_set_save_handler('_drupal_session_open', '_drupal_session_close', '_drupal_session_read', '_drupal_session_write', '_drupal_session_destroy', '_drupal_session_garbage_collection');
// We use !empty() in the following check to ensure that blank session IDs
// are not valid.
if (!empty($_COOKIE[session_name()]) || ($is_https && variable_get('https', FALSE) && !empty($_COOKIE[substr(session_name(), 1)]))) {
// If a session cookie exists, initialize the session. Otherwise the
// session is only started on demand in drupal_session_commit(), making
// anonymous users not use a session cookie unless something is stored in
// $_SESSION. This allows HTTP proxies to cache anonymous pageviews.
drupal_session_start();
if (!empty($user->uid) || !empty($_SESSION)) {
drupal_page_is_cacheable(FALSE);
}
}
else {
// Set a session identifier for this request. This is necessary because
// we lazily start sessions at the end of this request, and some
// processes (like drupal_get_token()) needs to know the future
// session ID in advance.
$GLOBALS['lazy_session'] = TRUE;
$user = drupal_anonymous_user();
// Less random sessions (which are much faster to generate) are used for
// anonymous users than are generated in drupal_session_regenerate() when
// a user becomes authenticated.
session_id(drupal_random_key());
if ($is_https && variable_get('https', FALSE)) {
$insecure_session_name = substr(session_name(), 1);
$session_id = drupal_random_key();
$_COOKIE[$insecure_session_name] = $session_id;
}
}
date_default_timezone_set(drupal_get_user_timezone());
}
/**
* Starts a session forcefully, preserving already set session data.
*
* @ingroup php_wrappers
*/
function drupal_session_start() {
// Command line clients do not support cookies nor sessions.
if (!drupal_session_started() && !drupal_is_cli()) {
// Save current session data before starting it, as PHP will destroy it.
$session_data = isset($_SESSION) ? $_SESSION : NULL;
session_start();
drupal_session_started(TRUE);
// Restore session data.
if (!empty($session_data)) {
$_SESSION += $session_data;
}
}
}
/**
* Commits the current session, if necessary.
*
* If an anonymous user already have an empty session, destroy it.
*/
function drupal_session_commit() {
global $user, $is_https;
if (!drupal_save_session()) {
// We don't have anything to do if we are not allowed to save the session.
return;
}
if (empty($user->uid) && empty($_SESSION)) {
// There is no session data to store, destroy the session if it was
// previously started.
if (drupal_session_started()) {
session_destroy();
}
}
else {
// There is session data to store. Start the session if it is not already
// started.
if (!drupal_session_started()) {
drupal_session_start();
if ($is_https && variable_get('https', FALSE)) {
$insecure_session_name = substr(session_name(), 1);
$params = session_get_cookie_params();
$expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
setcookie($insecure_session_name, $_COOKIE[$insecure_session_name], $expire, $params['path'], $params['domain'], FALSE, $params['httponly']);
}
}
// Write the session data.
session_write_close();
}
}
/**
* Returns whether a session has been started.
*/
function drupal_session_started($set = NULL) {
static $session_started = FALSE;
if (isset($set)) {
$session_started = $set;
}
return $session_started && session_id();
}
/**
* Called when an anonymous user becomes authenticated or vice-versa.
*
* @ingroup php_wrappers
*/
function drupal_session_regenerate() {
global $user, $is_https;
// Nothing to do if we are not allowed to change the session.
if (!drupal_save_session()) {
return;
}
if ($is_https && variable_get('https', FALSE)) {
$insecure_session_name = substr(session_name(), 1);
if (!isset($GLOBALS['lazy_session']) && isset($_COOKIE[$insecure_session_name])) {
$old_insecure_session_id = $_COOKIE[$insecure_session_name];
}
$params = session_get_cookie_params();
$session_id = drupal_random_key();
// If a session cookie lifetime is set, the session will expire
// $params['lifetime'] seconds from the current request. If it is not set,
// it will expire when the browser is closed.
$expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
setcookie($insecure_session_name, $session_id, $expire, $params['path'], $params['domain'], FALSE, $params['httponly']);
$_COOKIE[$insecure_session_name] = $session_id;
}
if (drupal_session_started()) {
$old_session_id = session_id();
_drupal_session_regenerate_existing();
}
else {
session_id(drupal_random_key());
}
if (isset($old_session_id)) {
$params = session_get_cookie_params();
$expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
setcookie(session_name(), session_id(), $expire, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
$fields = array('sid' => session_id());
if ($is_https) {
$fields['ssid'] = session_id();
// If the "secure pages" setting is enabled, use the newly-created
// insecure session identifier as the regenerated sid.
if (variable_get('https', FALSE)) {
$fields['sid'] = $session_id;
}
}
db_update('sessions')
->fields($fields)
->condition($is_https ? 'ssid' : 'sid', $old_session_id)
->execute();
}
elseif (isset($old_insecure_session_id)) {
// If logging in to the secure site, and there was no active session on the
// secure site but a session was active on the insecure site, update the
// insecure session with the new session identifiers.
db_update('sessions')
->fields(array('sid' => $session_id, 'ssid' => session_id()))
->condition('sid', $old_insecure_session_id)
->execute();
}
else {
// Start the session when it doesn't exist yet.
// Preserve the logged in user, as it will be reset to anonymous
// by _drupal_session_read.
$account = $user;
drupal_session_start();
$user = $account;
}
date_default_timezone_set(drupal_get_user_timezone());
}
/**
* Regenerates an existing session.
*/
function _drupal_session_regenerate_existing() {
global $user;
// Preserve existing settings for the saving of sessions.
$original_save_session_status = drupal_save_session();
// Turn off saving of sessions.
drupal_save_session(FALSE);
session_write_close();
drupal_session_started(FALSE);
// Preserve the user object, as starting a new session will reset it.
$original_user = $user;
session_id(drupal_random_key());
drupal_session_start();
$user = $original_user;
// Restore the original settings for the saving of sessions.
drupal_save_session($original_save_session_status);
}
/**
* Session handler assigned by session_set_save_handler().
*
* Cleans up a specific session.
*
* @param $sid
* Session ID.
*/
function _drupal_session_destroy($sid) {
global $user, $is_https;
// Nothing to do if we are not allowed to change the session.
if (!drupal_save_session()) {
return TRUE;
}
// Delete session data.
db_delete('sessions')
->condition($is_https ? 'ssid' : 'sid', $sid)
->execute();
// Reset $_SESSION and $user to prevent a new session from being started
// in drupal_session_commit().
$_SESSION = array();
$user = drupal_anonymous_user();
// Unset the session cookies.
_drupal_session_delete_cookie(session_name());
if ($is_https) {
_drupal_session_delete_cookie(substr(session_name(), 1), FALSE);
}
elseif (variable_get('https', FALSE)) {
_drupal_session_delete_cookie('S' . session_name(), TRUE);
}
return TRUE;
}
/**
* Deletes the session cookie.
*
* @param $name
* Name of session cookie to delete.
* @param boolean $secure
* Force the secure value of the cookie.
*/
function _drupal_session_delete_cookie($name, $secure = NULL) {
global $is_https;
if (isset($_COOKIE[$name]) || (!$is_https && $secure === TRUE)) {
$params = session_get_cookie_params();
if ($secure !== NULL) {
$params['secure'] = $secure;
}
setcookie($name, '', REQUEST_TIME - 3600, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
unset($_COOKIE[$name]);
}
}
/**
* Ends a specific user's session(s).
*
* @param $uid
* User ID.
*/
function drupal_session_destroy_uid($uid) {
// Nothing to do if we are not allowed to change the session.
if (!drupal_save_session()) {
return;
}
db_delete('sessions')
->condition('uid', $uid)
->execute();
}
/**
* Session handler assigned by session_set_save_handler().
*
* Cleans up stalled sessions.
*
* @param $lifetime
* The value of session.gc_maxlifetime, passed by PHP.
* Sessions not updated for more than $lifetime seconds will be removed.
*/
function _drupal_session_garbage_collection($lifetime) {
// Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough
// value. For example, if you want user sessions to stay in your database
// for three weeks before deleting them, you need to set gc_maxlifetime
// to '1814400'. At that value, only after a user doesn't log in after
// three weeks (1814400 seconds) will his/her session be removed.
db_delete('sessions')
->condition('timestamp', REQUEST_TIME - $lifetime, '<')
->execute();
return TRUE;
}
/**
* Determines whether to save session data of the current request.
*
* This function allows the caller to temporarily disable writing of
* session data, should the request end while performing potentially
* dangerous operations, such as manipulating the global $user object.
* See http://drupal.org/node/218104 for usage.
*
* @param $status
* Disables writing of session data when FALSE, (re-)enables
* writing when TRUE.
*
* @return
* FALSE if writing session data has been disabled. Otherwise, TRUE.
*/
function drupal_save_session($status = NULL) {
// PHP session ID, session, and cookie handling happens in the global scope.
// This value has to persist across calls to drupal_static_reset(), since a
// potentially wrong or disallowed session would be written otherwise.
static $save_session = TRUE;
if (isset($status)) {
$save_session = $status;
}
return $save_session;
}
+982
View File
@@ -0,0 +1,982 @@
<?php
/**
* @file
* Drupal stream wrapper interface.
*
* Provides a Drupal interface and classes to implement PHP stream wrappers for
* public, private, and temporary files.
*
* A stream wrapper is an abstraction of a file system that allows Drupal to
* use the same set of methods to access both local files and remote resources.
*
* Note that PHP 5.2 fopen() only supports URIs of the form "scheme://target"
* despite the fact that according to RFC 3986 a URI's scheme component
* delimiter is in general just ":", not "://". Because of this PHP limitation
* and for consistency Drupal will only accept URIs of form "scheme://target".
*
* @see http://www.faqs.org/rfcs/rfc3986.html
* @see http://bugs.php.net/bug.php?id=47070
*/
/**
* Stream wrapper bit flags that are the basis for composite types.
*
* Note that 0x0002 is skipped, because it was the value of a constant that has
* since been removed.
*/
/**
* Stream wrapper bit flag -- a filter that matches all wrappers.
*/
define('STREAM_WRAPPERS_ALL', 0x0000);
/**
* Stream wrapper bit flag -- refers to a local file system location.
*/
define('STREAM_WRAPPERS_LOCAL', 0x0001);
/**
* Stream wrapper bit flag -- wrapper is readable (almost always true).
*/
define('STREAM_WRAPPERS_READ', 0x0004);
/**
* Stream wrapper bit flag -- wrapper is writeable.
*/
define('STREAM_WRAPPERS_WRITE', 0x0008);
/**
* Stream wrapper bit flag -- exposed in the UI and potentially web accessible.
*/
define('STREAM_WRAPPERS_VISIBLE', 0x0010);
/**
* Composite stream wrapper bit flags that are usually used as the types.
*/
/**
* Stream wrapper type flag -- not visible in the UI or accessible via web,
* but readable and writable. E.g. the temporary directory for uploads.
*/
define('STREAM_WRAPPERS_HIDDEN', STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE);
/**
* Stream wrapper type flag -- hidden, readable and writeable using local files.
*/
define('STREAM_WRAPPERS_LOCAL_HIDDEN', STREAM_WRAPPERS_LOCAL | STREAM_WRAPPERS_HIDDEN);
/**
* Stream wrapper type flag -- visible, readable and writeable.
*/
define('STREAM_WRAPPERS_WRITE_VISIBLE', STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE | STREAM_WRAPPERS_VISIBLE);
/**
* Stream wrapper type flag -- visible and read-only.
*/
define('STREAM_WRAPPERS_READ_VISIBLE', STREAM_WRAPPERS_READ | STREAM_WRAPPERS_VISIBLE);
/**
* Stream wrapper type flag -- the default when 'type' is omitted from
* hook_stream_wrappers(). This does not include STREAM_WRAPPERS_LOCAL,
* because PHP grants a greater trust level to local files (for example, they
* can be used in an "include" statement, regardless of the "allow_url_include"
* setting), so stream wrappers need to explicitly opt-in to this.
*/
define('STREAM_WRAPPERS_NORMAL', STREAM_WRAPPERS_WRITE_VISIBLE);
/**
* Stream wrapper type flag -- visible, readable and writeable using local files.
*/
define('STREAM_WRAPPERS_LOCAL_NORMAL', STREAM_WRAPPERS_LOCAL | STREAM_WRAPPERS_NORMAL);
/**
* Generic PHP stream wrapper interface.
*
* @see http://www.php.net/manual/class.streamwrapper.php
*/
interface StreamWrapperInterface {
public function stream_open($uri, $mode, $options, &$opened_url);
public function stream_close();
public function stream_lock($operation);
public function stream_read($count);
public function stream_write($data);
public function stream_eof();
public function stream_seek($offset, $whence);
public function stream_flush();
public function stream_tell();
public function stream_stat();
public function unlink($uri);
public function rename($from_uri, $to_uri);
public function mkdir($uri, $mode, $options);
public function rmdir($uri, $options);
public function url_stat($uri, $flags);
public function dir_opendir($uri, $options);
public function dir_readdir();
public function dir_rewinddir();
public function dir_closedir();
}
/**
* Drupal stream wrapper extension.
*
* Extend the StreamWrapperInterface with methods expected by Drupal stream
* wrapper classes.
*/
interface DrupalStreamWrapperInterface extends StreamWrapperInterface {
/**
* Set the absolute stream resource URI.
*
* This allows you to set the URI. Generally is only called by the factory
* method.
*
* @param $uri
* A string containing the URI that should be used for this instance.
*/
public function setUri($uri);
/**
* Returns the stream resource URI.
*
* @return
* Returns the current URI of the instance.
*/
public function getUri();
/**
* Returns a web accessible URL for the resource.
*
* This function should return a URL that can be embedded in a web page
* and accessed from a browser. For example, the external URL of
* "youtube://xIpLd0WQKCY" might be
* "http://www.youtube.com/watch?v=xIpLd0WQKCY".
*
* @return
* Returns a string containing a web accessible URL for the resource.
*/
public function getExternalUrl();
/**
* Returns the MIME type of the resource.
*
* @param $uri
* The URI, path, or filename.
* @param $mapping
* An optional map of extensions to their mimetypes, in the form:
* - 'mimetypes': a list of mimetypes, keyed by an identifier,
* - 'extensions': the mapping itself, an associative array in which
* the key is the extension and the value is the mimetype identifier.
*
* @return
* Returns a string containing the MIME type of the resource.
*/
public static function getMimeType($uri, $mapping = NULL);
/**
* Changes permissions of the resource.
*
* PHP lacks this functionality and it is not part of the official stream
* wrapper interface. This is a custom implementation for Drupal.
*
* @param $mode
* Integer value for the permissions. Consult PHP chmod() documentation
* for more information.
*
* @return
* Returns TRUE on success or FALSE on failure.
*/
public function chmod($mode);
/**
* Returns canonical, absolute path of the resource.
*
* Implementation placeholder. PHP's realpath() does not support stream
* wrappers. We provide this as a default so that individual wrappers may
* implement their own solutions.
*
* @return
* Returns a string with absolute pathname on success (implemented
* by core wrappers), or FALSE on failure or if the registered
* wrapper does not provide an implementation.
*/
public function realpath();
/**
* Gets the name of the directory from a given path.
*
* This method is usually accessed through drupal_dirname(), which wraps
* around the normal PHP dirname() function, which does not support stream
* wrappers.
*
* @param $uri
* An optional URI.
*
* @return
* A string containing the directory name, or FALSE if not applicable.
*
* @see drupal_dirname()
*/
public function dirname($uri = NULL);
}
/**
* Drupal stream wrapper base class for local files.
*
* This class provides a complete stream wrapper implementation. URIs such as
* "public://example.txt" are expanded to a normal filesystem path such as
* "sites/default/files/example.txt" and then PHP filesystem functions are
* invoked.
*
* DrupalLocalStreamWrapper implementations need to implement at least the
* getDirectoryPath() and getExternalUrl() methods.
*/
abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface {
/**
* Stream context resource.
*
* @var Resource
*/
public $context;
/**
* A generic resource handle.
*
* @var Resource
*/
public $handle = NULL;
/**
* Instance URI (stream).
*
* A stream is referenced as "scheme://target".
*
* @var String
*/
protected $uri;
/**
* Gets the path that the wrapper is responsible for.
* @TODO: Review this method name in D8 per http://drupal.org/node/701358
*
* @return
* String specifying the path.
*/
abstract function getDirectoryPath();
/**
* Base implementation of setUri().
*/
function setUri($uri) {
$this->uri = $uri;
}
/**
* Base implementation of getUri().
*/
function getUri() {
return $this->uri;
}
/**
* Returns the local writable target of the resource within the stream.
*
* This function should be used in place of calls to realpath() or similar
* functions when attempting to determine the location of a file. While
* functions like realpath() may return the location of a read-only file, this
* method may return a URI or path suitable for writing that is completely
* separate from the URI used for reading.
*
* @param $uri
* Optional URI.
*
* @return
* Returns a string representing a location suitable for writing of a file,
* or FALSE if unable to write to the file such as with read-only streams.
*/
protected function getTarget($uri = NULL) {
if (!isset($uri)) {
$uri = $this->uri;
}
list($scheme, $target) = explode('://', $uri, 2);
// Remove erroneous leading or trailing, forward-slashes and backslashes.
return trim($target, '\/');
}
/**
* Base implementation of getMimeType().
*/
static function getMimeType($uri, $mapping = NULL) {
if (!isset($mapping)) {
// The default file map, defined in file.mimetypes.inc is quite big.
// We only load it when necessary.
include_once DRUPAL_ROOT . '/includes/file.mimetypes.inc';
$mapping = file_mimetype_mapping();
}
$extension = '';
$file_parts = explode('.', drupal_basename($uri));
// Remove the first part: a full filename should not match an extension.
array_shift($file_parts);
// Iterate over the file parts, trying to find a match.
// For my.awesome.image.jpeg, we try:
// - jpeg
// - image.jpeg, and
// - awesome.image.jpeg
while ($additional_part = array_pop($file_parts)) {
$extension = strtolower($additional_part . ($extension ? '.' . $extension : ''));
if (isset($mapping['extensions'][$extension])) {
return $mapping['mimetypes'][$mapping['extensions'][$extension]];
}
}
return 'application/octet-stream';
}
/**
* Base implementation of chmod().
*/
function chmod($mode) {
$output = @chmod($this->getLocalPath(), $mode);
// We are modifying the underlying file here, so we have to clear the stat
// cache so that PHP understands that URI has changed too.
clearstatcache();
return $output;
}
/**
* Base implementation of realpath().
*/
function realpath() {
return $this->getLocalPath();
}
/**
* Returns the canonical absolute path of the URI, if possible.
*
* @param string $uri
* (optional) The stream wrapper URI to be converted to a canonical
* absolute path. This may point to a directory or another type of file.
*
* @return string|false
* If $uri is not set, returns the canonical absolute path of the URI
* previously set by the DrupalStreamWrapperInterface::setUri() function.
* If $uri is set and valid for this class, returns its canonical absolute
* path, as determined by the realpath() function. If $uri is set but not
* valid, returns FALSE.
*/
protected function getLocalPath($uri = NULL) {
if (!isset($uri)) {
$uri = $this->uri;
}
$path = $this->getDirectoryPath() . '/' . $this->getTarget($uri);
$realpath = realpath($path);
if (!$realpath) {
// This file does not yet exist.
$realpath = realpath(dirname($path)) . '/' . drupal_basename($path);
}
$directory = realpath($this->getDirectoryPath());
if (!$realpath || !$directory || strpos($realpath, $directory) !== 0) {
return FALSE;
}
return $realpath;
}
/**
* Support for fopen(), file_get_contents(), file_put_contents() etc.
*
* @param $uri
* A string containing the URI to the file to open.
* @param $mode
* The file mode ("r", "wb" etc.).
* @param $options
* A bit mask of STREAM_USE_PATH and STREAM_REPORT_ERRORS.
* @param $opened_path
* A string containing the path actually opened.
*
* @return
* Returns TRUE if file was opened successfully.
*
* @see http://php.net/manual/streamwrapper.stream-open.php
*/
public function stream_open($uri, $mode, $options, &$opened_path) {
$this->uri = $uri;
$path = $this->getLocalPath();
$this->handle = ($options & STREAM_REPORT_ERRORS) ? fopen($path, $mode) : @fopen($path, $mode);
if ((bool) $this->handle && $options & STREAM_USE_PATH) {
$opened_path = $path;
}
return (bool) $this->handle;
}
/**
* Support for flock().
*
* @param $operation
* One of the following:
* - LOCK_SH to acquire a shared lock (reader).
* - LOCK_EX to acquire an exclusive lock (writer).
* - LOCK_UN to release a lock (shared or exclusive).
* - LOCK_NB if you don't want flock() to block while locking (not
* supported on Windows).
*
* @return
* Always returns TRUE at the present time.
*
* @see http://php.net/manual/streamwrapper.stream-lock.php
*/
public function stream_lock($operation) {
if (in_array($operation, array(LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB))) {
return flock($this->handle, $operation);
}
return TRUE;
}
/**
* Support for fread(), file_get_contents() etc.
*
* @param $count
* Maximum number of bytes to be read.
*
* @return
* The string that was read, or FALSE in case of an error.
*
* @see http://php.net/manual/streamwrapper.stream-read.php
*/
public function stream_read($count) {
return fread($this->handle, $count);
}
/**
* Support for fwrite(), file_put_contents() etc.
*
* @param $data
* The string to be written.
*
* @return
* The number of bytes written (integer).
*
* @see http://php.net/manual/streamwrapper.stream-write.php
*/
public function stream_write($data) {
return fwrite($this->handle, $data);
}
/**
* Support for feof().
*
* @return
* TRUE if end-of-file has been reached.
*
* @see http://php.net/manual/streamwrapper.stream-eof.php
*/
public function stream_eof() {
return feof($this->handle);
}
/**
* Support for fseek().
*
* @param $offset
* The byte offset to got to.
* @param $whence
* SEEK_SET, SEEK_CUR, or SEEK_END.
*
* @return
* TRUE on success.
*
* @see http://php.net/manual/streamwrapper.stream-seek.php
*/
public function stream_seek($offset, $whence) {
// fseek returns 0 on success and -1 on a failure.
// stream_seek 1 on success and 0 on a failure.
return !fseek($this->handle, $offset, $whence);
}
/**
* Support for fflush().
*
* @return
* TRUE if data was successfully stored (or there was no data to store).
*
* @see http://php.net/manual/streamwrapper.stream-flush.php
*/
public function stream_flush() {
return fflush($this->handle);
}
/**
* Support for ftell().
*
* @return
* The current offset in bytes from the beginning of file.
*
* @see http://php.net/manual/streamwrapper.stream-tell.php
*/
public function stream_tell() {
return ftell($this->handle);
}
/**
* Support for fstat().
*
* @return
* An array with file status, or FALSE in case of an error - see fstat()
* for a description of this array.
*
* @see http://php.net/manual/streamwrapper.stream-stat.php
*/
public function stream_stat() {
return fstat($this->handle);
}
/**
* Support for fclose().
*
* @return
* TRUE if stream was successfully closed.
*
* @see http://php.net/manual/streamwrapper.stream-close.php
*/
public function stream_close() {
return fclose($this->handle);
}
/**
* Sets metadata on the stream.
*
* WARNING: Do not call this method directly! It will be called internally by
* PHP itself when one of the following functions is called on a stream URL:
*
* @param string $uri
* A string containing the URI to the file to set metadata on.
* @param int $option
* One of:
* - STREAM_META_TOUCH: The method was called in response to touch().
* - STREAM_META_OWNER_NAME: The method was called in response to chown()
* with string parameter.
* - STREAM_META_OWNER: The method was called in response to chown().
* - STREAM_META_GROUP_NAME: The method was called in response to chgrp().
* - STREAM_META_GROUP: The method was called in response to chgrp().
* - STREAM_META_ACCESS: The method was called in response to chmod().
* @param mixed $value
* If option is:
* - STREAM_META_TOUCH: Array consisting of two arguments of the touch()
* function.
* - STREAM_META_OWNER_NAME or STREAM_META_GROUP_NAME: The name of the owner
* user/group as string.
* - STREAM_META_OWNER or STREAM_META_GROUP: The value of the owner
* user/group as integer.
* - STREAM_META_ACCESS: The argument of the chmod() as integer.
*
* @return bool
* Returns TRUE on success or FALSE on failure. If $option is not
* implemented, FALSE should be returned.
*
* @see touch()
* @see chmod()
* @see chown()
* @see chgrp()
* @link http://php.net/manual/streamwrapper.stream-metadata.php
*/
public function stream_metadata($uri, $option, $value) {
$target = $this->getLocalPath($uri);
$return = FALSE;
switch ($option) {
case STREAM_META_TOUCH:
if (!empty($value)) {
$return = touch($target, $value[0], $value[1]);
}
else {
$return = touch($target);
}
break;
case STREAM_META_OWNER_NAME:
case STREAM_META_OWNER:
$return = chown($target, $value);
break;
case STREAM_META_GROUP_NAME:
case STREAM_META_GROUP:
$return = chgrp($target, $value);
break;
case STREAM_META_ACCESS:
$return = chmod($target, $value);
break;
}
if ($return) {
// For convenience clear the file status cache of the underlying file,
// since metadata operations are often followed by file status checks.
clearstatcache(TRUE, $target);
}
return $return;
}
/**
* Truncate stream.
*
* Will respond to truncation; e.g., through ftruncate().
*
* @param int $new_size
* The new size.
*
* @return bool
* TRUE on success, FALSE otherwise.
*/
public function stream_truncate($new_size) {
return ftruncate($this->handle, $new_size);
}
/**
* Retrieve the underlying stream resource.
*
* This method is called in response to stream_select().
*
* @param int $cast_as
* Can be STREAM_CAST_FOR_SELECT when stream_select() is calling
* stream_cast() or STREAM_CAST_AS_STREAM when stream_cast() is called for
* other uses.
*
* @return resource|false
* The underlying stream resource or FALSE if stream_select() is not
* supported.
*
* @see stream_select()
* @link http://php.net/manual/streamwrapper.stream-cast.php
*/
public function stream_cast($cast_as) {
return $this->handle ? $this->handle : FALSE;
}
/**
* Change stream options.
*
* This method is called to set options on the stream.
*
* Since Windows systems do not allow it and it is not needed for most use
* cases anyway, this method is not supported on local files and will trigger
* an error and return false. If needed, custom subclasses can provide
* OS-specific implementations for advanced use cases.
*
* @param int $option
* One of:
* - STREAM_OPTION_BLOCKING: The method was called in response to
* stream_set_blocking().
* - STREAM_OPTION_READ_TIMEOUT: The method was called in response to
* stream_set_timeout().
* - STREAM_OPTION_WRITE_BUFFER: The method was called in response to
* stream_set_write_buffer().
* @param int $arg1
* If option is:
* - STREAM_OPTION_BLOCKING: The requested blocking mode:
* - 1 means blocking.
* - 0 means not blocking.
* - STREAM_OPTION_READ_TIMEOUT: The timeout in seconds.
* - STREAM_OPTION_WRITE_BUFFER: The buffer mode, STREAM_BUFFER_NONE or
* STREAM_BUFFER_FULL.
* @param int $arg2
* If option is:
* - STREAM_OPTION_BLOCKING: This option is not set.
* - STREAM_OPTION_READ_TIMEOUT: The timeout in microseconds.
* - STREAM_OPTION_WRITE_BUFFER: The requested buffer size.
*
* @return bool
* TRUE on success, FALSE otherwise. If $option is not implemented, FALSE
* should be returned.
*/
public function stream_set_option($option, $arg1, $arg2) {
trigger_error('stream_set_option() not supported for local file based stream wrappers', E_USER_WARNING);
return FALSE;
}
/**
* Support for unlink().
*
* @param $uri
* A string containing the URI to the resource to delete.
*
* @return
* TRUE if resource was successfully deleted.
*
* @see http://php.net/manual/streamwrapper.unlink.php
*/
public function unlink($uri) {
$this->uri = $uri;
return drupal_unlink($this->getLocalPath());
}
/**
* Support for rename().
*
* @param $from_uri,
* The URI to the file to rename.
* @param $to_uri
* The new URI for file.
*
* @return
* TRUE if file was successfully renamed.
*
* @see http://php.net/manual/streamwrapper.rename.php
*/
public function rename($from_uri, $to_uri) {
return rename($this->getLocalPath($from_uri), $this->getLocalPath($to_uri));
}
/**
* Gets the name of the directory from a given path.
*
* This method is usually accessed through drupal_dirname(), which wraps
* around the PHP dirname() function because it does not support stream
* wrappers.
*
* @param $uri
* A URI or path.
*
* @return
* A string containing the directory name.
*
* @see drupal_dirname()
*/
public function dirname($uri = NULL) {
list($scheme, $target) = explode('://', $uri, 2);
$target = $this->getTarget($uri);
$dirname = dirname($target);
if ($dirname == '.') {
$dirname = '';
}
return $scheme . '://' . $dirname;
}
/**
* Support for mkdir().
*
* @param $uri
* A string containing the URI to the directory to create.
* @param $mode
* Permission flags - see mkdir().
* @param $options
* A bit mask of STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE.
*
* @return
* TRUE if directory was successfully created.
*
* @see http://php.net/manual/streamwrapper.mkdir.php
*/
public function mkdir($uri, $mode, $options) {
$this->uri = $uri;
$recursive = (bool) ($options & STREAM_MKDIR_RECURSIVE);
if ($recursive) {
// $this->getLocalPath() fails if $uri has multiple levels of directories
// that do not yet exist.
$localpath = $this->getDirectoryPath() . '/' . $this->getTarget($uri);
}
else {
$localpath = $this->getLocalPath($uri);
}
if ($options & STREAM_REPORT_ERRORS) {
return mkdir($localpath, $mode, $recursive);
}
else {
return @mkdir($localpath, $mode, $recursive);
}
}
/**
* Support for rmdir().
*
* @param $uri
* A string containing the URI to the directory to delete.
* @param $options
* A bit mask of STREAM_REPORT_ERRORS.
*
* @return
* TRUE if directory was successfully removed.
*
* @see http://php.net/manual/streamwrapper.rmdir.php
*/
public function rmdir($uri, $options) {
$this->uri = $uri;
if ($options & STREAM_REPORT_ERRORS) {
return drupal_rmdir($this->getLocalPath());
}
else {
return @drupal_rmdir($this->getLocalPath());
}
}
/**
* Support for stat().
*
* @param $uri
* A string containing the URI to get information about.
* @param $flags
* A bit mask of STREAM_URL_STAT_LINK and STREAM_URL_STAT_QUIET.
*
* @return
* An array with file status, or FALSE in case of an error - see fstat()
* for a description of this array.
*
* @see http://php.net/manual/streamwrapper.url-stat.php
*/
public function url_stat($uri, $flags) {
$this->uri = $uri;
$path = $this->getLocalPath();
// Suppress warnings if requested or if the file or directory does not
// exist. This is consistent with PHP's plain filesystem stream wrapper.
if ($flags & STREAM_URL_STAT_QUIET || !file_exists($path)) {
return @stat($path);
}
else {
return stat($path);
}
}
/**
* Support for opendir().
*
* @param $uri
* A string containing the URI to the directory to open.
* @param $options
* Unknown (parameter is not documented in PHP Manual).
*
* @return
* TRUE on success.
*
* @see http://php.net/manual/streamwrapper.dir-opendir.php
*/
public function dir_opendir($uri, $options) {
$this->uri = $uri;
$this->handle = opendir($this->getLocalPath());
return (bool) $this->handle;
}
/**
* Support for readdir().
*
* @return
* The next filename, or FALSE if there are no more files in the directory.
*
* @see http://php.net/manual/streamwrapper.dir-readdir.php
*/
public function dir_readdir() {
return readdir($this->handle);
}
/**
* Support for rewinddir().
*
* @return
* TRUE on success.
*
* @see http://php.net/manual/streamwrapper.dir-rewinddir.php
*/
public function dir_rewinddir() {
rewinddir($this->handle);
// We do not really have a way to signal a failure as rewinddir() does not
// have a return value and there is no way to read a directory handler
// without advancing to the next file.
return TRUE;
}
/**
* Support for closedir().
*
* @return
* TRUE on success.
*
* @see http://php.net/manual/streamwrapper.dir-closedir.php
*/
public function dir_closedir() {
closedir($this->handle);
// We do not really have a way to signal a failure as closedir() does not
// have a return value.
return TRUE;
}
}
/**
* Drupal public (public://) stream wrapper class.
*
* Provides support for storing publicly accessible files with the Drupal file
* interface.
*/
class DrupalPublicStreamWrapper extends DrupalLocalStreamWrapper {
/**
* Implements abstract public function getDirectoryPath()
*/
public function getDirectoryPath() {
return variable_get('file_public_path', conf_path() . '/files');
}
/**
* Overrides getExternalUrl().
*
* Return the HTML URI of a public file.
*/
function getExternalUrl() {
$path = str_replace('\\', '/', $this->getTarget());
return $GLOBALS['base_url'] . '/' . self::getDirectoryPath() . '/' . drupal_encode_path($path);
}
}
/**
* Drupal private (private://) stream wrapper class.
*
* Provides support for storing privately accessible files with the Drupal file
* interface.
*/
class DrupalPrivateStreamWrapper extends DrupalLocalStreamWrapper {
/**
* Implements abstract public function getDirectoryPath()
*/
public function getDirectoryPath() {
return variable_get('file_private_path', '');
}
/**
* Overrides getExternalUrl().
*
* Return the HTML URI of a private file.
*/
function getExternalUrl() {
$path = str_replace('\\', '/', $this->getTarget());
return url('system/files/' . $path, array('absolute' => TRUE));
}
}
/**
* Drupal temporary (temporary://) stream wrapper class.
*
* Provides support for storing temporarily accessible files with the Drupal
* file interface.
*
* Extends DrupalPublicStreamWrapper.
*/
class DrupalTemporaryStreamWrapper extends DrupalLocalStreamWrapper {
/**
* Implements abstract public function getDirectoryPath()
*/
public function getDirectoryPath() {
return variable_get('file_temporary_path', file_directory_temp());
}
/**
* Overrides getExternalUrl().
*/
public function getExternalUrl() {
$path = str_replace('\\', '/', $this->getTarget());
return url('system/temporary/' . $path, array('absolute' => TRUE));
}
}
+255
View File
@@ -0,0 +1,255 @@
<?php
/**
* @file
* Functions to aid in the creation of sortable tables.
*
* All tables created with a call to theme('table') have the option of having
* column headers that the user can click on to sort the table by that column.
*/
/**
* Query extender class for tablesort queries.
*/
class TableSort extends SelectQueryExtender {
/**
* The array of fields that can be sorted by.
*
* @var array
*/
protected $header = array();
public function __construct(SelectQueryInterface $query, DatabaseConnection $connection) {
parent::__construct($query, $connection);
// Add convenience tag to mark that this is an extended query. We have to
// do this in the constructor to ensure that it is set before preExecute()
// gets called.
$this->addTag('tablesort');
}
/**
* Order the query based on a header array.
*
* @see theme_table()
* @param $header
* Table header array.
* @return SelectQueryInterface
* The called object.
*/
public function orderByHeader(Array $header) {
$this->header = $header;
$ts = $this->init();
if (!empty($ts['sql'])) {
// Based on code from db_escape_table(), but this can also contain a dot.
$field = preg_replace('/[^A-Za-z0-9_.]+/', '', $ts['sql']);
// orderBy() will ensure that only ASC/DESC values are accepted, so we
// don't need to sanitize that here.
$this->orderBy($field, $ts['sort']);
}
return $this;
}
/**
* Initializes the table sort context.
*/
protected function init() {
$ts = $this->order();
$ts['sort'] = $this->getSort();
$ts['query'] = $this->getQueryParameters();
return $ts;
}
/**
* Determine the current sort direction.
*
* @param $headers
* An array of column headers in the format described in theme_table().
* @return
* The current sort direction ("asc" or "desc").
*/
protected function getSort() {
return tablesort_get_sort($this->header);
}
/**
* Compose a URL query parameter array to append to table sorting requests.
*
* @return
* A URL query parameter array that consists of all components of the current
* page request except for those pertaining to table sorting.
*
* @see tablesort_get_query_parameters()
*/
protected function getQueryParameters() {
return tablesort_get_query_parameters();
}
/**
* Determine the current sort criterion.
*
* @param $headers
* An array of column headers in the format described in theme_table().
* @return
* An associative array describing the criterion, containing the keys:
* - "name": The localized title of the table column.
* - "sql": The name of the database field to sort on.
*/
protected function order() {
return tablesort_get_order($this->header);
}
}
/**
* Initialize the table sort context.
*/
function tablesort_init($header) {
$ts = tablesort_get_order($header);
$ts['sort'] = tablesort_get_sort($header);
$ts['query'] = tablesort_get_query_parameters();
return $ts;
}
/**
* Formats a column header.
*
* If the cell in question is the column header for the current sort criterion,
* it gets special formatting. All possible sort criteria become links.
*
* @param $cell
* The cell to format.
* @param $header
* An array of column headers in the format described in theme_table().
* @param $ts
* The current table sort context as returned from tablesort_init().
*
* @return
* A properly formatted cell, ready for _theme_table_cell().
*/
function tablesort_header($cell, $header, $ts) {
// Special formatting for the currently sorted column header.
if (is_array($cell) && isset($cell['field'])) {
$title = t('sort by @s', array('@s' => $cell['data']));
if ($cell['data'] == $ts['name']) {
$ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc');
$cell['class'][] = 'active';
$image = theme('tablesort_indicator', array('style' => $ts['sort']));
}
else {
// If the user clicks a different header, we want to sort ascending initially.
$ts['sort'] = 'asc';
$image = '';
}
$cell['data'] = l($cell['data'] . $image, $_GET['q'], array('attributes' => array('title' => $title), 'query' => array_merge($ts['query'], array('sort' => $ts['sort'], 'order' => $cell['data'])), 'html' => TRUE));
unset($cell['field'], $cell['sort']);
}
return $cell;
}
/**
* Formats a table cell.
*
* Adds a class attribute to all cells in the currently active column.
*
* @param $cell
* The cell to format.
* @param $header
* An array of column headers in the format described in theme_table().
* @param $ts
* The current table sort context as returned from tablesort_init().
* @param $i
* The index of the cell's table column.
*
* @return
* A properly formatted cell, ready for _theme_table_cell().
*/
function tablesort_cell($cell, $header, $ts, $i) {
if (isset($header[$i]['data']) && $header[$i]['data'] == $ts['name'] && !empty($header[$i]['field'])) {
if (is_array($cell)) {
$cell['class'][] = 'active';
}
else {
$cell = array('data' => $cell, 'class' => array('active'));
}
}
return $cell;
}
/**
* Composes a URL query parameter array for table sorting links.
*
* @return
* A URL query parameter array that consists of all components of the current
* page request except for those pertaining to table sorting.
*/
function tablesort_get_query_parameters() {
return drupal_get_query_parameters($_GET, array('q', 'sort', 'order'));
}
/**
* Determines the current sort criterion.
*
* @param $headers
* An array of column headers in the format described in theme_table().
*
* @return
* An associative array describing the criterion, containing the keys:
* - "name": The localized title of the table column.
* - "sql": The name of the database field to sort on.
*/
function tablesort_get_order($headers) {
$order = isset($_GET['order']) ? $_GET['order'] : '';
foreach ($headers as $header) {
if (is_array($header)) {
if (isset($header['data']) && $order == $header['data']) {
$default = $header;
break;
}
if (empty($default) && isset($header['sort']) && ($header['sort'] == 'asc' || $header['sort'] == 'desc')) {
$default = $header;
}
}
}
if (!isset($default)) {
$default = reset($headers);
if (!is_array($default)) {
$default = array('data' => $default);
}
}
$default += array('data' => NULL, 'field' => NULL);
return array('name' => $default['data'], 'sql' => $default['field']);
}
/**
* Determines the current sort direction.
*
* @param $headers
* An array of column headers in the format described in theme_table().
*
* @return
* The current sort direction ("asc" or "desc").
*/
function tablesort_get_sort($headers) {
if (isset($_GET['sort'])) {
return (strtolower($_GET['sort']) == 'desc') ? 'desc' : 'asc';
}
// The user has not specified a sort. Use the default for the currently sorted
// header if specified; otherwise use "asc".
else {
// Find out which header is currently being sorted.
$ts = tablesort_get_order($headers);
foreach ($headers as $header) {
if (is_array($header) && isset($header['data']) && $header['data'] == $ts['name'] && isset($header['sort'])) {
return $header['sort'];
}
}
}
return 'asc';
}
+3053
View File
File diff suppressed because it is too large Load Diff
+211
View File
@@ -0,0 +1,211 @@
<?php
/**
* @file
* Theming for maintenance pages.
*/
/**
* Sets up the theming system for maintenance page.
*
* Used for site installs, updates and when the site is in maintenance mode.
* It also applies when the database is unavailable or bootstrap was not
* complete. Seven is always used for the initial install and update
* operations. In other cases, Bartik is used, but this can be overridden by
* setting a "maintenance_theme" key in the $conf variable in settings.php.
*/
function _drupal_maintenance_theme() {
global $theme, $theme_key, $conf;
// If $theme is already set, assume the others are set too, and do nothing.
if (isset($theme)) {
return;
}
require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'includes/path.inc');
require_once DRUPAL_ROOT . '/includes/theme.inc';
require_once DRUPAL_ROOT . '/includes/common.inc';
require_once DRUPAL_ROOT . '/includes/unicode.inc';
require_once DRUPAL_ROOT . '/includes/file.inc';
require_once DRUPAL_ROOT . '/includes/module.inc';
unicode_check();
// Install and update pages are treated differently to prevent theming overrides.
if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
$custom_theme = (isset($conf['maintenance_theme']) ? $conf['maintenance_theme'] : 'seven');
}
else {
// The bootstrap was not complete. So we are operating in a crippled
// environment, we need to bootstrap just enough to allow hook invocations
// to work. See _drupal_log_error().
if (!class_exists('Database', FALSE)) {
require_once DRUPAL_ROOT . '/includes/database/database.inc';
}
// We use the default theme as the maintenance theme. If a default theme
// isn't specified in the database or in settings.php, we use Bartik.
$custom_theme = variable_get('maintenance_theme', variable_get('theme_default', 'bartik'));
}
// Ensure that system.module is loaded.
if (!function_exists('_system_rebuild_theme_data')) {
$module_list['system']['filename'] = 'modules/system/system.module';
module_list(TRUE, FALSE, FALSE, $module_list);
drupal_load('module', 'system');
}
$themes = list_themes();
// list_themes() triggers a drupal_alter() in maintenance mode, but we can't
// let themes alter the .info data until we know a theme's base themes. So
// don't set global $theme until after list_themes() builds its cache.
$theme = $custom_theme;
// Store the identifier for retrieving theme settings with.
$theme_key = $theme;
// Find all our ancestor themes and put them in an array.
$base_theme = array();
$ancestor = $theme;
while ($ancestor && isset($themes[$ancestor]->base_theme)) {
$base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme];
$ancestor = $themes[$ancestor]->base_theme;
}
_drupal_theme_initialize($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry');
// These are usually added from system_init() -except maintenance.css.
// When the database is inactive it's not called so we add it here.
$path = drupal_get_path('module', 'system');
drupal_add_css($path . '/system.base.css');
drupal_add_css($path . '/system.admin.css');
drupal_add_css($path . '/system.menus.css');
drupal_add_css($path . '/system.messages.css');
drupal_add_css($path . '/system.theme.css');
drupal_add_css($path . '/system.maintenance.css');
}
/**
* Builds the registry when the site needs to bypass any database calls.
*/
function _theme_load_offline_registry($theme, $base_theme = NULL, $theme_engine = NULL) {
return _theme_build_registry($theme, $base_theme, $theme_engine);
}
/**
* Returns HTML for a list of maintenance tasks to perform.
*
* @param $variables
* An associative array containing:
* - items: An associative array of maintenance tasks.
* - active: The key for the currently active maintenance task.
*
* @ingroup themeable
*/
function theme_task_list($variables) {
$items = $variables['items'];
$active = $variables['active'];
$done = isset($items[$active]) || $active == NULL;
$output = '<h2 class="element-invisible">Installation tasks</h2>';
$output .= '<ol class="task-list">';
foreach ($items as $k => $item) {
if ($active == $k) {
$class = 'active';
$status = '(' . t('active') . ')';
$done = FALSE;
}
else {
$class = $done ? 'done' : '';
$status = $done ? '(' . t('done') . ')' : '';
}
$output .= '<li';
$output .= ($class ? ' class="' . $class . '"' : '') . '>';
$output .= $item;
$output .= ($status ? '<span class="element-invisible">' . $status . '</span>' : '');
$output .= '</li>';
}
$output .= '</ol>';
return $output;
}
/**
* Returns HTML for the installation page.
*
* Note: this function is not themeable.
*
* @param $variables
* An associative array containing:
* - content: The page content to show.
*/
function theme_install_page($variables) {
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
return theme('maintenance_page', $variables);
}
/**
* Returns HTML for the update page.
*
* Note: this function is not themeable.
*
* @param $variables
* An associative array containing:
* - content: The page content to show.
* - show_messages: Whether to output status and error messages.
* FALSE can be useful to postpone the messages to a subsequent page.
*/
function theme_update_page($variables) {
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
return theme('maintenance_page', $variables);
}
/**
* Returns HTML for a results report of an operation run by authorize.php.
*
* @param $variables
* An associative array containing:
* - messages: An array of result messages.
*
* @ingroup themeable
*/
function theme_authorize_report($variables) {
$messages = $variables['messages'];
$output = '';
if (!empty($messages)) {
$output .= '<div id="authorize-results">';
foreach ($messages as $heading => $logs) {
$items = array();
foreach ($logs as $number => $log_message) {
if ($number === '#abort') {
continue;
}
$items[] = theme('authorize_message', array('message' => $log_message['message'], 'success' => $log_message['success']));
}
$output .= theme('item_list', array('items' => $items, 'title' => $heading));
}
$output .= '</div>';
}
return $output;
}
/**
* Returns HTML for a single log message from the authorize.php batch operation.
*
* @param $variables
* An associative array containing:
* - message: The log message.
* - success: A boolean indicating failure or success.
*
* @ingroup themeable
*/
function theme_authorize_message($variables) {
$message = $variables['message'];
$success = $variables['success'];
if ($success) {
$item = array('data' => $message, 'class' => array('success'));
}
else {
$item = array('data' => '<strong>' . $message . '</strong>', 'class' => array('failure'));
}
return $item;
}
+264
View File
@@ -0,0 +1,264 @@
<?php
/**
* @file
* Drupal placeholder/token replacement system.
*
* API functions for replacing placeholders in text with meaningful values.
*
* For example: When configuring automated emails, an administrator enters
* standard text for the email. Variables like the title of a node and the date
* the email was sent can be entered as placeholders like [node:title] and
* [date:short]. When a Drupal module prepares to send the email, it can call
* the token_replace() function, passing in the text. The token system will
* scan the text for placeholder tokens, give other modules an opportunity to
* replace them with meaningful text, then return the final product to the
* original module.
*
* Tokens follow the form: [$type:$name], where $type is a general class of
* tokens like 'node', 'user', or 'comment' and $name is the name of a given
* placeholder. For example, [node:title] or [node:created:since].
*
* In addition to raw text containing placeholders, modules may pass in an array
* of objects to be used when performing the replacement. The objects should be
* keyed by the token type they correspond to. For example:
*
* @code
* // Load a node and a user, then replace tokens in the text.
* $text = 'On [date:short], [user:name] read [node:title].';
* $node = node_load(1);
* $user = user_load(1);
*
* // [date:...] tokens use the current date automatically.
* $data = array('node' => $node, 'user' => $user);
* return token_replace($text, $data);
* @endcode
*
* Some tokens may be chained in the form of [$type:$pointer:$name], where $type
* is a normal token type, $pointer is a reference to another token type, and
* $name is the name of a given placeholder. For example, [node:author:mail]. In
* that example, 'author' is a pointer to the 'user' account that created the
* node, and 'mail' is a placeholder available for any 'user'.
*
* @see token_replace()
* @see hook_tokens()
* @see hook_token_info()
*/
/**
* Replaces all tokens in a given string with appropriate values.
*
* @param $text
* A string potentially containing replaceable tokens.
* @param $data
* (optional) An array of keyed objects. For simple replacement scenarios
* 'node', 'user', and others are common keys, with an accompanying node or
* user object being the value. Some token types, like 'site', do not require
* any explicit information from $data and can be replaced even if it is
* empty.
* @param $options
* (optional) A keyed array of settings and flags to control the token
* replacement process. Supported options are:
* - language: A language object to be used when generating locale-sensitive
* tokens.
* - callback: A callback function that will be used to post-process the array
* of token replacements after they are generated. For example, a module
* using tokens in a text-only email might provide a callback to strip HTML
* entities from token values before they are inserted into the final text.
* - clear: A boolean flag indicating that tokens should be removed from the
* final text if no replacement value can be generated.
* - sanitize: A boolean flag indicating that tokens should be sanitized for
* display to a web browser. Defaults to TRUE. Developers who set this
* option to FALSE assume responsibility for running filter_xss(),
* check_plain() or other appropriate scrubbing functions before displaying
* data to users.
*
* @return
* Text with tokens replaced.
*/
function token_replace($text, array $data = array(), array $options = array()) {
$text_tokens = token_scan($text);
if (empty($text_tokens)) {
return $text;
}
$replacements = array();
foreach ($text_tokens as $type => $tokens) {
$replacements += token_generate($type, $tokens, $data, $options);
if (!empty($options['clear'])) {
$replacements += array_fill_keys($tokens, '');
}
}
// Optionally alter the list of replacement values.
if (!empty($options['callback']) && function_exists($options['callback'])) {
$function = $options['callback'];
$function($replacements, $data, $options);
}
$tokens = array_keys($replacements);
$values = array_values($replacements);
return str_replace($tokens, $values, $text);
}
/**
* Builds a list of all token-like patterns that appear in the text.
*
* @param $text
* The text to be scanned for possible tokens.
*
* @return
* An associative array of discovered tokens, grouped by type.
*/
function token_scan($text) {
// Matches tokens with the following pattern: [$type:$name]
// $type and $name may not contain [ ] characters.
// $type may not contain : or whitespace characters, but $name may.
preg_match_all('/
\[ # [ - pattern start
([^\s\[\]:]*) # match $type not containing whitespace : [ or ]
: # : - separator
([^\[\]]*) # match $name not containing [ or ]
\] # ] - pattern end
/x', $text, $matches);
$types = $matches[1];
$tokens = $matches[2];
// Iterate through the matches, building an associative array containing
// $tokens grouped by $types, pointing to the version of the token found in
// the source text. For example, $results['node']['title'] = '[node:title]';
$results = array();
for ($i = 0; $i < count($tokens); $i++) {
$results[$types[$i]][$tokens[$i]] = $matches[0][$i];
}
return $results;
}
/**
* Generates replacement values for a list of tokens.
*
* @param $type
* The type of token being replaced. 'node', 'user', and 'date' are common.
* @param $tokens
* An array of tokens to be replaced, keyed by the literal text of the token
* as it appeared in the source text.
* @param $data
* (optional) An array of keyed objects. For simple replacement scenarios
* 'node', 'user', and others are common keys, with an accompanying node or
* user object being the value. Some token types, like 'site', do not require
* any explicit information from $data and can be replaced even if it is
* empty.
* @param $options
* (optional) A keyed array of settings and flags to control the token
* replacement process. Supported options are:
* - language: A language object to be used when generating locale-sensitive
* tokens.
* - callback: A callback function that will be used to post-process the
* array of token replacements after they are generated. Can be used when
* modules require special formatting of token text, for example URL
* encoding or truncation to a specific length.
* - sanitize: A boolean flag indicating that tokens should be sanitized for
* display to a web browser. Developers who set this option to FALSE assume
* responsibility for running filter_xss(), check_plain() or other
* appropriate scrubbing functions before displaying data to users.
*
* @return
* An associative array of replacement values, keyed by the original 'raw'
* tokens that were found in the source text. For example:
* $results['[node:title]'] = 'My new node';
*
* @see hook_tokens()
* @see hook_tokens_alter()
*/
function token_generate($type, array $tokens, array $data = array(), array $options = array()) {
$options += array('sanitize' => TRUE);
$replacements = module_invoke_all('tokens', $type, $tokens, $data, $options);
// Allow other modules to alter the replacements.
$context = array(
'type' => $type,
'tokens' => $tokens,
'data' => $data,
'options' => $options,
);
drupal_alter('tokens', $replacements, $context);
return $replacements;
}
/**
* Returns a list of tokens that begin with a specific prefix.
*
* Used to extract a group of 'chained' tokens (such as [node:author:name])
* from the full list of tokens found in text. For example:
* @code
* $data = array(
* 'author:name' => '[node:author:name]',
* 'title' => '[node:title]',
* 'created' => '[node:created]',
* );
* $results = token_find_with_prefix($data, 'author');
* $results == array('name' => '[node:author:name]');
* @endcode
*
* @param $tokens
* A keyed array of tokens, and their original raw form in the source text.
* @param $prefix
* A textual string to be matched at the beginning of the token.
* @param $delimiter
* An optional string containing the character that separates the prefix from
* the rest of the token. Defaults to ':'.
*
* @return
* An associative array of discovered tokens, with the prefix and delimiter
* stripped from the key.
*/
function token_find_with_prefix(array $tokens, $prefix, $delimiter = ':') {
$results = array();
foreach ($tokens as $token => $raw) {
$parts = explode($delimiter, $token, 2);
if (count($parts) == 2 && $parts[0] == $prefix) {
$results[$parts[1]] = $raw;
}
}
return $results;
}
/**
* Returns metadata describing supported tokens.
*
* The metadata array contains token type, name, and description data as well
* as an optional pointer indicating that the token chains to another set of
* tokens.
*
* For example:
* @code
* $data['types']['node'] = array(
* 'name' => t('Nodes'),
* 'description' => t('Tokens related to node objects.'),
* );
* $data['tokens']['node']['title'] = array(
* 'name' => t('Title'),
* 'description' => t('The title of the current node.'),
* );
* $data['tokens']['node']['author'] = array(
* 'name' => t('Author'),
* 'description' => t('The author of the current node.'),
* 'type' => 'user',
* );
* @endcode
*
* @return
* An associative array of token information, grouped by token type.
*/
function token_info() {
$data = &drupal_static(__FUNCTION__);
if (!isset($data)) {
$data = module_invoke_all('token_info');
drupal_alter('token_info', $data);
}
return $data;
}
+265
View File
@@ -0,0 +1,265 @@
<?php
/**
* @file
* (X)HTML entities, as defined in HTML 4.01.
*
* @see http://www.w3.org/TR/html401/sgml/entities.html
*/
$html_entities = array(
'&Aacute;' => 'Á',
'&aacute;' => 'á',
'&Acirc;' => 'Â',
'&acirc;' => 'â',
'&acute;' => '´',
'&AElig;' => 'Æ',
'&aelig;' => 'æ',
'&Agrave;' => 'À',
'&agrave;' => 'à',
'&alefsym;' => 'ℵ',
'&Alpha;' => 'Α',
'&alpha;' => 'α',
'&amp;' => '&',
'&and;' => '∧',
'&ang;' => '∠',
'&Aring;' => 'Å',
'&aring;' => 'å',
'&asymp;' => '≈',
'&Atilde;' => 'Ã',
'&atilde;' => 'ã',
'&Auml;' => 'Ä',
'&auml;' => 'ä',
'&bdquo;' => '„',
'&Beta;' => 'Β',
'&beta;' => 'β',
'&brvbar;' => '¦',
'&bull;' => '•',
'&cap;' => '∩',
'&Ccedil;' => 'Ç',
'&ccedil;' => 'ç',
'&cedil;' => '¸',
'&cent;' => '¢',
'&Chi;' => 'Χ',
'&chi;' => 'χ',
'&circ;' => 'ˆ',
'&clubs;' => '♣',
'&cong;' => '≅',
'&copy;' => '©',
'&crarr;' => '↵',
'&cup;' => '',
'&curren;' => '¤',
'&dagger;' => '†',
'&Dagger;' => '‡',
'&darr;' => '↓',
'&dArr;' => '⇓',
'&deg;' => '°',
'&Delta;' => 'Δ',
'&delta;' => 'δ',
'&diams;' => '♦',
'&divide;' => '÷',
'&Eacute;' => 'É',
'&eacute;' => 'é',
'&Ecirc;' => 'Ê',
'&ecirc;' => 'ê',
'&Egrave;' => 'È',
'&egrave;' => 'è',
'&empty;' => '∅',
'&emsp;' => '',
'&ensp;' => '',
'&Epsilon;' => 'Ε',
'&epsilon;' => 'ε',
'&equiv;' => '≡',
'&Eta;' => 'Η',
'&eta;' => 'η',
'&ETH;' => 'Ð',
'&eth;' => 'ð',
'&Euml;' => 'Ë',
'&euml;' => 'ë',
'&euro;' => '€',
'&exist;' => '∃',
'&fnof;' => 'ƒ',
'&forall;' => '∀',
'&frac12;' => '½',
'&frac14;' => '¼',
'&frac34;' => '¾',
'&frasl;' => '',
'&Gamma;' => 'Γ',
'&gamma;' => 'γ',
'&ge;' => '≥',
'&harr;' => '↔',
'&hArr;' => '⇔',
'&hearts;' => '♥',
'&hellip;' => '…',
'&Iacute;' => 'Í',
'&iacute;' => 'í',
'&Icirc;' => 'Î',
'&icirc;' => 'î',
'&iexcl;' => '¡',
'&Igrave;' => 'Ì',
'&igrave;' => 'ì',
'&image;' => '',
'&infin;' => '∞',
'&int;' => '∫',
'&Iota;' => 'Ι',
'&iota;' => 'ι',
'&iquest;' => '¿',
'&isin;' => '∈',
'&Iuml;' => 'Ï',
'&iuml;' => 'ï',
'&Kappa;' => 'Κ',
'&kappa;' => 'κ',
'&Lambda;' => 'Λ',
'&lambda;' => 'λ',
'&lang;' => '〈',
'&laquo;' => '«',
'&larr;' => '←',
'&lArr;' => '⇐',
'&lceil;' => '⌈',
'&ldquo;' => '“',
'&le;' => '≤',
'&lfloor;' => '⌊',
'&lowast;' => '',
'&loz;' => '◊',
'&lrm;' => '',
'&lsaquo;' => '',
'&lsquo;' => '',
'&macr;' => '¯',
'&mdash;' => '—',
'&micro;' => 'µ',
'&middot;' => '·',
'&minus;' => '',
'&Mu;' => 'Μ',
'&mu;' => 'μ',
'&nabla;' => '∇',
'&nbsp;' => ' ',
'&ndash;' => '',
'&ne;' => '≠',
'&ni;' => '∋',
'&not;' => '¬',
'&notin;' => '∉',
'&nsub;' => '⊄',
'&Ntilde;' => 'Ñ',
'&ntilde;' => 'ñ',
'&Nu;' => 'Ν',
'&nu;' => 'ν',
'&Oacute;' => 'Ó',
'&oacute;' => 'ó',
'&Ocirc;' => 'Ô',
'&ocirc;' => 'ô',
'&OElig;' => 'Œ',
'&oelig;' => 'œ',
'&Ograve;' => 'Ò',
'&ograve;' => 'ò',
'&oline;' => '‾',
'&Omega;' => 'Ω',
'&omega;' => 'ω',
'&Omicron;' => 'Ο',
'&omicron;' => 'ο',
'&oplus;' => '⊕',
'&or;' => '',
'&ordf;' => 'ª',
'&ordm;' => 'º',
'&Oslash;' => 'Ø',
'&oslash;' => 'ø',
'&Otilde;' => 'Õ',
'&otilde;' => 'õ',
'&otimes;' => '⊗',
'&Ouml;' => 'Ö',
'&ouml;' => 'ö',
'&para;' => '¶',
'&part;' => '∂',
'&permil;' => '‰',
'&perp;' => '⊥',
'&Phi;' => 'Φ',
'&phi;' => 'φ',
'&Pi;' => 'Π',
'&pi;' => 'π',
'&piv;' => 'ϖ',
'&plusmn;' => '±',
'&pound;' => '£',
'&prime;' => '',
'&Prime;' => '″',
'&prod;' => '∏',
'&prop;' => '∝',
'&Psi;' => 'Ψ',
'&psi;' => 'ψ',
'&radic;' => '√',
'&rang;' => '〉',
'&raquo;' => '»',
'&rarr;' => '→',
'&rArr;' => '⇒',
'&rceil;' => '⌉',
'&rdquo;' => '”',
'&real;' => '',
'&reg;' => '®',
'&rfloor;' => '⌋',
'&Rho;' => 'Ρ',
'&rho;' => 'ρ',
'&rlm;' => '',
'&rsaquo;' => '',
'&rsquo;' => '',
'&sbquo;' => '',
'&Scaron;' => 'Š',
'&scaron;' => 'š',
'&sdot;' => '⋅',
'&sect;' => '§',
'&shy;' => '­',
'&Sigma;' => 'Σ',
'&sigma;' => 'σ',
'&sigmaf;' => 'ς',
'&sim;' => '',
'&spades;' => '♠',
'&sub;' => '⊂',
'&sube;' => '⊆',
'&sum;' => '∑',
'&sup1;' => '¹',
'&sup2;' => '²',
'&sup3;' => '³',
'&sup;' => '⊃',
'&supe;' => '⊇',
'&szlig;' => 'ß',
'&Tau;' => 'Τ',
'&tau;' => 'τ',
'&there4;' => '∴',
'&Theta;' => 'Θ',
'&theta;' => 'θ',
'&thetasym;' => 'ϑ',
'&thinsp;' => '',
'&THORN;' => 'Þ',
'&thorn;' => 'þ',
'&tilde;' => '˜',
'&times;' => '×',
'&trade;' => '™',
'&Uacute;' => 'Ú',
'&uacute;' => 'ú',
'&uarr;' => '↑',
'&uArr;' => '⇑',
'&Ucirc;' => 'Û',
'&ucirc;' => 'û',
'&Ugrave;' => 'Ù',
'&ugrave;' => 'ù',
'&uml;' => '¨',
'&upsih;' => 'ϒ',
'&Upsilon;' => 'Υ',
'&upsilon;' => 'υ',
'&Uuml;' => 'Ü',
'&uuml;' => 'ü',
'&weierp;' => '℘',
'&Xi;' => 'Ξ',
'&xi;' => 'ξ',
'&Yacute;' => 'Ý',
'&yacute;' => 'ý',
'&yen;' => '¥',
'&yuml;' => 'ÿ',
'&Yuml;' => 'Ÿ',
'&Zeta;' => 'Ζ',
'&zeta;' => 'ζ',
'&zwj;' => '',
'&zwnj;' => '',
'&gt;' => '>',
'&lt;' => '<',
'&quot;' => '"',
// Add apostrophe (XML).
'&apos;' => "'",
);
+676
View File
@@ -0,0 +1,676 @@
<?php
/**
* @file
* Provides Unicode-related conversions and operations.
*/
/**
* Indicates an error during check for PHP unicode support.
*/
define('UNICODE_ERROR', -1);
/**
* Indicates that standard PHP (emulated) unicode support is being used.
*/
define('UNICODE_SINGLEBYTE', 0);
/**
* Indicates that full unicode support with the PHP mbstring extension is being
* used.
*/
define('UNICODE_MULTIBYTE', 1);
/**
* Matches Unicode characters that are word boundaries.
*
* Characters with the following General_category (gc) property values are used
* as word boundaries. While this does not fully conform to the Word Boundaries
* algorithm described in http://unicode.org/reports/tr29, as PCRE does not
* contain the Word_Break property table, this simpler algorithm has to do.
* - Cc, Cf, Cn, Co, Cs: Other.
* - Pc, Pd, Pe, Pf, Pi, Po, Ps: Punctuation.
* - Sc, Sk, Sm, So: Symbols.
* - Zl, Zp, Zs: Separators.
*
* Non-boundary characters include the following General_category (gc) property
* values:
* - Ll, Lm, Lo, Lt, Lu: Letters.
* - Mc, Me, Mn: Combining Marks.
* - Nd, Nl, No: Numbers.
*
* Note that the PCRE property matcher is not used because we wanted to be
* compatible with Unicode 5.2.0 regardless of the PCRE version used (and any
* bugs in PCRE property tables).
*
* @see http://unicode.org/glossary
*/
define('PREG_CLASS_UNICODE_WORD_BOUNDARY',
'\x{0}-\x{2F}\x{3A}-\x{40}\x{5B}-\x{60}\x{7B}-\x{A9}\x{AB}-\x{B1}\x{B4}' .
'\x{B6}-\x{B8}\x{BB}\x{BF}\x{D7}\x{F7}\x{2C2}-\x{2C5}\x{2D2}-\x{2DF}' .
'\x{2E5}-\x{2EB}\x{2ED}\x{2EF}-\x{2FF}\x{375}\x{37E}-\x{385}\x{387}\x{3F6}' .
'\x{482}\x{55A}-\x{55F}\x{589}-\x{58A}\x{5BE}\x{5C0}\x{5C3}\x{5C6}' .
'\x{5F3}-\x{60F}\x{61B}-\x{61F}\x{66A}-\x{66D}\x{6D4}\x{6DD}\x{6E9}' .
'\x{6FD}-\x{6FE}\x{700}-\x{70F}\x{7F6}-\x{7F9}\x{830}-\x{83E}' .
'\x{964}-\x{965}\x{970}\x{9F2}-\x{9F3}\x{9FA}-\x{9FB}\x{AF1}\x{B70}' .
'\x{BF3}-\x{BFA}\x{C7F}\x{CF1}-\x{CF2}\x{D79}\x{DF4}\x{E3F}\x{E4F}' .
'\x{E5A}-\x{E5B}\x{F01}-\x{F17}\x{F1A}-\x{F1F}\x{F34}\x{F36}\x{F38}' .
'\x{F3A}-\x{F3D}\x{F85}\x{FBE}-\x{FC5}\x{FC7}-\x{FD8}\x{104A}-\x{104F}' .
'\x{109E}-\x{109F}\x{10FB}\x{1360}-\x{1368}\x{1390}-\x{1399}\x{1400}' .
'\x{166D}-\x{166E}\x{1680}\x{169B}-\x{169C}\x{16EB}-\x{16ED}' .
'\x{1735}-\x{1736}\x{17B4}-\x{17B5}\x{17D4}-\x{17D6}\x{17D8}-\x{17DB}' .
'\x{1800}-\x{180A}\x{180E}\x{1940}-\x{1945}\x{19DE}-\x{19FF}' .
'\x{1A1E}-\x{1A1F}\x{1AA0}-\x{1AA6}\x{1AA8}-\x{1AAD}\x{1B5A}-\x{1B6A}' .
'\x{1B74}-\x{1B7C}\x{1C3B}-\x{1C3F}\x{1C7E}-\x{1C7F}\x{1CD3}\x{1FBD}' .
'\x{1FBF}-\x{1FC1}\x{1FCD}-\x{1FCF}\x{1FDD}-\x{1FDF}\x{1FED}-\x{1FEF}' .
'\x{1FFD}-\x{206F}\x{207A}-\x{207E}\x{208A}-\x{208E}\x{20A0}-\x{20B8}' .
'\x{2100}-\x{2101}\x{2103}-\x{2106}\x{2108}-\x{2109}\x{2114}' .
'\x{2116}-\x{2118}\x{211E}-\x{2123}\x{2125}\x{2127}\x{2129}\x{212E}' .
'\x{213A}-\x{213B}\x{2140}-\x{2144}\x{214A}-\x{214D}\x{214F}' .
'\x{2190}-\x{244A}\x{249C}-\x{24E9}\x{2500}-\x{2775}\x{2794}-\x{2B59}' .
'\x{2CE5}-\x{2CEA}\x{2CF9}-\x{2CFC}\x{2CFE}-\x{2CFF}\x{2E00}-\x{2E2E}' .
'\x{2E30}-\x{3004}\x{3008}-\x{3020}\x{3030}\x{3036}-\x{3037}' .
'\x{303D}-\x{303F}\x{309B}-\x{309C}\x{30A0}\x{30FB}\x{3190}-\x{3191}' .
'\x{3196}-\x{319F}\x{31C0}-\x{31E3}\x{3200}-\x{321E}\x{322A}-\x{3250}' .
'\x{3260}-\x{327F}\x{328A}-\x{32B0}\x{32C0}-\x{33FF}\x{4DC0}-\x{4DFF}' .
'\x{A490}-\x{A4C6}\x{A4FE}-\x{A4FF}\x{A60D}-\x{A60F}\x{A673}\x{A67E}' .
'\x{A6F2}-\x{A716}\x{A720}-\x{A721}\x{A789}-\x{A78A}\x{A828}-\x{A82B}' .
'\x{A836}-\x{A839}\x{A874}-\x{A877}\x{A8CE}-\x{A8CF}\x{A8F8}-\x{A8FA}' .
'\x{A92E}-\x{A92F}\x{A95F}\x{A9C1}-\x{A9CD}\x{A9DE}-\x{A9DF}' .
'\x{AA5C}-\x{AA5F}\x{AA77}-\x{AA79}\x{AADE}-\x{AADF}\x{ABEB}' .
'\x{E000}-\x{F8FF}\x{FB29}\x{FD3E}-\x{FD3F}\x{FDFC}-\x{FDFD}' .
'\x{FE10}-\x{FE19}\x{FE30}-\x{FE6B}\x{FEFF}-\x{FF0F}\x{FF1A}-\x{FF20}' .
'\x{FF3B}-\x{FF40}\x{FF5B}-\x{FF65}\x{FFE0}-\x{FFFD}');
/**
* Wrapper around _unicode_check().
*/
function unicode_check() {
list($GLOBALS['multibyte']) = _unicode_check();
}
/**
* Perform checks about Unicode support in PHP, and set the right settings if
* needed.
*
* Because Drupal needs to be able to handle text in various encodings, we do
* not support mbstring function overloading. HTTP input/output conversion must
* be disabled for similar reasons.
*
* @param $errors
* Whether to report any fatal errors with form_set_error().
*/
function _unicode_check() {
// Ensure translations don't break during installation.
$t = get_t();
// Check for mbstring extension
if (!function_exists('mb_strlen')) {
return array(UNICODE_SINGLEBYTE, $t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="@url">PHP mbstring extension</a> for improved Unicode support.', array('@url' => 'http://www.php.net/mbstring')));
}
// Check mbstring configuration
if (ini_get('mbstring.func_overload') != 0) {
return array(UNICODE_ERROR, $t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
}
if (ini_get('mbstring.encoding_translation') != 0) {
return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
}
// mbstring.http_input and mbstring.http_output are deprecated and empty by
// default in PHP 5.6.
if (version_compare(PHP_VERSION, '5.6.0') == -1) {
if (ini_get('mbstring.http_input') != 'pass') {
return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
}
if (ini_get('mbstring.http_output') != 'pass') {
return array(UNICODE_ERROR, $t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
}
}
// Set appropriate configuration
mb_internal_encoding('utf-8');
mb_language('uni');
return array(UNICODE_MULTIBYTE, '');
}
/**
* Returns Unicode library status and errors.
*/
function unicode_requirements() {
// Ensure translations don't break during installation.
$t = get_t();
$libraries = array(
UNICODE_SINGLEBYTE => $t('Standard PHP'),
UNICODE_MULTIBYTE => $t('PHP Mbstring Extension'),
UNICODE_ERROR => $t('Error'),
);
$severities = array(
UNICODE_SINGLEBYTE => REQUIREMENT_WARNING,
UNICODE_MULTIBYTE => REQUIREMENT_OK,
UNICODE_ERROR => REQUIREMENT_ERROR,
);
list($library, $description) = _unicode_check();
$requirements['unicode'] = array(
'title' => $t('Unicode library'),
'value' => $libraries[$library],
);
if ($description) {
$requirements['unicode']['description'] = $description;
}
$requirements['unicode']['severity'] = $severities[$library];
return $requirements;
}
/**
* Prepares a new XML parser.
*
* This is a wrapper around xml_parser_create() which extracts the encoding
* from the XML data first and sets the output encoding to UTF-8. This function
* should be used instead of xml_parser_create(), because PHP 4's XML parser
* doesn't check the input encoding itself. "Starting from PHP 5, the input
* encoding is automatically detected, so that the encoding parameter specifies
* only the output encoding."
*
* This is also where unsupported encodings will be converted. Callers should
* take this into account: $data might have been changed after the call.
*
* @param $data
* The XML data which will be parsed later.
*
* @return
* An XML parser object or FALSE on error.
*
* @ingroup php_wrappers
*/
function drupal_xml_parser_create(&$data) {
// Default XML encoding is UTF-8
$encoding = 'utf-8';
$bom = FALSE;
// Check for UTF-8 byte order mark (PHP5's XML parser doesn't handle it).
if (!strncmp($data, "\xEF\xBB\xBF", 3)) {
$bom = TRUE;
$data = substr($data, 3);
}
// Check for an encoding declaration in the XML prolog if no BOM was found.
if (!$bom && preg_match('/^<\?xml[^>]+encoding="(.+?)"/', $data, $match)) {
$encoding = $match[1];
}
// Unsupported encodings are converted here into UTF-8.
$php_supported = array('utf-8', 'iso-8859-1', 'us-ascii');
if (!in_array(strtolower($encoding), $php_supported)) {
$out = drupal_convert_to_utf8($data, $encoding);
if ($out !== FALSE) {
$encoding = 'utf-8';
$data = preg_replace('/^(<\?xml[^>]+encoding)="(.+?)"/', '\\1="utf-8"', $out);
}
else {
watchdog('php', 'Could not convert XML encoding %s to UTF-8.', array('%s' => $encoding), WATCHDOG_WARNING);
return FALSE;
}
}
$xml_parser = xml_parser_create($encoding);
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'utf-8');
return $xml_parser;
}
/**
* Converts data to UTF-8.
*
* Requires the iconv, GNU recode or mbstring PHP extension.
*
* @param $data
* The data to be converted.
* @param $encoding
* The encoding that the data is in.
*
* @return
* Converted data or FALSE.
*/
function drupal_convert_to_utf8($data, $encoding) {
if (function_exists('iconv')) {
$out = @iconv($encoding, 'utf-8', $data);
}
elseif (function_exists('mb_convert_encoding')) {
$out = @mb_convert_encoding($data, 'utf-8', $encoding);
}
elseif (function_exists('recode_string')) {
$out = @recode_string($encoding . '..utf-8', $data);
}
else {
watchdog('php', 'Unsupported encoding %s. Please install iconv, GNU recode or mbstring for PHP.', array('%s' => $encoding), WATCHDOG_ERROR);
return FALSE;
}
return $out;
}
/**
* Truncates a UTF-8-encoded string safely to a number of bytes.
*
* If the end position is in the middle of a UTF-8 sequence, it scans backwards
* until the beginning of the byte sequence.
*
* Use this function whenever you want to chop off a string at an unsure
* location. On the other hand, if you're sure that you're splitting on a
* character boundary (e.g. after using strpos() or similar), you can safely
* use substr() instead.
*
* @param $string
* The string to truncate.
* @param $len
* An upper limit on the returned string length.
*
* @return
* The truncated string.
*/
function drupal_truncate_bytes($string, $len) {
if (strlen($string) <= $len) {
return $string;
}
if ((ord($string[$len]) < 0x80) || (ord($string[$len]) >= 0xC0)) {
return substr($string, 0, $len);
}
// Scan backwards to beginning of the byte sequence.
while (--$len >= 0 && ord($string[$len]) >= 0x80 && ord($string[$len]) < 0xC0);
return substr($string, 0, $len);
}
/**
* Truncates a UTF-8-encoded string safely to a number of characters.
*
* @param $string
* The string to truncate.
* @param $max_length
* An upper limit on the returned string length, including trailing ellipsis
* if $add_ellipsis is TRUE.
* @param $wordsafe
* If TRUE, attempt to truncate on a word boundary. Word boundaries are
* spaces, punctuation, and Unicode characters used as word boundaries in
* non-Latin languages; see PREG_CLASS_UNICODE_WORD_BOUNDARY for more
* information. If a word boundary cannot be found that would make the length
* of the returned string fall within length guidelines (see parameters
* $max_length and $min_wordsafe_length), word boundaries are ignored.
* @param $add_ellipsis
* If TRUE, add t('...') to the end of the truncated string (defaults to
* FALSE). The string length will still fall within $max_length.
* @param $min_wordsafe_length
* If $wordsafe is TRUE, the minimum acceptable length for truncation (before
* adding an ellipsis, if $add_ellipsis is TRUE). Has no effect if $wordsafe
* is FALSE. This can be used to prevent having a very short resulting string
* that will not be understandable. For instance, if you are truncating the
* string "See myverylongurlexample.com for more information" to a word-safe
* return length of 20, the only available word boundary within 20 characters
* is after the word "See", which wouldn't leave a very informative string. If
* you had set $min_wordsafe_length to 10, though, the function would realise
* that "See" alone is too short, and would then just truncate ignoring word
* boundaries, giving you "See myverylongurl..." (assuming you had set
* $add_ellipses to TRUE).
*
* @return string
* The truncated string.
*/
function truncate_utf8($string, $max_length, $wordsafe = FALSE, $add_ellipsis = FALSE, $min_wordsafe_length = 1) {
$ellipsis = '';
$max_length = max($max_length, 0);
$min_wordsafe_length = max($min_wordsafe_length, 0);
if (drupal_strlen($string) <= $max_length) {
// No truncation needed, so don't add ellipsis, just return.
return $string;
}
if ($add_ellipsis) {
// Truncate ellipsis in case $max_length is small.
$ellipsis = drupal_substr(t('...'), 0, $max_length);
$max_length -= drupal_strlen($ellipsis);
$max_length = max($max_length, 0);
}
if ($max_length <= $min_wordsafe_length) {
// Do not attempt word-safe if lengths are bad.
$wordsafe = FALSE;
}
if ($wordsafe) {
$matches = array();
// Find the last word boundary, if there is one within $min_wordsafe_length
// to $max_length characters. preg_match() is always greedy, so it will
// find the longest string possible.
$found = preg_match('/^(.{' . $min_wordsafe_length . ',' . $max_length . '})[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . ']/u', $string, $matches);
if ($found) {
$string = $matches[1];
}
else {
$string = drupal_substr($string, 0, $max_length);
}
}
else {
$string = drupal_substr($string, 0, $max_length);
}
if ($add_ellipsis) {
$string .= $ellipsis;
}
return $string;
}
/**
* Encodes MIME/HTTP header values that contain incorrectly encoded characters.
*
* For example, mime_header_encode('tést.txt') returns "=?UTF-8?B?dMOpc3QudHh0?=".
*
* See http://www.rfc-editor.org/rfc/rfc2047.txt for more information.
*
* Notes:
* - Only encode strings that contain non-ASCII characters.
* - We progressively cut-off a chunk with truncate_utf8(). This is to ensure
* each chunk starts and ends on a character boundary.
* - Using \n as the chunk separator may cause problems on some systems and may
* have to be changed to \r\n or \r.
*
* @param $string
* The header to encode.
*
* @return string
* The mime-encoded header.
*
* @see mime_header_decode()
*/
function mime_header_encode($string) {
if (preg_match('/[^\x20-\x7E]/', $string)) {
$chunk_size = 47; // floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
$len = strlen($string);
$output = '';
while ($len > 0) {
$chunk = drupal_truncate_bytes($string, $chunk_size);
$output .= ' =?UTF-8?B?' . base64_encode($chunk) . "?=\n";
$c = strlen($chunk);
$string = substr($string, $c);
$len -= $c;
}
return trim($output);
}
return $string;
}
/**
* Decodes MIME/HTTP encoded header values.
*
* @param $header
* The header to decode.
*
* @return string
* The mime-decoded header.
*
* @see mime_header_encode()
*/
function mime_header_decode($header) {
// First step: encoded chunks followed by other encoded chunks (need to collapse whitespace)
$header = preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=\s+(?==\?)/', '_mime_header_decode', $header);
// Second step: remaining chunks (do not collapse whitespace)
return preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=/', '_mime_header_decode', $header);
}
/**
* Decodes encoded header data passed from mime_header_decode().
*
* Callback for preg_replace_callback() within mime_header_decode().
*
* @param $matches
* The array of matches from preg_replace_callback().
*
* @return string
* The mime-decoded string.
*
* @see mime_header_decode()
*/
function _mime_header_decode($matches) {
// Regexp groups:
// 1: Character set name
// 2: Escaping method (Q or B)
// 3: Encoded data
$data = ($matches[2] == 'B') ? base64_decode($matches[3]) : str_replace('_', ' ', quoted_printable_decode($matches[3]));
if (strtolower($matches[1]) != 'utf-8') {
$data = drupal_convert_to_utf8($data, $matches[1]);
}
return $data;
}
/**
* Decodes all HTML entities (including numerical ones) to regular UTF-8 bytes.
*
* Double-escaped entities will only be decoded once ("&amp;lt;" becomes "&lt;"
* , not "<"). Be careful when using this function, as decode_entities can
* revert previous sanitization efforts (&lt;script&gt; will become <script>).
*
* @param $text
* The text to decode entities in.
*
* @return
* The input $text, with all HTML entities decoded once.
*/
function decode_entities($text) {
return html_entity_decode($text, ENT_QUOTES, 'UTF-8');
}
/**
* Counts the number of characters in a UTF-8 string.
*
* This is less than or equal to the byte count.
*
* @param $text
* The string to run the operation on.
*
* @return integer
* The length of the string.
*
* @ingroup php_wrappers
*/
function drupal_strlen($text) {
global $multibyte;
if ($multibyte == UNICODE_MULTIBYTE) {
return mb_strlen($text);
}
else {
// Do not count UTF-8 continuation bytes.
return strlen(preg_replace("/[\x80-\xBF]/", '', $text));
}
}
/**
* Uppercase a UTF-8 string.
*
* @param $text
* The string to run the operation on.
*
* @return string
* The string in uppercase.
*
* @ingroup php_wrappers
*/
function drupal_strtoupper($text) {
global $multibyte;
if ($multibyte == UNICODE_MULTIBYTE) {
return mb_strtoupper($text);
}
else {
// Use C-locale for ASCII-only uppercase
$text = strtoupper($text);
// Case flip Latin-1 accented letters
$text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', '_unicode_caseflip', $text);
return $text;
}
}
/**
* Lowercase a UTF-8 string.
*
* @param $text
* The string to run the operation on.
*
* @return string
* The string in lowercase.
*
* @ingroup php_wrappers
*/
function drupal_strtolower($text) {
global $multibyte;
if ($multibyte == UNICODE_MULTIBYTE) {
return mb_strtolower($text);
}
else {
// Use C-locale for ASCII-only lowercase
$text = strtolower($text);
// Case flip Latin-1 accented letters
$text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', '_unicode_caseflip', $text);
return $text;
}
}
/**
* Flips U+C0-U+DE to U+E0-U+FD and back.
*
* @param $matches
* An array of matches.
*
* @return array
* The Latin-1 version of the array of matches.
*
* @see drupal_strtolower()
*/
function _unicode_caseflip($matches) {
return $matches[0][0] . chr(ord($matches[0][1]) ^ 32);
}
/**
* Capitalizes the first letter of a UTF-8 string.
*
* @param $text
* The string to convert.
*
* @return
* The string with the first letter as uppercase.
*
* @ingroup php_wrappers
*/
function drupal_ucfirst($text) {
// Note: no mbstring equivalent!
return drupal_strtoupper(drupal_substr($text, 0, 1)) . drupal_substr($text, 1);
}
/**
* Cuts off a piece of a string based on character indices and counts.
*
* Follows the same behavior as PHP's own substr() function. Note that for
* cutting off a string at a known character/substring location, the usage of
* PHP's normal strpos/substr is safe and much faster.
*
* @param $text
* The input string.
* @param $start
* The position at which to start reading.
* @param $length
* The number of characters to read.
*
* @return
* The shortened string.
*
* @ingroup php_wrappers
*/
function drupal_substr($text, $start, $length = NULL) {
global $multibyte;
if ($multibyte == UNICODE_MULTIBYTE) {
return $length === NULL ? mb_substr($text, $start) : mb_substr($text, $start, $length);
}
else {
$strlen = strlen($text);
// Find the starting byte offset.
$bytes = 0;
if ($start > 0) {
// Count all the continuation bytes from the start until we have found
// $start characters or the end of the string.
$bytes = -1; $chars = -1;
while ($bytes < $strlen - 1 && $chars < $start) {
$bytes++;
$c = ord($text[$bytes]);
if ($c < 0x80 || $c >= 0xC0) {
$chars++;
}
}
}
elseif ($start < 0) {
// Count all the continuation bytes from the end until we have found
// abs($start) characters.
$start = abs($start);
$bytes = $strlen; $chars = 0;
while ($bytes > 0 && $chars < $start) {
$bytes--;
$c = ord($text[$bytes]);
if ($c < 0x80 || $c >= 0xC0) {
$chars++;
}
}
}
$istart = $bytes;
// Find the ending byte offset.
if ($length === NULL) {
$iend = $strlen;
}
elseif ($length > 0) {
// Count all the continuation bytes from the starting index until we have
// found $length characters or reached the end of the string, then
// backtrace one byte.
$iend = $istart - 1;
$chars = -1;
$last_real = FALSE;
while ($iend < $strlen - 1 && $chars < $length) {
$iend++;
$c = ord($text[$iend]);
$last_real = FALSE;
if ($c < 0x80 || $c >= 0xC0) {
$chars++;
$last_real = TRUE;
}
}
// Backtrace one byte if the last character we found was a real character
// and we don't need it.
if ($last_real && $chars >= $length) {
$iend--;
}
}
elseif ($length < 0) {
// Count all the continuation bytes from the end until we have found
// abs($start) characters, then backtrace one byte.
$length = abs($length);
$iend = $strlen; $chars = 0;
while ($iend > 0 && $chars < $length) {
$iend--;
$c = ord($text[$iend]);
if ($c < 0x80 || $c >= 0xC0) {
$chars++;
}
}
// Backtrace one byte if we are not at the beginning of the string.
if ($iend > 0) {
$iend--;
}
}
else {
// $length == 0, return an empty string.
return '';
}
return substr($text, $istart, max(0, $iend - $istart + 1));
}
}
+1489
View File
File diff suppressed because it is too large Load Diff
+427
View File
@@ -0,0 +1,427 @@
<?php
/**
* @file
* Classes used for updating various files in the Drupal webroot. These
* classes use a FileTransfer object to actually perform the operations.
* Normally, the FileTransfer is provided when the site owner is redirected to
* authorize.php as part of a multistep process.
*/
/**
* Interface for a class which can update a Drupal project.
*
* An Updater currently serves the following purposes:
* - It can take a given directory, and determine if it can operate on it.
* - It can move the contents of that directory into the appropriate place
* on the system using FileTransfer classes.
* - It can return a list of "next steps" after an update or install.
* - In the future, it will most likely perform some of those steps as well.
*/
interface DrupalUpdaterInterface {
/**
* Checks if the project is installed.
*
* @return bool
*/
public function isInstalled();
/**
* Returns the system name of the project.
*
* @param string $directory
* A directory containing a project.
*/
public static function getProjectName($directory);
/**
* @return string
* An absolute path to the default install location.
*/
public function getInstallDirectory();
/**
* Determine if the Updater can handle the project provided in $directory.
*
* @todo: Provide something more rational here, like a project spec file.
*
* @param string $directory
*
* @return bool
* TRUE if the project is installed, FALSE if not.
*/
public static function canUpdateDirectory($directory);
/**
* Actions to run after an install has occurred.
*/
public function postInstall();
/**
* Actions to run after an update has occurred.
*/
public function postUpdate();
}
/**
* Base class for Updaters used in Drupal.
*/
class Updater {
/**
* @var string $source Directory to install from.
*/
public $source;
public function __construct($source) {
$this->source = $source;
$this->name = self::getProjectName($source);
$this->title = self::getProjectTitle($source);
}
/**
* Return an Updater of the appropriate type depending on the source.
*
* If a directory is provided which contains a module, will return a
* ModuleUpdater.
*
* @param string $source
* Directory of a Drupal project.
*
* @return Updater
*/
public static function factory($source) {
if (is_dir($source)) {
$updater = self::getUpdaterFromDirectory($source);
}
else {
throw new UpdaterException(t('Unable to determine the type of the source directory.'));
}
return new $updater($source);
}
/**
* Determine which Updater class can operate on the given directory.
*
* @param string $directory
* Extracted Drupal project.
*
* @return string
* The class name which can work with this project type.
*/
public static function getUpdaterFromDirectory($directory) {
// Gets a list of possible implementing classes.
$updaters = drupal_get_updaters();
foreach ($updaters as $updater) {
$class = $updater['class'];
if (call_user_func(array($class, 'canUpdateDirectory'), $directory)) {
return $class;
}
}
throw new UpdaterException(t('Cannot determine the type of project.'));
}
/**
* Figure out what the most important (or only) info file is in a directory.
*
* Since there is no enforcement of which info file is the project's "main"
* info file, this will get one with the same name as the directory, or the
* first one it finds. Not ideal, but needs a larger solution.
*
* @param string $directory
* Directory to search in.
*
* @return string
* Path to the info file.
*/
public static function findInfoFile($directory) {
$info_files = file_scan_directory($directory, '/.*\.info$/');
if (!$info_files) {
return FALSE;
}
foreach ($info_files as $info_file) {
if (drupal_substr($info_file->filename, 0, -5) == drupal_basename($directory)) {
// Info file Has the same name as the directory, return it.
return $info_file->uri;
}
}
// Otherwise, return the first one.
$info_file = array_shift($info_files);
return $info_file->uri;
}
/**
* Get the name of the project directory (basename).
*
* @todo: It would be nice, if projects contained an info file which could
* provide their canonical name.
*
* @param string $directory
*
* @return string
* The name of the project.
*/
public static function getProjectName($directory) {
return drupal_basename($directory);
}
/**
* Return the project name from a Drupal info file.
*
* @param string $directory
* Directory to search for the info file.
*
* @return string
* The title of the project.
*/
public static function getProjectTitle($directory) {
$info_file = self::findInfoFile($directory);
$info = drupal_parse_info_file($info_file);
if (empty($info)) {
throw new UpdaterException(t('Unable to parse info file: %info_file.', array('%info_file' => $info_file)));
}
if (empty($info['name'])) {
throw new UpdaterException(t("The info file (%info_file) does not define a 'name' attribute.", array('%info_file' => $info_file)));
}
return $info['name'];
}
/**
* Store the default parameters for the Updater.
*
* @param array $overrides
* An array of overrides for the default parameters.
*
* @return array
* An array of configuration parameters for an update or install operation.
*/
protected function getInstallArgs($overrides = array()) {
$args = array(
'make_backup' => FALSE,
'install_dir' => $this->getInstallDirectory(),
'backup_dir' => $this->getBackupDir(),
);
return array_merge($args, $overrides);
}
/**
* Updates a Drupal project, returns a list of next actions.
*
* @param FileTransfer $filetransfer
* Object that is a child of FileTransfer. Used for moving files
* to the server.
* @param array $overrides
* An array of settings to override defaults; see self::getInstallArgs().
*
* @return array
* An array of links which the user may need to complete the update
*/
public function update(&$filetransfer, $overrides = array()) {
try {
// Establish arguments with possible overrides.
$args = $this->getInstallArgs($overrides);
// Take a Backup.
if ($args['make_backup']) {
$this->makeBackup($args['install_dir'], $args['backup_dir']);
}
if (!$this->name) {
// This is bad, don't want to delete the install directory.
throw new UpdaterException(t('Fatal error in update, cowardly refusing to wipe out the install directory.'));
}
// Make sure the installation parent directory exists and is writable.
$this->prepareInstallDirectory($filetransfer, $args['install_dir']);
// Note: If the project is installed in sites/all, it will not be
// deleted. It will be installed in sites/default as that will override
// the sites/all reference and not break other sites which are using it.
if (is_dir($args['install_dir'] . '/' . $this->name)) {
// Remove the existing installed file.
$filetransfer->removeDirectory($args['install_dir'] . '/' . $this->name);
}
// Copy the directory in place.
$filetransfer->copyDirectory($this->source, $args['install_dir']);
// Make sure what we just installed is readable by the web server.
$this->makeWorldReadable($filetransfer, $args['install_dir'] . '/' . $this->name);
// Run the updates.
// @TODO: decide if we want to implement this.
$this->postUpdate();
// For now, just return a list of links of things to do.
return $this->postUpdateTasks();
}
catch (FileTransferException $e) {
throw new UpdaterFileTransferException(t('File Transfer failed, reason: !reason', array('!reason' => strtr($e->getMessage(), $e->arguments))));
}
}
/**
* Installs a Drupal project, returns a list of next actions.
*
* @param FileTransfer $filetransfer
* Object that is a child of FileTransfer.
* @param array $overrides
* An array of settings to override defaults; see self::getInstallArgs().
*
* @return array
* An array of links which the user may need to complete the install.
*/
public function install(&$filetransfer, $overrides = array()) {
try {
// Establish arguments with possible overrides.
$args = $this->getInstallArgs($overrides);
// Make sure the installation parent directory exists and is writable.
$this->prepareInstallDirectory($filetransfer, $args['install_dir']);
// Copy the directory in place.
$filetransfer->copyDirectory($this->source, $args['install_dir']);
// Make sure what we just installed is readable by the web server.
$this->makeWorldReadable($filetransfer, $args['install_dir'] . '/' . $this->name);
// Potentially enable something?
// @TODO: decide if we want to implement this.
$this->postInstall();
// For now, just return a list of links of things to do.
return $this->postInstallTasks();
}
catch (FileTransferException $e) {
throw new UpdaterFileTransferException(t('File Transfer failed, reason: !reason', array('!reason' => strtr($e->getMessage(), $e->arguments))));
}
}
/**
* Make sure the installation parent directory exists and is writable.
*
* @param FileTransfer $filetransfer
* Object which is a child of FileTransfer.
* @param string $directory
* The installation directory to prepare.
*/
public function prepareInstallDirectory(&$filetransfer, $directory) {
// Make the parent dir writable if need be and create the dir.
if (!is_dir($directory)) {
$parent_dir = dirname($directory);
if (!is_writable($parent_dir)) {
@chmod($parent_dir, 0755);
// It is expected that this will fail if the directory is owned by the
// FTP user. If the FTP user == web server, it will succeed.
try {
$filetransfer->createDirectory($directory);
$this->makeWorldReadable($filetransfer, $directory);
}
catch (FileTransferException $e) {
// Probably still not writable. Try to chmod and do it again.
// @todo: Make a new exception class so we can catch it differently.
try {
$old_perms = substr(sprintf('%o', fileperms($parent_dir)), -4);
$filetransfer->chmod($parent_dir, 0755);
$filetransfer->createDirectory($directory);
$this->makeWorldReadable($filetransfer, $directory);
// Put the permissions back.
$filetransfer->chmod($parent_dir, intval($old_perms, 8));
}
catch (FileTransferException $e) {
$message = t($e->getMessage(), $e->arguments);
$throw_message = t('Unable to create %directory due to the following: %reason', array('%directory' => $directory, '%reason' => $message));
throw new UpdaterException($throw_message);
}
}
// Put the parent directory back.
@chmod($parent_dir, 0555);
}
}
}
/**
* Ensure that a given directory is world readable.
*
* @param FileTransfer $filetransfer
* Object which is a child of FileTransfer.
* @param string $path
* The file path to make world readable.
* @param bool $recursive
* If the chmod should be applied recursively.
*/
public function makeWorldReadable(&$filetransfer, $path, $recursive = TRUE) {
if (!is_executable($path)) {
// Set it to read + execute.
$new_perms = substr(sprintf('%o', fileperms($path)), -4, -1) . "5";
$filetransfer->chmod($path, intval($new_perms, 8), $recursive);
}
}
/**
* Perform a backup.
*
* @todo Not implemented.
*/
public function makeBackup(&$filetransfer, $from, $to) {
}
/**
* Return the full path to a directory where backups should be written.
*/
public function getBackupDir() {
return file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath();
}
/**
* Perform actions after new code is updated.
*/
public function postUpdate() {
}
/**
* Perform actions after installation.
*/
public function postInstall() {
}
/**
* Return an array of links to pages that should be visited post operation.
*
* @return array
* Links which provide actions to take after the install is finished.
*/
public function postInstallTasks() {
return array();
}
/**
* Return an array of links to pages that should be visited post operation.
*
* @return array
* Links which provide actions to take after the update is finished.
*/
public function postUpdateTasks() {
return array();
}
}
/**
* Exception class for the Updater class hierarchy.
*
* This is identical to the base Exception class, we just give it a more
* specific name so that call sites that want to tell the difference can
* specifically catch these exceptions and treat them differently.
*/
class UpdaterException extends Exception {
}
/**
* Child class of UpdaterException that indicates a FileTransfer exception.
*
* We have to catch FileTransfer exceptions and wrap those in t(), since
* FileTransfer is so low-level that it doesn't use any Drupal APIs and none
* of the strings are translated.
*/
class UpdaterFileTransferException extends UpdaterException {
}
+66
View File
@@ -0,0 +1,66 @@
<?php
/**
* @file
* Miscellaneous functions.
*/
/**
* Drupal-friendly var_export().
*
* @param $var
* The variable to export.
* @param $prefix
* A prefix that will be added at the beginning of every lines of the output.
*
* @return
* The variable exported in a way compatible to Drupal's coding standards.
*/
function drupal_var_export($var, $prefix = '') {
if (is_array($var)) {
if (empty($var)) {
$output = 'array()';
}
else {
$output = "array(\n";
// Don't export keys if the array is non associative.
$export_keys = array_values($var) != $var;
foreach ($var as $key => $value) {
$output .= ' ' . ($export_keys ? drupal_var_export($key) . ' => ' : '') . drupal_var_export($value, ' ', FALSE) . ",\n";
}
$output .= ')';
}
}
elseif (is_bool($var)) {
$output = $var ? 'TRUE' : 'FALSE';
}
elseif (is_string($var)) {
$line_safe_var = str_replace("\n", '\n', $var);
if (strpos($var, "\n") !== FALSE || strpos($var, "'") !== FALSE) {
// If the string contains a line break or a single quote, use the
// double quote export mode. Encode backslash and double quotes and
// transform some common control characters.
$var = str_replace(array('\\', '"', "\n", "\r", "\t"), array('\\\\', '\"', '\n', '\r', '\t'), $var);
$output = '"' . $var . '"';
}
else {
$output = "'" . $var . "'";
}
}
elseif (is_object($var) && get_class($var) === 'stdClass') {
// var_export() will export stdClass objects using an undefined
// magic method __set_state() leaving the export broken. This
// workaround avoids this by casting the object as an array for
// export and casting it back to an object when evaluated.
$output = '(object) ' . drupal_var_export((array) $var, $prefix);
}
else {
$output = var_export($var, TRUE);
}
if ($prefix) {
$output = str_replace("\n", "\n$prefix", $output);
}
return $output;
}
+658
View File
@@ -0,0 +1,658 @@
<?php
/**
* @file
* Drupal XML-RPC library.
*
* Based on the IXR - The Incutio XML-RPC Library - (c) Incutio Ltd 2002-2005
* Version 1.7 (beta) - Simon Willison, 23rd May 2005
* Site: http://scripts.incutio.com/xmlrpc/
* Manual: http://scripts.incutio.com/xmlrpc/manual.php
* This version is made available under the GNU GPL License
*/
/**
* Turns a data structure into objects with 'data' and 'type' attributes.
*
* @param $data
* The data structure.
* @param $type
* Optional type to assign to $data.
*
* @return object
* An XML-RPC data object containing the input $data.
*/
function xmlrpc_value($data, $type = FALSE) {
$xmlrpc_value = new stdClass();
$xmlrpc_value->data = $data;
if (!$type) {
$type = xmlrpc_value_calculate_type($xmlrpc_value);
}
$xmlrpc_value->type = $type;
if ($type == 'struct') {
// Turn all the values in the array into new xmlrpc_values
foreach ($xmlrpc_value->data as $key => $value) {
$xmlrpc_value->data[$key] = xmlrpc_value($value);
}
}
if ($type == 'array') {
for ($i = 0, $j = count($xmlrpc_value->data); $i < $j; $i++) {
$xmlrpc_value->data[$i] = xmlrpc_value($xmlrpc_value->data[$i]);
}
}
return $xmlrpc_value;
}
/**
* Maps a PHP type to an XML-RPC type.
*
* @param $xmlrpc_value
* Variable whose type should be mapped.
*
* @return string
* The corresponding XML-RPC type.
*
* @see http://www.xmlrpc.com/spec#scalars
*/
function xmlrpc_value_calculate_type($xmlrpc_value) {
// http://www.php.net/gettype: Never use gettype() to test for a certain type
// [...] Instead, use the is_* functions.
if (is_bool($xmlrpc_value->data)) {
return 'boolean';
}
if (is_double($xmlrpc_value->data)) {
return 'double';
}
if (is_int($xmlrpc_value->data)) {
return 'int';
}
if (is_array($xmlrpc_value->data)) {
// empty or integer-indexed arrays are 'array', string-indexed arrays 'struct'
return empty($xmlrpc_value->data) || range(0, count($xmlrpc_value->data) - 1) === array_keys($xmlrpc_value->data) ? 'array' : 'struct';
}
if (is_object($xmlrpc_value->data)) {
if (isset($xmlrpc_value->data->is_date)) {
return 'date';
}
if (isset($xmlrpc_value->data->is_base64)) {
return 'base64';
}
$xmlrpc_value->data = get_object_vars($xmlrpc_value->data);
return 'struct';
}
// default
return 'string';
}
/**
* Generates XML representing the given value.
*
* @param $xmlrpc_value
* A value to be represented in XML.
*
* @return
* XML representation of $xmlrpc_value.
*/
function xmlrpc_value_get_xml($xmlrpc_value) {
switch ($xmlrpc_value->type) {
case 'boolean':
return '<boolean>' . (($xmlrpc_value->data) ? '1' : '0') . '</boolean>';
case 'int':
return '<int>' . $xmlrpc_value->data . '</int>';
case 'double':
return '<double>' . $xmlrpc_value->data . '</double>';
case 'string':
// Note: we don't escape apostrophes because of the many blogging clients
// that don't support numerical entities (and XML in general) properly.
return '<string>' . htmlspecialchars($xmlrpc_value->data) . '</string>';
case 'array':
$return = '<array><data>' . "\n";
foreach ($xmlrpc_value->data as $item) {
$return .= ' <value>' . xmlrpc_value_get_xml($item) . "</value>\n";
}
$return .= '</data></array>';
return $return;
case 'struct':
$return = '<struct>' . "\n";
foreach ($xmlrpc_value->data as $name => $value) {
$return .= " <member><name>" . check_plain($name) . "</name><value>";
$return .= xmlrpc_value_get_xml($value) . "</value></member>\n";
}
$return .= '</struct>';
return $return;
case 'date':
return xmlrpc_date_get_xml($xmlrpc_value->data);
case 'base64':
return xmlrpc_base64_get_xml($xmlrpc_value->data);
}
return FALSE;
}
/**
* Constructs an object representing an XML-RPC message.
*
* @param $message
* A string containing an XML message.
*
* @return object
* An XML-RPC object containing the message.
*
* @see http://www.xmlrpc.com/spec
*/
function xmlrpc_message($message) {
$xmlrpc_message = new stdClass();
// The stack used to keep track of the current array/struct
$xmlrpc_message->array_structs = array();
// The stack used to keep track of if things are structs or array
$xmlrpc_message->array_structs_types = array();
// A stack as well
$xmlrpc_message->current_struct_name = array();
$xmlrpc_message->message = $message;
return $xmlrpc_message;
}
/**
* Parses an XML-RPC message.
*
* If parsing fails, the faultCode and faultString will be added to the message
* object.
*
* @param $xmlrpc_message
* An object generated by xmlrpc_message().
*
* @return
* TRUE if parsing succeeded; FALSE otherwise.
*/
function xmlrpc_message_parse($xmlrpc_message) {
$xmlrpc_message->_parser = xml_parser_create();
// Set XML parser to take the case of tags into account.
xml_parser_set_option($xmlrpc_message->_parser, XML_OPTION_CASE_FOLDING, FALSE);
// Set XML parser callback functions
xml_set_element_handler($xmlrpc_message->_parser, 'xmlrpc_message_tag_open', 'xmlrpc_message_tag_close');
xml_set_character_data_handler($xmlrpc_message->_parser, 'xmlrpc_message_cdata');
xmlrpc_message_set($xmlrpc_message);
// Strip XML declaration.
$header = preg_replace('/<\?xml.*?\?'.'>/s', '', substr($xmlrpc_message->message, 0, 100), 1);
$xml = trim(substr_replace($xmlrpc_message->message, $header, 0, 100));
if ($xml == '') {
return FALSE;
}
// Strip DTD.
$header = preg_replace('/^<!DOCTYPE[^>]*+>/i', '', substr($xml, 0, 200), 1);
$xml = trim(substr_replace($xml, $header, 0, 200));
if ($xml == '') {
return FALSE;
}
// Confirm the XML now starts with a valid root tag. A root tag can end in [> \t\r\n]
$root_tag = substr($xml, 0, strcspn(substr($xml, 0, 20), "> \t\r\n"));
// Reject a second DTD.
if (strtoupper($root_tag) == '<!DOCTYPE') {
return FALSE;
}
if (!in_array($root_tag, array('<methodCall', '<methodResponse', '<fault'))) {
return FALSE;
}
// Skip parsing if there is an unreasonably large number of tags.
try {
$dom = new DOMDocument();
@$dom->loadXML($xml);
if ($dom->getElementsByTagName('*')->length > variable_get('xmlrpc_message_maximum_tag_count', 30000)) {
return FALSE;
}
}
catch (Exception $e) {
return FALSE;
}
if (!xml_parse($xmlrpc_message->_parser, $xml)) {
return FALSE;
}
xml_parser_free($xmlrpc_message->_parser);
// Grab the error messages, if any.
$xmlrpc_message = xmlrpc_message_get();
if (!isset($xmlrpc_message->messagetype)) {
return FALSE;
}
elseif ($xmlrpc_message->messagetype == 'fault') {
$xmlrpc_message->fault_code = $xmlrpc_message->params[0]['faultCode'];
$xmlrpc_message->fault_string = $xmlrpc_message->params[0]['faultString'];
}
return TRUE;
}
/**
* Stores a copy of the most recent XML-RPC message object temporarily.
*
* @param $value
* An XML-RPC message to store, or NULL to keep the last message.
*
* @return object
* The most recently stored message.
*
* @see xmlrpc_message_get()
*/
function xmlrpc_message_set($value = NULL) {
static $xmlrpc_message;
if ($value) {
$xmlrpc_message = $value;
}
return $xmlrpc_message;
}
/**
* Returns the most recently stored XML-RPC message object.
*
* @return object
* The most recently stored message.
*
* @see xmlrpc_message_set()
*/
function xmlrpc_message_get() {
return xmlrpc_message_set();
}
/**
* Handles opening tags for XML parsing in xmlrpc_message_parse().
*/
function xmlrpc_message_tag_open($parser, $tag, $attr) {
$xmlrpc_message = xmlrpc_message_get();
$xmlrpc_message->current_tag_contents = '';
$xmlrpc_message->last_open = $tag;
switch ($tag) {
case 'methodCall':
case 'methodResponse':
case 'fault':
$xmlrpc_message->messagetype = $tag;
break;
// Deal with stacks of arrays and structs
case 'data':
$xmlrpc_message->array_structs_types[] = 'array';
$xmlrpc_message->array_structs[] = array();
break;
case 'struct':
$xmlrpc_message->array_structs_types[] = 'struct';
$xmlrpc_message->array_structs[] = array();
break;
}
xmlrpc_message_set($xmlrpc_message);
}
/**
* Handles character data for XML parsing in xmlrpc_message_parse().
*/
function xmlrpc_message_cdata($parser, $cdata) {
$xmlrpc_message = xmlrpc_message_get();
$xmlrpc_message->current_tag_contents .= $cdata;
xmlrpc_message_set($xmlrpc_message);
}
/**
* Handles closing tags for XML parsing in xmlrpc_message_parse().
*/
function xmlrpc_message_tag_close($parser, $tag) {
$xmlrpc_message = xmlrpc_message_get();
$value_flag = FALSE;
switch ($tag) {
case 'int':
case 'i4':
$value = (int)trim($xmlrpc_message->current_tag_contents);
$value_flag = TRUE;
break;
case 'double':
$value = (double)trim($xmlrpc_message->current_tag_contents);
$value_flag = TRUE;
break;
case 'string':
$value = $xmlrpc_message->current_tag_contents;
$value_flag = TRUE;
break;
case 'dateTime.iso8601':
$value = xmlrpc_date(trim($xmlrpc_message->current_tag_contents));
// $value = $iso->getTimestamp();
$value_flag = TRUE;
break;
case 'value':
// If no type is indicated, the type is string
// We take special care for empty values
if (trim($xmlrpc_message->current_tag_contents) != '' || (isset($xmlrpc_message->last_open) && ($xmlrpc_message->last_open == 'value'))) {
$value = (string) $xmlrpc_message->current_tag_contents;
$value_flag = TRUE;
}
unset($xmlrpc_message->last_open);
break;
case 'boolean':
$value = (boolean)trim($xmlrpc_message->current_tag_contents);
$value_flag = TRUE;
break;
case 'base64':
$value = base64_decode(trim($xmlrpc_message->current_tag_contents));
$value_flag = TRUE;
break;
// Deal with stacks of arrays and structs
case 'data':
case 'struct':
$value = array_pop($xmlrpc_message->array_structs);
array_pop($xmlrpc_message->array_structs_types);
$value_flag = TRUE;
break;
case 'member':
array_pop($xmlrpc_message->current_struct_name);
break;
case 'name':
$xmlrpc_message->current_struct_name[] = trim($xmlrpc_message->current_tag_contents);
break;
case 'methodName':
$xmlrpc_message->methodname = trim($xmlrpc_message->current_tag_contents);
break;
}
if ($value_flag) {
if (count($xmlrpc_message->array_structs) > 0) {
// Add value to struct or array
if ($xmlrpc_message->array_structs_types[count($xmlrpc_message->array_structs_types) - 1] == 'struct') {
// Add to struct
$xmlrpc_message->array_structs[count($xmlrpc_message->array_structs) - 1][$xmlrpc_message->current_struct_name[count($xmlrpc_message->current_struct_name) - 1]] = $value;
}
else {
// Add to array
$xmlrpc_message->array_structs[count($xmlrpc_message->array_structs) - 1][] = $value;
}
}
else {
// Just add as a parameter
$xmlrpc_message->params[] = $value;
}
}
if (!in_array($tag, array("data", "struct", "member"))) {
$xmlrpc_message->current_tag_contents = '';
}
xmlrpc_message_set($xmlrpc_message);
}
/**
* Constructs an object representing an XML-RPC request.
*
* @param $method
* The name of the method to be called.
* @param $args
* An array of parameters to send with the method.
*
* @return object
* An XML-RPC object representing the request.
*/
function xmlrpc_request($method, $args) {
$xmlrpc_request = new stdClass();
$xmlrpc_request->method = $method;
$xmlrpc_request->args = $args;
$xmlrpc_request->xml = <<<EOD
<?xml version="1.0"?>
<methodCall>
<methodName>{$xmlrpc_request->method}</methodName>
<params>
EOD;
foreach ($xmlrpc_request->args as $arg) {
$xmlrpc_request->xml .= '<param><value>';
$v = xmlrpc_value($arg);
$xmlrpc_request->xml .= xmlrpc_value_get_xml($v);
$xmlrpc_request->xml .= "</value></param>\n";
}
$xmlrpc_request->xml .= '</params></methodCall>';
return $xmlrpc_request;
}
/**
* Generates, temporarily saves, and returns an XML-RPC error object.
*
* @param $code
* The error code.
* @param $message
* The error message.
* @param $reset
* TRUE to empty the temporary error storage. Ignored if $code is supplied.
*
* @return object
* An XML-RPC error object representing $code and $message, or the most
* recently stored error object if omitted.
*/
function xmlrpc_error($code = NULL, $message = NULL, $reset = FALSE) {
static $xmlrpc_error;
if (isset($code)) {
$xmlrpc_error = new stdClass();
$xmlrpc_error->is_error = TRUE;
$xmlrpc_error->code = $code;
$xmlrpc_error->message = $message;
}
elseif ($reset) {
$xmlrpc_error = NULL;
}
return $xmlrpc_error;
}
/**
* Converts an XML-RPC error object into XML.
*
* @param $xmlrpc_error
* The XML-RPC error object.
*
* @return string
* An XML representation of the error as an XML methodResponse.
*/
function xmlrpc_error_get_xml($xmlrpc_error) {
return <<<EOD
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>{$xmlrpc_error->code}</int></value>
</member>
<member>
<name>faultString</name>
<value><string>{$xmlrpc_error->message}</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>
EOD;
}
/**
* Converts a PHP or ISO date/time to an XML-RPC object.
*
* @param $time
* A PHP timestamp or an ISO date-time string.
*
* @return object
* An XML-RPC time/date object.
*/
function xmlrpc_date($time) {
$xmlrpc_date = new stdClass();
$xmlrpc_date->is_date = TRUE;
// $time can be a PHP timestamp or an ISO one
if (is_numeric($time)) {
$xmlrpc_date->year = gmdate('Y', $time);
$xmlrpc_date->month = gmdate('m', $time);
$xmlrpc_date->day = gmdate('d', $time);
$xmlrpc_date->hour = gmdate('H', $time);
$xmlrpc_date->minute = gmdate('i', $time);
$xmlrpc_date->second = gmdate('s', $time);
$xmlrpc_date->iso8601 = gmdate('Ymd\TH:i:s', $time);
}
else {
$xmlrpc_date->iso8601 = $time;
$time = str_replace(array('-', ':'), '', $time);
$xmlrpc_date->year = substr($time, 0, 4);
$xmlrpc_date->month = substr($time, 4, 2);
$xmlrpc_date->day = substr($time, 6, 2);
$xmlrpc_date->hour = substr($time, 9, 2);
$xmlrpc_date->minute = substr($time, 11, 2);
$xmlrpc_date->second = substr($time, 13, 2);
}
return $xmlrpc_date;
}
/**
* Converts an XML-RPC date-time object into XML.
*
* @param $xmlrpc_date
* The XML-RPC date-time object.
*
* @return string
* An XML representation of the date/time as XML.
*/
function xmlrpc_date_get_xml($xmlrpc_date) {
return '<dateTime.iso8601>' . $xmlrpc_date->year . $xmlrpc_date->month . $xmlrpc_date->day . 'T' . $xmlrpc_date->hour . ':' . $xmlrpc_date->minute . ':' . $xmlrpc_date->second . '</dateTime.iso8601>';
}
/**
* Returns an XML-RPC base 64 object.
*
* @param $data
* Base 64 data to store in returned object.
*
* @return object
* An XML-RPC base 64 object.
*/
function xmlrpc_base64($data) {
$xmlrpc_base64 = new stdClass();
$xmlrpc_base64->is_base64 = TRUE;
$xmlrpc_base64->data = $data;
return $xmlrpc_base64;
}
/**
* Converts an XML-RPC base 64 object into XML.
*
* @param $xmlrpc_base64
* The XML-RPC base 64 object.
*
* @return string
* An XML representation of the base 64 data as XML.
*/
function xmlrpc_base64_get_xml($xmlrpc_base64) {
return '<base64>' . base64_encode($xmlrpc_base64->data) . '</base64>';
}
/**
* Performs one or more XML-RPC requests.
*
* @param $url
* An absolute URL of the XML-RPC endpoint, e.g.,
* http://example.com/xmlrpc.php
* @param $args
* An associative array whose keys are the methods to call and whose values
* are the arguments to pass to the respective method. If multiple methods
* are specified, a system.multicall is performed.
* @param $options
* (optional) An array of options to pass along to drupal_http_request().
*
* @return
* A single response (single request) or an array of responses (multicall
* request). Each response is the return value of the method, just as if it
* has been a local function call, on success, or FALSE on failure. If FALSE
* is returned, see xmlrpc_errno() and xmlrpc_error_msg() to get more
* information.
*/
function _xmlrpc($url, $args, $options = array()) {
xmlrpc_clear_error();
if (count($args) > 1) {
$multicall_args = array();
foreach ($args as $method => $call) {
$multicall_args[] = array('methodName' => $method, 'params' => $call);
}
$method = 'system.multicall';
$args = array($multicall_args);
}
else {
$method = key($args);
$args = $args[$method];
}
$xmlrpc_request = xmlrpc_request($method, $args);
// Required options which will replace any that are passed in.
$options['method'] = 'POST';
$options['headers']['Content-Type'] = 'text/xml';
$options['data'] = $xmlrpc_request->xml;
$result = drupal_http_request($url, $options);
if ($result->code != 200) {
xmlrpc_error($result->code, $result->error);
return FALSE;
}
$message = xmlrpc_message($result->data);
// Now parse what we've got back
if (!xmlrpc_message_parse($message)) {
// XML error
xmlrpc_error(-32700, t('Parse error. Not well formed'));
return FALSE;
}
// Is the message a fault?
if ($message->messagetype == 'fault') {
xmlrpc_error($message->fault_code, $message->fault_string);
return FALSE;
}
// We now know that the message is well-formed and a non-fault result.
if ($method == 'system.multicall') {
// Return per-method results or error objects.
$return = array();
foreach ($message->params[0] as $result) {
if (array_keys($result) == array(0)) {
$return[] = $result[0];
}
else {
$return[] = xmlrpc_error($result['faultCode'], $result['faultString']);
}
}
}
else {
$return = $message->params[0];
}
return $return;
}
/**
* Returns the last XML-RPC client error number.
*/
function xmlrpc_errno() {
$error = xmlrpc_error();
return ($error != NULL ? $error->code : NULL);
}
/**
* Returns the last XML-RPC client error message.
*/
function xmlrpc_error_msg() {
$error = xmlrpc_error();
return ($error != NULL ? $error->message : NULL);
}
/**
* Clears any previously-saved errors.
*
* @see xmlrpc_error()
*/
function xmlrpc_clear_error() {
xmlrpc_error(NULL, NULL, TRUE);
}
+394
View File
@@ -0,0 +1,394 @@
<?php
/**
* @file
* Provides API for defining and handling XML-RPC requests.
*/
/**
* Invokes XML-RPC methods on this server.
*
* @param array $callbacks
* Either an associative array of external XML-RPC method names as keys with
* the callbacks they map to as values, or a more complex structure
* describing XML-RPC callbacks as returned from hook_xmlrpc().
*/
function xmlrpc_server($callbacks) {
$xmlrpc_server = new stdClass();
// Define built-in XML-RPC method names
$defaults = array(
'system.multicall' => 'xmlrpc_server_multicall',
array(
'system.methodSignature',
'xmlrpc_server_method_signature',
array('array', 'string'),
'Returns an array describing the return type and required parameters of a method.',
),
array(
'system.getCapabilities',
'xmlrpc_server_get_capabilities',
array('struct'),
'Returns a struct describing the XML-RPC specifications supported by this server.',
),
array(
'system.listMethods',
'xmlrpc_server_list_methods',
array('array'),
'Returns an array of available methods on this server.',
),
array(
'system.methodHelp',
'xmlrpc_server_method_help',
array('string', 'string'),
'Returns a documentation string for the specified method.',
),
);
// We build an array of all method names by combining the built-ins
// with those defined by modules implementing the _xmlrpc hook.
// Built-in methods are overridable.
$callbacks = array_merge($defaults, (array) $callbacks);
drupal_alter('xmlrpc', $callbacks);
foreach ($callbacks as $key => $callback) {
// we could check for is_array($callback)
if (is_int($key)) {
$method = $callback[0];
$xmlrpc_server->callbacks[$method] = $callback[1];
$xmlrpc_server->signatures[$method] = $callback[2];
$xmlrpc_server->help[$method] = $callback[3];
}
else {
$xmlrpc_server->callbacks[$key] = $callback;
$xmlrpc_server->signatures[$key] = '';
$xmlrpc_server->help[$key] = '';
}
}
$data = file_get_contents('php://input');
if (!$data) {
print 'XML-RPC server accepts POST requests only.';
drupal_exit();
}
$xmlrpc_server->message = xmlrpc_message($data);
if (!xmlrpc_message_parse($xmlrpc_server->message)) {
xmlrpc_server_error(-32700, t('Parse error. Request not well formed.'));
}
if ($xmlrpc_server->message->messagetype != 'methodCall') {
xmlrpc_server_error(-32600, t('Server error. Invalid XML-RPC. Request must be a methodCall.'));
}
if (!isset($xmlrpc_server->message->params)) {
$xmlrpc_server->message->params = array();
}
xmlrpc_server_set($xmlrpc_server);
$result = xmlrpc_server_call($xmlrpc_server, $xmlrpc_server->message->methodname, $xmlrpc_server->message->params);
if (is_object($result) && !empty($result->is_error)) {
xmlrpc_server_error($result);
}
// Encode the result
$r = xmlrpc_value($result);
// Create the XML
$xml = '
<methodResponse>
<params>
<param>
<value>' . xmlrpc_value_get_xml($r) . '</value>
</param>
</params>
</methodResponse>
';
// Send it
xmlrpc_server_output($xml);
}
/**
* Throws an XML-RPC error.
*
* @param $error
* An error object or integer error code.
* @param $message
* (optional) The description of the error. Used only if an integer error
* code was passed in.
*/
function xmlrpc_server_error($error, $message = FALSE) {
if ($message && !is_object($error)) {
$error = xmlrpc_error($error, $message);
}
xmlrpc_server_output(xmlrpc_error_get_xml($error));
}
/**
* Sends XML-RPC output to the browser.
*
* @param string $xml
* XML to send to the browser.
*/
function xmlrpc_server_output($xml) {
$xml = '<?xml version="1.0"?>' . "\n" . $xml;
drupal_add_http_header('Content-Length', strlen($xml));
drupal_add_http_header('Content-Type', 'text/xml');
echo $xml;
drupal_exit();
}
/**
* Stores a copy of an XML-RPC request temporarily.
*
* @param object $xmlrpc_server
* (optional) Request object created by xmlrpc_server(). Omit to leave the
* previous server object saved.
*
* @return
* The latest stored request.
*
* @see xmlrpc_server_get()
*/
function xmlrpc_server_set($xmlrpc_server = NULL) {
static $server;
if (!isset($server)) {
$server = $xmlrpc_server;
}
return $server;
}
/**
* Retrieves the latest stored XML-RPC request.
*
* @return object
* The stored request.
*
* @see xmlrpc_server_set()
*/
function xmlrpc_server_get() {
return xmlrpc_server_set();
}
/**
* Dispatches an XML-RPC request and any parameters to the appropriate handler.
*
* @param object $xmlrpc_server
* Object containing information about this XML-RPC server, the methods it
* provides, their signatures, etc.
* @param string $methodname
* The external XML-RPC method name; e.g., 'system.methodHelp'.
* @param array $args
* Array containing any parameters that are to be sent along with the request.
*
* @return
* The results of the call.
*/
function xmlrpc_server_call($xmlrpc_server, $methodname, $args) {
// Make sure parameters are in an array
if ($args && !is_array($args)) {
$args = array($args);
}
// Has this method been mapped to a Drupal function by us or by modules?
if (!isset($xmlrpc_server->callbacks[$methodname])) {
return xmlrpc_error(-32601, t('Server error. Requested method @methodname not specified.', array("@methodname" => $xmlrpc_server->message->methodname)));
}
$method = $xmlrpc_server->callbacks[$methodname];
$signature = $xmlrpc_server->signatures[$methodname];
// If the method has a signature, validate the request against the signature
if (is_array($signature)) {
$ok = TRUE;
$return_type = array_shift($signature);
// Check the number of arguments
if (count($args) != count($signature)) {
return xmlrpc_error(-32602, t('Server error. Wrong number of method parameters.'));
}
// Check the argument types
foreach ($signature as $key => $type) {
$arg = $args[$key];
switch ($type) {
case 'int':
case 'i4':
if (is_array($arg) || !is_int($arg)) {
$ok = FALSE;
}
break;
case 'base64':
case 'string':
if (!is_string($arg)) {
$ok = FALSE;
}
break;
case 'boolean':
if ($arg !== FALSE && $arg !== TRUE) {
$ok = FALSE;
}
break;
case 'float':
case 'double':
if (!is_float($arg)) {
$ok = FALSE;
}
break;
case 'date':
case 'dateTime.iso8601':
if (!$arg->is_date) {
$ok = FALSE;
}
break;
}
if (!$ok) {
return xmlrpc_error(-32602, t('Server error. Invalid method parameters.'));
}
}
}
if (!function_exists($method)) {
return xmlrpc_error(-32601, t('Server error. Requested function @method does not exist.', array("@method" => $method)));
}
// Call the mapped function
return call_user_func_array($method, $args);
}
/**
* Dispatches multiple XML-RPC requests.
*
* @param array $methodcalls
* An array of XML-RPC requests to make. Each request is an array with the
* following elements:
* - methodName: Name of the method to invoke.
* - params: Parameters to pass to the method.
*
* @return
* An array of the results of each request.
*
* @see xmlrpc_server_call()
*/
function xmlrpc_server_multicall($methodcalls) {
// See http://www.xmlrpc.com/discuss/msgReader$1208
// To avoid multicall expansion attacks, limit the number of duplicate method
// calls allowed with a default of 1. Set to -1 for unlimited.
$duplicate_method_limit = variable_get('xmlrpc_multicall_duplicate_method_limit', 1);
$method_count = array();
$return = array();
$xmlrpc_server = xmlrpc_server_get();
foreach ($methodcalls as $call) {
$ok = TRUE;
if (!isset($call['methodName']) || !isset($call['params'])) {
$result = xmlrpc_error(3, t('Invalid syntax for system.multicall.'));
$ok = FALSE;
}
$method = $call['methodName'];
$method_count[$method] = isset($method_count[$method]) ? $method_count[$method] + 1 : 1;
$params = $call['params'];
if ($method == 'system.multicall') {
$result = xmlrpc_error(-32600, t('Recursive calls to system.multicall are forbidden.'));
}
elseif ($duplicate_method_limit > 0 && $method_count[$method] > $duplicate_method_limit) {
$result = xmlrpc_error(-156579, t('Too many duplicate method calls in system.multicall.'));
}
elseif ($ok) {
$result = xmlrpc_server_call($xmlrpc_server, $method, $params);
}
if (is_object($result) && !empty($result->is_error)) {
$return[] = array(
'faultCode' => $result->code,
'faultString' => $result->message,
);
}
else {
$return[] = array($result);
}
}
return $return;
}
/**
* Lists the methods available on this XML-RPC server.
*
* XML-RPC method system.listMethods maps to this function.
*
* @return array
* Array of the names of methods available on this server.
*/
function xmlrpc_server_list_methods() {
$xmlrpc_server = xmlrpc_server_get();
return array_keys($xmlrpc_server->callbacks);
}
/**
* Returns a list of the capabilities of this server.
*
* XML-RPC method system.getCapabilities maps to this function.
*
* @return array
* Array of server capabilities.
*
* @see http://groups.yahoo.com/group/xml-rpc/message/2897
*/
function xmlrpc_server_get_capabilities() {
return array(
'xmlrpc' => array(
'specUrl' => 'http://www.xmlrpc.com/spec',
'specVersion' => 1,
),
'faults_interop' => array(
'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
'specVersion' => 20010516,
),
'system.multicall' => array(
'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
'specVersion' => 1,
),
'introspection' => array(
'specUrl' => 'http://scripts.incutio.com/xmlrpc/introspection.html',
'specVersion' => 1,
),
);
}
/**
* Returns one method signature for a function.
*
* This is the function mapped to the XML-RPC method system.methodSignature.
*
* A method signature is an array of the input and output types of a method. For
* instance, the method signature of this function is array('array', 'string'),
* because it takes an array and returns a string.
*
* @param string $methodname
* Name of method to return a method signature for.
*
* @return array
* An array of arrays of types, each of the arrays representing one method
* signature of the function that $methodname maps to.
*/
function xmlrpc_server_method_signature($methodname) {
$xmlrpc_server = xmlrpc_server_get();
if (!isset($xmlrpc_server->callbacks[$methodname])) {
return xmlrpc_error(-32601, t('Server error. Requested method @methodname not specified.', array("@methodname" => $methodname)));
}
if (!is_array($xmlrpc_server->signatures[$methodname])) {
return xmlrpc_error(-32601, t('Server error. Requested method @methodname signature not specified.', array("@methodname" => $methodname)));
}
// We array of types
$return = array();
foreach ($xmlrpc_server->signatures[$methodname] as $type) {
$return[] = $type;
}
return array($return);
}
/**
* Returns the help for an XML-RPC method.
*
* XML-RPC method system.methodHelp maps to this function.
*
* @param string $method
* Name of method for which we return a help string.
*
* @return string
* Help text for $method.
*/
function xmlrpc_server_method_help($method) {
$xmlrpc_server = xmlrpc_server_get();
return $xmlrpc_server->help[$method];
}
+21
View File
@@ -0,0 +1,21 @@
<?php
/**
* @file
* The PHP page that serves all page requests on a Drupal installation.
*
* The routines here dispatch control to the appropriate handler, which then
* prints the appropriate page.
*
* All Drupal code is released under the GNU General Public License.
* See COPYRIGHT.txt and LICENSE.txt.
*/
/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
menu_execute_active_handler();
+26
View File
@@ -0,0 +1,26 @@
<?php
/**
* @file
* Initiates a browser-based installation of Drupal.
*/
/**
* Defines the root directory of the Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
/**
* Global flag to indicate the site is in installation mode.
*/
define('MAINTENANCE_MODE', 'install');
// Exit early if running an incompatible PHP version to avoid fatal errors.
if (version_compare(PHP_VERSION, '5.2.4') < 0) {
print 'Your PHP installation is too old. Drupal requires at least PHP 5.2.4. See the <a href="http://drupal.org/requirements">system requirements</a> page for more information.';
exit;
}
// Start the installer.
require_once DRUPAL_ROOT . '/includes/install.core.inc';
install_drupal();
+14
View File
@@ -0,0 +1,14 @@
diff --git a/logintoboggan.permissions.js b/logintoboggan.permissions.js
index d463d29..492b64c 100644
--- a/logintoboggan.permissions.js
+++ b/logintoboggan.permissions.js
@@ -14,6 +14,9 @@ Drupal.behaviors.LoginTobogganPermissions = {
$('table#permissions', context).once('tobogganPermissions', function () {
$('input[type=checkbox]', this).filter('.rid-' + settings.LoginToboggan.preAuthID).removeClass('real-checkbox').each(function () {
$(this).next().filter('.dummy-checkbox').remove();
+ $('input.rid-' + settings.LoginToboggan.preAuthID).each(function () {
+ this.style.display = '';
+ });
});
});
},
@@ -0,0 +1,136 @@
diff --git a/logintoboggan.module b/logintoboggan.module
index 55b93fe..4e4e0fc 100644
--- a/logintoboggan.module
+++ b/logintoboggan.module
@@ -306,26 +306,6 @@ function logintoboggan_form_user_pass_reset_alter(&$form, &$form_state) {
}
/**
- * Implement hook_form_user_admin_permissions_alter().
- *
- * @ingroup logintoboggan_core
- */
-function logintoboggan_form_user_admin_permissions_alter(&$form, &$form_state) {
- // If the pre-auth role isn't the auth user, then add it as a setting.
- $id = logintoboggan_validating_id();
- if ($id != DRUPAL_AUTHENTICATED_RID) {
- $form['#attached']['js'][] = array(
- 'data' => array(
- 'LoginToboggan' => array(
- 'preAuthID' => $id,
- ),
- ),
- 'type' => 'setting',
- );
- }
-}
-
-/**
* Implement hook_form_alter().
*
* @ingroup logintoboggan_core
@@ -410,7 +390,10 @@ function logintoboggan_js_alter(&$javascript) {
// prevent the pre-auth role's checkboxes from being automatically disabled
// when the auth user's checkboxes are checked.
if ($id != DRUPAL_AUTHENTICATED_RID) {
- $javascript['modules/user/user.permissions.js']['data'] = drupal_get_path('module', 'logintoboggan') . '/logintoboggan.permissions.js';
+ $javascript['settings']['data'][] = array('LoginToboggan' => array('preAuthID' => $id));
+ $file = drupal_get_path('module', 'logintoboggan') . '/logintoboggan.permissions.js';
+ $javascript[$file] = drupal_js_defaults($file);
+ $javascript[$file]['weight'] = 999;
}
}
}
diff --git a/logintoboggan.permissions.js b/logintoboggan.permissions.js
index 1d406cc..492b64c 100644
--- a/logintoboggan.permissions.js
+++ b/logintoboggan.permissions.js
@@ -1,77 +1,25 @@
/**
- * This is a custom implementation of user.permissions.js, which is necessary
- * because LoginToboggan needs its pre-auth role to not be explicitly tied to
- * the auth role. The change is minor -- simply exclude the pre-auth role from
- * all the auto-checking as the anon and auth user roles are.
+ * LoginToboggan needs its pre-auth role to not be explicitly tied to
+ * the auth role.
*/
-
(function ($) {
/**
* Shows checked and disabled checkboxes for inherited permissions.
*/
-Drupal.behaviors.permissions = {
- attach: function (context) {
- var self = this;
- $('table#permissions').once('permissions', function () {
- // On a site with many roles and permissions, this behavior initially has
- // to perform thousands of DOM manipulations to inject checkboxes and hide
- // them. By detaching the table from the DOM, all operations can be
- // performed without triggering internal layout and re-rendering processes
- // in the browser.
- var $table = $(this);
- if ($table.prev().length) {
- var $ancestor = $table.prev(), method = 'after';
- }
- else {
- var $ancestor = $table.parent(), method = 'append';
- }
- $table.detach();
-
- // Create dummy checkboxes. We use dummy checkboxes instead of reusing
- // the existing checkboxes here because new checkboxes don't alter the
- // submitted form. If we'd automatically check existing checkboxes, the
- // permission table would be polluted with redundant entries. This
- // is deliberate, but desirable when we automatically check them.
- var $dummy = $('<input type="checkbox" class="dummy-checkbox" disabled="disabled" checked="checked" />')
- .attr('title', Drupal.t("This permission is inherited from the authenticated user role."))
- .hide();
-
- $('input[type=checkbox]', this).not('.rid-2, .rid-1, .rid-' + Drupal.settings.LoginToboggan.preAuthID).addClass('real-checkbox').each(function () {
- $dummy.clone().insertAfter(this);
+Drupal.behaviors.LoginTobogganPermissions = {
+ attach: function (context, settings) {
+ // Revert changes made by modules/user/user.permissions.js
+ $('table#permissions', context).once('tobogganPermissions', function () {
+ $('input[type=checkbox]', this).filter('.rid-' + settings.LoginToboggan.preAuthID).removeClass('real-checkbox').each(function () {
+ $(this).next().filter('.dummy-checkbox').remove();
+ $('input.rid-' + settings.LoginToboggan.preAuthID).each(function () {
+ this.style.display = '';
+ });
});
-
- // Initialize the authenticated user checkbox.
- $('input[type=checkbox].rid-2', this)
- .bind('click.permissions', self.toggle)
- // .triggerHandler() cannot be used here, as it only affects the first
- // element.
- .each(self.toggle);
-
- // Re-insert the table into the DOM.
- $ancestor[method]($table);
});
},
-
- /**
- * Toggles all dummy checkboxes based on the checkboxes' state.
- *
- * If the "authenticated user" checkbox is checked, the checked and disabled
- * checkboxes are shown, the real checkboxes otherwise.
- */
- toggle: function () {
- var authCheckbox = this, $row = $(this).closest('tr');
- // jQuery performs too many layout calculations for .hide() and .show(),
- // leading to a major page rendering lag on sites with many roles and
- // permissions. Therefore, we toggle visibility directly.
- $row.find('.real-checkbox').each(function () {
- this.style.display = (authCheckbox.checked ? 'none' : '');
- });
- $row.find('.dummy-checkbox').each(function () {
- this.style.display = (authCheckbox.checked ? '' : 'none');
- });
- }
};
})(jQuery);

Some files were not shown because too many files have changed in this diff Show More