public function execute($request) { if (!isset($request->limit)) { $request->limit = sfConfig::get('app_hits_per_page'); } if (isset($request->subquery)) { try { // Parse query string $query = QubitSearch::getInstance()->parse($request->subquery); } catch (Exception $e) { $this->error = $e->getMessage(); return; } } else { $this->redirect(array('module' => 'actor', 'action' => 'browse')); } $query->addSubquery(QubitSearch::getInstance()->addTerm('QubitActor', 'className'), true); $query = QubitAcl::searchFilterByResource($query, QubitActor::getById(QubitActor::ROOT_ID)); $this->pager = new QubitArrayPager(); try { $this->pager->hits = QubitSearch::getInstance()->getEngine()->getIndex()->find($query); } catch (Exception $e) { $this->error = $e->getMessage(); return; } $this->pager->setMaxPerPage($request->limit); $this->pager->setPage($request->page); $ids = array(); foreach ($this->pager->getResults() as $hit) { $ids[] = $hit->getDocument()->id; } $criteria = new Criteria(); $criteria->add(QubitActor::ID, $ids, Criteria::IN); $this->actors = QubitActor::get($criteria); }
public static function getactorsRelatedByparentIdById($id, array $options = array()) { $criteria = new Criteria(); self::addactorsRelatedByparentIdCriteriaById($criteria, $id); return QubitActor::get($criteria, $options); }
public static function getAllExceptUsers($options = array()) { //returns all Actor objects except those that are //also an instance of the User class $criteria = new Criteria(); $criteria->add(QubitObject::CLASS_NAME, 'QubitActor'); // sort by name $criteria->addAscendingOrderByColumn('authorized_form_of_name'); // Do fallback $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitActor', $options); return QubitActor::get($criteria); }
public function getActors($options = array()) { $criteria = new Criteria(); $criteria->addJoin(QubitActor::ID, QubitEvent::ACTOR_ID); $criteria->add(QubitEvent::INFORMATION_OBJECT_ID, $this->id); if (isset($options['eventTypeId'])) { $criteria->add(QubitEvent::TYPE_ID, $options['eventTypeId']); } if (isset($options['cultureFallback']) && true === $options['cultureFallback']) { $criteria->addAscendingOrderByColumn('authorized_form_of_name'); $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitActor', $options); } $actors = QubitActor::get($criteria); // allow inheriting actors from ancestors if (isset($options['inherit']) && false !== $options['inherit']) { if (0 === count($actors)) { // Ascend up object hierarchy until an actor is found foreach ($this->getAncestors() as $ancestor) { if (0 !== count($actors = $ancestor->getActors($options))) { break; } } } } return $actors; }
/** * @see xfIndex */ public function qubitPopulate($options) { $conn = Propel::getConnection(); $start = microtime(true); $this->getLogger()->log('Populating index...', $this->getName()); // if we are using an offset to resume from a segfault, optimize the index instead of deleting if (!isset($options['actorOffset']) && !isset($options['ioOffset'])) { $this->getEngine()->erase(); $this->getLogger()->log('Index erased.', $this->getName()); } else { $this->optimize(); } // set buffering and updates to be batched for better performance // NB: not sure why this doesn't work in object scope self::getInstance()->getEngine()->enableBatchMode(); $actorOffset = intval($options['actorOffset']); $ioOffset = intval($options['ioOffset']); // index actors if (-1 < $actorOffset) { // Get count of all actors $sql = 'SELECT COUNT(*) from ' . QubitActor::TABLE_NAME; $rs = $conn->query($sql); $rowcount = $rs->fetchColumn(0); // Get actors (with offset) $criteria = new Criteria(); QubitActor::addSelectColumns($criteria); if (0 < $actorOffset) { $criteria->setOffset($actorOffset); } $actors = QubitActor::get($criteria); // Loop through results, and add to search index foreach ($actors as $key => $actor) { if ($key == 0 && 0 < $actorOffset) { $this->getLogger()->log('Ignoring first ' . $actorOffset . ' actors.'); } self::addActorIndex($actor); $this->getLogger()->log('"' . $actor->__toString() . '" inserted (' . round(microtime(true) - $start, 2) . 's) (' . ($key + $actorOffset + 1) . '/' . $rowcount . ')', $this->getName()); } } else { $this->getLogger()->log('Actors are ignored.'); } // index information objects if (-1 < $ioOffset) { // Get count of all information objects $sql = 'SELECT COUNT(*) from ' . QubitInformationObject::TABLE_NAME; $rs = $conn->query($sql); $rowcount = $rs->fetchColumn(0); // Get info objects (with offset) $criteria = new Criteria(); QubitInformationObject::addSelectColumns($criteria); if (0 < $ioOffset) { $criteria->setOffset($ioOffset); } $informationObjects = QubitInformationObject::get($criteria); // Loop through results, and add to search index foreach ($informationObjects as $key => $informationObject) { if ($key == 0 && 0 < $ioOffset) { $this->getLogger()->log('Ignoring first ' . $ioOffset . ' information objects.'); } if (0 < count($languages = $this->getTranslatedLanguages($informationObject))) { foreach ($languages as $language) { self::addInformationObjectIndex($informationObject, $language, $options); } } $this->getLogger()->log('"' . $informationObject->__toString() . '" inserted (' . round(microtime(true) - $start, 2) . 's) (' . ($key + $ioOffset + 1) . '/' . $rowcount . ')', $this->getName()); } } else { $this->getLogger()->log('Information objects are ignored.'); } $this->getLogger()->log('Index populated in "' . round(microtime(true) - $start, 2) . '" seconds.', $this->getName()); }