getChildren()) > 0; } public function getPosterity() { return Doctrine::getTable('Page')->createQuery()->where('parent_id = ?', $this->getId())->addOrderBy('priority DESC')->execute(); //return $this->getChildren(); } public function getUrl() { return self::URL_PREFIX . $this->getSlug(); } public function getLink($html_options = array()) { sfLoader::loadHelpers('Url'); return link_to($this->getName(), $this->getUrl(), $html_options); } public function getName() { return $this->_get('title'); } public function isChildSlug($slug) { $result = $this->getTable() ->createQuery() ->where('parent_id = ?', $this->getId()) ->andWhere('slug = ?', $slug) ->fetchOne(); return !($result == false); } public function hasInMenu() { return $this->getInMenu(); } public function getPermission() { return $this->_get('permission'); } /* * Lucene vyhledavani */ public function save(Doctrine_Connection $conn = null) { // ... $ret = parent::save($conn); $this->updateLuceneIndex(); return $ret; } public function updateLuceneIndex() { $index = $this->getTable()->getLuceneIndex(); // remove existing entries foreach ($index->find('pk:'.$this->getId()) as $hit) { $index->delete($hit->id); } $doc = new Zend_Search_Lucene_Document(); // store job primary key to identify it in the search results $doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $this->getId())); // index job fields $doc->addField(Zend_Search_Lucene_Field::UnStored('title', $this->title, 'UTF-8')); $doc->addField(Zend_Search_Lucene_Field::UnStored('introduction', $this->introduction, 'UTF-8')); $doc->addField(Zend_Search_Lucene_Field::UnStored('body', $this->body, 'UTF-8')); // add job to the index $index->addDocument($doc); $index->commit(); } public function getFulltextFields() { return array($this->introduction, $this->body); } public function getMetaDescription($default = false) { $desc = $this->_get('description'); if(empty($desc) && $default) { return $this->getName().', '.substr(trim(strip_tags($this->getBody())), 0, 100); } else { return $desc; } } public function getMetaKeywords() { return $this->getMetaKw(); } public function getPermissionObject() { return Doctrine::getTable('sfGuardPermission')->createQuery() ->addWhere('name =?', $this->getPermission()) ->fetchOne(); } }