예제 #1
0
파일: tree.php 프로젝트: Keneth1212/moodle
 /**
  * Gets information about this tree (including all or selected children) as
  * HTML for display to staff or student.
  *
  * @param bool $not True if there is a NOT in effect
  * @param info $info Information about location of condition tree
  * @param result $result Result object if this is a student display, else null
  * @param bool $root True if this is the root item
  * @param bool $hidden Staff display; true if this tree has show=false (from parent)
  */
 protected function get_full_information_recursive($not, info $info, result $result = null, $root, $hidden = false)
 {
     global $PAGE;
     // Get list of children - either full list, or those which are shown.
     $children = $this->children;
     $staff = true;
     if ($result) {
         $children = $result->filter_nodes($children);
         $staff = false;
     }
     // If no children, return empty string.
     if (!$children) {
         return '';
     }
     list($innernot, $andoperator) = $this->get_logic_flags($not);
     // If there is only one child, don't bother displaying this tree
     // (AND and OR makes no difference). Recurse to the child if a tree,
     // otherwise display directly.
     if (count($children) === 1) {
         $child = reset($children);
         if ($this->root && is_null($result)) {
             if (is_null($this->showchildren)) {
                 $childhidden = !$this->show;
             } else {
                 $childhidden = !$this->showchildren[0];
             }
         } else {
             $childhidden = $hidden;
         }
         if ($child instanceof tree) {
             return $child->get_full_information_recursive($innernot, $info, $result, $root, $childhidden);
         } else {
             if ($root) {
                 $result = $child->get_standalone_description($staff, $innernot, $info);
             } else {
                 $result = $child->get_description($staff, $innernot, $info);
             }
             if ($childhidden) {
                 $result .= ' ' . get_string('hidden_marker', 'availability');
             }
             return $result;
         }
     }
     // Multiple children, so prepare child messages (recursive).
     $items = array();
     $index = 0;
     foreach ($children as $child) {
         // Work out if this node is hidden (staff view only).
         $childhidden = $this->root && is_null($result) && !is_null($this->showchildren) && !$this->showchildren[$index];
         if ($child instanceof tree) {
             $items[] = $child->get_full_information_recursive($innernot, $info, $result, false, $childhidden);
         } else {
             $childdescription = $child->get_description($staff, $innernot, $info);
             if ($childhidden) {
                 $childdescription .= ' ' . get_string('hidden_marker', 'availability');
             }
             $items[] = $childdescription;
         }
         $index++;
     }
     // If showing output to staff, and root is set to hide completely,
     // then include this information in the message.
     if ($this->root) {
         $treehidden = !$this->show && is_null($result);
     } else {
         $treehidden = $hidden;
     }
     // Format output for display.
     $renderer = $PAGE->get_renderer('core', 'availability');
     return $renderer->multiple_messages($root, $andoperator, $treehidden, $items);
 }