Esempio n. 1
0
 function cache_export($template = false)
 {
     if (!is_object($template) || strtolower(get_class($template)) != 'template') {
         $tpl = new Template('framework/menus/links/' . $this->type . '.tpl');
     } else {
         $tpl = $template->copy();
     }
     $original_tpl = $tpl->copy();
     foreach ($this->elements as $element) {
         $tpl->assign_block_vars('elements', array('DISPLAY' => $element->cache_export($original_tpl->copy())));
     }
     parent::_assign($tpl, LINKS_MENU_ELEMENT__CLASSIC_DISPLAYING);
     $tpl->assign_vars(array('C_MENU' => true, 'C_NEXT_MENU' => $this->depth > 0, 'C_FIRST_MENU' => $this->depth == 0, 'C_HAS_CHILD' => count($this->elements) > 0, 'ID' => '##.#GET_UID#.##', 'ID_VAR' => '##.#GET_UID_VAR#.##'));
     if ($this->depth == 0) {
         $cache_str = parent::cache_export_begin() . '\'.' . var_export($tpl->parse(TEMPLATE_STRING_MODE), true) . '.\'' . parent::cache_export_end();
         $cache_str = str_replace(array('#GET_UID#', '#GET_UID_VAR#', '##'), array('($__uid = get_uid())', '$__uid', '\''), $cache_str);
         return $cache_str;
     }
     return parent::cache_export_begin() . $tpl->parse(TEMPLATE_STRING_MODE) . parent::cache_export_end();
 }
 function cache_export($template)
 {
     parent::_assign($template);
     $template->assign_vars(array('C_LINK' => true));
     return parent::cache_export_begin() . $template->parse(TEMPLATE_STRING_MODE) . parent::cache_export_end();
 }
Esempio n. 3
0
 /**
  * @return string the string to write in the cache file
  */
 public function cache_export($template = false)
 {
     // Get the good Template object
     if (!is_object($template) || !$template instanceof Template) {
         $tpl = new FileTemplate('framework/menus/links/links.tpl');
     } else {
         $tpl = clone $template;
     }
     $original_tpl = clone $tpl;
     // Children assignment
     foreach ($this->elements as $element) {
         // We use a new Tpl to avoid overwrite issues
         $tpl->assign_block_vars('elements', array('DISPLAY' => $element->cache_export(clone $original_tpl)));
     }
     // Menu assignment
     parent::_assign($tpl, LinksMenuElement::LINKS_MENU_ELEMENT__CLASSIC_DISPLAYING);
     $tpl->put_all(array('C_MENU' => true, 'C_NEXT_MENU' => $this->depth > 0, 'C_FIRST_MENU' => $this->depth == 0, 'C_HAS_CHILD' => count($this->elements) > 0, 'DEPTH' => $this->depth, 'ID' => '##.#GET_UID#.##', 'ID_VAR' => '##.#GET_UID_VAR#.##'));
     if ($this->type == self::AUTOMATIC_MENU) {
         $tpl->put_all(array('C_MENU_CONTAINER' => in_array($this->get_block(), array(Menu::BLOCK_POSITION__LEFT, Menu::BLOCK_POSITION__RIGHT)), 'C_MENU_HORIZONTAL' => in_array($this->get_block(), array(Menu::BLOCK_POSITION__HEADER, Menu::BLOCK_POSITION__SUB_HEADER, Menu::BLOCK_POSITION__TOP_CENTRAL, Menu::BLOCK_POSITION__BOTTOM_CENTRAL)), 'C_MENU_VERTICAL' => in_array($this->get_block(), array(Menu::BLOCK_POSITION__LEFT, Menu::BLOCK_POSITION__RIGHT)), 'C_MENU_STATIC' => in_array($this->get_block(), array(Menu::BLOCK_POSITION__TOP_FOOTER, Menu::BLOCK_POSITION__FOOTER)), 'C_MENU_LEFT' => $this->get_block() == Menu::BLOCK_POSITION__LEFT, 'C_MENU_RIGHT' => $this->get_block() == Menu::BLOCK_POSITION__RIGHT));
     } else {
         $tpl->put_all(array('C_MENU_CONTAINER' => in_array($this->get_block(), array(Menu::BLOCK_POSITION__LEFT, Menu::BLOCK_POSITION__RIGHT)), 'C_MENU_HORIZONTAL' => $this->type == self::HORIZONTAL_MENU, 'C_MENU_VERTICAL' => $this->type == self::VERTICAL_MENU, 'C_MENU_STATIC' => $this->type == self::STATIC_MENU, 'C_MENU_LEFT' => $this->get_block() == Menu::BLOCK_POSITION__LEFT, 'C_MENU_RIGHT' => $this->get_block() == Menu::BLOCK_POSITION__RIGHT));
     }
     if ($this->depth == 0) {
         // We protect and unprotect only on the top level
         $cache_str = parent::cache_export_begin() . '\'.' . var_export($tpl->render(), true) . '.\'' . parent::cache_export_end();
         $cache_str = str_replace(array('#GET_UID#', '#GET_UID_VAR#', '##'), array('($__uid = AppContext::get_uid())', '$__uid', '\''), $cache_str);
         return $cache_str;
     }
     return parent::cache_export_begin() . $tpl->render() . parent::cache_export_end();
 }