public static function getInstance() { if (!self::$_instance) { self::$_instance = new sfSympalSearch(); } return self::$_instance; }
private function _executeSearch(sfWebRequest $request) { if ($q = $request->getParameter('q')) { $query = sfSympalSearch::getInstance()->getDoctrineSearchQuery('sfSympalContent', $q); $this->dataGrid = sfSympalDataGrid::create($query)->addColumn('a.title', 'renderer=sympal_search/title label=Search Result'); $this->getResponse()->setTitle(__('Sympal Search / ') . $q); } else { $this->getResponse()->setTitle(__('Sympal Search')); } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); if ($this->configuration instanceof sfApplicationConfiguration && !$options['all']) { $this->sites = Doctrine_Core::getTable('sfSympalSite')->createQuery('s')->where('s.slug = ?', sfConfig::get('sf_app'))->execute(); } else { $this->sites = Doctrine_Core::getTable('sfSympalSite')->createQuery('s')->execute(); } foreach ($this->sites as $site) { $this->logSection('sympal', sprintf('Indexing models for site "%s"', sfConfig::get('sf_app'))); $search = sfSympalSearch::getInstance(); $models = sfSympalConfig::getSearchableModels(); foreach ($models as $model) { $records = Doctrine_Core::getTable($model)->findAll(); $this->logBlock(sprintf('Indexing "%s"', $model), 'INFO'); foreach ($records as $record) { $this->logBlock(sprintf('...%s (%s)', $record->getId(), (string) $record), 'COMMENT'); $search->updateSearchIndex($record); } } } }
public function save(Doctrine_Connection $conn = null) { $result = parent::save($conn); // When a slot is saved and we have some content set lets update the search index if ($this->_contentRenderedFor) { sfSympalSearch::getInstance()->updateSearchIndex($this->_contentRenderedFor); } return $result; }
public function delete(Doctrine_Connection $conn = null) { if ($this->_updateSearchIndex) { $index = sfSympalSearch::getInstance()->getIndex(); foreach ($index->find('pk:' . $this->getId()) as $hit) { $index->delete($hit->id); } } return parent::delete($conn); }
public function getSearchQuery($query) { return sfSympalSearch::getInstance()->getDoctrineSearchQuery($this->getOption('name'), $query); }
public function delete(Doctrine_Connection $conn = null) { if ($this->_updateSearchIndex) { $index = sfSympalSearch::getInstance()->getIndex(); foreach ($index->find('pk:' . $this->getId()) as $hit) { $index->delete($hit->id); } } // delete content from accociated content type table Doctrine_Core::getTable($this->getType()->getName())->findOneByContentId($this->getId())->delete(); return parent::delete($conn); }