Esempio n. 1
0
 public function RenderFileBrowser($parentId, $link, $basePath = null, $level = 0, $id = 'fileTree', $withRoot = false)
 {
     $links = array();
     $tree = new Model_Page();
     $children = $tree->getChildren($parentId, null, 'name');
     // add a link for site root
     if (isset($withRoot) && $withRoot == true) {
         $links[] = $this->_getSiteRootElement();
     }
     foreach ($children as $child) {
         if ($tree->hasChildren($child)) {
             $newLevel = $level + 1;
             $submenu = $this->view->RenderFileBrowser($child->id, $link, $basePath, $newLevel);
             $icon = 'folder.png';
         } else {
             $icon = 'page_white_text.png';
             $submenu = false;
         }
         if (isset($child->label) && !empty($child->label)) {
             $label = $child->label;
         } else {
             $label = $child->name;
         }
         $links[] = '<li class="menuItem">' . $this->view->link($label, $link . $child->id, $icon) . $submenu . '</li>';
     }
     if (is_array($links)) {
         if ($level == 0) {
             $strId = "id='{$id}'";
         } else {
             $strId = null;
         }
         $filetree = "<ul {$strId}>" . implode(null, $links) . '</ul>';
         return $filetree;
     }
 }
Esempio n. 2
0
 public function RenderFileChecklist($values = array(), $parentId, $level = 0, $id = 'fileChecklist')
 {
     $links = array();
     $page = new Model_Page();
     $children = $page->getChildren($parentId);
     foreach ($children as $child) {
         if ($page->hasChildren($child)) {
             $newLevel = $level + 1;
             $submenu = $this->view->RenderFileChecklist($values, $child->id, $newLevel);
         } else {
             $submenu = false;
         }
         if (in_array($child->id, $values)) {
             $checked = 1;
         } else {
             $checked = 0;
         }
         $checkbox = $this->view->formCheckbox('file_' . $child->id, $checked);
         $links[] = '<li class="page">' . $checkbox . $child->name . $submenu . '</li>';
     }
     if (is_array($links)) {
         if ($level == 0) {
             $strId = "id='{$id}'";
         } else {
             $strId = null;
         }
         $fileChecklist = "<ul {$strId}>" . implode(null, $links) . '</ul>';
         return $fileChecklist;
     }
 }
 public function renderFileChecklist($values = array(), $parentId, $level = 0, $class = 'fileChecklist', $icon = null)
 {
     $links = array();
     $page = new Model_Page();
     $children = $page->getChildren($parentId);
     foreach ($children as $child) {
         $submenu = false;
         if ($page->hasChildren($child)) {
             $newLevel = $level + 1;
             $submenu = $this->view->renderFileChecklist($values, $child->id, $newLevel, $class, $icon);
         }
         // TODO: refactor into Toolbox String - replace empty spaces with underscores for element names only
         $childName = strtolower(str_replace(' ', '_', $child->name));
         $checked = 0;
         if (in_array($childName, $values)) {
             $checked = 1;
         }
         $form = new Digitalus_Form();
         $checkbox = $form->createElement('checkbox', $childName, array('value' => $checked, 'decorators' => array('ViewHelper'), 'belongsTo' => $class));
         $links[] = '<li>' . $checkbox . $this->getIcon($icon, $child->name) . $child->name . $submenu . '</li>';
     }
     $strClass = null;
     if (is_array($links)) {
         if ($level == 0) {
             $strClass = 'class="' . $class . '"';
         }
         $fileChecklist = '<ul ' . $strClass . 'class="treeview">' . implode(null, $links) . '</ul>';
         return $fileChecklist;
     }
 }
Esempio n. 4
0
 /**
  * this function loads the current menu and is run automatically by the constructor
  *
  */
 protected function _load()
 {
     $page = new Model_Page();
     $children = $page->getChildren($this->_parentId);
     if ($children != null && $children->count() > 0) {
         foreach ($children as $child) {
             if ($child->show_on_menu == 1) {
                 $this->items[] = new Digitalus_Menu_Item($child);
             }
         }
     }
 }
 public function renderFileBrowser($parentId, $link, $basePath = null, $level = 0, $id = 'fileTree', $withRoot = false, $current = null, $exclude = null, $translate = true)
 {
     $links = array();
     $tree = new Model_Page();
     $children = $tree->getChildren($parentId);
     // add a link for site root
     if (isset($withRoot) && $withRoot == true) {
         $links[] = $this->_getSiteRootElement();
     }
     foreach ($children as $child) {
         if ($tree->hasChildren($child)) {
             $newLevel = $level + 1;
             $submenu = $this->view->renderFileBrowser($child->id, $link, $basePath, $newLevel, null, null, $current, $exclude);
             $icon = 'folder.png';
             if ($child->id == $current) {
                 $icon = 'folder_wrench.png';
             }
         } else {
             $icon = 'page_white_text.png';
             if ($child->id == $current) {
                 $icon = 'page_white_wrench.png';
             }
             $submenu = false;
         }
         $label = $child->name;
         if ($child->id == $exclude) {
             $links[] = $this->_getExcludeElement($label, $submenu, $icon);
         } else {
             $links[] = '<li class="menuItem">' . $this->view->link($label, $link . $child->id, $icon, null, null, null, $translate) . $submenu . '</li>';
         }
     }
     if (is_array($links)) {
         if ($level == 0) {
             $strId = 'id="' . $id . '"';
         } else {
             $strId = null;
         }
         $filetree = "<ul {$strId}>" . implode(null, $links) . '</ul>';
         return $filetree;
     }
 }