示例#1
0
 /**
  * Get the adapter
  *
  * @return  object
  */
 public function adapter()
 {
     if (!$this->_adapter) {
         $this->_adapter = $this->_adapter();
         $this->_adapter->set('thread', $this->get('thread'));
         $this->_adapter->set('parent', $this->get('parent'));
         $this->_adapter->set('post', $this->get('id'));
         if (!$this->get('category')) {
             $category = Category::getInstance($this->get('category_id'));
             $this->set('category', $category->get('alias'));
         }
         $this->_adapter->set('category', $this->get('category'));
         if (!$this->get('section')) {
             $category = Category::getInstance($this->get('category_id'));
             $this->set('section', Section::getInstance($category->get('section_id'))->get('alias'));
         }
         $this->_adapter->set('section', $this->get('section'));
     }
     return $this->_adapter;
 }
示例#2
0
 /**
  * Set and get a specific category
  *
  * @param   mixed  $id Integer or string (ID or alias) for a category
  * @return  object
  */
 public function category($id = null)
 {
     if (!isset($this->_cache['category']) || $id !== null && (int) $this->_cache['category']->get('id') != $id && (string) $this->_cache['category']->get('alias') != $id) {
         $this->_cache['category'] = null;
         if ($this->_cache['categories'] instanceof ItemList) {
             foreach ($this->_cache['categories'] as $key => $category) {
                 if ((int) $category->get('id') == $id || (string) $category->get('alias') == $id) {
                     $this->_cache['category'] = $category;
                     break;
                 }
             }
         }
         if (!$this->_cache['category']) {
         }
         $this->_cache['category'] = Category::getInstance($id, $this->get('id'));
         //, $this->get('scope'), $this->get('scope_id'));
         if (!$this->_cache['category']->exists()) {
             $this->_cache['category']->set('scope', $this->get('scope'));
             $this->_cache['category']->set('scope_id', $this->get('scope_id'));
         }
         $this->_cache['category']->set('section_alias', $this->get('alias'));
     }
     return $this->_cache['category'];
 }