context_condition_bookroot.inc 516 B

12345678910111213141516171819
  1. <?php
  2. /**
  3. * Set the context on the basis of the node type of page's book root.
  4. */
  5. class context_condition_bookroot extends context_condition_node {
  6. function execute($node, $op) {
  7. if ($this->condition_used() && !empty($node->book['bid'])) {
  8. $type = db_select('node')
  9. ->fields('node', array('type'))
  10. ->condition('nid', $node->book['bid'])
  11. ->execute()
  12. ->fetchField();
  13. $book = new stdClass();
  14. $book->type = $type;
  15. parent::execute($book, $op);
  16. }
  17. }
  18. }