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); }
protected function earlyExecute() { $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = new QubitActor(); // Make root actor the parent of new actors $this->resource->parentId = QubitActor::ROOT_ID; if (isset($this->getRoute()->resource)) { $this->resource = $this->getRoute()->resource; // Check that this isn't the root if (!isset($this->resource->parent)) { $this->forward404(); } // Check user authorization if (!QubitAcl::check($this->resource, 'update')) { QubitAcl::forwardUnauthorized(); } // Add optimistic lock $this->form->setDefault('serialNumber', $this->resource->serialNumber); $this->form->setValidator('serialNumber', new sfValidatorInteger()); $this->form->setWidget('serialNumber', new sfWidgetFormInputHidden()); } else { // Check user authorization against Actor ROOT if (!QubitAcl::check(QubitActor::getById(QubitActor::ROOT_ID), 'create')) { QubitAcl::forwardUnauthorized(); } } $this->form->setDefault('next', $this->request->getReferer()); $this->form->setValidator('next', new sfValidatorString()); $this->form->setWidget('next', new sfWidgetFormInputHidden()); }
public function execute($request) { if (!isset($request->limit)) { $request->limit = sfConfig::get('app_hits_per_page'); } $criteria = new Criteria(); $criteria->add(QubitActor::PARENT_ID, QubitActor::ROOT_ID); // Add criteria to exclude actors that are users or repository objects $criteria = QubitActor::addGetOnlyActorsCriteria($criteria); $fallbackTable = 'QubitActor'; switch ($request->sort) { case 'nameDown': $criteria->addDescendingOrderByColumn('authorized_form_of_name'); break; case 'nameUp': $criteria->addAscendingOrderByColumn('authorized_form_of_name'); break; case 'typeDown': $fallbackTable = 'QubitTerm'; $criteria->addJoin(QubitActor::ENTITY_TYPE_ID, QubitTerm::ID, Criteria::LEFT_JOIN); $criteria->addDescendingOrderByColumn('name'); break; case 'typeUp': $fallbackTable = 'QubitTerm'; $criteria->addJoin(QubitActor::ENTITY_TYPE_ID, QubitTerm::ID, Criteria::LEFT_JOIN); $criteria->addAscendingOrderByColumn('name'); break; case 'updatedDown': $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT); break; case 'updatedUp': $criteria->addAscendingOrderByColumn(QubitObject::UPDATED_AT); break; default: if (!$this->getUser()->isAuthenticated()) { $criteria->addAscendingOrderByColumn('authorized_form_of_name'); } else { $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT); } } // Do source culture fallback $criteria = QubitCultureFallback::addFallbackCriteria($criteria, $fallbackTable); // Page results $this->pager = new QubitPager('QubitActor'); $this->pager->setCriteria($criteria); $this->pager->setMaxPerPage($request->limit); $this->pager->setPage($request->page); }
?> <input class="list" type="hidden" value="<?php echo url_for(array('module' => 'term', 'action' => 'autocomplete', 'taxonomy' => url_for(array(QubitTaxonomy::getById(QubitTaxonomy::PLACE_ID), 'module' => 'taxonomy')))); ?> "/> </div> <div class="form-item"> <?php echo $form->nameAccessPoints->label(__('Name access points (subjects)'))->renderLabel(); ?> <?php echo $form->nameAccessPoints->render(array('class' => 'form-autocomplete')); ?> <?php if (QubitAcl::check(QubitActor::getRoot(), 'create')) { ?> <input class="add" type="hidden" value="<?php echo url_for(array('module' => 'actor', 'action' => 'add')); ?> #authorizedFormOfName"/> <?php } ?> <input class="list" type="hidden" value="<?php echo url_for(array('module' => 'actor', 'action' => 'autocomplete', 'showOnlyActors' => 'true')); ?> "/> </div> </fieldset>
public function __construct() { parent::__construct(); $this->tables[] = Propel::getDatabaseMap(QubitUser::DATABASE_NAME)->getTable(QubitUser::TABLE_NAME); }
public function parse($doc) { require_once sfConfig::get('sf_root_dir') . '/vendor/FluentDOM/FluentDOM.php'; $fd = FluentDOM($doc)->namespaces(array('eac' => 'urn:isbn:1-931666-33-4')); $this->resource->sourceStandard = 'http://eac.staatsbibliothek-berlin.de/schema/cpf.xsd'; $this->resource->descriptionIdentifier = $fd->find('eac:control/eac:recordId')->text(); //$fd->find('eac:control/eac:otherRecordId'); $this->maintenanceStatus = $fd->find('eac:control/eac:maintenanceStatus')->text(); $this->publicationStatus = $fd->find('eac:control/eac:publicationStatus')->text(); // TODO <descriptiveNote/>, <otherAgencyCode/> $this->resource->institutionResponsibleIdentifier = $fd->find('eac:control/eac:maintenanceAgency/eac:agencyName')->text(); // TODO <descriptiveNote/> foreach ($fd->find('eac:control/eac:languageDeclaration/eac:language/@languageCode') as $node) { $this->resource->language[] = $node->textContent; } foreach ($fd->find('eac:control/eac:languageDeclaration/eac:script/@scriptCode') as $node) { $this->resource->script[] = $node->textContent; } // conventionDeclaration/abbreviation is an identifier, referenced by e.g. // <authorizedForm/> and <alternativeForm/> // // TODO <descriptiveNote/> $this->resource->rules = $fd->find('eac:control/eac:conventionDeclaration/eac:citation')->text(); // TODO <abbreviation/>, <descriptiveNote/> //$fd->find('eac:control/eac:localTypeDeclaration'); // TODO <date/>, <dateRange/>, <term/> //$this->resource->descriptionDetail = $fd->find('eac:control/eac:localControl')->text(); $this->maintenanceHistory = $fd->find('eac:control/eac:maintenanceHistory'); // TODO <descriptiveNote/>, @lastDateTimeVerified $this->resource->sources = $fd->find('eac:control/eac:sources/eac:source/eac:sourceEntry')->text(); // TODO eac:cpfDescription/eac:identity/@identityType $this->resource->corporateBodyIdentifiers = $fd->find('eac:cpfDescription/eac:identity/eac:entityId')->text(); $this->entityType = $fd->find('eac:cpfDescription/eac:identity/eac:entityType')->text(); // TODO <nameEntryParallel/>, <useDates/> $this->resource->authorizedFormOfName = $fd->find('eac:cpfDescription/eac:identity/eac:nameEntry[eac:authorizedForm]/eac:part')->text(); foreach ($fd->find('eac:cpfDescription/eac:identity/eac:nameEntry[not(eac:authorizedForm)]') as $node) { $item = new QubitOtherName(); $item->name = $fd->spawn()->add($node)->find('eac:part')->text(); $item->typeId = QubitTerm::OTHER_FORM_OF_NAME_ID; $this->resource->otherNames[] = $item; } //$fd->find('eac:cpfDescription/eac:identity/eac:nameEntry/eac:authorizedForm'); //$fd->find('eac:cpfDescription/eac:identity/eac:nameEntry/eac:alternativeForm'); //$fd->find('eac:cpfDescription/eac:identity/eac:nameEntry/eac:preferredForm'); // TODO eac:cpfDescription/eac:identity/eac:descriptiveNote $this->existDates = $fd->find('eac:cpfDescription/eac:description/eac:existDates'); // TODO <address/>, <addressLine/>, <date/>, <dateRange/>, <dateSet/>, // <descriptiveNote/>, <placeRole/>, <term/>, @accuracy, @altitude, // @countryCode, @latitude, @longitude, @vocabularySource $this->resource->places = $fd->find('eac:cpfDescription/eac:description/eac:place/eac:placeEntry|eac:cpfDescription/eac:description/eac:places/eac:place/eac:placeEntry')->text(); // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, // <placeEntry/>, <term/> //$fd->find('eac:cpfDescription/eac:description/eac:localDescription'); //$fd->find('eac:cpfDescription/eac:description/eac:localDescriptions'); // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, // <placeEntry/> $this->resource->legalStatus = $fd->find('eac:cpfDescription/eac:description/eac:legalStatus/eac:term|eac:cpfDescription/eac:description/eac:legalStatuses/eac:legalStatus/eac:term')->text(); // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, // <placeEntry/> $this->resource->functions = $fd->find('eac:cpfDescription/eac:description/eac:function/eac:term|eac:cpfDescription/eac:description/eac:functions/eac:function/eac:term|eac:cpfDescription/eac:description/eac:occupation/eac:term|eac:cpfDescription/eac:description/eac:occupations/eac:occupation/eac:term')->text(); //$fd->find('eac:cpfDescription/eac:description/eac:languageUsed'); // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, // <placeEntry/> $this->resource->mandates = $fd->find('eac:cpfDescription/eac:description/eac:mandate/eac:term|eac:cpfDescription/eac:description/eac:mandates/eac:mandate/eac:term')->text(); $this->internalStructures = $fd->find('eac:cpfDescription/eac:description/eac:structureOrGenealogy'); $this->generalContext = $fd->find('eac:cpfDescription/eac:description/eac:generalContext'); // TODO <abstract/>, <chronList/> $this->biogHist = $fd->find('eac:cpfDescription/eac:description/eac:biogHist'); // TODO @lastDateTimeVerified, <date/>, <dateRange/>, <dateSet/>, // <descriptiveNote/>, <placeEntry/> foreach ($fd->find('eac:cpfDescription/eac:relations/eac:cpfRelation') as $node) { $url = preg_replace('/^(?:[^:]+:\\/\\/[^\\/]+)?' . preg_quote(sfContext::getInstance()->request->getPathInfoPrefix(), '/') . '/', null, $node->getAttributeNS('http://www.w3.org/1999/xlink', 'href'), -1, $count); // @href is one of our resources if ($node->hasAttributeNS('http://www.w3.org/1999/xlink', 'href') && 0 < $count) { $params = sfContext::getInstance()->routing->parse($url); $item = $params['_sf_route']->resource; } else { $item = new QubitActor(); $item->authorizedFormOfName = $fd->spawn()->add($node)->find('eac:relationEntry')->text(); // TODO Cascade save through QubitEvent $item->save(); } $relation = new QubitRelation(); $relation->object = $item; $relation->typeId = self::fromCpfRelationType($node->getAttribute('cpfRelationType')); if (0 < count($date = self::parseDates($node))) { $relation->startDate = $date[0][0]; $relation->endDate = $date[count($date) - 1][1]; } // Multiple, non-contiguous dates if (1 < count($date)) { foreach ($date as $key => $value) { $date[$key] = Qubit::renderDate($value[0]) . ' - ' . Qubit::renderDate($value[1]); } $note = new QubitNote(); $note->typeId = QubitTerm::RELATION_NOTE_DATE_ID; $note->scope = 'QubitRelation'; $note->content = implode(', ', $date); $relation->notes[] = $note; } $this->resource->relationsRelatedBysubjectId[] = $relation; } // TODO @lastDateTimeVerified, <date/>, <dateRange/>, <dateSet/>, // <descriptiveNote/>, <placeEntry/> foreach ($fd->find('eac:cpfDescription/eac:relations/eac:resourceRelation') as $node) { $url = preg_replace('/^(?:[^:]+:\\/\\/[^\\/]+)?' . preg_quote(sfContext::getInstance()->request->getPathInfoPrefix(), '/') . '/', null, $node->getAttributeNS('http://www.w3.org/1999/xlink', 'href'), -1, $count); // @href is one of our resources if ($node->hasAttributeNS('http://www.w3.org/1999/xlink', 'href') && 0 < $count) { $params = sfContext::getInstance()->routing->parse($url); $item = $params['_sf_route']->resource; } else { $item = new QubitInformationObject(); $item->parentId = QubitInformationObject::ROOT_ID; $item->title = $fd->spawn()->add($node)->find('eac:relationEntry')->text(); // TODO Cascade save through QubitEvent $item->save(); } $event = new QubitEvent(); $event->informationObject = $item; $event->typeId = self::fromResourceRelationType($node->getAttribute('resourceRelationType')); if (0 < count($date = self::parseDates($node))) { $event->startDate = $date[0][0]; $event->endDate = $date[count($date) - 1][1]; } // Multiple, non-contiguous dates if (1 < count($date)) { foreach ($date as $key => $value) { $date[$key] = Qubit::renderDate($value[0]) . ' - ' . Qubit::renderDate($value[1]); } $event->date = implode(', ', $date); } $this->resource->events[] = $event; } // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, // <placeEntry/>, @lastDateTimeVerified foreach ($fd->find('eac:cpfDescription/eac:relations/eac:functionRelation') as $node) { $url = preg_replace('/^(?:[^:]+:\\/\\/[^\\/]+)?' . preg_quote(sfContext::getInstance()->request->getPathInfoPrefix(), '/') . '/', null, $node->getAttributeNS('http://www.w3.org/1999/xlink', 'href'), -1, $count); // @href is one of our resources if ($node->hasAttributeNS('http://www.w3.org/1999/xlink', 'href') && 0 < $count) { $params = sfContext::getInstance()->routing->parse($url); $item = $params['_sf_route']->resource; } else { $item = new QubitFunction(); $item->authorizedFormOfName = $fd->spawn()->add($node)->find('eac:relationEntry')->text(); // TODO Cascade save through QubitEvent $item->save(); } $relation = new QubitRelation(); $relation->subject = $item; // TODO Set $relation->type by mapping to controlled vocabulary $this->resource->relationsRelatedByobjectId[] = $relation; } // TODO <alternativeSet/> return $this; }
public static function getactorsRelatedByparentIdById($id, array $options = array()) { $criteria = new Criteria(); self::addactorsRelatedByparentIdCriteriaById($criteria, $id); return QubitActor::get($criteria, $options); }
public function doSearch() { $criteria = new Criteria(); $this->sort = $this->request->getParameter('sort', 'updatedDown'); // This join seems to be necessary to avoid cross joining the local table // with the QubitObject table $criteria->addJoin(constant($this->className . '::ID'), QubitObject::ID); switch ($this->form->getValue('className')) { case 'QubitActor': $nameColumn = 'authorized_form_of_name'; $this->nameColumnDisplay = 'Name'; $criteria = QubitActor::addGetOnlyActorsCriteria($criteria); $criteria->add(QubitActor::PARENT_ID, null, Criteria::ISNOTNULL); break; case 'QubitFunction': $nameColumn = 'authorized_form_of_name'; $this->nameColumnDisplay = 'Name'; break; case 'QubitRepository': $nameColumn = 'authorized_form_of_name'; $this->nameColumnDisplay = 'Name'; $criteria = QubitRepository::addGetOnlyRepositoryCriteria($criteria); break; case 'QubitTerm': $nameColumn = 'name'; $this->nameColumnDisplay = 'Name'; $criteria->add(QubitTerm::PARENT_ID, null, Criteria::ISNOTNULL); break; // Default: information object // Default: information object default: $nameColumn = 'title'; $this->nameColumnDisplay = 'Title'; $criteria->add(QubitInformationObject::PARENT_ID, null, Criteria::ISNOTNULL); } if ('QubitInformationObject' == $this->className && 'all' != $this->form->getValue('publicationStatus')) { $criteria->addJoin(QubitObject::ID, QubitStatus::OBJECT_ID); $criteria->add(QubitStatus::STATUS_ID, $this->form->getValue('publicationStatus')); } // End date at midnight if (null != $this->form->getValue('dateEnd')) { $dateEnd = $this->form->getValue('dateEnd') . ' 24:00:00'; } // Add date criteria switch ($dateOf = $this->form->getValue('dateOf')) { case 'CREATED_AT': case 'UPDATED_AT': if (null !== $this->form->getValue('dateStart')) { $criteria->addAnd(constant('QubitObject::' . $dateOf), $this->form->getValue('dateStart'), Criteria::GREATER_EQUAL); } if (isset($dateEnd)) { $criteria->addAnd(constant('QubitObject::' . $dateOf), $dateEnd, Criteria::LESS_EQUAL); } break; default: if (null !== $this->form->getValue('dateStart')) { $c1 = $criteria->getNewCriterion(QubitObject::CREATED_AT, $this->form->getValue('dateStart'), Criteria::GREATER_EQUAL); $c2 = $criteria->getNewCriterion(QubitObject::UPDATED_AT, $this->form->getValue('dateStart'), Criteria::GREATER_EQUAL); $c1->addOr($c2); $criteria->addAnd($c1); } if (isset($dateEnd)) { $c3 = $criteria->getNewCriterion(QubitObject::CREATED_AT, $dateEnd, Criteria::LESS_EQUAL); $c4 = $criteria->getNewCriterion(QubitObject::UPDATED_AT, $dateEnd, Criteria::LESS_EQUAL); $c3->addOr($c4); $criteria->addAnd($c3); } } // Add sort criteria switch ($this->sort) { case 'nameDown': $criteria->addDescendingOrderByColumn($nameColumn); break; case 'nameUp': $criteria->addAscendingOrderByColumn($nameColumn); break; case 'updatedUp': $criteria->addAscendingOrderByColumn(QubitObject::UPDATED_AT); break; case 'updatedDown': default: $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT); } // Add fallback criteria for name if ('nameDown' == $this->sort || 'nameUp' == $this->sort) { $criteria = QubitCultureFallback::addFallbackCriteria($criteria, $this->form->getValue('className')); } // Page results $this->pager = new QubitPager($this->className); $this->pager->setCriteria($criteria); $this->pager->setMaxPerPage($this->form->getValue('limit')); $this->pager->setPage($this->request->getParameter('page', 1)); }
<?php echo get_partial('addActorDialog', array('basicActions' => $basicActions)); ?> <form method="post" action="<?php echo url_for(array($resource, 'module' => 'aclGroup', 'action' => 'editActorAcl')); ?> " id="editForm"> <?php foreach ($actors as $objectId => $permissions) { ?> <div class="form-item"> <?php echo get_component('aclGroup', 'aclTable', array('object' => QubitActor::getById($objectId), 'permissions' => $permissions, 'actions' => $basicActions)); ?> </div> <?php } ?> <div class="form-item"> <label for="addActorLink"><?php echo __('Add permissions by %1%', array('%1%' => sfConfig::get('app_ui_label_actor'))); ?> </label> <a id="addActorLink" href="javascript:myDialog.show()"><?php echo __('Add %1%', array('%1%' => sfConfig::get('app_ui_label_actor'))); ?> </a>
public static function loadData() { $object = new QubitInformationObject(); $object->id = QubitInformationObject::ROOT_ID; $object->save(); $object = new QubitActor(); $object->id = QubitActor::ROOT_ID; $object->save(); $object = new QubitSetting(); $object->name = 'plugins'; $object->value = serialize(array('sfCaribouPlugin', 'sfEhriThemePlugin', 'sfDcPlugin', 'sfEacPlugin', 'sfEadPlugin', 'sfIsaarPlugin', 'sfIsadPlugin', 'sfEhriIsadPlugin', 'sfIsdfPlugin', 'sfIsdiahPlugin', 'sfEhriIsdiahPlugin', 'sfModsPlugin', 'sfRadPlugin', 'sfSkosPlugin')); $object->save(); $dispatcher = sfContext::getInstance()->getEventDispatcher(); $formatter = new sfAnsiColorFormatter(); chdir(sfConfig::get('sf_root_dir')); $loadData = new sfPropelDataLoadTask($dispatcher, $formatter); $loadData->run(); }
/** * Search for an actor by the AUTHORIZED_FORM_OF_NAME i18n column. Optionally * limit search to a specific culture. * * @param string $name search string * @param array $options optional parameters * @return QubitActor found actor */ public static function getByAuthorizedFormOfName($name, $options = array()) { $criteria = new Criteria(); $criteria->addJoin(QubitActor::ID, QubitActorI18n::ID); $criteria->add(QubitActorI18n::AUTHORIZED_FORM_OF_NAME, $name); if (isset($options['culture'])) { $criteria->addAnd(QubitActorI18n::CULTURE, $options['culture']); } return QubitActor::getOne($criteria, $options); }
?> </tr> </thead><tbody> <?php foreach ($acl as $objectId => $actions) { ?> <tr> <td colspan="<?php echo $tableCols; ?> "><strong> <?php if (1 < $objectId) { ?> <?php echo render_title(QubitActor::getById($objectId)); ?> <?php } else { ?> <em><?php echo __('All %1%', array('%1%' => sfConfig::get('app_ui_label_actor'))); ?> </em> <?php } ?> </strong></td> </tr> <?php $row = 0;
public function setActorByName($name, $options) { // Only create an linked Actor if the event or relation type is indicated if (!isset($options['event_type_id']) && !isset($options['relation_type_id'])) { return; } // See if the Actor record already exists, if not create it $criteria = new Criteria(); $criteria->addJoin(QubitActor::ID, QubitActorI18n::ID); $criteria->add(QubitActorI18n::AUTHORIZED_FORM_OF_NAME, $name); if (null === ($actor = QubitActor::getOne($criteria))) { $actor = new QubitActor(); // Make root actor the parent of new actors $actor->parentId = QubitActor::ROOT_ID; $actor->setAuthorizedFormOfName($name); if (isset($options['entity_type_id'])) { // set actor entityTypeId $actor->setEntityTypeId($options['entity_type_id']); } if (isset($options['source'])) { // set actor entityTypeId $actor->setSources($options['source']); } if (isset($options['rules'])) { // set actor entityTypeId $actor->setRules($options['rules']); } if (isset($options['history'])) { $actor->setHistory($options['history']); } $actor->save(); } if (isset($options['event_type_id'])) { // create an event object to link the information object and actor $event = new QubitEvent(); $event->setActorId($actor->id); $event->setTypeId($options['event_type_id']); if (isset($options['dates'])) { $event->setDate($options['dates']); } $this->events[] = $event; } else { if (isset($options['relation_type_id'])) { // only add Actor as name access point if they are not already linked to // an event (i.e. they are not already a "creator", "accumulator", etc.) $existingRelation = false; foreach ($this->events as $existingEvent) { if ($actor->id == $existingEvent->actorId) { $existingRelation = true; break; } } if (!$existingRelation) { $relation = new QubitRelation(); $relation->objectId = $actor->id; $relation->typeId = QubitTerm::NAME_ACCESS_POINT_ID; $this->relationsRelatedBysubjectId[] = $relation; } } } }
/** * @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()); }
public function addCreatorsAndHistory($parameters) { $creators = $histories = array(); $i = 0; $updated = false; // Get array of existing actors $this->getActors(); if (isset($parameters['creatorHistory'])) { $histories = explode('|', $parameters['creatorHistory']); } foreach (explode('|', $parameters['creators']) as $creator) { if (0 == strlen(trim($creator))) { continue; } if (isset($this->actors[$creator])) { $actor = $this->actors[$creator]; } else { $actor = new QubitActor(); $actor->authorizedFormOfName = $creator; $updated = true; // Add to array of existing actors $this->actors[$creator] = $actor; } if (isset($histories[$i])) { $actor->history = $histories[$i]; $updated = true; } if ($updated) { $actor->save(); } $creators[] = $actor; $i++; } return $creators; }
public function save($connection = null) { parent::save($connection); foreach ($this->repositoryI18ns as $repositoryI18n) { $repositoryI18n->id = $this->id; $repositoryI18n->save($connection); } return $this; }