You are here

class draggableviews_hierarchy_handler_book in DraggableViews 7.2

Hierarchy

Expanded class hierarchy of draggableviews_hierarchy_handler_book

2 string references to 'draggableviews_hierarchy_handler_book'
draggableviews_book_views_default_views in draggableviews_book/draggableviews_book.views_default.inc
Implements hook_views_default_views().
draggableviews_hierarchy_handler_book.inc in draggableviews_book/handlers/draggableviews_hierarchy_handler_book.inc

File

draggableviews_book/handlers/draggableviews_hierarchy_handler_book.inc, line 15

View source
class draggableviews_hierarchy_handler_book extends draggableviews_hierarchy_handler {
  public function get($field, $index) {
    $row = $field->view->result[$index];
    $parent_mlid = $row->draggableviews_book_plid;
    $parent_link_path = db_query('SELECT link_path FROM {menu_links} WHERE mlid = :mlid', array(
      ':mlid' => $parent_mlid,
    ))
      ->fetchField();
    return !empty($parent_link_path) ? drupal_substr($parent_link_path, 5) : 0;
  }
  public function get_depth($field, $index) {
    $row = $field->view->result[$index];

    // Cache depth of the top parent so we do not recalculate it.
    static $parent_depth;
    if (is_null($parent_depth)) {
      $parent_mlid = $row->draggableviews_book_plid;
      $parent_depth = db_query('SELECT depth FROM {menu_links} WHERE mlid = :mlid', array(
        ':mlid' => $parent_mlid,
      ))
        ->fetchField() + 1;
    }
    return isset($row->draggableviews_book_depth) ? $row->draggableviews_book_depth - $parent_depth : 0;
  }

  // Don't need to set value here as it is done in "weight" handler
  // draggableviews_handler in order to avoid doing multiple identical queries
  // to draggableviews_structure table.
  function set($form_state) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
draggableviews_hierarchy_handler::get_index public function Get "results" array index of and item with specific base field id.
draggableviews_hierarchy_handler::options_form public function Form with settings of the handler.
draggableviews_hierarchy_handler::option_definition public function Settings form default values.
draggableviews_hierarchy_handler_book::get public function Get the parent value. Overrides draggableviews_hierarchy_handler::get
draggableviews_hierarchy_handler_book::get_depth public function
draggableviews_hierarchy_handler_book::set function Save parent value. Overrides draggableviews_hierarchy_handler::set