diff --git a/core/includes/archiver.inc b/core/includes/archiver.inc index 835d46f338d..3ce1173906b 100644 --- a/core/includes/archiver.inc +++ b/core/includes/archiver.inc @@ -51,12 +51,12 @@ interface ArchiverInterface { * @param $files * Optionally specify a list of files to be extracted. Files are * relative to the root of the archive. If not specified, all files - * in the archive will be extracted + * in the archive will be extracted. * * @return ArchiverInterface * The called object. */ - public function extract($path, Array $files = array()); + public function extract($path, array $files = array()); /** * Lists all files in the archive. diff --git a/core/includes/common.inc b/core/includes/common.inc index a4c445f5e77..f840e5c2005 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1850,7 +1850,9 @@ function format_interval($interval, $granularity = 2, $langcode = NULL) { * A UNIX timestamp to format. * @param $type * (optional) The format to use, one of: - * - 'short', 'medium', or 'long' (the corresponding built-in date formats). + * - One of the built-in formats: 'short', 'medium', 'long', 'html_datetime', + * 'html_date', 'html_time', 'html_yearless_date', 'html_week', + * 'html_month', 'html_year'. * - The name of a date type defined by a module in hook_date_format_types(), * if it's been assigned a format. * - The machine name of an administrator-defined date format. @@ -1903,6 +1905,34 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL $format = variable_get('date_format_long', 'l, F j, Y - H:i'); break; + case 'html_datetime': + $format = variable_get('date_format_html_datetime', 'Y-m-d\TH:i:sO'); + break; + + case 'html_date': + $format = variable_get('date_format_html_date', 'Y-m-d'); + break; + + case 'html_time': + $format = variable_get('date_format_html_time', 'H:i:s'); + break; + + case 'html_yearless_date': + $format = variable_get('date_format_html_yearless_date', 'm-d'); + break; + + case 'html_week': + $format = variable_get('date_format_html_week', 'Y-\WW'); + break; + + case 'html_month': + $format = variable_get('date_format_html_month', 'Y-m'); + break; + + case 'html_year': + $format = variable_get('date_format_html_year', 'Y'); + break; + case 'custom': // No change to format. break; @@ -6720,6 +6750,9 @@ function drupal_common_theme() { 'render element' => 'elements', 'template' => 'region', ), + 'datetime' => array( + 'variables' => array('timestamp' => NULL, 'text' => NULL, 'attributes' => array(), 'html' => FALSE), + ), 'status_messages' => array( 'variables' => array('display' => NULL), ), diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 40f9bfee385..84bd0d1e125 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -447,18 +447,10 @@ function menu_get_item($path = NULL, $router_item = NULL) { } $original_map = arg(NULL, $path); - // Since there is no limit to the length of $path, use a hash to keep it - // short yet unique. - $cid = 'menu_item:' . hash('sha256', $path); - if ($cached = cache('menu')->get($cid)) { - $router_item = $cached->data; - } - else { - $parts = array_slice($original_map, 0, MENU_MAX_PARTS); - $ancestors = menu_get_ancestors($parts); - $router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc(); - cache('menu')->set($cid, $router_item); - } + $parts = array_slice($original_map, 0, MENU_MAX_PARTS); + $ancestors = menu_get_ancestors($parts); + $router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc(); + if ($router_item) { // Allow modules to alter the router item before it is translated and // checked for access. diff --git a/core/includes/theme.inc b/core/includes/theme.inc index de695a46ba1..5088c416683 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1474,6 +1474,66 @@ function theme_disable($theme_list) { * @{ */ +/** + * Preprocess variables for theme_datetime(). + */ +function template_preprocess_datetime(&$variables) { + // Format the 'datetime' attribute based on the timestamp. + // @see http://www.w3.org/TR/html5-author/the-time-element.html#attr-time-datetime + if (!isset($variables['attributes']['datetime']) && isset($variables['timestamp'])) { + $variables['attributes']['datetime'] = format_date($variables['timestamp'], 'html_datetime', '', 'UTC'); + } + + // If no text was provided, try to auto-generate it. + if (!isset($variables['text'])) { + // Format and use a human-readable version of the timestamp, if any. + if (isset($variables['timestamp'])) { + $variables['text'] = format_date($variables['timestamp']); + $variables['html'] = FALSE; + } + // Otherwise, use the literal datetime attribute. + elseif (isset($variables['attributes']['datetime'])) { + $variables['text'] = $variables['attributes']['datetime']; + $variables['html'] = FALSE; + } + } +} + +/** + * Returns HTML for a date / time. + * + * @param $variables + * An associative array containing: + * - timestamp: (optional) A UNIX timestamp for the datetime attribute. If the + * datetime cannot be represented as a UNIX timestamp, use a valid datetime + * attribute value in $variables['attributes']['datetime']. + * - text: (optional) The content to display within the