Skip to content
Snippets Groups Projects
Commit c97bf911 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2504633 by eiriksm: Fix comments with more than 80 characters per line in BookManager

parent ac7ba212
No related branches found
No related tags found
No related merge requests found
...@@ -200,7 +200,8 @@ public function addFormElements(array $form, FormStateInterface $form_state, Nod ...@@ -200,7 +200,8 @@ public function addFormElements(array $form, FormStateInterface $form_state, Nod
$options = array(); $options = array();
$nid = !$node->isNew() ? $node->id() : 'new'; $nid = !$node->isNew() ? $node->id() : 'new';
if ($node->id() && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) { if ($node->id() && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) {
// This is the top level node in a maximum depth book and thus cannot be moved. // This is the top level node in a maximum depth book and thus cannot be
// moved.
$options[$node->id()] = $node->label(); $options[$node->id()] = $node->label();
} }
else { else {
...@@ -316,8 +317,8 @@ public function getBookParents(array $item, array $parent = array()) { ...@@ -316,8 +317,8 @@ public function getBookParents(array $item, array $parent = array()) {
/** /**
* Builds the parent selection form element for the node form or outline tab. * Builds the parent selection form element for the node form or outline tab.
* *
* This function is also called when generating a new set of options during the * This function is also called when generating a new set of options during
* Ajax callback, so an array is returned that can be used to replace an * the Ajax callback, so an array is returned that can be used to replace an
* existing form element. * existing form element.
* *
* @param array $book_link * @param array $book_link
...@@ -372,9 +373,9 @@ protected function addParentSelectFormElements(array $book_link) { ...@@ -372,9 +373,9 @@ protected function addParentSelectFormElements(array $book_link) {
* Recursively processes and formats book links for getTableOfContents(). * Recursively processes and formats book links for getTableOfContents().
* *
* This helper function recursively modifies the table of contents array for * This helper function recursively modifies the table of contents array for
* each item in the book tree, ignoring items in the exclude array or at a depth * each item in the book tree, ignoring items in the exclude array or at a
* greater than the limit. Truncates titles over thirty characters and appends * depth greater than the limit. Truncates titles over thirty characters and
* an indentation string incremented by depth. * appends an indentation string incremented by depth.
* *
* @param array $tree * @param array $tree
* The data structure of the book's outline tree. Includes hidden links. * The data structure of the book's outline tree. Includes hidden links.
...@@ -382,13 +383,14 @@ protected function addParentSelectFormElements(array $book_link) { ...@@ -382,13 +383,14 @@ protected function addParentSelectFormElements(array $book_link) {
* A string appended to each node title. Increments by '--' per depth * A string appended to each node title. Increments by '--' per depth
* level. * level.
* @param array $toc * @param array $toc
* Reference to the table of contents array. This is modified in place, so the * Reference to the table of contents array. This is modified in place, so
* function does not have a return value. * the function does not have a return value.
* @param array $exclude * @param array $exclude
* Optional array of Node ID values. Any link whose node ID is in this * Optional array of Node ID values. Any link whose node ID is in this
* array will be excluded (along with its children). * array will be excluded (along with its children).
* @param int $depth_limit * @param int $depth_limit
* Any link deeper than this value will be excluded (along with its children). * Any link deeper than this value will be excluded (along with its
* children).
*/ */
protected function recurseTableOfContents(array $tree, $indent, array &$toc, array $exclude, $depth_limit) { protected function recurseTableOfContents(array $tree, $indent, array &$toc, array $exclude, $depth_limit) {
$nids = array(); $nids = array();
...@@ -582,9 +584,9 @@ protected function buildItems(array $tree) { ...@@ -582,9 +584,9 @@ protected function buildItems(array $tree) {
* The Book ID to find links for. * The Book ID to find links for.
* @param array $parameters * @param array $parameters
* (optional) An associative array of build parameters. Possible keys: * (optional) An associative array of build parameters. Possible keys:
* - expanded: An array of parent link ids to return only book links that are * - expanded: An array of parent link ids to return only book links that
* children of one of the plids in this list. If empty, the whole outline * are children of one of the plids in this list. If empty, the whole
* is built, unless 'only_active_trail' is TRUE. * outline is built, unless 'only_active_trail' is TRUE.
* - active_trail: An array of nids, representing the coordinates of the * - active_trail: An array of nids, representing the coordinates of the
* currently active book link. * currently active book link.
* - only_active_trail: Whether to only return links that are in the active * - only_active_trail: Whether to only return links that are in the active
...@@ -907,8 +909,8 @@ public function bookTreeCheckAccess(&$tree, $node_links = array()) { ...@@ -907,8 +909,8 @@ public function bookTreeCheckAccess(&$tree, $node_links = array()) {
// @todo Extract that into its own method. // @todo Extract that into its own method.
$nids = array_keys($node_links); $nids = array_keys($node_links);
// @todo This should be actually filtering on the desired node status field // @todo This should be actually filtering on the desired node status
// language and just fall back to the default language. // field language and just fall back to the default language.
$nids = \Drupal::entityQuery('node') $nids = \Drupal::entityQuery('node')
->condition('nid', $nids, 'IN') ->condition('nid', $nids, 'IN')
->condition('status', 1) ->condition('status', 1)
...@@ -976,8 +978,8 @@ public function bookLinkTranslate(&$link) { ...@@ -976,8 +978,8 @@ public function bookLinkTranslate(&$link) {
* *
* @param array $links * @param array $links
* A flat array of book links that are part of the book. Each array element * A flat array of book links that are part of the book. Each array element
* is an associative array of information about the book link, containing the * is an associative array of information about the book link, containing
* fields from the {book} table. This array must be ordered depth-first. * the fields from the {book} table. This array must be ordered depth-first.
* @param array $parents * @param array $parents
* An array of the node ID values that are in the path from the current * An array of the node ID values that are in the path from the current
* page to the root of the book tree. * page to the root of the book tree.
...@@ -989,10 +991,10 @@ public function bookLinkTranslate(&$link) { ...@@ -989,10 +991,10 @@ public function bookLinkTranslate(&$link) {
* associative array containing: * associative array containing:
* - link: The book link item from $links, with additional element * - link: The book link item from $links, with additional element
* 'in_active_trail' (TRUE if the link ID was in $parents). * 'in_active_trail' (TRUE if the link ID was in $parents).
* - below: An array containing the sub-tree of this item, where each element * - below: An array containing the sub-tree of this item, where each
* is a tree item array with 'link' and 'below' elements. This array will be * element is a tree item array with 'link' and 'below' elements. This
* empty if the book link has no items in its sub-tree having a depth * array will be empty if the book link has no items in its sub-tree
* greater than or equal to $depth. * having a depth greater than or equal to $depth.
*/ */
protected function buildBookOutlineData(array $links, array $parents = array(), $depth = 1) { protected function buildBookOutlineData(array $links, array $parents = array(), $depth = 1) {
// Reverse the array so we can use the more efficient array_pop() function. // Reverse the array so we can use the more efficient array_pop() function.
...@@ -1017,8 +1019,9 @@ protected function buildBookOutlineRecursive(&$links, $parents, $depth) { ...@@ -1017,8 +1019,9 @@ protected function buildBookOutlineRecursive(&$links, $parents, $depth) {
'link' => $item, 'link' => $item,
'below' => array(), 'below' => array(),
); );
// Look ahead to the next link, but leave it on the array so it's available // Look ahead to the next link, but leave it on the array so it's
// to other recursive function calls if we return or build a sub-tree. // available to other recursive function calls if we return or build a
// sub-tree.
$next = end($links); $next = end($links);
// Check whether the next link is the first in a new sub-tree. // Check whether the next link is the first in a new sub-tree.
if ($next && $next['depth'] > $depth) { if ($next && $next['depth'] > $depth) {
...@@ -1048,8 +1051,8 @@ public function bookSubtreeData($link) { ...@@ -1048,8 +1051,8 @@ public function bookSubtreeData($link) {
$tree_cid_cache = \Drupal::cache('data')->get($cid); $tree_cid_cache = \Drupal::cache('data')->get($cid);
if ($tree_cid_cache && $tree_cid_cache->data) { if ($tree_cid_cache && $tree_cid_cache->data) {
// If the cache entry exists, it will just be the cid for the actual data. // If the cache entry exists, it will just be the cid for the actual
// This avoids duplication of large amounts of data. // data. This avoids duplication of large amounts of data.
$cache = \Drupal::cache('data')->get($tree_cid_cache->data); $cache = \Drupal::cache('data')->get($tree_cid_cache->data);
if ($cache && isset($cache->data)) { if ($cache && isset($cache->data)) {
...@@ -1074,7 +1077,8 @@ public function bookSubtreeData($link) { ...@@ -1074,7 +1077,8 @@ public function bookSubtreeData($link) {
if (!\Drupal::cache('data')->get($tree_cid)) { if (!\Drupal::cache('data')->get($tree_cid)) {
\Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, array('bid:' . $link['bid'])); \Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, array('bid:' . $link['bid']));
} }
// Cache the cid of the (shared) data using the book and item-specific cid. // Cache the cid of the (shared) data using the book and item-specific
// cid.
\Drupal::cache('data')->set($cid, $tree_cid, Cache::PERMANENT, array('bid:' . $link['bid'])); \Drupal::cache('data')->set($cid, $tree_cid, Cache::PERMANENT, array('bid:' . $link['bid']));
} }
// Check access for the current user to each item in the tree. // Check access for the current user to each item in the tree.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment