Esempio n. 1
0
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $data = $data->fork();
     if (!empty($this->attributes['menuplugid'])) {
         $menuplugid = $this->attributes['menuplugid'];
         $db = Typeframe::Database();
         $base = substr(Typeframe::CurrentPage()->uri(), STRLEN(TYPEF_WEB_DIR));
         if ($base == '') {
             $base = '/';
         }
         $search = new Model_Nav();
         $search->where('plugid = ?', $menuplugid);
         $search->where('url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR pageid = ?', "~{$base}", "~{$base}/", "/{$base}", "/{$base}/", TYPEF_WEB_DIR . $base, TYPEF_WEB_DIR . $base . '/', Typeframe::CurrentPage()->pageid());
         foreach ($search->select() as $current) {
             $current['url'] = $this->_convertUrl($current['url']);
             $data->set('current', $current);
             $parentid = $current['parent'];
             $siblings = new Model_Nav();
             $siblings->where('plugid = ?', $menuplugid);
             $siblings->where('parent = ?', $parentid);
             $siblings->order('sortnum');
             $data['siblings'] = $siblings;
             /*$sibArray = array();
             		foreach ($siblings->select() as $sib) {
             			$sib['url'] = $this->_convertUrl($sib['url']);
             			$sibArray[] = $sib;
             		}
             		$data['siblings'] = $sibArray;*/
             if (!empty($this->attributes['showparent'])) {
                 $parent = $db->execute('SELECT * FROM #__nav WHERE itemid = ' . $parentid);
                 foreach ($parent as $par) {
                     $par['url'] = $this->_convertUrl($par['url']);
                     $data->set('parent', $par);
                 }
             }
             if (!empty($this->attributes['showchildren'])) {
                 $childArray = array();
                 $children = $db->execute('SELECT * FROM #__nav WHERE plugid = ' . $menuplugid . ' AND parent = ' . $current['itemid'] . ' ORDER BY sortnum');
                 foreach ($children as $chi) {
                     $chi['url'] = $this->_convertUrl($chi['url']);
                     $childArray[] = $chi;
                 }
                 $data['children'] = $childArray;
             }
         }
     }
     $this->pluginTemplate = "navigation/submenu.plug.html";
     parent::output($data, $stream);
 }