Exemplo n.º 1
0
 /**
  * naplni control optiony
  * @param LBoxFormControlChoose $control
  * @param LBoxConfigItemStructure $root
  * @param string $pre
  */
 protected function fillControlChooseParentID(LBoxFormControlChoose $control, LBoxConfigItemStructure $root = NULL, $pre = "")
 {
     try {
         if (!$root) {
             $control->addOption(new LBoxFormControlOption(0, " "));
         }
         $iterator = $root instanceof LBoxConfigItemStructure ? $root->getChildNodesIterator() : LBoxConfigManagerStructure::getInstance()->getIterator();
         foreach ($iterator as $page) {
             if ($this->getPage() && $page->id == $this->getPage()->id) {
                 continue;
             }
             $control->addOption(new LBoxFormControlOption($page->id, $pre . $page->heading . " - " . $page->url));
             if ($page->hasChildren()) {
                 $this->fillControlChooseParentID($control, $page, "{$pre}    ");
             }
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemplo n.º 2
0
 /**
  * 
  * vytvori novou item pod predaneho parenta
  * @param LBoxConfigItemStructure $parent
  * @param string $urlPart
  */
 public function getCreateChild(LBoxConfigItemStructure $parent, $urlPart = "")
 {
     try {
         if (strlen($urlPart) < 1) {
             throw new LBoxExceptionConfig(LBoxExceptionConfig::MSG_PARAM_STRING_NOTNULL, LBoxExceptionConfig::CODE_BAD_PARAM);
         }
         $url = $parent->url . "/" . $urlPart . "/";
         $url = preg_replace("/(\\/+)/", "/", $url);
         if ($parent->hasChildren()) {
             $maxId = 0;
             foreach ($parent->getChildNodesIterator() as $child) {
                 $maxId = $child->id > $maxId ? $child->id : $maxId;
             }
             $id = $maxId + 1;
         } else {
             $id = (int) ((string) $parent->id . "001");
             while (array_key_exists($id, $this->cacheNodes)) {
                 $id++;
             }
         }
         $child = $this->getCreateItem($url, $id);
         $parent->appendChild($child);
         return $child;
     } catch (Exception $e) {
         throw $e;
     }
 }