diff --git a/drupal-dev/CHANGELOG.txt b/drupal-dev/CHANGELOG.txt new file mode 100644 index 0000000..9f1bcf1 --- /dev/null +++ b/drupal-dev/CHANGELOG.txt @@ -0,0 +1,1833 @@ + +Drupal 7.26, 2014-01-15 +---------------------- +- Fixed security issues (multiple vulnerabilities). See SA-CORE-2014-001. + +Drupal 7.25, 2014-01-02 +----------------------- +- Fixed a bug in node_save() which prevented the saved node from being updated + in hook_node_insert() and other similar hooks. +- Added a meta tag to install.php to prevent it from being indexed by search + engines even when Drupal is installed in a subfolder (minor markup change). +- Fixed a bug in the database API that caused frequent deadlock errors when + running merge queries on some servers. +- Performance improvement: Prevented block rehashing from writing blocks to the + database on every cache clear and cron run when the blocks have not changed. + This fix results in an extra 'saved' key which is added and set to TRUE for + each block returned by _block_rehash() that actually is saved to the database + (data structure change). +- Added an optional 'skip on cron' parameter to hook_cron_queue_info() to allow + queues to avoid being automatically processed on cron runs (API addition). +- Fixed a bug which caused hook_block_view_MODULE_DELTA_alter() to never be + invoked if the block delta had a hyphen in it. To implement the hook when the + block delta has a hyphen, modules should now replace hyphens with underscores + when constructing the function name for the hook implementation. +- Fixed a bug which caused cached pages to sometimes be sent to the browser + with incorrect compression. The fix adds a new 'page_compressed' key to the + $cache->data array returned by drupal_page_get_cache() (minor data structure + change). +- Fixed broken tests on PHP 5.5. +- Made the File and Image modules more robust when saving entities that have + deleted files attached. The code in file_field_presave() will now remove the + record of the deleted file from the entity before saving (minor data + structure change). +- Standardized menu callback functions throughout Drupal core to return + MENU_NOT_FOUND and MENU_ACCESS_DENIED rather than printing their own "page + not found" or "access denied" pages (minor API change in the return value of + these functions under some circumstances). +- Fixed a bug in which caches were not properly cleared when a node was deleted + via the administrative interface. +- Changed the Bartik theme to render content contained in
,  and
+  similar tags in a larger font size, so it is easier to read.
+- Fixed a bug in the Search module that caused exceptions to be thrown during
+  searches if the server was not configured to represent decimal points as a
+  period.
+- Fixed a regression in the Image module that made image_style_url() not work
+  when a relative path (rather than a complete file URI) was passed to it.
+- Added an optional feature to the Statistics module to allow node views to be
+  tracked by Ajax requests rather than during the server-side generation of the
+  page. This allows the node counter to work on sites that use external page
+  caches (string change and new administrative option:
+  https://drupal.org/node/2164069).
+- Added a link to the drupal.org documentation page for cron to the Cron
+  settings page (string change).
+- Added a 'drupal_anonymous_user_object' variable to allow the anonymous user
+  object returned by drupal_anonymous_user() to be overridden with a classed
+  object (API addition).
+- Changed the database API to allow inserts based on a SELECT * query to work
+  correctly.
+- Changed the database schema of the {file_managed} table to allow Drupal to
+  manage files larger than 4 GB.
+- Changed the File module's hook_field_load() implementation to prevent file
+  entity properties which have the same name as file or image field properties
+  from overwriting the field properties (minor API change).
+- Numerous small bug fixes.
+- Numerous API documentation improvements.
+- Additional automated test coverage.
+
+Drupal 7.24, 2013-11-20
+----------------------
+- Fixed security issues (multiple vulnerabilities), see SA-CORE-2013-003.
+
+Drupal 7.23, 2013-08-07
+-----------------------
+- Fixed a fatal error on PostgreSQL databases when updating the Taxonomy module
+  from Drupal 6 to Drupal 7.
+- Fixed the default ordering of CSS files for sites using right-to-left
+  languages, to consistently place the right-to-left override file immediately
+  after the CSS it is overriding (API change: https://drupal.org/node/2058463).
+- Added a drupal_check_memory_limit() API function to allow the memory limit to
+  be checked consistently (API addition).
+- Changed the default web.config file for IIS servers to allow favicon.ico
+  files which are present in the filesystem to be accessed.
+- Fixed inconsistent support for the 'tel' protocol in Drupal's URL filtering
+  functions.
+- Performance improvement: Allowed all hooks to be included in the
+  module_implements() cache, even those that are only invoked on HTTP POST
+  requests.
+- Made the database system replace truncate queries with delete queries when
+  inside a transaction, to fix issues with PostgreSQL and other databases.
+- Fixed a bug which caused nested contextual links to display improperly.
+- Fixed a bug which prevented cached image derivatives from being flushed for
+  private files and other non-default file schemes.
+- Fixed drupal_render() to always return an empty string when there is no
+  output, rather than sometimes returning NULL (minor API change).
+- Added protection to cache_clear_all() to ensure that non-cache tables cannot
+  be truncated (API addition: a new isValidBin() method has been added to the
+  default database cache implementation).
+- Changed the default .htaccess file to support HTTP authorization in CGI
+  environments.
+- Changed the password reset form to pre-fill the username when requested via a
+  URL query parameter, and used this in the error message that appears after a
+  failed login attempt (minor data structure and behavior change).
+- Fixed broken support for foreign keys in the field API.
+- Fixed "No active batch" error when a user cancels their own account.
+- Added a description to the "access content overview" permission on the
+  permissions page (string change).
+- Added a drupal_array_diff_assoc_recursive() function to allow associative
+  arrays to be compared recursively (API addition).
+- Added human-readable labels to image styles, in addition to the existing
+  machine-readable name (API change: https://drupal.org/node/2058503).
+- Moved the drupal_get_hash_salt() function to bootstrap.inc and used it in
+  additional places in the code, for added security in the case where there is
+  no hash salt in settings.php.
+- Fixed a regression in Drupal 7.22 that caused internal server errors for
+  sites running on very old Apache 1.x web servers.
+- Numerous small bug fixes.
+- Numerous API documentation improvements.
+- Additional automated test coverage.
+
+Drupal 7.22, 2013-04-03
+-----------------------
+- Allowed the drupal_http_request() function to be overridden so that
+  additional HTTP request capabilities can be added by contributed modules.
+- Changed the Simpletest module to allow PSR-0 test classes to be used in
+  Drupal 7.
+- Removed an unnecessary "Content-Disposition" header from private file
+  downloads; it prevented many private files from being viewed inline in a web
+  browser.
+- Changed various field API functions to allow them to optionally act on a
+  single field within an entity (API addition: http://drupal.org/node/1825844).
+- Fixed a bug which prevented Drupal's file transfer functionality from working
+  on some PHP 5.4 systems.
+- Fixed incorrect log message when theme() is called for a theme hook that does
+  not exist (minor string change).
+- Fixed Drupal's token-replacement system to allow spaces in the token value.
+- Changed the default behavior after a user creates a node they do not have
+  access to view. The user will now be redirected to the front page rather than
+  an access denied page.
+- Fixed a bug which prevented empty HTTP headers (such as "0") from being set.
+  (Minor behavior change: Callers of drupal_add_http_header() must now set
+  FALSE explicitly to prevent a header from being sent at all; this was already
+  indicated in the function's documentation.)
+- Fixed OpenID errors when more than one module implements hook_openid(). The
+  behavior is now changed so that if more than one module tries to set the same
+  parameter, the last module's change takes effect.
+- Fixed a serious documentation bug: The $name variable in the
+  taxonomy-term.tpl.php theme template was incorrectly documented as being
+  sanitized when in fact it is not.
+- Fixed a bug which prevented Drupal 6 to Drupal 7 upgrades on sites which had
+  duplicate permission names in the User module's database tables.
+- Added an empty "datatype" attribute to taxonomy term and username links to
+  make the RDFa markup upward compatible with RDFa 1.1 (minor markup addition).
+- Fixed a bug which caused the denial-of-service protection added in Drupal
+  7.20 to break certain valid image URLs that had an extra slash in them.
+- Fixed a bug with update queries in the SQLite database driver that prevented
+  Drupal from being installed with SQLite on PHP 5.4.
+- Fixed enforced dependencies errors updating to recent versions of Drupal 7 on
+  certain non-MySQL databases.
+- Refactored the Field module's caching behavior to obtain large improvements
+  in memory usage for sites with many fields and instances (API addition:
+  http://drupal.org/node/1915646).
+- Fixed entity argument not being passed to implementations of
+  hook_file_download_access_alter(). The fix adds an additional context
+  parameter that can be passed when calling drupal_alter() for any hook (API
+  change: http://drupal.org/node/1882722).
+- Fixed broken support for translatable comment fields (API change:
+  http://drupal.org/node/1874724).
+- Added an assertThemeOutput() method to Simpletest to allow tests to check
+  that themed output matches an expected HTML string (API addition).
+- Added a link to "Install another module" after a module has been successfully
+  downloaded via the Update Manager (UI change).
+- Added an optional "exclusive" flag to installation profile .info files which
+  allows Drupal distributions to force a profile to be selected during
+  installation (API addition: http://drupal.org/node/1961012).
+- Fixed a bug which caused the database API to not properly close database
+  connections.
+- Added a link to the URL for running cron from outside the site to the Cron
+  settings page (UI change).
+- Fixed a bug which prevented image styles from being reverted on PHP 5.4.
+- Made the default .htaccess rules protocol sensitive to improve security for
+  sites which use HTTPS and redirect between "www" and non-"www" versions of
+  the page.
+- Numerous small bug fixes.
+- Numerous API documentation improvements.
+- Additional automated test coverage.
+
+Drupal 7.21, 2013-03-06
+-----------------------
+- Allowed sites using the 'image_allow_insecure_derivatives' variable to still
+  have partial protection from the security issues fixed in Drupal 7.20.
+
+Drupal 7.20, 2013-02-20
+-----------------------
+- Fixed security issues (denial of service). See SA-CORE-2013-002.
+
+Drupal 7.19, 2013-01-16
+-----------------------
+- Fixed security issues (multiple vulnerabilities). See SA-CORE-2013-001.
+
+Drupal 7.18, 2012-12-19
+-----------------------
+- Fixed security issues (multiple vulnerabilities). See SA-CORE-2012-004.
+
+Drupal 7.17, 2012-11-07
+-----------------------
+- Changed the default value of the '404_fast_html' variable to have a DOCTYPE
+  declaration.
+- Made it possible to use associative arrays for the 'items' variable in
+  theme_item_list().
+- Fixed a bug which prevented required form elements without a title from being
+  given an "error" class when the form fails validation.
+- Prevented duplicate HTML IDs from appearing when two forms are displayed on
+  the same page and one of them is submitted with invalid data (minor markup
+  change).
+- Fixed a bug which prevented Drupal 6 to Drupal 7 upgrades on sites which had
+  stale data in the Upload module's database tables.
+- Fixed a bug in the States API which prevented certain types of form elements
+  from being disabled when requested.
+- Allowed aggregator feed items with author names longer than 255 characters to
+  have a truncated version saved to the database (rather than causing a fatal
+  error).
+- Allowed aggregator feed items to have URLs longer than 255 characters
+  (schema change which results in several columns in the Aggregator module's
+  database tables changing from VARCHAR to TEXT fields).
+- Added hook_taxonomy_term_view() and standardized the process for rendering
+  taxonomy terms to invoke hook_entity_view() and otherwise make it consistent
+  with other entities (API change: http://drupal.org/node/1808870).
+- Added hook_entity_view_mode_alter() to allow modules to change entity view
+  modes on display (API addition: http://drupal.org/node/1833086).
+- Fixed a bug which made database queries running a "LIKE" query on blob fields
+  fail on PostgreSQL databases. This caused errors during the Drupal 6 to
+  Drupal 7 upgrade.
+- Changed the hook_menu() entry for Drupal's rss.xml page to prevent extra path
+  components from being accidentally passed to the page callback function (data
+  structure change).
+- Removed a non-standard "name" attribute from Drupal's default Content-Type
+  header for file downloads.
+- Fixed the theme settings form to properly clean up submitted values in
+  $form_state['values'] when the form is submitted (data structure change).
+- Fixed an inconsistency by removing the colon from the end of the label on
+  multi-valued form fields (minor string change).
+- Added support for 'weight' in hook_field_widget_info() to allow modules to
+  control the order in which widgets are displayed in the Field UI.
+- Updated various tables in the OpenID and Book modules to use the default
+  "empty table" text pattern (string change).
+- Added proxy server support to drupal_http_request().
+- Added "lang" attributes to language links, to better support screen readers.
+- Fixed double occurrence of a "ul" HTML tag on secondary local tasks in the
+  Seven theme (markup change).
+- Fixed bugs which caused taxonomy vocabulary and shortcut set titles to be
+  double-escaped. The fix replaces the taxonomy vocabulary overview page and
+  "Edit shortcuts" menu items' title callback entries in hook_menu() with new
+  functions that do not escape HTML characters (data structure change).
+- Modified the Update manager module to allow drupal.org to collect usage
+  statistics for individual modules and themes, rather than only for entire
+  projects.
+- Modified the node listing database query on Drupal's default front page to
+  add table aliases for better query altering (this is a data structure change
+  affecting code which implements hook_query_alter() on this query).
+- Improved the translatability of the "Field type(s) in use" message on the
+  modules page (admin-facing string change).
+- Fixed a regression which caused a "call to undefined function
+  drupal_find_base_themes()" fatal error under rare circumstances.
+- Numerous API documentation improvements.
+- Additional automated test coverage.
+
+Drupal 7.16, 2012-10-17
+-----------------------
+- Fixed security issues (Arbitrary PHP code execution and information
+  disclosure). See SA-CORE-2012-003.
+
+Drupal 7.15, 2012-08-01
+-----------------------
+- Introduced a 'user_password_reset_timeout' variable to allow the 24-hour
+  expiration for user password reset links to be adjusted (API addition).
+- Fixed database errors due to ambiguous column names that occurred when
+  EntityFieldQuery was used in certain situations.
+- Changed the drupal_array_get_nested_value() function to return a reference
+  (API addition).
+- Changed the System module's hook_block_info() implementation to assign the
+  "Main page content" and "System help" blocks to appropriate regions by
+  default and prevent error messages on the block administration page (data
+  structure change).
+- Fixed regression: Non-node entities couldn't be accessed with
+  EntityFieldQuery.
+- Fixed regression: Optional radio buttons with an empty, non-NULL default
+  value led to an illegal choice error when none were selected.
+- Reorganized the testing framework to split setUp() into specific sub-methods
+  and fix several regressions in the process.
+- Fixed bug which made it impossible to search for strings that have not been
+  translated into a particular language.
+- Renamed the "Field" column on the Manage Fields screen to "Field type", since
+  the former was confusing and inaccurate (UI change).
+- Performance improvement: Removed needless call to system_rebuild_module_data()
+  in field_sync_field_status(), greatly speeding up bulk module enable/disable.
+- Fixed bug which prevented notifications from being sent when core, module, and
+  theme updates are available.
+- Fixed bug which prevented sub-themes from inheriting the default values of
+  theme settings defined by the base theme.
+- Fixed bug which prevented the jQuery UI Datepicker from being localized.
+- Made Ajax alert dialogs respect error reporting settings.
+- Fixed bug which prevented image styles from being deleted on PHP 5.4.
+- Fixed bug: Language detection by domain only worked on port 80.
+- Fixed regression: The first plural index on a page was not calculated
+  correctly.
+- Introduced generic entity language support. Entities may now declare their
+  language property in hook_entity_info(), and modules working with entities
+  may access the language using entity_language() (API change:
+  http://drupal.org/node/1626346).
+- Added EntityFieldQuery support for taxonomy bundles.
+- Fixed issue where field form structure was incomplete if field_access()
+  returned FALSE. Instead of being incomplete, the form structure now has
+  #access set to FALSE and field form validation is skipped (data structure
+  change: http://drupal.org/node/1663020).
+- Fixed data loss issue due to field_has_data() returning inconsistent results.
+  The fix adds an optional DANGEROUS_ACCESS_CHECK_OPT_OUT tag to entity field
+  queries which field storage engines can respond to (API addition:
+  http://drupal.org/node/1597378).
+- Fixed notice: Undefined index: default_image in image_field_prepare_view()
+- Numerous API documentation improvements.
+- Additional automated test coverage.
+
+Drupal 7.14 2012-05-02
+----------------------
+- Fixed "integrity constraint" fatal errors when rebuilding registry.
+- Fixed custom logo and favicon functionality referencing incorrect paths.
+- Fixed DB Case Sensitivity: Allow BINARY attribute in MySQL.
+- Split field_bundle_settings out per bundle.
+- Improve UX for machine names for fields (UI change).
+- Fixed User pictures are not removed properly.
+- Fixed HTTPS sessions not working in all cases.
+- Fixed Regression: Required radios throw illegal choice error when none
+  selected.
+- Fixed allow autocompletion requests to include slashes.
+- Eliminate $user->cache and {session}.cache in favor of
+  $_SESSION['cache_expiration'][$bin] (Performance).
+- Fixed focus jumps to tab when pressing enter on a form element within tab.
+- Fixed race condition in locale() - duplicates in {locales_source}.
+- Fixed Missing "Default image" per field instance.
+- Quit clobbering people's work when they click the filter tips link
+- Form API #states: Fix conditionals to allow OR and XOR constructions.
+- Fixed Focus jumps to tab when pressing enter on a form element within tab.
+  (Accessibility)
+- Improved performance of node_access queries.
+- Fixed Fieldsets inside vertical tabs have no title and can't be collapsed.
+- Reduce size of cache_menu table (Performance).
+- Fixed unnecessary aggregation of CSS/JS (Performance).
+- Fixed taxonomy_autocomplete() produces SQL error for nonexistent field.
+- Fixed HTML filter is not run first by default, despite default weight.
+- Fixed Overlay does not work with prefixed URL paths.
+- Better debug info for field errors (string change).
+- Fixed Data corruption in comment IDs (results in broken threading on
+  PostgreSQL).
+- Fixed machine name not editable if every character is replaced.
+- Fixed user picture not appearing in comment preview (Markup change).
+- Added optional vid argument for taxonomy_get_term_by_name().
+- Fixed Invalid Unicode code range in PREG_CLASS_UNICODE_WORD_BOUNDARY fails
+  with PCRE 8.30.
+- Fixed {trigger_assignments()}.hook has only 32 characters, is too short.
+- Numerous fixes to run-tests.sh.
+- Fixed Tests in profiles/[name]/modules cannot be run and cannot use a
+  different profile for running tests.
+- Numerous JavaScript performance fixes.
+- Numerous documentation fixes.
+- Fixed All pager links have an 'active' CSS class.
+- Numerous upgrade path fixes; notably:
+  - system_update_7061() fails on inserting files with same name but different
+    case.
+  - system_update_7061() converts filepaths too aggressively.
+  - Trigger upgrade path: Node triggers removed when upgrading to 7-x from 6.25.
+
+Drupal 7.13 2012-05-02
+----------------------
+- Fixed security issues (Multiple vulnerabilities), see SA-CORE-2012-002.
+
+Drupal 7.12, 2012-02-01
+----------------------
+- Fixed bug preventing custom menus from receiving an active trail.
+- Fixed hook_field_delete() no longer invoked during field_purge_data().
+- Fixed bug causing entity info cache to not be cleared with the rest of caches.
+- Fixed file_unmanaged_copy() fails with Drupal 7.7+ and safe_mode() or
+  open_basedir().
+- Fixed Nested transactions throw exceptions when they got out of scope.
+- Fixed bugs with the Return-Path when sending mail on both Windows and
+  non-Windows systems.
+- Fixed bug with DrupalCacheArray property visibility preventing others from
+  extending it (API change: http://drupal.org/node/1422264).
+- Fixed bug with handling of non-ASCII characters in file names (API change:
+  http://drupal.org/node/1424840).
+- Reconciled field maximum length with database column size in image and
+  aggregator modules.
+- Fixes to various core JavaScript files to allow for minification and
+  aggregation.
+- Fixed Prevent tests from deleting main installation's tables when
+  parent::setUp() is not called.
+- Fixed several Poll module bugs.
+- Fixed several Shortcut module bugs.
+- Added new hook_system_theme_info() to provide ability for contributed modules
+  to test theme functionality.
+- Added ability to cancel mail sending from hook_mail_alter().
+- Added support for configurable PDO connection options, enabling master-master
+  database replication.
+- Numerous improvements to tests and test runner to pave the way for faster test
+  runs.
+- Expanded test coverage.
+- Numerous API documentation improvements.
+- Numerous performance improvements, including token replacement and render
+  cache.
+
+Drupal 7.11, 2012-02-01
+----------------------
+- Fixed security issues (Multiple vulnerabilities), see SA-CORE-2012-001.
+
+Drupal 7.10, 2011-12-05
+----------------------
+- Fixed Content-Language HTTP header to not cause issues with Drush 5.x.
+- Reduce memory usage of theme registry (performance).
+- Fixed PECL upload progress bar for FileField
+- Fixed running update.php doesn't always clear the cache.
+- Fixed PDO exceptions on long titles.
+- Fixed Overlay redirect does not include query string.
+- Fixed D6 modules satisfy D7 module dependencies.
+- Fixed the ordering of module hooks when using module_implements_alter().
+- Fixed "floating" submit buttons during AJAX requests.
+- Fixed timezone selected on install not propogating to admin account.
+- Added msgctx context to JS translation functions, for feature parity with t().
+- Profiles' .install files now available during hook_install_tasks().
+- Added test coverage of 7.0 -> 7.x upgrade path.
+- Numerous notice fixes.
+- Numerous documentation improvements.
+- Additional automated test coverage.
+
+Drupal 7.9, 2011-10-26
+----------------------
+- Critical fixes to OpenID to spec violations that could allow for
+  impersonation in certain scenarios. Existing OpenID users should see
+  http://drupal.org/node/1120290#comment-5092796 for more information on
+  transitioning.
+- Fixed files getting lost when adding multiple files to multiple file fields
+  at the same time.
+- Improved usability of the clean URL test screens.
+- Restored height/width attributes on images run through the theme system.
+- Fixed usability bug with first password field being pre-filled by certain
+  browser plugins.
+- Fixed file_usage_list() so that it can return more than one result.
+- Fixed bug preventing preview of private images on node form.
+- Fixed PDO error when inserting an aggregator title longer than 255 characters.
+- Spelled out what TRADITIONAL means in MySQL sql_mode.
+- Deprecated "!=" operator for DBTNG; should be "<>".
+- Added two new API functions (menu_tree_set_path()/menu_tree_get_path()) were
+  added in order to enable setting the active menu trail for dynamically
+  generated menu paths.
+- Added new "fast 404" capability in settings.php to bypass Drupal bootstrap
+  when serving 404 pages for certain file types.
+- Added format_string() function which can perform string munging ala the t()
+  function without the overhead of the translation system.
+- Numerous #states system fixes.
+- Numerous EntityFieldQuery, DBTNG, and SQLite fixes.
+- Numerous Shortcut module fixes.
+- Numerous language system fixes.
+- Numerous token fixes.
+- Numerous CSS fixes.
+- Numerous upgrade path fixes.
+- Numerous minor string fixes.
+- Numerous notice fixes.
+
+Drupal 7.8, 2011-08-31
+----------------------
+- Fixed critical upgrade path issue with multilingual sites, leading to lost
+  content.
+- Numerous fixes to upgrade path, preventing fatal errors due to incorrect
+  dependencies.
+- Fixed issue with saving files on hosts with open_basedir restrictions.
+- Fixed Update manger error when used with Overlay.
+- Fixed RTL support in Seven administration theme and Overlay.
+- Fixes to nested transaction support.
+- Introduced performance pattern to reduce Drupal core's RAM usage.
+- Added support for HTML 5 tags to filter_xss_admin().
+- Added exception handling to cron.
+- Added new hook hook_field_widget_form_alter() for contribtued modules.
+- element_validate_*() functions now available to contrib.
+- Added new maintainers for several subsystems.
+- Numerous testing system improvements.
+- Numerous markup and CSS fixes.
+- Numerous poll module fixes.
+- Numerous notice/warning fixes.
+- Numerous documentation fixes.
+- Numerous token fixes.
+
+Drupal 7.7, 2011-07-27
+----------------------
+- Fixed VERSION string.
+
+Drupal 7.6, 2011-07-27
+----------------------
+- Fixed support for remote streamwrappers.
+- AJAX now binds to 'click' instead of 'mousedown'.
+- 'Translatable' flag on fields created in UI now defaults to FALSE, to match those created via the API.
+- Performance enhancement to permissions page on large numbers of permissions.
+- More secure password generation.
+- Fix for temporary directory on Windows servers.
+- run-tests.sh now uses proc_open() instead of pcntl_fork() for better Windows support.
+- Numerous upgrade path fixes.
+- Numerous documentation fixes.
+- Numerous notice fixes.
+- Numerous fixes to improve PHP 5.4 support.
+- Numerous RTL improvements.
+
+Drupal 7.5, 2011-07-27
+----------------------
+- Fixed security issue (Access bypass), see SA-CORE-2011-003.
+
+Drupal 7.4, 2011-06-29
+----------------------
+- Rolled back patch that caused fatal errors in CTools, Feeds, and other modules using the class registry.
+- Fixed critical bug with saving default images.
+- Fixed fatal errors when uninstalling some modules.
+- Added workaround for MySQL transaction support breaking on DDL statments.
+- Improved page caching with external caching systems.
+- Fix to Batch API, which was terminating too early.
+- Numerous upgrade path fixes.
+- Performance fixes.
+- Additional test coverage.
+- Numerous documentation fixes.
+
+Drupal 7.3, 2011-06-29
+----------------------
+- Fixed security issue (Access bypass), see SA-CORE-2011-002.
+
+Drupal 7.2, 2011-05-25
+----------------------
+- Added a default .gitignore file.
+- Improved PostgreSQL and SQLite support.
+- Numerous critical performance improvements.
+- Numerous critical fixes to the upgrade path.
+- Numerous fixes to language and translation systems.
+- Numerous fixes to AJAX and #states systems.
+- Improvements to the locking system.
+- Numerous documentation fixes.
+- Numerous styling and theme system fixes.
+- Numerous fixes for schema mis-matches between Drupal 6 and 7.
+- Minor internal API clean-ups.
+
+Drupal 7.1, 2011-05-25
+----------------------
+- Fixed security issues (Cross site scripting, File access bypass), see SA-CORE-2011-001.
+
+Drupal 7.0, 2011-01-05 
+----------------------
+- Database:
+    * Fully rewritten database layer utilizing PHP 5's PDO abstraction layer.
+    * Drupal now requires MySQL >= 5.0.15 or PostgreSQL >= 8.3.
+    * Added query builders for INSERT, UPDATE, DELETE, MERGE, and SELECT queries.
+    * Support for master/slave replication, transactions, multi-insert queries,
+      and other features.
+    * Added support for the SQLite database engine.
+    * Default to InnoDB engine, rather than MyISAM, on MySQL when available.
+      This offers increased scalability and data integrity.
+- Security:
+    * Protected cron.php -- cron will only run if the proper key is provided.
+    * Implemented a pluggable password system and much stronger password hashes
+      that are compatible with the Portable PHP password hashing framework.
+    * Rate limited login attempts to prevent brute-force password guessing, and
+      improved the flood control API to allow variable time windows and
+      identifiers for limiting user access to resources.
+    * Transformed the "Update status" module into the "Update manager" which
+      can securely install or update modules and themes via a web interface.
+- Usability:
+    * Added contextual links (a.k.a. local tasks) to page elements, such as
+      blocks, nodes, or comments, which allows to perform the most common tasks
+      with a single click only.
+    * Improved installer requirements check.
+    * Improved support for integration of WYSIWYG editors.
+    * Implemented drag-and-drop positioning for input format listings.
+    * Implemented drag-and-drop positioning for language listing.
+    * Implemented drag-and-drop positioning for poll options.
+    * Provided descriptions and human-readable names for user permissions.
+    * Removed comment controls for users.
+    * Removed display order settings for comment module. Comment display
+      order can now be customized using the Views module.
+    * Removed the 'related terms' feature from taxonomy module since this can
+      now be achieved with Field API.
+    * Added additional features to the default installation profile, and
+      implemented a "slimmed down" profile designed for developers.
+    * Added a built-in, automated cron run feature, which is triggered by site
+      visitors.
+    * Added an administrator role which is assigned all permissions for
+      installed modules automatically.
+    * Image toolkits are now provided by modules (rather than requiring a
+      manual file copy to the includes directory).
+    * Added an edit tab to taxonomy term pages.
+    * Redesigned password strength validator.
+    * Redesigned the add content type screen.
+    * Highlight duplicate URL aliases.
+    * Renamed "input formats" to "text formats".
+    * Moved text format permissions to the main permissions page.
+    * Added configurable ability for users to cancel their own accounts.
+    * Added "vertical tabs", a reusable interface component that features
+      automatic summaries and increases usability.
+    * Replaced fieldsets on node edit and add pages with vertical tabs.
+- Performance:
+    * Improved performance on uncached page views by loading multiple core
+      objects in a single database query.
+    * Improved performance for logged-in users by reducing queries for path
+      alias lookups.
+    * Improved support for HTTP proxies (including reverse proxies), allowing
+      anonymous page views to be served entirely from the proxy.
+- Documentation:
+    * Hook API documentation now included in Drupal core.
+- News aggregator:
+    * Added OPML import functionality for RSS feeds.
+    * Optionally, RSS feeds may be configured to not automatically generate feed blocks.
+- Search:
+    * Added support for language-aware searches.
+- Aggregator:
+    * Introduced architecture that allows pluggable parsers and processors for
+      syndicating RSS and Atom feeds.
+    * Added options to suspend updating specific feeds and never discard feeds
+      items.
+- Testing:
+    * Added test framework and tests.
+- Improved time zone support:
+    * Drupal now uses PHP's time zone database when rendering dates in local
+      time. Site-wide and user-configured time zone offsets have been converted
+      to time zone names, e.g. Africa/Abidjan.
+    * In some cases the upgrade and install scripts do not choose the preferred
+      site default time zone. The automatically-selected time zone can be
+      corrected at admin/config/regional/settings.
+    * If your site is being upgraded from Drupal 6 and you do not have the
+      contributed date or event modules installed, user time zone settings will
+      fallback to the system time zone and will have to be reconfigured by each user.
+    * User-configured time zones now serve as the default time zone for PHP
+      date/time functions.
+- Filter system:
+    * Revamped the filter API and text format storage.
+    * Added support for default text formats to be assigned on a per-role basis.
+    * Refactored the HTML corrector to take advantage of PHP 5 features.
+- User system:
+    * Added clean API functions for creating, loading, updating, and deleting
+      user roles and permissions.
+    * Refactored the "access rules" component of user module: The user module
+      now provides a simple interface for blocking single IP addresses. The
+      previous functionality in the user module for restricting certain e-mail
+      addresses and usernames is now available as a contributed module. Further,
+      IP address range blocking is no longer supported and should be implemented
+      at the operating system level.
+    * Removed per-user themes: Contributed modules with similar functionality
+      are available.
+- OpenID:
+    * Added support for Gmail and Google Apps for Domain identifiers. Users can
+      now login with their user@example.com identifier when example.com is powered
+      by Google.
+    * Made the OpenID module more pluggable.
+- Added code registry:
+    * Using the registry, modules declare their includable files via their .info file,
+      allowing Drupal to lazy-load classes and interfaces as needed.
+- Theme system:
+    * Removed the Bluemarine, Chameleon and Pushbutton themes. These themes live
+      on as contributed themes (http://drupal.org/project/bluemarine,
+      http://drupal.org/project/chameleon and http://drupal.org/project/pushbutton).
+    * Added Stark theme to make analyzing Drupal's default HTML and CSS easier.
+    * Added Seven as the default administration theme.
+    * Variable preprocessing of theme hooks prior to template rendering now goes
+      through two phases: a 'preprocess' phase and a new 'process' phase. See
+      http://api.drupal.org/api/function/theme/7 for details.
+    * Theme hooks implemented as functions (rather than as templates) can now
+      also have preprocess (and process) functions. See
+      http://api.drupal.org/api/function/theme/7 for details.
+    * Added Bartik as the default theme.
+- File handling:
+    * Files are now first class Drupal objects with file_load(), file_save(),
+      and file_validate() functions and corresponding hooks.
+    * The file_move(), file_copy() and file_delete() functions now operate on
+      file objects and invoke file hooks so that modules are notified and can
+      respond to changes.
+    * For the occasions when only basic file manipulation are needed--such as
+      uploading a site logo--that don't require the overhead of databases and
+      hooks, the current unmanaged copy, move and delete operations have been
+      preserved but renamed to file_unmanaged_*().
+    * Rewrote file handling to use PHP stream wrappers to enable support for
+      both public and private files and to support pluggable storage mechanisms
+      and access to remote resources (e.g. S3 storage or Flickr photos).
+    * The mime_extension_mapping variable has been removed. Modules that need to
+      alter the default MIME type extension mappings should implement
+      hook_file_mimetype_mapping_alter().
+    * Added the hook_file_url_alter() hook, which makes it possible to serve
+      files from a CDN.
+    * Added a field specifically for uploading files, previously provided by
+      the contributed module FileField.
+- Image handling:
+    * Improved image handling, including better support for add-on image
+      libraries.
+    * Added API and interface for creating advanced image thumbnails.
+    * Inclusion of additional effects such as rotate and desaturate.
+    * Added a field specifically for uploading images, previously provided by
+      the contributed module ImageField.
+- Added aliased multi-site support:
+    * Added support for mapping domain names to sites directories.
+- Added RDF support:
+    * Modules can declare RDF namespaces which are serialized in the  tag
+      for RDFa support.
+    * Modules can specify how their data structure maps to RDF.
+    * Added support for RDFa export of nodes, comments, terms, users, etc. and
+      their fields.
+- Search engine optimization and web linking:
+    * Added a rel="canonical" link on node and comment pages to prevent
+      duplicate content indexing by search engines.
+    * Added a default rel="shortlink" link on node and comment pages that
+      advertises a short link as an alternative URL to third-party services.
+    * Meta information is now alterable by all modules before rendering.
+- Field API:
+    * Custom data fields may be attached to nodes, users, comments and taxonomy
+      terms.
+    * Node bodies and teasers are now Field API fields instead of
+      being a hard-coded property of node objects.
+    * In addition, any other object type may register with Field API
+      and allow custom data fields to be attached to itself.
+    * Provides most of the features of the former Content Construction
+      Kit (CCK) module.
+    * Taxonomy terms are now Field API fields that can be added to any fieldable
+      object.
+- Installer:
+    * Refactored the installer into an API that allows Drupal to be installed
+      via a command line script.
+- Page organization
+    * Made the help text area a full featured region with blocks.
+    * Site mission is replaced with the highlighted content block region and
+      separate RSS feed description settings.
+    * The footer message setting was removed in favor of custom blocks.
+    * Made the main page content a block which can be moved and ordered
+      with other blocks in the same region.
+    * Blocks can now return structured arrays for later rendering just
+      like page callbacks.
+- Translation system
+    * The translation system now supports message context (msgctxt).
+    * Added support for translatable fields to Field API.
+- JavaScript changes
+    * Upgraded the core JavaScript library to jQuery version 1.4.4.
+    * Upgraded the jQuery Forms library to 2.52.
+    * Added jQuery UI 1.8.7, which allows improvements to Drupal's user
+      experience.
+- Better module version support
+    * Modules now can specify which version of another module they depend on.
+- Removed modules from core
+    * The following modules have been removed from core, because contributed
+      modules with similar functionality are available:
+      * Blog API module
+      * Ping module
+      * Throttle module
+- Improved node access control system.
+    * All modules may now influence the access to a node at runtime, not just
+      the module that defined a node.
+    * Users may now be allowed to bypass node access restrictions without giving
+      them complete access to the site.
+    * Access control affects both published and unpublished nodes.
+    * Numerous other improvements to the node access system.
+- Actions system
+    * Simplified definitions of actions and triggers.
+    * Removed dependency on the combination of hooks and operations. Triggers
+      now directly map to module hooks.
+- Task handling
+    * Added a queue API to process many or long-running tasks.
+    * Added queue API support to cron API.
+    * Added a locking framework to coordinate long-running operations across
+      requests.
+
+Drupal 6.23-dev, xxxx-xx-xx (development release)
+-----------------------
+
+Drupal 6.22, 2011-05-25
+-----------------------
+- Made Drupal 6 work better with IIS and Internet Explorer.
+- Fixed .po file imports to work better with custom textgroups.
+- Improved code documentation at various places.
+- Fixed a variety of other bugs.
+
+Drupal 6.21, 2011-05-25
+----------------------
+- Fixed security issues (Cross site scripting), see SA-CORE-2011-001.
+
+Drupal 6.20, 2010-12-15
+----------------------
+- Fixed a variety of small bugs, improved code documentation.
+
+Drupal 6.19, 2010-08-11
+----------------------
+- Fixed a variety of small bugs, improved code documentation.
+
+Drupal 6.18, 2010-08-11
+----------------------
+- Fixed security issues (OpenID authentication bypass, File download access
+  bypass, Comment unpublishing bypass, Actions cross site scripting),
+  see SA-CORE-2010-002.
+
+Drupal 6.17, 2010-06-02
+----------------------
+- Improved PostgreSQL compatibility
+- Better PHP 5.3 and PHP 4 compatibility
+- Better browser compatibility of CSS and JS aggregation
+- Improved logging for login failures
+- Fixed an incompatibility with some contributed modules and the locking system
+- Fixed a variety of other bugs.
+
+Drupal 6.16, 2010-03-03
+----------------------
+- Fixed security issues (Installation cross site scripting, Open redirection,
+  Locale module cross site scripting, Blocked user session regeneration),
+  see SA-CORE-2010-001.
+- Better support for updated jQuery versions.
+- Reduced resource usage of update.module.
+- Fixed several issues relating to support of installation profiles and
+  distributions.
+- Added a locking framework to avoid data corruption on long operations.
+- Fixed a variety of other bugs.
+
+Drupal 6.15, 2009-12-16
+----------------------
+- Fixed security issues (Cross site scripting), see SA-CORE-2009-009.
+- Fixed a variety of other bugs.
+
+Drupal 6.14, 2009-09-16
+----------------------
+- Fixed security issues (OpenID association cross site request forgeries,
+  OpenID impersonation and File upload), see SA-CORE-2009-008.
+- Changed the system modules page to not run all cache rebuilds; use the
+  button on the performance settings page to achieve the same effect.
+- Added support for PHP 5.3.0 out of the box.
+- Fixed a variety of small bugs.
+
+Drupal 6.13, 2009-07-01
+----------------------
+- Fixed security issues (Cross site scripting, Input format access bypass and
+  Password leakage in URL), see SA-CORE-2009-007.
+- Fixed a variety of small bugs.
+
+Drupal 6.12, 2009-05-13
+----------------------
+- Fixed security issues (Cross site scripting), see SA-CORE-2009-006.
+- Fixed a variety of small bugs.
+
+Drupal 6.11, 2009-04-29
+----------------------
+- Fixed security issues (Cross site scripting and limited information
+  disclosure), see SA-CORE-2009-005
+- Fixed performance issues with the menu router cache, the update
+  status cache and improved cache invalidation
+- Fixed a variety of small bugs.
+
+Drupal 6.10, 2009-02-25
+----------------------
+- Fixed a security issue, (Local file inclusion on Windows),
+  see SA-CORE-2009-003
+- Fixed node_feed() so custom fields can show up in RSS feeds.
+- Improved PostgreSQL compatibility.
+- Fixed a variety of small bugs.
+
+Drupal 6.9, 2009-01-14
+----------------------
+- Fixed security issues, (Access Bypass, Validation Bypass and Hardening
+  against SQL injection), see SA-CORE-2009-001
+- Made HTTP request checking more robust and informative.
+- Fixed HTTP_HOST checking to work again with HTTP 1.0 clients and
+  basic shell scripts.
+- Removed t() calls from all schema documentation. Suggested best practice
+  changed for contributed modules, see http://drupal.org/node/322731.
+- Fixed a variety of small bugs.
+
+Drupal 6.8, 2008-12-11
+----------------------
+- Removed a previous change incompatible with PHP 5.1.x and lower.
+
+Drupal 6.7, 2008-12-10
+----------------------
+- Fixed security issues, (Cross site request forgery and Cross site scripting), see SA-2008-073
+- Updated robots.txt and .htaccess to match current file use.
+- Fixed a variety of small bugs.
+
+Drupal 6.6, 2008-10-22
+----------------------
+- Fixed security issues, (File inclusion, Cross site scripting), see SA-2008-067
+- Fixed a variety of small bugs.
+
+Drupal 6.5, 2008-10-08
+----------------------
+- Fixed security issues, (File upload access bypass, Access rules bypass,
+  BlogAPI access bypass), see SA-2008-060.
+- Fixed a variety of small bugs.
+
+Drupal 6.4, 2008-08-13
+----------------------
+- Fixed a security issue (Cross site scripting, Arbitrary file uploads via
+  BlogAPI, Cross site request forgeries and Various Upload module
+  vulnerabilities), see SA-2008-047.
+- Improved error messages during installation.
+- Fixed a bug that prevented AHAH handlers to be attached to radios widgets.
+- Fixed a variety of small bugs.
+
+Drupal 6.3, 2008-07-09
+----------------------
+- Fixed security issues, (Cross site scripting, cross site request forgery,
+  session fixation and SQL injection), see SA-2008-044.
+- Slightly modified installation process to prevent file ownership issues on
+  shared hosts.
+- Improved PostgreSQL compatibility (rewritten queries; custom blocks).
+- Upgraded to jQuery 1.2.6.
+- Performance improvements to search, menu handling and form API caches.
+- Fixed Views compatibility issues (Views for Drupal 6 requires Drupal 6.3+).
+- Fixed a variety of small bugs.
+
+Drupal 6.2, 2008-04-09
+----------------------
+- Fixed a variety of small bugs.
+- Fixed a security issue (Access bypasses), see SA-2008-026.
+
+Drupal 6.1, 2008-02-27
+----------------------
+- Fixed a variety of small bugs.
+- Fixed a security issue (Cross site scripting), see SA-2008-018.
+
+Drupal 6.0, 2008-02-13
+----------------------
+- New, faster and better menu system.
+- New watchdog as a hook functionality.
+   * New hook_watchdog that can be implemented by any module to route log
+     messages to various destinations.
+   * Expands the severity levels from 3 (Error, Warning, Notice) to the 8
+     levels defined in RFC 3164.
+   * The watchdog module is now called dblog, and is optional, but enabled by
+     default in the default installation profile.
+   * Extended the database log module so log messages can be filtered.
+   * Added syslog module: useful for monitoring large Drupal installations.
+- Added optional e-mail notifications when users are approved, blocked, or
+  deleted.
+- Drupal works with error reporting set to E_ALL.
+- Added scripts/drupal.sh to execute Drupal code from the command line. Useful
+  to use Drupal as a framework to build command-line tools.
+- Made signature support optional and made it possible to theme signatures.
+- Made it possible to filter the URL aliases on the URL alias administration
+  screen.
+- Language system improvements:
+    * Support for right to left languages.
+    * Language detection based on parts of the URL.
+    * Browser based language detection.
+    * Made it possible to specify a node's language.
+    * Support for translating posts on the site to different languages.
+    * Language dependent path aliases.
+    * Automatically import translations when adding a new language.
+    * JavaScript interface translation.
+    * Automatically import a module's translation upon enabling that module.
+- Moved "PHP input filter" to a standalone module so it can be deleted for
+  security reasons.
+- Usability:
+    * Improved handling of teasers in posts.
+    * Added sticky table headers.
+    * Check for clean URL support automatically with JavaScript.
+    * Removed default/settings.php. Instead the installer will create it from
+      default.settings.php.
+    * Made it possible to configure your own date formats.
+    * Remember anonymous comment posters.
+    * Only allow modules and themes to be enabled that have explicitly been
+      ported to the correct core API version.
+    * Can now specify the minimum PHP version required for a module within the
+      .info file.
+    * Drupal core no longer requires CREATE TEMPORARY TABLES or LOCK TABLES
+      database rights.
+    * Dynamically check password strength and confirmation.
+    * Refactored poll administration.
+    * Implemented drag-and-drop positioning for blocks, menu items, taxonomy
+      vocabularies and terms, forums, profile fields, and input format filters.
+- Theme system:
+    * Added .info files to themes and made it easier to specify regions and
+      features.
+    * Added theme registry: modules can directly provide .tpl.php files for
+      their themes without having to create theme_ functions.
+    * Used the Garland theme for the installation and maintenance pages.
+    * Added theme preprocess functions for themes that are templates.
+    * Added support for themeable functions in JavaScript.
+- Refactored update.php to a generic batch API to be able to run time-consuming
+  operations in multiple subsequent HTTP requests.
+- Installer:
+    * Themed the installer with the Garland theme.
+    * Added form to provide initial site information during installation.
+    * Added ability to provide extra installation steps programmatically.
+    * Made it possible to import interface translations during installation.
+- Added the HTML corrector filter:
+    * Fixes faulty and chopped off HTML in postings.
+    * Tags are now automatically closed at the end of the teaser.
+- Performance:
+    * Made it easier to conditionally load .include files and split up many core
+      modules.
+    * Added a JavaScript aggregator.
+    * Added block-level caching, improving performance for both authenticated
+      and anonymous users.
+    * Made Drupal work correctly when running behind a reverse proxy like
+      Squid or Pound.
+- File handling improvements:
+    * Entries in the files table are now keyed to a user instead of a node.
+    * Added reusable validation functions to check for uploaded file sizes,
+      extensions, and image resolution.
+    * Added ability to create and remove temporary files during a cron job.
+- Forum improvements:
+    * Any node type may now be posted in a forum.
+- Taxonomy improvements:
+    * Descriptions for terms are now shown on taxonomy/term pages as well
+      as RSS feeds.
+    * Added versioning support to categories by associating them with node
+      revisions.
+- Added support for OpenID.
+- Added support for triggering configurable actions.
+- Added the Update status module to automatically check for available updates
+  and warn sites if they are missing security updates or newer versions.
+  Sites deploying from CVS should use http://drupal.org/project/cvs_deploy.
+  Advanced settings provided by http://drupal.org/project/update_advanced.
+- Upgraded the core JavaScript library to jQuery version 1.2.3.
+- Added a new Schema API, which provides built-in support for core and
+  contributed modules to work with databases other than MySQL.
+- Removed drupal.module. The functionality lives on as the Site network
+  contributed module (http://drupal.org/project/site_network).
+- Removed old system updates. Updates from Drupal versions prior to 5.x will
+  require upgrading to 5.x before upgrading to 6.x.
+
+Drupal 5.23, 2010-08-11
+-----------------------
+- Fixed security issues (File download access bypass, Comment unpublishing
+  bypass), see SA-CORE-2010-002.
+
+Drupal 5.22, 2010-03-03
+-----------------------
+- Fixed security issues (Open redirection, Locale module cross site scripting,
+  Blocked user session regeneration), see SA-CORE-2010-001.
+
+Drupal 5.21, 2009-12-16
+-----------------------
+- Fixed a security issue (Cross site scripting), see SA-CORE-2009-009.
+- Fixed a variety of small bugs.
+
+Drupal 5.20, 2009-09-16
+-----------------------
+- Avoid security problems resulting from writing Drupal 6-style menu
+  declarations.
+- Fixed security issues (session fixation), see SA-CORE-2009-008.
+- Fixed a variety of small bugs.
+
+Drupal 5.19, 2009-07-01
+-----------------------
+- Fixed security issues (Cross site scripting and Password leakage in URL), see
+  SA-CORE-2009-007.          
+- Fixed a variety of small bugs.
+
+Drupal 5.18, 2009-05-13
+-----------------------
+- Fixed security issues (Cross site scripting), see SA-CORE-2009-006.
+- Fixed a variety of small bugs.
+
+Drupal 5.17, 2009-04-29
+-----------------------
+- Fixed security issues (Cross site scripting and limited information
+  disclosure) see SA-CORE-2009-005.
+- Fixed a variety of small bugs.
+
+Drupal 5.16, 2009-02-25
+-----------------------
+- Fixed a security issue, (Local file inclusion on Windows), see SA-CORE-2009-004.
+- Fixed a variety of small bugs.
+
+Drupal 5.15, 2009-01-14
+-----------------------
+- Fixed security issues, (Hardening against SQL injection), see
+  SA-CORE-2009-001
+- Fixed HTTP_HOST checking to work again with HTTP 1.0 clients and basic shell
+  scripts.
+- Fixed a variety of small bugs.
+
+Drupal 5.14, 2008-12-11
+-----------------------
+- removed a previous change incompatible with PHP 5.1.x and lower.
+
+Drupal 5.13, 2008-12-10
+-----------------------
+- fixed a variety of small bugs.
+- fixed security issues, (Cross site request forgery and Cross site scripting), see SA-2008-073
+- updated robots.txt and .htaccess to match current file use.
+
+Drupal 5.12, 2008-10-22
+-----------------------
+- fixed security issues, (File inclusion), see SA-2008-067
+
+Drupal 5.11, 2008-10-08
+-----------------------
+- fixed a variety of small bugs.
+- fixed security issues, (File upload access bypass, Access rules bypass,
+  BlogAPI access bypass, Node validation bypass), see SA-2008-060
+
+Drupal 5.10, 2008-08-13
+-----------------------
+- fixed a variety of small bugs.
+- fixed security issues, (Cross site scripting, Arbitrary file uploads via
+  BlogAPI and Cross site request forgery), see SA-2008-047
+
+Drupal 5.9, 2008-07-23
+----------------------
+- fixed a variety of small bugs.
+- fixed security issues, (Session fixation), see SA-2008-046
+
+Drupal 5.8, 2008-07-09
+----------------------
+- fixed a variety of small bugs.
+- fixed security issues, (Cross site scripting, cross site request forgery, and
+  session fixation), see SA-2008-044
+
+Drupal 5.7, 2008-01-28
+----------------------
+- fixed the input format configuration page.
+- fixed a variety of small bugs.
+
+Drupal 5.6, 2008-01-10
+----------------------
+- fixed a variety of small bugs.
+- fixed a security issue (Cross site request forgery), see SA-2008-005
+- fixed a security issue (Cross site scripting, UTF8), see SA-2008-006
+- fixed a security issue (Cross site scripting, register_globals), see SA-2008-007
+
+Drupal 5.5, 2007-12-06
+----------------------
+- fixed missing missing brackets in a query in the user module.
+- fixed taxonomy feed bug introduced by SA-2007-031
+
+Drupal 5.4, 2007-12-05
+----------------------
+- fixed a variety of small bugs.
+- fixed a security issue (SQL injection), see SA-2007-031
+
+Drupal 5.3, 2007-10-17
+----------------------
+- fixed a variety of small bugs.
+- fixed a security issue (HTTP response splitting), see SA-2007-024
+- fixed a security issue (Arbitrary code execution via installer), see SA-2007-025
+- fixed a security issue (Cross site scripting via uploads), see SA-2007-026
+- fixed a security issue (User deletion cross site request forgery), see SA-2007-029
+- fixed a security issue (API handling of unpublished comment), see SA-2007-030
+
+Drupal 5.2, 2007-07-26
+----------------------
+- changed hook_link() $teaser argument to match documentation.
+- fixed a variety of small bugs.
+- fixed a security issue (cross-site request forgery), see SA-2007-017
+- fixed a security issue (cross-site scripting), see SA-2007-018
+
+Drupal 5.1, 2007-01-29
+----------------------
+- fixed security issue (code execution), see SA-2007-005
+- fixed a variety of small bugs.
+
+Drupal 5.0, 2007-01-15
+----------------------
+- Completely retooled the administration page
+    * /Admin now contains an administration page which may be themed
+    * Reorganised administration menu items by task and by module
+    * Added a status report page with detailed PHP/MySQL/Drupal information
+- Added web-based installer which can:
+    * Check installation and run-time requirements
+    * Automatically generate the database configuration file
+    * Install pre-made installation profiles or distributions
+    * Import the database structure with automatic table prefixing
+    * Be localized
+- Added new default Garland theme
+- Added color module to change some themes' color schemes
+- Included the jQuery JavaScript library 1.0.4 and converted all core JavaScript to use it
+- Introduced the ability to alter mail sent from system
+- Module system:
+    * Added .info files for module meta-data
+    * Added support for module dependencies
+    * Improved module installation screen
+    * Moved core modules to their own directories
+    * Added support for module uninstalling
+- Added support for different cache backends
+- Added support for a generic "sites/all" directory.
+- Usability:
+    * Added support for auto-complete forms (AJAX) to user profiles.
+    * Made it possible to instantly assign roles to newly created user accounts.
+    * Improved configurability of the contact forms.
+    * Reorganized the settings pages.
+    * Made it easy to investigate popular search terms.
+    * Added a 'select all' checkbox and a range select feature to administration tables.
+    * Simplified the 'break' tag to split teasers from body.
+    * Use proper capitalization for titles, menu items and operations.
+- Integrated urlfilter.module into filter.module
+- Block system:
+    * Extended the block visibility settings with a role specific setting.
+    * Made it possible to customize all block titles.
+- Poll module:
+    * Optionally allow people to inspect all votes.
+    * Optionally allow people to cancel their vote.
+- Distributed authentication:
+    * Added default server option.
+- Added default robots.txt to control crawlers.
+- Database API:
+    * Added db_table_exists().
+- Blogapi module:
+    * 'Blogapi new' and 'blogapi edit' nodeapi operations.
+- User module:
+    * Added hook_profile_alter().
+    * E-mail verification is made optional.
+    * Added mass editing and filtering on admin/user/user.
+- PHP Template engine:
+    * Add the ability to look for a series of suggested templates.
+    * Look for page templates based upon the path.
+    * Look for block templates based upon the region, module, and delta.
+- Content system:
+    * Made it easier for node access modules to work well with each other.
+    * Added configurable content types.
+    * Changed node rendering to work with structured arrays.
+- Performance:
+    * Improved session handling: reduces database overhead.
+    * Improved access checking: reduces database overhead.
+    * Made it possible to do memcached based session management.
+    * Omit sidebars when serving a '404 - Page not found': saves CPU cycles and bandwidth.
+    * Added an 'aggressive' caching policy.
+    * Added a CSS aggregator and compressor (up to 40% faster page loads).
+- Removed the archive module.
+- Upgrade system:
+    * Created space for update branches.
+- Form API:
+    * Made it possible to programmatically submit forms.
+    * Improved api for multistep forms.
+- Theme system:
+    * Split up and removed drupal.css.
+    * Added nested lists generation.
+    * Added a self-clearing block class.
+
+Drupal 4.7.11, 2008-01-10
+-------------------------
+- fixed a security issue (Cross site request forgery), see SA-2008-005
+- fixed a security issue (Cross site scripting, UTF8), see SA-2008-006
+- fixed a security issue (Cross site scripting, register_globals), see SA-2008-007
+
+Drupal 4.7.10, 2007-12-06
+-------------------------
+- fixed taxonomy feed bug introduced by SA-2007-031
+
+Drupal 4.7.9, 2007-12-05
+------------------------
+- fixed a security issue (SQL injection), see SA-2007-031
+
+Drupal 4.7.8, 2007-10-17
+----------------------
+- fixed a security issue (HTTP response splitting), see SA-2007-024
+- fixed a security issue (Cross site scripting via uploads), see SA-2007-026
+- fixed a security issue (API handling of unpublished comment), see SA-2007-030
+
+Drupal 4.7.7, 2007-07-26
+------------------------
+- fixed security issue (XSS), see SA-2007-018
+
+Drupal 4.7.6, 2007-01-29
+------------------------
+- fixed security issue (code execution), see SA-2007-005
+
+Drupal 4.7.5, 2007-01-05
+------------------------
+- Fixed security issue (XSS), see SA-2007-001
+- Fixed security issue (DoS), see SA-2007-002
+
+Drupal 4.7.4, 2006-10-18
+------------------------
+- Fixed security issue (XSS), see SA-2006-024
+- Fixed security issue (CSRF), see SA-2006-025
+- Fixed security issue (Form action attribute injection), see SA-2006-026
+
+Drupal 4.7.3, 2006-08-02
+------------------------
+- Fixed security issue (XSS), see SA-2006-011
+
+Drupal 4.7.2, 2006-06-01
+------------------------
+- Fixed critical upload issue, see SA-2006-007
+- Fixed taxonomy XSS issue, see SA-2006-008
+- Fixed a variety of small bugs.
+
+Drupal 4.7.1, 2006-05-24
+------------------------
+- Fixed critical SQL issue, see SA-2006-005
+- Fixed a serious upgrade related bug.
+- Fixed a variety of small bugs.
+
+Drupal 4.7.0, 2006-05-01
+------------------------
+- Added free tagging support.
+- Added a site-wide contact form.
+- Theme system:
+    * Added the PHPTemplate theme engine and removed the Xtemplate engine.
+    * Converted the bluemarine theme from XTemplate to PHPTemplate.
+    * Converted the pushbutton theme from XTemplate to PHPTemplate.
+- Usability:
+    * Reworked the 'request new password' functionality.
+    * Reworked the node and comment edit forms.
+    * Made it easy to add nodes to the navigation menu.
+    * Added site 'offline for maintenance' feature.
+    * Added support for auto-complete forms (AJAX).
+    * Added support for collapsible page sections (JS).
+    * Added support for resizable text fields (JS).
+    * Improved file upload functionality (AJAX).
+    * Reorganized some settings pages.
+    * Added friendly database error screens.
+    * Improved styling of update.php.
+- Refactored the forms API.
+    * Made it possible to alter, extend or theme forms.
+- Comment system:
+    * Added support for "mass comment operations" to ease repetitive tasks.
+    * Comment moderation has been removed.
+- Node system:
+    * Reworked the revision functionality.
+    * Removed the bookmarklet code. Third-party modules can now handle
+      This.
+- Upgrade system:
+    * Allows contributed modules to plug into the upgrade system.
+- Profiles:
+    * Added a block to display author information along with posts.
+    * Added support for private profile fields.
+- Statistics module:
+    * Added the ability to track page generation times.
+    * Made it possible to block certain IPs/hostnames.
+- Block system:
+    * Added support for theme-specific block regions.
+- Syndication:
+    * Made the aggregator module parse Atom feeds.
+    * Made the aggregator generate RSS feeds.
+    * Added RSS feed settings.
+- XML-RPC:
+    * Replaced the XML-RPC library by a better one.
+- Performance:
+    * Added 'loose caching' option for high-traffic sites.
+    * Improved performance of path aliasing.
+    * Added the ability to track page generation times.
+- Internationalization:
+    * Improved Unicode string handling API.
+    * Added support for PHP's multibyte string module.
+- Added support for PHP5's 'mysqli' extension.
+- Search module:
+    * Made indexer smarter and more robust.
+    * Added advanced search operators (e.g. phrase, node type, ...).
+    * Added customizable result ranking.
+- PostgreSQL support:
+    * Removed dependency on PL/pgSQL procedural language.
+- Menu system:
+    * Added support for external URLs.
+- Queue module:
+    * Removed from core.
+- HTTP handling:
+    * Added support for a tolerant Base URL.
+    * Output URIs relative to the root, without a base tag.
+
+Drupal 4.6.11, 2007-01-05
+-------------------------
+- Fixed security issue (XSS), see SA-2007-001
+- Fixed security issue (DoS), see SA-2007-002
+
+Drupal 4.6.10, 2006-10-18
+------------------------
+- Fixed security issue (XSS), see SA-2006-024
+- Fixed security issue (CSRF), see SA-2006-025
+- Fixed security issue (Form action attribute injection), see SA-2006-026
+
+Drupal 4.6.9, 2006-08-02
+------------------------
+- Fixed security issue (XSS), see SA-2006-011
+
+Drupal 4.6.8, 2006-06-01
+------------------------
+- Fixed critical upload issue, see SA-2006-007
+- Fixed taxonomy XSS issue, see SA-2006-008
+
+Drupal 4.6.7, 2006-05-24
+------------------------
+- Fixed critical SQL issue, see SA-2006-005
+
+Drupal 4.6.6, 2006-03-13
+------------------------
+- Fixed bugs, including 4 security vulnerabilities.
+
+Drupal 4.6.5, 2005-12-12
+------------------------
+- Fixed bugs: no critical bugs were identified.
+
+Drupal 4.6.4, 2005-11-30
+------------------------
+- Fixed bugs, including 3 security vulnerabilities.
+
+Drupal 4.6.3, 2005-08-15
+------------------------
+- Fixed bugs, including a critical "arbitrary PHP code execution" bug.
+
+Drupal 4.6.2, 2005-06-29
+------------------------
+- Fixed bugs, including two critical "arbitrary PHP code execution" bugs.
+
+Drupal 4.6.1, 2005-06-01
+------------------------
+- Fixed bugs, including a critical input validation bug.
+
+Drupal 4.6.0, 2005-04-15
+------------------------
+- PHP5 compliance
+- Search:
+    * Added UTF-8 support to make it work with all languages.
+    * Improved search indexing algorithm.
+    * Improved search output.
+    * Impose a throttle on indexing of large sites.
+    * Added search block.
+- Syndication:
+    * Made the ping module ping pingomatic.com which, in turn, will ping all the major ping services.
+    * Made Drupal generate RSS 2.0 feeds.
+    * Made RSS feeds extensible.
+    * Added categories to RSS feeds.
+    * Added enclosures to RSS feeds.
+- Flood control mechanism:
+    * Added a mechanism to throttle certain operations.
+- Usability:
+    * Refactored the block configuration pages.
+    * Refactored the statistics pages.
+    * Refactored the watchdog pages.
+    * Refactored the throttle module configuration.
+    * Refactored the access rules page.
+    * Refactored the content administration page.
+    * Introduced forum configuration pages.
+    * Added a 'add child page' link to book pages.
+- Contact module:
+    * Added a simple contact module that allows users to contact each other using e-mail.
+- Multi-site configuration:
+    * Made it possible to run multiple sites from a single code base.
+- Added an image API: enables better image handling.
+- Block system:
+    * Extended the block visibility settings.
+- Theme system:
+    * Added new theme functions.
+- Database backend:
+    * The PEAR database backend is no longer supported.
+- Performance:
+    * Improved performance of the forum topics block.
+    * Improved performance of the tracker module.
+    * Improved performance of the node pages.
+- Documentation:
+    * Improved and extended PHPDoc/Doxygen comments.
+
+Drupal 4.5.8, 2006-03-13
+------------------------
+- Fixed bugs, including 3 security vulnerabilities.
+
+Drupal 4.5.7, 2005-12-12
+------------------------
+- Fixed bugs: no critical bugs were identified.
+
+Drupal 4.5.6, 2005-11-30
+------------------------
+- Fixed bugs, including 3 security vulnerabilities.
+
+Drupal 4.5.5, 2005-08-15
+------------------------
+- Fixed bugs, including a critical "arbitrary PHP code execution" bug.
+
+Drupal 4.5.4, 2005-06-29
+------------------------
+- Fixed bugs, including two critical "arbitrary PHP code execution" bugs.
+
+Drupal 4.5.3, 2005-06-01
+------------------------
+- Fixed bugs, including a critical input validation bug.
+
+Drupal 4.5.2, 2005-01-15
+------------------------
+- Fixed bugs: a cross-site scripting (XSS) vulnerability has been fixed.
+
+Drupal 4.5.1, 2004-12-01
+------------------------
+- Fixed bugs: no critical bugs were identified.
+
+Drupal 4.5.0, 2004-10-18
+------------------------
+- Navigation:
+    * Made it possible to add, delete, rename and move menu items.
+    * Introduced tabs and subtabs for local tasks.
+    * Reorganized the navigation menus.
+- User management:
+    * Added support for multiple roles per user.
+    * Made it possible to add custom profile fields.
+    * Made it possible to browse user profiles by field.
+- Node system:
+    * Added support for node-level permissions.
+- Comment module:
+    * Made it possible to leave contact information without having to register.
+- Upload module:
+    * Added support for uploading documents (includes images).
+- Forum module:
+    * Added support for sticky forum topics.
+    * Made it possible to track forum topics.
+- Syndication:
+    * Added support for RSS ping-notifications of http://technorati.com/.
+    * Refactored the categorization of syndicated news items.
+    * Added an URL alias for 'rss.xml'.
+    * Improved date parsing.
+- Database backend:
+    * Added support for multiple database connections.
+    * The PostgreSQL backend does no longer require PEAR.
+- Theme system:
+    * Changed all GIFs to PNGs.
+    * Reorganised the handling of themes, template engines, templates and styles.
+    * Unified and extended the available theme settings.
+    * Added theme screenshots.
+- Blocks:
+    * Added 'recent comments' block.
+    * Added 'categories' block.
+- Blogger API:
+    * Added support for auto-discovery of blogger API via RSD.
+- Performance:
+    * Added support for sending gzip compressed pages.
+    * Improved performance of the forum module.
+- Accessibility:
+    * Improved the accessibility of the archive module's calendar.
+    * Improved form handling and error reporting.
+    * Added HTTP redirects to prevent submitting twice when refreshing right after a form submission.
+- Refactored 403 (forbidden) handling and added support for custom 403 pages.
+- Documentation:
+    * Added PHPDoc/Doxygen comments.
+- Filter system:
+    * Added support for using multiple input formats on the site
+    * Expanded the embedded PHP-code feature so it can be used everywhere
+    * Added support for role-dependent filtering, through input formats
+- UI translation:
+    * Managing translations is now completely done through the administration interface
+    * Added support for importing/exporting gettext .po files
+
+Drupal 4.4.3, 2005-06-01
+------------------------
+- Fixed bugs, including a critical input validation bug.
+
+Drupal 4.4.2, 2004-07-04
+------------------------
+- Fixed bugs: no critical bugs were identified.
+
+Drupal 4.4.1, 2004-05-01
+------------------------
+- Fixed bugs: no critical bugs were identified.
+
+Drupal 4.4.0, 2004-04-01
+------------------------
+- Added support for the MetaWeblog API and MovableType extensions.
+- Added a file API: enables better document management.
+- Improved the watchdog and search module to log search keys.
+- News aggregator:
+    * Added support for conditional GET.
+    * Added OPML feed subscription list.
+    * Added support for , , , ,  and .
+- Comment module:
+    * Made it possible to disable the "comment viewing controls".
+- Performance:
+    * Improved module loading when serving cached pages.
+    * Made it possible to automatically disable modules when under heavy load.
+    * Made it possible to automatically disable blocks when under heavy load.
+    * Improved performance and memory footprint of the locale module.
+- Theme system:
+    * Made all theme functions start with 'theme_'.
+    * Made all theme functions return their output.
+    * Migrated away from using the BaseTheme class.
+    * Added many new theme functions and refactored existing theme functions.
+    * Added avatar support to 'Xtemplate'.
+    * Replaced theme 'UnConeD' by 'Chameleon'.
+    * Replaced theme 'Marvin' by 'Pushbutton'.
+- Usability:
+    * Added breadcrumb navigation to all pages.
+    * Made it possible to add context-sensitive help to all pages.
+    * Replaced drop-down menus by radio buttons where appropriate.
+    * Removed the 'magic_quotes_gpc = 0' requirement.
+    * Added a 'book navigation' block.
+- Accessibility:
+    * Made themes degrade gracefully in absence of CSS.
+    * Grouped form elements using '
' and '' tags. + * Added '
'; ?> + * @endcode + * + * @see template_preprocess() + * @see template_preprocess_search_result() + * @see template_process() + * + * @ingroup themeable + */ +?> +
  • > + +

    > + +

    + +
    + +

    >

    + + +

    + +
    +
  • diff --git a/drupal-dev/modules/search/search-results.tpl.php b/drupal-dev/modules/search/search-results.tpl.php new file mode 100644 index 0000000..aa9bf8d --- /dev/null +++ b/drupal-dev/modules/search/search-results.tpl.php @@ -0,0 +1,35 @@ + + +

    +
      + +
    + + +

    + + diff --git a/drupal-dev/modules/search/search-rtl.css b/drupal-dev/modules/search/search-rtl.css new file mode 100644 index 0000000..da9e8d9 --- /dev/null +++ b/drupal-dev/modules/search/search-rtl.css @@ -0,0 +1,13 @@ + +.search-advanced .criterion { + float: right; + margin-right: 0; + margin-left: 2em; +} +.search-advanced .action { + float: right; + clear: right; +} +.search-results .search-snippet-info { + padding-right: 1em; /* LTR */ +} \ No newline at end of file diff --git a/drupal-dev/modules/search/search.admin.inc b/drupal-dev/modules/search/search.admin.inc new file mode 100644 index 0000000..a609485 --- /dev/null +++ b/drupal-dev/modules/search/search.admin.inc @@ -0,0 +1,186 @@ + $info) { + $names[$module] = $system_info[$module]['name']; + } + asort($names, SORT_STRING); + return $names; +} + +/** + * Menu callback: displays the search module settings page. + * + * @ingroup forms + * + * @see search_admin_settings_validate() + * @see search_admin_settings_submit() + * @see search_admin_reindex_submit() + */ +function search_admin_settings($form) { + // Collect some stats + $remaining = 0; + $total = 0; + foreach (variable_get('search_active_modules', array('node', 'user')) as $module) { + if ($status = module_invoke($module, 'search_status')) { + $remaining += $status['remaining']; + $total += $status['total']; + } + } + + $count = format_plural($remaining, 'There is 1 item left to index.', 'There are @count items left to index.'); + $percentage = ((int)min(100, 100 * ($total - $remaining) / max(1, $total))) . '%'; + $status = '

    ' . t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) . ' ' . $count . '

    '; + $form['status'] = array('#type' => 'fieldset', '#title' => t('Indexing status')); + $form['status']['status'] = array('#markup' => $status); + $form['status']['wipe'] = array('#type' => 'submit', '#value' => t('Re-index site'), '#submit' => array('search_admin_reindex_submit')); + + $items = drupal_map_assoc(array(10, 20, 50, 100, 200, 500)); + + // Indexing throttle: + $form['indexing_throttle'] = array( + '#type' => 'fieldset', + '#title' => t('Indexing throttle') + ); + $form['indexing_throttle']['search_cron_limit'] = array( + '#type' => 'select', + '#title' => t('Number of items to index per cron run'), + '#default_value' => variable_get('search_cron_limit', 100), + '#options' => $items, + '#description' => t('The maximum number of items indexed in each pass of a cron maintenance task. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status'))) + ); + // Indexing settings: + $form['indexing_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Indexing settings') + ); + $form['indexing_settings']['info'] = array( + '#markup' => t('

    Changing the settings below will cause the site index to be rebuilt. The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed.

    The default settings should be appropriate for the majority of sites.

    ') + ); + $form['indexing_settings']['minimum_word_size'] = array( + '#type' => 'textfield', + '#title' => t('Minimum word length to index'), + '#default_value' => variable_get('minimum_word_size', 3), + '#size' => 5, + '#maxlength' => 3, + '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).'), + '#element_validate' => array('element_validate_integer_positive'), + ); + $form['indexing_settings']['overlap_cjk'] = array( + '#type' => 'checkbox', + '#title' => t('Simple CJK handling'), + '#default_value' => variable_get('overlap_cjk', TRUE), + '#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.') + ); + + $form['active'] = array( + '#type' => 'fieldset', + '#title' => t('Active search modules') + ); + $module_options = _search_get_module_names(); + $form['active']['search_active_modules'] = array( + '#type' => 'checkboxes', + '#title' => t('Active modules'), + '#title_display' => 'invisible', + '#default_value' => variable_get('search_active_modules', array('node', 'user')), + '#options' => $module_options, + '#description' => t('Choose which search modules are active from the available modules.') + ); + $form['active']['search_default_module'] = array( + '#title' => t('Default search module'), + '#type' => 'radios', + '#default_value' => variable_get('search_default_module', 'node'), + '#options' => $module_options, + '#description' => t('Choose which search module is the default.') + ); + $form['#validate'][] = 'search_admin_settings_validate'; + $form['#submit'][] = 'search_admin_settings_submit'; + + // Per module settings + foreach (variable_get('search_active_modules', array('node', 'user')) as $module) { + $added_form = module_invoke($module, 'search_admin'); + if (is_array($added_form)) { + $form = array_merge($form, $added_form); + } + } + + return system_settings_form($form); +} + +/** + * Form validation handler for search_admin_settings(). + */ +function search_admin_settings_validate($form, &$form_state) { + // Check whether we selected a valid default. + if ($form_state['triggering_element']['#value'] != t('Reset to defaults')) { + $new_modules = array_filter($form_state['values']['search_active_modules']); + $default = $form_state['values']['search_default_module']; + if (!in_array($default, $new_modules, TRUE)) { + form_set_error('search_default_module', t('Your default search module is not selected as an active module.')); + } + } +} + +/** + * Form submission handler for search_admin_settings(). + */ +function search_admin_settings_submit($form, &$form_state) { + // If these settings change, the index needs to be rebuilt. + if ((variable_get('minimum_word_size', 3) != $form_state['values']['minimum_word_size']) || + (variable_get('overlap_cjk', TRUE) != $form_state['values']['overlap_cjk'])) { + drupal_set_message(t('The index will be rebuilt.')); + search_reindex(); + } + $current_modules = variable_get('search_active_modules', array('node', 'user')); + // Check whether we are resetting the values. + if ($form_state['triggering_element']['#value'] == t('Reset to defaults')) { + $new_modules = array('node', 'user'); + } + else { + $new_modules = array_filter($form_state['values']['search_active_modules']); + } + if (array_diff($current_modules, $new_modules)) { + drupal_set_message(t('The active search modules have been changed.')); + variable_set('menu_rebuild_needed', TRUE); + } +} + +/** + * Form submission handler for reindex button on search_admin_settings_form(). + */ +function search_admin_reindex_submit($form, &$form_state) { + // send the user to the confirmation page + $form_state['redirect'] = 'admin/config/search/settings/reindex'; +} diff --git a/drupal-dev/modules/search/search.api.php b/drupal-dev/modules/search/search.api.php new file mode 100644 index 0000000..62d53b8 --- /dev/null +++ b/drupal-dev/modules/search/search.api.php @@ -0,0 +1,376 @@ + 'Content', + 'path' => 'node', + 'conditions_callback' => 'callback_search_conditions', + ); +} + +/** + * Define access to a custom search routine. + * + * This hook allows a module to define permissions for a search tab. + * + * @ingroup search + */ +function hook_search_access() { + return user_access('access content'); +} + +/** + * Take action when the search index is going to be rebuilt. + * + * Modules that use hook_update_index() should update their indexing + * bookkeeping so that it starts from scratch the next time + * hook_update_index() is called. + * + * @ingroup search + */ +function hook_search_reset() { + db_update('search_dataset') + ->fields(array('reindex' => REQUEST_TIME)) + ->condition('type', 'node') + ->execute(); +} + +/** + * Report the status of indexing. + * + * The core search module only invokes this hook on active modules. + * Implementing modules do not need to check whether they are active when + * calculating their return values. + * + * @return + * An associative array with the key-value pairs: + * - 'remaining': The number of items left to index. + * - 'total': The total number of items to index. + * + * @ingroup search + */ +function hook_search_status() { + $total = db_query('SELECT COUNT(*) FROM {node} WHERE status = 1')->fetchField(); + $remaining = db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.sid IS NULL OR d.reindex <> 0")->fetchField(); + return array('remaining' => $remaining, 'total' => $total); +} + +/** + * Add elements to the search settings form. + * + * @return + * Form array for the Search settings page at admin/config/search/settings. + * + * @ingroup search + */ +function hook_search_admin() { + // Output form for defining rank factor weights. + $form['content_ranking'] = array( + '#type' => 'fieldset', + '#title' => t('Content ranking'), + ); + $form['content_ranking']['#theme'] = 'node_search_admin'; + $form['content_ranking']['info'] = array( + '#value' => '' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '' + ); + + // Note: reversed to reflect that higher number = higher ranking. + $options = drupal_map_assoc(range(0, 10)); + foreach (module_invoke_all('ranking') as $var => $values) { + $form['content_ranking']['factors']['node_rank_' . $var] = array( + '#title' => $values['title'], + '#type' => 'select', + '#options' => $options, + '#default_value' => variable_get('node_rank_' . $var, 0), + ); + } + return $form; +} + +/** + * Execute a search for a set of key words. + * + * Use database API with the 'PagerDefault' query extension to perform your + * search. + * + * If your module uses hook_update_index() and search_index() to index its + * items, use table 'search_index' aliased to 'i' as the main table in your + * query, with the 'SearchQuery' extension. You can join to your module's table + * using the 'i.sid' field, which will contain the $sid values you provided to + * search_index(). Add the main keywords to the query by using method + * searchExpression(). The functions search_expression_extract() and + * search_expression_insert() may also be helpful for adding custom search + * parameters to the search expression. + * + * See node_search_execute() for an example of a module that uses the search + * index, and user_search_execute() for an example that doesn't use the search + * index. + * + * @param $keys + * The search keywords as entered by the user. + * @param $conditions + * An optional array of additional conditions, such as filters. + * + * @return + * An array of search results. To use the default search result + * display, each item should have the following keys': + * - 'link': Required. The URL of the found item. + * - 'type': The type of item (such as the content type). + * - 'title': Required. The name of the item. + * - 'user': The author of the item. + * - 'date': A timestamp when the item was last modified. + * - 'extra': An array of optional extra information items. + * - 'snippet': An excerpt or preview to show with the result (can be + * generated with search_excerpt()). + * - 'language': Language code for the item (usually two characters). + * + * @ingroup search + */ +function hook_search_execute($keys = NULL, $conditions = NULL) { + // Build matching conditions + $query = db_select('search_index', 'i', array('target' => 'slave'))->extend('SearchQuery')->extend('PagerDefault'); + $query->join('node', 'n', 'n.nid = i.sid'); + $query + ->condition('n.status', 1) + ->addTag('node_access') + ->searchExpression($keys, 'node'); + + // Insert special keywords. + $query->setOption('type', 'n.type'); + $query->setOption('language', 'n.language'); + if ($query->setOption('term', 'ti.tid')) { + $query->join('taxonomy_index', 'ti', 'n.nid = ti.nid'); + } + // Only continue if the first pass query matches. + if (!$query->executeFirstPass()) { + return array(); + } + + // Add the ranking expressions. + _node_rankings($query); + + // Load results. + $find = $query + ->limit(10) + ->execute(); + $results = array(); + foreach ($find as $item) { + // Build the node body. + $node = node_load($item->sid); + node_build_content($node, 'search_result'); + $node->body = drupal_render($node->content); + + // Fetch comments for snippet. + $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node); + // Fetch terms for snippet. + $node->rendered .= ' ' . module_invoke('taxonomy', 'node_update_index', $node); + + $extra = module_invoke_all('node_search_result', $node); + + $results[] = array( + 'link' => url('node/' . $item->sid, array('absolute' => TRUE)), + 'type' => check_plain(node_type_get_name($node)), + 'title' => $node->title, + 'user' => theme('username', array('account' => $node)), + 'date' => $node->changed, + 'node' => $node, + 'extra' => $extra, + 'score' => $item->calculated_score, + 'snippet' => search_excerpt($keys, $node->body), + ); + } + return $results; +} + +/** + * Override the rendering of search results. + * + * A module that implements hook_search_info() to define a type of search may + * implement this hook in order to override the default theming of its search + * results, which is otherwise themed using theme('search_results'). + * + * Note that by default, theme('search_results') and theme('search_result') + * work together to create an ordered list (OL). So your hook_search_page() + * implementation should probably do this as well. + * + * @param $results + * An array of search results. + * + * @return + * A renderable array, which will render the formatted search results with a + * pager included. + * + * @see search-result.tpl.php + * @see search-results.tpl.php + */ +function hook_search_page($results) { + $output['prefix']['#markup'] = '
      '; + + foreach ($results as $entry) { + $output[] = array( + '#theme' => 'search_result', + '#result' => $entry, + '#module' => 'my_module_name', + ); + } + $output['suffix']['#markup'] = '
    ' . theme('pager'); + + return $output; +} + +/** + * Preprocess text for search. + * + * This hook is called to preprocess both the text added to the search index and + * the keywords users have submitted for searching. + * + * Possible uses: + * - Adding spaces between words of Chinese or Japanese text. + * - Stemming words down to their root words to allow matches between, for + * instance, walk, walked, walking, and walks in searching. + * - Expanding abbreviations and acronymns that occur in text. + * + * @param $text + * The text to preprocess. This is a single piece of plain text extracted + * from between two HTML tags or from the search query. It will not contain + * any HTML entities or HTML tags. + * + * @return + * The text after preprocessing. Note that if your module decides not to alter + * the text, it should return the original text. Also, after preprocessing, + * words in the text should be separated by a space. + * + * @ingroup search + */ +function hook_search_preprocess($text) { + // Do processing on $text + return $text; +} + +/** + * Update the search index for this module. + * + * This hook is called every cron run if search.module is enabled, your + * module has implemented hook_search_info(), and your module has been set as + * an active search module on the Search settings page + * (admin/config/search/settings). It allows your module to add items to the + * built-in search index using search_index(), or to add them to your module's + * own indexing mechanism. + * + * When implementing this hook, your module should index content items that + * were modified or added since the last run. PHP has a time limit + * for cron, though, so it is advisable to limit how many items you index + * per run using variable_get('search_cron_limit') (see example below). Also, + * since the cron run could time out and abort in the middle of your run, you + * should update your module's internal bookkeeping on when items have last + * been indexed as you go rather than waiting to the end of indexing. + * + * @ingroup search + */ +function hook_update_index() { + $limit = (int)variable_get('search_cron_limit', 100); + + $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit); + + foreach ($result as $node) { + $node = node_load($node->nid); + + // Save the changed time of the most recent indexed node, for the search + // results half-life calculation. + variable_set('node_cron_last', $node->changed); + + // Render the node. + node_build_content($node, 'search_index'); + $node->rendered = drupal_render($node->content); + + $text = '

    ' . check_plain($node->title) . '

    ' . $node->rendered; + + // Fetch extra data normally not visible + $extra = module_invoke_all('node_update_index', $node); + foreach ($extra as $t) { + $text .= $t; + } + + // Update index + search_index($node->nid, 'node', $text); + } +} +/** + * @} End of "addtogroup hooks". + */ + +/** + * Provide search query conditions. + * + * Callback for hook_search_info(). + * + * This callback is invoked by search_view() to get an array of additional + * search conditions to pass to search_data(). For example, a search module + * may get additional keywords, filters, or modifiers for the search from + * the query string. + * + * This example pulls additional search keywords out of the $_REQUEST variable, + * (i.e. from the query string of the request). The conditions may also be + * generated internally - for example based on a module's settings. + * + * @param $keys + * The search keywords string. + * + * @return + * An array of additional conditions, such as filters. + * + * @ingroup callbacks + * @ingroup search + */ +function callback_search_conditions($keys) { + $conditions = array(); + + if (!empty($_REQUEST['keys'])) { + $conditions['keys'] = $_REQUEST['keys']; + } + if (!empty($_REQUEST['sample_search_keys'])) { + $conditions['sample_search_keys'] = $_REQUEST['sample_search_keys']; + } + if ($force_keys = config('sample_search.settings')->get('force_keywords')) { + $conditions['sample_search_force_keywords'] = $force_keys; + } + return $conditions; +} diff --git a/drupal-dev/modules/search/search.css b/drupal-dev/modules/search/search.css new file mode 100644 index 0000000..ff7230f --- /dev/null +++ b/drupal-dev/modules/search/search.css @@ -0,0 +1,34 @@ + +.search-form { + margin-bottom: 1em; +} +.search-form input { + margin-top: 0; + margin-bottom: 0; +} +.search-results { + list-style: none; +} +.search-results p { + margin-top: 0; +} +.search-results .title { + font-size: 1.2em; +} +.search-results li { + margin-bottom: 1em; +} +.search-results .search-snippet-info { + padding-left: 1em; /* LTR */ +} +.search-results .search-info { + font-size: 0.85em; +} +.search-advanced .criterion { + float: left; /* LTR */ + margin-right: 2em; /* LTR */ +} +.search-advanced .action { + float: left; /* LTR */ + clear: left; /* LTR */ +} diff --git a/drupal-dev/modules/search/search.extender.inc b/drupal-dev/modules/search/search.extender.inc new file mode 100644 index 0000000..6709466 --- /dev/null +++ b/drupal-dev/modules/search/search.extender.inc @@ -0,0 +1,536 @@ + array(), 'negative' => array()); + + /** + * Indicates whether the first pass query requires complex conditions (LIKE). + * + * @var boolean. + */ + protected $simple = TRUE; + + /** + * Conditions that are used for exact searches. + * + * This is always used for the second pass query but not for the first pass, + * unless $this->simple is FALSE. + * + * @var DatabaseCondition + */ + protected $conditions; + + /** + * Indicates how many matches for a search query are necessary. + * + * @var int + */ + protected $matches = 0; + + /** + * Array of search words. + * + * These words have to match against {search_index}.word. + * + * @var array + */ + protected $words = array(); + + /** + * Multiplier for the normalized search score. + * + * This value is calculated by the first pass query and multiplied with the + * actual score of a specific word to make sure that the resulting calculated + * score is between 0 and 1. + * + * @var float + */ + protected $normalize; + + /** + * Indicates whether the first pass query has been executed. + * + * @var boolean + */ + protected $executedFirstPass = FALSE; + + /** + * Stores score expressions. + * + * @var array + * + * @see addScore() + */ + protected $scores = array(); + + /** + * Stores arguments for score expressions. + * + * @var array + */ + protected $scoresArguments = array(); + + /** + * Stores multipliers for score expressions. + * + * @var array + */ + protected $multiply = array(); + + /** + * Whether or not search expressions were ignored. + * + * The maximum number of AND/OR combinations exceeded can be configured to + * avoid Denial-of-Service attacks. Expressions beyond the limit are ignored. + * + * @var boolean + */ + protected $expressionsIgnored = FALSE; + + /** + * Sets up the search query expression. + * + * @param $query + * A search query string, which can contain options. + * @param $module + * The search module. This maps to {search_index}.type in the database. + * + * @return + * The SearchQuery object. + */ + public function searchExpression($expression, $module) { + $this->searchExpression = $expression; + $this->type = $module; + + return $this; + } + + /** + * Applies a search option and removes it from the search query string. + * + * These options are in the form option:value,value2,value3. + * + * @param $option + * Name of the option. + * @param $column + * Name of the database column to which the value should be applied. + * + * @return + * TRUE if a value for that option was found, FALSE if not. + */ + public function setOption($option, $column) { + if ($values = search_expression_extract($this->searchExpression, $option)) { + $or = db_or(); + foreach (explode(',', $values) as $value) { + $or->condition($column, $value); + } + $this->condition($or); + $this->searchExpression = search_expression_insert($this->searchExpression, $option); + return TRUE; + } + return FALSE; + } + + /** + * Parses the search query into SQL conditions. + * + * We build two queries that match the dataset bodies. + */ + protected function parseSearchExpression() { + // Matchs words optionally prefixed by a dash. A word in this case is + // something between two spaces, optionally quoted. + preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->searchExpression , $keywords, PREG_SET_ORDER); + + if (count($keywords) == 0) { + return; + } + + // Classify tokens. + $or = FALSE; + $warning = ''; + $limit_combinations = variable_get('search_and_or_limit', 7); + // The first search expression does not count as AND. + $and_count = -1; + $or_count = 0; + foreach ($keywords as $match) { + if ($or_count && $and_count + $or_count >= $limit_combinations) { + // Ignore all further search expressions to prevent Denial-of-Service + // attacks using a high number of AND/OR combinations. + $this->expressionsIgnored = TRUE; + break; + } + $phrase = FALSE; + // Strip off phrase quotes. + if ($match[2]{0} == '"') { + $match[2] = substr($match[2], 1, -1); + $phrase = TRUE; + $this->simple = FALSE; + } + // Simplify keyword according to indexing rules and external + // preprocessors. Use same process as during search indexing, so it + // will match search index. + $words = search_simplify($match[2]); + // Re-explode in case simplification added more words, except when + // matching a phrase. + $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY); + // Negative matches. + if ($match[1] == '-') { + $this->keys['negative'] = array_merge($this->keys['negative'], $words); + } + // OR operator: instead of a single keyword, we store an array of all + // OR'd keywords. + elseif ($match[2] == 'OR' && count($this->keys['positive'])) { + $last = array_pop($this->keys['positive']); + // Starting a new OR? + if (!is_array($last)) { + $last = array($last); + } + $this->keys['positive'][] = $last; + $or = TRUE; + $or_count++; + continue; + } + // AND operator: implied, so just ignore it. + elseif ($match[2] == 'AND' || $match[2] == 'and') { + $warning = $match[2]; + continue; + } + + // Plain keyword. + else { + if ($match[2] == 'or') { + $warning = $match[2]; + } + if ($or) { + // Add to last element (which is an array). + $this->keys['positive'][count($this->keys['positive']) - 1] = array_merge($this->keys['positive'][count($this->keys['positive']) - 1], $words); + } + else { + $this->keys['positive'] = array_merge($this->keys['positive'], $words); + $and_count++; + } + } + $or = FALSE; + } + + // Convert keywords into SQL statements. + $this->conditions = db_and(); + $simple_and = FALSE; + $simple_or = FALSE; + // Positive matches. + foreach ($this->keys['positive'] as $key) { + // Group of ORed terms. + if (is_array($key) && count($key)) { + $simple_or = TRUE; + $any = FALSE; + $queryor = db_or(); + foreach ($key as $or) { + list($num_new_scores) = $this->parseWord($or); + $any |= $num_new_scores; + $queryor->condition('d.data', "% $or %", 'LIKE'); + } + if (count($queryor)) { + $this->conditions->condition($queryor); + // A group of OR keywords only needs to match once. + $this->matches += ($any > 0); + } + } + // Single ANDed term. + else { + $simple_and = TRUE; + list($num_new_scores, $num_valid_words) = $this->parseWord($key); + $this->conditions->condition('d.data', "% $key %", 'LIKE'); + if (!$num_valid_words) { + $this->simple = FALSE; + } + // Each AND keyword needs to match at least once. + $this->matches += $num_new_scores; + } + } + if ($simple_and && $simple_or) { + $this->simple = FALSE; + } + // Negative matches. + foreach ($this->keys['negative'] as $key) { + $this->conditions->condition('d.data', "% $key %", 'NOT LIKE'); + $this->simple = FALSE; + } + + if ($warning == 'or') { + drupal_set_message(t('Search for either of the two terms with uppercase OR. For example, cats OR dogs.')); + } + } + + /** + * Helper function for parseQuery(). + */ + protected function parseWord($word) { + $num_new_scores = 0; + $num_valid_words = 0; + // Determine the scorewords of this word/phrase. + $split = explode(' ', $word); + foreach ($split as $s) { + $num = is_numeric($s); + if ($num || drupal_strlen($s) >= variable_get('minimum_word_size', 3)) { + if (!isset($this->words[$s])) { + $this->words[$s] = $s; + $num_new_scores++; + } + $num_valid_words++; + } + } + // Return matching snippet and number of added words. + return array($num_new_scores, $num_valid_words); + } + + /** + * Executes the first pass query. + * + * This can either be done explicitly, so that additional scores and + * conditions can be applied to the second pass query, or implicitly by + * addScore() or execute(). + * + * @return + * TRUE if search items exist, FALSE if not. + */ + public function executeFirstPass() { + $this->parseSearchExpression(); + + if (count($this->words) == 0) { + form_set_error('keys', format_plural(variable_get('minimum_word_size', 3), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.')); + return FALSE; + } + if ($this->expressionsIgnored) { + drupal_set_message(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => variable_get('search_and_or_limit', 7))), 'warning'); + } + $this->executedFirstPass = TRUE; + + if (!empty($this->words)) { + $or = db_or(); + foreach ($this->words as $word) { + $or->condition('i.word', $word); + } + $this->condition($or); + } + // Build query for keyword normalization. + $this->join('search_total', 't', 'i.word = t.word'); + $this + ->condition('i.type', $this->type) + ->groupBy('i.type') + ->groupBy('i.sid') + ->having('COUNT(*) >= :matches', array(':matches' => $this->matches)); + + // Clone the query object to do the firstPass query; + $first = clone $this->query; + + // For complex search queries, add the LIKE conditions to the first pass query. + if (!$this->simple) { + $first->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type'); + $first->condition($this->conditions); + } + + // Calculate maximum keyword relevance, to normalize it. + $first->addExpression('SUM(i.score * t.count)', 'calculated_score'); + $this->normalize = $first + ->range(0, 1) + ->orderBy('calculated_score', 'DESC') + ->execute() + ->fetchField(); + + if ($this->normalize) { + return TRUE; + } + return FALSE; + } + + /** + * Adds a custom score expression to the search query. + * + * Score expressions are used to order search results. If no calls to + * addScore() have taken place, a default keyword relevance score will be + * used. However, if at least one call to addScore() has taken place, the + * keyword relevance score is not automatically added. + * + * Also note that if you call orderBy() directly on the query, search scores + * will not automatically be used to order search results. Your orderBy() + * expression can reference 'calculated_score', which will be the total + * calculated score value. + * + * @param $score + * The score expression, which should evaluate to a number between 0 and 1. + * The string 'i.relevance' in a score expression will be replaced by a + * measure of keyword relevance between 0 and 1. + * @param $arguments + * Query arguments needed to provide values to the score expression. + * @param $multiply + * If set, the score is multiplied with this value. However, all scores + * with multipliers are then divided by the total of all multipliers, so + * that overall, the normalization is maintained. + * + * @return object + * The updated query object. + */ + public function addScore($score, $arguments = array(), $multiply = FALSE) { + if ($multiply) { + $i = count($this->multiply); + // Modify the score expression so it is multiplied by the multiplier, + // with a divisor to renormalize. + $score = "CAST(:multiply_$i AS DECIMAL) * COALESCE(( " . $score . "), 0) / CAST(:total_$i AS DECIMAL)"; + // Add an argument for the multiplier. The :total_$i argument is taken + // care of in the execute() method, which is when the total divisor is + // calculated. + $arguments[':multiply_' . $i] = $multiply; + $this->multiply[] = $multiply; + } + + $this->scores[] = $score; + $this->scoresArguments += $arguments; + + return $this; + } + + /** + * Executes the search. + * + * If not already done, this executes the first pass query. Then the complex + * conditions are applied to the query including score expressions and + * ordering. + * + * @return + * FALSE if the first pass query returned no results, and a database result + * set if there were results. + */ + public function execute() + { + if (!$this->executedFirstPass) { + $this->executeFirstPass(); + } + if (!$this->normalize) { + return new DatabaseStatementEmpty(); + } + + // Add conditions to query. + $this->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type'); + $this->condition($this->conditions); + + if (empty($this->scores)) { + // Add default score. + $this->addScore('i.relevance'); + } + + if (count($this->multiply)) { + // Re-normalize scores with multipliers by dividing by the total of all + // multipliers. The expressions were altered in addScore(), so here just + // add the arguments for the total. + $i = 0; + $sum = array_sum($this->multiply); + foreach ($this->multiply as $total) { + $this->scoresArguments[':total_' . $i] = $sum; + $i++; + } + } + + // Replace the pseudo-expression 'i.relevance' with a measure of keyword + // relevance in all score expressions, using string replacement. Careful + // though! If you just print out a float, some locales use ',' as the + // decimal separator in PHP, while SQL always uses '.'. So, make sure to + // set the number format correctly. + $relevance = number_format((1.0 / $this->normalize), 10, '.', ''); + $this->scores = str_replace('i.relevance', '(' . $relevance . ' * i.score * t.count)', $this->scores); + + // Add all scores together to form a query field. + $this->addExpression('SUM(' . implode(' + ', $this->scores) . ')', 'calculated_score', $this->scoresArguments); + + // If an order has not yet been set for this query, add a default order + // that sorts by the calculated sum of scores. + if (count($this->getOrderBy()) == 0) { + $this->orderBy('calculated_score', 'DESC'); + } + + // Add tag and useful metadata. + $this + ->addTag('search_' . $this->type) + ->addMetaData('normalize', $this->normalize) + ->fields('i', array('type', 'sid')); + + return $this->query->execute(); + } + + /** + * Builds the default count query for SearchQuery. + * + * Since SearchQuery always uses GROUP BY, we can default to a subquery. We + * also add the same conditions as execute() because countQuery() is called + * first. + */ + public function countQuery() { + // Clone the inner query. + $inner = clone $this->query; + + // Add conditions to query. + $inner->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type'); + $inner->condition($this->conditions); + + // Remove existing fields and expressions, they are not needed for a count + // query. + $fields =& $inner->getFields(); + $fields = array(); + $expressions =& $inner->getExpressions(); + $expressions = array(); + + // Add the sid as the only field and count them as a subquery. + $count = db_select($inner->fields('i', array('sid')), NULL, array('target' => 'slave')); + + // Add the COUNT() expression. + $count->addExpression('COUNT(*)'); + + return $count; + } +} diff --git a/drupal-dev/modules/search/search.info b/drupal-dev/modules/search/search.info new file mode 100644 index 0000000..3c0495d --- /dev/null +++ b/drupal-dev/modules/search/search.info @@ -0,0 +1,15 @@ +name = Search +description = Enables site-wide keyword searching. +package = Core +version = VERSION +core = 7.x +files[] = search.extender.inc +files[] = search.test +configure = admin/config/search/settings +stylesheets[all][] = search.css + +; Information added by Drupal.org packaging script on 2014-01-15 +version = "7.26" +project = "drupal" +datestamp = "1389815930" + diff --git a/drupal-dev/modules/search/search.install b/drupal-dev/modules/search/search.install new file mode 100644 index 0000000..f0113b3 --- /dev/null +++ b/drupal-dev/modules/search/search.install @@ -0,0 +1,182 @@ + 'Stores items that will be searched.', + 'fields' => array( + 'sid' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'Search item ID, e.g. node ID for nodes.', + ), + 'type' => array( + 'type' => 'varchar', + 'length' => 16, + 'not null' => TRUE, + 'description' => 'Type of item, e.g. node.', + ), + 'data' => array( + 'type' => 'text', + 'not null' => TRUE, + 'size' => 'big', + 'description' => 'List of space-separated words from the item.', + ), + 'reindex' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'Set to force node reindexing.', + ), + ), + 'primary key' => array('sid', 'type'), + ); + + $schema['search_index'] = array( + 'description' => 'Stores the search index, associating words, items and scores.', + 'fields' => array( + 'word' => array( + 'type' => 'varchar', + 'length' => 50, + 'not null' => TRUE, + 'default' => '', + 'description' => 'The {search_total}.word that is associated with the search item.', + ), + 'sid' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The {search_dataset}.sid of the searchable item to which the word belongs.', + ), + 'type' => array( + 'type' => 'varchar', + 'length' => 16, + 'not null' => TRUE, + 'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.', + ), + 'score' => array( + 'type' => 'float', + 'not null' => FALSE, + 'description' => 'The numeric score of the word, higher being more important.', + ), + ), + 'indexes' => array( + 'sid_type' => array('sid', 'type'), + ), + 'foreign keys' => array( + 'search_dataset' => array( + 'table' => 'search_dataset', + 'columns' => array( + 'sid' => 'sid', + 'type' => 'type', + ), + ), + ), + 'primary key' => array('word', 'sid', 'type'), + ); + + $schema['search_total'] = array( + 'description' => 'Stores search totals for words.', + 'fields' => array( + 'word' => array( + 'description' => 'Primary Key: Unique word in the search index.', + 'type' => 'varchar', + 'length' => 50, + 'not null' => TRUE, + 'default' => '', + ), + 'count' => array( + 'description' => "The count of the word in the index using Zipf's law to equalize the probability distribution.", + 'type' => 'float', + 'not null' => FALSE, + ), + ), + 'primary key' => array('word'), + ); + + $schema['search_node_links'] = array( + 'description' => 'Stores items (like nodes) that link to other nodes, used to improve search scores for nodes that are frequently linked to.', + 'fields' => array( + 'sid' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The {search_dataset}.sid of the searchable item containing the link to the node.', + ), + 'type' => array( + 'type' => 'varchar', + 'length' => 16, + 'not null' => TRUE, + 'default' => '', + 'description' => 'The {search_dataset}.type of the searchable item containing the link to the node.', + ), + 'nid' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The {node}.nid that this item links to.', + ), + 'caption' => array( + 'type' => 'text', + 'size' => 'big', + 'not null' => FALSE, + 'description' => 'The text used to link to the {node}.nid.', + ), + ), + 'primary key' => array('sid', 'type', 'nid'), + 'indexes' => array( + 'nid' => array('nid'), + ), + ); + + return $schema; +} + +/** + * Replace unique keys in 'search_dataset' and 'search_index' by primary keys. + */ +function search_update_7000() { + db_drop_unique_key('search_dataset', 'sid_type'); + $dataset_type_spec = array( + 'type' => 'varchar', + 'length' => 16, + 'not null' => TRUE, + 'description' => 'Type of item, e.g. node.', + ); + db_change_field('search_dataset', 'type', 'type', $dataset_type_spec); + db_add_primary_key('search_dataset', array('sid', 'type')); + + db_drop_index('search_index', 'word'); + db_drop_unique_key('search_index', 'word_sid_type'); + $index_type_spec = array( + 'type' => 'varchar', + 'length' => 16, + 'not null' => TRUE, + 'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.', + ); + db_change_field('search_index', 'type', 'type', $index_type_spec); + db_add_primary_key('search_index', array('word', 'sid', 'type')); +} + diff --git a/drupal-dev/modules/search/search.module b/drupal-dev/modules/search/search.module new file mode 100644 index 0000000..7542f98 --- /dev/null +++ b/drupal-dev/modules/search/search.module @@ -0,0 +1,1356 @@ +' . t('About') . ''; + $output .= '

    ' . t('The Search module provides the ability to index and search for content by exact keywords, and for users by username or e-mail. For more information, see the online handbook entry for Search module.', array('@search-module' => 'http://drupal.org/documentation/modules/search/', '@search' => url('search'))) . '

    '; + $output .= '

    ' . t('Uses') . '

    '; + $output .= '
    '; + $output .= '
    ' . t('Searching content and users') . '
    '; + $output .= '
    ' . t('Users with Use search permission can use the search block and Search page. Users with the View published content permission can search for content containing exact keywords. Users with the View user profiles permission can search for users containing the keyword anywhere in the user name, and users with the Administer users permission can search for users by email address. Additionally, users with Use advanced search permission can find content using more complex search methods and filtering by choosing the Advanced search option on the Search page.', array('@search' => url('search'))) . '
    '; + $output .= '
    ' . t('Indexing content with cron') . '
    '; + $output .= '
    ' . t('To provide keyword searching, the search engine maintains an index of words found in the content and its fields, along with text added to your content by other modules (such as comments from the core Comment module, and taxonomy terms from the core Taxonomy module). To build and maintain this index, a correctly configured cron maintenance task is required. Users with Administer search permission can further configure the cron settings on the Search settings page.', array('@cron' => 'http://drupal.org/cron', '@searchsettings' => url('admin/config/search/settings'))) . '
    '; + $output .= '
    ' . t('Content reindexing') . '
    '; + $output .= '
    ' . t('Content-related actions on your site (creating, editing, or deleting content and comments) automatically cause affected content items to be marked for indexing or reindexing at the next cron run. When content is marked for reindexing, the previous content remains in the index until cron runs, at which time it is replaced by the new content. Unlike content-related actions, actions related to the structure of your site do not cause affected content to be marked for reindexing. Examples of structure-related actions that affect content include deleting or editing taxonomy terms, enabling or disabling modules that add text to content (such as Taxonomy, Comment, and field-providing modules), and modifying the fields or display parameters of your content types. If you take one of these actions and you want to ensure that the search index is updated to reflect your changed site structure, you can mark all content for reindexing by clicking the "Re-index site" button on the Search settings page. If you have a lot of content on your site, it may take several cron runs for the content to be reindexed.', array('@searchsettings' => url('admin/config/search/settings'))) . '
    '; + $output .= '
    ' . t('Configuring search settings') . '
    '; + $output .= '
    ' . t('Indexing behavior can be adjusted using the Search settings page. Users with Administer search permission can control settings such as the Number of items to index per cron run, Indexing settings (word length), Active search modules, and Content ranking, which lets you adjust the priority in which indexed content is returned in results.', array('@searchsettings' => url('admin/config/search/settings'))) . '
    '; + $output .= '
    ' . t('Search block') . '
    '; + $output .= '
    ' . t('The Search module includes a default Search form block, which can be enabled and configured on the Blocks administration page. The block is available to users with the Search content permission.', array('@blocks' => url('admin/structure/block'))) . '
    '; + $output .= '
    ' . t('Extending Search module') . '
    '; + $output .= '
    ' . t('By default, the Search module only supports exact keyword matching in content searches. You can modify this behavior by installing a language-specific stemming module for your language (such as Porter Stemmer for American English), which allows words such as walk, walking, and walked to be matched in the Search module. Another approach is to use a third-party search technology with stemming or partial word matching features built in, such as Apache Solr or Sphinx. These and other search-related contributed modules can be downloaded by visiting Drupal.org.', array('@contrib-search' => 'http://drupal.org/project/modules?filters=tid%3A105')) . '
    '; + $output .= '
    '; + return $output; + case 'admin/config/search/settings': + return '

    ' . t('The search engine maintains an index of words found in your site\'s content. To build and maintain this index, a correctly configured cron maintenance task is required. Indexing behavior can be adjusted using the settings below.', array('@cron' => url('admin/reports/status'))) . '

    '; + case 'search#noresults': + return t('
      +
    • Check if your spelling is correct.
    • +
    • Remove quotes around phrases to search for each word individually. bike shed will often show more results than "bike shed".
    • +
    • Consider loosening your query with OR. bike OR shed will often show more results than bike shed.
    • +
    '); + } +} + +/** + * Implements hook_theme(). + */ +function search_theme() { + return array( + 'search_block_form' => array( + 'render element' => 'form', + 'template' => 'search-block-form', + ), + 'search_result' => array( + 'variables' => array('result' => NULL, 'module' => NULL), + 'file' => 'search.pages.inc', + 'template' => 'search-result', + ), + 'search_results' => array( + 'variables' => array('results' => NULL, 'module' => NULL), + 'file' => 'search.pages.inc', + 'template' => 'search-results', + ), + ); +} + +/** + * Implements hook_permission(). + */ +function search_permission() { + return array( + 'administer search' => array( + 'title' => t('Administer search'), + ), + 'search content' => array( + 'title' => t('Use search'), + ), + 'use advanced search' => array( + 'title' => t('Use advanced search'), + ), + ); +} + +/** + * Implements hook_block_info(). + */ +function search_block_info() { + $blocks['form']['info'] = t('Search form'); + // Not worth caching. + $blocks['form']['cache'] = DRUPAL_NO_CACHE; + $blocks['form']['properties']['administrative'] = TRUE; + return $blocks; +} + +/** + * Implements hook_block_view(). + */ +function search_block_view($delta = '') { + if (user_access('search content')) { + $block['content'] = drupal_get_form('search_block_form'); + return $block; + } +} + +/** + * Implements hook_menu(). + */ +function search_menu() { + $items['search'] = array( + 'title' => 'Search', + 'page callback' => 'search_view', + 'access callback' => 'search_is_active', + 'type' => MENU_SUGGESTED_ITEM, + 'file' => 'search.pages.inc', + ); + $items['admin/config/search/settings'] = array( + 'title' => 'Search settings', + 'description' => 'Configure relevance settings for search and other indexing options.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('search_admin_settings'), + 'access arguments' => array('administer search'), + 'weight' => -10, + 'file' => 'search.admin.inc', + ); + $items['admin/config/search/settings/reindex'] = array( + 'title' => 'Clear index', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('search_reindex_confirm'), + 'access arguments' => array('administer search'), + 'type' => MENU_VISIBLE_IN_BREADCRUMB, + 'file' => 'search.admin.inc', + ); + + // Add paths for searching. We add each module search path twice: once without + // and once with %menu_tail appended. The reason for this is that we want to + // preserve keywords when switching tabs, and also to have search tabs + // highlighted properly. The only way to do that within the Drupal menu + // system appears to be having two sets of tabs. See discussion on issue + // http://drupal.org/node/245103 for details. + + drupal_static_reset('search_get_info'); + $default_info = search_get_default_module_info(); + if ($default_info) { + foreach (search_get_info() as $module => $search_info) { + $path = 'search/' . $search_info['path']; + $items[$path] = array( + 'title' => $search_info['title'], + 'page callback' => 'search_view', + 'page arguments' => array($module, ''), + 'access callback' => '_search_menu_access', + 'access arguments' => array($module), + 'type' => MENU_LOCAL_TASK, + 'file' => 'search.pages.inc', + 'weight' => $module == $default_info['module'] ? -10 : 0, + ); + $items["$path/%menu_tail"] = array( + 'title' => $search_info['title'], + 'load arguments' => array('%map', '%index'), + 'page callback' => 'search_view', + 'page arguments' => array($module, 2), + 'access callback' => '_search_menu_access', + 'access arguments' => array($module), + // The default local task points to its parent, but this item points to + // where it should so it should not be changed. + 'type' => MENU_LOCAL_TASK, + 'file' => 'search.pages.inc', + 'weight' => 0, + // These tabs are not subtabs. + 'tab_root' => 'search/' . $default_info['path'] . '/%', + // These tabs need to display at the same level. + 'tab_parent' => 'search/' . $default_info['path'], + ); + } + } + return $items; +} + +/** + * Determines access for the ?q=search path. + */ +function search_is_active() { + // This path cannot be accessed if there are no active modules. + return user_access('search content') && search_get_info(); +} + +/** + * Returns information about available search modules. + * + * @param $all + * If TRUE, information about all enabled modules implementing + * hook_search_info() will be returned. If FALSE (default), only modules that + * have been set to active on the search settings page will be returned. + * + * @return + * Array of hook_search_info() return values, keyed by module name. The + * 'title' and 'path' array elements will be set to defaults for each module + * if not supplied by hook_search_info(), and an additional array element of + * 'module' will be added (set to the module name). + */ +function search_get_info($all = FALSE) { + $search_hooks = &drupal_static(__FUNCTION__); + + if (!isset($search_hooks)) { + foreach (module_implements('search_info') as $module) { + $search_hooks[$module] = call_user_func($module . '_search_info'); + // Use module name as the default value. + $search_hooks[$module] += array('title' => $module, 'path' => $module); + // Include the module name itself in the array. + $search_hooks[$module]['module'] = $module; + } + } + + if ($all) { + return $search_hooks; + } + + $active = variable_get('search_active_modules', array('node', 'user')); + return array_intersect_key($search_hooks, array_flip($active)); +} + +/** + * Returns information about the default search module. + * + * @return + * The search_get_info() array element for the default search module, if any. + */ +function search_get_default_module_info() { + $info = search_get_info(); + $default = variable_get('search_default_module', 'node'); + if (isset($info[$default])) { + return $info[$default]; + } + // The variable setting does not match any active module, so just return + // the info for the first active module (if any). + return reset($info); +} + +/** + * Access callback for search tabs. + */ +function _search_menu_access($name) { + return user_access('search content') && (!function_exists($name . '_search_access') || module_invoke($name, 'search_access')); +} + +/** + * Clears a part of or the entire search index. + * + * @param $sid + * (optional) The ID of the item to remove from the search index. If + * specified, $module must also be given. Omit both $sid and $module to clear + * the entire search index. + * @param $module + * (optional) The machine-readable name of the module for the item to remove + * from the search index. + */ +function search_reindex($sid = NULL, $module = NULL, $reindex = FALSE) { + if ($module == NULL && $sid == NULL) { + module_invoke_all('search_reset'); + } + else { + db_delete('search_dataset') + ->condition('sid', $sid) + ->condition('type', $module) + ->execute(); + db_delete('search_index') + ->condition('sid', $sid) + ->condition('type', $module) + ->execute(); + // Don't remove links if re-indexing. + if (!$reindex) { + db_delete('search_node_links') + ->condition('sid', $sid) + ->condition('type', $module) + ->execute(); + } + } +} + +/** + * Marks a word as "dirty" (changed), or retrieves the list of dirty words. + * + * This is used during indexing (cron). Words that are dirty have outdated + * total counts in the search_total table, and need to be recounted. + */ +function search_dirty($word = NULL) { + $dirty = &drupal_static(__FUNCTION__, array()); + if ($word !== NULL) { + $dirty[$word] = TRUE; + } + else { + return $dirty; + } +} + +/** + * Implements hook_cron(). + * + * Fires hook_update_index() in all modules and cleans up dirty words. + * + * @see search_dirty() + */ +function search_cron() { + // We register a shutdown function to ensure that search_total is always up + // to date. + drupal_register_shutdown_function('search_update_totals'); + + foreach (variable_get('search_active_modules', array('node', 'user')) as $module) { + // Update word index + module_invoke($module, 'update_index'); + } +} + +/** + * Updates the {search_total} database table. + * + * This function is called on shutdown to ensure that {search_total} is always + * up to date (even if cron times out or otherwise fails). + */ +function search_update_totals() { + // Update word IDF (Inverse Document Frequency) counts for new/changed words. + foreach (search_dirty() as $word => $dummy) { + // Get total count + $total = db_query("SELECT SUM(score) FROM {search_index} WHERE word = :word", array(':word' => $word), array('target' => 'slave'))->fetchField(); + // Apply Zipf's law to equalize the probability distribution. + $total = log10(1 + 1/(max(1, $total))); + db_merge('search_total') + ->key(array('word' => $word)) + ->fields(array('count' => $total)) + ->execute(); + } + // Find words that were deleted from search_index, but are still in + // search_total. We use a LEFT JOIN between the two tables and keep only the + // rows which fail to join. + $result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL", array(), array('target' => 'slave')); + $or = db_or(); + foreach ($result as $word) { + $or->condition('word', $word->realword); + } + if (count($or) > 0) { + db_delete('search_total') + ->condition($or) + ->execute(); + } +} + +/** + * Simplifies a string according to indexing rules. + * + * @param $text + * Text to simplify. + * + * @return + * Simplified text. + * + * @see hook_search_preprocess() + */ +function search_simplify($text) { + // Decode entities to UTF-8 + $text = decode_entities($text); + + // Lowercase + $text = drupal_strtolower($text); + + // Call an external processor for word handling. + search_invoke_preprocess($text); + + // Simple CJK handling + if (variable_get('overlap_cjk', TRUE)) { + $text = preg_replace_callback('/[' . PREG_CLASS_CJK . ']+/u', 'search_expand_cjk', $text); + } + + // To improve searching for numerical data such as dates, IP addresses + // or version numbers, we consider a group of numerical characters + // separated only by punctuation characters to be one piece. + // This also means that searching for e.g. '20/03/1984' also returns + // results with '20-03-1984' in them. + // Readable regexp: ([number]+)[punctuation]+(?=[number]) + $text = preg_replace('/([' . PREG_CLASS_NUMBERS . ']+)[' . PREG_CLASS_PUNCTUATION . ']+(?=[' . PREG_CLASS_NUMBERS . '])/u', '\1', $text); + + // Multiple dot and dash groups are word boundaries and replaced with space. + // No need to use the unicode modifer here because 0-127 ASCII characters + // can't match higher UTF-8 characters as the leftmost bit of those are 1. + $text = preg_replace('/[.-]{2,}/', ' ', $text); + + // The dot, underscore and dash are simply removed. This allows meaningful + // search behavior with acronyms and URLs. See unicode note directly above. + $text = preg_replace('/[._-]+/', '', $text); + + // With the exception of the rules above, we consider all punctuation, + // marks, spacers, etc, to be a word boundary. + $text = preg_replace('/[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . ']+/u', ' ', $text); + + // Truncate everything to 50 characters. + $words = explode(' ', $text); + array_walk($words, '_search_index_truncate'); + $text = implode(' ', $words); + + return $text; +} + +/** + * Splits CJK (Chinese, Japanese, Korean) text into tokens. + * + * The Search module matches exact words, where a word is defined to be a + * sequence of characters delimited by spaces or punctuation. CJK languages are + * written in long strings of characters, though, not split up into words. So + * in order to allow search matching, we split up CJK text into tokens + * consisting of consecutive, overlapping sequences of characters whose length + * is equal to the 'minimum_word_size' variable. This tokenizing is only done if + * the 'overlap_cjk' variable is TRUE. + * + * @param $matches + * This function is a callback for preg_replace_callback(), which is called + * from search_simplify(). So, $matches is an array of regular expression + * matches, which means that $matches[0] contains the matched text -- a string + * of CJK characters to tokenize. + * + * @return + * Tokenized text, starting and ending with a space character. + */ +function search_expand_cjk($matches) { + $min = variable_get('minimum_word_size', 3); + $str = $matches[0]; + $length = drupal_strlen($str); + // If the text is shorter than the minimum word size, don't tokenize it. + if ($length <= $min) { + return ' ' . $str . ' '; + } + $tokens = ' '; + // Build a FIFO queue of characters. + $chars = array(); + for ($i = 0; $i < $length; $i++) { + // Add the next character off the beginning of the string to the queue. + $current = drupal_substr($str, 0, 1); + $str = substr($str, strlen($current)); + $chars[] = $current; + if ($i >= $min - 1) { + // Make a token of $min characters, and add it to the token string. + $tokens .= implode('', $chars) . ' '; + // Shift out the first character in the queue. + array_shift($chars); + } + } + return $tokens; +} + +/** + * Simplifies and splits a string into tokens for indexing. + */ +function search_index_split($text) { + $last = &drupal_static(__FUNCTION__); + $lastsplit = &drupal_static(__FUNCTION__ . ':lastsplit'); + + if ($last == $text) { + return $lastsplit; + } + // Process words + $text = search_simplify($text); + $words = explode(' ', $text); + + // Save last keyword result + $last = $text; + $lastsplit = $words; + + return $words; +} + +/** + * Helper function for array_walk in search_index_split. + */ +function _search_index_truncate(&$text) { + if (is_numeric($text)) { + $text = ltrim($text, '0'); + } + $text = truncate_utf8($text, 50); +} + +/** + * Invokes hook_search_preprocess() in modules. + */ +function search_invoke_preprocess(&$text) { + foreach (module_implements('search_preprocess') as $module) { + $text = module_invoke($module, 'search_preprocess', $text); + } +} + +/** + * Update the full-text search index for a particular item. + * + * @param $sid + * An ID number identifying this particular item (e.g., node ID). + * @param $module + * The machine-readable name of the module that this item comes from (a module + * that implements hook_search_info()). + * @param $text + * The content of this item. Must be a piece of HTML or plain text. + * + * @ingroup search + */ +function search_index($sid, $module, $text) { + $minimum_word_size = variable_get('minimum_word_size', 3); + + // Link matching + global $base_url; + $node_regexp = '@href=[\'"]?(?:' . preg_quote($base_url, '@') . '/|' . preg_quote(base_path(), '@') . ')(?:\?q=)?/?((?![a-z]+:)[^\'">]+)[\'">]@i'; + + // Multipliers for scores of words inside certain HTML tags. The weights are stored + // in a variable so that modules can overwrite the default weights. + // Note: 'a' must be included for link ranking to work. + $tags = variable_get('search_tag_weights', array( + 'h1' => 25, + 'h2' => 18, + 'h3' => 15, + 'h4' => 12, + 'h5' => 9, + 'h6' => 6, + 'u' => 3, + 'b' => 3, + 'i' => 3, + 'strong' => 3, + 'em' => 3, + 'a' => 10)); + + // Strip off all ignored tags to speed up processing, but insert space before/after + // them to keep word boundaries. + $text = str_replace(array('<', '>'), array(' <', '> '), $text); + $text = strip_tags($text, '<' . implode('><', array_keys($tags)) . '>'); + + // Split HTML tags from plain text. + $split = preg_split('/\s*<([^>]+?)>\s*/', $text, -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. + $link = FALSE; // State variable for link analyzer + $score = 1; // Starting score per word + $accum = ' '; // Accumulator for cleaned up data + $tagstack = array(); // Stack with open tags + $tagwords = 0; // Counter for consecutive words + $focus = 1; // Focus state + + $results = array(0 => array()); // Accumulator for words for index + + foreach ($split as $value) { + if ($tag) { + // Increase or decrease score per word based on tag + list($tagname) = explode(' ', $value, 2); + $tagname = drupal_strtolower($tagname); + // Closing or opening tag? + if ($tagname[0] == '/') { + $tagname = substr($tagname, 1); + // If we encounter unexpected tags, reset score to avoid incorrect boosting. + if (!count($tagstack) || $tagstack[0] != $tagname) { + $tagstack = array(); + $score = 1; + } + else { + // Remove from tag stack and decrement score + $score = max(1, $score - $tags[array_shift($tagstack)]); + } + if ($tagname == 'a') { + $link = FALSE; + } + } + else { + if (isset($tagstack[0]) && $tagstack[0] == $tagname) { + // None of the tags we look for make sense when nested identically. + // If they are, it's probably broken HTML. + $tagstack = array(); + $score = 1; + } + else { + // Add to open tag stack and increment score + array_unshift($tagstack, $tagname); + $score += $tags[$tagname]; + } + if ($tagname == 'a') { + // Check if link points to a node on this site + if (preg_match($node_regexp, $value, $match)) { + $path = drupal_get_normal_path($match[1]); + if (preg_match('!(?:node|book)/(?:view/)?([0-9]+)!i', $path, $match)) { + $linknid = $match[1]; + if ($linknid > 0) { + $node = db_query('SELECT title, nid, vid FROM {node} WHERE nid = :nid', array(':nid' => $linknid), array('target' => 'slave'))->fetchObject(); + $link = TRUE; + $linktitle = $node->title; + } + } + } + } + } + // A tag change occurred, reset counter. + $tagwords = 0; + } + else { + // Note: use of PREG_SPLIT_DELIM_CAPTURE above will introduce empty values + if ($value != '') { + if ($link) { + // Check to see if the node link text is its URL. If so, we use the target node title instead. + if (preg_match('!^https?://!i', $value)) { + $value = $linktitle; + } + } + $words = search_index_split($value); + foreach ($words as $word) { + // Add word to accumulator + $accum .= $word . ' '; + // Check wordlength + if (is_numeric($word) || drupal_strlen($word) >= $minimum_word_size) { + // Links score mainly for the target. + if ($link) { + if (!isset($results[$linknid])) { + $results[$linknid] = array(); + } + $results[$linknid][] = $word; + // Reduce score of the link caption in the source. + $focus *= 0.2; + } + // Fall-through + if (!isset($results[0][$word])) { + $results[0][$word] = 0; + } + $results[0][$word] += $score * $focus; + + // Focus is a decaying value in terms of the amount of unique words up to this point. + // From 100 words and more, it decays, to e.g. 0.5 at 500 words and 0.3 at 1000 words. + $focus = min(1, .01 + 3.5 / (2 + count($results[0]) * .015)); + } + $tagwords++; + // Too many words inside a single tag probably mean a tag was accidentally left open. + if (count($tagstack) && $tagwords >= 15) { + $tagstack = array(); + $score = 1; + } + } + } + } + $tag = !$tag; + } + + search_reindex($sid, $module, TRUE); + + // Insert cleaned up data into dataset + db_insert('search_dataset') + ->fields(array( + 'sid' => $sid, + 'type' => $module, + 'data' => $accum, + 'reindex' => 0, + )) + ->execute(); + + // Insert results into search index + foreach ($results[0] as $word => $score) { + // If a word already exists in the database, its score gets increased + // appropriately. If not, we create a new record with the appropriate + // starting score. + db_merge('search_index') + ->key(array( + 'word' => $word, + 'sid' => $sid, + 'type' => $module, + )) + ->fields(array('score' => $score)) + ->expression('score', 'score + :score', array(':score' => $score)) + ->execute(); + search_dirty($word); + } + unset($results[0]); + + // Get all previous links from this item. + $result = db_query("SELECT nid, caption FROM {search_node_links} WHERE sid = :sid AND type = :type", array( + ':sid' => $sid, + ':type' => $module + ), array('target' => 'slave')); + $links = array(); + foreach ($result as $link) { + $links[$link->nid] = $link->caption; + } + + // Now store links to nodes. + foreach ($results as $nid => $words) { + $caption = implode(' ', $words); + if (isset($links[$nid])) { + if ($links[$nid] != $caption) { + // Update the existing link and mark the node for reindexing. + db_update('search_node_links') + ->fields(array('caption' => $caption)) + ->condition('sid', $sid) + ->condition('type', $module) + ->condition('nid', $nid) + ->execute(); + search_touch_node($nid); + } + // Unset the link to mark it as processed. + unset($links[$nid]); + } + elseif ($sid != $nid || $module != 'node') { + // Insert the existing link and mark the node for reindexing, but don't + // reindex if this is a link in a node pointing to itself. + db_insert('search_node_links') + ->fields(array( + 'caption' => $caption, + 'sid' => $sid, + 'type' => $module, + 'nid' => $nid, + )) + ->execute(); + search_touch_node($nid); + } + } + // Any left-over links in $links no longer exist. Delete them and mark the nodes for reindexing. + foreach ($links as $nid => $caption) { + db_delete('search_node_links') + ->condition('sid', $sid) + ->condition('type', $module) + ->condition('nid', $nid) + ->execute(); + search_touch_node($nid); + } +} + +/** + * Changes a node's changed timestamp to 'now' to force reindexing. + * + * @param $nid + * The node ID of the node that needs reindexing. + */ +function search_touch_node($nid) { + db_update('search_dataset') + ->fields(array('reindex' => REQUEST_TIME)) + ->condition('type', 'node') + ->condition('sid', $nid) + ->execute(); +} + +/** + * Implements hook_node_update_index(). + */ +function search_node_update_index($node) { + // Transplant links to a node into the target node. + $result = db_query("SELECT caption FROM {search_node_links} WHERE nid = :nid", array(':nid' => $node->nid), array('target' => 'slave')); + $output = array(); + foreach ($result as $link) { + $output[] = $link->caption; + } + if (count($output)) { + return '(' . implode(', ', $output) . ')'; + } +} + +/** + * Implements hook_node_update(). + */ +function search_node_update($node) { + // Reindex the node when it is updated. The node is automatically indexed + // when it is added, simply by being added to the node table. + search_touch_node($node->nid); +} + +/** + * Implements hook_comment_insert(). + */ +function search_comment_insert($comment) { + // Reindex the node when comments are added. + search_touch_node($comment->nid); +} + +/** + * Implements hook_comment_update(). + */ +function search_comment_update($comment) { + // Reindex the node when comments are changed. + search_touch_node($comment->nid); +} + +/** + * Implements hook_comment_delete(). + */ +function search_comment_delete($comment) { + // Reindex the node when comments are deleted. + search_touch_node($comment->nid); +} + +/** + * Implements hook_comment_publish(). + */ +function search_comment_publish($comment) { + // Reindex the node when comments are published. + search_touch_node($comment->nid); +} + +/** + * Implements hook_comment_unpublish(). + */ +function search_comment_unpublish($comment) { + // Reindex the node when comments are unpublished. + search_touch_node($comment->nid); +} + +/** + * Extracts a module-specific search option from a search expression. + * + * Search options are added using search_expression_insert(), and retrieved + * using search_expression_extract(). They take the form option:value, and + * are added to the ordinary keywords in the search expression. + * + * @param $expression + * The search expression to extract from. + * @param $option + * The name of the option to retrieve from the search expression. + * + * @return + * The value previously stored in the search expression for option $option, + * if any. Trailing spaces in values will not be included. + */ +function search_expression_extract($expression, $option) { + if (preg_match('/(^| )' . $option . ':([^ ]*)( |$)/i', $expression, $matches)) { + return $matches[2]; + } +} + +/** + * Adds a module-specific search option to a search expression. + * + * Search options are added using search_expression_insert(), and retrieved + * using search_expression_extract(). They take the form option:value, and + * are added to the ordinary keywords in the search expression. + * + * @param $expression + * The search expression to add to. + * @param $option + * The name of the option to add to the search expression. + * @param $value + * The value to add for the option. If present, it will replace any previous + * value added for the option. Cannot contain any spaces or | characters, as + * these are used as delimiters. If you want to add a blank value $option: to + * the search expression, pass in an empty string or a string that is composed + * of only spaces. To clear a previously-stored option without adding a + * replacement, pass in NULL for $value or omit. + * + * @return + * $expression, with any previous value for this option removed, and a new + * $option:$value pair added if $value was provided. + */ +function search_expression_insert($expression, $option, $value = NULL) { + // Remove any previous values stored with $option. + $expression = trim(preg_replace('/(^| )' . $option . ':[^ ]*/i', '', $expression)); + + // Set new value, if provided. + if (isset($value)) { + $expression .= ' ' . $option . ':' . trim($value); + } + return $expression; +} + +/** + * @defgroup search Search interface + * @{ + * The Drupal search interface manages a global search mechanism. + * + * Modules may plug into this system to provide searches of different types of + * data. Most of the system is handled by search.module, so this must be enabled + * for all of the search features to work. + * + * There are three ways to interact with the search system: + * - Specifically for searching nodes, you can implement + * hook_node_update_index() and hook_node_search_result(). However, note that + * the search system already indexes all visible output of a node; i.e., + * everything displayed normally by hook_view() and hook_node_view(). This is + * usually sufficient. You should only use this mechanism if you want + * additional, non-visible data to be indexed. + * - Implement hook_search_info(). This will create a search tab for your module + * on the /search page with a simple keyword search form. You will also need + * to implement hook_search_execute() to perform the search. + * - Implement hook_update_index(). This allows your module to use Drupal's + * HTML indexing mechanism for searching full text efficiently. + * + * If your module needs to provide a more complicated search form, then you need + * to implement it yourself without hook_search_info(). In that case, you should + * define it as a local task (tab) under the /search page (e.g. /search/mymodule) + * so that users can easily find it. + */ + +/** + * Builds a search form. + * + * @param $action + * Form action. Defaults to "search/$path", where $path is the search path + * associated with the module in its hook_search_info(). This will be + * run through url(). + * @param $keys + * The search string entered by the user, containing keywords for the search. + * @param $module + * The search module to render the form for: a module that implements + * hook_search_info(). If not supplied, the default search module is used. + * @param $prompt + * Label for the keywords field. Defaults to t('Enter your keywords') if NULL. + * Supply '' to omit. + * + * @return + * A Form API array for the search form. + */ +function search_form($form, &$form_state, $action = '', $keys = '', $module = NULL, $prompt = NULL) { + $module_info = FALSE; + if (!$module) { + $module_info = search_get_default_module_info(); + } + else { + $info = search_get_info(); + $module_info = isset($info[$module]) ? $info[$module] : FALSE; + } + + // Sanity check. + if (!$module_info) { + form_set_error(NULL, t('Search is currently disabled.'), 'error'); + return $form; + } + + if (!$action) { + $action = 'search/' . $module_info['path']; + } + if (!isset($prompt)) { + $prompt = t('Enter your keywords'); + } + + $form['#action'] = url($action); + // Record the $action for later use in redirecting. + $form_state['action'] = $action; + $form['#attributes']['class'][] = 'search-form'; + $form['module'] = array('#type' => 'value', '#value' => $module); + $form['basic'] = array('#type' => 'container', '#attributes' => array('class' => array('container-inline'))); + $form['basic']['keys'] = array( + '#type' => 'textfield', + '#title' => $prompt, + '#default_value' => $keys, + '#size' => $prompt ? 40 : 20, + '#maxlength' => 255, + ); + // processed_keys is used to coordinate keyword passing between other forms + // that hook into the basic search form. + $form['basic']['processed_keys'] = array('#type' => 'value', '#value' => ''); + $form['basic']['submit'] = array('#type' => 'submit', '#value' => t('Search')); + + return $form; +} + +/** + * Form builder; Output a search form for the search block's search box. + * + * @ingroup forms + * @see search_box_form_submit() + * @see search-block-form.tpl.php + */ +function search_box($form, &$form_state, $form_id) { + $form[$form_id] = array( + '#type' => 'textfield', + '#title' => t('Search'), + '#title_display' => 'invisible', + '#size' => 15, + '#default_value' => '', + '#attributes' => array('title' => t('Enter the terms you wish to search for.')), + ); + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Search')); + $form['#submit'][] = 'search_box_form_submit'; + + return $form; +} + +/** + * Process a block search form submission. + */ +function search_box_form_submit($form, &$form_state) { + // The search form relies on control of the redirect destination for its + // functionality, so we override any static destination set in the request, + // for example by drupal_access_denied() or drupal_not_found() + // (see http://drupal.org/node/292565). + if (isset($_GET['destination'])) { + unset($_GET['destination']); + } + + // Check to see if the form was submitted empty. + // If it is empty, display an error message. + // (This method is used instead of setting #required to TRUE for this field + // because that results in a confusing error message. It would say a plain + // "field is required" because the search keywords field has no title. + // The error message would also complain about a missing #title field.) + if ($form_state['values']['search_block_form'] == '') { + form_set_error('keys', t('Please enter some keywords.')); + } + + $form_id = $form['form_id']['#value']; + $info = search_get_default_module_info(); + if ($info) { + $form_state['redirect'] = 'search/' . $info['path'] . '/' . trim($form_state['values'][$form_id]); + } + else { + form_set_error(NULL, t('Search is currently disabled.'), 'error'); + } +} + +/** + * Process variables for search-block-form.tpl.php. + * + * The $variables array contains the following arguments: + * - $form + * + * @see search-block-form.tpl.php + */ +function template_preprocess_search_block_form(&$variables) { + $variables['search'] = array(); + $hidden = array(); + // Provide variables named after form keys so themers can print each element independently. + foreach (element_children($variables['form']) as $key) { + $type = isset($variables['form'][$key]['#type']) ? $variables['form'][$key]['#type'] : ''; + if ($type == 'hidden' || $type == 'token') { + $hidden[] = drupal_render($variables['form'][$key]); + } + else { + $variables['search'][$key] = drupal_render($variables['form'][$key]); + } + } + // Hidden form elements have no value to themers. No need for separation. + $variables['search']['hidden'] = implode($hidden); + // Collect all form elements to make it easier to print the whole form. + $variables['search_form'] = implode($variables['search']); +} + +/** + * Performs a search by calling hook_search_execute(). + * + * @param $keys + * Keyword query to search on. + * @param $module + * Search module to search. + * @param $conditions + * Optional array of additional search conditions. + * + * @return + * Renderable array of search results. No return value if $keys are not + * supplied or if the given search module is not active. + */ +function search_data($keys, $module, $conditions = NULL) { + if (module_hook($module, 'search_execute')) { + $results = module_invoke($module, 'search_execute', $keys, $conditions); + if (module_hook($module, 'search_page')) { + return module_invoke($module, 'search_page', $results); + } + else { + return array( + '#theme' => 'search_results', + '#results' => $results, + '#module' => $module, + ); + } + } +} + +/** + * Returns snippets from a piece of text, with certain keywords highlighted. + * Used for formatting search results. + * + * @param $keys + * A string containing a search query. + * + * @param $text + * The text to extract fragments from. + * + * @return + * A string containing HTML for the excerpt. + */ +function search_excerpt($keys, $text) { + // We highlight around non-indexable or CJK characters. + $boundary = '(?:(?<=[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . PREG_CLASS_CJK . '])|(?=[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . PREG_CLASS_CJK . ']))'; + + // Extract positive keywords and phrases + preg_match_all('/ ("([^"]+)"|(?!OR)([^" ]+))/', ' ' . $keys, $matches); + $keys = array_merge($matches[2], $matches[3]); + + // Prepare text by stripping HTML tags and decoding HTML entities. + $text = strip_tags(str_replace(array('<', '>'), array(' <', '> '), $text)); + $text = decode_entities($text); + + // Slash-escape quotes in the search keyword string. + array_walk($keys, '_search_excerpt_replace'); + $workkeys = $keys; + + // Extract fragments around keywords. + // First we collect ranges of text around each keyword, starting/ending + // at spaces, trying to get to 256 characters. + // If the sum of all fragments is too short, we look for second occurrences. + $ranges = array(); + $included = array(); + $foundkeys = array(); + $length = 0; + while ($length < 256 && count($workkeys)) { + foreach ($workkeys as $k => $key) { + if (strlen($key) == 0) { + unset($workkeys[$k]); + unset($keys[$k]); + continue; + } + if ($length >= 256) { + break; + } + // Remember occurrence of key so we can skip over it if more occurrences + // are desired. + if (!isset($included[$key])) { + $included[$key] = 0; + } + // Locate a keyword (position $p, always >0 because $text starts with a + // space). First try bare keyword, but if that doesn't work, try to find a + // derived form from search_simplify(). + $p = 0; + if (preg_match('/' . $boundary . $key . $boundary . '/iu', $text, $match, PREG_OFFSET_CAPTURE, $included[$key])) { + $p = $match[0][1]; + } + else { + $info = search_simplify_excerpt_match($key, $text, $included[$key], $boundary); + if ($info['where']) { + $p = $info['where']; + if ($info['keyword']) { + $foundkeys[] = $info['keyword']; + } + } + } + // Now locate a space in front (position $q) and behind it (position $s), + // leaving about 60 characters extra before and after for context. + // Note that a space was added to the front and end of $text above. + if ($p) { + if (($q = strpos(' ' . $text, ' ', max(0, $p - 61))) !== FALSE) { + $end = substr($text . ' ', $p, 80); + if (($s = strrpos($end, ' ')) !== FALSE) { + // Account for the added spaces. + $q = max($q - 1, 0); + $s = min($s, strlen($end) - 1); + $ranges[$q] = $p + $s; + $length += $p + $s - $q; + $included[$key] = $p + 1; + } + else { + unset($workkeys[$k]); + } + } + else { + unset($workkeys[$k]); + } + } + else { + unset($workkeys[$k]); + } + } + } + + if (count($ranges) == 0) { + // We didn't find any keyword matches, so just return the first part of the + // text. We also need to re-encode any HTML special characters that we + // entity-decoded above. + return check_plain(truncate_utf8($text, 256, TRUE, TRUE)); + } + + // Sort the text ranges by starting position. + ksort($ranges); + + // Now we collapse overlapping text ranges into one. The sorting makes it O(n). + $newranges = array(); + foreach ($ranges as $from2 => $to2) { + if (!isset($from1)) { + $from1 = $from2; + $to1 = $to2; + continue; + } + if ($from2 <= $to1) { + $to1 = max($to1, $to2); + } + else { + $newranges[$from1] = $to1; + $from1 = $from2; + $to1 = $to2; + } + } + $newranges[$from1] = $to1; + + // Fetch text + $out = array(); + foreach ($newranges as $from => $to) { + $out[] = substr($text, $from, $to - $from); + } + + // Let translators have the ... separator text as one chunk. + $dots = explode('!excerpt', t('... !excerpt ... !excerpt ...')); + + $text = (isset($newranges[0]) ? '' : $dots[0]) . implode($dots[1], $out) . $dots[2]; + $text = check_plain($text); + + // Slash-escape quotes in keys found in a derived form and merge with original keys. + array_walk($foundkeys, '_search_excerpt_replace'); + $keys = array_merge($keys, $foundkeys); + + // Highlight keywords. Must be done at once to prevent conflicts ('strong' and ''). + $text = preg_replace('/' . $boundary . '(' . implode('|', $keys) . ')' . $boundary . '/iu', '\0', $text); + return $text; +} + +/** + * @} End of "defgroup search". + */ + +/** + * Helper function for array_walk() in search_excerpt(). + */ +function _search_excerpt_replace(&$text) { + $text = preg_quote($text, '/'); +} + +/** + * Find words in the original text that matched via search_simplify(). + * + * This is called in search_excerpt() if an exact match is not found in the + * text, so that we can find the derived form that matches. + * + * @param $key + * The keyword to find. + * @param $text + * The text to search for the keyword. + * @param $offset + * Offset position in $text to start searching at. + * @param $boundary + * Text to include in a regular expression that will match a word boundary. + * + * @return + * FALSE if no match is found. If a match is found, return an associative + * array with element 'where' giving the position of the match, and element + * 'keyword' giving the actual word found in the text at that position. + */ +function search_simplify_excerpt_match($key, $text, $offset, $boundary) { + $pos = NULL; + $simplified_key = search_simplify($key); + $simplified_text = search_simplify($text); + + // Return immediately if simplified key or text are empty. + if (!$simplified_key || !$simplified_text) { + return FALSE; + } + + // Check if we have a match after simplification in the text. + if (!preg_match('/' . $boundary . $simplified_key . $boundary . '/iu', $simplified_text, $match, PREG_OFFSET_CAPTURE, $offset)) { + return FALSE; + } + + // If we get here, we have a match. Now find the exact location of the match + // and the original text that matched. Start by splitting up the text by all + // potential starting points of the matching text and iterating through them. + $split = array_filter(preg_split('/' . $boundary . '/iu', $text, -1, PREG_SPLIT_OFFSET_CAPTURE), '_search_excerpt_match_filter'); + foreach ($split as $value) { + // Skip starting points before the offset. + if ($value[1] < $offset) { + continue; + } + + // Check a window of 80 characters after the starting point for a match, + // based on the size of the excerpt window. + $window = substr($text, $value[1], 80); + $simplified_window = search_simplify($window); + if (strpos($simplified_window, $simplified_key) === 0) { + // We have a match in this window. Store the position of the match. + $pos = $value[1]; + // Iterate through the text in the window until we find the full original + // matching text. + $length = strlen($window); + for ($i = 1; $i <= $length; $i++) { + $keyfound = substr($text, $value[1], $i); + if ($simplified_key == search_simplify($keyfound)) { + break; + } + } + break; + } + } + + return $pos ? array('where' => $pos, 'keyword' => $keyfound) : FALSE; +} + +/** + * Helper function for array_filter() in search_search_excerpt_match(). + */ +function _search_excerpt_match_filter($var) { + return strlen(trim($var[0])); +} + +/** + * Implements hook_forms(). + */ +function search_forms() { + $forms['search_block_form']= array( + 'callback' => 'search_box', + 'callback arguments' => array('search_block_form'), + ); + return $forms; +} + diff --git a/drupal-dev/modules/search/search.pages.inc b/drupal-dev/modules/search/search.pages.inc new file mode 100644 index 0000000..9dd00a6 --- /dev/null +++ b/drupal-dev/modules/search/search.pages.inc @@ -0,0 +1,158 @@ + ''); + // Process the search form. Note that if there is $_POST data, + // search_form_submit() will cause a redirect to search/[module path]/[keys], + // which will get us back to this page callback. In other words, the search + // form submits with POST but redirects to GET. This way we can keep + // the search query URL clean as a whistle. + if (empty($_POST['form_id']) || $_POST['form_id'] != 'search_form') { + $conditions = NULL; + if (isset($info['conditions_callback']) && function_exists($info['conditions_callback'])) { + // Build an optional array of more search conditions. + $conditions = call_user_func($info['conditions_callback'], $keys); + } + // Only search if there are keywords or non-empty conditions. + if ($keys || !empty($conditions)) { + // Log the search keys. + watchdog('search', 'Searched %type for %keys.', array('%keys' => $keys, '%type' => $info['title']), WATCHDOG_NOTICE, l(t('results'), 'search/' . $info['path'] . '/' . $keys)); + + // Collect the search results. + $results = search_data($keys, $info['module'], $conditions); + } + } + // The form may be altered based on whether the search was run. + $build['search_form'] = drupal_get_form('search_form', NULL, $keys, $info['module']); + $build['search_results'] = $results; + + return $build; +} + +/** + * Process variables for search-results.tpl.php. + * + * The $variables array contains the following arguments: + * - $results: Search results array. + * - $module: Module the search results came from (module implementing + * hook_search_info()). + * + * @see search-results.tpl.php + */ +function template_preprocess_search_results(&$variables) { + $variables['search_results'] = ''; + if (!empty($variables['module'])) { + $variables['module'] = check_plain($variables['module']); + } + foreach ($variables['results'] as $result) { + $variables['search_results'] .= theme('search_result', array('result' => $result, 'module' => $variables['module'])); + } + $variables['pager'] = theme('pager', array('tags' => NULL)); + $variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module']; +} + +/** + * Process variables for search-result.tpl.php. + * + * The $variables array contains the following arguments: + * - $result + * - $module + * + * @see search-result.tpl.php + */ +function template_preprocess_search_result(&$variables) { + global $language; + + $result = $variables['result']; + $variables['url'] = check_url($result['link']); + $variables['title'] = check_plain($result['title']); + if (isset($result['language']) && $result['language'] != $language->language && $result['language'] != LANGUAGE_NONE) { + $variables['title_attributes_array']['xml:lang'] = $result['language']; + $variables['content_attributes_array']['xml:lang'] = $result['language']; + } + + $info = array(); + if (!empty($result['module'])) { + $info['module'] = check_plain($result['module']); + } + if (!empty($result['user'])) { + $info['user'] = $result['user']; + } + if (!empty($result['date'])) { + $info['date'] = format_date($result['date'], 'short'); + } + if (isset($result['extra']) && is_array($result['extra'])) { + $info = array_merge($info, $result['extra']); + } + // Check for existence. User search does not include snippets. + $variables['snippet'] = isset($result['snippet']) ? $result['snippet'] : ''; + // Provide separated and grouped meta information.. + $variables['info_split'] = $info; + $variables['info'] = implode(' - ', $info); + $variables['theme_hook_suggestions'][] = 'search_result__' . $variables['module']; +} + +/** + * As the search form collates keys from other modules hooked in via + * hook_form_alter, the validation takes place in _submit. + * search_form_validate() is used solely to set the 'processed_keys' form + * value for the basic search form. + */ +function search_form_validate($form, &$form_state) { + form_set_value($form['basic']['processed_keys'], trim($form_state['values']['keys']), $form_state); +} + +/** + * Process a search form submission. + */ +function search_form_submit($form, &$form_state) { + $keys = $form_state['values']['processed_keys']; + if ($keys == '') { + form_set_error('keys', t('Please enter some keywords.')); + // Fall through to the form redirect. + } + + $form_state['redirect'] = $form_state['action'] . '/' . $keys; +} diff --git a/drupal-dev/modules/search/search.test b/drupal-dev/modules/search/search.test new file mode 100644 index 0000000..09c879b --- /dev/null +++ b/drupal-dev/modules/search/search.test @@ -0,0 +1,2079 @@ + 'Search engine queries', + 'description' => 'Indexes content and queries it.', + 'group' => 'Search', + ); + } + + /** + * Implementation setUp(). + */ + function setUp() { + parent::setUp('search'); + } + + /** + * Test search indexing. + */ + function testMatching() { + $this->_setup(); + $this->_testQueries(); + } + + /** + * Set up a small index of items to test against. + */ + function _setup() { + variable_set('minimum_word_size', 3); + + for ($i = 1; $i <= 7; ++$i) { + search_index($i, SEARCH_TYPE, $this->getText($i)); + } + for ($i = 1; $i <= 5; ++$i) { + search_index($i + 7, SEARCH_TYPE_2, $this->getText2($i)); + } + // No getText builder function for Japanese text; just a simple array. + foreach (array( + 13 => '以呂波耳・ほへとち。リヌルヲ。', + 14 => 'ドルーパルが大好きよ!', + 15 => 'コーヒーとケーキ', + ) as $i => $jpn) { + search_index($i, SEARCH_TYPE_JPN, $jpn); + } + search_update_totals(); + } + + /** + * _test_: Helper method for generating snippets of content. + * + * Generated items to test against: + * 1 ipsum + * 2 dolore sit + * 3 sit am ut + * 4 am ut enim am + * 5 ut enim am minim veniam + * 6 enim am minim veniam es cillum + * 7 am minim veniam es cillum dolore eu + */ + function getText($n) { + $words = explode(' ', "Ipsum dolore sit am. Ut enim am minim veniam. Es cillum dolore eu."); + return implode(' ', array_slice($words, $n - 1, $n)); + } + + /** + * _test2_: Helper method for generating snippets of content. + * + * Generated items to test against: + * 8 dear + * 9 king philip + * 10 philip came over + * 11 came over from germany + * 12 over from germany swimming + */ + function getText2($n) { + $words = explode(' ', "Dear King Philip came over from Germany swimming."); + return implode(' ', array_slice($words, $n - 1, $n)); + } + + /** + * Run predefine queries looking for indexed terms. + */ + function _testQueries() { + /* + Note: OR queries that include short words in OR groups are only accepted + if the ORed terms are ANDed with at least one long word in the rest of the query. + + e.g. enim dolore OR ut = enim (dolore OR ut) = (enim dolor) OR (enim ut) -> good + e.g. dolore OR ut = (dolore) OR (ut) -> bad + + This is a design limitation to avoid full table scans. + */ + $queries = array( + // Simple AND queries. + 'ipsum' => array(1), + 'enim' => array(4, 5, 6), + 'xxxxx' => array(), + 'enim minim' => array(5, 6), + 'enim xxxxx' => array(), + 'dolore eu' => array(7), + 'dolore xx' => array(), + 'ut minim' => array(5), + 'xx minim' => array(), + 'enim veniam am minim ut' => array(5), + // Simple OR queries. + 'dolore OR ipsum' => array(1, 2, 7), + 'dolore OR xxxxx' => array(2, 7), + 'dolore OR ipsum OR enim' => array(1, 2, 4, 5, 6, 7), + 'ipsum OR dolore sit OR cillum' => array(2, 7), + 'minim dolore OR ipsum' => array(7), + 'dolore OR ipsum veniam' => array(7), + 'minim dolore OR ipsum OR enim' => array(5, 6, 7), + 'dolore xx OR yy' => array(), + 'xxxxx dolore OR ipsum' => array(), + // Negative queries. + 'dolore -sit' => array(7), + 'dolore -eu' => array(2), + 'dolore -xxxxx' => array(2, 7), + 'dolore -xx' => array(2, 7), + // Phrase queries. + '"dolore sit"' => array(2), + '"sit dolore"' => array(), + '"am minim veniam es"' => array(6, 7), + '"minim am veniam es"' => array(), + // Mixed queries. + '"am minim veniam es" OR dolore' => array(2, 6, 7), + '"minim am veniam es" OR "dolore sit"' => array(2), + '"minim am veniam es" OR "sit dolore"' => array(), + '"am minim veniam es" -eu' => array(6), + '"am minim veniam" -"cillum dolore"' => array(5, 6), + '"am minim veniam" -"dolore cillum"' => array(5, 6, 7), + 'xxxxx "minim am veniam es" OR dolore' => array(), + 'xx "minim am veniam es" OR dolore' => array() + ); + foreach ($queries as $query => $results) { + $result = db_select('search_index', 'i') + ->extend('SearchQuery') + ->searchExpression($query, SEARCH_TYPE) + ->execute(); + + $set = $result ? $result->fetchAll() : array(); + $this->_testQueryMatching($query, $set, $results); + $this->_testQueryScores($query, $set, $results); + } + + // These queries are run against the second index type, SEARCH_TYPE_2. + $queries = array( + // Simple AND queries. + 'ipsum' => array(), + 'enim' => array(), + 'enim minim' => array(), + 'dear' => array(8), + 'germany' => array(11, 12), + ); + foreach ($queries as $query => $results) { + $result = db_select('search_index', 'i') + ->extend('SearchQuery') + ->searchExpression($query, SEARCH_TYPE_2) + ->execute(); + + $set = $result ? $result->fetchAll() : array(); + $this->_testQueryMatching($query, $set, $results); + $this->_testQueryScores($query, $set, $results); + } + + // These queries are run against the third index type, SEARCH_TYPE_JPN. + $queries = array( + // Simple AND queries. + '呂波耳' => array(13), + '以呂波耳' => array(13), + 'ほへと ヌルヲ' => array(13), + 'とちリ' => array(), + 'ドルーパル' => array(14), + 'パルが大' => array(14), + 'コーヒー' => array(15), + 'ヒーキ' => array(), + ); + foreach ($queries as $query => $results) { + $result = db_select('search_index', 'i') + ->extend('SearchQuery') + ->searchExpression($query, SEARCH_TYPE_JPN) + ->execute(); + + $set = $result ? $result->fetchAll() : array(); + $this->_testQueryMatching($query, $set, $results); + $this->_testQueryScores($query, $set, $results); + } + } + + /** + * Test the matching abilities of the engine. + * + * Verify if a query produces the correct results. + */ + function _testQueryMatching($query, $set, $results) { + // Get result IDs. + $found = array(); + foreach ($set as $item) { + $found[] = $item->sid; + } + + // Compare $results and $found. + sort($found); + sort($results); + $this->assertEqual($found, $results, "Query matching '$query'"); + } + + /** + * Test the scoring abilities of the engine. + * + * Verify if a query produces normalized, monotonous scores. + */ + function _testQueryScores($query, $set, $results) { + // Get result scores. + $scores = array(); + foreach ($set as $item) { + $scores[] = $item->calculated_score; + } + + // Check order. + $sorted = $scores; + sort($sorted); + $this->assertEqual($scores, array_reverse($sorted), "Query order '$query'"); + + // Check range. + $this->assertEqual(!count($scores) || (min($scores) > 0.0 && max($scores) <= 1.0001), TRUE, "Query scoring '$query'"); + } +} + +/** + * Tests the bike shed text on no results page, and text on the search page. + */ +class SearchPageText extends DrupalWebTestCase { + protected $searching_user; + + public static function getInfo() { + return array( + 'name' => 'Search page text', + 'description' => 'Tests the bike shed text on the no results page, and various other text on search pages.', + 'group' => 'Search' + ); + } + + function setUp() { + parent::setUp('search'); + + // Create user. + $this->searching_user = $this->drupalCreateUser(array('search content', 'access user profiles')); + } + + /** + * Tests the failed search text, and various other text on the search page. + */ + function testSearchText() { + $this->drupalLogin($this->searching_user); + $this->drupalGet('search/node'); + $this->assertText(t('Enter your keywords')); + $this->assertText(t('Search')); + $title = t('Search') . ' | Drupal'; + $this->assertTitle($title, 'Search page title is correct'); + + $edit = array(); + $edit['keys'] = 'bike shed ' . $this->randomName(); + $this->drupalPost('search/node', $edit, t('Search')); + $this->assertText(t('Consider loosening your query with OR. bike OR shed will often show more results than bike shed.'), 'Help text is displayed when search returns no results.'); + $this->assertText(t('Search')); + $this->assertTitle($title, 'Search page title is correct'); + + $edit['keys'] = $this->searching_user->name; + $this->drupalPost('search/user', $edit, t('Search')); + $this->assertText(t('Search')); + $this->assertTitle($title, 'Search page title is correct'); + + // Test that search keywords containing slashes are correctly loaded + // from the path and displayed in the search form. + $arg = $this->randomName() . '/' . $this->randomName(); + $this->drupalGet('search/node/' . $arg); + $input = $this->xpath("//input[@id='edit-keys' and @value='{$arg}']"); + $this->assertFalse(empty($input), 'Search keys with a / are correctly set as the default value in the search box.'); + + // Test a search input exceeding the limit of AND/OR combinations to test + // the Denial-of-Service protection. + $limit = variable_get('search_and_or_limit', 7); + $keys = array(); + for ($i = 0; $i < $limit + 1; $i++) { + $keys[] = $this->randomName(3); + if ($i % 2 == 0) { + $keys[] = 'OR'; + } + } + $edit['keys'] = implode(' ', $keys); + $this->drupalPost('search/node', $edit, t('Search')); + $this->assertRaw(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => $limit))); + } +} + +class SearchAdvancedSearchForm extends DrupalWebTestCase { + protected $node; + + public static function getInfo() { + return array( + 'name' => 'Advanced search form', + 'description' => 'Indexes content and tests the advanced search form.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search'); + // Create and login user. + $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes')); + $this->drupalLogin($test_user); + + // Create initial node. + $node = $this->drupalCreateNode(); + $this->node = $this->drupalCreateNode(); + + // First update the index. This does the initial processing. + node_update_index(); + + // Then, run the shutdown function. Testing is a unique case where indexing + // and searching has to happen in the same request, so running the shutdown + // function manually is needed to finish the indexing process. + search_update_totals(); + } + + /** + * Test using the search form with GET and POST queries. + * Test using the advanced search form to limit search to nodes of type "Basic page". + */ + function testNodeType() { + $this->assertTrue($this->node->type == 'page', 'Node type is Basic page.'); + + // Assert that the dummy title doesn't equal the real title. + $dummy_title = 'Lorem ipsum'; + $this->assertNotEqual($dummy_title, $this->node->title, "Dummy title doesn't equal node title"); + + // Search for the dummy title with a GET query. + $this->drupalGet('search/node/' . $dummy_title); + $this->assertNoText($this->node->title, 'Basic page node is not found with dummy title.'); + + // Search for the title of the node with a GET query. + $this->drupalGet('search/node/' . $this->node->title); + $this->assertText($this->node->title, 'Basic page node is found with GET query.'); + + // Search for the title of the node with a POST query. + $edit = array('or' => $this->node->title); + $this->drupalPost('search/node', $edit, t('Advanced search')); + $this->assertText($this->node->title, 'Basic page node is found with POST query.'); + + // Advanced search type option. + $this->drupalPost('search/node', array_merge($edit, array('type[page]' => 'page')), t('Advanced search')); + $this->assertText($this->node->title, 'Basic page node is found with POST query and type:page.'); + + $this->drupalPost('search/node', array_merge($edit, array('type[article]' => 'article')), t('Advanced search')); + $this->assertText('bike shed', 'Article node is not found with POST query and type:article.'); + } +} + +class SearchRankingTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Search engine ranking', + 'description' => 'Indexes content and tests ranking factors.', + 'group' => 'Search', + ); + } + + /** + * Implementation setUp(). + */ + function setUp() { + parent::setUp('search', 'statistics', 'comment'); + } + + function testRankings() { + // Login with sufficient privileges. + $this->drupalLogin($this->drupalCreateUser(array('skip comment approval', 'create page content'))); + + // Build a list of the rankings to test. + $node_ranks = array('sticky', 'promote', 'relevance', 'recent', 'comments', 'views'); + + // Create nodes for testing. + foreach ($node_ranks as $node_rank) { + $settings = array( + 'type' => 'page', + 'title' => 'Drupal rocks', + 'body' => array(LANGUAGE_NONE => array(array('value' => "Drupal's search rocks"))), + ); + foreach (array(0, 1) as $num) { + if ($num == 1) { + switch ($node_rank) { + case 'sticky': + case 'promote': + $settings[$node_rank] = 1; + break; + case 'relevance': + $settings['body'][LANGUAGE_NONE][0]['value'] .= " really rocks"; + break; + case 'recent': + $settings['created'] = REQUEST_TIME + 3600; + break; + case 'comments': + $settings['comment'] = 2; + break; + } + } + $nodes[$node_rank][$num] = $this->drupalCreateNode($settings); + } + } + + // Update the search index. + module_invoke_all('update_index'); + search_update_totals(); + + // Refresh variables after the treatment. + $this->refreshVariables(); + + // Add a comment to one of the nodes. + $edit = array(); + $edit['subject'] = 'my comment title'; + $edit['comment_body[' . LANGUAGE_NONE . '][0][value]'] = 'some random comment'; + $this->drupalGet('comment/reply/' . $nodes['comments'][1]->nid); + $this->drupalPost(NULL, $edit, t('Preview')); + $this->drupalPost(NULL, $edit, t('Save')); + + // Enable counting of statistics. + variable_set('statistics_count_content_views', 1); + + // Then View one of the nodes a bunch of times. + for ($i = 0; $i < 5; $i ++) { + $this->drupalGet('node/' . $nodes['views'][1]->nid); + } + + // Test each of the possible rankings. + foreach ($node_ranks as $node_rank) { + // Disable all relevancy rankings except the one we are testing. + foreach ($node_ranks as $var) { + variable_set('node_rank_' . $var, $var == $node_rank ? 10 : 0); + } + + // Do the search and assert the results. + $set = node_search_execute('rocks'); + $this->assertEqual($set[0]['node']->nid, $nodes[$node_rank][1]->nid, 'Search ranking "' . $node_rank . '" order.'); + } + } + + /** + * Test rankings of HTML tags. + */ + function testHTMLRankings() { + // Login with sufficient privileges. + $this->drupalLogin($this->drupalCreateUser(array('create page content'))); + + // Test HTML tags with different weights. + $sorted_tags = array('h1', 'h2', 'h3', 'h4', 'a', 'h5', 'h6', 'notag'); + $shuffled_tags = $sorted_tags; + + // Shuffle tags to ensure HTML tags are ranked properly. + shuffle($shuffled_tags); + $settings = array( + 'type' => 'page', + 'title' => 'Simple node', + ); + foreach ($shuffled_tags as $tag) { + switch ($tag) { + case 'a': + $settings['body'] = array(LANGUAGE_NONE => array(array('value' => l('Drupal Rocks', 'node'), 'format' => 'full_html'))); + break; + case 'notag': + $settings['body'] = array(LANGUAGE_NONE => array(array('value' => 'Drupal Rocks'))); + break; + default: + $settings['body'] = array(LANGUAGE_NONE => array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html'))); + break; + } + $nodes[$tag] = $this->drupalCreateNode($settings); + } + + // Update the search index. + module_invoke_all('update_index'); + search_update_totals(); + + // Refresh variables after the treatment. + $this->refreshVariables(); + + // Disable all other rankings. + $node_ranks = array('sticky', 'promote', 'recent', 'comments', 'views'); + foreach ($node_ranks as $node_rank) { + variable_set('node_rank_' . $node_rank, 0); + } + $set = node_search_execute('rocks'); + + // Test the ranking of each tag. + foreach ($sorted_tags as $tag_rank => $tag) { + // Assert the results. + if ($tag == 'notag') { + $this->assertEqual($set[$tag_rank]['node']->nid, $nodes[$tag]->nid, 'Search tag ranking for plain text order.'); + } else { + $this->assertEqual($set[$tag_rank]['node']->nid, $nodes[$tag]->nid, 'Search tag ranking for "<' . $sorted_tags[$tag_rank] . '>" order.'); + } + } + + // Test tags with the same weight against the sorted tags. + $unsorted_tags = array('u', 'b', 'i', 'strong', 'em'); + foreach ($unsorted_tags as $tag) { + $settings['body'] = array(LANGUAGE_NONE => array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html'))); + $node = $this->drupalCreateNode($settings); + + // Update the search index. + module_invoke_all('update_index'); + search_update_totals(); + + // Refresh variables after the treatment. + $this->refreshVariables(); + + $set = node_search_execute('rocks'); + + // Ranking should always be second to last. + $set = array_slice($set, -2, 1); + + // Assert the results. + $this->assertEqual($set[0]['node']->nid, $node->nid, 'Search tag ranking for "<' . $tag . '>" order.'); + + // Delete node so it doesn't show up in subsequent search results. + node_delete($node->nid); + } + } + + /** + * Verifies that if we combine two rankings, search still works. + * + * See issue http://drupal.org/node/771596 + */ + function testDoubleRankings() { + // Login with sufficient privileges. + $this->drupalLogin($this->drupalCreateUser(array('skip comment approval', 'create page content'))); + + // See testRankings() above - build a node that will rank high for sticky. + $settings = array( + 'type' => 'page', + 'title' => 'Drupal rocks', + 'body' => array(LANGUAGE_NONE => array(array('value' => "Drupal's search rocks"))), + 'sticky' => 1, + ); + + $node = $this->drupalCreateNode($settings); + + // Update the search index. + module_invoke_all('update_index'); + search_update_totals(); + + // Refresh variables after the treatment. + $this->refreshVariables(); + + // Set up for ranking sticky and lots of comments; make sure others are + // disabled. + $node_ranks = array('sticky', 'promote', 'relevance', 'recent', 'comments', 'views'); + foreach ($node_ranks as $var) { + $value = ($var == 'sticky' || $var == 'comments') ? 10 : 0; + variable_set('node_rank_' . $var, $value); + } + + // Do the search and assert the results. + $set = node_search_execute('rocks'); + $this->assertEqual($set[0]['node']->nid, $node->nid, 'Search double ranking order.'); + } +} + +class SearchBlockTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Block availability', + 'description' => 'Check if the search form block is available.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search'); + + // Create and login user + $admin_user = $this->drupalCreateUser(array('administer blocks', 'search content')); + $this->drupalLogin($admin_user); + } + + function testSearchFormBlock() { + // Set block title to confirm that the interface is available. + $this->drupalPost('admin/structure/block/manage/search/form/configure', array('title' => $this->randomName(8)), t('Save block')); + $this->assertText(t('The block configuration has been saved.'), 'Block configuration set.'); + + // Set the block to a region to confirm block is available. + $edit = array(); + $edit['blocks[search_form][region]'] = 'footer'; + $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); + $this->assertText(t('The block settings have been updated.'), 'Block successfully move to footer region.'); + } + + /** + * Test that the search block form works correctly. + */ + function testBlock() { + // Enable the block, and place it in the 'content' region so that it isn't + // hidden on 404 pages. + $edit = array('blocks[search_form][region]' => 'content'); + $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); + + // Test a normal search via the block form, from the front page. + $terms = array('search_block_form' => 'test'); + $this->drupalPost('node', $terms, t('Search')); + $this->assertText('Your search yielded no results'); + + // Test a search from the block on a 404 page. + $this->drupalGet('foo'); + $this->assertResponse(404); + $this->drupalPost(NULL, $terms, t('Search')); + $this->assertResponse(200); + $this->assertText('Your search yielded no results'); + + // Test a search from the block when it doesn't appear on the search page. + $edit = array('pages' => 'search'); + $this->drupalPost('admin/structure/block/manage/search/form/configure', $edit, t('Save block')); + $this->drupalPost('node', $terms, t('Search')); + $this->assertText('Your search yielded no results'); + + // Confirm that the user is redirected to the search page. + $this->assertEqual( + $this->getUrl(), + url('search/node/' . $terms['search_block_form'], array('absolute' => TRUE)), + 'Redirected to correct url.' + ); + + // Test an empty search via the block form, from the front page. + $terms = array('search_block_form' => ''); + $this->drupalPost('node', $terms, t('Search')); + $this->assertText('Please enter some keywords'); + + // Confirm that the user is redirected to the search page, when form is submitted empty. + $this->assertEqual( + $this->getUrl(), + url('search/node/', array('absolute' => TRUE)), + 'Redirected to correct url.' + ); + } +} + +/** + * Tests that searching for a phrase gets the correct page count. + */ +class SearchExactTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Search engine phrase queries', + 'description' => 'Tests that searching for a phrase gets the correct page count.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search'); + } + + /** + * Tests that the correct number of pager links are found for both keywords and phrases. + */ + function testExactQuery() { + // Login with sufficient privileges. + $this->drupalLogin($this->drupalCreateUser(array('create page content', 'search content'))); + + $settings = array( + 'type' => 'page', + 'title' => 'Simple Node', + ); + // Create nodes with exact phrase. + for ($i = 0; $i <= 17; $i++) { + $settings['body'] = array(LANGUAGE_NONE => array(array('value' => 'love pizza'))); + $this->drupalCreateNode($settings); + } + // Create nodes containing keywords. + for ($i = 0; $i <= 17; $i++) { + $settings['body'] = array(LANGUAGE_NONE => array(array('value' => 'love cheesy pizza'))); + $this->drupalCreateNode($settings); + } + + // Update the search index. + module_invoke_all('update_index'); + search_update_totals(); + + // Refresh variables after the treatment. + $this->refreshVariables(); + + // Test that the correct number of pager links are found for keyword search. + $edit = array('keys' => 'love pizza'); + $this->drupalPost('search/node', $edit, t('Search')); + $this->assertLinkByHref('page=1', 0, '2nd page link is found for keyword search.'); + $this->assertLinkByHref('page=2', 0, '3rd page link is found for keyword search.'); + $this->assertLinkByHref('page=3', 0, '4th page link is found for keyword search.'); + $this->assertNoLinkByHref('page=4', '5th page link is not found for keyword search.'); + + // Test that the correct number of pager links are found for exact phrase search. + $edit = array('keys' => '"love pizza"'); + $this->drupalPost('search/node', $edit, t('Search')); + $this->assertLinkByHref('page=1', 0, '2nd page link is found for exact phrase search.'); + $this->assertNoLinkByHref('page=2', '3rd page link is not found for exact phrase search.'); + } +} + +/** + * Test integration searching comments. + */ +class SearchCommentTestCase extends DrupalWebTestCase { + protected $admin_user; + + public static function getInfo() { + return array( + 'name' => 'Comment Search tests', + 'description' => 'Verify text formats and filters used elsewhere.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('comment', 'search'); + + // Create and log in an administrative user having access to the Full HTML + // text format. + $full_html_format = filter_format_load('full_html'); + $permissions = array( + 'administer filters', + filter_permission_name($full_html_format), + 'administer permissions', + 'create page content', + 'skip comment approval', + 'access comments', + ); + $this->admin_user = $this->drupalCreateUser($permissions); + $this->drupalLogin($this->admin_user); + } + + /** + * Verify that comments are rendered using proper format in search results. + */ + function testSearchResultsComment() { + $comment_body = 'Test comment body'; + + variable_set('comment_preview_article', DRUPAL_OPTIONAL); + // Enable check_plain() for 'Filtered HTML' text format. + $filtered_html_format_id = 'filtered_html'; + $edit = array( + 'filters[filter_html_escape][status]' => TRUE, + ); + $this->drupalPost('admin/config/content/formats/' . $filtered_html_format_id, $edit, t('Save configuration')); + // Allow anonymous users to search content. + $edit = array( + DRUPAL_ANONYMOUS_RID . '[search content]' => 1, + DRUPAL_ANONYMOUS_RID . '[access comments]' => 1, + DRUPAL_ANONYMOUS_RID . '[post comments]' => 1, + ); + $this->drupalPost('admin/people/permissions', $edit, t('Save permissions')); + + // Create a node. + $node = $this->drupalCreateNode(array('type' => 'article')); + // Post a comment using 'Full HTML' text format. + $edit_comment = array(); + $edit_comment['subject'] = 'Test comment subject'; + $edit_comment['comment_body[' . LANGUAGE_NONE . '][0][value]'] = '

    ' . $comment_body . '

    '; + $full_html_format_id = 'full_html'; + $edit_comment['comment_body[' . LANGUAGE_NONE . '][0][format]'] = $full_html_format_id; + $this->drupalPost('comment/reply/' . $node->nid, $edit_comment, t('Save')); + + // Invoke search index update. + $this->drupalLogout(); + $this->cronRun(); + + // Search for the comment subject. + $edit = array( + 'search_block_form' => "'" . $edit_comment['subject'] . "'", + ); + $this->drupalPost('', $edit, t('Search')); + $this->assertText($node->title, 'Node found in search results.'); + $this->assertText($edit_comment['subject'], 'Comment subject found in search results.'); + + // Search for the comment body. + $edit = array( + 'search_block_form' => "'" . $comment_body . "'", + ); + $this->drupalPost('', $edit, t('Search')); + $this->assertText($node->title, 'Node found in search results.'); + + // Verify that comment is rendered using proper format. + $this->assertText($comment_body, 'Comment body text found in search results.'); + $this->assertNoRaw(t('n/a'), 'HTML in comment body is not hidden.'); + $this->assertNoRaw(check_plain($edit_comment['comment_body[' . LANGUAGE_NONE . '][0][value]']), 'HTML in comment body is not escaped.'); + + // Hide comments. + $this->drupalLogin($this->admin_user); + $node->comment = 0; + node_save($node); + + // Invoke search index update. + $this->drupalLogout(); + $this->cronRun(); + + // Search for $title. + $this->drupalPost('', $edit, t('Search')); + $this->assertNoText($comment_body, 'Comment body text not found in search results.'); + } + + /** + * Verify access rules for comment indexing with different permissions. + */ + function testSearchResultsCommentAccess() { + $comment_body = 'Test comment body'; + $this->comment_subject = 'Test comment subject'; + $this->admin_role = $this->admin_user->roles; + unset($this->admin_role[DRUPAL_AUTHENTICATED_RID]); + $this->admin_role = key($this->admin_role); + + // Create a node. + variable_set('comment_preview_article', DRUPAL_OPTIONAL); + $this->node = $this->drupalCreateNode(array('type' => 'article')); + + // Post a comment using 'Full HTML' text format. + $edit_comment = array(); + $edit_comment['subject'] = $this->comment_subject; + $edit_comment['comment_body[' . LANGUAGE_NONE . '][0][value]'] = '

    ' . $comment_body . '

    '; + $this->drupalPost('comment/reply/' . $this->node->nid, $edit_comment, t('Save')); + + $this->drupalLogout(); + $this->setRolePermissions(DRUPAL_ANONYMOUS_RID); + $this->checkCommentAccess('Anon user has search permission but no access comments permission, comments should not be indexed'); + + $this->setRolePermissions(DRUPAL_ANONYMOUS_RID, TRUE); + $this->checkCommentAccess('Anon user has search permission and access comments permission, comments should be indexed', TRUE); + + $this->drupalLogin($this->admin_user); + $this->drupalGet('admin/people/permissions'); + + // Disable search access for authenticated user to test admin user. + $this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, FALSE, FALSE); + + $this->setRolePermissions($this->admin_role); + $this->checkCommentAccess('Admin user has search permission but no access comments permission, comments should not be indexed'); + + $this->setRolePermissions($this->admin_role, TRUE); + $this->checkCommentAccess('Admin user has search permission and access comments permission, comments should be indexed', TRUE); + + $this->setRolePermissions(DRUPAL_AUTHENTICATED_RID); + $this->checkCommentAccess('Authenticated user has search permission but no access comments permission, comments should not be indexed'); + + $this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, TRUE); + $this->checkCommentAccess('Authenticated user has search permission and access comments permission, comments should be indexed', TRUE); + + // Verify that access comments permission is inherited from the + // authenticated role. + $this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, TRUE, FALSE); + $this->setRolePermissions($this->admin_role); + $this->checkCommentAccess('Admin user has search permission and no access comments permission, but comments should be indexed because admin user inherits authenticated user\'s permission to access comments', TRUE); + + // Verify that search content permission is inherited from the authenticated + // role. + $this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, TRUE, TRUE); + $this->setRolePermissions($this->admin_role, TRUE, FALSE); + $this->checkCommentAccess('Admin user has access comments permission and no search permission, but comments should be indexed because admin user inherits authenticated user\'s permission to search', TRUE); + + } + + /** + * Set permissions for role. + */ + function setRolePermissions($rid, $access_comments = FALSE, $search_content = TRUE) { + $permissions = array( + 'access comments' => $access_comments, + 'search content' => $search_content, + ); + user_role_change_permissions($rid, $permissions); + } + + /** + * Update search index and search for comment. + */ + function checkCommentAccess($message, $assume_access = FALSE) { + // Invoke search index update. + search_touch_node($this->node->nid); + $this->cronRun(); + + // Search for the comment subject. + $edit = array( + 'search_block_form' => "'" . $this->comment_subject . "'", + ); + $this->drupalPost('', $edit, t('Search')); + $method = $assume_access ? 'assertText' : 'assertNoText'; + $verb = $assume_access ? 'found' : 'not found'; + $this->{$method}($this->node->title, "Node $verb in search results: " . $message); + $this->{$method}($this->comment_subject, "Comment subject $verb in search results: " . $message); + } + + /** + * Verify that 'add new comment' does not appear in search results or index. + */ + function testAddNewComment() { + // Create a node with a short body. + $settings = array( + 'type' => 'article', + 'title' => 'short title', + 'body' => array(LANGUAGE_NONE => array(array('value' => 'short body text'))), + ); + + $user = $this->drupalCreateUser(array('search content', 'create article content', 'access content')); + $this->drupalLogin($user); + + $node = $this->drupalCreateNode($settings); + // Verify that if you view the node on its own page, 'add new comment' + // is there. + $this->drupalGet('node/' . $node->nid); + $this->assertText(t('Add new comment'), 'Add new comment appears on node page'); + + // Run cron to index this page. + $this->drupalLogout(); + $this->cronRun(); + + // Search for 'comment'. Should be no results. + $this->drupalLogin($user); + $this->drupalPost('search/node', array('keys' => 'comment'), t('Search')); + $this->assertText(t('Your search yielded no results'), 'No results searching for the word comment'); + + // Search for the node title. Should be found, and 'Add new comment' should + // not be part of the search snippet. + $this->drupalPost('search/node', array('keys' => 'short'), t('Search')); + $this->assertText($node->title, 'Search for keyword worked'); + $this->assertNoText(t('Add new comment'), 'Add new comment does not appear on search results page'); + } + +} + +/** + * Tests search_expression_insert() and search_expression_extract(). + * + * @see http://drupal.org/node/419388 (issue) + */ +class SearchExpressionInsertExtractTestCase extends DrupalUnitTestCase { + public static function getInfo() { + return array( + 'name' => 'Search expression insert/extract', + 'description' => 'Tests the functions search_expression_insert() and search_expression_extract()', + 'group' => 'Search', + ); + } + + function setUp() { + drupal_load('module', 'search'); + parent::setUp(); + } + + /** + * Tests search_expression_insert() and search_expression_extract(). + */ + function testInsertExtract() { + $base_expression = "mykeyword"; + // Build an array of option, value, what should be in the expression, what + // should be retrieved from expression. + $cases = array( + array('foo', 'bar', 'foo:bar', 'bar'), // Normal case. + array('foo', NULL, '', NULL), // Empty value: shouldn't insert. + array('foo', ' ', 'foo:', ''), // Space as value: should insert but retrieve empty string. + array('foo', '', 'foo:', ''), // Empty string as value: should insert but retrieve empty string. + array('foo', '0', 'foo:0', '0'), // String zero as value: should insert. + array('foo', 0, 'foo:0', '0'), // Numeric zero as value: should insert. + ); + + foreach ($cases as $index => $case) { + $after_insert = search_expression_insert($base_expression, $case[0], $case[1]); + if (empty($case[2])) { + $this->assertEqual($after_insert, $base_expression, "Empty insert does not change expression in case $index"); + } + else { + $this->assertEqual($after_insert, $base_expression . ' ' . $case[2], "Insert added correct expression for case $index"); + } + + $retrieved = search_expression_extract($after_insert, $case[0]); + if (!isset($case[3])) { + $this->assertFalse(isset($retrieved), "Empty retrieval results in unset value in case $index"); + } + else { + $this->assertEqual($retrieved, $case[3], "Value is retrieved for case $index"); + } + + $after_clear = search_expression_insert($after_insert, $case[0]); + $this->assertEqual(trim($after_clear), $base_expression, "After clearing, base expression is restored for case $index"); + + $cleared = search_expression_extract($after_clear, $case[0]); + $this->assertFalse(isset($cleared), "After clearing, value could not be retrieved for case $index"); + } + } +} + +/** + * Tests that comment count display toggles properly on comment status of node + * + * Issue 537278 + * + * - Nodes with comment status set to Open should always how comment counts + * - Nodes with comment status set to Closed should show comment counts + * only when there are comments + * - Nodes with comment status set to Hidden should never show comment counts + */ +class SearchCommentCountToggleTestCase extends DrupalWebTestCase { + protected $searching_user; + protected $searchable_nodes; + + public static function getInfo() { + return array( + 'name' => 'Comment count toggle', + 'description' => 'Verify that comment count display toggles properly on comment status of node.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search'); + + // Create searching user. + $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); + + // Create initial nodes. + $node_params = array('type' => 'article', 'body' => array(LANGUAGE_NONE => array(array('value' => 'SearchCommentToggleTestCase')))); + + $this->searchable_nodes['1 comment'] = $this->drupalCreateNode($node_params); + $this->searchable_nodes['0 comments'] = $this->drupalCreateNode($node_params); + + // Login with sufficient privileges. + $this->drupalLogin($this->searching_user); + + // Create a comment array + $edit_comment = array(); + $edit_comment['subject'] = $this->randomName(); + $edit_comment['comment_body[' . LANGUAGE_NONE . '][0][value]'] = $this->randomName(); + $filtered_html_format_id = 'filtered_html'; + $edit_comment['comment_body[' . LANGUAGE_NONE . '][0][format]'] = $filtered_html_format_id; + + // Post comment to the test node with comment + $this->drupalPost('comment/reply/' . $this->searchable_nodes['1 comment']->nid, $edit_comment, t('Save')); + + // First update the index. This does the initial processing. + node_update_index(); + + // Then, run the shutdown function. Testing is a unique case where indexing + // and searching has to happen in the same request, so running the shutdown + // function manually is needed to finish the indexing process. + search_update_totals(); + } + + /** + * Verify that comment count display toggles properly on comment status of node + */ + function testSearchCommentCountToggle() { + // Search for the nodes by string in the node body. + $edit = array( + 'search_block_form' => "'SearchCommentToggleTestCase'", + ); + + // Test comment count display for nodes with comment status set to Open + $this->drupalPost('', $edit, t('Search')); + $this->assertText(t('0 comments'), 'Empty comment count displays for nodes with comment status set to Open'); + $this->assertText(t('1 comment'), 'Non-empty comment count displays for nodes with comment status set to Open'); + + // Test comment count display for nodes with comment status set to Closed + $this->searchable_nodes['0 comments']->comment = COMMENT_NODE_CLOSED; + node_save($this->searchable_nodes['0 comments']); + $this->searchable_nodes['1 comment']->comment = COMMENT_NODE_CLOSED; + node_save($this->searchable_nodes['1 comment']); + + $this->drupalPost('', $edit, t('Search')); + $this->assertNoText(t('0 comments'), 'Empty comment count does not display for nodes with comment status set to Closed'); + $this->assertText(t('1 comment'), 'Non-empty comment count displays for nodes with comment status set to Closed'); + + // Test comment count display for nodes with comment status set to Hidden + $this->searchable_nodes['0 comments']->comment = COMMENT_NODE_HIDDEN; + node_save($this->searchable_nodes['0 comments']); + $this->searchable_nodes['1 comment']->comment = COMMENT_NODE_HIDDEN; + node_save($this->searchable_nodes['1 comment']); + + $this->drupalPost('', $edit, t('Search')); + $this->assertNoText(t('0 comments'), 'Empty comment count does not display for nodes with comment status set to Hidden'); + $this->assertNoText(t('1 comment'), 'Non-empty comment count does not display for nodes with comment status set to Hidden'); + } +} + +/** + * Test search_simplify() on every Unicode character, and some other cases. + */ +class SearchSimplifyTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Search simplify', + 'description' => 'Check that the search_simply() function works as intended.', + 'group' => 'Search', + ); + } + + /** + * Tests that all Unicode characters simplify correctly. + */ + function testSearchSimplifyUnicode() { + // This test uses a file that was constructed so that the even lines are + // boundary characters, and the odd lines are valid word characters. (It + // was generated as a sequence of all the Unicode characters, and then the + // boundary chararacters (punctuation, spaces, etc.) were split off into + // their own lines). So the even-numbered lines should simplify to nothing, + // and the odd-numbered lines we need to split into shorter chunks and + // verify that simplification doesn't lose any characters. + $input = file_get_contents(DRUPAL_ROOT . '/modules/search/tests/UnicodeTest.txt'); + $basestrings = explode(chr(10), $input); + $strings = array(); + foreach ($basestrings as $key => $string) { + if ($key %2) { + // Even line - should simplify down to a space. + $simplified = search_simplify($string); + $this->assertIdentical($simplified, ' ', "Line $key is excluded from the index"); + } + else { + // Odd line, should be word characters. + // Split this into 30-character chunks, so we don't run into limits + // of truncation in search_simplify(). + $start = 0; + while ($start < drupal_strlen($string)) { + $newstr = drupal_substr($string, $start, 30); + // Special case: leading zeros are removed from numeric strings, + // and there's one string in this file that is numbers starting with + // zero, so prepend a 1 on that string. + if (preg_match('/^[0-9]+$/', $newstr)) { + $newstr = '1' . $newstr; + } + $strings[] = $newstr; + $start += 30; + } + } + } + foreach ($strings as $key => $string) { + $simplified = search_simplify($string); + $this->assertTrue(drupal_strlen($simplified) >= drupal_strlen($string), "Nothing is removed from string $key."); + } + + // Test the low-numbered ASCII control characters separately. They are not + // in the text file because they are problematic for diff, especially \0. + $string = ''; + for ($i = 0; $i < 32; $i++) { + $string .= chr($i); + } + $this->assertIdentical(' ', search_simplify($string), 'Search simplify works for ASCII control characters.'); + } + + /** + * Tests that search_simplify() does the right thing with punctuation. + */ + function testSearchSimplifyPunctuation() { + $cases = array( + array('20.03/94-28,876', '20039428876', 'Punctuation removed from numbers'), + array('great...drupal--module', 'great drupal module', 'Multiple dot and dashes are word boundaries'), + array('very_great-drupal.module', 'verygreatdrupalmodule', 'Single dot, dash, underscore are removed'), + array('regular,punctuation;word', 'regular punctuation word', 'Punctuation is a word boundary'), + ); + + foreach ($cases as $case) { + $out = trim(search_simplify($case[0])); + $this->assertEqual($out, $case[1], $case[2]); + } + } +} + + +/** + * Tests keywords and conditions. + */ +class SearchKeywordsConditions extends DrupalWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'Keywords and conditions', + 'description' => 'Verify the search pulls in keywords and extra conditions.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search', 'search_extra_type'); + // Create searching user. + $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); + // Login with sufficient privileges. + $this->drupalLogin($this->searching_user); + // Test with all search modules enabled. + variable_set('search_active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type')); + menu_rebuild(); + } + + /** + * Verify the kewords are captured and conditions respected. + */ + function testSearchKeyswordsConditions() { + // No keys, not conditions - no results. + $this->drupalGet('search/dummy_path'); + $this->assertNoText('Dummy search snippet to display'); + // With keys - get results. + $keys = 'bike shed ' . $this->randomName(); + $this->drupalGet("search/dummy_path/{$keys}"); + $this->assertText("Dummy search snippet to display. Keywords: {$keys}"); + $keys = 'blue drop ' . $this->randomName(); + $this->drupalGet("search/dummy_path", array('query' => array('keys' => $keys))); + $this->assertText("Dummy search snippet to display. Keywords: {$keys}"); + // Add some conditions and keys. + $keys = 'moving drop ' . $this->randomName(); + $this->drupalGet("search/dummy_path/bike", array('query' => array('search_conditions' => $keys))); + $this->assertText("Dummy search snippet to display."); + $this->assertRaw(print_r(array('search_conditions' => $keys), TRUE)); + // Add some conditions and no keys. + $keys = 'drop kick ' . $this->randomName(); + $this->drupalGet("search/dummy_path", array('query' => array('search_conditions' => $keys))); + $this->assertText("Dummy search snippet to display."); + $this->assertRaw(print_r(array('search_conditions' => $keys), TRUE)); + } +} + +/** + * Tests that numbers can be searched. + */ +class SearchNumbersTestCase extends DrupalWebTestCase { + protected $test_user; + protected $numbers; + protected $nodes; + + public static function getInfo() { + return array( + 'name' => 'Search numbers', + 'description' => 'Check that numbers can be searched', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search'); + + $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); + $this->drupalLogin($this->test_user); + + // Create content with various numbers in it. + // Note: 50 characters is the current limit of the search index's word + // field. + $this->numbers = array( + 'ISBN' => '978-0446365383', + 'UPC' => '036000 291452', + 'EAN bar code' => '5901234123457', + 'negative' => '-123456.7890', + 'quoted negative' => '"-123456.7890"', + 'leading zero' => '0777777777', + 'tiny' => '111', + 'small' => '22222222222222', + 'medium' => '333333333333333333333333333', + 'large' => '444444444444444444444444444444444444444', + 'gigantic' => '5555555555555555555555555555555555555555555555555', + 'over fifty characters' => '666666666666666666666666666666666666666666666666666666666666', + 'date', '01/02/2009', + 'commas', '987,654,321', + ); + + foreach ($this->numbers as $doc => $num) { + $info = array( + 'body' => array(LANGUAGE_NONE => array(array('value' => $num))), + 'type' => 'page', + 'language' => LANGUAGE_NONE, + 'title' => $doc . ' number', + ); + $this->nodes[$doc] = $this->drupalCreateNode($info); + } + + // Run cron to ensure the content is indexed. + $this->cronRun(); + $this->drupalGet('admin/reports/dblog'); + $this->assertText(t('Cron run completed'), 'Log shows cron run completed'); + } + + /** + * Tests that all the numbers can be searched. + */ + function testNumberSearching() { + $types = array_keys($this->numbers); + + foreach ($types as $type) { + $number = $this->numbers[$type]; + // If the number is negative, remove the - sign, because - indicates + // "not keyword" when searching. + $number = ltrim($number, '-'); + $node = $this->nodes[$type]; + + // Verify that the node title does not appear on the search page + // with a dummy search. + $this->drupalPost('search/node', + array('keys' => 'foo'), + t('Search')); + $this->assertNoText($node->title, $type . ': node title not shown in dummy search'); + + // Verify that the node title does appear as a link on the search page + // when searching for the number. + $this->drupalPost('search/node', + array('keys' => $number), + t('Search')); + $this->assertText($node->title, format_string('%type: node title shown (search found the node) in search for number %number.', array('%type' => $type, '%number' => $number))); + } + } +} + +/** + * Tests that numbers can be searched, with more complex matching. + */ +class SearchNumberMatchingTestCase extends DrupalWebTestCase { + protected $test_user; + protected $numbers; + protected $nodes; + + public static function getInfo() { + return array( + 'name' => 'Search number matching', + 'description' => 'Check that numbers can be searched with more complex matching', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search'); + + $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); + $this->drupalLogin($this->test_user); + + // Define a group of numbers that should all match each other -- + // numbers with internal punctuation should match each other, as well + // as numbers with and without leading zeros and leading/trailing + // . and -. + $this->numbers = array( + '123456789', + '12/34/56789', + '12.3456789', + '12-34-56789', + '123,456,789', + '-123456789', + '0123456789', + ); + + foreach ($this->numbers as $num) { + $info = array( + 'body' => array(LANGUAGE_NONE => array(array('value' => $num))), + 'type' => 'page', + 'language' => LANGUAGE_NONE, + ); + $this->nodes[] = $this->drupalCreateNode($info); + } + + // Run cron to ensure the content is indexed. + $this->cronRun(); + $this->drupalGet('admin/reports/dblog'); + $this->assertText(t('Cron run completed'), 'Log shows cron run completed'); + } + + /** + * Tests that all the numbers can be searched. + */ + function testNumberSearching() { + for ($i = 0; $i < count($this->numbers); $i++) { + $node = $this->nodes[$i]; + + // Verify that the node title does not appear on the search page + // with a dummy search. + $this->drupalPost('search/node', + array('keys' => 'foo'), + t('Search')); + $this->assertNoText($node->title, format_string('%number: node title not shown in dummy search', array('%number' => $i))); + + // Now verify that we can find node i by searching for any of the + // numbers. + for ($j = 0; $j < count($this->numbers); $j++) { + $number = $this->numbers[$j]; + // If the number is negative, remove the - sign, because - indicates + // "not keyword" when searching. + $number = ltrim($number, '-'); + + $this->drupalPost('search/node', + array('keys' => $number), + t('Search')); + $this->assertText($node->title, format_string('%i: node title shown (search found the node) in search for number %number', array('%i' => $i, '%number' => $number))); + } + } + + } +} + +/** + * Test config page. + */ +class SearchConfigSettingsForm extends DrupalWebTestCase { + public $search_user; + public $search_node; + + public static function getInfo() { + return array( + 'name' => 'Config settings form', + 'description' => 'Verify the search config settings form.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search', 'search_extra_type'); + + // Login as a user that can create and search content. + $this->search_user = $this->drupalCreateUser(array('search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks')); + $this->drupalLogin($this->search_user); + + // Add a single piece of content and index it. + $node = $this->drupalCreateNode(); + $this->search_node = $node; + // Link the node to itself to test that it's only indexed once. The content + // also needs the word "pizza" so we can use it as the search keyword. + $langcode = LANGUAGE_NONE; + $body_key = "body[$langcode][0][value]"; + $edit[$body_key] = l($node->title, 'node/' . $node->nid) . ' pizza sandwich'; + $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); + + node_update_index(); + search_update_totals(); + + // Enable the search block. + $edit = array(); + $edit['blocks[search_form][region]'] = 'content'; + $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); + } + + /** + * Verify the search settings form. + */ + function testSearchSettingsPage() { + + // Test that the settings form displays the correct count of items left to index. + $this->drupalGet('admin/config/search/settings'); + $this->assertText(t('There are @count items left to index.', array('@count' => 0))); + + // Test the re-index button. + $this->drupalPost('admin/config/search/settings', array(), t('Re-index site')); + $this->assertText(t('Are you sure you want to re-index the site')); + $this->drupalPost('admin/config/search/settings/reindex', array(), t('Re-index site')); + $this->assertText(t('The index will be rebuilt')); + $this->drupalGet('admin/config/search/settings'); + $this->assertText(t('There is 1 item left to index.')); + + // Test that the form saves with the default values. + $this->drupalPost('admin/config/search/settings', array(), t('Save configuration')); + $this->assertText(t('The configuration options have been saved.'), 'Form saves with the default values.'); + + // Test that the form does not save with an invalid word length. + $edit = array( + 'minimum_word_size' => $this->randomName(3), + ); + $this->drupalPost('admin/config/search/settings', $edit, t('Save configuration')); + $this->assertNoText(t('The configuration options have been saved.'), 'Form does not save with an invalid word length.'); + } + + /** + * Verify that you can disable individual search modules. + */ + function testSearchModuleDisabling() { + // Array of search modules to test: 'path' is the search path, 'title' is + // the tab title, 'keys' are the keywords to search for, and 'text' is + // the text to assert is on the results page. + $module_info = array( + 'node' => array( + 'path' => 'node', + 'title' => 'Content', + 'keys' => 'pizza', + 'text' => $this->search_node->title, + ), + 'user' => array( + 'path' => 'user', + 'title' => 'User', + 'keys' => $this->search_user->name, + 'text' => $this->search_user->mail, + ), + 'search_extra_type' => array( + 'path' => 'dummy_path', + 'title' => 'Dummy search type', + 'keys' => 'foo', + 'text' => 'Dummy search snippet to display', + ), + ); + $modules = array_keys($module_info); + + // Test each module if it's enabled as the only search module. + foreach ($modules as $module) { + // Enable the one module and disable other ones. + $info = $module_info[$module]; + $edit = array(); + foreach ($modules as $other) { + $edit['search_active_modules[' . $other . ']'] = (($other == $module) ? $module : FALSE); + } + $edit['search_default_module'] = $module; + $this->drupalPost('admin/config/search/settings', $edit, t('Save configuration')); + + // Run a search from the correct search URL. + $this->drupalGet('search/' . $info['path'] . '/' . $info['keys']); + $this->assertNoText('no results', $info['title'] . ' search found results'); + $this->assertText($info['text'], 'Correct search text found'); + + // Verify that other module search tab titles are not visible. + foreach ($modules as $other) { + if ($other != $module) { + $title = $module_info[$other]['title']; + $this->assertNoText($title, $title . ' search tab is not shown'); + } + } + + // Run a search from the search block on the node page. Verify you get + // to this module's search results page. + $terms = array('search_block_form' => $info['keys']); + $this->drupalPost('node', $terms, t('Search')); + $this->assertEqual( + $this->getURL(), + url('search/' . $info['path'] . '/' . $info['keys'], array('absolute' => TRUE)), + 'Block redirected to right search page'); + + // Try an invalid search path. Should redirect to our active module. + $this->drupalGet('search/not_a_module_path'); + $this->assertEqual( + $this->getURL(), + url('search/' . $info['path'], array('absolute' => TRUE)), + 'Invalid search path redirected to default search page'); + } + + // Test with all search modules enabled. When you go to the search + // page or run search, all modules should be shown. + $edit = array(); + foreach ($modules as $module) { + $edit['search_active_modules[' . $module . ']'] = $module; + } + $edit['search_default_module'] = 'node'; + + $this->drupalPost('admin/config/search/settings', $edit, t('Save configuration')); + + foreach (array('search/node/pizza', 'search/node') as $path) { + $this->drupalGet($path); + foreach ($modules as $module) { + $title = $module_info[$module]['title']; + $this->assertText($title, format_string('%title search tab is shown', array('%title' => $title))); + } + } + } +} + +/** + * Tests the search_excerpt() function. + */ +class SearchExcerptTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Search excerpt extraction', + 'description' => 'Tests that the search_excerpt() function works.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search'); + } + + /** + * Tests search_excerpt() with several simulated search keywords. + * + * Passes keywords and a sample marked up string, "The quick + * brown fox jumps over the lazy dog", and compares it to the + * correctly marked up string. The correctly marked up string + * contains either highlighted keywords or the original marked + * up string if no keywords matched the string. + */ + function testSearchExcerpt() { + // Make some text with entities and tags. + $text = 'The quick brown fox & jumps

    over

    the lazy dog'; + // Note: The search_excerpt() function adds some extra spaces -- not + // important for HTML formatting. Remove these for comparison. + $expected = 'The quick brown fox & jumps over the lazy dog'; + $result = preg_replace('| +|', ' ', search_excerpt('nothing', $text)); + $this->assertEqual(preg_replace('| +|', ' ', $result), $expected, 'Entire string is returned when keyword is not found in short string'); + + $result = preg_replace('| +|', ' ', search_excerpt('fox', $text)); + $this->assertEqual($result, 'The quick brown fox & jumps over the lazy dog ...', 'Found keyword is highlighted'); + + $longtext = str_repeat($text . ' ', 10); + $result = preg_replace('| +|', ' ', search_excerpt('nothing', $longtext)); + $this->assertTrue(strpos($result, $expected) === 0, 'When keyword is not found in long string, return value starts as expected'); + + $entities = str_repeat('készítése ', 20); + $result = preg_replace('| +|', ' ', search_excerpt('nothing', $entities)); + $this->assertFalse(strpos($result, '&'), 'Entities are not present in excerpt'); + $this->assertTrue(strpos($result, 'í') > 0, 'Entities are converted in excerpt'); + + // The node body that will produce this rendered $text is: + // 123456789 HTMLTest +123456789+‘ +‘ +‘ +‘ +12345678    +‘ +‘ +‘ ‘ + $text = "

    123456789 HTMLTest +123456789+‘ +‘ +‘ +‘ +12345678    +‘ +‘ +‘ ‘

    \n
    "; + $result = search_excerpt('HTMLTest', $text); + $this->assertFalse(empty($result), 'Rendered Multi-byte HTML encodings are not corrupted in search excerpts'); + } + + /** + * Tests search_excerpt() with search keywords matching simplified words. + * + * Excerpting should handle keywords that are matched only after going through + * search_simplify(). This test passes keywords that match simplified words + * and compares them with strings that contain the original unsimplified word. + */ + function testSearchExcerptSimplified() { + $lorem1 = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero.'; + $lorem2 = 'Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci.'; + + // Make some text with some keywords that will get simplified. + $text = $lorem1 . ' Number: 123456.7890 Hyphenated: one-two abc,def ' . $lorem2; + // Note: The search_excerpt() function adds some extra spaces -- not + // important for HTML formatting. Remove these for comparison. + $result = preg_replace('| +|', ' ', search_excerpt('123456.7890', $text)); + $this->assertTrue(strpos($result, 'Number: 123456.7890') !== FALSE, 'Numeric keyword is highlighted with exact match'); + + $result = preg_replace('| +|', ' ', search_excerpt('1234567890', $text)); + $this->assertTrue(strpos($result, 'Number: 123456.7890') !== FALSE, 'Numeric keyword is highlighted with simplified match'); + + $result = preg_replace('| +|', ' ', search_excerpt('Number 1234567890', $text)); + $this->assertTrue(strpos($result, 'Number: 123456.7890') !== FALSE, 'Punctuated and numeric keyword is highlighted with simplified match'); + + $result = preg_replace('| +|', ' ', search_excerpt('"Number 1234567890"', $text)); + $this->assertTrue(strpos($result, 'Number: 123456.7890') !== FALSE, 'Phrase with punctuated and numeric keyword is highlighted with simplified match'); + + $result = preg_replace('| +|', ' ', search_excerpt('"Hyphenated onetwo"', $text)); + $this->assertTrue(strpos($result, 'Hyphenated: one-two') !== FALSE, 'Phrase with punctuated and hyphenated keyword is highlighted with simplified match'); + + $result = preg_replace('| +|', ' ', search_excerpt('"abc def"', $text)); + $this->assertTrue(strpos($result, 'abc,def') !== FALSE, 'Phrase with keyword simplified into two separate words is highlighted with simplified match'); + + // Test phrases with characters which are being truncated. + $result = preg_replace('| +|', ' ', search_excerpt('"ipsum _"', $text)); + $this->assertTrue(strpos($result, 'ipsum ') !== FALSE, 'Only valid part of the phrase is highlighted and invalid part containing "_" is ignored.'); + + $result = preg_replace('| +|', ' ', search_excerpt('"ipsum 0000"', $text)); + $this->assertTrue(strpos($result, 'ipsum ') !== FALSE, 'Only valid part of the phrase is highlighted and invalid part "0000" is ignored.'); + + // Test combination of the valid keyword and keyword containing only + // characters which are being truncated during simplification. + $result = preg_replace('| +|', ' ', search_excerpt('ipsum _', $text)); + $this->assertTrue(strpos($result, 'ipsum') !== FALSE, 'Only valid keyword is highlighted and invalid keyword "_" is ignored.'); + + $result = preg_replace('| +|', ' ', search_excerpt('ipsum 0000', $text)); + $this->assertTrue(strpos($result, 'ipsum') !== FALSE, 'Only valid keyword is highlighted and invalid keyword "0000" is ignored.'); + } +} + +/** + * Test the CJK tokenizer. + */ +class SearchTokenizerTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'CJK tokenizer', + 'description' => 'Check that CJK tokenizer works as intended.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search'); + } + + /** + * Verifies that strings of CJK characters are tokenized. + * + * The search_simplify() function does special things with numbers, symbols, + * and punctuation. So we only test that CJK characters that are not in these + * character classes are tokenized properly. See PREG_CLASS_CKJ for more + * information. + */ + function testTokenizer() { + // Set the minimum word size to 1 (to split all CJK characters) and make + // sure CJK tokenizing is turned on. + variable_set('minimum_word_size', 1); + variable_set('overlap_cjk', TRUE); + $this->refreshVariables(); + + // Create a string of CJK characters from various character ranges in + // the Unicode tables. + + // Beginnings of the character ranges. + $starts = array( + 'CJK unified' => 0x4e00, + 'CJK Ext A' => 0x3400, + 'CJK Compat' => 0xf900, + 'Hangul Jamo' => 0x1100, + 'Hangul Ext A' => 0xa960, + 'Hangul Ext B' => 0xd7b0, + 'Hangul Compat' => 0x3131, + 'Half non-punct 1' => 0xff21, + 'Half non-punct 2' => 0xff41, + 'Half non-punct 3' => 0xff66, + 'Hangul Syllables' => 0xac00, + 'Hiragana' => 0x3040, + 'Katakana' => 0x30a1, + 'Katakana Ext' => 0x31f0, + 'CJK Reserve 1' => 0x20000, + 'CJK Reserve 2' => 0x30000, + 'Bomofo' => 0x3100, + 'Bomofo Ext' => 0x31a0, + 'Lisu' => 0xa4d0, + 'Yi' => 0xa000, + ); + + // Ends of the character ranges. + $ends = array( + 'CJK unified' => 0x9fcf, + 'CJK Ext A' => 0x4dbf, + 'CJK Compat' => 0xfaff, + 'Hangul Jamo' => 0x11ff, + 'Hangul Ext A' => 0xa97f, + 'Hangul Ext B' => 0xd7ff, + 'Hangul Compat' => 0x318e, + 'Half non-punct 1' => 0xff3a, + 'Half non-punct 2' => 0xff5a, + 'Half non-punct 3' => 0xffdc, + 'Hangul Syllables' => 0xd7af, + 'Hiragana' => 0x309f, + 'Katakana' => 0x30ff, + 'Katakana Ext' => 0x31ff, + 'CJK Reserve 1' => 0x2fffd, + 'CJK Reserve 2' => 0x3fffd, + 'Bomofo' => 0x312f, + 'Bomofo Ext' => 0x31b7, + 'Lisu' => 0xa4fd, + 'Yi' => 0xa48f, + ); + + // Generate characters consisting of starts, midpoints, and ends. + $chars = array(); + $charcodes = array(); + foreach ($starts as $key => $value) { + $charcodes[] = $starts[$key]; + $chars[] = $this->code2utf($starts[$key]); + $mid = round(0.5 * ($starts[$key] + $ends[$key])); + $charcodes[] = $mid; + $chars[] = $this->code2utf($mid); + $charcodes[] = $ends[$key]; + $chars[] = $this->code2utf($ends[$key]); + } + + // Merge into a string and tokenize. + $string = implode('', $chars); + $out = trim(search_simplify($string)); + $expected = drupal_strtolower(implode(' ', $chars)); + + // Verify that the output matches what we expect. + $this->assertEqual($out, $expected, 'CJK tokenizer worked on all supplied CJK characters'); + } + + /** + * Verifies that strings of non-CJK characters are not tokenized. + * + * This is just a sanity check - it verifies that strings of letters are + * not tokenized. + */ + function testNoTokenizer() { + // Set the minimum word size to 1 (to split all CJK characters) and make + // sure CJK tokenizing is turned on. + variable_set('minimum_word_size', 1); + variable_set('overlap_cjk', TRUE); + $this->refreshVariables(); + + $letters = 'abcdefghijklmnopqrstuvwxyz'; + $out = trim(search_simplify($letters)); + + $this->assertEqual($letters, $out, 'Letters are not CJK tokenized'); + } + + /** + * Like PHP chr() function, but for unicode characters. + * + * chr() only works for ASCII characters up to character 255. This function + * converts a number to the corresponding unicode character. Adapted from + * functions supplied in comments on several functions on php.net. + */ + function code2utf($num) { + if ($num < 128) { + return chr($num); + } + + if ($num < 2048) { + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); + } + + if ($num < 65536) { + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); + } + + if ($num < 2097152) { + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); + } + + return ''; + } +} + +/** + * Tests that we can embed a form in search results and submit it. + */ +class SearchEmbedForm extends DrupalWebTestCase { + /** + * Node used for testing. + */ + public $node; + + /** + * Count of how many times the form has been submitted. + */ + public $submit_count = 0; + + public static function getInfo() { + return array( + 'name' => 'Embedded forms', + 'description' => 'Verifies that a form embedded in search results works', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search', 'search_embedded_form'); + + // Create a user and a node, and update the search index. + $test_user = $this->drupalCreateUser(array('access content', 'search content', 'administer nodes')); + $this->drupalLogin($test_user); + + $this->node = $this->drupalCreateNode(); + + node_update_index(); + search_update_totals(); + + // Set up a dummy initial count of times the form has been submitted. + $this->submit_count = 12; + variable_set('search_embedded_form_submitted', $this->submit_count); + $this->refreshVariables(); + } + + /** + * Tests that the embedded form appears and can be submitted. + */ + function testEmbeddedForm() { + // First verify we can submit the form from the module's page. + $this->drupalPost('search_embedded_form', + array('name' => 'John'), + t('Send away')); + $this->assertText(t('Test form was submitted'), 'Form message appears'); + $count = variable_get('search_embedded_form_submitted', 0); + $this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct'); + $this->submit_count = $count; + + // Now verify that we can see and submit the form from the search results. + $this->drupalGet('search/node/' . $this->node->title); + $this->assertText(t('Your name'), 'Form is visible'); + $this->drupalPost('search/node/' . $this->node->title, + array('name' => 'John'), + t('Send away')); + $this->assertText(t('Test form was submitted'), 'Form message appears'); + $count = variable_get('search_embedded_form_submitted', 0); + $this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct'); + $this->submit_count = $count; + + // Now verify that if we submit the search form, it doesn't count as + // our form being submitted. + $this->drupalPost('search', + array('keys' => 'foo'), + t('Search')); + $this->assertNoText(t('Test form was submitted'), 'Form message does not appear'); + $count = variable_get('search_embedded_form_submitted', 0); + $this->assertEqual($this->submit_count, $count, 'Form submission count is correct'); + $this->submit_count = $count; + } +} + +/** + * Tests that hook_search_page runs. + */ +class SearchPageOverride extends DrupalWebTestCase { + public $search_user; + + public static function getInfo() { + return array( + 'name' => 'Search page override', + 'description' => 'Verify that hook_search_page can override search page display.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search', 'search_extra_type'); + + // Login as a user that can create and search content. + $this->search_user = $this->drupalCreateUser(array('search content', 'administer search')); + $this->drupalLogin($this->search_user); + + // Enable the extra type module for searching. + variable_set('search_active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type')); + menu_rebuild(); + } + + function testSearchPageHook() { + $keys = 'bike shed ' . $this->randomName(); + $this->drupalGet("search/dummy_path/{$keys}"); + $this->assertText('Dummy search snippet', 'Dummy search snippet is shown'); + $this->assertText('Test page text is here', 'Page override is working'); + } +} + +/** + * Test node search with multiple languages. + */ +class SearchLanguageTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Search language selection', + 'description' => 'Tests advanced search with different languages enabled.', + 'group' => 'Search', + ); + } + + /** + * Implementation setUp(). + */ + function setUp() { + parent::setUp('search', 'locale'); + + // Create and login user. + $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages')); + $this->drupalLogin($test_user); + } + + function testLanguages() { + // Check that there are initially no languages displayed. + $this->drupalGet('search/node'); + $this->assertNoText(t('Languages'), 'No languages to choose from.'); + + // Add predefined language. + $edit = array('langcode' => 'fr'); + $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); + $this->assertText('fr', 'Language added successfully.'); + + // Now we should have languages displayed. + $this->drupalGet('search/node'); + $this->assertText(t('Languages'), 'Languages displayed to choose from.'); + $this->assertText(t('English'), 'English is a possible choice.'); + $this->assertText(t('French'), 'French is a possible choice.'); + + // Ensure selecting no language does not make the query different. + $this->drupalPost('search/node', array(), t('Advanced search')); + $this->assertEqual($this->getUrl(), url('search/node/', array('absolute' => TRUE)), 'Correct page redirection, no language filtering.'); + + // Pick French and ensure it is selected. + $edit = array('language[fr]' => TRUE); + $this->drupalPost('search/node', $edit, t('Advanced search')); + $this->assertFieldByXPath('//input[@name="keys"]', 'language:fr', 'Language filter added to query.'); + + // Change the default language and disable English. + $path = 'admin/config/regional/language'; + $this->drupalGet($path); + $this->assertFieldChecked('edit-site-default-en', 'English is the default language.'); + $edit = array('site_default' => 'fr'); + $this->drupalPost(NULL, $edit, t('Save configuration')); + $this->assertNoFieldChecked('edit-site-default-en', 'Default language updated.'); + $edit = array('enabled[en]' => FALSE); + $this->drupalPost('admin/config/regional/language', $edit, t('Save configuration')); + $this->assertNoFieldChecked('edit-enabled-en', 'Language disabled.'); + + // Check that there are again no languages displayed. + $this->drupalGet('search/node'); + $this->assertNoText(t('Languages'), 'No languages to choose from.'); + } +} + +/** + * Tests node search with node access control. + */ +class SearchNodeAccessTest extends DrupalWebTestCase { + public $test_user; + + public static function getInfo() { + return array( + 'name' => 'Search and node access', + 'description' => 'Tests search functionality with node access control.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search', 'node_access_test'); + node_access_rebuild(); + + // Create a test user and log in. + $this->test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search')); + $this->drupalLogin($this->test_user); + } + + /** + * Tests that search returns results with punctuation in the search phrase. + */ + function testPhraseSearchPunctuation() { + $node = $this->drupalCreateNode(array('body' => array(LANGUAGE_NONE => array(array('value' => "The bunny's ears were fuzzy."))))); + + // Update the search index. + module_invoke_all('update_index'); + search_update_totals(); + + // Refresh variables after the treatment. + $this->refreshVariables(); + + // Submit a phrase wrapped in double quotes to include the punctuation. + $edit = array('keys' => '"bunny\'s"'); + $this->drupalPost('search/node', $edit, t('Search')); + $this->assertText($node->title); + } +} + +/** + * Tests searching with locale values set. + */ +class SearchSetLocaleTest extends DrupalWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'Search with numeric locale set', + 'description' => 'Check that search works with numeric locale settings', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search'); + + // Create a simple node so something will be put in the index. + $info = array( + 'body' => array(LANGUAGE_NONE => array(array('value' => 'Tapir'))), + ); + $this->drupalCreateNode($info); + + // Run cron to index. + $this->cronRun(); + } + + /** + * Verify that search works with a numeric locale set. + */ + public function testSearchWithNumericLocale() { + // French decimal point is comma. + setlocale(LC_NUMERIC, 'fr_FR'); + + // An exception will be thrown if a float in the wrong format occurs in the + // query to the database, so an assertion is not necessary here. + db_select('search_index', 'i') + ->extend('searchquery') + ->searchexpression('tapir', 'node') + ->execute(); + } +} diff --git a/drupal-dev/modules/search/tests/UnicodeTest.txt b/drupal-dev/modules/search/tests/UnicodeTest.txt new file mode 100644 index 0000000..af8a65c --- /dev/null +++ b/drupal-dev/modules/search/tests/UnicodeTest.txt @@ -0,0 +1,333 @@ + + !"#$%&'()*+,-./ +0123456789 +:;<=>?@ +ABCDEFGHIJKLMNOPQRSTUVWXYZ +[\]^_` +abcdefghijklmnopqrstuvwxyz +{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨© +ª +«¬­®¯°± +²³ +´ +µ +¶·¸ +¹º +» +¼½¾ +¿ +ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ +× +ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö +÷ +øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼʽʾʿˀˁ +˂˃˄˅ +ˆˇˈˉˊˋˌˍˎˏːˑ +˒˓˔˕˖˗˘˙˚˛˜˝˞˟ +ˠˡˢˣˤ +˥˦˧˨˩˪˫ +ˬ +˭ +ˮ +˯˰˱˲˳˴˵˶˷˸˹˺˻˼˽˾˿ +̴̵̶̷̸̡̢̧̨̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̹̺̻̼͇͈͉͍͎̀́̂̃̄̅̆̇̈̉̊̋̌̍̎̏̐̑̒̓̔̽̾̿̀́͂̓̈́͆͊͋͌̕̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮͯ͘͜͟͢͝͞͠͡ͰͱͲͳʹ +͵ +Ͷͷͺͻͼͽ +;΄΅ +Ά +· +ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϏϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵ +϶ +ϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁ +҂ +҃҄҅҆҇҈҉ҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӏӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖՙ +՚՛՜՝՞՟ +աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև +։֊ +ְֱֲֳִֵֶַָֹֺֻּֽ֑֖֛֢֣֤֥֦֧֪֚֭֮֒֓֔֕֗֘֙֜֝֞֟֠֡֨֩֫֬֯ +־ +ֿ +׀ +ׁׂ +׃ +ׅׄ +׆ +ׇאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײ +׳״؀؁؂؃؆؇؈؉؊؋،؍؎؏ +ؘؙؚؐؑؒؓؔؕؖؗ +؛؞؟ +ءآأؤإئابةتثجحخدذرزسشصضطظعغػؼؽؾؿـفقكلمنهوىيًٌٍَُِّْٕٖٜٓٔٗ٘ٙٚٛٝٞ٠١٢٣٤٥٦٧٨٩ +٪٫٬٭ +ٮٯٰٱٲٳٴٵٶٷٸٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿۀہۂۃۄۅۆۇۈۉۊۋیۍێۏېۑےۓ +۔ +ەۖۗۘۙۚۛۜ +۝ +۞ۣ۟۠ۡۢۤۥۦۧۨ +۩ +۪ۭ۫۬ۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼ +۽۾ +ۿ +܀܁܂܃܄܅܆܇܈܉܊܋܌܍܏ +ܐܑܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯܱܴܷܸܹܻܼܾ݂݄݆݈ܰܲܳܵܶܺܽܿ݀݁݃݅݇݉݊ݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥަާިީުޫެޭޮޯްޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪ߲߫߬߭߮߯߰߱߳ߴߵ +߶߷߸߹ +ߺࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࠖࠗ࠘࠙ࠚࠛࠜࠝࠞࠟࠠࠡࠢࠣࠤࠥࠦࠧࠨࠩࠪࠫࠬ࠭ +࠰࠱࠲࠳࠴࠵࠶࠷࠸࠹࠺࠻࠼࠽࠾ +ऀँंःऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनऩपफबभमयरऱलळऴवशषसह़ऽािीुूृॄॅॆेैॉॊोौ्ॎॐ॒॑॓॔ॕक़ख़ग़ज़ड़ढ़फ़य़ॠॡॢॣ +।॥ +०१२३४५६७८९ +॰ +ॱॲॹॺॻॼॽॾॿঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣ০১২৩৪৫৬৭৮৯ৰৱ +৲৳ +৴৵৶৷৸৹ +৺৻ +ਁਂਃਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਲ਼ਵਸ਼ਸਹ਼ਾਿੀੁੂੇੈੋੌ੍ੑਖ਼ਗ਼ਜ਼ੜਫ਼੦੧੨੩੪੫੬੭੮੯ੰੱੲੳੴੵઁંઃઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહ઼ઽાિીુૂૃૄૅેૈૉોૌ્ૐૠૡૢૣ૦૧૨૩૪૫૬૭૮૯ +૱ +ଁଂଃଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହ଼ଽାିୀୁୂୃୄେୈୋୌ୍ୖୗଡ଼ଢ଼ୟୠୡୢୣ୦୧୨୩୪୫୬୭୮୯ +୰ +ୱஂஃஅஆஇஈஉஊஎஏஐஒஓஔகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹாிீுூெேைொோௌ்ௐௗ௦௧௨௩௪௫௬௭௮௯௰௱௲ +௳௴௵௶௷௸௹௺ +ఁంఃఅఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళవశషసహఽాిీుూృౄెేైొోౌ్ౕౖౘౙౠౡౢౣ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ +౿ +ಂಃಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹ಼ಽಾಿೀುೂೃೄೆೇೈೊೋೌ್ೕೖೞೠೡೢೣ೦೧೨೩೪೫೬೭೮೯ +ೱೲ +ംഃഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനപഫബഭമയരറലളഴവശഷസഹഽാിീുൂൃൄെേൈൊോൌ്ൗൠൡൢൣ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵ +൹ +ൺൻർൽൾൿංඃඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ්ාැෑිීුූෘෙේෛොෝෞෟෲෳ +෴ +กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู +฿ +เแโใไๅๆ็่้๊๋์ํ๎ +๏ +๐๑๒๓๔๕๖๗๘๙ +๚๛ +ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະັາຳິີຶືຸູົຼຽເແໂໃໄໆ່້໊໋໌ໍ໐໑໒໓໔໕໖໗໘໙ໜໝༀ +༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗ +༘༙ +༚༛༜༝༞༟ +༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ +༴ +༵ +༶ +༷ +༸ +༹ +༺༻༼༽ +༾༿ཀཁགགྷངཅཆཇཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ +྅ +྆྇ྈྉྊྋྐྑྒྒྷྔྕྖྗྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ +྾྿࿀࿁࿂࿃࿄࿅ +࿆ +࿇࿈࿉࿊࿋࿌࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘ +ကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဦဧဨဩဪါာိီုူေဲဳဴဵံ့း္်ျြွှဿ၀၁၂၃၄၅၆၇၈၉ +၊။၌၍၎၏ +ၐၑၒၓၔၕၖၗၘၙၚၛၜၝၞၟၠၡၢၣၤၥၦၧၨၩၪၫၬၭၮၯၰၱၲၳၴၵၶၷၸၹၺၻၼၽၾၿႀႁႂႃႄႅႆႇႈႉႊႋႌႍႎႏ႐႑႒႓႔႕႖႗႘႙ႚႛႜႝ +႞႟ +ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅაბგდევზთიკლმნოპჟრსტუფქღყშჩცძწჭხჯჰჱჲჳჴჵჶჷჸჹჺ +჻ +ჼᄀᄁᄂᄃᄄᄅᄆᄇᄈᄉᄊᄋᄌᄍᄎᄏᄐᄑᄒᄓᄔᄕᄖᄗᄘᄙᄚᄛᄜᄝᄞᄟᄠᄡᄢᄣᄤᄥᄦᄧᄨᄩᄪᄫᄬᄭᄮᄯᄰᄱᄲᄳᄴᄵᄶᄷᄸᄹᄺᄻᄼᄽᄾᄿᅀᅁᅂᅃᅄᅅᅆᅇᅈᅉᅊᅋᅌᅍᅎᅏᅐᅑᅒᅓᅔᅕᅖᅗᅘᅙᅚᅛᅜᅝᅞᅟᅠᅡᅢᅣᅤᅥᅦᅧᅨᅩᅪᅫᅬᅭᅮᅯᅰᅱᅲᅳᅴᅵᅶᅷᅸᅹᅺᅻᅼᅽᅾᅿᆀᆁᆂᆃᆄᆅᆆᆇᆈᆉᆊᆋᆌᆍᆎᆏᆐᆑᆒᆓᆔᆕᆖᆗᆘᆙᆚᆛᆜᆝᆞᆟᆠᆡᆢᆣᆤᆥᆦᆧᆨᆩᆪᆫᆬᆭᆮᆯᆰᆱᆲᆳᆴᆵᆶᆷᆸᆹᆺᆻᆼᆽᆾᆿᇀᇁᇂᇃᇄᇅᇆᇇᇈᇉᇊᇋᇌᇍᇎᇏᇐᇑᇒᇓᇔᇕᇖᇗᇘᇙᇚᇛᇜᇝᇞᇟᇠᇡᇢᇣᇤᇥᇦᇧᇨᇩᇪᇫᇬᇭᇮᇯᇰᇱᇲᇳᇴᇵᇶᇷᇸᇹᇺᇻᇼᇽᇾᇿሀሁሂሃሄህሆሇለሉሊላሌልሎሏሐሑሒሓሔሕሖሗመሙሚማሜምሞሟሠሡሢሣሤሥሦሧረሩሪራሬርሮሯሰሱሲሳሴስሶሷሸሹሺሻሼሽሾሿቀቁቂቃቄቅቆቇቈቊቋቌቍቐቑቒቓቔቕቖቘቚቛቜቝበቡቢባቤብቦቧቨቩቪቫቬቭቮቯተቱቲታቴትቶቷቸቹቺቻቼችቾቿኀኁኂኃኄኅኆኇኈኊኋኌኍነኑኒናኔንኖኗኘኙኚኛኜኝኞኟአኡኢኣኤእኦኧከኩኪካኬክኮኯኰኲኳኴኵኸኹኺኻኼኽኾዀዂዃዄዅወዉዊዋዌውዎዏዐዑዒዓዔዕዖዘዙዚዛዜዝዞዟዠዡዢዣዤዥዦዧየዩዪያዬይዮዯደዱዲዳዴድዶዷዸዹዺዻዼዽዾዿጀጁጂጃጄጅጆጇገጉጊጋጌግጎጏጐጒጓጔጕጘጙጚጛጜጝጞጟጠጡጢጣጤጥጦጧጨጩጪጫጬጭጮጯጰጱጲጳጴጵጶጷጸጹጺጻጼጽጾጿፀፁፂፃፄፅፆፇፈፉፊፋፌፍፎፏፐፑፒፓፔፕፖፗፘፙፚ፟ +፠፡።፣፤፥፦፧፨ +፩፪፫፬፭፮፯፰፱፲፳፴፵፶፷፸፹፺፻፼ᎀᎁᎂᎃᎄᎅᎆᎇᎈᎉᎊᎋᎌᎍᎎᎏ +᎐᎑᎒᎓᎔᎕᎖᎗᎘᎙ +ᎠᎡᎢᎣᎤᎥᎦᎧᎨᎩᎪᎫᎬᎭᎮᎯᎰᎱᎲᎳᎴᎵᎶᎷᎸᎹᎺᎻᎼᎽᎾᎿᏀᏁᏂᏃᏄᏅᏆᏇᏈᏉᏊᏋᏌᏍᏎᏏᏐᏑᏒᏓᏔᏕᏖᏗᏘᏙᏚᏛᏜᏝᏞᏟᏠᏡᏢᏣᏤᏥᏦᏧᏨᏩᏪᏫᏬᏭᏮᏯᏰᏱᏲᏳᏴ +᐀ +ᐁᐂᐃᐄᐅᐆᐇᐈᐉᐊᐋᐌᐍᐎᐏᐐᐑᐒᐓᐔᐕᐖᐗᐘᐙᐚᐛᐜᐝᐞᐟᐠᐡᐢᐣᐤᐥᐦᐧᐨᐩᐪᐫᐬᐭᐮᐯᐰᐱᐲᐳᐴᐵᐶᐷᐸᐹᐺᐻᐼᐽᐾᐿᑀᑁᑂᑃᑄᑅᑆᑇᑈᑉᑊᑋᑌᑍᑎᑏᑐᑑᑒᑓᑔᑕᑖᑗᑘᑙᑚᑛᑜᑝᑞᑟᑠᑡᑢᑣᑤᑥᑦᑧᑨᑩᑪᑫᑬᑭᑮᑯᑰᑱᑲᑳᑴᑵᑶᑷᑸᑹᑺᑻᑼᑽᑾᑿᒀᒁᒂᒃᒄᒅᒆᒇᒈᒉᒊᒋᒌᒍᒎᒏᒐᒑᒒᒓᒔᒕᒖᒗᒘᒙᒚᒛᒜᒝᒞᒟᒠᒡᒢᒣᒤᒥᒦᒧᒨᒩᒪᒫᒬᒭᒮᒯᒰᒱᒲᒳᒴᒵᒶᒷᒸᒹᒺᒻᒼᒽᒾᒿᓀᓁᓂᓃᓄᓅᓆᓇᓈᓉᓊᓋᓌᓍᓎᓏᓐᓑᓒᓓᓔᓕᓖᓗᓘᓙᓚᓛᓜᓝᓞᓟᓠᓡᓢᓣᓤᓥᓦᓧᓨᓩᓪᓫᓬᓭᓮᓯᓰᓱᓲᓳᓴᓵᓶᓷᓸᓹᓺᓻᓼᓽᓾᓿᔀᔁᔂᔃᔄᔅᔆᔇᔈᔉᔊᔋᔌᔍᔎᔏᔐᔑᔒᔓᔔᔕᔖᔗᔘᔙᔚᔛᔜᔝᔞᔟᔠᔡᔢᔣᔤᔥᔦᔧᔨᔩᔪᔫᔬᔭᔮᔯᔰᔱᔲᔳᔴᔵᔶᔷᔸᔹᔺᔻᔼᔽᔾᔿᕀᕁᕂᕃᕄᕅᕆᕇᕈᕉᕊᕋᕌᕍᕎᕏᕐᕑᕒᕓᕔᕕᕖᕗᕘᕙᕚᕛᕜᕝᕞᕟᕠᕡᕢᕣᕤᕥᕦᕧᕨᕩᕪᕫᕬᕭᕮᕯᕰᕱᕲᕳᕴᕵᕶᕷᕸᕹᕺᕻᕼᕽᕾᕿᖀᖁᖂᖃᖄᖅᖆᖇᖈᖉᖊᖋᖌᖍᖎᖏᖐᖑᖒᖓᖔᖕᖖᖗᖘᖙᖚᖛᖜᖝᖞᖟᖠᖡᖢᖣᖤᖥᖦᖧᖨᖩᖪᖫᖬᖭᖮᖯᖰᖱᖲᖳᖴᖵᖶᖷᖸᖹᖺᖻᖼᖽᖾᖿᗀᗁᗂᗃᗄᗅᗆᗇᗈᗉᗊᗋᗌᗍᗎᗏᗐᗑᗒᗓᗔᗕᗖᗗᗘᗙᗚᗛᗜᗝᗞᗟᗠᗡᗢᗣᗤᗥᗦᗧᗨᗩᗪᗫᗬᗭᗮᗯᗰᗱᗲᗳᗴᗵᗶᗷᗸᗹᗺᗻᗼᗽᗾᗿᘀᘁᘂᘃᘄᘅᘆᘇᘈᘉᘊᘋᘌᘍᘎᘏᘐᘑᘒᘓᘔᘕᘖᘗᘘᘙᘚᘛᘜᘝᘞᘟᘠᘡᘢᘣᘤᘥᘦᘧᘨᘩᘪᘫᘬᘭᘮᘯᘰᘱᘲᘳᘴᘵᘶᘷᘸᘹᘺᘻᘼᘽᘾᘿᙀᙁᙂᙃᙄᙅᙆᙇᙈᙉᙊᙋᙌᙍᙎᙏᙐᙑᙒᙓᙔᙕᙖᙗᙘᙙᙚᙛᙜᙝᙞᙟᙠᙡᙢᙣᙤᙥᙦᙧᙨᙩᙪᙫᙬ +᙭᙮ +ᙯᙰᙱᙲᙳᙴᙵᙶᙷᙸᙹᙺᙻᙼᙽᙾᙿ +  +ᚁᚂᚃᚄᚅᚆᚇᚈᚉᚊᚋᚌᚍᚎᚏᚐᚑᚒᚓᚔᚕᚖᚗᚘᚙᚚ +᚛᚜ +ᚠᚡᚢᚣᚤᚥᚦᚧᚨᚩᚪᚫᚬᚭᚮᚯᚰᚱᚲᚳᚴᚵᚶᚷᚸᚹᚺᚻᚼᚽᚾᚿᛀᛁᛂᛃᛄᛅᛆᛇᛈᛉᛊᛋᛌᛍᛎᛏᛐᛑᛒᛓᛔᛕᛖᛗᛘᛙᛚᛛᛜᛝᛞᛟᛠᛡᛢᛣᛤᛥᛦᛧᛨᛩᛪ +᛫᛬᛭ +ᛮᛯᛰᜀᜁᜂᜃᜄᜅᜆᜇᜈᜉᜊᜋᜌᜎᜏᜐᜑᜒᜓ᜔ᜠᜡᜢᜣᜤᜥᜦᜧᜨᜩᜪᜫᜬᜭᜮᜯᜰᜱᜲᜳ᜴ +᜵᜶ +ᝀᝁᝂᝃᝄᝅᝆᝇᝈᝉᝊᝋᝌᝍᝎᝏᝐᝑᝒᝓᝠᝡᝢᝣᝤᝥᝦᝧᝨᝩᝪᝫᝬᝮᝯᝰᝲᝳកខគឃងចឆជឈញដឋឌឍណតថទធនបផពភមយរលវឝឞសហឡអឣឤឥឦឧឨឩឪឫឬឭឮឯឰឱឲឳ +឴឵ +ាិីឹឺុូួើឿៀេែៃោៅំះៈ៉៊់៌៍៎៏័៑្៓ +។៕៖ +ៗ +៘៙៚៛ +ៜ៝០១២៣៤៥៦៧៨៩៰៱៲៳៴៵៶៷៸៹ +᠀᠁᠂᠃᠄᠅᠆᠇᠈᠉᠊ +᠋᠌᠍ +᠎ +᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙ᠠᠡᠢᠣᠤᠥᠦᠧᠨᠩᠪᠫᠬᠭᠮᠯᠰᠱᠲᠳᠴᠵᠶᠷᠸᠹᠺᠻᠼᠽᠾᠿᡀᡁᡂᡃᡄᡅᡆᡇᡈᡉᡊᡋᡌᡍᡎᡏᡐᡑᡒᡓᡔᡕᡖᡗᡘᡙᡚᡛᡜᡝᡞᡟᡠᡡᡢᡣᡤᡥᡦᡧᡨᡩᡪᡫᡬᡭᡮᡯᡰᡱᡲᡳᡴᡵᡶᡷᢀᢁᢂᢃᢄᢅᢆᢇᢈᢉᢊᢋᢌᢍᢎᢏᢐᢑᢒᢓᢔᢕᢖᢗᢘᢙᢚᢛᢜᢝᢞᢟᢠᢡᢢᢣᢤᢥᢦᢧᢨᢩᢪᢰᢱᢲᢳᢴᢵᢶᢷᢸᢹᢺᢻᢼᢽᢾᢿᣀᣁᣂᣃᣄᣅᣆᣇᣈᣉᣊᣋᣌᣍᣎᣏᣐᣑᣒᣓᣔᣕᣖᣗᣘᣙᣚᣛᣜᣝᣞᣟᣠᣡᣢᣣᣤᣥᣦᣧᣨᣩᣪᣫᣬᣭᣮᣯᣰᣱᣲᣳᣴᣵᤀᤁᤂᤃᤄᤅᤆᤇᤈᤉᤊᤋᤌᤍᤎᤏᤐᤑᤒᤓᤔᤕᤖᤗᤘᤙᤚᤛᤜᤠᤡᤢᤣᤤᤥᤦᤧᤨᤩᤪᤫᤰᤱᤲᤳᤴᤵᤶᤷᤸ᤻᤹᤺ +᥀᥄᥅ +᥆᥇᥈᥉᥊᥋᥌᥍᥎᥏ᥐᥑᥒᥓᥔᥕᥖᥗᥘᥙᥚᥛᥜᥝᥞᥟᥠᥡᥢᥣᥤᥥᥦᥧᥨᥩᥪᥫᥬᥭᥰᥱᥲᥳᥴᦀᦁᦂᦃᦄᦅᦆᦇᦈᦉᦊᦋᦌᦍᦎᦏᦐᦑᦒᦓᦔᦕᦖᦗᦘᦙᦚᦛᦜᦝᦞᦟᦠᦡᦢᦣᦤᦥᦦᦧᦨᦩᦪᦫᦰᦱᦲᦳᦴᦵᦶᦷᦸᦹᦺᦻᦼᦽᦾᦿᧀᧁᧂᧃᧄᧅᧆᧇᧈᧉ᧐᧑᧒᧓᧔᧕᧖᧗᧘᧙᧚ +᧞᧟᧠᧡᧢᧣᧤᧥᧦᧧᧨᧩᧪᧫᧬᧭᧮᧯᧰᧱᧲᧳᧴᧵᧶᧷᧸᧹᧺᧻᧼᧽᧾᧿ +ᨀᨁᨂᨃᨄᨅᨆᨇᨈᨉᨊᨋᨌᨍᨎᨏᨐᨑᨒᨓᨔᨕᨖᨘᨗᨙᨚᨛ +᨞᨟ +ᨠᨡᨢᨣᨤᨥᨦᨧᨨᨩᨪᨫᨬᨭᨮᨯᨰᨱᨲᨳᨴᨵᨶᨷᨸᨹᨺᨻᨼᨽᨾᨿᩀᩁᩂᩃᩄᩅᩆᩇᩈᩉᩊᩋᩌᩍᩎᩏᩐᩑᩒᩓᩔᩕᩖᩗᩘᩙᩚᩛᩜᩝᩞ᩠ᩡᩢᩣᩤᩥᩦᩧᩨᩩᩪᩫᩬᩭᩮᩯᩰᩱᩲᩳᩴ᩿᩵᩶᩷᩸᩹᩺᩻᩼᪀᪁᪂᪃᪄᪅᪆᪇᪈᪉᪐᪑᪒᪓᪔᪕᪖᪗᪘᪙ +᪠᪡᪢᪣᪤᪥᪦ +ᪧ +᪨᪩᪪᪫᪬᪭ +ᬀᬁᬂᬃᬄᬅᬆᬇᬈᬉᬊᬋᬌᬍᬎᬏᬐᬑᬒᬓᬔᬕᬖᬗᬘᬙᬚᬛᬜᬝᬞᬟᬠᬡᬢᬣᬤᬥᬦᬧᬨᬩᬪᬫᬬᬭᬮᬯᬰᬱᬲᬳ᬴ᬵᬶᬷᬸᬹᬺᬻᬼᬽᬾᬿᭀᭁᭂᭃ᭄ᭅᭆᭇᭈᭉᭊᭋ᭐᭑᭒᭓᭔᭕᭖᭗᭘᭙ +᭚᭛᭜᭝᭞᭟᭠᭡᭢᭣᭤᭥᭦᭧᭨᭩᭪ +᭬᭫᭭᭮᭯᭰᭱᭲᭳ +᭴᭵᭶᭷᭸᭹᭺᭻᭼ +ᮀᮁᮂᮃᮄᮅᮆᮇᮈᮉᮊᮋᮌᮍᮎᮏᮐᮑᮒᮓᮔᮕᮖᮗᮘᮙᮚᮛᮜᮝᮞᮟᮠᮡᮢᮣᮤᮥᮦᮧᮨᮩ᮪ᮮᮯ᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹ᰀᰁᰂᰃᰄᰅᰆᰇᰈᰉᰊᰋᰌᰍᰎᰏᰐᰑᰒᰓᰔᰕᰖᰗᰘᰙᰚᰛᰜᰝᰞᰟᰠᰡᰢᰣᰤᰥᰦᰧᰨᰩᰪᰫᰬᰭᰮᰯᰰᰱᰲᰳᰴᰵᰶ᰷ +᰻᰼᰽᰾᰿ +᱀᱁᱂᱃᱄᱅᱆᱇᱈᱉ᱍᱎᱏ᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙ᱚᱛᱜᱝᱞᱟᱠᱡᱢᱣᱤᱥᱦᱧᱨᱩᱪᱫᱬᱭᱮᱯᱰᱱᱲᱳᱴᱵᱶᱷᱸᱹᱺᱻᱼᱽ +᱾᱿ +᳐᳑᳒ +᳓ +᳔᳕᳖᳗᳘᳙᳜᳝᳞᳟᳚᳛᳠᳡᳢᳣᳤᳥᳦᳧᳨ᳩᳪᳫᳬ᳭ᳮᳯᳰᳱᳲᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩᴪᴫᴬᴭᴮᴯᴰᴱᴲᴳᴴᴵᴶᴷᴸᴹᴺᴻᴼᴽᴾᴿᵀᵁᵂᵃᵄᵅᵆᵇᵈᵉᵊᵋᵌᵍᵎᵏᵐᵑᵒᵓᵔᵕᵖᵗᵘᵙᵚᵛᵜᵝᵞᵟᵠᵡᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵸᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚᶛᶜᶝᶞᶟᶠᶡᶢᶣᶤᶥᶦᶧᶨᶩᶪᶫᶬᶭᶮᶯᶰᶱᶲᶳᶴᶵᶶᶷᶸᶹᶺᶻᶼᶽᶾᶿ᷐᷎᷂᷊᷏᷽᷿᷀᷁᷃᷄᷅᷆᷇᷈᷉᷋᷌᷑᷒ᷓᷔᷕᷖᷗᷘᷙᷚᷛᷜᷝᷞᷟᷠᷡᷢᷣᷤᷥᷦ᷾᷍ḀḁḂḃḄḅḆḇḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẜẝẞẟẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹỺỻỼỽỾỿἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾈᾉᾊᾋᾌᾍᾎᾏᾐᾑᾒᾓᾔᾕᾖᾗᾘᾙᾚᾛᾜᾝᾞᾟᾠᾡᾢᾣᾤᾥᾦᾧᾨᾩᾪᾫᾬᾭᾮᾯᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆᾼ +᾽ +ι +᾿῀῁ +ῂῃῄῆῇῈΈῊΉῌ +῍῎῏ +ῐῑῒΐῖῗῘῙῚΊ +῝῞῟ +ῠῡῢΰῤῥῦῧῨῩῪΎῬ +῭΅` +ῲῳῴῶῷῸΌῺΏῼ +´῾           ​‌‍‎‏‐‑‒–—―‖‗‘’‚‛“”„‟†‡•‣․‥…‧

‪‫‬‭‮ ‰‱′″‴‵‶‷‸‹›※‼‽‾‿⁀⁁⁂⁃⁄⁅⁆⁇⁈⁉⁊⁋⁌⁍⁎⁏⁐⁑⁒⁓⁔⁕⁖⁗⁘⁙⁚⁛⁜⁝⁞ ⁠⁡⁢⁣⁤ +⁰ⁱ⁴⁵⁶⁷⁸⁹ +⁺⁻⁼⁽⁾ +ⁿ₀₁₂₃₄₅₆₇₈₉ +₊₋₌₍₎ +ₐₑₒₓₔ +₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵₶₷₸ +⃒⃓⃘⃙⃚⃐⃑⃔⃕⃖⃗⃛⃜⃝⃞⃟⃠⃡⃢⃣⃤⃥⃦⃪⃫⃨⃬⃭⃮⃯⃧⃩⃰ +℀℁ +ℂ +℃℄℅℆ +ℇ +℈℉ +ℊℋℌℍℎℏℐℑℒℓ +℔ +ℕ +№℗℘ +ℙℚℛℜℝ +℞℟℠℡™℣ +ℤ +℥ +Ω +℧ +ℨ +℩ +KÅℬℭ +℮ +ℯℰℱℲℳℴℵℶℷℸℹ +℺℻ +ℼℽℾℿ +⅀⅁⅂⅃⅄ +ⅅⅆⅇⅈⅉ +⅊⅋⅌⅍ +ⅎ +⅏ +⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞⅟ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿↀↁↂↃↄↅↆↇↈ↉ +←↑→↓↔↕↖↗↘↙↚↛↜↝↞↟↠↡↢↣↤↥↦↧↨↩↪↫↬↭↮↯↰↱↲↳↴↵↶↷↸↹↺↻↼↽↾↿⇀⇁⇂⇃⇄⇅⇆⇇⇈⇉⇊⇋⇌⇍⇎⇏⇐⇑⇒⇓⇔⇕⇖⇗⇘⇙⇚⇛⇜⇝⇞⇟⇠⇡⇢⇣⇤⇥⇦⇧⇨⇩⇪⇫⇬⇭⇮⇯⇰⇱⇲⇳⇴⇵⇶⇷⇸⇹⇺⇻⇼⇽⇾⇿∀∁∂∃∄∅∆∇∈∉∊∋∌∍∎∏∐∑−∓∔∕∖∗∘∙√∛∜∝∞∟∠∡∢∣∤∥∦∧∨∩∪∫∬∭∮∯∰∱∲∳∴∵∶∷∸∹∺∻∼∽∾∿≀≁≂≃≄≅≆≇≈≉≊≋≌≍≎≏≐≑≒≓≔≕≖≗≘≙≚≛≜≝≞≟≠≡≢≣≤≥≦≧≨≩≪≫≬≭≮≯≰≱≲≳≴≵≶≷≸≹≺≻≼≽≾≿⊀⊁⊂⊃⊄⊅⊆⊇⊈⊉⊊⊋⊌⊍⊎⊏⊐⊑⊒⊓⊔⊕⊖⊗⊘⊙⊚⊛⊜⊝⊞⊟⊠⊡⊢⊣⊤⊥⊦⊧⊨⊩⊪⊫⊬⊭⊮⊯⊰⊱⊲⊳⊴⊵⊶⊷⊸⊹⊺⊻⊼⊽⊾⊿⋀⋁⋂⋃⋄⋅⋆⋇⋈⋉⋊⋋⋌⋍⋎⋏⋐⋑⋒⋓⋔⋕⋖⋗⋘⋙⋚⋛⋜⋝⋞⋟⋠⋡⋢⋣⋤⋥⋦⋧⋨⋩⋪⋫⋬⋭⋮⋯⋰⋱⋲⋳⋴⋵⋶⋷⋸⋹⋺⋻⋼⋽⋾⋿⌀⌁⌂⌃⌄⌅⌆⌇⌈⌉⌊⌋⌌⌍⌎⌏⌐⌑⌒⌓⌔⌕⌖⌗⌘⌙⌚⌛⌜⌝⌞⌟⌠⌡⌢⌣⌤⌥⌦⌧⌨〈〉⌫⌬⌭⌮⌯⌰⌱⌲⌳⌴⌵⌶⌷⌸⌹⌺⌻⌼⌽⌾⌿⍀⍁⍂⍃⍄⍅⍆⍇⍈⍉⍊⍋⍌⍍⍎⍏⍐⍑⍒⍓⍔⍕⍖⍗⍘⍙⍚⍛⍜⍝⍞⍟⍠⍡⍢⍣⍤⍥⍦⍧⍨⍩⍪⍫⍬⍭⍮⍯⍰⍱⍲⍳⍴⍵⍶⍷⍸⍹⍺⍻⍼⍽⍾⍿⎀⎁⎂⎃⎄⎅⎆⎇⎈⎉⎊⎋⎌⎍⎎⎏⎐⎑⎒⎓⎔⎕⎖⎗⎘⎙⎚⎛⎜⎝⎞⎟⎠⎡⎢⎣⎤⎥⎦⎧⎨⎩⎪⎫⎬⎭⎮⎯⎰⎱⎲⎳⎴⎵⎶⎷⎸⎹⎺⎻⎼⎽⎾⎿⏀⏁⏂⏃⏄⏅⏆⏇⏈⏉⏊⏋⏌⏍⏎⏏⏐⏑⏒⏓⏔⏕⏖⏗⏘⏙⏚⏛⏜⏝⏞⏟⏠⏡⏢⏣⏤⏥⏦⏧⏨␀␁␂␃␄␅␆␇␈␉␊␋␌␍␎␏␐␑␒␓␔␕␖␗␘␙␚␛␜␝␞␟␠␡␢␣␤␥␦⑀⑁⑂⑃⑄⑅⑆⑇⑈⑉⑊ +①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇⒈⒉⒊⒋⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛ +⒜⒝⒞⒟⒠⒡⒢⒣⒤⒥⒦⒧⒨⒩⒪⒫⒬⒭⒮⒯⒰⒱⒲⒳⒴⒵ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ +⓪⓫⓬⓭⓮⓯⓰⓱⓲⓳⓴⓵⓶⓷⓸⓹⓺⓻⓼⓽⓾⓿ +─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟■□▢▣▤▥▦▧▨▩▪▫▬▭▮▯▰▱▲△▴▵▶▷▸▹►▻▼▽▾▿◀◁◂◃◄◅◆◇◈◉◊○◌◍◎●◐◑◒◓◔◕◖◗◘◙◚◛◜◝◞◟◠◡◢◣◤◥◦◧◨◩◪◫◬◭◮◯◰◱◲◳◴◵◶◷◸◹◺◻◼◽◾◿☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☔☕☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♈♉♊♋♌♍♎♏♐♑♒♓♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚇⚈⚉⚊⚋⚌⚍⚎⚏⚐⚑⚒⚓⚔⚕⚖⚗⚘⚙⚚⚛⚜⚝⚞⚟⚠⚡⚢⚣⚤⚥⚦⚧⚨⚩⚪⚫⚬⚭⚮⚯⚰⚱⚲⚳⚴⚵⚶⚷⚸⚹⚺⚻⚼⚽⚾⚿⛀⛁⛂⛃⛄⛅⛆⛇⛈⛉⛊⛋⛌⛍⛏⛐⛑⛒⛓⛔⛕⛖⛗⛘⛙⛚⛛⛜⛝⛞⛟⛠⛡⛣⛨⛩⛪⛫⛬⛭⛮⛯⛰⛱⛲⛳⛴⛵⛶⛷⛸⛹⛺⛻⛼⛽⛾⛿✁✂✃✄✆✇✈✉✌✍✎✏✐✑✒✓✔✕✖✗✘✙✚✛✜✝✞✟✠✡✢✣✤✥✦✧✩✪✫✬✭✮✯✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❍❏❐❑❒❖❗❘❙❚❛❜❝❞❡❢❣❤❥❦❧❨❩❪❫❬❭❮❯❰❱❲❳❴❵ +❶❷❸❹❺❻❼❽❾❿➀➁➂➃➄➅➆➇➈➉➊➋➌➍➎➏➐➑➒➓ +➔➘➙➚➛➜➝➞➟➠➡➢➣➤➥➦➧➨➩➪➫➬➭➮➯➱➲➳➴➵➶➷➸➹➺➻➼➽➾⟀⟁⟂⟃⟄⟅⟆⟇⟈⟉⟊⟌⟐⟑⟒⟓⟔⟕⟖⟗⟘⟙⟚⟛⟜⟝⟞⟟⟠⟡⟢⟣⟤⟥⟦⟧⟨⟩⟪⟫⟬⟭⟮⟯⟰⟱⟲⟳⟴⟵⟶⟷⟸⟹⟺⟻⟼⟽⟾⟿⠀⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⡈⡉⡊⡋⡌⡍⡎⡏⡐⡑⡒⡓⡔⡕⡖⡗⡘⡙⡚⡛⡜⡝⡞⡟⡠⡡⡢⡣⡤⡥⡦⡧⡨⡩⡪⡫⡬⡭⡮⡯⡰⡱⡲⡳⡴⡵⡶⡷⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⢈⢉⢊⢋⢌⢍⢎⢏⢐⢑⢒⢓⢔⢕⢖⢗⢘⢙⢚⢛⢜⢝⢞⢟⢠⢡⢢⢣⢤⢥⢦⢧⢨⢩⢪⢫⢬⢭⢮⢯⢰⢱⢲⢳⢴⢵⢶⢷⢸⢹⢺⢻⢼⢽⢾⢿⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿⤀⤁⤂⤃⤄⤅⤆⤇⤈⤉⤊⤋⤌⤍⤎⤏⤐⤑⤒⤓⤔⤕⤖⤗⤘⤙⤚⤛⤜⤝⤞⤟⤠⤡⤢⤣⤤⤥⤦⤧⤨⤩⤪⤫⤬⤭⤮⤯⤰⤱⤲⤳⤴⤵⤶⤷⤸⤹⤺⤻⤼⤽⤾⤿⥀⥁⥂⥃⥄⥅⥆⥇⥈⥉⥊⥋⥌⥍⥎⥏⥐⥑⥒⥓⥔⥕⥖⥗⥘⥙⥚⥛⥜⥝⥞⥟⥠⥡⥢⥣⥤⥥⥦⥧⥨⥩⥪⥫⥬⥭⥮⥯⥰⥱⥲⥳⥴⥵⥶⥷⥸⥹⥺⥻⥼⥽⥾⥿⦀⦁⦂⦃⦄⦅⦆⦇⦈⦉⦊⦋⦌⦍⦎⦏⦐⦑⦒⦓⦔⦕⦖⦗⦘⦙⦚⦛⦜⦝⦞⦟⦠⦡⦢⦣⦤⦥⦦⦧⦨⦩⦪⦫⦬⦭⦮⦯⦰⦱⦲⦳⦴⦵⦶⦷⦸⦹⦺⦻⦼⦽⦾⦿⧀⧁⧂⧃⧄⧅⧆⧇⧈⧉⧊⧋⧌⧍⧎⧏⧐⧑⧒⧓⧔⧕⧖⧗⧘⧙⧚⧛⧜⧝⧞⧟⧠⧡⧢⧣⧤⧥⧦⧧⧨⧩⧪⧫⧬⧭⧮⧯⧰⧱⧲⧳⧴⧵⧶⧷⧸⧹⧺⧻⧼⧽⧾⧿⨀⨁⨂⨃⨄⨅⨆⨇⨈⨉⨊⨋⨌⨍⨎⨏⨐⨑⨒⨓⨔⨕⨖⨗⨘⨙⨚⨛⨜⨝⨞⨟⨠⨡⨢⨣⨤⨥⨦⨧⨨⨩⨪⨫⨬⨭⨮⨯⨰⨱⨲⨳⨴⨵⨶⨷⨸⨹⨺⨻⨼⨽⨾⨿⩀⩁⩂⩃⩄⩅⩆⩇⩈⩉⩊⩋⩌⩍⩎⩏⩐⩑⩒⩓⩔⩕⩖⩗⩘⩙⩚⩛⩜⩝⩞⩟⩠⩡⩢⩣⩤⩥⩦⩧⩨⩩⩪⩫⩬⩭⩮⩯⩰⩱⩲⩳⩴⩵⩶⩷⩸⩹⩺⩻⩼⩽⩾⩿⪀⪁⪂⪃⪄⪅⪆⪇⪈⪉⪊⪋⪌⪍⪎⪏⪐⪑⪒⪓⪔⪕⪖⪗⪘⪙⪚⪛⪜⪝⪞⪟⪠⪡⪢⪣⪤⪥⪦⪧⪨⪩⪪⪫⪬⪭⪮⪯⪰⪱⪲⪳⪴⪵⪶⪷⪸⪹⪺⪻⪼⪽⪾⪿⫀⫁⫂⫃⫄⫅⫆⫇⫈⫉⫊⫋⫌⫍⫎⫏⫐⫑⫒⫓⫔⫕⫖⫗⫘⫙⫚⫛⫝̸⫝⫞⫟⫠⫡⫢⫣⫤⫥⫦⫧⫨⫩⫪⫫⫬⫭⫮⫯⫰⫱⫲⫳⫴⫵⫶⫷⫸⫹⫺⫻⫼⫽⫾⫿⬀⬁⬂⬃⬄⬅⬆⬇⬈⬉⬊⬋⬌⬍⬎⬏⬐⬑⬒⬓⬔⬕⬖⬗⬘⬙⬚⬛⬜⬝⬞⬟⬠⬡⬢⬣⬤⬥⬦⬧⬨⬩⬪⬫⬬⬭⬮⬯⬰⬱⬲⬳⬴⬵⬶⬷⬸⬹⬺⬻⬼⬽⬾⬿⭀⭁⭂⭃⭄⭅⭆⭇⭈⭉⭊⭋⭌⭐⭑⭒⭓⭔⭕⭖⭗⭘⭙ +ⰀⰁⰂⰃⰄⰅⰆⰇⰈⰉⰊⰋⰌⰍⰎⰏⰐⰑⰒⰓⰔⰕⰖⰗⰘⰙⰚⰛⰜⰝⰞⰟⰠⰡⰢⰣⰤⰥⰦⰧⰨⰩⰪⰫⰬⰭⰮⰰⰱⰲⰳⰴⰵⰶⰷⰸⰹⰺⰻⰼⰽⰾⰿⱀⱁⱂⱃⱄⱅⱆⱇⱈⱉⱊⱋⱌⱍⱎⱏⱐⱑⱒⱓⱔⱕⱖⱗⱘⱙⱚⱛⱜⱝⱞⱠⱡⱢⱣⱤⱥⱦⱧⱨⱩⱪⱫⱬⱭⱮⱯⱰⱱⱲⱳⱴⱵⱶⱷⱸⱹⱺⱻⱼⱽⱾⱿⲀⲁⲂⲃⲄⲅⲆⲇⲈⲉⲊⲋⲌⲍⲎⲏⲐⲑⲒⲓⲔⲕⲖⲗⲘⲙⲚⲛⲜⲝⲞⲟⲠⲡⲢⲣⲤⲥⲦⲧⲨⲩⲪⲫⲬⲭⲮⲯⲰⲱⲲⲳⲴⲵⲶⲷⲸⲹⲺⲻⲼⲽⲾⲿⳀⳁⳂⳃⳄⳅⳆⳇⳈⳉⳊⳋⳌⳍⳎⳏⳐⳑⳒⳓⳔⳕⳖⳗⳘⳙⳚⳛⳜⳝⳞⳟⳠⳡⳢⳣⳤ +⳥⳦⳧⳨⳩⳪ +ⳫⳬⳭⳮ⳯⳰⳱ +⳹⳺⳻⳼ +⳽ +⳾⳿ +ⴀⴁⴂⴃⴄⴅⴆⴇⴈⴉⴊⴋⴌⴍⴎⴏⴐⴑⴒⴓⴔⴕⴖⴗⴘⴙⴚⴛⴜⴝⴞⴟⴠⴡⴢⴣⴤⴥⴰⴱⴲⴳⴴⴵⴶⴷⴸⴹⴺⴻⴼⴽⴾⴿⵀⵁⵂⵃⵄⵅⵆⵇⵈⵉⵊⵋⵌⵍⵎⵏⵐⵑⵒⵓⵔⵕⵖⵗⵘⵙⵚⵛⵜⵝⵞⵟⵠⵡⵢⵣⵤⵥⵯⶀⶁⶂⶃⶄⶅⶆⶇⶈⶉⶊⶋⶌⶍⶎⶏⶐⶑⶒⶓⶔⶕⶖⶠⶡⶢⶣⶤⶥⶦⶨⶩⶪⶫⶬⶭⶮⶰⶱⶲⶳⶴⶵⶶⶸⶹⶺⶻⶼⶽⶾⷀⷁⷂⷃⷄⷅⷆⷈⷉⷊⷋⷌⷍⷎⷐⷑⷒⷓⷔⷕⷖⷘⷙⷚⷛⷜⷝⷞⷠⷡⷢⷣⷤⷥⷦⷧⷨⷩⷪⷫⷬⷭⷮⷯⷰⷱⷲⷳⷴⷵⷶⷷⷸⷹⷺⷻⷼⷽⷾⷿ +⸀⸁⸂⸃⸄⸅⸆⸇⸈⸉⸊⸋⸌⸍⸎⸏⸐⸑⸒⸓⸔⸕⸖⸗⸘⸙⸚⸛⸜⸝⸞⸟⸠⸡⸢⸣⸤⸥⸦⸧⸨⸩⸪⸫⸬⸭⸮ +ⸯ +⸰⸱⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠⻡⻢⻣⻤⻥⻦⻧⻨⻩⻪⻫⻬⻭⻮⻯⻰⻱⻲⻳⼀⼁⼂⼃⼄⼅⼆⼇⼈⼉⼊⼋⼌⼍⼎⼏⼐⼑⼒⼓⼔⼕⼖⼗⼘⼙⼚⼛⼜⼝⼞⼟⼠⼡⼢⼣⼤⼥⼦⼧⼨⼩⼪⼫⼬⼭⼮⼯⼰⼱⼲⼳⼴⼵⼶⼷⼸⼹⼺⼻⼼⼽⼾⼿⽀⽁⽂⽃⽄⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿⾀⾁⾂⾃⾄⾅⾆⾇⾈⾉⾊⾋⾌⾍⾎⾏⾐⾑⾒⾓⾔⾕⾖⾗⾘⾙⾚⾛⾜⾝⾞⾟⾠⾡⾢⾣⾤⾥⾦⾧⾨⾩⾪⾫⾬⾭⾮⾯⾰⾱⾲⾳⾴⾵⾶⾷⾸⾹⾺⾻⾼⾽⾾⾿⿀⿁⿂⿃⿄⿅⿆⿇⿈⿉⿊⿋⿌⿍⿎⿏⿐⿑⿒⿓⿔⿕⿰⿱⿲⿳⿴⿵⿶⿷⿸⿹⿺⿻ 、。〃〄 +々〆〇 +〈〉《》「」『』【】〒〓〔〕〖〗〘〙〚〛〜〝〞〟〠 +〡〢〣〤〥〦〧〨〩〪〭〮〯〫〬 +〰 +〱〲〳〴〵 +〶〷 +〸〹〺〻〼 +〽〾〿 +ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんゔゕゖ゙゚ +゛゜ +ゝゞゟ +゠ +ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ +・ +ーヽヾヿㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦㄧㄨㄩㄪㄫㄬㄭㄱㄲㄳㄴㄵㄶㄷㄸㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅃㅄㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣㅤㅥㅦㅧㅨㅩㅪㅫㅬㅭㅮㅯㅰㅱㅲㅳㅴㅵㅶㅷㅸㅹㅺㅻㅼㅽㅾㅿㆀㆁㆂㆃㆄㆅㆆㆇㆈㆉㆊㆋㆌㆍㆎ +㆐㆑ +㆒㆓㆔㆕ +㆖㆗㆘㆙㆚㆛㆜㆝㆞㆟ +ㆠㆡㆢㆣㆤㆥㆦㆧㆨㆩㆪㆫㆬㆭㆮㆯㆰㆱㆲㆳㆴㆵㆶㆷ +㇀㇁㇂㇃㇄㇅㇆㇇㇈㇉㇊㇋㇌㇍㇎㇏㇐㇑㇒㇓㇔㇕㇖㇗㇘㇙㇚㇛㇜㇝㇞㇟㇠㇡㇢㇣ +ㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ +㈀㈁㈂㈃㈄㈅㈆㈇㈈㈉㈊㈋㈌㈍㈎㈏㈐㈑㈒㈓㈔㈕㈖㈗㈘㈙㈚㈛㈜㈝㈞ +㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ +㈪㈫㈬㈭㈮㈯㈰㈱㈲㈳㈴㈵㈶㈷㈸㈹㈺㈻㈼㈽㈾㈿㉀㉁㉂㉃㉄㉅㉆㉇㉈㉉㉊㉋㉌㉍㉎㉏㉐ +㉑㉒㉓㉔㉕㉖㉗㉘㉙㉚㉛㉜㉝㉞㉟ +㉠㉡㉢㉣㉤㉥㉦㉧㉨㉩㉪㉫㉬㉭㉮㉯㉰㉱㉲㉳㉴㉵㉶㉷㉸㉹㉺㉻㉼㉽㉾㉿ +㊀㊁㊂㊃㊄㊅㊆㊇㊈㊉ +㊊㊋㊌㊍㊎㊏㊐㊑㊒㊓㊔㊕㊖㊗㊘㊙㊚㊛㊜㊝㊞㊟㊠㊡㊢㊣㊤㊥㊦㊧㊨㊩㊪㊫㊬㊭㊮㊯㊰ +㊱㊲㊳㊴㊵㊶㊷㊸㊹㊺㊻㊼㊽㊾㊿ +㋀㋁㋂㋃㋄㋅㋆㋇㋈㋉㋊㋋㋌㋍㋎㋏㋐㋑㋒㋓㋔㋕㋖㋗㋘㋙㋚㋛㋜㋝㋞㋟㋠㋡㋢㋣㋤㋥㋦㋧㋨㋩㋪㋫㋬㋭㋮㋯㋰㋱㋲㋳㋴㋵㋶㋷㋸㋹㋺㋻㋼㋽㋾㌀㌁㌂㌃㌄㌅㌆㌇㌈㌉㌊㌋㌌㌍㌎㌏㌐㌑㌒㌓㌔㌕㌖㌗㌘㌙㌚㌛㌜㌝㌞㌟㌠㌡㌢㌣㌤㌥㌦㌧㌨㌩㌪㌫㌬㌭㌮㌯㌰㌱㌲㌳㌴㌵㌶㌷㌸㌹㌺㌻㌼㌽㌾㌿㍀㍁㍂㍃㍄㍅㍆㍇㍈㍉㍊㍋㍌㍍㍎㍏㍐㍑㍒㍓㍔㍕㍖㍗㍘㍙㍚㍛㍜㍝㍞㍟㍠㍡㍢㍣㍤㍥㍦㍧㍨㍩㍪㍫㍬㍭㍮㍯㍰㍱㍲㍳㍴㍵㍶㍷㍸㍹㍺㍻㍼㍽㍾㍿㎀㎁㎂㎃㎄㎅㎆㎇㎈㎉㎊㎋㎌㎍㎎㎏㎐㎑㎒㎓㎔㎕㎖㎗㎘㎙㎚㎛㎜㎝㎞㎟㎠㎡㎢㎣㎤㎥㎦㎧㎨㎩㎪㎫㎬㎭㎮㎯㎰㎱㎲㎳㎴㎵㎶㎷㎸㎹㎺㎻㎼㎽㎾㎿㏀㏁㏂㏃㏄㏅㏆㏇㏈㏉㏊㏋㏌㏍㏎㏏㏐㏑㏒㏓㏔㏕㏖㏗㏘㏙㏚㏛㏜㏝㏞㏟㏠㏡㏢㏣㏤㏥㏦㏧㏨㏩㏪㏫㏬㏭㏮㏯㏰㏱㏲㏳㏴㏵㏶㏷㏸㏹㏺㏻㏼㏽㏾㏿ +㐀䶵 +䷀䷁䷂䷃䷄䷅䷆䷇䷈䷉䷊䷋䷌䷍䷎䷏䷐䷑䷒䷓䷔䷕䷖䷗䷘䷙䷚䷛䷜䷝䷞䷟䷠䷡䷢䷣䷤䷥䷦䷧䷨䷩䷪䷫䷬䷭䷮䷯䷰䷱䷲䷳䷴䷵䷶䷷䷸䷹䷺䷻䷼䷽䷾䷿ +一鿋ꀀꀁꀂꀃꀄꀅꀆꀇꀈꀉꀊꀋꀌꀍꀎꀏꀐꀑꀒꀓꀔꀕꀖꀗꀘꀙꀚꀛꀜꀝꀞꀟꀠꀡꀢꀣꀤꀥꀦꀧꀨꀩꀪꀫꀬꀭꀮꀯꀰꀱꀲꀳꀴꀵꀶꀷꀸꀹꀺꀻꀼꀽꀾꀿꁀꁁꁂꁃꁄꁅꁆꁇꁈꁉꁊꁋꁌꁍꁎꁏꁐꁑꁒꁓꁔꁕꁖꁗꁘꁙꁚꁛꁜꁝꁞꁟꁠꁡꁢꁣꁤꁥꁦꁧꁨꁩꁪꁫꁬꁭꁮꁯꁰꁱꁲꁳꁴꁵꁶꁷꁸꁹꁺꁻꁼꁽꁾꁿꂀꂁꂂꂃꂄꂅꂆꂇꂈꂉꂊꂋꂌꂍꂎꂏꂐꂑꂒꂓꂔꂕꂖꂗꂘꂙꂚꂛꂜꂝꂞꂟꂠꂡꂢꂣꂤꂥꂦꂧꂨꂩꂪꂫꂬꂭꂮꂯꂰꂱꂲꂳꂴꂵꂶꂷꂸꂹꂺꂻꂼꂽꂾꂿꃀꃁꃂꃃꃄꃅꃆꃇꃈꃉꃊꃋꃌꃍꃎꃏꃐꃑꃒꃓꃔꃕꃖꃗꃘꃙꃚꃛꃜꃝꃞꃟꃠꃡꃢꃣꃤꃥꃦꃧꃨꃩꃪꃫꃬꃭꃮꃯꃰꃱꃲꃳꃴꃵꃶꃷꃸꃹꃺꃻꃼꃽꃾꃿꄀꄁꄂꄃꄄꄅꄆꄇꄈꄉꄊꄋꄌꄍꄎꄏꄐꄑꄒꄓꄔꄕꄖꄗꄘꄙꄚꄛꄜꄝꄞꄟꄠꄡꄢꄣꄤꄥꄦꄧꄨꄩꄪꄫꄬꄭꄮꄯꄰꄱꄲꄳꄴꄵꄶꄷꄸꄹꄺꄻꄼꄽꄾꄿꅀꅁꅂꅃꅄꅅꅆꅇꅈꅉꅊꅋꅌꅍꅎꅏꅐꅑꅒꅓꅔꅕꅖꅗꅘꅙꅚꅛꅜꅝꅞꅟꅠꅡꅢꅣꅤꅥꅦꅧꅨꅩꅪꅫꅬꅭꅮꅯꅰꅱꅲꅳꅴꅵꅶꅷꅸꅹꅺꅻꅼꅽꅾꅿꆀꆁꆂꆃꆄꆅꆆꆇꆈꆉꆊꆋꆌꆍꆎꆏꆐꆑꆒꆓꆔꆕꆖꆗꆘꆙꆚꆛꆜꆝꆞꆟꆠꆡꆢꆣꆤꆥꆦꆧꆨꆩꆪꆫꆬꆭꆮꆯꆰꆱꆲꆳꆴꆵꆶꆷꆸꆹꆺꆻꆼꆽꆾꆿꇀꇁꇂꇃꇄꇅꇆꇇꇈꇉꇊꇋꇌꇍꇎꇏꇐꇑꇒꇓꇔꇕꇖꇗꇘꇙꇚꇛꇜꇝꇞꇟꇠꇡꇢꇣꇤꇥꇦꇧꇨꇩꇪꇫꇬꇭꇮꇯꇰꇱꇲꇳꇴꇵꇶꇷꇸꇹꇺꇻꇼꇽꇾꇿꈀꈁꈂꈃꈄꈅꈆꈇꈈꈉꈊꈋꈌꈍꈎꈏꈐꈑꈒꈓꈔꈕꈖꈗꈘꈙꈚꈛꈜꈝꈞꈟꈠꈡꈢꈣꈤꈥꈦꈧꈨꈩꈪꈫꈬꈭꈮꈯꈰꈱꈲꈳꈴꈵꈶꈷꈸꈹꈺꈻꈼꈽꈾꈿꉀꉁꉂꉃꉄꉅꉆꉇꉈꉉꉊꉋꉌꉍꉎꉏꉐꉑꉒꉓꉔꉕꉖꉗꉘꉙꉚꉛꉜꉝꉞꉟꉠꉡꉢꉣꉤꉥꉦꉧꉨꉩꉪꉫꉬꉭꉮꉯꉰꉱꉲꉳꉴꉵꉶꉷꉸꉹꉺꉻꉼꉽꉾꉿꊀꊁꊂꊃꊄꊅꊆꊇꊈꊉꊊꊋꊌꊍꊎꊏꊐꊑꊒꊓꊔꊕꊖꊗꊘꊙꊚꊛꊜꊝꊞꊟꊠꊡꊢꊣꊤꊥꊦꊧꊨꊩꊪꊫꊬꊭꊮꊯꊰꊱꊲꊳꊴꊵꊶꊷꊸꊹꊺꊻꊼꊽꊾꊿꋀꋁꋂꋃꋄꋅꋆꋇꋈꋉꋊꋋꋌꋍꋎꋏꋐꋑꋒꋓꋔꋕꋖꋗꋘꋙꋚꋛꋜꋝꋞꋟꋠꋡꋢꋣꋤꋥꋦꋧꋨꋩꋪꋫꋬꋭꋮꋯꋰꋱꋲꋳꋴꋵꋶꋷꋸꋹꋺꋻꋼꋽꋾꋿꌀꌁꌂꌃꌄꌅꌆꌇꌈꌉꌊꌋꌌꌍꌎꌏꌐꌑꌒꌓꌔꌕꌖꌗꌘꌙꌚꌛꌜꌝꌞꌟꌠꌡꌢꌣꌤꌥꌦꌧꌨꌩꌪꌫꌬꌭꌮꌯꌰꌱꌲꌳꌴꌵꌶꌷꌸꌹꌺꌻꌼꌽꌾꌿꍀꍁꍂꍃꍄꍅꍆꍇꍈꍉꍊꍋꍌꍍꍎꍏꍐꍑꍒꍓꍔꍕꍖꍗꍘꍙꍚꍛꍜꍝꍞꍟꍠꍡꍢꍣꍤꍥꍦꍧꍨꍩꍪꍫꍬꍭꍮꍯꍰꍱꍲꍳꍴꍵꍶꍷꍸꍹꍺꍻꍼꍽꍾꍿꎀꎁꎂꎃꎄꎅꎆꎇꎈꎉꎊꎋꎌꎍꎎꎏꎐꎑꎒꎓꎔꎕꎖꎗꎘꎙꎚꎛꎜꎝꎞꎟꎠꎡꎢꎣꎤꎥꎦꎧꎨꎩꎪꎫꎬꎭꎮꎯꎰꎱꎲꎳꎴꎵꎶꎷꎸꎹꎺꎻꎼꎽꎾꎿꏀꏁꏂꏃꏄꏅꏆꏇꏈꏉꏊꏋꏌꏍꏎꏏꏐꏑꏒꏓꏔꏕꏖꏗꏘꏙꏚꏛꏜꏝꏞꏟꏠꏡꏢꏣꏤꏥꏦꏧꏨꏩꏪꏫꏬꏭꏮꏯꏰꏱꏲꏳꏴꏵꏶꏷꏸꏹꏺꏻꏼꏽꏾꏿꐀꐁꐂꐃꐄꐅꐆꐇꐈꐉꐊꐋꐌꐍꐎꐏꐐꐑꐒꐓꐔꐕꐖꐗꐘꐙꐚꐛꐜꐝꐞꐟꐠꐡꐢꐣꐤꐥꐦꐧꐨꐩꐪꐫꐬꐭꐮꐯꐰꐱꐲꐳꐴꐵꐶꐷꐸꐹꐺꐻꐼꐽꐾꐿꑀꑁꑂꑃꑄꑅꑆꑇꑈꑉꑊꑋꑌꑍꑎꑏꑐꑑꑒꑓꑔꑕꑖꑗꑘꑙꑚꑛꑜꑝꑞꑟꑠꑡꑢꑣꑤꑥꑦꑧꑨꑩꑪꑫꑬꑭꑮꑯꑰꑱꑲꑳꑴꑵꑶꑷꑸꑹꑺꑻꑼꑽꑾꑿꒀꒁꒂꒃꒄꒅꒆꒇꒈꒉꒊꒋꒌ +꒐꒑꒒꒓꒔꒕꒖꒗꒘꒙꒚꒛꒜꒝꒞꒟꒠꒡꒢꒣꒤꒥꒦꒧꒨꒩꒪꒫꒬꒭꒮꒯꒰꒱꒲꒳꒴꒵꒶꒷꒸꒹꒺꒻꒼꒽꒾꒿꓀꓁꓂꓃꓄꓅꓆ +ꓐꓑꓒꓓꓔꓕꓖꓗꓘꓙꓚꓛꓜꓝꓞꓟꓠꓡꓢꓣꓤꓥꓦꓧꓨꓩꓪꓫꓬꓭꓮꓯꓰꓱꓲꓳꓴꓵꓶꓷꓸꓹꓺꓻꓼꓽ +꓾꓿ +ꔀꔁꔂꔃꔄꔅꔆꔇꔈꔉꔊꔋꔌꔍꔎꔏꔐꔑꔒꔓꔔꔕꔖꔗꔘꔙꔚꔛꔜꔝꔞꔟꔠꔡꔢꔣꔤꔥꔦꔧꔨꔩꔪꔫꔬꔭꔮꔯꔰꔱꔲꔳꔴꔵꔶꔷꔸꔹꔺꔻꔼꔽꔾꔿꕀꕁꕂꕃꕄꕅꕆꕇꕈꕉꕊꕋꕌꕍꕎꕏꕐꕑꕒꕓꕔꕕꕖꕗꕘꕙꕚꕛꕜꕝꕞꕟꕠꕡꕢꕣꕤꕥꕦꕧꕨꕩꕪꕫꕬꕭꕮꕯꕰꕱꕲꕳꕴꕵꕶꕷꕸꕹꕺꕻꕼꕽꕾꕿꖀꖁꖂꖃꖄꖅꖆꖇꖈꖉꖊꖋꖌꖍꖎꖏꖐꖑꖒꖓꖔꖕꖖꖗꖘꖙꖚꖛꖜꖝꖞꖟꖠꖡꖢꖣꖤꖥꖦꖧꖨꖩꖪꖫꖬꖭꖮꖯꖰꖱꖲꖳꖴꖵꖶꖷꖸꖹꖺꖻꖼꖽꖾꖿꗀꗁꗂꗃꗄꗅꗆꗇꗈꗉꗊꗋꗌꗍꗎꗏꗐꗑꗒꗓꗔꗕꗖꗗꗘꗙꗚꗛꗜꗝꗞꗟꗠꗡꗢꗣꗤꗥꗦꗧꗨꗩꗪꗫꗬꗭꗮꗯꗰꗱꗲꗳꗴꗵꗶꗷꗸꗹꗺꗻꗼꗽꗾꗿꘀꘁꘂꘃꘄꘅꘆꘇꘈꘉꘊꘋꘌ +꘍꘎꘏ +ꘐꘑꘒꘓꘔꘕꘖꘗꘘꘙꘚꘛꘜꘝꘞꘟ꘠꘡꘢꘣꘤꘥꘦꘧꘨꘩ꘪꘫꙀꙁꙂꙃꙄꙅꙆꙇꙈꙉꙊꙋꙌꙍꙎꙏꙐꙑꙒꙓꙔꙕꙖꙗꙘꙙꙚꙛꙜꙝꙞꙟꙢꙣꙤꙥꙦꙧꙨꙩꙪꙫꙬꙭꙮ꙯꙰꙱꙲ +꙳ +꙼꙽ +꙾ +ꙿꚀꚁꚂꚃꚄꚅꚆꚇꚈꚉꚊꚋꚌꚍꚎꚏꚐꚑꚒꚓꚔꚕꚖꚗꚠꚡꚢꚣꚤꚥꚦꚧꚨꚩꚪꚫꚬꚭꚮꚯꚰꚱꚲꚳꚴꚵꚶꚷꚸꚹꚺꚻꚼꚽꚾꚿꛀꛁꛂꛃꛄꛅꛆꛇꛈꛉꛊꛋꛌꛍꛎꛏꛐꛑꛒꛓꛔꛕꛖꛗꛘꛙꛚꛛꛜꛝꛞꛟꛠꛡꛢꛣꛤꛥꛦꛧꛨꛩꛪꛫꛬꛭꛮꛯ꛰꛱ +꛲꛳꛴꛵꛶꛷꜀꜁꜂꜃꜄꜅꜆꜇꜈꜉꜊꜋꜌꜍꜎꜏꜐꜑꜒꜓꜔꜕꜖ +ꜗꜘꜙꜚꜛꜜꜝꜞꜟ +꜠꜡ +ꜢꜣꜤꜥꜦꜧꜨꜩꜪꜫꜬꜭꜮꜯꜰꜱꜲꜳꜴꜵꜶꜷꜸꜹꜺꜻꜼꜽꜾꜿꝀꝁꝂꝃꝄꝅꝆꝇꝈꝉꝊꝋꝌꝍꝎꝏꝐꝑꝒꝓꝔꝕꝖꝗꝘꝙꝚꝛꝜꝝꝞꝟꝠꝡꝢꝣꝤꝥꝦꝧꝨꝩꝪꝫꝬꝭꝮꝯꝰꝱꝲꝳꝴꝵꝶꝷꝸꝹꝺꝻꝼꝽꝾꝿꞀꞁꞂꞃꞄꞅꞆꞇꞈ +꞉꞊ +Ꞌꞌꟻꟼꟽꟾꟿꠀꠁꠂꠃꠄꠅ꠆ꠇꠈꠉꠊꠋꠌꠍꠎꠏꠐꠑꠒꠓꠔꠕꠖꠗꠘꠙꠚꠛꠜꠝꠞꠟꠠꠡꠢꠣꠤꠥꠦꠧ +꠨꠩꠪꠫ +꠰꠱꠲꠳꠴꠵ +꠶꠷꠸꠹ +ꡀꡁꡂꡃꡄꡅꡆꡇꡈꡉꡊꡋꡌꡍꡎꡏꡐꡑꡒꡓꡔꡕꡖꡗꡘꡙꡚꡛꡜꡝꡞꡟꡠꡡꡢꡣꡤꡥꡦꡧꡨꡩꡪꡫꡬꡭꡮꡯꡰꡱꡲꡳ +꡴꡵꡶꡷ +ꢀꢁꢂꢃꢄꢅꢆꢇꢈꢉꢊꢋꢌꢍꢎꢏꢐꢑꢒꢓꢔꢕꢖꢗꢘꢙꢚꢛꢜꢝꢞꢟꢠꢡꢢꢣꢤꢥꢦꢧꢨꢩꢪꢫꢬꢭꢮꢯꢰꢱꢲꢳꢴꢵꢶꢷꢸꢹꢺꢻꢼꢽꢾꢿꣀꣁꣂꣃ꣄ +꣎꣏ +꣐꣑꣒꣓꣔꣕꣖꣗꣘꣙꣠꣡꣢꣣꣤꣥꣦꣧꣨꣩꣪꣫꣬꣭꣮꣯꣰꣱ꣲꣳꣴꣵꣶꣷ +꣸꣹꣺ +ꣻ꤀꤁꤂꤃꤄꤅꤆꤇꤈꤉ꤊꤋꤌꤍꤎꤏꤐꤑꤒꤓꤔꤕꤖꤗꤘꤙꤚꤛꤜꤝꤞꤟꤠꤡꤢꤣꤤꤥꤦꤧꤨꤩꤪ꤫꤬꤭ +꤮꤯ +ꤰꤱꤲꤳꤴꤵꤶꤷꤸꤹꤺꤻꤼꤽꤾꤿꥀꥁꥂꥃꥄꥅꥆꥇꥈꥉꥊꥋꥌꥍꥎꥏꥐꥑꥒ꥓ +꥟ +ꥠꥡꥢꥣꥤꥥꥦꥧꥨꥩꥪꥫꥬꥭꥮꥯꥰꥱꥲꥳꥴꥵꥶꥷꥸꥹꥺꥻꥼꦀꦁꦂꦃꦄꦅꦆꦇꦈꦉꦊꦋꦌꦍꦎꦏꦐꦑꦒꦓꦔꦕꦖꦗꦘꦙꦚꦛꦜꦝꦞꦟꦠꦡꦢꦣꦤꦥꦦꦧꦨꦩꦪꦫꦬꦭꦮꦯꦰꦱꦲ꦳ꦴꦵꦶꦷꦸꦹꦺꦻꦼꦽꦾꦿ꧀ +꧁꧂꧃꧄꧅꧆꧇꧈꧉꧊꧋꧌꧍ +ꧏ꧐꧑꧒꧓꧔꧕꧖꧗꧘꧙ +꧞꧟ +ꨀꨁꨂꨃꨄꨅꨆꨇꨈꨉꨊꨋꨌꨍꨎꨏꨐꨑꨒꨓꨔꨕꨖꨗꨘꨙꨚꨛꨜꨝꨞꨟꨠꨡꨢꨣꨤꨥꨦꨧꨨꨩꨪꨫꨬꨭꨮꨯꨰꨱꨲꨳꨴꨵꨶꩀꩁꩂꩃꩄꩅꩆꩇꩈꩉꩊꩋꩌꩍ꩐꩑꩒꩓꩔꩕꩖꩗꩘꩙ +꩜꩝꩞꩟ +ꩠꩡꩢꩣꩤꩥꩦꩧꩨꩩꩪꩫꩬꩭꩮꩯꩰꩱꩲꩳꩴꩵꩶ +꩷꩸꩹ +ꩺꩻꪀꪁꪂꪃꪄꪅꪆꪇꪈꪉꪊꪋꪌꪍꪎꪏꪐꪑꪒꪓꪔꪕꪖꪗꪘꪙꪚꪛꪜꪝꪞꪟꪠꪡꪢꪣꪤꪥꪦꪧꪨꪩꪪꪫꪬꪭꪮꪯꪰꪱꪴꪲꪳꪵꪶꪷꪸꪹꪺꪻꪼꪽꪾ꪿ꫀ꫁ꫂꫛꫜꫝ +꫞꫟ +ꯀꯁꯂꯃꯄꯅꯆꯇꯈꯉꯊꯋꯌꯍꯎꯏꯐꯑꯒꯓꯔꯕꯖꯗꯘꯙꯚꯛꯜꯝꯞꯟꯠꯡꯢꯣꯤꯥꯦꯧꯨꯩꯪ +꯫ +꯬꯭꯰꯱꯲꯳꯴꯵꯶꯷꯸꯹가힣ힰힱힲힳힴힵힶힷힸힹힺힻힼힽힾힿퟀퟁퟂퟃퟄퟅퟆퟋퟌퟍퟎퟏퟐퟑퟒퟓퟔퟕퟖퟗퟘퟙퟚퟛퟜퟝퟞퟟퟠퟡퟢퟣퟤퟥퟦퟧퟨퟩퟪퟫퟬퟭퟮퟯퟰퟱퟲퟳퟴퟵퟶퟷퟸퟹퟺퟻ + +豈更車賈滑串句龜龜契金喇奈懶癩羅蘿螺裸邏樂洛烙珞落酪駱亂卵欄爛蘭鸞嵐濫藍襤拉臘蠟廊朗浪狼郎來冷勞擄櫓爐盧老蘆虜路露魯鷺碌祿綠菉錄鹿論壟弄籠聾牢磊賂雷壘屢樓淚漏累縷陋勒肋凜凌稜綾菱陵讀拏樂諾丹寧怒率異北磻便復不泌數索參塞省葉說殺辰沈拾若掠略亮兩凉梁糧良諒量勵呂女廬旅濾礪閭驪麗黎力曆歷轢年憐戀撚漣煉璉秊練聯輦蓮連鍊列劣咽烈裂說廉念捻殮簾獵令囹寧嶺怜玲瑩羚聆鈴零靈領例禮醴隸惡了僚寮尿料樂燎療蓼遼龍暈阮劉杻柳流溜琉留硫紐類六戮陸倫崙淪輪律慄栗率隆利吏履易李梨泥理痢罹裏裡里離匿溺吝燐璘藺隣鱗麟林淋臨立笠粒狀炙識什茶刺切度拓糖宅洞暴輻行降見廓兀嗀﨎﨏塚﨑晴﨓﨔凞猪益礼神祥福靖精羽﨟蘒﨡諸﨣﨤逸都﨧﨨﨩飯飼館鶴侮僧免勉勤卑喝嘆器塀墨層屮悔慨憎懲敏既暑梅海渚漢煮爫琢碑社祉祈祐祖祝禍禎穀突節練縉繁署者臭艹艹著褐視謁謹賓贈辶逸難響頻恵𤋮舘並况全侀充冀勇勺喝啕喙嗢塚墳奄奔婢嬨廒廙彩徭惘慎愈憎慠懲戴揄搜摒敖晴朗望杖歹殺流滛滋漢瀞煮瞧爵犯猪瑱甆画瘝瘟益盛直睊着磌窱節类絛練缾者荒華蝹襁覆視調諸請謁諾諭謹變贈輸遲醙鉶陼難靖韛響頋頻鬒龜𢡊𢡄𣏕㮝䀘䀹𥉉𥳐𧻓齃龎fffiflffifflſtstﬓﬔﬕﬖﬗיִﬞײַﬠﬡﬢﬣﬤﬥﬦﬧﬨ +﬩ +שׁשׂשּׁשּׂאַאָאּבּגּדּהּוּזּטּיּךּכּלּמּנּסּףּפּצּקּרּשּתּוֹבֿכֿפֿﭏﭐﭑﭒﭓﭔﭕﭖﭗﭘﭙﭚﭛﭜﭝﭞﭟﭠﭡﭢﭣﭤﭥﭦﭧﭨﭩﭪﭫﭬﭭﭮﭯﭰﭱﭲﭳﭴﭵﭶﭷﭸﭹﭺﭻﭼﭽﭾﭿﮀﮁﮂﮃﮄﮅﮆﮇﮈﮉﮊﮋﮌﮍﮎﮏﮐﮑﮒﮓﮔﮕﮖﮗﮘﮙﮚﮛﮜﮝﮞﮟﮠﮡﮢﮣﮤﮥﮦﮧﮨﮩﮪﮫﮬﮭﮮﮯﮰﮱﯓﯔﯕﯖﯗﯘﯙﯚﯛﯜﯝﯞﯟﯠﯡﯢﯣﯤﯥﯦﯧﯨﯩﯪﯫﯬﯭﯮﯯﯰﯱﯲﯳﯴﯵﯶﯷﯸﯹﯺﯻﯼﯽﯾﯿﰀﰁﰂﰃﰄﰅﰆﰇﰈﰉﰊﰋﰌﰍﰎﰏﰐﰑﰒﰓﰔﰕﰖﰗﰘﰙﰚﰛﰜﰝﰞﰟﰠﰡﰢﰣﰤﰥﰦﰧﰨﰩﰪﰫﰬﰭﰮﰯﰰﰱﰲﰳﰴﰵﰶﰷﰸﰹﰺﰻﰼﰽﰾﰿﱀﱁﱂﱃﱄﱅﱆﱇﱈﱉﱊﱋﱌﱍﱎﱏﱐﱑﱒﱓﱔﱕﱖﱗﱘﱙﱚﱛﱜﱝﱞﱟﱠﱡﱢﱣﱤﱥﱦﱧﱨﱩﱪﱫﱬﱭﱮﱯﱰﱱﱲﱳﱴﱵﱶﱷﱸﱹﱺﱻﱼﱽﱾﱿﲀﲁﲂﲃﲄﲅﲆﲇﲈﲉﲊﲋﲌﲍﲎﲏﲐﲑﲒﲓﲔﲕﲖﲗﲘﲙﲚﲛﲜﲝﲞﲟﲠﲡﲢﲣﲤﲥﲦﲧﲨﲩﲪﲫﲬﲭﲮﲯﲰﲱﲲﲳﲴﲵﲶﲷﲸﲹﲺﲻﲼﲽﲾﲿﳀﳁﳂﳃﳄﳅﳆﳇﳈﳉﳊﳋﳌﳍﳎﳏﳐﳑﳒﳓﳔﳕﳖﳗﳘﳙﳚﳛﳜﳝﳞﳟﳠﳡﳢﳣﳤﳥﳦﳧﳨﳩﳪﳫﳬﳭﳮﳯﳰﳱﳲﳳﳴﳵﳶﳷﳸﳹﳺﳻﳼﳽﳾﳿﴀﴁﴂﴃﴄﴅﴆﴇﴈﴉﴊﴋﴌﴍﴎﴏﴐﴑﴒﴓﴔﴕﴖﴗﴘﴙﴚﴛﴜﴝﴞﴟﴠﴡﴢﴣﴤﴥﴦﴧﴨﴩﴪﴫﴬﴭﴮﴯﴰﴱﴲﴳﴴﴵﴶﴷﴸﴹﴺﴻﴼﴽ +﴾﴿ +ﵐﵑﵒﵓﵔﵕﵖﵗﵘﵙﵚﵛﵜﵝﵞﵟﵠﵡﵢﵣﵤﵥﵦﵧﵨﵩﵪﵫﵬﵭﵮﵯﵰﵱﵲﵳﵴﵵﵶﵷﵸﵹﵺﵻﵼﵽﵾﵿﶀﶁﶂﶃﶄﶅﶆﶇﶈﶉﶊﶋﶌﶍﶎﶏﶒﶓﶔﶕﶖﶗﶘﶙﶚﶛﶜﶝﶞﶟﶠﶡﶢﶣﶤﶥﶦﶧﶨﶩﶪﶫﶬﶭﶮﶯﶰﶱﶲﶳﶴﶵﶶﶷﶸﶹﶺﶻﶼﶽﶾﶿﷀﷁﷂﷃﷄﷅﷆﷇﷰﷱﷲﷳﷴﷵﷶﷷﷸﷹﷺﷻ +﷼﷽ +︀︁︂︃︄︅︆︇︈︉︊︋︌︍︎️ +︐︑︒︓︔︕︖︗︘︙ +︠︡︢︣︤︥︦ +︰︱︲︳︴︵︶︷︸︹︺︻︼︽︾︿﹀﹁﹂﹃﹄﹅﹆﹇﹈﹉﹊﹋﹌﹍﹎﹏﹐﹑﹒﹔﹕﹖﹗﹘﹙﹚﹛﹜﹝﹞﹟﹠﹡﹢﹣﹤﹥﹦﹨﹩﹪﹫ +ﹰﹱﹲﹳﹴﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ +!"#$%&'()*+,-./ +0123456789 +:;<=>?@ +ABCDEFGHIJKLMNOPQRSTUVWXYZ +[\]^_` +abcdefghijklmnopqrstuvwxyz +{|}~⦅⦆。「」、・ +ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚ᅠᄀᄁᆪᄂᆬᆭᄃᄄᄅᆰᆱᆲᆳᆴᆵᄚᄆᄇᄈᄡᄉᄊᄋᄌᄍᄎᄏᄐᄑ하ᅢᅣᅤᅥᅦᅧᅨᅩᅪᅫᅬᅭᅮᅯᅰᅱᅲᅳᅴᅵ +¢£¬ ̄¦¥₩│←↑→↓■○� +𐀀 \ No newline at end of file diff --git a/drupal-dev/modules/search/tests/search_embedded_form.info b/drupal-dev/modules/search/tests/search_embedded_form.info new file mode 100644 index 0000000..6413e94 --- /dev/null +++ b/drupal-dev/modules/search/tests/search_embedded_form.info @@ -0,0 +1,12 @@ +name = "Search embedded form" +description = "Support module for search module testing of embedded forms." +package = Testing +version = VERSION +core = 7.x +hidden = TRUE + +; Information added by Drupal.org packaging script on 2014-01-15 +version = "7.26" +project = "drupal" +datestamp = "1389815930" + diff --git a/drupal-dev/modules/search/tests/search_embedded_form.module b/drupal-dev/modules/search/tests/search_embedded_form.module new file mode 100644 index 0000000..4845796 --- /dev/null +++ b/drupal-dev/modules/search/tests/search_embedded_form.module @@ -0,0 +1,70 @@ + 'Search_Embed_Form', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('search_embedded_form_form'), + 'access arguments' => array('search content'), + 'type' => MENU_CALLBACK, + ); + + return $items; +} + +/** + * Builds a form for embedding in search results for testing. + * + * @see search_embedded_form_form_submit(). + */ +function search_embedded_form_form($form, &$form_state) { + $count = variable_get('search_embedded_form_submitted', 0); + + $form['name'] = array( + '#type' => 'textfield', + '#title' => t('Your name'), + '#maxlength' => 255, + '#default_value' => '', + '#required' => TRUE, + '#description' => t('Times form has been submitted: %count', array('%count' => $count)), + ); + + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Send away'), + ); + + $form['#submit'][] = 'search_embedded_form_form_submit'; + + return $form; +} + +/** + * Submit handler for search_embedded_form_form(). + */ +function search_embedded_form_form_submit($form, &$form_state) { + $count = variable_get('search_embedded_form_submitted', 0) + 1; + variable_set('search_embedded_form_submitted', $count); + drupal_set_message(t('Test form was submitted')); +} + +/** + * Adds the test form to search results. + */ +function search_embedded_form_preprocess_search_result(&$variables) { + $form = drupal_get_form('search_embedded_form_form'); + $variables['snippet'] .= drupal_render($form); +} diff --git a/drupal-dev/modules/search/tests/search_extra_type.info b/drupal-dev/modules/search/tests/search_extra_type.info new file mode 100644 index 0000000..d4296c8 --- /dev/null +++ b/drupal-dev/modules/search/tests/search_extra_type.info @@ -0,0 +1,12 @@ +name = "Test search type" +description = "Support module for search module testing." +package = Testing +version = VERSION +core = 7.x +hidden = TRUE + +; Information added by Drupal.org packaging script on 2014-01-15 +version = "7.26" +project = "drupal" +datestamp = "1389815930" + diff --git a/drupal-dev/modules/search/tests/search_extra_type.module b/drupal-dev/modules/search/tests/search_extra_type.module new file mode 100644 index 0000000..80c050c --- /dev/null +++ b/drupal-dev/modules/search/tests/search_extra_type.module @@ -0,0 +1,69 @@ + 'Dummy search type', + 'path' => 'dummy_path', + 'conditions_callback' => 'search_extra_type_conditions', + ); +} + +/** + * Test conditions callback for hook_search_info(). + */ +function search_extra_type_conditions() { + $conditions = array(); + + if (!empty($_REQUEST['search_conditions'])) { + $conditions['search_conditions'] = $_REQUEST['search_conditions']; + } + return $conditions; +} + +/** + * Implements hook_search_execute(). + * + * This is a dummy search, so when search "executes", we just return a dummy + * result containing the keywords and a list of conditions. + */ +function search_extra_type_search_execute($keys = NULL, $conditions = NULL) { + if (!$keys) { + $keys = ''; + } + return array( + array( + 'link' => url('node'), + 'type' => 'Dummy result type', + 'title' => 'Dummy title', + 'snippet' => "Dummy search snippet to display. Keywords: {$keys}\n\nConditions: " . print_r($conditions, TRUE), + ), + ); +} + +/** + * Implements hook_search_page(). + * + * Adds some text to the search page so we can verify that it runs. + */ +function search_extra_type_search_page($results) { + $output['prefix']['#markup'] = '

    Test page text is here

      '; + + foreach ($results as $entry) { + $output[] = array( + '#theme' => 'search_result', + '#result' => $entry, + '#module' => 'search_extra_type', + ); + } + $output['suffix']['#markup'] = '
    ' . theme('pager'); + + return $output; +} diff --git a/drupal-dev/modules/shortcut/shortcut-rtl.css b/drupal-dev/modules/shortcut/shortcut-rtl.css new file mode 100644 index 0000000..5dec957 --- /dev/null +++ b/drupal-dev/modules/shortcut/shortcut-rtl.css @@ -0,0 +1,48 @@ + +div#toolbar a#edit-shortcuts { + position: absolute; + left: 0; + top: 0; + padding: 5px 5px 5px 10px; +} +div#toolbar div.toolbar-shortcuts ul { + float: none; + margin-right: 5px; + margin-left: 10em; +} +div#toolbar div.toolbar-shortcuts ul li a { + margin-left: 5px; + margin-right: 0; + padding: 0 5px; +} +div#toolbar div.toolbar-shortcuts span.icon { + float: right; +} +div.add-or-remove-shortcuts a span.icon { + float: right; + margin-right: 8px; + margin-left: 0; +} +div.add-or-remove-shortcuts a span.text { + float: right; + padding-right: 10px; + padding-left: 0; +} +div.add-or-remove-shortcuts a:focus span.text, +div.add-or-remove-shortcuts a:hover span.text { + -moz-border-radius: 5px 0 0 5px; + -webkit-border-top-left-radius: 5px; + -webkit-border-bottom-left-radius: 5px; + border-radius: 5px 0 0 5px; + padding-left: 6px; +} +#shortcut-set-switch .form-item-new { + padding-right: 17px; + padding-left: 0; +} +div.add-shortcut a:hover span.icon { + background-position: 0 -24px; +} +div.remove-shortcut a:hover span.icon { + background-position: -12px -24px; +} diff --git a/drupal-dev/modules/shortcut/shortcut.admin.css b/drupal-dev/modules/shortcut/shortcut.admin.css new file mode 100644 index 0000000..8ca03be --- /dev/null +++ b/drupal-dev/modules/shortcut/shortcut.admin.css @@ -0,0 +1,8 @@ + +.shortcut-slot-hidden { + display: none; +} + +div.form-item-set div.form-item-new { + display: inline; +} diff --git a/drupal-dev/modules/shortcut/shortcut.admin.inc b/drupal-dev/modules/shortcut/shortcut.admin.inc new file mode 100644 index 0000000..2e8ddb4 --- /dev/null +++ b/drupal-dev/modules/shortcut/shortcut.admin.inc @@ -0,0 +1,788 @@ + $set) { + $options[$name] = check_plain($set->title); + } + + // Only administrators can add shortcut sets. + $add_access = user_access('administer shortcuts'); + if ($add_access) { + $options['new'] = t('New set'); + } + + if (count($options) > 1) { + $form['account'] = array( + '#type' => 'value', + '#value' => $account, + ); + + $form['set'] = array( + '#type' => 'radios', + '#title' => $user->uid == $account->uid ? t('Choose a set of shortcuts to use') : t('Choose a set of shortcuts for this user'), + '#options' => $options, + '#default_value' => $current_set->set_name, + ); + + $form['new'] = array( + '#type' => 'textfield', + '#title' => t('Name'), + '#title_display' => 'invisible', + '#description' => t('The new set is created by copying items from your default shortcut set.'), + '#access' => $add_access, + ); + + if ($user->uid != $account->uid) { + $default_set = shortcut_default_set($account); + $form['new']['#description'] = t('The new set is created by copying items from the %default set.', array('%default' => $default_set->title)); + } + + $form['#attached'] = array( + 'css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.css'), + 'js' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.js'), + ); + + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Change set'), + ); + } + else { + // There is only 1 option, so output a message in the $form array. + $form['info'] = array( + '#markup' => '

    ' . t('You are currently using the %set-name shortcut set.', array('%set-name' => $current_set->title)) . '

    ', + ); + } + + return $form; +} + +/** + * Validation handler for shortcut_set_switch(). + */ +function shortcut_set_switch_validate($form, &$form_state) { + if ($form_state['values']['set'] == 'new') { + // Check to prevent creating a shortcut set with an empty title. + if (trim($form_state['values']['new']) == '') { + form_set_error('new', t('The new set name is required.')); + } + // Check to prevent a duplicate title. + if (shortcut_set_title_exists($form_state['values']['new'])) { + form_set_error('new', t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state['values']['new']))); + } + } +} + +/** + * Submit handler for shortcut_set_switch(). + */ +function shortcut_set_switch_submit($form, &$form_state) { + global $user; + $account = $form_state['values']['account']; + + if ($form_state['values']['set'] == 'new') { + // Save a new shortcut set with links copied from the user's default set. + $default_set = shortcut_default_set($account); + $set = (object) array( + 'title' => $form_state['values']['new'], + 'links' => menu_links_clone($default_set->links), + ); + shortcut_set_save($set); + $replacements = array( + '%user' => $account->name, + '%set_name' => $set->title, + '@switch-url' => url(current_path()), + ); + if ($account->uid == $user->uid) { + // Only administrators can create new shortcut sets, so we know they have + // access to switch back. + drupal_set_message(t('You are now using the new %set_name shortcut set. You can edit it from this page or switch back to a different one.', $replacements)); + } + else { + drupal_set_message(t('%user is now using a new shortcut set called %set_name. You can edit it from this page.', $replacements)); + } + $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $set->set_name; + } + else { + // Switch to a different shortcut set. + $set = shortcut_set_load($form_state['values']['set']); + $replacements = array( + '%user' => $account->name, + '%set_name' => $set->title, + ); + drupal_set_message($account->uid == $user->uid ? t('You are now using the %set_name shortcut set.', $replacements) : t('%user is now using the %set_name shortcut set.', $replacements)); + } + + // Assign the shortcut set to the provided user account. + shortcut_set_assign_user($set, $account); +} + +/** + * Menu page callback: builds the page for administering shortcut sets. + */ +function shortcut_set_admin() { + $shortcut_sets = shortcut_sets(); + $header = array(t('Name'), array('data' => t('Operations'), 'colspan' => 4)); + + $rows = array(); + foreach ($shortcut_sets as $set) { + $row = array( + check_plain($set->title), + l(t('list links'), "admin/config/user-interface/shortcut/$set->set_name"), + l(t('edit set name'), "admin/config/user-interface/shortcut/$set->set_name/edit"), + ); + if (shortcut_set_delete_access($set)) { + $row[] = l(t('delete set'), "admin/config/user-interface/shortcut/$set->set_name/delete"); + } + else { + $row[] = ''; + } + + $rows[] = $row; + } + + return theme('table', array('header' => $header, 'rows' => $rows)); +} + +/** + * Form callback: builds the form for adding a shortcut set. + * + * @param $form + * An associative array containing the structure of the form. + * @param $form_state + * An associative array containing the current state of the form. + * + * @return + * An array representing the form definition. + * + * @ingroup forms + * @see shortcut_set_add_form_validate() + * @see shortcut_set_add_form_submit() + */ +function shortcut_set_add_form($form, &$form_state) { + $form['new'] = array( + '#type' => 'textfield', + '#title' => t('Set name'), + '#description' => t('The new set is created by copying items from your default shortcut set.'), + '#required' => TRUE, + ); + + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Create new set'), + ); + + return $form; +} + +/** + * Validation handler for shortcut_set_add_form(). + */ +function shortcut_set_add_form_validate($form, &$form_state) { + // Check to prevent a duplicate title. + if (shortcut_set_title_exists($form_state['values']['new'])) { + form_set_error('new', t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state['values']['new']))); + } +} + +/** + * Submit handler for shortcut_set_add_form(). + */ +function shortcut_set_add_form_submit($form, &$form_state) { + // Save a new shortcut set with links copied from the user's default set. + $default_set = shortcut_default_set(); + $set = (object) array( + 'title' => $form_state['values']['new'], + 'links' => menu_links_clone($default_set->links), + ); + shortcut_set_save($set); + drupal_set_message(t('The %set_name shortcut set has been created. You can edit it from this page.', array('%set_name' => $set->title))); + $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $set->set_name; +} + +/** + * Form callback: builds the form for customizing shortcut sets. + * + * @param $form + * An associative array containing the structure of the form. + * @param $form_state + * An associative array containing the current state of the form. + * @param $shortcut_set + * An object representing the shortcut set which is being edited. + * + * @return + * An array representing the form definition. + * + * @ingroup forms + * @see shortcut_set_customize_submit() + */ +function shortcut_set_customize($form, &$form_state, $shortcut_set) { + $form['#shortcut_set_name'] = $shortcut_set->set_name; + $form['shortcuts'] = array( + '#tree' => TRUE, + '#weight' => -20, + 'enabled' => array(), + 'disabled' => array(), + ); + + foreach ($shortcut_set->links as $link) { + $mlid = $link['mlid']; + $status = $link['hidden'] ? 'disabled' : 'enabled'; + $form['shortcuts'][$status][$mlid]['name']['#markup'] = l($link['link_title'], $link['link_path']); + $form['shortcuts'][$status][$mlid]['weight'] = array( + '#type' => 'weight', + '#title' => t('Weight'), + '#delta' => 50, + '#default_value' => $link['weight'], + '#attributes' => array('class' => array('shortcut-weight')), + ); + $form['shortcuts'][$status][$mlid]['status'] = array( + '#type' => 'select', + '#title' => t('Status'), + '#options' => array('disabled' => t('Disabled'), 'enabled' => t('Enabled')), + '#default_value' => $status, + '#attributes' => array('class' => array('shortcut-status-select')), + ); + + $form['shortcuts'][$status][$mlid]['edit']['#markup'] = l(t('edit'), 'admin/config/user-interface/shortcut/link/' . $mlid); + $form['shortcuts'][$status][$mlid]['delete']['#markup'] = l(t('delete'), 'admin/config/user-interface/shortcut/link/' . $mlid . '/delete'); + } + + $form['#attached'] = array( + 'css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.css'), + 'js' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.js'), + ); + + $form['actions'] = array( + '#type' => 'actions', + '#access' => !empty($shortcut_set->links), + ); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Save changes'), + ); + + return $form; +} + +/** + * Submit handler for shortcut_set_customize(). + */ +function shortcut_set_customize_submit($form, &$form_state) { + foreach ($form_state['values']['shortcuts'] as $group => $links) { + foreach ($links as $mlid => $data) { + $link = menu_link_load($mlid); + $link['hidden'] = $data['status'] == 'enabled' ? 0 : 1; + $link['weight'] = $data['weight']; + menu_link_save($link); + } + } + drupal_set_message(t('The shortcut set has been updated.')); +} + +/** + * Returns HTML for a shortcut set customization form. + * + * @param $variables + * An associative array containing: + * - form: A render element representing the form. + * + * @see shortcut_set_customize() + * @ingroup themeable + */ +function theme_shortcut_set_customize($variables) { + $form = $variables['form']; + $map = array('disabled' => t('Disabled'), 'enabled' => t('Enabled')); + $shortcuts_by_status = array( + 'enabled' => element_children($form['shortcuts']['enabled']), + 'disabled' => element_children($form['shortcuts']['disabled']), + ); + // Do not add any rows to the table if there are no shortcuts to display. + $statuses = empty($shortcuts_by_status['enabled']) && empty($shortcuts_by_status['disabled']) ? array() : array_keys($shortcuts_by_status); + + $rows = array(); + foreach ($statuses as $status) { + drupal_add_tabledrag('shortcuts', 'match', 'sibling', 'shortcut-status-select'); + drupal_add_tabledrag('shortcuts', 'order', 'sibling', 'shortcut-weight'); + $rows[] = array( + 'data' => array(array( + 'colspan' => 5, + 'data' => '' . $map[$status] . '', + )), + 'class' => array('shortcut-status', 'shortcut-status-' . $status), + ); + + foreach ($shortcuts_by_status[$status] as $key) { + $shortcut = &$form['shortcuts'][$status][$key]; + $row = array(); + $row[] = drupal_render($shortcut['name']); + $row[] = drupal_render($shortcut['weight']); + $row[] = drupal_render($shortcut['status']); + $row[] = drupal_render($shortcut['edit']); + $row[] = drupal_render($shortcut['delete']); + $rows[] = array( + 'data' => $row, + 'class' => array('draggable'), + ); + } + + if ($status == 'enabled') { + for ($i = 0; $i < shortcut_max_slots(); $i++) { + $rows['empty-' . $i] = array( + 'data' => array(array( + 'colspan' => 5, + 'data' => '' . t('Empty') . '', + )), + 'class' => array('shortcut-slot-empty'), + ); + } + $count_shortcuts = count($shortcuts_by_status[$status]); + if (!empty($count_shortcuts)) { + for ($i = 0; $i < min($count_shortcuts, shortcut_max_slots()); $i++) { + $rows['empty-' . $i]['class'][] = 'shortcut-slot-hidden'; + } + } + } + } + + $header = array(t('Name'), t('Weight'), t('Status'), array('data' => t('Operations'), 'colspan' => 2)); + $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'shortcuts'), 'empty' => t('No shortcuts available. Add a shortcut.', array('@link' => url('admin/config/user-interface/shortcut/' . $form['#shortcut_set_name'] . '/add-link'))))); + $output .= drupal_render($form['actions']); + $output = drupal_render_children($form) . $output; + return $output; +} + +/** + * Form callback: builds the form for adding a new shortcut link. + * + * @param $form + * An associative array containing the structure of the form. + * @param $form_state + * An associative array containing the current state of the form. + * @param $shortcut_set + * An object representing the shortcut set to which the link will be added. + * + * @return + * An array representing the form definition. + * + * @ingroup forms + * @see shortcut_link_edit_validate() + * @see shortcut_link_add_submit() + */ +function shortcut_link_add($form, &$form_state, $shortcut_set) { + drupal_set_title(t('Add new shortcut')); + $form['shortcut_set'] = array( + '#type' => 'value', + '#value' => $shortcut_set, + ); + $form += _shortcut_link_form_elements(); + return $form; +} + +/** + * Form callback: builds the form for editing a shortcut link. + * + * @param $form + * An associative array containing the structure of the form. + * @param $form_state + * An associative array containing the current state of the form. + * @param $shortcut_link + * An array representing the link that is being edited. + * + * @return + * An array representing the form definition. + * + * @ingroup forms + * @see shortcut_link_edit_validate() + * @see shortcut_link_edit_submit() + */ +function shortcut_link_edit($form, &$form_state, $shortcut_link) { + drupal_set_title(t('Editing @shortcut', array('@shortcut' => $shortcut_link['link_title']))); + $form['original_shortcut_link'] = array( + '#type' => 'value', + '#value' => $shortcut_link, + ); + $form += _shortcut_link_form_elements($shortcut_link); + return $form; +} + +/** + * Helper function for building a form for adding or editing shortcut links. + * + * @param $shortcut_link + * (optional) An array representing the shortcut link that will be edited. If + * not provided, a new link will be created. + * + * @return + * An array of form elements. + */ +function _shortcut_link_form_elements($shortcut_link = NULL) { + if (!isset($shortcut_link)) { + $shortcut_link = array( + 'link_title' => '', + 'link_path' => '' + ); + } + else { + $shortcut_link['link_path'] = ($shortcut_link['link_path'] == '') ? '' : drupal_get_path_alias($shortcut_link['link_path']); + } + + $form['shortcut_link']['#tree'] = TRUE; + $form['shortcut_link']['link_title'] = array( + '#type' => 'textfield', + '#title' => t('Name'), + '#description' => t('The name of the shortcut.'), + '#size' => 40, + '#maxlength' => 255, + '#default_value' => $shortcut_link['link_title'], + '#required' => TRUE, + ); + + $form['shortcut_link']['link_path'] = array( + '#type' => 'textfield', + '#title' => t('Path'), + '#description' => t('The path to the shortcut.'), + '#size' => 40, + '#maxlength' => 255, + '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), + '#default_value' => $shortcut_link['link_path'], + ); + + $form['#validate'][] = 'shortcut_link_edit_validate'; + + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Save'), + ); + + return $form; +} + +/** + * Validation handler for the shortcut link add and edit forms. + */ +function shortcut_link_edit_validate($form, &$form_state) { + if (!shortcut_valid_link($form_state['values']['shortcut_link']['link_path'])) { + form_set_error('shortcut_link][link_path', t('The link must correspond to a valid path on the site.')); + } +} + +/** + * Submit handler for shortcut_link_edit(). + */ +function shortcut_link_edit_submit($form, &$form_state) { + // Normalize the path in case it is an alias. + $shortcut_path = drupal_get_normal_path($form_state['values']['shortcut_link']['link_path']); + if (empty($shortcut_path)) { + $shortcut_path = ''; + } + $form_state['values']['shortcut_link']['link_path'] = $shortcut_path; + + $shortcut_link = array_merge($form_state['values']['original_shortcut_link'], $form_state['values']['shortcut_link']); + + menu_link_save($shortcut_link); + $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name']; + drupal_set_message(t('The shortcut %link has been updated.', array('%link' => $shortcut_link['link_title']))); +} + +/** + * Submit handler for shortcut_link_add(). + */ +function shortcut_link_add_submit($form, &$form_state) { + // Add the shortcut link to the set. + $shortcut_set = $form_state['values']['shortcut_set']; + $shortcut_link = $form_state['values']['shortcut_link']; + $shortcut_link['menu_name'] = $shortcut_set->set_name; + shortcut_admin_add_link($shortcut_link, $shortcut_set, shortcut_max_slots()); + shortcut_set_save($shortcut_set); + $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name']; + drupal_set_message(t('Added a shortcut for %title.', array('%title' => $shortcut_link['link_title']))); +} + +/** + * Adds a link to the end of a shortcut set, keeping within a prescribed limit. + * + * @param $link + * An array representing a shortcut link. + * @param $shortcut_set + * An object representing the shortcut set which the link will be added to. + * The links in the shortcut set will be re-weighted so that the new link is + * at the end, and some existing links may be disabled (if the $limit + * parameter is provided). + * @param $limit + * (optional) The maximum number of links that are allowed to be enabled for + * this shortcut set. If provided, existing links at the end of the list that + * exceed the limit will be automatically disabled. If not provided, no limit + * will be enforced. + */ +function shortcut_admin_add_link($shortcut_link, &$shortcut_set, $limit = NULL) { + if (isset($limit)) { + // Disable any existing links at the end of the list that would cause the + // limit to be exceeded. Take into account whether or not the new link will + // be enabled and count towards the total. + $number_enabled = !empty($shortcut_link['hidden']) ? 0 : 1; + foreach ($shortcut_set->links as &$link) { + if (!$link['hidden']) { + $number_enabled++; + if ($number_enabled > $limit) { + $link['hidden'] = 1; + } + } + } + } + + // Normalize the path in case it is an alias. + $shortcut_link['link_path'] = drupal_get_normal_path($shortcut_link['link_path']); + if (empty($shortcut_link['link_path'])) { + $shortcut_link['link_path'] = ''; + } + + // Add the link to the end of the list. + $shortcut_set->links[] = $shortcut_link; + shortcut_set_reset_link_weights($shortcut_set); +} + +/** + * Form callback: builds the form for editing the shortcut set name. + * + * @param $form + * An associative array containing the structure of the form. + * @param $form_state + * An associative array containing the current state of the form. + * @param object $shortcut_set + * An object representing the shortcut set, as returned from + * shortcut_set_load(). + * + * @return + * An array representing the form definition. + * + * @ingroup forms + * @see shortcut_set_edit_form_validate() + * @see shortcut_set_edit_form_submit() + */ +function shortcut_set_edit_form($form, &$form_state, $shortcut_set) { + $form['shortcut_set'] = array( + '#type' => 'value', + '#value' => $shortcut_set, + ); + $form['title'] = array( + '#type' => 'textfield', + '#title' => t('Set name'), + '#default_value' => $shortcut_set->title, + '#maxlength' => 255, + '#required' => TRUE, + '#weight' => -5, + ); + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Save'), + '#weight' => 5, + ); + + return $form; +} + +/** + * Validation handler for shortcut_set_edit_form(). + */ +function shortcut_set_edit_form_validate($form, &$form_state) { + // Check to prevent a duplicate title, if the title was edited from its + // original value. + if ($form_state['values']['title'] != $form_state['values']['shortcut_set']->title && shortcut_set_title_exists($form_state['values']['title'])) { + form_set_error('title', t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state['values']['title']))); + } +} + +/** + * Submit handler for shortcut_set_edit_form(). + */ +function shortcut_set_edit_form_submit($form, &$form_state) { + $shortcut_set = $form_state['values']['shortcut_set']; + $shortcut_set->title = $form_state['values']['title']; + shortcut_set_save($shortcut_set); + drupal_set_message(t('Updated set name to %set-name.', array('%set-name' => $shortcut_set->title))); + $form_state['redirect'] = "admin/config/user-interface/shortcut/$shortcut_set->set_name"; +} + +/** + * Form callback: builds the confirmation form for deleting a shortcut set. + * + * @param $form + * An associative array containing the structure of the form. + * @param $form_state + * An associative array containing the current state of the form. + * @param object $shortcut_set + * An object representing the shortcut set, as returned from + * shortcut_set_load(). + * + * @return + * An array representing the form definition. + * + * @ingroup forms + * @see shortcut_set_delete_form_submit() + */ +function shortcut_set_delete_form($form, &$form_state, $shortcut_set) { + $form['shortcut_set'] = array( + '#type' => 'value', + '#value' => $shortcut_set->set_name, + ); + + // Find out how many users are directly assigned to this shortcut set, and + // make a message. + $number = db_query('SELECT COUNT(*) FROM {shortcut_set_users} WHERE set_name = :name', array(':name' => $shortcut_set->set_name))->fetchField(); + $info = ''; + if ($number) { + $info .= '

    ' . format_plural($number, + '1 user has chosen or been assigned to this shortcut set.', + '@count users have chosen or been assigned to this shortcut set.') . '

    '; + } + + // Also, if a module implements hook_shortcut_default_set(), it's possible + // that this set is being used as a default set. Add a message about that too. + if (count(module_implements('shortcut_default_set')) > 0) { + $info .= '

    ' . t('If you have chosen this shortcut set as the default for some or all users, they may also be affected by deleting it.') . '

    '; + } + + $form['info'] = array( + '#markup' => $info, + ); + + return confirm_form( + $form, + t('Are you sure you want to delete the shortcut set %title?', array('%title' => $shortcut_set->title)), + 'admin/config/user-interface/shortcut/' . $shortcut_set->set_name, + t('This action cannot be undone.'), + t('Delete'), + t('Cancel') + ); +} + +/** + * Submit handler for shortcut_set_delete_form(). + */ +function shortcut_set_delete_form_submit($form, &$form_state) { + $shortcut_set = shortcut_set_load($form_state['values']['shortcut_set']); + shortcut_set_delete($shortcut_set); + $form_state['redirect'] = 'admin/config/user-interface/shortcut'; + drupal_set_message(t('The shortcut set %title has been deleted.', array('%title' => $shortcut_set->title))); +} + +/** + * Form callback: builds the confirmation form for deleting a shortcut link. + * + * @param $form + * An associative array containing the structure of the form. + * @param $form_state + * An associative array containing the current state of the form. + * @param $shortcut_link + * An array representing the link that will be deleted. + * + * @return + * An array representing the form definition. + * + * @ingroup forms + * @see shortcut_link_delete_submit() + */ +function shortcut_link_delete($form, &$form_state, $shortcut_link) { + $form['shortcut_link'] = array( + '#type' => 'value', + '#value' => $shortcut_link, + ); + + return confirm_form( + $form, + t('Are you sure you want to delete the shortcut %title?', array('%title' => $shortcut_link['link_title'])), + 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name'], + t('This action cannot be undone.'), + t('Delete'), + t('Cancel') + ); +} + +/** + * Submit handler for shortcut_link_delete_submit(). + */ +function shortcut_link_delete_submit($form, &$form_state) { + $shortcut_link = $form_state['values']['shortcut_link']; + menu_link_delete($shortcut_link['mlid']); + $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name']; + drupal_set_message(t('The shortcut %title has been deleted.', array('%title' => $shortcut_link['link_title']))); +} + +/** + * Menu page callback: creates a new link in the provided shortcut set. + * + * After completion, redirects the user back to where they came from. + * + * @param $shortcut_set + * Returned from shortcut_set_load(). + */ +function shortcut_link_add_inline($shortcut_set) { + if (isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'shortcut-add-link') && shortcut_valid_link($_GET['link'])) { + $item = menu_get_item($_GET['link']); + $title = ($item && $item['title']) ? $item['title'] : $_GET['name']; + $link = array( + 'link_title' => $title, + 'link_path' => $_GET['link'], + ); + shortcut_admin_add_link($link, $shortcut_set, shortcut_max_slots()); + if (shortcut_set_save($shortcut_set)) { + drupal_set_message(t('Added a shortcut for %title.', array('%title' => $link['link_title']))); + } + else { + drupal_set_message(t('Unable to add a shortcut for %title.', array('%title' => $link['link_title']))); + } + drupal_goto(); + } + + return MENU_ACCESS_DENIED; +} diff --git a/drupal-dev/modules/shortcut/shortcut.admin.js b/drupal-dev/modules/shortcut/shortcut.admin.js new file mode 100644 index 0000000..422cc4c --- /dev/null +++ b/drupal-dev/modules/shortcut/shortcut.admin.js @@ -0,0 +1,115 @@ +(function ($) { + +/** + * Handle the concept of a fixed number of slots. + * + * This behavior is dependent on the tableDrag behavior, since it uses the + * objects initialized in that behavior to update the row. + */ +Drupal.behaviors.shortcutDrag = { + attach: function (context, settings) { + if (Drupal.tableDrag) { + var table = $('table#shortcuts'), + visibleLength = 0, + slots = 0, + tableDrag = Drupal.tableDrag.shortcuts; + $('> tbody > tr, > tr', table) + .filter(':visible') + .filter(':odd').filter('.odd') + .removeClass('odd').addClass('even') + .end().end() + .filter(':even').filter('.even') + .removeClass('even').addClass('odd') + .end().end() + .end() + .filter('.shortcut-slot-empty').each(function(index) { + if ($(this).is(':visible')) { + visibleLength++; + } + slots++; + }); + + // Add a handler for when a row is swapped. + tableDrag.row.prototype.onSwap = function (swappedRow) { + var disabledIndex = $(table).find('tr').index($(table).find('tr.shortcut-status-disabled')) - slots - 2, + count = 0; + $(table).find('tr.shortcut-status-enabled').nextAll(':not(.shortcut-slot-empty)').each(function(index) { + if (index < disabledIndex) { + count++; + } + }); + var total = slots - count; + if (total == -1) { + var disabled = $(table).find('tr.shortcut-status-disabled'); + // To maintain the shortcut links limit, we need to move the last + // element from the enabled section to the disabled section. + var changedRow = disabled.prevAll(':not(.shortcut-slot-empty)').not($(this.element)).get(0); + disabled.after(changedRow); + if ($(changedRow).hasClass('draggable')) { + // The dropped element will automatically be marked as changed by + // the tableDrag system. However, the row that swapped with it + // has moved to the "disabled" section, so we need to force its + // status to be disabled and mark it also as changed. + var changedRowObject = new tableDrag.row(changedRow, 'mouse', false, 0, true); + changedRowObject.markChanged(); + tableDrag.rowStatusChange(changedRowObject); + } + } + else if (total != visibleLength) { + if (total > visibleLength) { + // Less slots on screen than needed. + $('.shortcut-slot-empty:hidden:last').show(); + visibleLength++; + } + else { + // More slots on screen than needed. + $('.shortcut-slot-empty:visible:last').hide(); + visibleLength--; + } + } + }; + + // Add a handler so when a row is dropped, update fields dropped into new regions. + tableDrag.onDrop = function () { + tableDrag.rowStatusChange(this.rowObject); + return true; + }; + + tableDrag.rowStatusChange = function (rowObject) { + // Use "status-message" row instead of "status" row because + // "status-{status_name}-message" is less prone to regexp match errors. + var statusRow = $(rowObject.element).prevAll('tr.shortcut-status').get(0); + var statusName = statusRow.className.replace(/([^ ]+[ ]+)*shortcut-status-([^ ]+)([ ]+[^ ]+)*/, '$2'); + var statusField = $('select.shortcut-status-select', rowObject.element); + statusField.val(statusName); + }; + + tableDrag.restripeTable = function () { + // :even and :odd are reversed because jQuery counts from 0 and + // we count from 1, so we're out of sync. + // Match immediate children of the parent element to allow nesting. + $('> tbody > tr:visible, > tr:visible', this.table) + .filter(':odd').filter('.odd') + .removeClass('odd').addClass('even') + .end().end() + .filter(':even').filter('.even') + .removeClass('even').addClass('odd'); + }; + } + } +}; + +/** + * Make it so when you enter text into the "New set" textfield, the + * corresponding radio button gets selected. + */ +Drupal.behaviors.newSet = { + attach: function (context, settings) { + var selectDefault = function() { + $(this).closest('form').find('.form-item-set .form-type-radio:last input').attr('checked', 'checked'); + }; + $('div.form-item-new input').focus(selectDefault).keyup(selectDefault); + } +}; + +})(jQuery); diff --git a/drupal-dev/modules/shortcut/shortcut.api.php b/drupal-dev/modules/shortcut/shortcut.api.php new file mode 100644 index 0000000..717a7c9 --- /dev/null +++ b/drupal-dev/modules/shortcut/shortcut.api.php @@ -0,0 +1,42 @@ +roles)) { + return variable_get('mymodule_shortcut_admin_default_set'); + } +} + +/** + * @} End of "addtogroup hooks". + */ diff --git a/drupal-dev/modules/shortcut/shortcut.css b/drupal-dev/modules/shortcut/shortcut.css new file mode 100644 index 0000000..3afcb94 --- /dev/null +++ b/drupal-dev/modules/shortcut/shortcut.css @@ -0,0 +1,106 @@ +div#toolbar a#edit-shortcuts { + float: right; + padding: 5px 10px 5px 5px; + line-height: 24px; + color: #fefefe; +} +div#toolbar a#edit-shortcuts:focus, +div#toolbar a#edit-shortcuts:hover, +div#toolbar a#edit-shortcuts.active { + color: #fff; + text-decoration: underline; +} + +div#toolbar div.toolbar-shortcuts ul { + padding: 5px 0 2px 0; + height: 28px; + line-height: 24px; + float: left; /* LTR */ + margin-left:5px; /* LTR */ +} + +div#toolbar div.toolbar-shortcuts ul li a { + padding: 0 5px 0 5px; + margin-right: 5px; /* LTR */ + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; +} + +div#toolbar div.toolbar-shortcuts ul li a:focus, +div#toolbar div.toolbar-shortcuts ul li a:hover, +div#toolbar div.toolbar-shortcuts ul li a.active:focus { + background: #555; +} + +div#toolbar div.toolbar-shortcuts ul li a.active:hover, +div#toolbar div.toolbar-shortcuts ul li a.active { + background: #000; +} + +div#toolbar div.toolbar-shortcuts span.icon { + float: left; /* LTR */ + background: #444; + width: 30px; + height: 30px; + margin-right: 5px; /* LTR */ + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; +} + +div.add-or-remove-shortcuts { + padding-top: 5px; +} + +div.add-or-remove-shortcuts a span.icon { + display: block; + width: 12px; + background: transparent url(shortcut.png) no-repeat scroll 0 0; + height: 12px; + float: left; + margin-left:8px; +} + +div.add-shortcut a:focus span.icon, +div.add-shortcut a:hover span.icon { + background-position: 0 -12px; +} +div.remove-shortcut a span.icon { + background-position: -12px 0; +} +div.remove-shortcut a:focus span.icon, +div.remove-shortcut a:hover span.icon { + background-position: -12px -12px; +} + +div.add-or-remove-shortcuts a span.text { + float: left; + padding-left:10px; + display: none; +} + +div.add-or-remove-shortcuts a:focus span.text, +div.add-or-remove-shortcuts a:hover span.text { + font-size: 10px; + line-height: 12px; + color: #fff; + background-color: #5f605b; + display: block; + padding-right: 6px; /* LTR */ + cursor: pointer; + -moz-border-radius: 0 5px 5px 0; /* LTR */ + -webkit-border-top-right-radius: 5px; /* LTR */ + -webkit-border-bottom-right-radius: 5px; /* LTR */ + border-radius: 0 5px 5px 0; /* LTR */ +} + +#shortcut-set-switch .form-type-radios { + padding-bottom: 0; + margin-bottom: 0; +} + +#shortcut-set-switch .form-item-new { + padding-top: 0; + padding-left: 17px; /* LTR */ +} diff --git a/drupal-dev/modules/shortcut/shortcut.info b/drupal-dev/modules/shortcut/shortcut.info new file mode 100644 index 0000000..4b8f7b5 --- /dev/null +++ b/drupal-dev/modules/shortcut/shortcut.info @@ -0,0 +1,13 @@ +name = Shortcut +description = Allows users to manage customizable lists of shortcut links. +package = Core +version = VERSION +core = 7.x +files[] = shortcut.test +configure = admin/config/user-interface/shortcut + +; Information added by Drupal.org packaging script on 2014-01-15 +version = "7.26" +project = "drupal" +datestamp = "1389815930" + diff --git a/drupal-dev/modules/shortcut/shortcut.install b/drupal-dev/modules/shortcut/shortcut.install new file mode 100644 index 0000000..60ee6be --- /dev/null +++ b/drupal-dev/modules/shortcut/shortcut.install @@ -0,0 +1,115 @@ +title = $t('Default'); + $shortcut_set->links = array( + array( + 'link_path' => 'node/add', + 'link_title' => $t('Add content'), + 'weight' => -20, + ), + array( + 'link_path' => 'admin/content', + 'link_title' => $t('Find content'), + 'weight' => -19, + ), + ); + // If Drupal is being installed, rebuild the menu before saving the shortcut + // set, to make sure the links defined above can be correctly saved. (During + // installation, the menu might not have been built at all yet, or it might + // have been built but without the node module's links in it.) + if (drupal_installation_attempted()) { + menu_rebuild(); + } + shortcut_set_save($shortcut_set); +} + +/** + * Implements hook_uninstall(). + */ +function shortcut_uninstall() { + drupal_load('module', 'shortcut'); + // Delete the menu links associated with each shortcut set. + foreach (shortcut_sets() as $shortcut_set) { + menu_delete_links($shortcut_set->set_name); + } +} + +/** + * Implements hook_schema(). + */ +function shortcut_schema() { + $schema['shortcut_set'] = array( + 'description' => 'Stores information about sets of shortcuts links.', + 'fields' => array( + 'set_name' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'default' => '', + 'description' => "Primary Key: The {menu_links}.menu_name under which the set's links are stored.", + ), + 'title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + 'description' => 'The title of the set.', + ), + ), + 'primary key' => array('set_name'), + 'foreign keys' => array( + 'menu_name' => array( + 'table' => 'menu_links', + 'columns' => array('set_name' => 'menu_name'), + ), + ), + ); + + $schema['shortcut_set_users'] = array( + 'description' => 'Maps users to shortcut sets.', + 'fields' => array( + 'uid' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The {users}.uid for this set.', + ), + 'set_name' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'default' => '', + 'description' => "The {shortcut_set}.set_name that will be displayed for this user.", + ), + ), + 'primary key' => array('uid'), + 'indexes' => array( + 'set_name' => array('set_name'), + ), + 'foreign keys' => array( + 'set_user' => array( + 'table' => 'users', + 'columns' => array('uid' => 'uid'), + ), + 'set_name' => array( + 'table' => 'shortcut_set', + 'columns' => array('set_name' => 'set_name'), + ), + ), + ); + + return $schema; +} diff --git a/drupal-dev/modules/shortcut/shortcut.module b/drupal-dev/modules/shortcut/shortcut.module new file mode 100644 index 0000000..2f6db0a --- /dev/null +++ b/drupal-dev/modules/shortcut/shortcut.module @@ -0,0 +1,767 @@ +' . t('About') . ''; + $output .= '

    ' . t('The Shortcut module allows users to create sets of shortcut links to commonly-visited pages of the site. Shortcuts are contained within sets. Each user with Select any shortcut set permission can select a shortcut set created by anyone at the site. For more information, see the online handbook entry for Shortcut module.', array('@shortcut' => 'http://drupal.org/documentation/modules/shortcut/')) . '

    '; + $output .= '

    ' . t('Uses') . '

    '; + $output .= '
    ' . t('Administering shortcuts') . '
    '; + $output .= '
    ' . t('Users with the Administer shortcuts permission can manage shortcut sets and edit the shortcuts within sets from the Shortcuts administration page.', array('@shortcuts' => url('admin/config/user-interface/shortcut'))) . '
    '; + $output .= '
    ' . t('Choosing shortcut sets') . '
    '; + $output .= '
    ' . t('Users with permission to switch shortcut sets can choose a shortcut set to use from the Shortcuts tab of their user account page.') . '
    '; + $output .= '
    ' . t('Adding and removing shortcuts') . '
    '; + $output .= '
    ' . t('The Shortcut module creates an add/remove link for each page on your site; the link lets you add or remove the current page from the currently-enabled set of shortcuts (if your theme displays it and you have permission to edit your shortcut set). The core Seven administration theme displays this link next to the page title, as a small + or - sign. If you click on the + sign, you will add that page to your preferred set of shortcuts. If the page is already part of your shortcut set, the link will be a - sign, and will allow you to remove the current page from your shortcut set.') . '
    '; + $output .= '
    ' . t('Displaying shortcuts') . '
    '; + $output .= '
    ' . t('You can display your shortcuts by enabling the Shortcuts block on the Blocks administration page. Certain administrative modules also display your shortcuts; for example, the core Toolbar module displays them near the top of the page, along with an Edit shortcuts link.', array('@blocks' => url('admin/structure/block'), '@toolbar-help' => url('admin/help/toolbar'))) . '
    '; + $output .= '
    '; + return $output; + + case 'admin/config/user-interface/shortcut': + case 'admin/config/user-interface/shortcut/%': + if (user_access('switch shortcut sets')) { + $output = '

    ' . t('Define which shortcut set you are using on the Shortcuts tab of your account page.', array('@shortcut-link' => url("user/{$user->uid}/shortcuts"))) . '

    '; + return $output; + } + } +} + +/** + * Implements hook_permission(). + */ +function shortcut_permission() { + return array( + 'administer shortcuts' => array( + 'title' => t('Administer shortcuts'), + ), + 'customize shortcut links' => array( + 'title' => t('Edit current shortcut set'), + 'description' => t('Editing the current shortcut set will affect other users if that set has been assigned to or selected by other users. Granting "Select any shortcut set" permission along with this permission will grant permission to edit any shortcut set.'), + ), + 'switch shortcut sets' => array( + 'title' => t('Select any shortcut set'), + 'description' => t('From all shortcut sets, select one to be own active set. Without this permission, an administrator selects shortcut sets for users.'), + ), + ); +} + +/** + * Implements hook_menu(). + */ +function shortcut_menu() { + $items['admin/config/user-interface/shortcut'] = array( + 'title' => 'Shortcuts', + 'description' => 'Add and modify shortcut sets.', + 'page callback' => 'shortcut_set_admin', + 'access arguments' => array('administer shortcuts'), + 'file' => 'shortcut.admin.inc', + ); + $items['admin/config/user-interface/shortcut/add-set'] = array( + 'title' => 'Add shortcut set', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('shortcut_set_add_form'), + 'access arguments' => array('administer shortcuts'), + 'type' => MENU_LOCAL_ACTION, + 'file' => 'shortcut.admin.inc', + ); + $items['admin/config/user-interface/shortcut/%shortcut_set'] = array( + 'title' => 'Edit shortcuts', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('shortcut_set_customize', 4), + 'title callback' => 'shortcut_set_title_callback', + 'title arguments' => array(4), + 'access callback' => 'shortcut_set_edit_access', + 'access arguments' => array(4), + 'file' => 'shortcut.admin.inc', + ); + $items['admin/config/user-interface/shortcut/%shortcut_set/links'] = array( + 'title' => 'List links', + 'type' => MENU_DEFAULT_LOCAL_TASK, + ); + $items['admin/config/user-interface/shortcut/%shortcut_set/edit'] = array( + 'title' => 'Edit set name', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('shortcut_set_edit_form', 4), + 'access callback' => 'shortcut_set_edit_access', + 'access arguments' => array(4), + 'type' => MENU_LOCAL_TASK, + 'file' => 'shortcut.admin.inc', + 'weight' => 10, + ); + $items['admin/config/user-interface/shortcut/%shortcut_set/delete'] = array( + 'title' => 'Delete shortcut set', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('shortcut_set_delete_form', 4), + 'access callback' => 'shortcut_set_delete_access', + 'access arguments' => array(4), + 'file' => 'shortcut.admin.inc', + ); + $items['admin/config/user-interface/shortcut/%shortcut_set/add-link'] = array( + 'title' => 'Add shortcut', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('shortcut_link_add', 4), + 'access callback' => 'shortcut_set_edit_access', + 'access arguments' => array(4), + 'type' => MENU_LOCAL_ACTION, + 'file' => 'shortcut.admin.inc', + ); + $items['admin/config/user-interface/shortcut/%shortcut_set/add-link-inline'] = array( + 'title' => 'Add shortcut', + 'page callback' => 'shortcut_link_add_inline', + 'page arguments' => array(4), + 'access callback' => 'shortcut_set_edit_access', + 'access arguments' => array(4), + 'type' => MENU_CALLBACK, + 'file' => 'shortcut.admin.inc', + ); + $items['admin/config/user-interface/shortcut/link/%menu_link'] = array( + 'title' => 'Edit shortcut', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('shortcut_link_edit', 5), + 'access callback' => 'shortcut_link_access', + 'access arguments' => array(5), + 'file' => 'shortcut.admin.inc', + ); + $items['admin/config/user-interface/shortcut/link/%menu_link/delete'] = array( + 'title' => 'Delete shortcut', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('shortcut_link_delete', 5), + 'access callback' => 'shortcut_link_access', + 'access arguments' => array(5), + 'file' => 'shortcut.admin.inc', + ); + $items['user/%user/shortcuts'] = array( + 'title' => 'Shortcuts', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('shortcut_set_switch', 1), + 'access callback' => 'shortcut_set_switch_access', + 'access arguments' => array(1), + 'type' => MENU_LOCAL_TASK, + 'file' => 'shortcut.admin.inc', + ); + + return $items; +} + +/** + * Implements hook_admin_paths(). + */ +function shortcut_admin_paths() { + $paths = array( + 'user/*/shortcuts' => TRUE, + ); + return $paths; +} + +/** + * Implements hook_theme(). + */ +function shortcut_theme() { + return array( + 'shortcut_set_customize' => array( + 'render element' => 'form', + 'file' => 'shortcut.admin.inc', + ), + ); +} + +/** + * Implements hook_block_info(). + */ +function shortcut_block_info() { + $blocks['shortcuts']['info'] = t('Shortcuts'); + // Shortcut blocks can't be cached because each menu item can have a custom + // access callback. menu.inc manages its own caching. + $blocks['shortcuts']['cache'] = DRUPAL_NO_CACHE; + return $blocks; +} + +/** + * Implements hook_block_view(). + */ +function shortcut_block_view($delta = '') { + if ($delta == 'shortcuts') { + $shortcut_set = shortcut_current_displayed_set(); + $data['subject'] = t('@shortcut_set shortcuts', array('@shortcut_set' => $shortcut_set->title)); + $data['content'] = shortcut_renderable_links($shortcut_set); + return $data; + } +} + +/** + * Access callback for editing a shortcut set. + * + * @param object $shortcut_set + * (optional) The shortcut set to be edited. If not set, the current user's + * shortcut set will be used. + * + * @return + * TRUE if the current user has access to edit the shortcut set, FALSE + * otherwise. + */ +function shortcut_set_edit_access($shortcut_set = NULL) { + // Sufficiently-privileged users can edit their currently displayed shortcut + // set, but not other sets. Shortcut administrators can edit any set. + if (user_access('administer shortcuts')) { + return TRUE; + } + if (user_access('customize shortcut links')) { + return !isset($shortcut_set) || $shortcut_set == shortcut_current_displayed_set(); + } + return FALSE; +} + +/** + * Access callback for deleting a shortcut set. + * + * @param $shortcut_set + * The shortcut set to be deleted. + * + * @return + * TRUE if the current user has access to delete shortcut sets and this is + * not the site-wide default set; FALSE otherwise. + */ +function shortcut_set_delete_access($shortcut_set) { + // Only admins can delete sets. + if (!user_access('administer shortcuts')) { + return FALSE; + } + + // Never let the default shortcut set be deleted. + if ($shortcut_set->set_name == SHORTCUT_DEFAULT_SET_NAME) { + return FALSE; + } + + return TRUE; +} + +/** + * Access callback for switching the shortcut set assigned to a user account. + * + * @param object $account + * (optional) The user account whose shortcuts will be switched. If not set, + * permissions will be checked for switching the logged-in user's own + * shortcut set. + * + * @return + * TRUE if the current user has access to switch the shortcut set of the + * provided account, FALSE otherwise. + */ +function shortcut_set_switch_access($account = NULL) { + global $user; + + if (user_access('administer shortcuts')) { + // Administrators can switch anyone's shortcut set. + return TRUE; + } + + if (!user_access('switch shortcut sets')) { + // The user has no permission to switch anyone's shortcut set. + return FALSE; + } + + if (!isset($account) || $user->uid == $account->uid) { + // Users with the 'switch shortcut sets' permission can switch their own + // shortcuts sets. + return TRUE; + } + + return FALSE; +} + +/** + * Access callback for editing a link in a shortcut set. + */ +function shortcut_link_access($menu_link) { + // The link must belong to a shortcut set that the current user has access + // to edit. + if ($shortcut_set = shortcut_set_load($menu_link['menu_name'])) { + return shortcut_set_edit_access($shortcut_set); + } + return FALSE; +} + +/** + * Loads the data for a shortcut set. + * + * @param $set_name + * The name of the shortcut set to load. + * + * @return object + * If the shortcut set exists, an object containing the following properties: + * - 'set_name': The internal name of the shortcut set. + * - 'title': The title of the shortcut set. + * - 'links': An array of links associated with this shortcut set. + * If the shortcut set does not exist, the function returns FALSE. + */ +function shortcut_set_load($set_name) { + $set = db_select('shortcut_set', 'ss') + ->fields('ss') + ->condition('set_name', $set_name) + ->execute() + ->fetchObject(); + if (!$set) { + return FALSE; + } + $set->links = menu_load_links($set_name); + return $set; +} + +/** + * Saves a shortcut set. + * + * @param $shortcut_set + * An object containing the following properties: + * - 'title': The title of the shortcut set. + * - 'set_name': (optional) The internal name of the shortcut set. If + * omitted, a new shortcut set will be created, and the 'set_name' property + * will be added to the passed-in object. + * - 'links': (optional) An array of menu links to save for the shortcut set. + * Each link is an array containing at least the following keys (which will + * be expanded to fill in other default values after the shortcut set is + * saved): + * - 'link_path': The Drupal path or external path that the link points to. + * - 'link_title': The title of the link. + * Any other keys accepted by menu_link_save() may also be provided. + * + * @return + * A constant which is either SAVED_NEW or SAVED_UPDATED depending on whether + * a new set was created or an existing one was updated. + * + * @see menu_link_save() + */ +function shortcut_set_save(&$shortcut_set) { + // First save the shortcut set itself. + if (isset($shortcut_set->set_name)) { + $return = drupal_write_record('shortcut_set', $shortcut_set, 'set_name'); + } + else { + $shortcut_set->set_name = shortcut_set_get_unique_name(); + $return = drupal_write_record('shortcut_set', $shortcut_set); + } + // If links were provided for the set, save them. + if (isset($shortcut_set->links)) { + foreach ($shortcut_set->links as &$link) { + // Do not specifically associate these links with the shortcut module, + // since other modules may make them editable via the menu system. + // However, we do need to specify the correct menu name. + $link['menu_name'] = $shortcut_set->set_name; + $link['plid'] = 0; + menu_link_save($link); + } + // Make sure that we have a return value, since if the links were updated + // but the shortcut set was not, the call to drupal_write_record() above + // would not return an indication that anything had changed. + if (empty($return)) { + $return = SAVED_UPDATED; + } + } + return $return; +} + +/** + * Deletes a shortcut set. + * + * Note that the default set cannot be deleted. + * + * @param $shortcut_set + * An object representing the shortcut set to delete. + * + * @return + * TRUE if the set was deleted, FALSE otherwise. + */ +function shortcut_set_delete($shortcut_set) { + // Don't allow deletion of the system default shortcut set. + if ($shortcut_set->set_name == SHORTCUT_DEFAULT_SET_NAME) { + return FALSE; + } + + // First, delete any user assignments for this set, so that each of these + // users will go back to using whatever default set applies. + db_delete('shortcut_set_users') + ->condition('set_name', $shortcut_set->set_name) + ->execute(); + + // Next, delete the menu links for this set. + menu_delete_links($shortcut_set->set_name); + + // Finally, delete the set itself. + $deleted = db_delete('shortcut_set') + ->condition('set_name', $shortcut_set->set_name) + ->execute(); + + return (bool) $deleted; +} + +/** + * Resets the link weights in a shortcut set to match their current order. + * + * This function can be used, for example, when a new shortcut link is added to + * the set. If the link is added to the end of the array and this function is + * called, it will force that link to display at the end of the list. + * + * @param object $shortcut_set + * An object representing a shortcut set. The link weights of the passed-in + * object will be reset as described above. + */ +function shortcut_set_reset_link_weights(&$shortcut_set) { + $weight = -50; + foreach ($shortcut_set->links as &$link) { + $link['weight'] = $weight; + $weight++; + } +} + +/** + * Assigns a user to a particular shortcut set. + * + * @param $shortcut_set + * An object representing the shortcut set. + * @param $account + * A user account that will be assigned to use the set. + */ +function shortcut_set_assign_user($shortcut_set, $account) { + db_merge('shortcut_set_users') + ->key(array('uid' => $account->uid)) + ->fields(array('set_name' => $shortcut_set->set_name)) + ->execute(); + drupal_static_reset('shortcut_current_displayed_set'); +} + +/** + * Unassigns a user from any shortcut set they may have been assigned to. + * + * The user will go back to using whatever default set applies. + * + * @param $account + * A user account that will be removed from the shortcut set assignment. + * + * @return + * TRUE if the user was previously assigned to a shortcut set and has been + * successfully removed from it. FALSE if the user was already not assigned + * to any set. + */ +function shortcut_set_unassign_user($account) { + $deleted = db_delete('shortcut_set_users') + ->condition('uid', $account->uid) + ->execute(); + return (bool) $deleted; +} + +/** + * Returns the current displayed shortcut set for the provided user account. + * + * @param $account + * (optional) The user account whose shortcuts will be returned. Defaults to + * the currently logged-in user. + * + * @return + * An object representing the shortcut set that should be displayed to the + * current user. If the user does not have an explicit shortcut set defined, + * the default set is returned. + */ +function shortcut_current_displayed_set($account = NULL) { + $shortcut_sets = &drupal_static(__FUNCTION__, array()); + global $user; + if (!isset($account)) { + $account = $user; + } + // Try to return a shortcut set from the static cache. + if (isset($shortcut_sets[$account->uid])) { + return $shortcut_sets[$account->uid]; + } + // If none was found, try to find a shortcut set that is explicitly assigned + // to this user. + $query = db_select('shortcut_set', 's'); + $query->addField('s', 'set_name'); + $query->join('shortcut_set_users', 'u', 's.set_name = u.set_name'); + $query->condition('u.uid', $account->uid); + $shortcut_set_name = $query->execute()->fetchField(); + if ($shortcut_set_name) { + $shortcut_set = shortcut_set_load($shortcut_set_name); + } + // Otherwise, use the default set. + else { + $shortcut_set = shortcut_default_set($account); + } + + $shortcut_sets[$account->uid] = $shortcut_set; + return $shortcut_set; +} + +/** + * Returns the default shortcut set for a given user account. + * + * @param object $account + * (optional) The user account whose default shortcut set will be returned. + * If not provided, the function will return the currently logged-in user's + * default shortcut set. + * + * @return + * An object representing the default shortcut set. + */ +function shortcut_default_set($account = NULL) { + global $user; + if (!isset($account)) { + $account = $user; + } + + // Allow modules to return a default shortcut set name. Since we can only + // have one, we allow the last module which returns a valid result to take + // precedence. If no module returns a valid set, fall back on the site-wide + // default, which is the lowest-numbered shortcut set. + $suggestions = array_reverse(module_invoke_all('shortcut_default_set', $account)); + $suggestions[] = SHORTCUT_DEFAULT_SET_NAME; + foreach ($suggestions as $name) { + if ($shortcut_set = shortcut_set_load($name)) { + break; + } + } + + return $shortcut_set; +} + +/** + * Returns a unique, machine-readable shortcut set name. + */ +function shortcut_set_get_unique_name() { + // Shortcut sets are numbered sequentially, so we keep trying until we find + // one that is available. For better performance, we start with a number + // equal to one more than the current number of shortcut sets, so that if + // no shortcut sets have been deleted from the database, this will + // automatically give us the correct one. + $number = db_query("SELECT COUNT(*) FROM {shortcut_set}")->fetchField() + 1; + do { + $name = shortcut_set_name($number); + $number++; + } while ($shortcut_set = shortcut_set_load($name)); + return $name; +} + +/** + * Returns the name of a shortcut set, based on a provided number. + * + * All shortcut sets have names like "shortcut-set-N" so that they can be + * matched with a properly-namespaced entry in the {menu_links} table. + * + * @param $number + * A number representing the shortcut set whose name should be retrieved. + * + * @return + * A string representing the expected shortcut name. + */ +function shortcut_set_name($number) { + return "shortcut-set-$number"; +} + +/** + * Returns an array of all shortcut sets, keyed by the set name. + * + * @return + * An array of shortcut sets. Note that only the basic shortcut set + * properties (name and title) are returned by this function, not the list + * of menu links that belong to the set. + */ +function shortcut_sets() { + return db_select('shortcut_set', 'ss') + ->fields('ss') + ->execute() + ->fetchAllAssoc('set_name'); +} + +/** + * Check to see if a shortcut set with the given title already exists. + * + * @param $title + * Human-readable name of the shortcut set to check. + * + * @return + * TRUE if a shortcut set with that title exists; FALSE otherwise. + */ +function shortcut_set_title_exists($title) { + return (bool) db_query_range('SELECT 1 FROM {shortcut_set} WHERE title = :title', 0, 1, array(':title' => $title))->fetchField(); +} + +/** + * Determines if a path corresponds to a valid shortcut link. + * + * @param $path + * The path to the link. + * @return + * TRUE if the shortcut link is valid, FALSE otherwise. Valid links are ones + * that correspond to actual paths on the site. + * + * @see menu_edit_item_validate() + */ +function shortcut_valid_link($path) { + // Do not use URL aliases. + $normal_path = drupal_get_normal_path($path); + if ($path != $normal_path) { + $path = $normal_path; + } + // An empty path is valid too and will be converted to . + return (!url_is_external($path) && menu_get_item($path)) || empty($path) || $path == ''; +} + +/** + * Returns an array of shortcut links, suitable for rendering. + * + * @param $shortcut_set + * (optional) An object representing the set whose links will be displayed. + * If not provided, the user's current set will be displayed. + * @return + * An array of shortcut links, in the format returned by the menu system. + * + * @see menu_tree() + */ +function shortcut_renderable_links($shortcut_set = NULL) { + if (!isset($shortcut_set)) { + $shortcut_set = shortcut_current_displayed_set(); + } + return menu_tree($shortcut_set->set_name); +} + +/** + * Implements hook_preprocess_page(). + */ +function shortcut_preprocess_page(&$variables) { + // Only display the shortcut link if the user has the ability to edit + // shortcuts and if the page's actual content is being shown (for example, + // we do not want to display it on "access denied" or "page not found" + // pages). + if (shortcut_set_edit_access() && ($item = menu_get_item()) && $item['access']) { + $link = $_GET['q']; + $query_parameters = drupal_get_query_parameters(); + if (!empty($query_parameters)) { + $link .= '?' . drupal_http_build_query($query_parameters); + } + $query = array( + 'link' => $link, + 'name' => drupal_get_title(), + ); + $query += drupal_get_destination(); + + $shortcut_set = shortcut_current_displayed_set(); + + // Check if $link is already a shortcut and set $link_mode accordingly. + foreach ($shortcut_set->links as $shortcut) { + if ($link == $shortcut['link_path']) { + $mlid = $shortcut['mlid']; + break; + } + } + $link_mode = isset($mlid) ? "remove" : "add"; + + if ($link_mode == "add") { + $query['token'] = drupal_get_token('shortcut-add-link'); + $link_text = shortcut_set_switch_access() ? t('Add to %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Add to shortcuts'); + $link_path = 'admin/config/user-interface/shortcut/' . $shortcut_set->set_name . '/add-link-inline'; + } + else { + $query['mlid'] = $mlid; + $link_text = shortcut_set_switch_access() ? t('Remove from %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Remove from shortcuts'); + $link_path = 'admin/config/user-interface/shortcut/link/' . $mlid . '/delete'; + } + + if (theme_get_setting('shortcut_module_link')) { + $variables['title_suffix']['add_or_remove_shortcut'] = array( + '#attached' => array('css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.css')), + '#prefix' => '', + ); + } + } +} + +/** + * Implements hook_page_alter(). + */ +function shortcut_page_alter(&$page) { + if (isset($page['page_top']['toolbar'])) { + // If the toolbar is available, add a pre-render function to display the + // current shortcuts in the toolbar drawer. + $page['page_top']['toolbar']['#pre_render'][] = 'shortcut_toolbar_pre_render'; + } +} + +/** + * Pre-render function for adding shortcuts to the toolbar drawer. + */ +function shortcut_toolbar_pre_render($toolbar) { + $links = shortcut_renderable_links(); + $links['#attached'] = array('css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.css')); + $links['#prefix'] = '
    '; + $links['#suffix'] = '
    '; + $shortcut_set = shortcut_current_displayed_set(); + $configure_link = NULL; + if (shortcut_set_edit_access($shortcut_set)) { + $configure_link = array( + '#type' => 'link', + '#title' => t('Edit shortcuts'), + '#href' => 'admin/config/user-interface/shortcut/' . $shortcut_set->set_name, + '#options' => array('attributes' => array('id' => 'edit-shortcuts')), + ); + } + + $drawer = array( + 'shortcuts' => $links, + 'configure' => $configure_link, + ); + + $toolbar['toolbar_drawer'][] = $drawer; + return $toolbar; +} + +/** + * Returns the sanitized title of a shortcut set. + * + * Deprecated. This function was previously used as a menu item title callback + * but has been replaced by shortcut_set_title_callback() (which does not + * sanitize the title, since the menu system does that automatically). In + * Drupal 7, use that function for title callbacks, and call check_plain() + * directly if you need a sanitized title. In Drupal 8, this function will be + * restored as a title callback and therefore will no longer sanitize its + * output. + * + * @param $shortcut_set + * An object representing the shortcut set, as returned by + * shortcut_set_load(). + */ +function shortcut_set_title($shortcut_set) { + return check_plain($shortcut_set->title); +} + +/** + * Returns the title of a shortcut set. + * + * Title callback for the editing pages for shortcut sets. + * + * @param $shortcut_set + * An object representing the shortcut set, as returned by + * shortcut_set_load(). + */ +function shortcut_set_title_callback($shortcut_set) { + return $shortcut_set->title; +} diff --git a/drupal-dev/modules/shortcut/shortcut.png b/drupal-dev/modules/shortcut/shortcut.png new file mode 100644 index 0000000..2924557 Binary files /dev/null and b/drupal-dev/modules/shortcut/shortcut.png differ diff --git a/drupal-dev/modules/shortcut/shortcut.test b/drupal-dev/modules/shortcut/shortcut.test new file mode 100644 index 0000000..2bd9605 --- /dev/null +++ b/drupal-dev/modules/shortcut/shortcut.test @@ -0,0 +1,371 @@ +admin_user = $this->drupalCreateUser(array('access toolbar', 'administer shortcuts', 'view the administration theme', 'create article content', 'create page content', 'access content overview')); + $this->shortcut_user = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets')); + + // Create a node. + $this->node = $this->drupalCreateNode(array('type' => 'article')); + + // Log in as admin and grab the default shortcut set. + $this->drupalLogin($this->admin_user); + $this->set = shortcut_set_load(SHORTCUT_DEFAULT_SET_NAME); + shortcut_set_assign_user($this->set, $this->admin_user); + } + + /** + * Creates a generic shortcut set. + */ + function generateShortcutSet($title = '', $default_links = TRUE) { + $set = new stdClass(); + $set->title = empty($title) ? $this->randomName(10) : $title; + if ($default_links) { + $set->links = array(); + $set->links[] = $this->generateShortcutLink('node/add'); + $set->links[] = $this->generateShortcutLink('admin/content'); + } + shortcut_set_save($set); + + return $set; + } + + /** + * Creates a generic shortcut link. + */ + function generateShortcutLink($path, $title = '') { + $link = array( + 'link_path' => $path, + 'link_title' => !empty($title) ? $title : $this->randomName(10), + ); + + return $link; + } + + /** + * Extracts information from shortcut set links. + * + * @param object $set + * The shortcut set object to extract information from. + * @param string $key + * The array key indicating what information to extract from each link: + * - 'link_path': Extract link paths. + * - 'link_title': Extract link titles. + * - 'mlid': Extract the menu link item ID numbers. + * + * @return array + * Array of the requested information from each link. + */ + function getShortcutInformation($set, $key) { + $info = array(); + foreach ($set->links as $link) { + $info[] = $link[$key]; + } + return $info; + } +} + +/** + * Defines shortcut links test cases. + */ +class ShortcutLinksTestCase extends ShortcutTestCase { + + public static function getInfo() { + return array( + 'name' => 'Shortcut link functionality', + 'description' => 'Create, view, edit, delete, and change shortcut links.', + 'group' => 'Shortcut', + ); + } + + /** + * Tests that creating a shortcut works properly. + */ + function testShortcutLinkAdd() { + $set = $this->set; + + // Create an alias for the node so we can test aliases. + $path = array( + 'source' => 'node/' . $this->node->nid, + 'alias' => $this->randomName(8), + ); + path_save($path); + + // Create some paths to test. + $test_cases = array( + array('path' => ''), + array('path' => 'admin'), + array('path' => 'admin/config/system/site-information'), + array('path' => "node/{$this->node->nid}/edit"), + array('path' => $path['alias']), + ); + + // Check that each new shortcut links where it should. + foreach ($test_cases as $test) { + $title = $this->randomName(10); + $form_data = array( + 'shortcut_link[link_title]' => $title, + 'shortcut_link[link_path]' => $test['path'], + ); + $this->drupalPost('admin/config/user-interface/shortcut/' . $set->set_name . '/add-link', $form_data, t('Save')); + $this->assertResponse(200); + $saved_set = shortcut_set_load($set->set_name); + $paths = $this->getShortcutInformation($saved_set, 'link_path'); + $test_path = empty($test['path']) ? '' : $test['path']; + $this->assertTrue(in_array(drupal_get_normal_path($test_path), $paths), 'Shortcut created: '. $test['path']); + $this->assertLink($title, 0, 'Shortcut link found on the page.'); + } + } + + /** + * Tests that the "add to shortcut" link changes to "remove shortcut". + */ + function testShortcutQuickLink() { + $this->drupalGet($this->set->links[0]['link_path']); + $this->assertRaw(t('Remove from %title shortcuts', array('%title' => $this->set->title)), '"Add to shortcuts" link properly switched to "Remove from shortcuts".'); + } + + /** + * Tests that shortcut links can be renamed. + */ + function testShortcutLinkRename() { + $set = $this->set; + + // Attempt to rename shortcut link. + $new_link_name = $this->randomName(10); + + $this->drupalPost('admin/config/user-interface/shortcut/link/' . $set->links[0]['mlid'], array('shortcut_link[link_title]' => $new_link_name, 'shortcut_link[link_path]' => $set->links[0]['link_path']), t('Save')); + $saved_set = shortcut_set_load($set->set_name); + $titles = $this->getShortcutInformation($saved_set, 'link_title'); + $this->assertTrue(in_array($new_link_name, $titles), 'Shortcut renamed: ' . $new_link_name); + $this->assertLink($new_link_name, 0, 'Renamed shortcut link appears on the page.'); + } + + /** + * Tests that changing the path of a shortcut link works. + */ + function testShortcutLinkChangePath() { + $set = $this->set; + + // Tests changing a shortcut path. + $new_link_path = 'admin/config'; + + $this->drupalPost('admin/config/user-interface/shortcut/link/' . $set->links[0]['mlid'], array('shortcut_link[link_title]' => $set->links[0]['link_title'], 'shortcut_link[link_path]' => $new_link_path), t('Save')); + $saved_set = shortcut_set_load($set->set_name); + $paths = $this->getShortcutInformation($saved_set, 'link_path'); + $this->assertTrue(in_array($new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path); + $this->assertLinkByHref($new_link_path, 0, 'Shortcut with new path appears on the page.'); + } + + /** + * Tests deleting a shortcut link. + */ + function testShortcutLinkDelete() { + $set = $this->set; + + $this->drupalPost('admin/config/user-interface/shortcut/link/' . $set->links[0]['mlid'] . '/delete', array(), 'Delete'); + $saved_set = shortcut_set_load($set->set_name); + $mlids = $this->getShortcutInformation($saved_set, 'mlid'); + $this->assertFalse(in_array($set->links[0]['mlid'], $mlids), 'Successfully deleted a shortcut.'); + } + + /** + * Tests that the add shortcut link is not displayed for 404/403 errors. + * + * Tests that the "Add to shortcuts" link is not displayed on a page not + * found or a page the user does not have access to. + */ + function testNoShortcutLink() { + // Change to a theme that displays shortcuts. + variable_set('theme_default', 'seven'); + + $this->drupalGet('page-that-does-not-exist'); + $this->assertNoRaw('add-shortcut', 'Add to shortcuts link was not shown on a page not found.'); + + // The user does not have access to this path. + $this->drupalGet('admin/modules'); + $this->assertNoRaw('add-shortcut', 'Add to shortcuts link was not shown on a page the user does not have access to.'); + + // Verify that the testing mechanism works by verifying the shortcut + // link appears on admin/content/node. + $this->drupalGet('admin/content/node'); + $this->assertRaw('add-shortcut', 'Add to shortcuts link was shown on a page the user does have access to.'); + } +} + +/** + * Defines shortcut set test cases. + */ +class ShortcutSetsTestCase extends ShortcutTestCase { + + public static function getInfo() { + return array( + 'name' => 'Shortcut set functionality', + 'description' => 'Create, view, edit, delete, and change shortcut sets.', + 'group' => 'Shortcut', + ); + } + + /** + * Tests creating a shortcut set. + */ + function testShortcutSetAdd() { + $new_set = $this->generateShortcutSet($this->randomName(10)); + $sets = shortcut_sets(); + $this->assertTrue(isset($sets[$new_set->set_name]), 'Successfully created a shortcut set.'); + $this->drupalGet('user/' . $this->admin_user->uid . '/shortcuts'); + $this->assertText($new_set->title, 'Generated shortcut set was listed as a choice on the user account page.'); + } + + /** + * Tests switching a user's own shortcut set. + */ + function testShortcutSetSwitchOwn() { + $new_set = $this->generateShortcutSet($this->randomName(10)); + + // Attempt to switch the default shortcut set to the newly created shortcut + // set. + $this->drupalPost('user/' . $this->admin_user->uid . '/shortcuts', array('set' => $new_set->set_name), t('Change set')); + $this->assertResponse(200); + $current_set = shortcut_current_displayed_set($this->admin_user); + $this->assertTrue($new_set->set_name == $current_set->set_name, 'Successfully switched own shortcut set.'); + } + + /** + * Tests switching another user's shortcut set. + */ + function testShortcutSetAssign() { + $new_set = $this->generateShortcutSet($this->randomName(10)); + + shortcut_set_assign_user($new_set, $this->shortcut_user); + $current_set = shortcut_current_displayed_set($this->shortcut_user); + $this->assertTrue($new_set->set_name == $current_set->set_name, "Successfully switched another user's shortcut set."); + } + + /** + * Tests switching a user's shortcut set and creating one at the same time. + */ + function testShortcutSetSwitchCreate() { + $edit = array( + 'set' => 'new', + 'new' => $this->randomName(10), + ); + $this->drupalPost('user/' . $this->admin_user->uid . '/shortcuts', $edit, t('Change set')); + $current_set = shortcut_current_displayed_set($this->admin_user); + $this->assertNotEqual($current_set->set_name, $this->set->set_name, 'A shortcut set can be switched to at the same time as it is created.'); + $this->assertEqual($current_set->title, $edit['new'], 'The new set is correctly assigned to the user.'); + } + + /** + * Tests switching a user's shortcut set without providing a new set name. + */ + function testShortcutSetSwitchNoSetName() { + $edit = array('set' => 'new'); + $this->drupalPost('user/' . $this->admin_user->uid . '/shortcuts', $edit, t('Change set')); + $this->assertText(t('The new set name is required.')); + $current_set = shortcut_current_displayed_set($this->admin_user); + $this->assertEqual($current_set->set_name, $this->set->set_name, 'Attempting to switch to a new shortcut set without providing a set name does not succeed.'); + } + + /** + * Tests that shortcut_set_save() correctly updates existing links. + */ + function testShortcutSetSave() { + $set = $this->set; + $old_mlids = $this->getShortcutInformation($set, 'mlid'); + + $set->links[] = $this->generateShortcutLink('admin', $this->randomName(10)); + shortcut_set_save($set); + $saved_set = shortcut_set_load($set->set_name); + + $new_mlids = $this->getShortcutInformation($saved_set, 'mlid'); + $this->assertTrue(count(array_intersect($old_mlids, $new_mlids)) == count($old_mlids), 'shortcut_set_save() did not inadvertently change existing mlids.'); + } + + /** + * Tests renaming a shortcut set. + */ + function testShortcutSetRename() { + $set = $this->set; + + $new_title = $this->randomName(10); + $this->drupalPost('admin/config/user-interface/shortcut/' . $set->set_name . '/edit', array('title' => $new_title), t('Save')); + $set = shortcut_set_load($set->set_name); + $this->assertTrue($set->title == $new_title, 'Shortcut set has been successfully renamed.'); + } + + /** + * Tests renaming a shortcut set to the same name as another set. + */ + function testShortcutSetRenameAlreadyExists() { + $set = $this->generateShortcutSet($this->randomName(10)); + $existing_title = $this->set->title; + $this->drupalPost('admin/config/user-interface/shortcut/' . $set->set_name . '/edit', array('title' => $existing_title), t('Save')); + $this->assertRaw(t('The shortcut set %name already exists. Choose another name.', array('%name' => $existing_title))); + $set = shortcut_set_load($set->set_name); + $this->assertNotEqual($set->title, $existing_title, format_string('The shortcut set %title cannot be renamed to %new-title because a shortcut set with that title already exists.', array('%title' => $set->title, '%new-title' => $existing_title))); + } + + /** + * Tests unassigning a shortcut set. + */ + function testShortcutSetUnassign() { + $new_set = $this->generateShortcutSet($this->randomName(10)); + + shortcut_set_assign_user($new_set, $this->shortcut_user); + shortcut_set_unassign_user($this->shortcut_user); + $current_set = shortcut_current_displayed_set($this->shortcut_user); + $default_set = shortcut_default_set($this->shortcut_user); + $this->assertTrue($current_set->set_name == $default_set->set_name, "Successfully unassigned another user's shortcut set."); + } + + /** + * Tests deleting a shortcut set. + */ + function testShortcutSetDelete() { + $new_set = $this->generateShortcutSet($this->randomName(10)); + + $this->drupalPost('admin/config/user-interface/shortcut/' . $new_set->set_name . '/delete', array(), t('Delete')); + $sets = shortcut_sets(); + $this->assertFalse(isset($sets[$new_set->set_name]), 'Successfully deleted a shortcut set.'); + } + + /** + * Tests deleting the default shortcut set. + */ + function testShortcutSetDeleteDefault() { + $this->drupalGet('admin/config/user-interface/shortcut/' . SHORTCUT_DEFAULT_SET_NAME . '/delete'); + $this->assertResponse(403); + } +} diff --git a/drupal-dev/modules/simpletest/drupal_web_test_case.php b/drupal-dev/modules/simpletest/drupal_web_test_case.php new file mode 100644 index 0000000..6d0e59a --- /dev/null +++ b/drupal-dev/modules/simpletest/drupal_web_test_case.php @@ -0,0 +1,3706 @@ + 0, + '#fail' => 0, + '#exception' => 0, + '#debug' => 0, + ); + + /** + * Assertions thrown in that test case. + * + * @var Array + */ + protected $assertions = array(); + + /** + * This class is skipped when looking for the source of an assertion. + * + * When displaying which function an assert comes from, it's not too useful + * to see "drupalWebTestCase->drupalLogin()', we would like to see the test + * that called it. So we need to skip the classes defining these helper + * methods. + */ + protected $skipClasses = array(__CLASS__ => TRUE); + + /** + * Flag to indicate whether the test has been set up. + * + * The setUp() method isolates the test from the parent Drupal site by + * creating a random prefix for the database and setting up a clean file + * storage directory. The tearDown() method then cleans up this test + * environment. We must ensure that setUp() has been run. Otherwise, + * tearDown() will act on the parent Drupal site rather than the test + * environment, destroying live data. + */ + protected $setup = FALSE; + + protected $setupDatabasePrefix = FALSE; + + protected $setupEnvironment = FALSE; + + /** + * Constructor for DrupalTestCase. + * + * @param $test_id + * Tests with the same id are reported together. + */ + public function __construct($test_id = NULL) { + $this->testId = $test_id; + } + + /** + * Internal helper: stores the assert. + * + * @param $status + * Can be 'pass', 'fail', 'exception'. + * TRUE is a synonym for 'pass', FALSE for 'fail'. + * @param $message + * The message string. + * @param $group + * Which group this assert belongs to. + * @param $caller + * By default, the assert comes from a function whose name starts with + * 'test'. Instead, you can specify where this assert originates from + * by passing in an associative array as $caller. Key 'file' is + * the name of the source file, 'line' is the line number and 'function' + * is the caller function itself. + */ + protected function assert($status, $message = '', $group = 'Other', array $caller = NULL) { + // Convert boolean status to string status. + if (is_bool($status)) { + $status = $status ? 'pass' : 'fail'; + } + + // Increment summary result counter. + $this->results['#' . $status]++; + + // Get the function information about the call to the assertion method. + if (!$caller) { + $caller = $this->getAssertionCall(); + } + + // Creation assertion array that can be displayed while tests are running. + $this->assertions[] = $assertion = array( + 'test_id' => $this->testId, + 'test_class' => get_class($this), + 'status' => $status, + 'message' => $message, + 'message_group' => $group, + 'function' => $caller['function'], + 'line' => $caller['line'], + 'file' => $caller['file'], + ); + + // Store assertion for display after the test has completed. + try { + $connection = Database::getConnection('default', 'simpletest_original_default'); + } + catch (DatabaseConnectionNotDefinedException $e) { + // If the test was not set up, the simpletest_original_default + // connection does not exist. + $connection = Database::getConnection('default', 'default'); + } + $connection + ->insert('simpletest') + ->fields($assertion) + ->execute(); + + // We do not use a ternary operator here to allow a breakpoint on + // test failure. + if ($status == 'pass') { + return TRUE; + } + else { + return FALSE; + } + } + + /** + * Store an assertion from outside the testing context. + * + * This is useful for inserting assertions that can only be recorded after + * the test case has been destroyed, such as PHP fatal errors. The caller + * information is not automatically gathered since the caller is most likely + * inserting the assertion on behalf of other code. In all other respects + * the method behaves just like DrupalTestCase::assert() in terms of storing + * the assertion. + * + * @return + * Message ID of the stored assertion. + * + * @see DrupalTestCase::assert() + * @see DrupalTestCase::deleteAssert() + */ + public static function insertAssert($test_id, $test_class, $status, $message = '', $group = 'Other', array $caller = array()) { + // Convert boolean status to string status. + if (is_bool($status)) { + $status = $status ? 'pass' : 'fail'; + } + + $caller += array( + 'function' => t('Unknown'), + 'line' => 0, + 'file' => t('Unknown'), + ); + + $assertion = array( + 'test_id' => $test_id, + 'test_class' => $test_class, + 'status' => $status, + 'message' => $message, + 'message_group' => $group, + 'function' => $caller['function'], + 'line' => $caller['line'], + 'file' => $caller['file'], + ); + + return db_insert('simpletest') + ->fields($assertion) + ->execute(); + } + + /** + * Delete an assertion record by message ID. + * + * @param $message_id + * Message ID of the assertion to delete. + * @return + * TRUE if the assertion was deleted, FALSE otherwise. + * + * @see DrupalTestCase::insertAssert() + */ + public static function deleteAssert($message_id) { + return (bool) db_delete('simpletest') + ->condition('message_id', $message_id) + ->execute(); + } + + /** + * Cycles through backtrace until the first non-assertion method is found. + * + * @return + * Array representing the true caller. + */ + protected function getAssertionCall() { + $backtrace = debug_backtrace(); + + // The first element is the call. The second element is the caller. + // We skip calls that occurred in one of the methods of our base classes + // or in an assertion function. + while (($caller = $backtrace[1]) && + ((isset($caller['class']) && isset($this->skipClasses[$caller['class']])) || + substr($caller['function'], 0, 6) == 'assert')) { + // We remove that call. + array_shift($backtrace); + } + + return _drupal_get_last_caller($backtrace); + } + + /** + * Check to see if a value is not false (not an empty string, 0, NULL, or FALSE). + * + * @param $value + * The value on which the assertion is to be done. + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @return + * TRUE if the assertion succeeded, FALSE otherwise. + */ + protected function assertTrue($value, $message = '', $group = 'Other') { + return $this->assert((bool) $value, $message ? $message : t('Value @value is TRUE.', array('@value' => var_export($value, TRUE))), $group); + } + + /** + * Check to see if a value is false (an empty string, 0, NULL, or FALSE). + * + * @param $value + * The value on which the assertion is to be done. + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @return + * TRUE if the assertion succeeded, FALSE otherwise. + */ + protected function assertFalse($value, $message = '', $group = 'Other') { + return $this->assert(!$value, $message ? $message : t('Value @value is FALSE.', array('@value' => var_export($value, TRUE))), $group); + } + + /** + * Check to see if a value is NULL. + * + * @param $value + * The value on which the assertion is to be done. + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @return + * TRUE if the assertion succeeded, FALSE otherwise. + */ + protected function assertNull($value, $message = '', $group = 'Other') { + return $this->assert(!isset($value), $message ? $message : t('Value @value is NULL.', array('@value' => var_export($value, TRUE))), $group); + } + + /** + * Check to see if a value is not NULL. + * + * @param $value + * The value on which the assertion is to be done. + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @return + * TRUE if the assertion succeeded, FALSE otherwise. + */ + protected function assertNotNull($value, $message = '', $group = 'Other') { + return $this->assert(isset($value), $message ? $message : t('Value @value is not NULL.', array('@value' => var_export($value, TRUE))), $group); + } + + /** + * Check to see if two values are equal. + * + * @param $first + * The first value to check. + * @param $second + * The second value to check. + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @return + * TRUE if the assertion succeeded, FALSE otherwise. + */ + protected function assertEqual($first, $second, $message = '', $group = 'Other') { + return $this->assert($first == $second, $message ? $message : t('Value @first is equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group); + } + + /** + * Check to see if two values are not equal. + * + * @param $first + * The first value to check. + * @param $second + * The second value to check. + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @return + * TRUE if the assertion succeeded, FALSE otherwise. + */ + protected function assertNotEqual($first, $second, $message = '', $group = 'Other') { + return $this->assert($first != $second, $message ? $message : t('Value @first is not equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group); + } + + /** + * Check to see if two values are identical. + * + * @param $first + * The first value to check. + * @param $second + * The second value to check. + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @return + * TRUE if the assertion succeeded, FALSE otherwise. + */ + protected function assertIdentical($first, $second, $message = '', $group = 'Other') { + return $this->assert($first === $second, $message ? $message : t('Value @first is identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group); + } + + /** + * Check to see if two values are not identical. + * + * @param $first + * The first value to check. + * @param $second + * The second value to check. + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @return + * TRUE if the assertion succeeded, FALSE otherwise. + */ + protected function assertNotIdentical($first, $second, $message = '', $group = 'Other') { + return $this->assert($first !== $second, $message ? $message : t('Value @first is not identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group); + } + + /** + * Fire an assertion that is always positive. + * + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @return + * TRUE. + */ + protected function pass($message = NULL, $group = 'Other') { + return $this->assert(TRUE, $message, $group); + } + + /** + * Fire an assertion that is always negative. + * + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @return + * FALSE. + */ + protected function fail($message = NULL, $group = 'Other') { + return $this->assert(FALSE, $message, $group); + } + + /** + * Fire an error assertion. + * + * @param $message + * The message to display along with the assertion. + * @param $group + * The type of assertion - examples are "Browser", "PHP". + * @param $caller + * The caller of the error. + * @return + * FALSE. + */ + protected function error($message = '', $group = 'Other', array $caller = NULL) { + if ($group == 'User notice') { + // Since 'User notice' is set by trigger_error() which is used for debug + // set the message to a status of 'debug'. + return $this->assert('debug', $message, 'Debug', $caller); + } + + return $this->assert('exception', $message, $group, $caller); + } + + /** + * Logs verbose message in a text file. + * + * The a link to the vebose message will be placed in the test results via + * as a passing assertion with the text '[verbose message]'. + * + * @param $message + * The verbose message to be stored. + * + * @see simpletest_verbose() + */ + protected function verbose($message) { + if ($id = simpletest_verbose($message)) { + $class_safe = str_replace('\\', '_', get_class($this)); + $url = file_create_url($this->originalFileDirectory . '/simpletest/verbose/' . $class_safe . '-' . $id . '.html'); + $this->error(l(t('Verbose message'), $url, array('attributes' => array('target' => '_blank'))), 'User notice'); + } + } + + /** + * Run all tests in this class. + * + * Regardless of whether $methods are passed or not, only method names + * starting with "test" are executed. + * + * @param $methods + * (optional) A list of method names in the test case class to run; e.g., + * array('testFoo', 'testBar'). By default, all methods of the class are + * taken into account, but it can be useful to only run a few selected test + * methods during debugging. + */ + public function run(array $methods = array()) { + // Initialize verbose debugging. + $class = get_class($this); + simpletest_verbose(NULL, variable_get('file_public_path', conf_path() . '/files'), str_replace('\\', '_', $class)); + + // HTTP auth settings (:) for the simpletest browser + // when sending requests to the test site. + $this->httpauth_method = variable_get('simpletest_httpauth_method', CURLAUTH_BASIC); + $username = variable_get('simpletest_httpauth_username', NULL); + $password = variable_get('simpletest_httpauth_password', NULL); + if ($username && $password) { + $this->httpauth_credentials = $username . ':' . $password; + } + + set_error_handler(array($this, 'errorHandler')); + // Iterate through all the methods in this class, unless a specific list of + // methods to run was passed. + $class_methods = get_class_methods($class); + if ($methods) { + $class_methods = array_intersect($class_methods, $methods); + } + foreach ($class_methods as $method) { + // If the current method starts with "test", run it - it's a test. + if (strtolower(substr($method, 0, 4)) == 'test') { + // Insert a fail record. This will be deleted on completion to ensure + // that testing completed. + $method_info = new ReflectionMethod($class, $method); + $caller = array( + 'file' => $method_info->getFileName(), + 'line' => $method_info->getStartLine(), + 'function' => $class . '->' . $method . '()', + ); + $completion_check_id = DrupalTestCase::insertAssert($this->testId, $class, FALSE, t('The test did not complete due to a fatal error.'), 'Completion check', $caller); + $this->setUp(); + if ($this->setup) { + try { + $this->$method(); + // Finish up. + } + catch (Exception $e) { + $this->exceptionHandler($e); + } + $this->tearDown(); + } + else { + $this->fail(t("The test cannot be executed because it has not been set up properly.")); + } + // Remove the completion check record. + DrupalTestCase::deleteAssert($completion_check_id); + } + } + // Clear out the error messages and restore error handler. + drupal_get_messages(); + restore_error_handler(); + } + + /** + * Handle errors during test runs. + * + * Because this is registered in set_error_handler(), it has to be public. + * @see set_error_handler + */ + public function errorHandler($severity, $message, $file = NULL, $line = NULL) { + if ($severity & error_reporting()) { + $error_map = array( + E_STRICT => 'Run-time notice', + E_WARNING => 'Warning', + E_NOTICE => 'Notice', + E_CORE_ERROR => 'Core error', + E_CORE_WARNING => 'Core warning', + E_USER_ERROR => 'User error', + E_USER_WARNING => 'User warning', + E_USER_NOTICE => 'User notice', + E_RECOVERABLE_ERROR => 'Recoverable error', + ); + + // PHP 5.3 adds new error logging constants. Add these conditionally for + // backwards compatibility with PHP 5.2. + if (defined('E_DEPRECATED')) { + $error_map += array( + E_DEPRECATED => 'Deprecated', + E_USER_DEPRECATED => 'User deprecated', + ); + } + + $backtrace = debug_backtrace(); + $this->error($message, $error_map[$severity], _drupal_get_last_caller($backtrace)); + } + return TRUE; + } + + /** + * Handle exceptions. + * + * @see set_exception_handler + */ + protected function exceptionHandler($exception) { + $backtrace = $exception->getTrace(); + // Push on top of the backtrace the call that generated the exception. + array_unshift($backtrace, array( + 'line' => $exception->getLine(), + 'file' => $exception->getFile(), + )); + require_once DRUPAL_ROOT . '/includes/errors.inc'; + // The exception message is run through check_plain() by _drupal_decode_exception(). + $this->error(t('%type: !message in %function (line %line of %file).', _drupal_decode_exception($exception)), 'Uncaught exception', _drupal_get_last_caller($backtrace)); + } + + /** + * Generates a random string of ASCII characters of codes 32 to 126. + * + * The generated string includes alpha-numeric characters and common + * miscellaneous characters. Use this method when testing general input + * where the content is not restricted. + * + * Do not use this method when special characters are not possible (e.g., in + * machine or file names that have already been validated); instead, + * use DrupalWebTestCase::randomName(). + * + * @param $length + * Length of random string to generate. + * + * @return + * Randomly generated string. + * + * @see DrupalWebTestCase::randomName() + */ + public static function randomString($length = 8) { + $str = ''; + for ($i = 0; $i < $length; $i++) { + $str .= chr(mt_rand(32, 126)); + } + return $str; + } + + /** + * Generates a random string containing letters and numbers. + * + * The string will always start with a letter. The letters may be upper or + * lower case. This method is better for restricted inputs that do not + * accept certain characters. For example, when testing input fields that + * require machine readable values (i.e. without spaces and non-standard + * characters) this method is best. + * + * Do not use this method when testing unvalidated user input. Instead, use + * DrupalWebTestCase::randomString(). + * + * @param $length + * Length of random string to generate. + * + * @return + * Randomly generated string. + * + * @see DrupalWebTestCase::randomString() + */ + public static function randomName($length = 8) { + $values = array_merge(range(65, 90), range(97, 122), range(48, 57)); + $max = count($values) - 1; + $str = chr(mt_rand(97, 122)); + for ($i = 1; $i < $length; $i++) { + $str .= chr($values[mt_rand(0, $max)]); + } + return $str; + } + + /** + * Converts a list of possible parameters into a stack of permutations. + * + * Takes a list of parameters containing possible values, and converts all of + * them into a list of items containing every possible permutation. + * + * Example: + * @code + * $parameters = array( + * 'one' => array(0, 1), + * 'two' => array(2, 3), + * ); + * $permutations = DrupalTestCase::generatePermutations($parameters) + * // Result: + * $permutations == array( + * array('one' => 0, 'two' => 2), + * array('one' => 1, 'two' => 2), + * array('one' => 0, 'two' => 3), + * array('one' => 1, 'two' => 3), + * ) + * @endcode + * + * @param $parameters + * An associative array of parameters, keyed by parameter name, and whose + * values are arrays of parameter values. + * + * @return + * A list of permutations, which is an array of arrays. Each inner array + * contains the full list of parameters that have been passed, but with a + * single value only. + */ + public static function generatePermutations($parameters) { + $all_permutations = array(array()); + foreach ($parameters as $parameter => $values) { + $new_permutations = array(); + // Iterate over all values of the parameter. + foreach ($values as $value) { + // Iterate over all existing permutations. + foreach ($all_permutations as $permutation) { + // Add the new parameter value to existing permutations. + $new_permutations[] = $permutation + array($parameter => $value); + } + } + // Replace the old permutations with the new permutations. + $all_permutations = $new_permutations; + } + return $all_permutations; + } +} + +/** + * Test case for Drupal unit tests. + * + * These tests can not access the database nor files. Calling any Drupal + * function that needs the database will throw exceptions. These include + * watchdog(), module_implements(), module_invoke_all() etc. + */ +class DrupalUnitTestCase extends DrupalTestCase { + + /** + * Constructor for DrupalUnitTestCase. + */ + function __construct($test_id = NULL) { + parent::__construct($test_id); + $this->skipClasses[__CLASS__] = TRUE; + } + + /** + * Sets up unit test environment. + * + * Unlike DrupalWebTestCase::setUp(), DrupalUnitTestCase::setUp() does not + * install modules because tests are performed without accessing the database. + * Any required files must be explicitly included by the child class setUp() + * method. + */ + protected function setUp() { + global $conf; + + // Store necessary current values before switching to the test environment. + $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files'); + + // Reset all statics so that test is performed with a clean environment. + drupal_static_reset(); + + // Generate temporary prefixed database to ensure that tests have a clean starting point. + $this->databasePrefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}'); + + // Create test directory. + $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10); + file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); + $conf['file_public_path'] = $public_files_directory; + + // Clone the current connection and replace the current prefix. + $connection_info = Database::getConnectionInfo('default'); + Database::renameConnection('default', 'simpletest_original_default'); + foreach ($connection_info as $target => $value) { + $connection_info[$target]['prefix'] = array( + 'default' => $value['prefix']['default'] . $this->databasePrefix, + ); + } + Database::addConnectionInfo('default', 'default', $connection_info['default']); + + // Set user agent to be consistent with web test case. + $_SERVER['HTTP_USER_AGENT'] = $this->databasePrefix; + + // If locale is enabled then t() will try to access the database and + // subsequently will fail as the database is not accessible. + $module_list = module_list(); + if (isset($module_list['locale'])) { + // Transform the list into the format expected as input to module_list(). + foreach ($module_list as &$module) { + $module = array('filename' => drupal_get_filename('module', $module)); + } + $this->originalModuleList = $module_list; + unset($module_list['locale']); + module_list(TRUE, FALSE, FALSE, $module_list); + } + $this->setup = TRUE; + } + + protected function tearDown() { + global $conf; + + // Get back to the original connection. + Database::removeConnection('default'); + Database::renameConnection('simpletest_original_default', 'default'); + + $conf['file_public_path'] = $this->originalFileDirectory; + // Restore modules if necessary. + if (isset($this->originalModuleList)) { + module_list(TRUE, FALSE, FALSE, $this->originalModuleList); + } + } +} + +/** + * Test case for typical Drupal tests. + */ +class DrupalWebTestCase extends DrupalTestCase { + /** + * The profile to install as a basis for testing. + * + * @var string + */ + protected $profile = 'standard'; + + /** + * The URL currently loaded in the internal browser. + * + * @var string + */ + protected $url; + + /** + * The handle of the current cURL connection. + * + * @var resource + */ + protected $curlHandle; + + /** + * The headers of the page currently loaded in the internal browser. + * + * @var Array + */ + protected $headers; + + /** + * The content of the page currently loaded in the internal browser. + * + * @var string + */ + protected $content; + + /** + * The content of the page currently loaded in the internal browser (plain text version). + * + * @var string + */ + protected $plainTextContent; + + /** + * The value of the Drupal.settings JavaScript variable for the page currently loaded in the internal browser. + * + * @var Array + */ + protected $drupalSettings; + + /** + * The parsed version of the page. + * + * @var SimpleXMLElement + */ + protected $elements = NULL; + + /** + * The current user logged in using the internal browser. + * + * @var bool + */ + protected $loggedInUser = FALSE; + + /** + * The current cookie file used by cURL. + * + * We do not reuse the cookies in further runs, so we do not need a file + * but we still need cookie handling, so we set the jar to NULL. + */ + protected $cookieFile = NULL; + + /** + * Additional cURL options. + * + * DrupalWebTestCase itself never sets this but always obeys what is set. + */ + protected $additionalCurlOptions = array(); + + /** + * The original user, before it was changed to a clean uid = 1 for testing purposes. + * + * @var object + */ + protected $originalUser = NULL; + + /** + * The original shutdown handlers array, before it was cleaned for testing purposes. + * + * @var array + */ + protected $originalShutdownCallbacks = array(); + + /** + * HTTP authentication method + */ + protected $httpauth_method = CURLAUTH_BASIC; + + /** + * HTTP authentication credentials (:). + */ + protected $httpauth_credentials = NULL; + + /** + * The current session name, if available. + */ + protected $session_name = NULL; + + /** + * The current session ID, if available. + */ + protected $session_id = NULL; + + /** + * Whether the files were copied to the test files directory. + */ + protected $generatedTestFiles = FALSE; + + /** + * The number of redirects followed during the handling of a request. + */ + protected $redirect_count; + + /** + * Constructor for DrupalWebTestCase. + */ + function __construct($test_id = NULL) { + parent::__construct($test_id); + $this->skipClasses[__CLASS__] = TRUE; + } + + /** + * Get a node from the database based on its title. + * + * @param $title + * A node title, usually generated by $this->randomName(). + * @param $reset + * (optional) Whether to reset the internal node_load() cache. + * + * @return + * A node object matching $title. + */ + function drupalGetNodeByTitle($title, $reset = FALSE) { + $nodes = node_load_multiple(array(), array('title' => $title), $reset); + // Load the first node returned from the database. + $returned_node = reset($nodes); + return $returned_node; + } + + /** + * Creates a node based on default settings. + * + * @param $settings + * An associative array of settings to change from the defaults, keys are + * node properties, for example 'title' => 'Hello, world!'. + * @return + * Created node object. + */ + protected function drupalCreateNode($settings = array()) { + // Populate defaults array. + $settings += array( + 'body' => array(LANGUAGE_NONE => array(array())), + 'title' => $this->randomName(8), + 'comment' => 2, + 'changed' => REQUEST_TIME, + 'moderate' => 0, + 'promote' => 0, + 'revision' => 1, + 'log' => '', + 'status' => 1, + 'sticky' => 0, + 'type' => 'page', + 'revisions' => NULL, + 'language' => LANGUAGE_NONE, + ); + + // Use the original node's created time for existing nodes. + if (isset($settings['created']) && !isset($settings['date'])) { + $settings['date'] = format_date($settings['created'], 'custom', 'Y-m-d H:i:s O'); + } + + // If the node's user uid is not specified manually, use the currently + // logged in user if available, or else the user running the test. + if (!isset($settings['uid'])) { + if ($this->loggedInUser) { + $settings['uid'] = $this->loggedInUser->uid; + } + else { + global $user; + $settings['uid'] = $user->uid; + } + } + + // Merge body field value and format separately. + $body = array( + 'value' => $this->randomName(32), + 'format' => filter_default_format(), + ); + $settings['body'][$settings['language']][0] += $body; + + $node = (object) $settings; + node_save($node); + + // Small hack to link revisions to our test user. + db_update('node_revision') + ->fields(array('uid' => $node->uid)) + ->condition('vid', $node->vid) + ->execute(); + return $node; + } + + /** + * Creates a custom content type based on default settings. + * + * @param $settings + * An array of settings to change from the defaults. + * Example: 'type' => 'foo'. + * @return + * Created content type. + */ + protected function drupalCreateContentType($settings = array()) { + // Find a non-existent random type name. + do { + $name = strtolower($this->randomName(8)); + } while (node_type_get_type($name)); + + // Populate defaults array. + $defaults = array( + 'type' => $name, + 'name' => $name, + 'base' => 'node_content', + 'description' => '', + 'help' => '', + 'title_label' => 'Title', + 'body_label' => 'Body', + 'has_title' => 1, + 'has_body' => 1, + ); + // Imposed values for a custom type. + $forced = array( + 'orig_type' => '', + 'old_type' => '', + 'module' => 'node', + 'custom' => 1, + 'modified' => 1, + 'locked' => 0, + ); + $type = $forced + $settings + $defaults; + $type = (object) $type; + + $saved_type = node_type_save($type); + node_types_rebuild(); + menu_rebuild(); + node_add_body_field($type); + + $this->assertEqual($saved_type, SAVED_NEW, t('Created content type %type.', array('%type' => $type->type))); + + // Reset permissions so that permissions for this content type are available. + $this->checkPermissions(array(), TRUE); + + return $type; + } + + /** + * Get a list files that can be used in tests. + * + * @param $type + * File type, possible values: 'binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'. + * @param $size + * File size in bytes to match. Please check the tests/files folder. + * @return + * List of files that match filter. + */ + protected function drupalGetTestFiles($type, $size = NULL) { + if (empty($this->generatedTestFiles)) { + // Generate binary test files. + $lines = array(64, 1024); + $count = 0; + foreach ($lines as $line) { + simpletest_generate_file('binary-' . $count++, 64, $line, 'binary'); + } + + // Generate text test files. + $lines = array(16, 256, 1024, 2048, 20480); + $count = 0; + foreach ($lines as $line) { + simpletest_generate_file('text-' . $count++, 64, $line); + } + + // Copy other test files from simpletest. + $original = drupal_get_path('module', 'simpletest') . '/files'; + $files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/'); + foreach ($files as $file) { + file_unmanaged_copy($file->uri, variable_get('file_public_path', conf_path() . '/files')); + } + + $this->generatedTestFiles = TRUE; + } + + $files = array(); + // Make sure type is valid. + if (in_array($type, array('binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'))) { + $files = file_scan_directory('public://', '/' . $type . '\-.*/'); + + // If size is set then remove any files that are not of that size. + if ($size !== NULL) { + foreach ($files as $file) { + $stats = stat($file->uri); + if ($stats['size'] != $size) { + unset($files[$file->uri]); + } + } + } + } + usort($files, array($this, 'drupalCompareFiles')); + return $files; + } + + /** + * Compare two files based on size and file name. + */ + protected function drupalCompareFiles($file1, $file2) { + $compare_size = filesize($file1->uri) - filesize($file2->uri); + if ($compare_size) { + // Sort by file size. + return $compare_size; + } + else { + // The files were the same size, so sort alphabetically. + return strnatcmp($file1->name, $file2->name); + } + } + + /** + * Create a user with a given set of permissions. + * + * @param array $permissions + * Array of permission names to assign to user. Note that the user always + * has the default permissions derived from the "authenticated users" role. + * + * @return object|false + * A fully loaded user object with pass_raw property, or FALSE if account + * creation fails. + */ + protected function drupalCreateUser(array $permissions = array()) { + // Create a role with the given permission set, if any. + $rid = FALSE; + if ($permissions) { + $rid = $this->drupalCreateRole($permissions); + if (!$rid) { + return FALSE; + } + } + + // Create a user assigned to that role. + $edit = array(); + $edit['name'] = $this->randomName(); + $edit['mail'] = $edit['name'] . '@example.com'; + $edit['pass'] = user_password(); + $edit['status'] = 1; + if ($rid) { + $edit['roles'] = array($rid => $rid); + } + + $account = user_save(drupal_anonymous_user(), $edit); + + $this->assertTrue(!empty($account->uid), t('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), t('User login')); + if (empty($account->uid)) { + return FALSE; + } + + // Add the raw password so that we can log in as this user. + $account->pass_raw = $edit['pass']; + return $account; + } + + /** + * Internal helper function; Create a role with specified permissions. + * + * @param $permissions + * Array of permission names to assign to role. + * @param $name + * (optional) String for the name of the role. Defaults to a random string. + * @return + * Role ID of newly created role, or FALSE if role creation failed. + */ + protected function drupalCreateRole(array $permissions, $name = NULL) { + // Generate random name if it was not passed. + if (!$name) { + $name = $this->randomName(); + } + + // Check the all the permissions strings are valid. + if (!$this->checkPermissions($permissions)) { + return FALSE; + } + + // Create new role. + $role = new stdClass(); + $role->name = $name; + user_role_save($role); + user_role_grant_permissions($role->rid, $permissions); + + $this->assertTrue(isset($role->rid), t('Created role of name: @name, id: @rid', array('@name' => $name, '@rid' => (isset($role->rid) ? $role->rid : t('-n/a-')))), t('Role')); + if ($role && !empty($role->rid)) { + $count = db_query('SELECT COUNT(*) FROM {role_permission} WHERE rid = :rid', array(':rid' => $role->rid))->fetchField(); + $this->assertTrue($count == count($permissions), t('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), t('Role')); + return $role->rid; + } + else { + return FALSE; + } + } + + /** + * Check to make sure that the array of permissions are valid. + * + * @param $permissions + * Permissions to check. + * @param $reset + * Reset cached available permissions. + * @return + * TRUE or FALSE depending on whether the permissions are valid. + */ + protected function checkPermissions(array $permissions, $reset = FALSE) { + $available = &drupal_static(__FUNCTION__); + + if (!isset($available) || $reset) { + $available = array_keys(module_invoke_all('permission')); + } + + $valid = TRUE; + foreach ($permissions as $permission) { + if (!in_array($permission, $available)) { + $this->fail(t('Invalid permission %permission.', array('%permission' => $permission)), t('Role')); + $valid = FALSE; + } + } + return $valid; + } + + /** + * Log in a user with the internal browser. + * + * If a user is already logged in, then the current user is logged out before + * logging in the specified user. + * + * Please note that neither the global $user nor the passed-in user object is + * populated with data of the logged in user. If you need full access to the + * user object after logging in, it must be updated manually. If you also need + * access to the plain-text password of the user (set by drupalCreateUser()), + * e.g. to log in the same user again, then it must be re-assigned manually. + * For example: + * @code + * // Create a user. + * $account = $this->drupalCreateUser(array()); + * $this->drupalLogin($account); + * // Load real user object. + * $pass_raw = $account->pass_raw; + * $account = user_load($account->uid); + * $account->pass_raw = $pass_raw; + * @endcode + * + * @param $account + * User object representing the user to log in. + * + * @see drupalCreateUser() + */ + protected function drupalLogin(stdClass $account) { + if ($this->loggedInUser) { + $this->drupalLogout(); + } + + $edit = array( + 'name' => $account->name, + 'pass' => $account->pass_raw + ); + $this->drupalPost('user', $edit, t('Log in')); + + // If a "log out" link appears on the page, it is almost certainly because + // the login was successful. + $pass = $this->assertLink(t('Log out'), 0, t('User %name successfully logged in.', array('%name' => $account->name)), t('User login')); + + if ($pass) { + $this->loggedInUser = $account; + } + } + + /** + * Generate a token for the currently logged in user. + */ + protected function drupalGetToken($value = '') { + $private_key = drupal_get_private_key(); + return drupal_hmac_base64($value, $this->session_id . $private_key); + } + + /* + * Logs a user out of the internal browser, then check the login page to confirm logout. + */ + protected function drupalLogout() { + // Make a request to the logout page, and redirect to the user page, the + // idea being if you were properly logged out you should be seeing a login + // screen. + $this->drupalGet('user/logout'); + $this->drupalGet('user'); + $pass = $this->assertField('name', t('Username field found.'), t('Logout')); + $pass = $pass && $this->assertField('pass', t('Password field found.'), t('Logout')); + + if ($pass) { + $this->loggedInUser = FALSE; + } + } + + /** + * Generates a database prefix for running tests. + * + * The generated database table prefix is used for the Drupal installation + * being performed for the test. It is also used as user agent HTTP header + * value by the cURL-based browser of DrupalWebTestCase, which is sent + * to the Drupal installation of the test. During early Drupal bootstrap, the + * user agent HTTP header is parsed, and if it matches, all database queries + * use the database table prefix that has been generated here. + * + * @see DrupalWebTestCase::curlInitialize() + * @see drupal_valid_test_ua() + * @see DrupalWebTestCase::setUp() + */ + protected function prepareDatabasePrefix() { + $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000); + + // As soon as the database prefix is set, the test might start to execute. + // All assertions as well as the SimpleTest batch operations are associated + // with the testId, so the database prefix has to be associated with it. + db_update('simpletest_test_id') + ->fields(array('last_prefix' => $this->databasePrefix)) + ->condition('test_id', $this->testId) + ->execute(); + } + + /** + * Changes the database connection to the prefixed one. + * + * @see DrupalWebTestCase::setUp() + */ + protected function changeDatabasePrefix() { + if (empty($this->databasePrefix)) { + $this->prepareDatabasePrefix(); + // If $this->prepareDatabasePrefix() failed to work, return without + // setting $this->setupDatabasePrefix to TRUE, so setUp() methods will + // know to bail out. + if (empty($this->databasePrefix)) { + return; + } + } + + // Clone the current connection and replace the current prefix. + $connection_info = Database::getConnectionInfo('default'); + Database::renameConnection('default', 'simpletest_original_default'); + foreach ($connection_info as $target => $value) { + $connection_info[$target]['prefix'] = array( + 'default' => $value['prefix']['default'] . $this->databasePrefix, + ); + } + Database::addConnectionInfo('default', 'default', $connection_info['default']); + + // Indicate the database prefix was set up correctly. + $this->setupDatabasePrefix = TRUE; + } + + /** + * Prepares the current environment for running the test. + * + * Backups various current environment variables and resets them, so they do + * not interfere with the Drupal site installation in which tests are executed + * and can be restored in tearDown(). + * + * Also sets up new resources for the testing environment, such as the public + * filesystem and configuration directories. + * + * @see DrupalWebTestCase::setUp() + * @see DrupalWebTestCase::tearDown() + */ + protected function prepareEnvironment() { + global $user, $language, $conf; + + // Store necessary current values before switching to prefixed database. + $this->originalLanguage = $language; + $this->originalLanguageDefault = variable_get('language_default'); + $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files'); + $this->originalProfile = drupal_get_profile(); + $this->originalCleanUrl = variable_get('clean_url', 0); + $this->originalUser = $user; + + // Set to English to prevent exceptions from utf8_truncate() from t() + // during install if the current language is not 'en'. + // The following array/object conversion is copied from language_default(). + $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''); + + // Save and clean the shutdown callbacks array because it is static cached + // and will be changed by the test run. Otherwise it will contain callbacks + // from both environments and the testing environment will try to call the + // handlers defined by the original one. + $callbacks = &drupal_register_shutdown_function(); + $this->originalShutdownCallbacks = $callbacks; + $callbacks = array(); + + // Create test directory ahead of installation so fatal errors and debug + // information can be logged during installation process. + // Use temporary files directory with the same prefix as the database. + $this->public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10); + $this->private_files_directory = $this->public_files_directory . '/private'; + $this->temp_files_directory = $this->private_files_directory . '/temp'; + + // Create the directories + file_prepare_directory($this->public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); + file_prepare_directory($this->private_files_directory, FILE_CREATE_DIRECTORY); + file_prepare_directory($this->temp_files_directory, FILE_CREATE_DIRECTORY); + $this->generatedTestFiles = FALSE; + + // Log fatal errors. + ini_set('log_errors', 1); + ini_set('error_log', $this->public_files_directory . '/error.log'); + + // Set the test information for use in other parts of Drupal. + $test_info = &$GLOBALS['drupal_test_info']; + $test_info['test_run_id'] = $this->databasePrefix; + $test_info['in_child_site'] = FALSE; + + // Indicate the environment was set up correctly. + $this->setupEnvironment = TRUE; + } + + /** + * Sets up a Drupal site for running functional and integration tests. + * + * Generates a random database prefix and installs Drupal with the specified + * installation profile in DrupalWebTestCase::$profile into the + * prefixed database. Afterwards, installs any additional modules specified by + * the test. + * + * After installation all caches are flushed and several configuration values + * are reset to the values of the parent site executing the test, since the + * default values may be incompatible with the environment in which tests are + * being executed. + * + * @param ... + * List of modules to enable for the duration of the test. This can be + * either a single array or a variable number of string arguments. + * + * @see DrupalWebTestCase::prepareDatabasePrefix() + * @see DrupalWebTestCase::changeDatabasePrefix() + * @see DrupalWebTestCase::prepareEnvironment() + */ + protected function setUp() { + global $user, $language, $conf; + + // Create the database prefix for this test. + $this->prepareDatabasePrefix(); + + // Prepare the environment for running tests. + $this->prepareEnvironment(); + if (!$this->setupEnvironment) { + return FALSE; + } + + // Reset all statics and variables to perform tests in a clean environment. + $conf = array(); + drupal_static_reset(); + + // Change the database prefix. + // All static variables need to be reset before the database prefix is + // changed, since DrupalCacheArray implementations attempt to + // write back to persistent caches when they are destructed. + $this->changeDatabasePrefix(); + if (!$this->setupDatabasePrefix) { + return FALSE; + } + + // Preset the 'install_profile' system variable, so the first call into + // system_rebuild_module_data() (in drupal_install_system()) will register + // the test's profile as a module. Without this, the installation profile of + // the parent site (executing the test) is registered, and the test + // profile's hook_install() and other hook implementations are never invoked. + $conf['install_profile'] = $this->profile; + + // Perform the actual Drupal installation. + include_once DRUPAL_ROOT . '/includes/install.inc'; + drupal_install_system(); + + $this->preloadRegistry(); + + // Set path variables. + variable_set('file_public_path', $this->public_files_directory); + variable_set('file_private_path', $this->private_files_directory); + variable_set('file_temporary_path', $this->temp_files_directory); + + // Set the 'simpletest_parent_profile' variable to add the parent profile's + // search path to the child site's search paths. + // @see drupal_system_listing() + // @todo This may need to be primed like 'install_profile' above. + variable_set('simpletest_parent_profile', $this->originalProfile); + + // Include the testing profile. + variable_set('install_profile', $this->profile); + $profile_details = install_profile_info($this->profile, 'en'); + + // Install the modules specified by the testing profile. + module_enable($profile_details['dependencies'], FALSE); + + // Install modules needed for this test. This could have been passed in as + // either a single array argument or a variable number of string arguments. + // @todo Remove this compatibility layer in Drupal 8, and only accept + // $modules as a single array argument. + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + if ($modules) { + $success = module_enable($modules, TRUE); + $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules)))); + } + + // Run the profile tasks. + $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array( + ':name' => $this->profile, + ))->fetchField(); + if ($install_profile_module_exists) { + module_enable(array($this->profile), FALSE); + } + + // Reset/rebuild all data structures after enabling the modules. + $this->resetAll(); + + // Run cron once in that environment, as install.php does at the end of + // the installation process. + drupal_cron_run(); + + // Ensure that the session is not written to the new environment and replace + // the global $user session with uid 1 from the new test site. + drupal_save_session(FALSE); + // Login as uid 1. + $user = user_load(1); + + // Restore necessary variables. + variable_set('install_task', 'done'); + variable_set('clean_url', $this->originalCleanUrl); + variable_set('site_mail', 'simpletest@example.com'); + variable_set('date_default_timezone', date_default_timezone_get()); + + // Set up English language. + unset($conf['language_default']); + $language = language_default(); + + // Use the test mail class instead of the default mail handler class. + variable_set('mail_system', array('default-system' => 'TestingMailSystem')); + + drupal_set_time_limit($this->timeLimit); + $this->setup = TRUE; + } + + /** + * Preload the registry from the testing site. + * + * This method is called by DrupalWebTestCase::setUp(), and preloads the + * registry from the testing site to cut down on the time it takes to + * set up a clean environment for the current test run. + */ + protected function preloadRegistry() { + // Use two separate queries, each with their own connections: copy the + // {registry} and {registry_file} tables over from the parent installation + // to the child installation. + $original_connection = Database::getConnection('default', 'simpletest_original_default'); + $test_connection = Database::getConnection(); + + foreach (array('registry', 'registry_file') as $table) { + // Find the records from the parent database. + $source_query = $original_connection + ->select($table, array(), array('fetch' => PDO::FETCH_ASSOC)) + ->fields($table); + + $dest_query = $test_connection->insert($table); + + $first = TRUE; + foreach ($source_query->execute() as $row) { + if ($first) { + $dest_query->fields(array_keys($row)); + $first = FALSE; + } + // Insert the records into the child database. + $dest_query->values($row); + } + + $dest_query->execute(); + } + } + + /** + * Reset all data structures after having enabled new modules. + * + * This method is called by DrupalWebTestCase::setUp() after enabling + * the requested modules. It must be called again when additional modules + * are enabled later. + */ + protected function resetAll() { + // Reset all static variables. + drupal_static_reset(); + // Reset the list of enabled modules. + module_list(TRUE); + + // Reset cached schema for new database prefix. This must be done before + // drupal_flush_all_caches() so rebuilds can make use of the schema of + // modules enabled on the cURL side. + drupal_get_schema(NULL, TRUE); + + // Perform rebuilds and flush remaining caches. + drupal_flush_all_caches(); + + // Reload global $conf array and permissions. + $this->refreshVariables(); + $this->checkPermissions(array(), TRUE); + } + + /** + * Refresh the in-memory set of variables. Useful after a page request is made + * that changes a variable in a different thread. + * + * In other words calling a settings page with $this->drupalPost() with a changed + * value would update a variable to reflect that change, but in the thread that + * made the call (thread running the test) the changed variable would not be + * picked up. + * + * This method clears the variables cache and loads a fresh copy from the database + * to ensure that the most up-to-date set of variables is loaded. + */ + protected function refreshVariables() { + global $conf; + cache_clear_all('variables', 'cache_bootstrap'); + $conf = variable_initialize(); + } + + /** + * Delete created files and temporary files directory, delete the tables created by setUp(), + * and reset the database prefix. + */ + protected function tearDown() { + global $user, $language; + + // In case a fatal error occurred that was not in the test process read the + // log to pick up any fatal errors. + simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE); + + $emailCount = count(variable_get('drupal_test_email_collector', array())); + if ($emailCount) { + $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.'); + $this->pass($message, t('E-mail')); + } + + // Delete temporary files directory. + file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10)); + + // Remove all prefixed tables. + $tables = db_find_tables($this->databasePrefix . '%'); + $connection_info = Database::getConnectionInfo('default'); + $tables = db_find_tables($connection_info['default']['prefix']['default'] . '%'); + if (empty($tables)) { + $this->fail('Failed to find test tables to drop.'); + } + $prefix_length = strlen($connection_info['default']['prefix']['default']); + foreach ($tables as $table) { + if (db_drop_table(substr($table, $prefix_length))) { + unset($tables[$table]); + } + } + if (!empty($tables)) { + $this->fail('Failed to drop all prefixed tables.'); + } + + // Get back to the original connection. + Database::removeConnection('default'); + Database::renameConnection('simpletest_original_default', 'default'); + + // Restore original shutdown callbacks array to prevent original + // environment of calling handlers from test run. + $callbacks = &drupal_register_shutdown_function(); + $callbacks = $this->originalShutdownCallbacks; + + // Return the user to the original one. + $user = $this->originalUser; + drupal_save_session(TRUE); + + // Ensure that internal logged in variable and cURL options are reset. + $this->loggedInUser = FALSE; + $this->additionalCurlOptions = array(); + + // Reload module list and implementations to ensure that test module hooks + // aren't called after tests. + module_list(TRUE); + module_implements('', FALSE, TRUE); + + // Reset the Field API. + field_cache_clear(); + + // Rebuild caches. + $this->refreshVariables(); + + // Reset public files directory. + $GLOBALS['conf']['file_public_path'] = $this->originalFileDirectory; + + // Reset language. + $language = $this->originalLanguage; + if ($this->originalLanguageDefault) { + $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault; + } + + // Close the CURL handler. + $this->curlClose(); + } + + /** + * Initializes the cURL connection. + * + * If the simpletest_httpauth_credentials variable is set, this function will + * add HTTP authentication headers. This is necessary for testing sites that + * are protected by login credentials from public access. + * See the description of $curl_options for other options. + */ + protected function curlInitialize() { + global $base_url; + + if (!isset($this->curlHandle)) { + $this->curlHandle = curl_init(); + + // Some versions/configurations of cURL break on a NULL cookie jar, so + // supply a real file. + if (empty($this->cookieFile)) { + $this->cookieFile = $this->public_files_directory . '/cookie.jar'; + } + + $curl_options = array( + CURLOPT_COOKIEJAR => $this->cookieFile, + CURLOPT_URL => $base_url, + CURLOPT_FOLLOWLOCATION => FALSE, + CURLOPT_RETURNTRANSFER => TRUE, + CURLOPT_SSL_VERIFYPEER => FALSE, // Required to make the tests run on HTTPS. + CURLOPT_SSL_VERIFYHOST => FALSE, // Required to make the tests run on HTTPS. + CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'), + CURLOPT_USERAGENT => $this->databasePrefix, + ); + if (isset($this->httpauth_credentials)) { + $curl_options[CURLOPT_HTTPAUTH] = $this->httpauth_method; + $curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials; + } + // curl_setopt_array() returns FALSE if any of the specified options + // cannot be set, and stops processing any further options. + $result = curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options); + if (!$result) { + throw new Exception('One or more cURL options could not be set.'); + } + + // By default, the child session name should be the same as the parent. + $this->session_name = session_name(); + } + // We set the user agent header on each request so as to use the current + // time and a new uniqid. + if (preg_match('/simpletest\d+/', $this->databasePrefix, $matches)) { + curl_setopt($this->curlHandle, CURLOPT_USERAGENT, drupal_generate_test_ua($matches[0])); + } + } + + /** + * Initializes and executes a cURL request. + * + * @param $curl_options + * An associative array of cURL options to set, where the keys are constants + * defined by the cURL library. For a list of valid options, see + * http://www.php.net/manual/function.curl-setopt.php + * @param $redirect + * FALSE if this is an initial request, TRUE if this request is the result + * of a redirect. + * + * @return + * The content returned from the call to curl_exec(). + * + * @see curlInitialize() + */ + protected function curlExec($curl_options, $redirect = FALSE) { + $this->curlInitialize(); + + // cURL incorrectly handles URLs with a fragment by including the + // fragment in the request to the server, causing some web servers + // to reject the request citing "400 - Bad Request". To prevent + // this, we strip the fragment from the request. + // TODO: Remove this for Drupal 8, since fixed in curl 7.20.0. + if (!empty($curl_options[CURLOPT_URL]) && strpos($curl_options[CURLOPT_URL], '#')) { + $original_url = $curl_options[CURLOPT_URL]; + $curl_options[CURLOPT_URL] = strtok($curl_options[CURLOPT_URL], '#'); + } + + $url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL]; + + if (!empty($curl_options[CURLOPT_POST])) { + // This is a fix for the Curl library to prevent Expect: 100-continue + // headers in POST requests, that may cause unexpected HTTP response + // codes from some webservers (like lighttpd that returns a 417 error + // code). It is done by setting an empty "Expect" header field that is + // not overwritten by Curl. + $curl_options[CURLOPT_HTTPHEADER][] = 'Expect:'; + } + curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options); + + if (!$redirect) { + // Reset headers, the session ID and the redirect counter. + $this->session_id = NULL; + $this->headers = array(); + $this->redirect_count = 0; + } + + $content = curl_exec($this->curlHandle); + $status = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE); + + // cURL incorrectly handles URLs with fragments, so instead of + // letting cURL handle redirects we take of them ourselves to + // to prevent fragments being sent to the web server as part + // of the request. + // TODO: Remove this for Drupal 8, since fixed in curl 7.20.0. + if (in_array($status, array(300, 301, 302, 303, 305, 307)) && $this->redirect_count < variable_get('simpletest_maximum_redirects', 5)) { + if ($this->drupalGetHeader('location')) { + $this->redirect_count++; + $curl_options = array(); + $curl_options[CURLOPT_URL] = $this->drupalGetHeader('location'); + $curl_options[CURLOPT_HTTPGET] = TRUE; + return $this->curlExec($curl_options, TRUE); + } + } + + $this->drupalSetContent($content, isset($original_url) ? $original_url : curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL)); + $message_vars = array( + '!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'), + '@url' => isset($original_url) ? $original_url : $url, + '@status' => $status, + '!length' => format_size(strlen($this->drupalGetContent())) + ); + $message = t('!method @url returned @status (!length).', $message_vars); + $this->assertTrue($this->drupalGetContent() !== FALSE, $message, t('Browser')); + return $this->drupalGetContent(); + } + + /** + * Reads headers and registers errors received from the tested site. + * + * @see _drupal_log_error(). + * + * @param $curlHandler + * The cURL handler. + * @param $header + * An header. + */ + protected function curlHeaderCallback($curlHandler, $header) { + // Header fields can be extended over multiple lines by preceding each + // extra line with at least one SP or HT. They should be joined on receive. + // Details are in RFC2616 section 4. + if ($header[0] == ' ' || $header[0] == "\t") { + // Normalize whitespace between chucks. + $this->headers[] = array_pop($this->headers) . ' ' . trim($header); + } + else { + $this->headers[] = $header; + } + + // Errors are being sent via X-Drupal-Assertion-* headers, + // generated by _drupal_log_error() in the exact form required + // by DrupalWebTestCase::error(). + if (preg_match('/^X-Drupal-Assertion-[0-9]+: (.*)$/', $header, $matches)) { + // Call DrupalWebTestCase::error() with the parameters from the header. + call_user_func_array(array(&$this, 'error'), unserialize(urldecode($matches[1]))); + } + + // Save cookies. + if (preg_match('/^Set-Cookie: ([^=]+)=(.+)/', $header, $matches)) { + $name = $matches[1]; + $parts = array_map('trim', explode(';', $matches[2])); + $value = array_shift($parts); + $this->cookies[$name] = array('value' => $value, 'secure' => in_array('secure', $parts)); + if ($name == $this->session_name) { + if ($value != 'deleted') { + $this->session_id = $value; + } + else { + $this->session_id = NULL; + } + } + } + + // This is required by cURL. + return strlen($header); + } + + /** + * Close the cURL handler and unset the handler. + */ + protected function curlClose() { + if (isset($this->curlHandle)) { + curl_close($this->curlHandle); + unset($this->curlHandle); + } + } + + /** + * Parse content returned from curlExec using DOM and SimpleXML. + * + * @return + * A SimpleXMLElement or FALSE on failure. + */ + protected function parse() { + if (!$this->elements) { + // DOM can load HTML soup. But, HTML soup can throw warnings, suppress + // them. + $htmlDom = new DOMDocument(); + @$htmlDom->loadHTML($this->drupalGetContent()); + if ($htmlDom) { + $this->pass(t('Valid HTML found on "@path"', array('@path' => $this->getUrl())), t('Browser')); + // It's much easier to work with simplexml than DOM, luckily enough + // we can just simply import our DOM tree. + $this->elements = simplexml_import_dom($htmlDom); + } + } + if (!$this->elements) { + $this->fail(t('Parsed page successfully.'), t('Browser')); + } + + return $this->elements; + } + + /** + * Retrieves a Drupal path or an absolute path. + * + * @param $path + * Drupal path or URL to load into internal browser + * @param $options + * Options to be forwarded to url(). + * @param $headers + * An array containing additional HTTP request headers, each formatted as + * "name: value". + * @return + * The retrieved HTML string, also available as $this->drupalGetContent() + */ + protected function drupalGet($path, array $options = array(), array $headers = array()) { + $options['absolute'] = TRUE; + + // We re-using a CURL connection here. If that connection still has certain + // options set, it might change the GET into a POST. Make sure we clear out + // previous options. + $out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => $headers)); + $this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up. + + // Replace original page output with new output from redirected page(s). + if ($new = $this->checkForMetaRefresh()) { + $out = $new; + } + $this->verbose('GET request to: ' . $path . + '
    Ending URL: ' . $this->getUrl() . + '
    ' . $out); + return $out; + } + + /** + * Retrieve a Drupal path or an absolute path and JSON decode the result. + */ + protected function drupalGetAJAX($path, array $options = array(), array $headers = array()) { + return drupal_json_decode($this->drupalGet($path, $options, $headers)); + } + + /** + * Execute a POST request on a Drupal page. + * It will be done as usual POST request with SimpleBrowser. + * + * @param $path + * Location of the post form. Either a Drupal path or an absolute path or + * NULL to post to the current page. For multi-stage forms you can set the + * path to NULL and have it post to the last received page. Example: + * + * @code + * // First step in form. + * $edit = array(...); + * $this->drupalPost('some_url', $edit, t('Save')); + * + * // Second step in form. + * $edit = array(...); + * $this->drupalPost(NULL, $edit, t('Save')); + * @endcode + * @param $edit + * Field data in an associative array. Changes the current input fields + * (where possible) to the values indicated. A checkbox can be set to + * TRUE to be checked and FALSE to be unchecked. Note that when a form + * contains file upload fields, other fields cannot start with the '@' + * character. + * + * Multiple select fields can be set using name[] and setting each of the + * possible values. Example: + * @code + * $edit = array(); + * $edit['name[]'] = array('value1', 'value2'); + * @endcode + * @param $submit + * Value of the submit button whose click is to be emulated. For example, + * t('Save'). The processing of the request depends on this value. For + * example, a form may have one button with the value t('Save') and another + * button with the value t('Delete'), and execute different code depending + * on which one is clicked. + * + * This function can also be called to emulate an Ajax submission. In this + * case, this value needs to be an array with the following keys: + * - path: A path to submit the form values to for Ajax-specific processing, + * which is likely different than the $path parameter used for retrieving + * the initial form. Defaults to 'system/ajax'. + * - triggering_element: If the value for the 'path' key is 'system/ajax' or + * another generic Ajax processing path, this needs to be set to the name + * of the element. If the name doesn't identify the element uniquely, then + * this should instead be an array with a single key/value pair, + * corresponding to the element name and value. The callback for the + * generic Ajax processing path uses this to find the #ajax information + * for the element, including which specific callback to use for + * processing the request. + * + * This can also be set to NULL in order to emulate an Internet Explorer + * submission of a form with a single text field, and pressing ENTER in that + * textfield: under these conditions, no button information is added to the + * POST data. + * @param $options + * Options to be forwarded to url(). + * @param $headers + * An array containing additional HTTP request headers, each formatted as + * "name: value". + * @param $form_html_id + * (optional) HTML ID of the form to be submitted. On some pages + * there are many identical forms, so just using the value of the submit + * button is not enough. For example: 'trigger-node-presave-assign-form'. + * Note that this is not the Drupal $form_id, but rather the HTML ID of the + * form, which is typically the same thing but with hyphens replacing the + * underscores. + * @param $extra_post + * (optional) A string of additional data to append to the POST submission. + * This can be used to add POST data for which there are no HTML fields, as + * is done by drupalPostAJAX(). This string is literally appended to the + * POST data, so it must already be urlencoded and contain a leading "&" + * (e.g., "&extra_var1=hello+world&extra_var2=you%26me"). + */ + protected function drupalPost($path, $edit, $submit, array $options = array(), array $headers = array(), $form_html_id = NULL, $extra_post = NULL) { + $submit_matches = FALSE; + $ajax = is_array($submit); + if (isset($path)) { + $this->drupalGet($path, $options); + } + if ($this->parse()) { + $edit_save = $edit; + // Let's iterate over all the forms. + $xpath = "//form"; + if (!empty($form_html_id)) { + $xpath .= "[@id='" . $form_html_id . "']"; + } + $forms = $this->xpath($xpath); + foreach ($forms as $form) { + // We try to set the fields of this form as specified in $edit. + $edit = $edit_save; + $post = array(); + $upload = array(); + $submit_matches = $this->handleForm($post, $edit, $upload, $ajax ? NULL : $submit, $form); + $action = isset($form['action']) ? $this->getAbsoluteUrl((string) $form['action']) : $this->getUrl(); + if ($ajax) { + $action = $this->getAbsoluteUrl(!empty($submit['path']) ? $submit['path'] : 'system/ajax'); + // Ajax callbacks verify the triggering element if necessary, so while + // we may eventually want extra code that verifies it in the + // handleForm() function, it's not currently a requirement. + $submit_matches = TRUE; + } + + // We post only if we managed to handle every field in edit and the + // submit button matches. + if (!$edit && ($submit_matches || !isset($submit))) { + $post_array = $post; + if ($upload) { + // TODO: cURL handles file uploads for us, but the implementation + // is broken. This is a less than elegant workaround. Alternatives + // are being explored at #253506. + foreach ($upload as $key => $file) { + $file = drupal_realpath($file); + if ($file && is_file($file)) { + // Use the new CurlFile class for file uploads when using PHP + // 5.5 or higher. + if (class_exists('CurlFile')) { + $post[$key] = curl_file_create($file); + } + else { + $post[$key] = '@' . $file; + } + } + } + } + else { + foreach ($post as $key => $value) { + // Encode according to application/x-www-form-urlencoded + // Both names and values needs to be urlencoded, according to + // http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1 + $post[$key] = urlencode($key) . '=' . urlencode($value); + } + $post = implode('&', $post) . $extra_post; + } + $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HTTPHEADER => $headers)); + // Ensure that any changes to variables in the other thread are picked up. + $this->refreshVariables(); + + // Replace original page output with new output from redirected page(s). + if ($new = $this->checkForMetaRefresh()) { + $out = $new; + } + $this->verbose('POST request to: ' . $path . + '
    Ending URL: ' . $this->getUrl() . + '
    Fields: ' . highlight_string('' . $out); + return $out; + } + } + // We have not found a form which contained all fields of $edit. + foreach ($edit as $name => $value) { + $this->fail(t('Failed to set field @name to @value', array('@name' => $name, '@value' => $value))); + } + if (!$ajax && isset($submit)) { + $this->assertTrue($submit_matches, t('Found the @submit button', array('@submit' => $submit))); + } + $this->fail(t('Found the requested form fields at @path', array('@path' => $path))); + } + } + + /** + * Execute an Ajax submission. + * + * This executes a POST as ajax.js does. It uses the returned JSON data, an + * array of commands, to update $this->content using equivalent DOM + * manipulation as is used by ajax.js. It also returns the array of commands. + * + * @param $path + * Location of the form containing the Ajax enabled element to test. Can be + * either a Drupal path or an absolute path or NULL to use the current page. + * @param $edit + * Field data in an associative array. Changes the current input fields + * (where possible) to the values indicated. + * @param $triggering_element + * The name of the form element that is responsible for triggering the Ajax + * functionality to test. May be a string or, if the triggering element is + * a button, an associative array where the key is the name of the button + * and the value is the button label. i.e.) array('op' => t('Refresh')). + * @param $ajax_path + * (optional) Override the path set by the Ajax settings of the triggering + * element. In the absence of both the triggering element's Ajax path and + * $ajax_path 'system/ajax' will be used. + * @param $options + * (optional) Options to be forwarded to url(). + * @param $headers + * (optional) An array containing additional HTTP request headers, each + * formatted as "name: value". Forwarded to drupalPost(). + * @param $form_html_id + * (optional) HTML ID of the form to be submitted, use when there is more + * than one identical form on the same page and the value of the triggering + * element is not enough to identify the form. Note this is not the Drupal + * ID of the form but rather the HTML ID of the form. + * @param $ajax_settings + * (optional) An array of Ajax settings which if specified will be used in + * place of the Ajax settings of the triggering element. + * + * @return + * An array of Ajax commands. + * + * @see drupalPost() + * @see ajax.js + */ + protected function drupalPostAJAX($path, $edit, $triggering_element, $ajax_path = NULL, array $options = array(), array $headers = array(), $form_html_id = NULL, $ajax_settings = NULL) { + // Get the content of the initial page prior to calling drupalPost(), since + // drupalPost() replaces $this->content. + if (isset($path)) { + $this->drupalGet($path, $options); + } + $content = $this->content; + $drupal_settings = $this->drupalSettings; + + // Get the Ajax settings bound to the triggering element. + if (!isset($ajax_settings)) { + if (is_array($triggering_element)) { + $xpath = '//*[@name="' . key($triggering_element) . '" and @value="' . current($triggering_element) . '"]'; + } + else { + $xpath = '//*[@name="' . $triggering_element . '"]'; + } + if (isset($form_html_id)) { + $xpath = '//form[@id="' . $form_html_id . '"]' . $xpath; + } + $element = $this->xpath($xpath); + $element_id = (string) $element[0]['id']; + $ajax_settings = $drupal_settings['ajax'][$element_id]; + } + + // Add extra information to the POST data as ajax.js does. + $extra_post = ''; + if (isset($ajax_settings['submit'])) { + foreach ($ajax_settings['submit'] as $key => $value) { + $extra_post .= '&' . urlencode($key) . '=' . urlencode($value); + } + } + foreach ($this->xpath('//*[@id]') as $element) { + $id = (string) $element['id']; + $extra_post .= '&' . urlencode('ajax_html_ids[]') . '=' . urlencode($id); + } + if (isset($drupal_settings['ajaxPageState'])) { + $extra_post .= '&' . urlencode('ajax_page_state[theme]') . '=' . urlencode($drupal_settings['ajaxPageState']['theme']); + $extra_post .= '&' . urlencode('ajax_page_state[theme_token]') . '=' . urlencode($drupal_settings['ajaxPageState']['theme_token']); + foreach ($drupal_settings['ajaxPageState']['css'] as $key => $value) { + $extra_post .= '&' . urlencode("ajax_page_state[css][$key]") . '=1'; + } + foreach ($drupal_settings['ajaxPageState']['js'] as $key => $value) { + $extra_post .= '&' . urlencode("ajax_page_state[js][$key]") . '=1'; + } + } + + // Unless a particular path is specified, use the one specified by the + // Ajax settings, or else 'system/ajax'. + if (!isset($ajax_path)) { + $ajax_path = isset($ajax_settings['url']) ? $ajax_settings['url'] : 'system/ajax'; + } + + // Submit the POST request. + $return = drupal_json_decode($this->drupalPost(NULL, $edit, array('path' => $ajax_path, 'triggering_element' => $triggering_element), $options, $headers, $form_html_id, $extra_post)); + + // Change the page content by applying the returned commands. + if (!empty($ajax_settings) && !empty($return)) { + // ajax.js applies some defaults to the settings object, so do the same + // for what's used by this function. + $ajax_settings += array( + 'method' => 'replaceWith', + ); + // DOM can load HTML soup. But, HTML soup can throw warnings, suppress + // them. + $dom = new DOMDocument(); + @$dom->loadHTML($content); + // XPath allows for finding wrapper nodes better than DOM does. + $xpath = new DOMXPath($dom); + foreach ($return as $command) { + switch ($command['command']) { + case 'settings': + $drupal_settings = drupal_array_merge_deep($drupal_settings, $command['settings']); + break; + + case 'insert': + $wrapperNode = NULL; + // When a command doesn't specify a selector, use the + // #ajax['wrapper'] which is always an HTML ID. + if (!isset($command['selector'])) { + $wrapperNode = $xpath->query('//*[@id="' . $ajax_settings['wrapper'] . '"]')->item(0); + } + // @todo Ajax commands can target any jQuery selector, but these are + // hard to fully emulate with XPath. For now, just handle 'head' + // and 'body', since these are used by ajax_render(). + elseif (in_array($command['selector'], array('head', 'body'))) { + $wrapperNode = $xpath->query('//' . $command['selector'])->item(0); + } + if ($wrapperNode) { + // ajax.js adds an enclosing DIV to work around a Safari bug. + $newDom = new DOMDocument(); + $newDom->loadHTML('
    ' . $command['data'] . '
    '); + $newNode = $dom->importNode($newDom->documentElement->firstChild->firstChild, TRUE); + $method = isset($command['method']) ? $command['method'] : $ajax_settings['method']; + // The "method" is a jQuery DOM manipulation function. Emulate + // each one using PHP's DOMNode API. + switch ($method) { + case 'replaceWith': + $wrapperNode->parentNode->replaceChild($newNode, $wrapperNode); + break; + case 'append': + $wrapperNode->appendChild($newNode); + break; + case 'prepend': + // If no firstChild, insertBefore() falls back to + // appendChild(). + $wrapperNode->insertBefore($newNode, $wrapperNode->firstChild); + break; + case 'before': + $wrapperNode->parentNode->insertBefore($newNode, $wrapperNode); + break; + case 'after': + // If no nextSibling, insertBefore() falls back to + // appendChild(). + $wrapperNode->parentNode->insertBefore($newNode, $wrapperNode->nextSibling); + break; + case 'html': + foreach ($wrapperNode->childNodes as $childNode) { + $wrapperNode->removeChild($childNode); + } + $wrapperNode->appendChild($newNode); + break; + } + } + break; + + // @todo Add suitable implementations for these commands in order to + // have full test coverage of what ajax.js can do. + case 'remove': + break; + case 'changed': + break; + case 'css': + break; + case 'data': + break; + case 'restripe': + break; + } + } + $content = $dom->saveHTML(); + } + $this->drupalSetContent($content); + $this->drupalSetSettings($drupal_settings); + return $return; + } + + /** + * Runs cron in the Drupal installed by Simpletest. + */ + protected function cronRun() { + $this->drupalGet($GLOBALS['base_url'] . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => variable_get('cron_key', 'drupal')))); + } + + /** + * Check for meta refresh tag and if found call drupalGet() recursively. This + * function looks for the http-equiv attribute to be set to "Refresh" + * and is case-sensitive. + * + * @return + * Either the new page content or FALSE. + */ + protected function checkForMetaRefresh() { + if (strpos($this->drupalGetContent(), 'parse()) { + $refresh = $this->xpath('//meta[@http-equiv="Refresh"]'); + if (!empty($refresh)) { + // Parse the content attribute of the meta tag for the format: + // "[delay]: URL=[page_to_redirect_to]". + if (preg_match('/\d+;\s*URL=(?P.*)/i', $refresh[0]['content'], $match)) { + return $this->drupalGet($this->getAbsoluteUrl(decode_entities($match['url']))); + } + } + } + return FALSE; + } + + /** + * Retrieves only the headers for a Drupal path or an absolute path. + * + * @param $path + * Drupal path or URL to load into internal browser + * @param $options + * Options to be forwarded to url(). + * @param $headers + * An array containing additional HTTP request headers, each formatted as + * "name: value". + * @return + * The retrieved headers, also available as $this->drupalGetContent() + */ + protected function drupalHead($path, array $options = array(), array $headers = array()) { + $options['absolute'] = TRUE; + $out = $this->curlExec(array(CURLOPT_NOBODY => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_HTTPHEADER => $headers)); + $this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up. + return $out; + } + + /** + * Handle form input related to drupalPost(). Ensure that the specified fields + * exist and attempt to create POST data in the correct manner for the particular + * field type. + * + * @param $post + * Reference to array of post values. + * @param $edit + * Reference to array of edit values to be checked against the form. + * @param $submit + * Form submit button value. + * @param $form + * Array of form elements. + * @return + * Submit value matches a valid submit input in the form. + */ + protected function handleForm(&$post, &$edit, &$upload, $submit, $form) { + // Retrieve the form elements. + $elements = $form->xpath('.//input[not(@disabled)]|.//textarea[not(@disabled)]|.//select[not(@disabled)]'); + $submit_matches = FALSE; + foreach ($elements as $element) { + // SimpleXML objects need string casting all the time. + $name = (string) $element['name']; + // This can either be the type of or the name of the tag itself + // for + + + + + + + + +

    Humans (and frogs): please leave this field blank.

    + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shirts4mike/css/style.css b/shirts4mike/css/style.css new file mode 100755 index 0000000..6c0b32a --- /dev/null +++ b/shirts4mike/css/style.css @@ -0,0 +1,786 @@ +/*! normalize.css - http://github.com/necolas/normalize.css */ + +/* ========================================================================== + HTML5 display definitions + ========================================================================== */ + +/* + * Corrects `block` display not defined in IE6/7/8/9 & FF3. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section, +summary { + display: block; +} + +/* + * Corrects `inline-block` display not defined in IE6/7/8/9 & FF3. + */ + +audio, +canvas, +video { + display: inline-block; + *display: inline; + *zoom: 1; +} + +/* + * Prevents modern browsers from displaying `audio` without controls. + * Remove excess height in iOS5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/* + * Addresses styling for `hidden` attribute not present in IE7/8/9, FF3, S4. + * Known issue: no IE6 support. + */ + +[hidden] { + display: none; +} + +/* ========================================================================== + Base + ========================================================================== */ + +/* + * 1. Corrects text resizing oddly in IE6/7 when body `font-size` is set using + * `em` units. + * 2. Prevents iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-size: 100%; /* 1 */ + -webkit-text-size-adjust: 100%; /* 2 */ + -ms-text-size-adjust: 100%; /* 2 */ +} + +/* + * Addresses `font-family` inconsistency between `textarea` and other form + * elements. + */ + +html, +button, +input, +select, +textarea { + font-family: sans-serif; +} + +/* + * Addresses margins handled incorrectly in IE6/7. + */ + +body { + margin: 0; +} + +/* ========================================================================== + Links + ========================================================================== */ + +/* + * Addresses `outline` inconsistency between Chrome and other browsers. + */ + +a:focus { + outline: thin dotted; +} + +/* + * Improves readability when focused and also mouse hovered in all browsers. + * people.opera.com/patrickl/experiments/keyboard/test + */ + +a:active, +a:hover { + outline: 0; +} + +/* ========================================================================== + Typography + ========================================================================== */ + +/* + * Addresses font sizes and margins set differently in IE6/7. + * Addresses font sizes within `section` and `article` in FF4+, Chrome, S5. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +h2 { + font-size: 1.5em; + margin: 0.83em 0; +} + +h3 { + font-size: 1.17em; + margin: 1em 0; +} + +h4 { + font-size: 1em; + margin: 1.33em 0; +} + +h5 { + font-size: 0.83em; + margin: 1.67em 0; +} + +h6 { + font-size: 0.75em; + margin: 2.33em 0; +} + +/* + * Addresses styling not present in IE7/8/9, S5, Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/* + * Addresses style set to `bolder` in FF3+, S4/5, Chrome. + */ + +b, +strong { + font-weight: bold; +} + +blockquote { + margin: 1em 40px; +} + +/* + * Addresses styling not present in S5, Chrome. + */ + +dfn { + font-style: italic; +} + +/* + * Addresses styling not present in IE6/7/8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/* + * Addresses margins set differently in IE6/7. + */ + +p, +pre { + margin: 1em 0; +} + +/* + * Corrects font family set oddly in IE6, S4/5, Chrome. + * en.wikipedia.org/wiki/User:Davidgothberg/Test59 + */ + +code, +kbd, +pre, +samp { + font-family: monospace, serif; + _font-family: 'courier new', monospace; + font-size: 1em; +} + +/* + * Improves readability of pre-formatted text in all browsers. + */ + +pre { + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; +} + +/* + * Addresses CSS quotes not supported in IE6/7. + */ + +q { + quotes: none; +} + +/* + * Addresses `quotes` property not supported in S4. + */ + +q:before, +q:after { + content: ''; + content: none; +} + +small { + font-size: 75%; +} + +/* + * Prevents `sub` and `sup` affecting `line-height` in all browsers. + * gist.github.com/413930 + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* ========================================================================== + Lists + ========================================================================== */ + +/* + * Addresses margins set differently in IE6/7. + */ + +dl, +menu, +ol, +ul { + margin: 1em 0; +} + +dd { + margin: 0 0 0 40px; +} + +/* + * Addresses paddings set differently in IE6/7. + */ + +menu, +ol, +ul { + padding: 0 0 0 40px; +} + +/* + * Corrects list images handled incorrectly in IE7. + */ + +nav ul, +nav ol { + list-style: none; + list-style-image: none; +} + +/* ========================================================================== + Embedded content + ========================================================================== */ + +/* + * 1. Removes border when inside `a` element in IE6/7/8/9, FF3. + * 2. Improves image quality when scaled in IE7. + * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ + */ + +img { + border: 0; /* 1 */ + -ms-interpolation-mode: bicubic; /* 2 */ +} + +/* + * Corrects overflow displayed oddly in IE9. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* ========================================================================== + Figures + ========================================================================== */ + +/* + * Addresses margin not present in IE6/7/8/9, S5, O11. + */ + +figure { + margin: 0; +} + +/* ========================================================================== + Forms + ========================================================================== */ + +/* + * Corrects margin displayed oddly in IE6/7. + */ + +form { + margin: 0; +} + +/* + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/* + * 1. Corrects color not being inherited in IE6/7/8/9. + * 2. Corrects text not wrapping in FF3. + * 3. Corrects alignment displayed oddly in IE6/7. + */ + +legend { + border: 0; /* 1 */ + padding: 0; + white-space: normal; /* 2 */ + *margin-left: -7px; /* 3 */ +} + +/* + * 1. Corrects font size not being inherited in all browsers. + * 2. Addresses margins set differently in IE6/7, FF3+, S5, Chrome. + * 3. Improves appearance and consistency in all browsers. + */ + +button, +input, +select, +textarea { + font-size: 100%; /* 1 */ + margin: 0; /* 2 */ + vertical-align: baseline; /* 3 */ + *vertical-align: middle; /* 3 */ +} + +/* + * Addresses FF3/4 setting `line-height` on `input` using `!important` in the + * UA stylesheet. + */ + +button, +input { + line-height: normal; +} + +/* + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Corrects inability to style clickable `input` types in iOS. + * 3. Improves usability and consistency of cursor style between image-type + * `input` and others. + * 4. Removes inner spacing in IE7 without affecting normal text inputs. + * Known issue: inner spacing remains in IE6. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ + *overflow: visible; /* 4 */ +} + +/* + * Re-set default cursor for disabled elements. + */ + +button[disabled], +input[disabled] { + cursor: default; +} + +/* + * 1. Addresses box sizing set to content-box in IE8/9. + * 2. Removes excess padding in IE8/9. + * 3. Removes excess padding in IE7. + * Known issue: excess padding remains in IE6. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ + *height: 13px; /* 3 */ + *width: 13px; /* 3 */ +} + +/* + * 1. Addresses `appearance` set to `searchfield` in S5, Chrome. + * 2. Addresses `box-sizing` set to `border-box` in S5, Chrome (include `-moz` + * to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/* + * Removes inner padding and search cancel button in S5, Chrome on OS X. + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/* + * Removes inner padding and border in FF3+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/* + * 1. Removes default vertical scrollbar in IE6/7/8/9. + * 2. Improves readability and alignment in all browsers. + */ + +textarea { + overflow: auto; /* 1 */ + vertical-align: top; /* 2 */ +} + +/* ========================================================================== + Tables + ========================================================================== */ + +/* + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + + +html {overflow-y: scroll; overflow-x: hidden;} +body {font-family: 'Oswald', sans-serif; background:#f0eeed; color: #676767;} + +.wrapper {width: 980px; margin: 0 auto;} +.header:after {content:"";height:0;display:block;visibility:hidden;clear:both;} +.header {background: #ff8400; border-bottom: 5px solid #f16702;} +.header .branding-title {float: left; margin: 0 0 0 12px; font: 0/0 serif; text-shadow: none; color: transparent; width:122px;height:77px;background:url(../img/branding-title.png) 0 14px no-repeat;padding: 14px 0;} +.header .branding-title a {display: block; height: 77px; width: 122px;} +.header .nav {float: right; top: 0; right: 0; margin: 0; position: relative; left: 15px; z-index: 99999999;} +.header .nav li {display: inline-block; margin: 0; list-style: none;} +.header .nav li.cart {margin-left: 44px; border: 0 solid #f16702; border-width: 0 8px;} +.header .nav li a { + color: white; + text-decoration: none; + display: block; + line-height: 95px; + padding: 10px 0 0; + margin: 0 0 0 40px; + width: 90px; + text-align: right; + background: url('../img/nav-sprite.png') no-repeat 0px 105px; + text-transform: uppercase; + white-space: nowrap; +} +.header .nav li.on a {text-decoration: underline;} +.header .nav li a:hover, .header .nav li a:active {color: #FFE200;} +.header .nav li.shirts a {background-position: 0px 0px;} +.header .nav li.contact a {background-position: 0px -105px;} +.header .nav li.search a {background-position: 0px -419px;} +.header .nav li.cart a { + width: 122px; + font-size: 0/95px serif; + text-shadow: none; + color: transparent; + background-position: 16px -216px; + margin: 0; +} +.header .nav li.cart a:hover {background-position: 16px -321px;} +#content {min-height: 400px; background: white;} +.section.banner {height: 290px; background: #3d3d3d url('../img/banner-background.jpg') center center no-repeat;} +.section.banner .wrapper {position: relative;} +.section.banner .hero {position: absolute; top: -89px; left: 117px; z-index: 999;} +.section.banner .button { + display: block; + position: absolute; + top: 97px; + left: 530px; + margin: 0; + background-image: linear-gradient(bottom, rgb(35,124,219) 0%, rgb(39,136,232) 16%, rgb(119,184,249) 100%); + background-image: -o-linear-gradient(bottom, rgb(35,124,219) 0%, rgb(39,136,232) 16%, rgb(119,184,249) 100%); + background-image: -moz-linear-gradient(bottom, rgb(35,124,219) 0%, rgb(39,136,232) 16%, rgb(119,184,249) 100%); + background-image: -webkit-linear-gradient(bottom, rgb(35,124,219) 0%, rgb(39,136,232) 16%, rgb(119,184,249) 100%); + background-image: -ms-linear-gradient(bottom, rgb(35,124,219) 0%, rgb(39,136,232) 16%, rgb(119,184,249) 100%); + background-image: -webkit-gradient( + linear, + left bottom, + left top, + color-stop(0, rgb(35,124,219)), + color-stop(0.16, rgb(39,136,232)), + color-stop(1, rgb(119,184,249)) + ); + -webkit-border-radius: 10px; + border-radius: 10px; + border: 5px solid #029af1; + z-index: 0; +} +.section.banner a { + width: 200px; + padding: 20px 20px 20px 50px; + display: block; + text-decoration: none; + background: url(../img/banner-link-arrow.png) 100% 50% no-repeat; + color: #FFF; +} +.section.banner a:hover { + color: #ffe200; +} +.section.banner h2 { + font-size: 18px; + font-weight: normal; + margin: 0; + line-height: 1.3; +} +.section.banner p { + color: #ffe200; + font-style: italic; + font-size: 14px; + margin: 0; +} +.section.page:after {content:"";display:block;visibility:hidden;height:0;clear:both;} +.section.page {padding: 34px 0; background: white;} +.section.page h1 { + font-size: 24px; + text-align: center; + text-transform: uppercase; + line-height: 1.6; + font-weight: normal; +} +.section.page .shirt-details h1 { + text-align: left; +} +.section.page p {width: 375px; margin-left: auto; margin-right: auto; } +.section.page .shirt-details h1 .price {color: #9d9f4e; padding-right: 10px; font-size: 34px;} +.section.shirts {padding-bottom: 42px; background: #fff;} +.section.shirts h2 { + font-size: 24px; + color: #c0bfbe; + text-align: center; + text-transform: uppercase; + line-height: 1.6; + font-weight: normal; +} +.section.shirts ul.products {margin: 0 0 -17px 0; padding: 0; width: 997px;} +.section.shirts ul.products li { + display: inline-block; + list-style: none; + border: 1px solid #e3e1e0; + -webkit-border-radius: 2px; + border-radius: 2px; + width: 202px; + text-align: center; + text-transform: lowercase; + padding: 14px; + background: #f0eeed; + margin: 0 0 17px 17px; + position: relative; + left: -17px; +} +.section.shirts ul.products li a:hover:after { + content: '+'; + font-size: 50px; position: absolute; top: -10px; right: 25px; color: #f16702; vertical-align: top; +} +.section.shirts ul.products li a { + background: white; + display: block; + padding: 30px 0 10px; + text-decoration: none; + color: #999; + opacity: .9; +} +.section.shirts ul.products li a:hover { + opacity: 1; + color: #666; +} +.section.shirts ul.products li img { + width: 190px; +} +.section.shirts ul.products li p { + margin-left: 0; + margin-right: 0; + width: auto; +} + +.shirt-picture { + float: left; + width: 460px; + text-align: center; + border: 1px solid #d9d9d9; + padding: 14px; + background: #f0eeed; +} +.shirt-picture span { + background: white; + display: block; + width: 100%; + padding: 36px 0 61px; +} +.shirt-picture img {width: 292px;} +.shirt-details { + width: 460px; + float: right; +} +.shirt-details form { + margin-left: 0; +} +form {width: 375px; margin: 34px auto;} +form tr { + border: 1px solid #CCC; + background: #f4f3f2; +} +form table {width: 375px; margin-bottom: 16px;} +form th { + width: 85px; + border-right: 1px solid #CCC; + vertical-align: middle; + padding: 8px; +} +form td { + padding: 15px 15px; +} +form td select, +form td input, +form td textarea { + width: 100%; +} +form input[type="submit"] { + width: 375px; + text-align: center; + border: 1px solid #8e8e46; + background: #9c9f4e; + color: #FFF; + -webkit-border-radius: 2px; + border-radius: 2px; + font-size: 14px; + text-transform: uppercase; + padding: 14px; +} +.search form { + width: auto; + text-align: center; +} +.search form input[type="text"] { + font-size: 24px; + width: 70%; + line-height: 1.5; + vertical-align: top; + padding: 3px; +} +.search form input[type="submit"] { + width: auto; + vertical-align: top; +} +.section.page.search p {text-align: center;} + +.pagination { + text-align: right; + margin: 1em 0; +} +.pagination a, +.pagination span { + padding: 5px 20px; + border: 1px solid #e3e1e0; + display: inline-block; + text-decoration: none; + color: #676767; +} +.pagination span {background: #CCC; border-color: #999; color: #444;} +.pagination a:hover {background: #f0eeed;} + +.page p.message { + background: #ffeca4; + border: 1px solid #f16702; + padding: 1em; + width: 344px; +} + + + + + +.breadcrumb { + font-family: Helvetica, Arial, sans-serif; + font-size: 14px; + font-weight: normal; + padding: 14px 0 48px; +} +.note-designer { + font-family: Georgia, serif; + font-size: 14px; + font-style: italic; + font-weight: bold; +} + +.footer { + background: #f0eeed; + padding: 42px 0; + font-size: 12px; + color: #a5a5a5; + font-family: Helvetica, Arial, sans-serif; +} +.footer ul {margin: 0; padding: 0; float: left;} +.footer ul li { + margin: 0; + padding: 0; + list-style: none; + display: inline-block; + text-transform: lowercase; +} +.footer ul li:after {content:" | "} +.footer ul li:last-child:after {content:"";} +.footer p {margin: 0; text-align: right; padding-right: 3px;} +.footer a {text-decoration: none; color: #539def; margin: 0 10px;} +.footer li:first-child a {margin-left: 4px;} +.footer a:hover, .footer a:active {text-decoration: underline;} \ No newline at end of file diff --git a/shirts4mike/favicon.ico b/shirts4mike/favicon.ico new file mode 100755 index 0000000..4ea5a00 Binary files /dev/null and b/shirts4mike/favicon.ico differ diff --git a/shirts4mike/img/banner-background.jpg b/shirts4mike/img/banner-background.jpg new file mode 100755 index 0000000..a0c6b7e Binary files /dev/null and b/shirts4mike/img/banner-background.jpg differ diff --git a/shirts4mike/img/banner-link-arrow.png b/shirts4mike/img/banner-link-arrow.png new file mode 100755 index 0000000..e1a2b0c Binary files /dev/null and b/shirts4mike/img/banner-link-arrow.png differ diff --git a/shirts4mike/img/branding-title.png b/shirts4mike/img/branding-title.png new file mode 100755 index 0000000..dd79d88 Binary files /dev/null and b/shirts4mike/img/branding-title.png differ diff --git a/shirts4mike/img/logo-paypal-classic.png b/shirts4mike/img/logo-paypal-classic.png new file mode 100755 index 0000000..7dcecc6 Binary files /dev/null and b/shirts4mike/img/logo-paypal-classic.png differ diff --git a/shirts4mike/img/logo-paypal.png b/shirts4mike/img/logo-paypal.png new file mode 100755 index 0000000..80a09ce Binary files /dev/null and b/shirts4mike/img/logo-paypal.png differ diff --git a/shirts4mike/img/mike-the-frog.png b/shirts4mike/img/mike-the-frog.png new file mode 100755 index 0000000..530b557 Binary files /dev/null and b/shirts4mike/img/mike-the-frog.png differ diff --git a/shirts4mike/img/nav-sprite.png b/shirts4mike/img/nav-sprite.png new file mode 100755 index 0000000..0eac96a Binary files /dev/null and b/shirts4mike/img/nav-sprite.png differ diff --git a/shirts4mike/img/shirts/shirt-101.jpg b/shirts4mike/img/shirts/shirt-101.jpg new file mode 100755 index 0000000..3f43ea2 Binary files /dev/null and b/shirts4mike/img/shirts/shirt-101.jpg differ diff --git a/shirts4mike/img/shirts/shirt-102.jpg b/shirts4mike/img/shirts/shirt-102.jpg new file mode 100755 index 0000000..d838907 Binary files /dev/null and b/shirts4mike/img/shirts/shirt-102.jpg differ diff --git a/shirts4mike/img/shirts/shirt-103.jpg b/shirts4mike/img/shirts/shirt-103.jpg new file mode 100755 index 0000000..a5a013e Binary files /dev/null and b/shirts4mike/img/shirts/shirt-103.jpg differ diff --git a/shirts4mike/img/shirts/shirt-104.jpg b/shirts4mike/img/shirts/shirt-104.jpg new file mode 100755 index 0000000..f09e11b Binary files /dev/null and b/shirts4mike/img/shirts/shirt-104.jpg differ diff --git a/shirts4mike/img/shirts/shirt-105.jpg b/shirts4mike/img/shirts/shirt-105.jpg new file mode 100755 index 0000000..f9242ba Binary files /dev/null and b/shirts4mike/img/shirts/shirt-105.jpg differ diff --git a/shirts4mike/img/shirts/shirt-106.jpg b/shirts4mike/img/shirts/shirt-106.jpg new file mode 100755 index 0000000..f893fde Binary files /dev/null and b/shirts4mike/img/shirts/shirt-106.jpg differ diff --git a/shirts4mike/img/shirts/shirt-107.jpg b/shirts4mike/img/shirts/shirt-107.jpg new file mode 100755 index 0000000..f9cc693 Binary files /dev/null and b/shirts4mike/img/shirts/shirt-107.jpg differ diff --git a/shirts4mike/img/shirts/shirt-108.jpg b/shirts4mike/img/shirts/shirt-108.jpg new file mode 100755 index 0000000..3dead9d Binary files /dev/null and b/shirts4mike/img/shirts/shirt-108.jpg differ diff --git a/shirts4mike/inc/footer.php b/shirts4mike/inc/footer.php new file mode 100644 index 0000000..a4fa264 --- /dev/null +++ b/shirts4mike/inc/footer.php @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/shirts4mike/inc/header.php b/shirts4mike/inc/header.php new file mode 100644 index 0000000..f18b606 --- /dev/null +++ b/shirts4mike/inc/header.php @@ -0,0 +1,26 @@ + + + <?php echo $pageTitle; ?> + + + + + + +
    + +
    + +

    Shirts 4 Mike

    + + + +
    + +
    + +
    \ No newline at end of file diff --git a/shirts4mike/inc/phpmailer/class.phpmailer.php b/shirts4mike/inc/phpmailer/class.phpmailer.php new file mode 100644 index 0000000..af089d5 --- /dev/null +++ b/shirts4mike/inc/phpmailer/class.phpmailer.php @@ -0,0 +1,2532 @@ +exceptions = ($exceptions == true); + } + + /** + * Sets message type to HTML. + * @param bool $ishtml + * @return void + */ + public function IsHTML($ishtml = true) { + if ($ishtml) { + $this->ContentType = 'text/html'; + } else { + $this->ContentType = 'text/plain'; + } + } + + /** + * Sets Mailer to send message using SMTP. + * @return void + */ + public function IsSMTP() { + $this->Mailer = 'smtp'; + } + + /** + * Sets Mailer to send message using PHP mail() function. + * @return void + */ + public function IsMail() { + $this->Mailer = 'mail'; + } + + /** + * Sets Mailer to send message using the $Sendmail program. + * @return void + */ + public function IsSendmail() { + if (!stristr(ini_get('sendmail_path'), 'sendmail')) { + $this->Sendmail = '/var/qmail/bin/sendmail'; + } + $this->Mailer = 'sendmail'; + } + + /** + * Sets Mailer to send message using the qmail MTA. + * @return void + */ + public function IsQmail() { + if (stristr(ini_get('sendmail_path'), 'qmail')) { + $this->Sendmail = '/var/qmail/bin/sendmail'; + } + $this->Mailer = 'sendmail'; + } + + ///////////////////////////////////////////////// + // METHODS, RECIPIENTS + ///////////////////////////////////////////////// + + /** + * Adds a "To" address. + * @param string $address + * @param string $name + * @return boolean true on success, false if address already used + */ + public function AddAddress($address, $name = '') { + return $this->AddAnAddress('to', $address, $name); + } + + /** + * Adds a "Cc" address. + * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer. + * @param string $address + * @param string $name + * @return boolean true on success, false if address already used + */ + public function AddCC($address, $name = '') { + return $this->AddAnAddress('cc', $address, $name); + } + + /** + * Adds a "Bcc" address. + * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer. + * @param string $address + * @param string $name + * @return boolean true on success, false if address already used + */ + public function AddBCC($address, $name = '') { + return $this->AddAnAddress('bcc', $address, $name); + } + + /** + * Adds a "Reply-to" address. + * @param string $address + * @param string $name + * @return boolean + */ + public function AddReplyTo($address, $name = '') { + return $this->AddAnAddress('Reply-To', $address, $name); + } + + /** + * Adds an address to one of the recipient arrays + * Addresses that have been added already return false, but do not throw exceptions + * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo' + * @param string $address The email address to send to + * @param string $name + * @return boolean true on success, false if address already used or invalid in some way + * @access protected + */ + protected function AddAnAddress($kind, $address, $name = '') { + if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) { + $this->SetError($this->Lang('Invalid recipient array').': '.$kind); + if ($this->exceptions) { + throw new phpmailerException('Invalid recipient array: ' . $kind); + } + if ($this->SMTPDebug) { + echo $this->Lang('Invalid recipient array').': '.$kind; + } + return false; + } + $address = trim($address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + if (!self::ValidateAddress($address)) { + $this->SetError($this->Lang('invalid_address').': '. $address); + if ($this->exceptions) { + throw new phpmailerException($this->Lang('invalid_address').': '.$address); + } + if ($this->SMTPDebug) { + echo $this->Lang('invalid_address').': '.$address; + } + return false; + } + if ($kind != 'Reply-To') { + if (!isset($this->all_recipients[strtolower($address)])) { + array_push($this->$kind, array($address, $name)); + $this->all_recipients[strtolower($address)] = true; + return true; + } + } else { + if (!array_key_exists(strtolower($address), $this->ReplyTo)) { + $this->ReplyTo[strtolower($address)] = array($address, $name); + return true; + } + } + return false; +} + +/** + * Set the From and FromName properties + * @param string $address + * @param string $name + * @return boolean + */ + public function SetFrom($address, $name = '', $auto = 1) { + $address = trim($address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + if (!self::ValidateAddress($address)) { + $this->SetError($this->Lang('invalid_address').': '. $address); + if ($this->exceptions) { + throw new phpmailerException($this->Lang('invalid_address').': '.$address); + } + if ($this->SMTPDebug) { + echo $this->Lang('invalid_address').': '.$address; + } + return false; + } + $this->From = $address; + $this->FromName = $name; + if ($auto) { + if (empty($this->ReplyTo)) { + $this->AddAnAddress('Reply-To', $address, $name); + } + if (empty($this->Sender)) { + $this->Sender = $address; + } + } + return true; + } + + /** + * Check that a string looks roughly like an email address should + * Static so it can be used without instantiation + * Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator + * Conforms approximately to RFC2822 + * @link http://www.hexillion.com/samples/#Regex Original pattern found here + * @param string $address The email address to check + * @return boolean + * @static + * @access public + */ + public static function ValidateAddress($address) { + if (function_exists('filter_var')) { //Introduced in PHP 5.2 + if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) { + return false; + } else { + return true; + } + } else { + return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address); + } + } + + ///////////////////////////////////////////////// + // METHODS, MAIL SENDING + ///////////////////////////////////////////////// + + /** + * Creates message and assigns Mailer. If the message is + * not sent successfully then it returns false. Use the ErrorInfo + * variable to view description of the error. + * @return bool + */ + public function Send() { + try { + if(!$this->PreSend()) return false; + return $this->PostSend(); + } catch (phpmailerException $e) { + $this->SentMIMEMessage = ''; + $this->SetError($e->getMessage()); + if ($this->exceptions) { + throw $e; + } + return false; + } + } + + protected function PreSend() { + try { + $mailHeader = ""; + if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { + throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL); + } + + // Set whether the message is multipart/alternative + if(!empty($this->AltBody)) { + $this->ContentType = 'multipart/alternative'; + } + + $this->error_count = 0; // reset errors + $this->SetMessageType(); + //Refuse to send an empty message + if (empty($this->Body)) { + throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL); + } + + $this->MIMEHeader = $this->CreateHeader(); + $this->MIMEBody = $this->CreateBody(); + + // To capture the complete message when using mail(), create + // an extra header list which CreateHeader() doesn't fold in + if ($this->Mailer == 'mail') { + if (count($this->to) > 0) { + $mailHeader .= $this->AddrAppend("To", $this->to); + } else { + $mailHeader .= $this->HeaderLine("To", "undisclosed-recipients:;"); + } + $mailHeader .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader(trim($this->Subject)))); + // if(count($this->cc) > 0) { + // $mailHeader .= $this->AddrAppend("Cc", $this->cc); + // } + } + + // digitally sign with DKIM if enabled + if ($this->DKIM_domain && $this->DKIM_private) { + $header_dkim = $this->DKIM_Add($this->MIMEHeader, $this->EncodeHeader($this->SecureHeader($this->Subject)), $this->MIMEBody); + $this->MIMEHeader = str_replace("\r\n", "\n", $header_dkim) . $this->MIMEHeader; + } + + $this->SentMIMEMessage = sprintf("%s%s\r\n\r\n%s",$this->MIMEHeader,$mailHeader,$this->MIMEBody); + return true; + + } catch (phpmailerException $e) { + $this->SetError($e->getMessage()); + if ($this->exceptions) { + throw $e; + } + return false; + } + } + + protected function PostSend() { + try { + // Choose the mailer and send through it + switch($this->Mailer) { + case 'sendmail': + return $this->SendmailSend($this->MIMEHeader, $this->MIMEBody); + case 'smtp': + return $this->SmtpSend($this->MIMEHeader, $this->MIMEBody); + case 'mail': + return $this->MailSend($this->MIMEHeader, $this->MIMEBody); + default: + return $this->MailSend($this->MIMEHeader, $this->MIMEBody); + } + + } catch (phpmailerException $e) { + $this->SetError($e->getMessage()); + if ($this->exceptions) { + throw $e; + } + if ($this->SMTPDebug) { + echo $e->getMessage()."\n"; + } + return false; + } + } + + /** + * Sends mail using the $Sendmail program. + * @param string $header The message headers + * @param string $body The message body + * @access protected + * @return bool + */ + protected function SendmailSend($header, $body) { + if ($this->Sender != '') { + $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); + } else { + $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); + } + if ($this->SingleTo === true) { + foreach ($this->SingleToArray as $key => $val) { + if(!@$mail = popen($sendmail, 'w')) { + throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + fputs($mail, "To: " . $val . "\n"); + fputs($mail, $header); + fputs($mail, $body); + $result = pclose($mail); + // implement call back function if it exists + $isSent = ($result == 0) ? 1 : 0; + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); + if($result != 0) { + throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + } else { + if(!@$mail = popen($sendmail, 'w')) { + throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + fputs($mail, $header); + fputs($mail, $body); + $result = pclose($mail); + // implement call back function if it exists + $isSent = ($result == 0) ? 1 : 0; + $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body); + if($result != 0) { + throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + return true; + } + + /** + * Sends mail using the PHP mail() function. + * @param string $header The message headers + * @param string $body The message body + * @access protected + * @return bool + */ + protected function MailSend($header, $body) { + $toArr = array(); + foreach($this->to as $t) { + $toArr[] = $this->AddrFormat($t); + } + $to = implode(', ', $toArr); + + if (empty($this->Sender)) { + $params = "-oi "; + } else { + $params = sprintf("-oi -f %s", $this->Sender); + } + if ($this->Sender != '' and !ini_get('safe_mode')) { + $old_from = ini_get('sendmail_from'); + ini_set('sendmail_from', $this->Sender); + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + // implement call back function if it exists + $isSent = ($rt == 1) ? 1 : 0; + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + // implement call back function if it exists + $isSent = ($rt == 1) ? 1 : 0; + $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body); + } + } else { + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + // implement call back function if it exists + $isSent = ($rt == 1) ? 1 : 0; + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + // implement call back function if it exists + $isSent = ($rt == 1) ? 1 : 0; + $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body); + } + } + if (isset($old_from)) { + ini_set('sendmail_from', $old_from); + } + if(!$rt) { + throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL); + } + return true; + } + + /** + * Sends mail via SMTP using PhpSMTP + * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. + * @param string $header The message headers + * @param string $body The message body + * @uses SMTP + * @access protected + * @return bool + */ + protected function SmtpSend($header, $body) { + require_once $this->PluginDir . 'class.smtp.php'; + $bad_rcpt = array(); + + if(!$this->SmtpConnect()) { + throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL); + } + $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; + if(!$this->smtp->Mail($smtp_from)) { + throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL); + } + + // Attempt to send attach all recipients + foreach($this->to as $to) { + if (!$this->smtp->Recipient($to[0])) { + $bad_rcpt[] = $to[0]; + // implement call back function if it exists + $isSent = 0; + $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body); + } else { + // implement call back function if it exists + $isSent = 1; + $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body); + } + } + foreach($this->cc as $cc) { + if (!$this->smtp->Recipient($cc[0])) { + $bad_rcpt[] = $cc[0]; + // implement call back function if it exists + $isSent = 0; + $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body); + } else { + // implement call back function if it exists + $isSent = 1; + $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body); + } + } + foreach($this->bcc as $bcc) { + if (!$this->smtp->Recipient($bcc[0])) { + $bad_rcpt[] = $bcc[0]; + // implement call back function if it exists + $isSent = 0; + $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body); + } else { + // implement call back function if it exists + $isSent = 1; + $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body); + } + } + + + if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses + $badaddresses = implode(', ', $bad_rcpt); + throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses); + } + if(!$this->smtp->Data($header . $body)) { + throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL); + } + if($this->SMTPKeepAlive == true) { + $this->smtp->Reset(); + } + return true; + } + + /** + * Initiates a connection to an SMTP server. + * Returns false if the operation failed. + * @uses SMTP + * @access public + * @return bool + */ + public function SmtpConnect() { + if(is_null($this->smtp)) { + $this->smtp = new SMTP(); + } + + $this->smtp->do_debug = $this->SMTPDebug; + $hosts = explode(';', $this->Host); + $index = 0; + $connection = $this->smtp->Connected(); + + // Retry while there is no connection + try { + while($index < count($hosts) && !$connection) { + $hostinfo = array(); + if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) { + $host = $hostinfo[1]; + $port = $hostinfo[2]; + } else { + $host = $hosts[$index]; + $port = $this->Port; + } + + $tls = ($this->SMTPSecure == 'tls'); + $ssl = ($this->SMTPSecure == 'ssl'); + + if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) { + + $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname()); + $this->smtp->Hello($hello); + + if ($tls) { + if (!$this->smtp->StartTLS()) { + throw new phpmailerException($this->Lang('tls')); + } + + //We must resend HELO after tls negotiation + $this->smtp->Hello($hello); + } + + $connection = true; + if ($this->SMTPAuth) { + if (!$this->smtp->Authenticate($this->Username, $this->Password)) { + throw new phpmailerException($this->Lang('authenticate')); + } + } + } + $index++; + if (!$connection) { + throw new phpmailerException($this->Lang('connect_host')); + } + } + } catch (phpmailerException $e) { + $this->smtp->Reset(); + if ($this->exceptions) { + throw $e; + } + } + return true; + } + + /** + * Closes the active SMTP session if one exists. + * @return void + */ + public function SmtpClose() { + if(!is_null($this->smtp)) { + if($this->smtp->Connected()) { + $this->smtp->Quit(); + $this->smtp->Close(); + } + } + } + + /** + * Sets the language for all class error messages. + * Returns false if it cannot load the language file. The default language is English. + * @param string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br") + * @param string $lang_path Path to the language file directory + * @access public + */ + function SetLanguage($langcode = 'en', $lang_path = 'language/') { + //Define full set of translatable strings + $PHPMAILER_LANG = array( + 'provide_address' => 'You must provide at least one recipient email address.', + 'mailer_not_supported' => ' mailer is not supported.', + 'execute' => 'Could not execute: ', + 'instantiate' => 'Could not instantiate mail function.', + 'authenticate' => 'SMTP Error: Could not authenticate.', + 'from_failed' => 'The following From address failed: ', + 'recipients_failed' => 'SMTP Error: The following recipients failed: ', + 'data_not_accepted' => 'SMTP Error: Data not accepted.', + 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', + 'file_access' => 'Could not access file: ', + 'file_open' => 'File Error: Could not open file: ', + 'encoding' => 'Unknown encoding: ', + 'signing' => 'Signing Error: ', + 'smtp_error' => 'SMTP server error: ', + 'empty_message' => 'Message body empty', + 'invalid_address' => 'Invalid address', + 'variable_set' => 'Cannot set or reset variable: ' + ); + //Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"! + $l = true; + if ($langcode != 'en') { //There is no English translation file + $l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php'; + } + $this->language = $PHPMAILER_LANG; + return ($l == true); //Returns false if language not found + } + + /** + * Return the current array of language strings + * @return array + */ + public function GetTranslations() { + return $this->language; + } + + ///////////////////////////////////////////////// + // METHODS, MESSAGE CREATION + ///////////////////////////////////////////////// + + /** + * Creates recipient headers. + * @access public + * @return string + */ + public function AddrAppend($type, $addr) { + $addr_str = $type . ': '; + $addresses = array(); + foreach ($addr as $a) { + $addresses[] = $this->AddrFormat($a); + } + $addr_str .= implode(', ', $addresses); + $addr_str .= $this->LE; + + return $addr_str; + } + + /** + * Formats an address correctly. + * @access public + * @return string + */ + public function AddrFormat($addr) { + if (empty($addr[1])) { + return $this->SecureHeader($addr[0]); + } else { + return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; + } + } + + /** + * Wraps message for use with mailers that do not + * automatically perform wrapping and for quoted-printable. + * Original written by philippe. + * @param string $message The message to wrap + * @param integer $length The line length to wrap to + * @param boolean $qp_mode Whether to run in Quoted-Printable mode + * @access public + * @return string + */ + public function WrapText($message, $length, $qp_mode = false) { + $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; + // If utf-8 encoding is used, we will need to make sure we don't + // split multibyte characters when we wrap + $is_utf8 = (strtolower($this->CharSet) == "utf-8"); + + $message = $this->FixEOL($message); + if (substr($message, -1) == $this->LE) { + $message = substr($message, 0, -1); + } + + $line = explode($this->LE, $message); + $message = ''; + for ($i = 0 ;$i < count($line); $i++) { + $line_part = explode(' ', $line[$i]); + $buf = ''; + for ($e = 0; $e $length)) { + $space_left = $length - strlen($buf) - 1; + if ($e != 0) { + if ($space_left > 20) { + $len = $space_left; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + $buf .= ' ' . $part; + $message .= $buf . sprintf("=%s", $this->LE); + } else { + $message .= $buf . $soft_break; + } + $buf = ''; + } + while (strlen($word) > 0) { + $len = $length; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + + if (strlen($word) > 0) { + $message .= $part . sprintf("=%s", $this->LE); + } else { + $buf = $part; + } + } + } else { + $buf_o = $buf; + $buf .= ($e == 0) ? $word : (' ' . $word); + + if (strlen($buf) > $length and $buf_o != '') { + $message .= $buf_o . $soft_break; + $buf = $word; + } + } + } + $message .= $buf . $this->LE; + } + + return $message; + } + + /** + * Finds last character boundary prior to maxLength in a utf-8 + * quoted (printable) encoded string. + * Original written by Colin Brown. + * @access public + * @param string $encodedText utf-8 QP text + * @param int $maxLength find last character boundary prior to this length + * @return int + */ + public function UTF8CharBoundary($encodedText, $maxLength) { + $foundSplitPos = false; + $lookBack = 3; + while (!$foundSplitPos) { + $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); + $encodedCharPos = strpos($lastChunk, "="); + if ($encodedCharPos !== false) { + // Found start of encoded character byte within $lookBack block. + // Check the encoded byte value (the 2 chars after the '=') + $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); + $dec = hexdec($hex); + if ($dec < 128) { // Single byte character. + // If the encoded char was found at pos 0, it will fit + // otherwise reduce maxLength to start of the encoded char + $maxLength = ($encodedCharPos == 0) ? $maxLength : + $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec >= 192) { // First byte of a multi byte character + // Reduce maxLength to split at start of character + $maxLength = $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back + $lookBack += 3; + } + } else { + // No encoded character found + $foundSplitPos = true; + } + } + return $maxLength; + } + + + /** + * Set the body wrapping. + * @access public + * @return void + */ + public function SetWordWrap() { + if($this->WordWrap < 1) { + return; + } + + switch($this->message_type) { + case 'alt': + case 'alt_inline': + case 'alt_attach': + case 'alt_inline_attach': + $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); + break; + default: + $this->Body = $this->WrapText($this->Body, $this->WordWrap); + break; + } + } + + /** + * Assembles message header. + * @access public + * @return string The assembled header + */ + public function CreateHeader() { + $result = ''; + + // Set the boundaries + $uniq_id = md5(uniqid(time())); + $this->boundary[1] = 'b1_' . $uniq_id; + $this->boundary[2] = 'b2_' . $uniq_id; + $this->boundary[3] = 'b3_' . $uniq_id; + + $result .= $this->HeaderLine('Date', self::RFCDate()); + if($this->Sender == '') { + $result .= $this->HeaderLine('Return-Path', trim($this->From)); + } else { + $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); + } + + // To be created automatically by mail() + if($this->Mailer != 'mail') { + if ($this->SingleTo === true) { + foreach($this->to as $t) { + $this->SingleToArray[] = $this->AddrFormat($t); + } + } else { + if(count($this->to) > 0) { + $result .= $this->AddrAppend('To', $this->to); + } elseif (count($this->cc) == 0) { + $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); + } + } + } + + $from = array(); + $from[0][0] = trim($this->From); + $from[0][1] = $this->FromName; + $result .= $this->AddrAppend('From', $from); + + // sendmail and mail() extract Cc from the header before sending + if(count($this->cc) > 0) { + $result .= $this->AddrAppend('Cc', $this->cc); + } + + // sendmail and mail() extract Bcc from the header before sending + if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { + $result .= $this->AddrAppend('Bcc', $this->bcc); + } + + if(count($this->ReplyTo) > 0) { + $result .= $this->AddrAppend('Reply-To', $this->ReplyTo); + } + + // mail() sets the subject itself + if($this->Mailer != 'mail') { + $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); + } + + if($this->MessageID != '') { + $result .= $this->HeaderLine('Message-ID', $this->MessageID); + } else { + $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); + } + $result .= $this->HeaderLine('X-Priority', $this->Priority); + if($this->XMailer) { + $result .= $this->HeaderLine('X-Mailer', $this->XMailer); + } else { + $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (http://code.google.com/a/apache-extras.org/p/phpmailer/)'); + } + + if($this->ConfirmReadingTo != '') { + $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); + } + + // Add custom headers + for($index = 0; $index < count($this->CustomHeader); $index++) { + $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); + } + if (!$this->sign_key_file) { + $result .= $this->HeaderLine('MIME-Version', '1.0'); + $result .= $this->GetMailMIME(); + } + + return $result; + } + + /** + * Returns the message MIME. + * @access public + * @return string + */ + public function GetMailMIME() { + $result = ''; + switch($this->message_type) { + case 'plain': + $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); + $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset="'.$this->CharSet.'"'); + break; + case 'inline': + $result .= $this->HeaderLine('Content-Type', 'multipart/related;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + case 'attach': + case 'inline_attach': + case 'alt_attach': + case 'alt_inline_attach': + $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + case 'alt': + case 'alt_inline': + $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + } + + if($this->Mailer != 'mail') { + $result .= $this->LE.$this->LE; + } + + return $result; + } + + /** + * Returns the MIME message (headers and body). Only really valid post PreSend(). + * @access public + * @return string + */ + public function GetSentMIMEMessage() { + return $this->SentMIMEMessage; + } + + + /** + * Assembles the message body. Returns an empty string on failure. + * @access public + * @return string The assembled message body + */ + public function CreateBody() { + $body = ''; + + if ($this->sign_key_file) { + $body .= $this->GetMailMIME(); + } + + $this->SetWordWrap(); + + switch($this->message_type) { + case 'plain': + $body .= $this->EncodeString($this->Body, $this->Encoding); + break; + case 'inline': + $body .= $this->GetBoundary($this->boundary[1], '', '', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->AttachAll("inline", $this->boundary[1]); + break; + case 'attach': + $body .= $this->GetBoundary($this->boundary[1], '', '', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->AttachAll("attachment", $this->boundary[1]); + break; + case 'inline_attach': + $body .= $this->TextLine("--" . $this->boundary[1]); + $body .= $this->HeaderLine('Content-Type', 'multipart/related;'); + $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', '', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->AttachAll("inline", $this->boundary[2]); + $body .= $this->LE; + $body .= $this->AttachAll("attachment", $this->boundary[1]); + break; + case 'alt': + $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); + $body .= $this->EncodeString($this->AltBody, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->GetBoundary($this->boundary[1], '', 'text/html', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->EndBoundary($this->boundary[1]); + break; + case 'alt_inline': + $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); + $body .= $this->EncodeString($this->AltBody, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->TextLine("--" . $this->boundary[1]); + $body .= $this->HeaderLine('Content-Type', 'multipart/related;'); + $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->AttachAll("inline", $this->boundary[2]); + $body .= $this->LE; + $body .= $this->EndBoundary($this->boundary[1]); + break; + case 'alt_attach': + $body .= $this->TextLine("--" . $this->boundary[1]); + $body .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); + $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', ''); + $body .= $this->EncodeString($this->AltBody, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->EndBoundary($this->boundary[2]); + $body .= $this->LE; + $body .= $this->AttachAll("attachment", $this->boundary[1]); + break; + case 'alt_inline_attach': + $body .= $this->TextLine("--" . $this->boundary[1]); + $body .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); + $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', ''); + $body .= $this->EncodeString($this->AltBody, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->TextLine("--" . $this->boundary[2]); + $body .= $this->HeaderLine('Content-Type', 'multipart/related;'); + $body .= $this->TextLine("\tboundary=\"" . $this->boundary[3] . '"'); + $body .= $this->LE; + $body .= $this->GetBoundary($this->boundary[3], '', 'text/html', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->AttachAll("inline", $this->boundary[3]); + $body .= $this->LE; + $body .= $this->EndBoundary($this->boundary[2]); + $body .= $this->LE; + $body .= $this->AttachAll("attachment", $this->boundary[1]); + break; + } + + if ($this->IsError()) { + $body = ''; + } elseif ($this->sign_key_file) { + try { + $file = tempnam('', 'mail'); + file_put_contents($file, $body); //TODO check this worked + $signed = tempnam("", "signed"); + if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) { + @unlink($file); + $body = file_get_contents($signed); + @unlink($signed); + } else { + @unlink($file); + @unlink($signed); + throw new phpmailerException($this->Lang("signing").openssl_error_string()); + } + } catch (phpmailerException $e) { + $body = ''; + if ($this->exceptions) { + throw $e; + } + } + } + + return $body; + } + + /** + * Returns the start of a message boundary. + * @access protected + * @return string + */ + protected function GetBoundary($boundary, $charSet, $contentType, $encoding) { + $result = ''; + if($charSet == '') { + $charSet = $this->CharSet; + } + if($contentType == '') { + $contentType = $this->ContentType; + } + if($encoding == '') { + $encoding = $this->Encoding; + } + $result .= $this->TextLine('--' . $boundary); + $result .= sprintf("Content-Type: %s; charset=\"%s\"", $contentType, $charSet); + $result .= $this->LE; + $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); + $result .= $this->LE; + + return $result; + } + + /** + * Returns the end of a message boundary. + * @access protected + * @return string + */ + protected function EndBoundary($boundary) { + return $this->LE . '--' . $boundary . '--' . $this->LE; + } + + /** + * Sets the message type. + * @access protected + * @return void + */ + protected function SetMessageType() { + $this->message_type = array(); + if($this->AlternativeExists()) $this->message_type[] = "alt"; + if($this->InlineImageExists()) $this->message_type[] = "inline"; + if($this->AttachmentExists()) $this->message_type[] = "attach"; + $this->message_type = implode("_", $this->message_type); + if($this->message_type == "") $this->message_type = "plain"; + } + + /** + * Returns a formatted header line. + * @access public + * @return string + */ + public function HeaderLine($name, $value) { + return $name . ': ' . $value . $this->LE; + } + + /** + * Returns a formatted mail line. + * @access public + * @return string + */ + public function TextLine($value) { + return $value . $this->LE; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, ATTACHMENTS + ///////////////////////////////////////////////// + + /** + * Adds an attachment from a path on the filesystem. + * Returns false if the file could not be found + * or accessed. + * @param string $path Path to the attachment. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + try { + if ( !@is_file($path) ) { + throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE); + } + $filename = basename($path); + if ( $name == '' ) { + $name = $filename; + } + + $this->attachment[] = array( + 0 => $path, + 1 => $filename, + 2 => $name, + 3 => $encoding, + 4 => $type, + 5 => false, // isStringAttachment + 6 => 'attachment', + 7 => 0 + ); + + } catch (phpmailerException $e) { + $this->SetError($e->getMessage()); + if ($this->exceptions) { + throw $e; + } + if ($this->SMTPDebug) { + echo $e->getMessage()."\n"; + } + if ( $e->getCode() == self::STOP_CRITICAL ) { + return false; + } + } + return true; + } + + /** + * Return the current array of attachments + * @return array + */ + public function GetAttachments() { + return $this->attachment; + } + + /** + * Attaches all fs, string, and binary attachments to the message. + * Returns an empty string on failure. + * @access protected + * @return string + */ + protected function AttachAll($disposition_type, $boundary) { + // Return text of body + $mime = array(); + $cidUniq = array(); + $incl = array(); + + // Add all attachments + foreach ($this->attachment as $attachment) { + // CHECK IF IT IS A VALID DISPOSITION_FILTER + if($attachment[6] == $disposition_type) { + // Check for string attachment + $bString = $attachment[5]; + if ($bString) { + $string = $attachment[0]; + } else { + $path = $attachment[0]; + } + + $inclhash = md5(serialize($attachment)); + if (in_array($inclhash, $incl)) { continue; } + $incl[] = $inclhash; + $filename = $attachment[1]; + $name = $attachment[2]; + $encoding = $attachment[3]; + $type = $attachment[4]; + $disposition = $attachment[6]; + $cid = $attachment[7]; + if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; } + $cidUniq[$cid] = true; + + $mime[] = sprintf("--%s%s", $boundary, $this->LE); + $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); + $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); + + if($disposition == 'inline') { + $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); + } + + $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); + + // Encode as string attachment + if($bString) { + $mime[] = $this->EncodeString($string, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } else { + $mime[] = $this->EncodeFile($path, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } + } + } + + $mime[] = sprintf("--%s--%s", $boundary, $this->LE); + + return implode("", $mime); + } + + /** + * Encodes attachment in requested format. + * Returns an empty string on failure. + * @param string $path The full path to the file + * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' + * @see EncodeFile() + * @access protected + * @return string + */ + protected function EncodeFile($path, $encoding = 'base64') { + try { + if (!is_readable($path)) { + throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE); + } + if (function_exists('get_magic_quotes')) { + function get_magic_quotes() { + return false; + } + } + $magic_quotes = get_magic_quotes_runtime(); + if ($magic_quotes) { + if (version_compare(PHP_VERSION, '5.3.0', '<')) { + set_magic_quotes_runtime(0); + } else { + ini_set('magic_quotes_runtime', 0); + } + } + $file_buffer = file_get_contents($path); + $file_buffer = $this->EncodeString($file_buffer, $encoding); + if ($magic_quotes) { + if (version_compare(PHP_VERSION, '5.3.0', '<')) { + set_magic_quotes_runtime($magic_quotes); + } else { + ini_set('magic_quotes_runtime', $magic_quotes); + } + } + return $file_buffer; + } catch (Exception $e) { + $this->SetError($e->getMessage()); + return ''; + } + } + + /** + * Encodes string to requested format. + * Returns an empty string on failure. + * @param string $str The text to encode + * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' + * @access public + * @return string + */ + public function EncodeString($str, $encoding = 'base64') { + $encoded = ''; + switch(strtolower($encoding)) { + case 'base64': + $encoded = chunk_split(base64_encode($str), 76, $this->LE); + break; + case '7bit': + case '8bit': + $encoded = $this->FixEOL($str); + //Make sure it ends with a line break + if (substr($encoded, -(strlen($this->LE))) != $this->LE) + $encoded .= $this->LE; + break; + case 'binary': + $encoded = $str; + break; + case 'quoted-printable': + $encoded = $this->EncodeQP($str); + break; + default: + $this->SetError($this->Lang('encoding') . $encoding); + break; + } + return $encoded; + } + + /** + * Encode a header string to best (shortest) of Q, B, quoted or none. + * @access public + * @return string + */ + public function EncodeHeader($str, $position = 'text') { + $x = 0; + + switch (strtolower($position)) { + case 'phrase': + if (!preg_match('/[\200-\377]/', $str)) { + // Can't use addslashes as we don't know what value has magic_quotes_sybase + $encoded = addcslashes($str, "\0..\37\177\\\""); + if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { + return ($encoded); + } else { + return ("\"$encoded\""); + } + } + $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); + break; + case 'comment': + $x = preg_match_all('/[()"]/', $str, $matches); + // Fall-through + case 'text': + default: + $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); + break; + } + + if ($x == 0) { + return ($str); + } + + $maxlen = 75 - 7 - strlen($this->CharSet); + // Try to select the encoding which should produce the shortest output + if (strlen($str)/3 < $x) { + $encoding = 'B'; + if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { + // Use a custom function which correctly encodes and wraps long + // multibyte strings without breaking lines within a character + $encoded = $this->Base64EncodeWrapMB($str); + } else { + $encoded = base64_encode($str); + $maxlen -= $maxlen % 4; + $encoded = trim(chunk_split($encoded, $maxlen, "\n")); + } + } else { + $encoding = 'Q'; + $encoded = $this->EncodeQ($str, $position); + $encoded = $this->WrapText($encoded, $maxlen, true); + $encoded = str_replace('='.$this->LE, "\n", trim($encoded)); + } + + $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); + $encoded = trim(str_replace("\n", $this->LE, $encoded)); + + return $encoded; + } + + /** + * Checks if a string contains multibyte characters. + * @access public + * @param string $str multi-byte text to wrap encode + * @return bool + */ + public function HasMultiBytes($str) { + if (function_exists('mb_strlen')) { + return (strlen($str) > mb_strlen($str, $this->CharSet)); + } else { // Assume no multibytes (we can't handle without mbstring functions anyway) + return false; + } + } + + /** + * Correctly encodes and wraps long multibyte strings for mail headers + * without breaking lines within a character. + * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php + * @access public + * @param string $str multi-byte text to wrap encode + * @return string + */ + public function Base64EncodeWrapMB($str) { + $start = "=?".$this->CharSet."?B?"; + $end = "?="; + $encoded = ""; + + $mb_length = mb_strlen($str, $this->CharSet); + // Each line must have length <= 75, including $start and $end + $length = 75 - strlen($start) - strlen($end); + // Average multi-byte ratio + $ratio = $mb_length / strlen($str); + // Base64 has a 4:3 ratio + $offset = $avgLength = floor($length * $ratio * .75); + + for ($i = 0; $i < $mb_length; $i += $offset) { + $lookBack = 0; + + do { + $offset = $avgLength - $lookBack; + $chunk = mb_substr($str, $i, $offset, $this->CharSet); + $chunk = base64_encode($chunk); + $lookBack++; + } + while (strlen($chunk) > $length); + + $encoded .= $chunk . $this->LE; + } + + // Chomp the last linefeed + $encoded = substr($encoded, 0, -strlen($this->LE)); + return $encoded; + } + + /** + * Encode string to quoted-printable. + * Only uses standard PHP, slow, but will always work + * @access public + * @param string $string the text to encode + * @param integer $line_max Number of chars allowed on a line before wrapping + * @return string + */ + public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) { + $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); + $lines = preg_split('/(?:\r\n|\r|\n)/', $input); + $eol = "\r\n"; + $escape = '='; + $output = ''; + while( list(, $line) = each($lines) ) { + $linlen = strlen($line); + $newline = ''; + for($i = 0; $i < $linlen; $i++) { + $c = substr( $line, $i, 1 ); + $dec = ord( $c ); + if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E + $c = '=2E'; + } + if ( $dec == 32 ) { + if ( $i == ( $linlen - 1 ) ) { // convert space at eol only + $c = '=20'; + } else if ( $space_conv ) { + $c = '=20'; + } + } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required + $h2 = floor($dec/16); + $h1 = floor($dec%16); + $c = $escape.$hex[$h2].$hex[$h1]; + } + if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted + $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay + $newline = ''; + // check if newline first character will be point or not + if ( $dec == 46 ) { + $c = '=2E'; + } + } + $newline .= $c; + } // end of for + $output .= $newline.$eol; + } // end of while + return $output; + } + + /** + * Encode string to RFC2045 (6.7) quoted-printable format + * Uses a PHP5 stream filter to do the encoding about 64x faster than the old version + * Also results in same content as you started with after decoding + * @see EncodeQPphp() + * @access public + * @param string $string the text to encode + * @param integer $line_max Number of chars allowed on a line before wrapping + * @param boolean $space_conv Dummy param for compatibility with existing EncodeQP function + * @return string + * @author Marcus Bointon + */ + public function EncodeQP($string, $line_max = 76, $space_conv = false) { + if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3) + return quoted_printable_encode($string); + } + $filters = stream_get_filters(); + if (!in_array('convert.*', $filters)) { //Got convert stream filter? + return $this->EncodeQPphp($string, $line_max, $space_conv); //Fall back to old implementation + } + $fp = fopen('php://temp/', 'r+'); + $string = preg_replace('/\r\n?/', $this->LE, $string); //Normalise line breaks + $params = array('line-length' => $line_max, 'line-break-chars' => $this->LE); + $s = stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params); + fputs($fp, $string); + rewind($fp); + $out = stream_get_contents($fp); + stream_filter_remove($s); + $out = preg_replace('/^\./m', '=2E', $out); //Encode . if it is first char on a line, workaround for bug in Exchange + fclose($fp); + return $out; + } + + /** + * Encode string to q encoding. + * @link http://tools.ietf.org/html/rfc2047 + * @param string $str the text to encode + * @param string $position Where the text is going to be used, see the RFC for what that means + * @access public + * @return string + */ + public function EncodeQ($str, $position = 'text') { + // There should not be any EOL in the string + $encoded = preg_replace('/[\r\n]*/', '', $str); + + switch (strtolower($position)) { + case 'phrase': + $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + case 'comment': + $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + case 'text': + default: + // Replace every high ascii, control =, ? and _ characters + //TODO using /e (equivalent to eval()) is probably not a good idea + $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', + "'='.sprintf('%02X', ord(stripslashes('\\1')))", $encoded); + break; + } + + // Replace every spaces to _ (more readable than =20) + $encoded = str_replace(' ', '_', $encoded); + + return $encoded; + } + + /** + * Adds a string or binary attachment (non-filesystem) to the list. + * This method can be used to attach ascii or binary data, + * such as a BLOB record from a database. + * @param string $string String attachment data. + * @param string $filename Name of the attachment. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return void + */ + public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { + // Append to $attachment array + $this->attachment[] = array( + 0 => $string, + 1 => $filename, + 2 => basename($filename), + 3 => $encoding, + 4 => $type, + 5 => true, // isStringAttachment + 6 => 'attachment', + 7 => 0 + ); + } + + /** + * Adds an embedded attachment. This can include images, sounds, and + * just about any other document. Make sure to set the $type to an + * image type. For JPEG images use "image/jpeg" and for GIF images + * use "image/gif". + * @param string $path Path to the attachment. + * @param string $cid Content ID of the attachment. Use this to identify + * the Id for accessing the image in an HTML form. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + + if ( !@is_file($path) ) { + $this->SetError($this->Lang('file_access') . $path); + return false; + } + + $filename = basename($path); + if ( $name == '' ) { + $name = $filename; + } + + // Append to $attachment array + $this->attachment[] = array( + 0 => $path, + 1 => $filename, + 2 => $name, + 3 => $encoding, + 4 => $type, + 5 => false, // isStringAttachment + 6 => 'inline', + 7 => $cid + ); + + return true; + } + + public function AddStringEmbeddedImage($string, $cid, $filename = '', $encoding = 'base64', $type = 'application/octet-stream') { + // Append to $attachment array + $this->attachment[] = array( + 0 => $string, + 1 => $filename, + 2 => basename($filename), + 3 => $encoding, + 4 => $type, + 5 => true, // isStringAttachment + 6 => 'inline', + 7 => $cid + ); + } + + /** + * Returns true if an inline attachment is present. + * @access public + * @return bool + */ + public function InlineImageExists() { + foreach($this->attachment as $attachment) { + if ($attachment[6] == 'inline') { + return true; + } + } + return false; + } + + public function AttachmentExists() { + foreach($this->attachment as $attachment) { + if ($attachment[6] == 'attachment') { + return true; + } + } + return false; + } + + public function AlternativeExists() { + return strlen($this->AltBody)>0; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MESSAGE RESET + ///////////////////////////////////////////////// + + /** + * Clears all recipients assigned in the TO array. Returns void. + * @return void + */ + public function ClearAddresses() { + foreach($this->to as $to) { + unset($this->all_recipients[strtolower($to[0])]); + } + $this->to = array(); + } + + /** + * Clears all recipients assigned in the CC array. Returns void. + * @return void + */ + public function ClearCCs() { + foreach($this->cc as $cc) { + unset($this->all_recipients[strtolower($cc[0])]); + } + $this->cc = array(); + } + + /** + * Clears all recipients assigned in the BCC array. Returns void. + * @return void + */ + public function ClearBCCs() { + foreach($this->bcc as $bcc) { + unset($this->all_recipients[strtolower($bcc[0])]); + } + $this->bcc = array(); + } + + /** + * Clears all recipients assigned in the ReplyTo array. Returns void. + * @return void + */ + public function ClearReplyTos() { + $this->ReplyTo = array(); + } + + /** + * Clears all recipients assigned in the TO, CC and BCC + * array. Returns void. + * @return void + */ + public function ClearAllRecipients() { + $this->to = array(); + $this->cc = array(); + $this->bcc = array(); + $this->all_recipients = array(); + } + + /** + * Clears all previously set filesystem, string, and binary + * attachments. Returns void. + * @return void + */ + public function ClearAttachments() { + $this->attachment = array(); + } + + /** + * Clears all custom headers. Returns void. + * @return void + */ + public function ClearCustomHeaders() { + $this->CustomHeader = array(); + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MISCELLANEOUS + ///////////////////////////////////////////////// + + /** + * Adds the error message to the error container. + * @access protected + * @return void + */ + protected function SetError($msg) { + $this->error_count++; + if ($this->Mailer == 'smtp' and !is_null($this->smtp)) { + $lasterror = $this->smtp->getError(); + if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) { + $msg .= '

    ' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "

    \n"; + } + } + $this->ErrorInfo = $msg; + } + + /** + * Returns the proper RFC 822 formatted date. + * @access public + * @return string + * @static + */ + public static function RFCDate() { + $tz = date('Z'); + $tzs = ($tz < 0) ? '-' : '+'; + $tz = abs($tz); + $tz = (int)($tz/3600)*100 + ($tz%3600)/60; + $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); + + return $result; + } + + /** + * Returns the server hostname or 'localhost.localdomain' if unknown. + * @access protected + * @return string + */ + protected function ServerHostname() { + if (!empty($this->Hostname)) { + $result = $this->Hostname; + } elseif (isset($_SERVER['SERVER_NAME'])) { + $result = $_SERVER['SERVER_NAME']; + } else { + $result = 'localhost.localdomain'; + } + + return $result; + } + + /** + * Returns a message in the appropriate language. + * @access protected + * @return string + */ + protected function Lang($key) { + if(count($this->language) < 1) { + $this->SetLanguage('en'); // set the default language + } + + if(isset($this->language[$key])) { + return $this->language[$key]; + } else { + return 'Language string failed to load: ' . $key; + } + } + + /** + * Returns true if an error occurred. + * @access public + * @return bool + */ + public function IsError() { + return ($this->error_count > 0); + } + + /** + * Changes every end of line from CR or LF to CRLF. + * @access public + * @return string + */ + public function FixEOL($str) { + $str = str_replace("\r\n", "\n", $str); + $str = str_replace("\r", "\n", $str); + $str = str_replace("\n", $this->LE, $str); + return $str; + } + + /** + * Adds a custom header. + * @access public + * @return void + */ + public function AddCustomHeader($custom_header) { + $this->CustomHeader[] = explode(':', $custom_header, 2); + } + + /** + * Evaluates the message and returns modifications for inline images and backgrounds + * @access public + * @return $message + */ + public function MsgHTML($message, $basedir = '') { + preg_match_all("/(src|background)=[\"'](.*)[\"']/Ui", $message, $images); + if(isset($images[2])) { + foreach($images[2] as $i => $url) { + // do not change urls for absolute images (thanks to corvuscorax) + if (!preg_match('#^[A-z]+://#', $url)) { + $filename = basename($url); + $directory = dirname($url); + ($directory == '.') ? $directory='': ''; + $cid = 'cid:' . md5($filename); + $ext = pathinfo($filename, PATHINFO_EXTENSION); + $mimeType = self::_mime_types($ext); + if ( strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; } + if ( strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; } + if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType) ) { + $message = preg_replace("/".$images[1][$i]."=[\"']".preg_quote($url, '/')."[\"']/Ui", $images[1][$i]."=\"".$cid."\"", $message); + } + } + } + } + $this->IsHTML(true); + $this->Body = $message; + if (empty($this->AltBody)) { + $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message))); + if (!empty($textMsg)) { + $this->AltBody = html_entity_decode($textMsg, ENT_QUOTES, $this->CharSet); + } + } + if (empty($this->AltBody)) { + $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n"; + } + return $message; + } + + /** + * Gets the MIME type of the embedded or inline image + * @param string File extension + * @access public + * @return string MIME type of ext + * @static + */ + public static function _mime_types($ext = '') { + $mimes = array( + 'hqx' => 'application/mac-binhex40', + 'cpt' => 'application/mac-compactpro', + 'doc' => 'application/msword', + 'bin' => 'application/macbinary', + 'dms' => 'application/octet-stream', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'exe' => 'application/octet-stream', + 'class' => 'application/octet-stream', + 'psd' => 'application/octet-stream', + 'so' => 'application/octet-stream', + 'sea' => 'application/octet-stream', + 'dll' => 'application/octet-stream', + 'oda' => 'application/oda', + 'pdf' => 'application/pdf', + 'ai' => 'application/postscript', + 'eps' => 'application/postscript', + 'ps' => 'application/postscript', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'mif' => 'application/vnd.mif', + 'xls' => 'application/vnd.ms-excel', + 'ppt' => 'application/vnd.ms-powerpoint', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'dcr' => 'application/x-director', + 'dir' => 'application/x-director', + 'dxr' => 'application/x-director', + 'dvi' => 'application/x-dvi', + 'gtar' => 'application/x-gtar', + 'php' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'phtml' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'js' => 'application/x-javascript', + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'tar' => 'application/x-tar', + 'tgz' => 'application/x-tar', + 'xhtml' => 'application/xhtml+xml', + 'xht' => 'application/xhtml+xml', + 'zip' => 'application/zip', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mpga' => 'audio/mpeg', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'aif' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'ram' => 'audio/x-pn-realaudio', + 'rm' => 'audio/x-pn-realaudio', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'ra' => 'audio/x-realaudio', + 'rv' => 'video/vnd.rn-realvideo', + 'wav' => 'audio/x-wav', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'png' => 'image/png', + 'tiff' => 'image/tiff', + 'tif' => 'image/tiff', + 'css' => 'text/css', + 'html' => 'text/html', + 'htm' => 'text/html', + 'shtml' => 'text/html', + 'txt' => 'text/plain', + 'text' => 'text/plain', + 'log' => 'text/plain', + 'rtx' => 'text/richtext', + 'rtf' => 'text/rtf', + 'xml' => 'text/xml', + 'xsl' => 'text/xml', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpe' => 'video/mpeg', + 'qt' => 'video/quicktime', + 'mov' => 'video/quicktime', + 'avi' => 'video/x-msvideo', + 'movie' => 'video/x-sgi-movie', + 'doc' => 'application/msword', + 'word' => 'application/msword', + 'xl' => 'application/excel', + 'eml' => 'message/rfc822' + ); + return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; + } + + /** + * Set (or reset) Class Objects (variables) + * + * Usage Example: + * $page->set('X-Priority', '3'); + * + * @access public + * @param string $name Parameter Name + * @param mixed $value Parameter Value + * NOTE: will not work with arrays, there are no arrays to set/reset + * @todo Should this not be using __set() magic function? + */ + public function set($name, $value = '') { + try { + if (isset($this->$name) ) { + $this->$name = $value; + } else { + throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL); + } + } catch (Exception $e) { + $this->SetError($e->getMessage()); + if ($e->getCode() == self::STOP_CRITICAL) { + return false; + } + } + return true; + } + + /** + * Strips newlines to prevent header injection. + * @access public + * @param string $str String + * @return string + */ + public function SecureHeader($str) { + $str = str_replace("\r", '', $str); + $str = str_replace("\n", '', $str); + return trim($str); + } + + /** + * Set the private key file and password to sign the message. + * + * @access public + * @param string $key_filename Parameter File Name + * @param string $key_pass Password for private key + */ + public function Sign($cert_filename, $key_filename, $key_pass) { + $this->sign_cert_file = $cert_filename; + $this->sign_key_file = $key_filename; + $this->sign_key_pass = $key_pass; + } + + /** + * Set the private key file and password to sign the message. + * + * @access public + * @param string $key_filename Parameter File Name + * @param string $key_pass Password for private key + */ + public function DKIM_QP($txt) { + $tmp = ''; + $line = ''; + for ($i = 0; $i < strlen($txt); $i++) { + $ord = ord($txt[$i]); + if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) { + $line .= $txt[$i]; + } else { + $line .= "=".sprintf("%02X", $ord); + } + } + return $line; + } + + /** + * Generate DKIM signature + * + * @access public + * @param string $s Header + */ + public function DKIM_Sign($s) { + $privKeyStr = file_get_contents($this->DKIM_private); + if ($this->DKIM_passphrase != '') { + $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); + } else { + $privKey = $privKeyStr; + } + if (openssl_sign($s, $signature, $privKey)) { + return base64_encode($signature); + } + } + + /** + * Generate DKIM Canonicalization Header + * + * @access public + * @param string $s Header + */ + public function DKIM_HeaderC($s) { + $s = preg_replace("/\r\n\s+/", " ", $s); + $lines = explode("\r\n", $s); + foreach ($lines as $key => $line) { + list($heading, $value) = explode(":", $line, 2); + $heading = strtolower($heading); + $value = preg_replace("/\s+/", " ", $value) ; // Compress useless spaces + $lines[$key] = $heading.":".trim($value) ; // Don't forget to remove WSP around the value + } + $s = implode("\r\n", $lines); + return $s; + } + + /** + * Generate DKIM Canonicalization Body + * + * @access public + * @param string $body Message Body + */ + public function DKIM_BodyC($body) { + if ($body == '') return "\r\n"; + // stabilize line endings + $body = str_replace("\r\n", "\n", $body); + $body = str_replace("\n", "\r\n", $body); + // END stabilize line endings + while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") { + $body = substr($body, 0, strlen($body) - 2); + } + return $body; + } + + /** + * Create the DKIM header, body, as new header + * + * @access public + * @param string $headers_line Header lines + * @param string $subject Subject + * @param string $body Body + */ + public function DKIM_Add($headers_line, $subject, $body) { + $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms + $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body + $DKIMquery = 'dns/txt'; // Query method + $DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) + $subject_header = "Subject: $subject"; + $headers = explode($this->LE, $headers_line); + foreach($headers as $header) { + if (strpos($header, 'From:') === 0) { + $from_header = $header; + } elseif (strpos($header, 'To:') === 0) { + $to_header = $header; + } + } + $from = str_replace('|', '=7C', $this->DKIM_QP($from_header)); + $to = str_replace('|', '=7C', $this->DKIM_QP($to_header)); + $subject = str_replace('|', '=7C', $this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable + $body = $this->DKIM_BodyC($body); + $DKIMlen = strlen($body) ; // Length of body + $DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body + $ident = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";"; + $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n". + "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n". + "\th=From:To:Subject;\r\n". + "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n". + "\tz=$from\r\n". + "\t|$to\r\n". + "\t|$subject;\r\n". + "\tbh=" . $DKIMb64 . ";\r\n". + "\tb="; + $toSign = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs); + $signed = $this->DKIM_Sign($toSign); + return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n"; + } + + protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) { + if (!empty($this->action_function) && function_exists($this->action_function)) { + $params = array($isSent, $to, $cc, $bcc, $subject, $body); + call_user_func_array($this->action_function, $params); + } + } +} + +class phpmailerException extends Exception { + public function errorMessage() { + $errorMsg = '' . $this->getMessage() . "
    \n"; + return $errorMsg; + } +} +?> diff --git a/shirts4mike/inc/products.php b/shirts4mike/inc/products.php new file mode 100644 index 0000000..efcf493 --- /dev/null +++ b/shirts4mike/inc/products.php @@ -0,0 +1,75 @@ +"; + $output = $output . ''; + $output = $output . '' . $product['; + $output = $output . "

    View Details

    "; + $output = $output . "
    "; + $output = $output . ""; + + return $output; +} + +$products = array(); +$products[101] = array( + "name" => "Logo Shirt, Red", + "img" => "img/shirts/shirt-101.jpg", + "price" => 18, + "paypal" => "9P7DLECFD4LKE", + "sizes" => array("Small","Medium","Large","X-Large") +); +$products[102] = array( + "name" => "Mike the Frog Shirt, Black", + "img" => "img/shirts/shirt-102.jpg", + "price" => 20, + "paypal" => "SXKPTHN2EES3J", + "sizes" => array("Small","Medium","Large","X-Large") +); +$products[103] = array( + "name" => "Mike the Frog Shirt, Blue", + "img" => "img/shirts/shirt-103.jpg", + "price" => 20, + "paypal" => "7T8LK5WXT5Q9J", + "sizes" => array("Small","Medium","Large","X-Large") +); +$products[104] = array( + "name" => "Logo Shirt, Green", + "img" => "img/shirts/shirt-104.jpg", + "price" => 18, + "paypal" => "YKVL5F87E8PCS", + "sizes" => array("Small","Medium","Large","X-Large") +); +$products[105] = array( + "name" => "Mike the Frog Shirt, Yellow", + "img" => "img/shirts/shirt-105.jpg", + "price" => 25, + "paypal" => "4CLP2SCVYM288", + "sizes" => array("Small","Medium","Large","X-Large") +); +$products[106] = array( + "name" => "Logo Shirt, Gray", + "img" => "img/shirts/shirt-106.jpg", + "price" => 20, + "paypal" => "TNAZ2RGYYJ396", + "sizes" => array("Small","Medium","Large","X-Large") +); +$products[107] = array( + "name" => "Logo Shirt, Teal", + "img" => "img/shirts/shirt-107.jpg", + "price" => 20, + "paypal" => "S5FMPJN6Y2C32", + "sizes" => array("Small","Medium","Large","X-Large") +); +$products[108] = array( + "name" => "Mike the Frog Shirt, Orange", + "img" => "img/shirts/shirt-108.jpg", + "price" => 25, + "paypal" => "JMFK7P7VEHS44", + "sizes" => array("Large","X-Large") +); + +?> \ No newline at end of file diff --git a/shirts4mike/index.php b/shirts4mike/index.php new file mode 100755 index 0000000..1909844 --- /dev/null +++ b/shirts4mike/index.php @@ -0,0 +1,47 @@ + + + +
    + +
    + +

    Mike’s Latest Shirts

    + + +
      + $product) { + $position = $position + 1; + if ($total_products - $position < 4) { + $list_view_html = get_list_view_html($product_id,$product) . $list_view_html; + } + } + echo $list_view_html; + ?> +
    + +
    + +
    + + \ No newline at end of file diff --git a/shirts4mike/receipt/index.php b/shirts4mike/receipt/index.php new file mode 100644 index 0000000..0c6af65 --- /dev/null +++ b/shirts4mike/receipt/index.php @@ -0,0 +1,20 @@ + + +
    + +
    + +

    Thank You!

    + +

    Thank you for your payment. Your transaction has been completed, and a receipt for your purchase has been emailed to you. You may log into your account at www.paypal.com/us to view details of this transaction.

    + +

    Need another shirt already? Visit the Shirts Listing page again.

    + +
    + +
    + + \ No newline at end of file diff --git a/shirts4mike/sass/test.scss b/shirts4mike/sass/test.scss new file mode 100644 index 0000000..e69de29 diff --git a/shirts4mike/shirt/index.php b/shirts4mike/shirt/index.php new file mode 100644 index 0000000..1eb4e3b --- /dev/null +++ b/shirts4mike/shirt/index.php @@ -0,0 +1,64 @@ + + +
    + +
    + + + +
    + + " alt=""> + +
    + +
    + +

    $

    + +
    + + "> + "> + + + + + +
    + + + + +
    + +
    + +

    * All shirts are designed by Mike the Frog.

    + +
    + +
    + +
    + + \ No newline at end of file diff --git a/shirts4mike/shirts/index.php b/shirts4mike/shirts/index.php new file mode 100644 index 0000000..a29fbc2 --- /dev/null +++ b/shirts4mike/shirts/index.php @@ -0,0 +1,23 @@ + + +
    + +
    + +

    Mike’s Full Catalog of Shirts

    + +
      + $product) { + echo get_list_view_html($product_id,$product); + } + ?> +
    + +
    + +
    + + \ No newline at end of file