Beispiel #1
0
 /**
  * @param \samson\cms\Navigation $parent
  * @param string $html
  * @param int $level
  * @param int $currentNavID
  * @return string
  */
 public function htmlTree(structure &$parent = null, &$html = '', $level = 0, $currentNavID = 0)
 {
     /** Collection of visited structures to avoid recursion */
     static $visited = array();
     // If we have not visited this structure yet
     if (!isset($visited[$parent->id])) {
         // Store it as visited
         $visited[$parent->id] = $parent->Name;
         // Get structure children
         $children = $parent->children();
         usort($children, array($this, 'strSorting'));
         // If we have children collection for this node
         if (sizeof($children)) {
             // Start html list
             $html .= '<ul>';
             // Iterate all children
             foreach ($children as $child) {
                 if ($child->Active == 1) {
                     // If external view is set
                     if (isset($this->treeTemplate)) {
                         if (!$this->recursion && sizeof($child->children())) {
                             // Start HTML list item and render this view
                             $html .= '<li class="hasChildren" controller = "' . $this->controller . '">';
                         } else {
                             $html .= '<li class="noChildren">';
                         }
                         // Start HTML list item and render this view
                         $html .= m()->view($this->treeTemplate)->parentid($parent->id)->nav_id($currentNavID)->db_structure($child)->output();
                     } else {
                         // Render just structure name
                         $html .= '<li>' . $child->Name;
                     }
                     if ($this->recursion) {
                         // Go deeper in recursion
                         $this->htmlTree($child, $html, $level++, $currentNavID);
                     }
                     // Close HTML list item
                     $html .= '</li>';
                 }
             }
             // Close HTML list
             $html .= '</ul>';
         }
     }
     return $html;
 }
Beispiel #2
0
 /**
  * Override standard view passing
  * @param string $prefix Prefix
  * @param array $restricted Collection of ignored entity fields
  * @return array Filled collection of key => values for view
  */
 public function toView($prefix = '', array $restricted = array())
 {
     return parent::toView($prefix, $restricted = array('parent', 'parents', 'children'));
 }