Skip to content
......@@ -317,7 +317,7 @@
* actually exists. This list of 'masks' is built in menu_rebuild().
*
* @param $parts
* An array of path parts; for the above example,
* An array of path parts; for the above example,
* array('node', '12345', 'edit').
*
* @return
......@@ -1067,7 +1067,7 @@ function menu_tree_output($tree) {
// the active class accordingly. But local tasks do not appear in menu
// trees, so if the current path is a local task, and this link is its
// tab root, then we have to set the class manually.
if ($data['link']['href'] == $router_item['tab_root_href'] && $data['link']['href'] != $_GET['q']) {
if ($router_item && $data['link']['href'] == $router_item['tab_root_href'] && $data['link']['href'] != $_GET['q']) {
$data['link']['localized_options']['attributes']['class'][] = 'active';
}
......@@ -1500,13 +1500,25 @@ function menu_tree_check_access(&$tree, $node_links = array()) {
$nids = array_keys($node_links);
$select = db_select('node', 'n');
$select->addField('n', 'nid');
$select->condition('n.status', 1);
// When a menu administrator who we know has permission to see unpublished
// nodes is administering the menu, included the unpublished nodes in the
// tree, with a special flag so that the Menu module can label them.
// Otherwise, exclude these nodes from the tree.
if (!empty($GLOBALS['menu_admin']) && user_access('bypass node access')) {
$select->addField('n', 'status');
}
else {
$select->condition('n.status', 1);
}
$select->condition('n.nid', $nids, 'IN');
$select->addTag('node_access');
$nids = $select->execute()->fetchCol();
foreach ($nids as $nid) {
foreach ($node_links[$nid] as $mlid => $link) {
$node_links[$nid][$mlid]['access'] = TRUE;
$node_objects = $select->execute()->fetchAll();
foreach ($node_objects as $node_object) {
foreach ($node_links[$node_object->nid] as $mlid => $link) {
$node_links[$node_object->nid][$mlid]['access'] = TRUE;
if (isset($node_object->status)) {
$node_links[$node_object->nid][$mlid]['node_unpublished'] = !$node_object->status;
}
}
}
}
......@@ -1868,7 +1880,7 @@ function menu_navigation_links($menu_name, $level = 0) {
$router_item = menu_get_item();
$links = array();
foreach ($tree as $item) {
if (!$item['link']['hidden']) {
if ($item['link']['access'] && !$item['link']['hidden']) {
$class = '';
$l = $item['link']['localized_options'];
$l['href'] = $item['link']['href'];
......@@ -2483,6 +2495,9 @@ function menu_link_get_preferred($path = NULL, $selected_menu = NULL) {
// untranslated paths). Afterwards, the most relevant path is picked from
// the menus, ordered by menu preference.
$item = menu_get_item($path);
if ($item === FALSE) {
return FALSE;
}
$path_candidates = array();
// 1. The current item href.
$path_candidates[$item['href']] = $item['href'];
......@@ -2592,7 +2607,7 @@ function menu_get_active_breadcrumb() {
// Don't show a link to the current page in the breadcrumb trail.
$end = end($active_trail);
if ($item['href'] == $end['href']) {
if (is_array($end) && $item['href'] == $end['href']) {
array_pop($active_trail);
}
......@@ -3188,7 +3203,7 @@ function menu_link_save(&$item, $existing_item = array(), $parent_candidates = a
'external' => $item['external'],
'has_children' => $item['has_children'],
'expanded' => $item['expanded'],
'weight' => $item['weight'],
'weight' => (int) $item['weight'],
'module' => $item['module'],
'link_title' => $item['link_title'],
'options' => serialize($item['options']),
......@@ -3252,7 +3267,7 @@ function menu_link_save(&$item, $existing_item = array(), $parent_candidates = a
'external' => $item['external'],
'has_children' => $item['has_children'],
'expanded' => $item['expanded'],
'weight' => $item['weight'],
'weight' => (int) $item['weight'],
'depth' => $item['depth'],
'p1' => $item['p1'],
'p2' => $item['p2'],
......@@ -3891,7 +3906,7 @@ function _menu_router_save($menu, $masks) {
'type' => $item['type'],
'description' => $item['description'],
'position' => $item['position'],
'weight' => $item['weight'],
'weight' => (int) $item['weight'],
'include_file' => $item['include file'],
));
......
......@@ -142,9 +142,10 @@ function system_list($type) {
foreach ($bootstrap_list as $module) {
drupal_get_filename('module', $module->name, $module->filename);
}
// We only return the module names here since module_list() doesn't need
// the filename itself.
$lists['bootstrap'] = array_keys($bootstrap_list);
// Only return module names here since module_list() doesn't need the
// filename itself. Don't use drupal_map_assoc() as that requires common.inc.
$list = array_keys($bootstrap_list);
$lists['bootstrap'] = (!empty($list) ? array_combine($list, $list) : array());
}
// Otherwise build the list for enabled modules and themes.
elseif (!isset($lists['module_enabled'])) {
......
......@@ -164,6 +164,21 @@ public function element($element) {
}
return $this;
}
/**
* Gets the element ID for this pager query.
*
* The element is used to differentiate different pager queries on the same
* page so that they may be operated independently.
*
* @return
* Element ID that is used to differentiate between different pager
* queries.
*/
public function getElement() {
$this->ensureElement();
return $this->element;
}
}
/**
......@@ -321,9 +336,19 @@ function theme_pager($variables) {
$tags = $variables['tags'];
$element = $variables['element'];
$parameters = $variables['parameters'];
$quantity = $variables['quantity'];
$quantity = empty($variables['quantity']) ? 0 : $variables['quantity'];
global $pager_page_array, $pager_total;
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element]) || !isset($pager_total[$element])) {
return;
}
// Nothing to do if there is only one page.
if ($pager_total[$element] <= 1) {
return;
}
// Calculate various markers within this pager piece:
// Middle is used to "center" pages around the current page.
$pager_middle = ceil($quantity / 2);
......@@ -455,6 +480,11 @@ function theme_pager_first($variables) {
global $pager_page_array;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element])) {
return;
}
// If we are anywhere but the first page
if ($pager_page_array[$element] > 0) {
$output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array(0, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters));
......@@ -485,6 +515,11 @@ function theme_pager_previous($variables) {
global $pager_page_array;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element])) {
return;
}
// If we are anywhere but the first page
if ($pager_page_array[$element] > 0) {
$page_new = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array);
......@@ -524,6 +559,11 @@ function theme_pager_next($variables) {
global $pager_page_array, $pager_total;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element]) || !isset($pager_total[$element])) {
return;
}
// If we are anywhere but the last page
if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
$page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
......@@ -560,6 +600,11 @@ function theme_pager_last($variables) {
global $pager_page_array, $pager_total;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element]) || !isset($pager_total[$element])) {
return;
}
// If we are anywhere but the last page
if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
$output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array($pager_total[$element] - 1, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters));
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/vendor/
/phpunit.xml
/.composer.lock
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.