当前位置: 首页>>代码示例>>PHP>>正文


PHP record_adapter::get_databox方法代码示例

本文整理汇总了PHP中record_adapter::get_databox方法的典型用法代码示例。如果您正苦于以下问题:PHP record_adapter::get_databox方法的具体用法?PHP record_adapter::get_databox怎么用?PHP record_adapter::get_databox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在record_adapter的用法示例。


在下文中一共展示了record_adapter::get_databox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateSubdefs

 public function generateSubdefs(\record_adapter $record, array $wanted_subdefs = null)
 {
     if (null === ($subdefs = $record->get_databox()->get_subdef_structure()->getSubdefGroup($record->get_type()))) {
         $this->logger->info(sprintf('Nothing to do for %s', $record->get_type()));
         return;
     }
     foreach ($subdefs as $subdef) {
         $subdefname = $subdef->get_name();
         if ($wanted_subdefs && !in_array($subdefname, $wanted_subdefs)) {
             continue;
         }
         $pathdest = null;
         if ($record->has_subdef($subdefname) && $record->get_subdef($subdefname)->is_physically_present()) {
             $pathdest = $record->get_subdef($subdefname)->get_pathfile();
             $record->get_subdef($subdefname)->remove_file();
             $this->logger->info(sprintf('Removed old file for %s', $subdefname));
             $record->clearSubdefCache($subdefname);
         }
         $pathdest = $this->generateSubdefPathname($record, $subdef, $pathdest);
         $this->logger->addInfo(sprintf('Generating subdef %s to %s', $subdefname, $pathdest));
         $this->generateSubdef($record, $subdef, $pathdest);
         if ($this->filesystem->exists($pathdest)) {
             $media = $this->mediavorus->guess($pathdest);
             \media_subdef::create($this->app, $record, $subdef->get_name(), $media);
         }
         $record->clearSubdefCache($subdefname);
         $this->app['dispatcher']->dispatch(RecordEvents::SUB_DEFINITION_CREATED, new RecordSubDefinitionCreatedEvent($record, $subdefname));
     }
     return $this;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:30,代码来源:SubdefGenerator.php

示例2: replaceMetadata

 public function replaceMetadata($metadataCollection, \record_adapter $record)
 {
     $metadatas = [];
     $tagnameToFieldnameMapping = [];
     $arrayStructure = iterator_to_array($record->get_databox()->get_meta_structure());
     array_walk($arrayStructure, function ($databoxField) use(&$tagnameToFieldnameMapping) {
         $tagname = $databoxField->get_tag()->getTagname();
         $tagnameToFieldnameMapping[$tagname][] = $databoxField->get_name();
     });
     array_walk($metadataCollection, function (Metadata $metadata) use(&$metadatas, $tagnameToFieldnameMapping) {
         $tagname = $metadata->getTag()->getTagname();
         if (!isset($tagnameToFieldnameMapping[$tagname])) {
             return;
         }
         foreach ($tagnameToFieldnameMapping[$tagname] as $fieldname) {
             if (!isset($metadatas[$fieldname])) {
                 $metadatas[$fieldname] = [];
             }
             $metadatas[$fieldname] = array_merge($metadatas[$fieldname], $metadata->getValue()->asArray());
         }
     });
     $metas = [];
     array_walk($arrayStructure, function (\databox_field $field) use(&$metas, $metadatas, $record) {
         $fieldname = $field->get_name();
         if (!isset($metadatas[$fieldname])) {
             return;
         }
         $values = $metadatas[$fieldname];
         if ($record->get_caption()->has_field($fieldname)) {
             foreach ($record->get_caption()->get_field($fieldname)->get_values() as $value) {
                 $value->delete();
             }
         }
         if ($field->is_multi()) {
             $tmpValues = [];
             foreach ($values as $value) {
                 $tmpValues = array_merge($tmpValues, \caption_field::get_multi_values($value, $field->get_separator()));
             }
             $values = array_unique($tmpValues);
             foreach ($values as $value) {
                 if (trim($value) === '') {
                     continue;
                 }
                 $metas[] = ['meta_struct_id' => $field->get_id(), 'meta_id' => null, 'value' => $value];
             }
         } else {
             $value = array_pop($values);
             if (trim($value) === '') {
                 return;
             }
             $metas[] = ['meta_struct_id' => $field->get_id(), 'meta_id' => null, 'value' => $value];
         }
     });
     if (count($metas) > 0) {
         $record->set_metadatas($metas, true);
     }
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:57,代码来源:PhraseanetMetadataSetter.php

示例3: substitute

 public function substitute(\record_adapter $record, $name, MediaInterface $media)
 {
     $newfilename = $record->get_record_id() . '_0_' . $name . '.' . $media->getFile()->getExtension();
     $subdef_def = false;
     if ($name == 'document') {
         $baseprefs = $record->get_databox()->get_sxml_structure();
         $pathhd = \p4string::addEndSlash((string) $baseprefs->path);
         $filehd = $record->get_record_id() . "_document." . strtolower($media->getFile()->getExtension());
         $pathhd = \databox::dispatch($this->fs, $pathhd);
         $this->fs->copy($media->getFile()->getRealPath(), $pathhd . $filehd, true);
         $subdefFile = $pathhd . $filehd;
         $meta_writable = true;
     } else {
         $type = $record->isStory() ? 'image' : $record->get_type();
         $subdef_def = $record->get_databox()->get_subdef_structure()->get_subdef($type, $name);
         if ($record->has_subdef($name) && $record->get_subdef($name)->is_physically_present()) {
             $path_file_dest = $record->get_subdef($name)->get_pathfile();
             $record->get_subdef($name)->remove_file();
             $record->clearSubdefCache($name);
         } else {
             $path = \databox::dispatch($this->fs, $subdef_def->get_path());
             $this->fs->mkdir($path, 0750);
             $path_file_dest = $path . $newfilename;
         }
         try {
             $this->alchemyst->turnInto($media->getFile()->getRealPath(), $path_file_dest, $subdef_def->getSpecs());
         } catch (MediaAlchemystException $e) {
             return;
         }
         $subdefFile = $path_file_dest;
         $meta_writable = $subdef_def->meta_writeable();
     }
     $this->fs->chmod($subdefFile, 0760);
     $media = $this->mediavorus->guess($subdefFile);
     \media_subdef::create($this->app, $record, $name, $media);
     $record->delete_data_from_cache(\record_adapter::CACHE_SUBDEFS);
     if ($meta_writable) {
         $record->write_metas();
     }
     if ($name == 'document') {
         $record->rebuild_subdefs();
     }
     $this->dispatcher->dispatch(RecordEvents::MEDIA_SUBSTITUTED, new RecordMediaSubstitutedEvent($record));
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:44,代码来源:SubdefSubstituer.php

示例4: logView

 private function logView(\record_adapter $record, Request $request)
 {
     try {
         $logger = $this->getDataboxLogger($record->get_databox());
         $log_id = $logger->get_id();
         $record->log_view($log_id, $request->headers->get('referer', 'NO REFERRER'), $this->app['phraseanet.configuration']['main']['key']);
     } catch (\Exception $e) {
         // Ignore exception
     }
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:10,代码来源:AbstractDelivery.php

示例5: deliverContent

 public function deliverContent(Request $request, \record_adapter $record, $subdef, $watermark, $stamp, Application $app)
 {
     $file = $record->get_subdef($subdef);
     $pathOut = $file->get_pathfile();
     if ($watermark === true && $file->get_type() === \media_subdef::TYPE_IMAGE) {
         $pathOut = \recordutils_image::watermark($app, $file);
     } elseif ($stamp === true && $file->get_type() === \media_subdef::TYPE_IMAGE) {
         $pathOut = \recordutils_image::stamp($app, $file);
     }
     $log_id = null;
     try {
         $logger = $app['phraseanet.logger']($record->get_databox());
         $log_id = $logger->get_id();
         $referrer = 'NO REFERRER';
         if (isset($_SERVER['HTTP_REFERER'])) {
             $referrer = $_SERVER['HTTP_REFERER'];
         }
         $record->log_view($log_id, $referrer, $app['conf']->get(['main', 'key']));
     } catch (\Exception $e) {
     }
     $disposition = $request->query->get('download') ? DeliverDataInterface::DISPOSITION_ATTACHMENT : DeliverDataInterface::DISPOSITION_INLINE;
     $response = $app['phraseanet.file-serve']->deliverFile($pathOut, $file->get_file(), $disposition, $file->get_mime());
     $response->setPrivate();
     /* @var $response \Symfony\Component\HttpFoundation\Response */
     if ($file->getEtag()) {
         $response->setEtag($file->getEtag());
         $response->setLastModified($file->get_modification_date());
     }
     if (false === $record->is_grouping() && $subdef !== 'document') {
         try {
             if ($file->getDataboxSubdef()->get_class() == \databox_subdef::CLASS_THUMBNAIL) {
                 // default expiration is 5 days
                 $expiration = 60 * 60 * 24 * 5;
                 $response->setExpires(new \DateTime(sprintf('+%d seconds', $expiration)));
                 $response->setMaxAge($expiration);
                 $response->setSharedMaxAge($expiration);
                 $response->setPublic();
             }
         } catch (\Exception $e) {
         }
     }
     $response->isNotModified($request);
     return $response;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:44,代码来源:AbstractDelivery.php

示例6: rotate

 /**
  *
  * @param int        $angle
  * @param Alchemyst  $alchemyst
  * @param MediaVorus $mediavorus
  *
  * @return media_subdef
  */
 public function rotate($angle, Alchemyst $alchemyst, MediaVorus $mediavorus)
 {
     if (!$this->is_physically_present()) {
         throw new \Alchemy\Phrasea\Exception\RuntimeException('You can not rotate a substitution');
     }
     $specs = new \MediaAlchemyst\Specification\Image();
     $specs->setRotationAngle($angle);
     try {
         $alchemyst->turnInto($this->get_pathfile(), $this->get_pathfile(), $specs);
     } catch (\MediaAlchemyst\Exception\ExceptionInterface $e) {
         return $this;
     }
     $media = $mediavorus->guess($this->get_pathfile());
     $sql = "UPDATE subdef\n              SET height = :height , width = :width, updated_on = NOW()\n              WHERE record_id = :record_id AND name = :name";
     $params = [':width' => $media->getWidth(), ':height' => $media->getHeight(), ':record_id' => $this->get_record_id(), ':name' => $this->get_name()];
     $stmt = $this->record->get_databox()->get_connection()->prepare($sql);
     $stmt->execute($params);
     $stmt->closeCursor();
     $this->width = $media->getWidth();
     $this->height = $media->getHeight();
     $this->delete_data_from_cache();
     unset($media);
     return $this;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:32,代码来源:subdef.php

示例7: updateRecordStatus

 /**
  * Set new status to selected record
  *
  * @param  \record_adapter $record
  * @param  array           $postStatus
  * @return array|null
  */
 private function updateRecordStatus(\record_adapter $record, array $postStatus)
 {
     $sbasId = $record->get_databox()->get_sbas_id();
     if (isset($postStatus[$sbasId]) && is_array($postStatus[$sbasId])) {
         $postStatus = $postStatus[$sbasId];
         $currentStatus = strrev($record->get_status());
         $newStatus = '';
         foreach (range(0, 31) as $i) {
             $newStatus .= isset($postStatus[$i]) ? $postStatus[$i] ? '1' : '0' : $currentStatus[$i];
         }
         $record->set_binary_status(strrev($newStatus));
         return ['current_status' => $currentStatus, 'new_status' => $newStatus];
     }
     return null;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:22,代码来源:Property.php

示例8: createQueryParams

 private function createQueryParams($query, SearchEngineOptions $options, \record_adapter $record = null)
 {
     $params = ['index' => $this->indexName, 'type' => 'record', 'body' => ['fields' => ['databox_id', 'record_id'], 'sort' => $this->createSortQueryParams($options)]];
     $ESquery = $this->createESQuery($query, $options);
     $filters = $this->createFilters($options);
     if ($record) {
         $filters[] = ['term' => ['_id' => sprintf('%s-%s', $record->get_sbas_id(), $record->get_record_id())]];
         $fields = [];
         foreach ($record->get_databox()->get_meta_structure() as $dbField) {
             $fields['caption.' . $dbField->get_name()] = new \stdClass();
         }
         $params['body']['highlight'] = ["pre_tags" => ["[[em]]"], "post_tags" => ["[[/em]]"], "fields" => $fields];
     }
     if (count($filters) > 0) {
         $ESquery = ['filtered' => ['query' => $ESquery, 'filter' => ['and' => $filters]]];
     }
     $params['body']['query'] = $ESquery;
     return $params;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:19,代码来源:ElasticSearchEngine.php

示例9: editRecord

 protected function editRecord($string2add, \record_adapter &$record, $indexable = true, $business = false)
 {
     $toupdate = [];
     $field = null;
     foreach ($record->get_databox()->get_meta_structure()->get_elements() as $field) {
         if ($indexable !== $field->is_indexable() || $field->isBusiness() !== $business) {
             continue;
         }
         try {
             $values = $record->get_caption()->get_field($field->get_name())->get_values();
             $value = array_pop($values);
             $meta_id = $value->getId();
         } catch (\Exception $e) {
             $meta_id = null;
         }
         $toupdate[$field->get_id()] = ['meta_id' => $meta_id, 'meta_struct_id' => $field->get_id(), 'value' => $string2add];
         break;
     }
     $record->set_metadatas($toupdate);
     return $field;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:21,代码来源:SearchEngineAbstractTest.php

示例10: connect

 public function connect(Application $app)
 {
     $app['controller.prod.story'] = $this;
     $controllers = $app['controllers_factory'];
     $app['firewall']->addMandatoryAuthentication($controllers);
     $controllers->get('/create/', function (Application $app) {
         return $app['twig']->render('prod/Story/Create.html.twig', []);
     })->bind('prod_stories_create');
     $controllers->post('/', function (Application $app, Request $request) {
         /* @var $request \Symfony\Component\HttpFoundation\Request */
         $collection = \collection::get_from_base_id($app, $request->request->get('base_id'));
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($collection->get_base_id(), 'canaddrecord')) {
             throw new AccessDeniedHttpException('You can not create a story on this collection');
         }
         $Story = \record_adapter::createStory($app, $collection);
         $records = RecordsRequest::fromRequest($app, $request, true);
         foreach ($records as $record) {
             if ($Story->hasChild($record)) {
                 continue;
             }
             $Story->appendChild($record);
         }
         $metadatas = [];
         foreach ($collection->get_databox()->get_meta_structure() as $meta) {
             if ($meta->get_thumbtitle()) {
                 $value = $request->request->get('name');
             } else {
                 continue;
             }
             $metadatas[] = ['meta_struct_id' => $meta->get_id(), 'meta_id' => null, 'value' => $value];
             break;
         }
         $Story->set_metadatas($metadatas)->rebuild_subdefs();
         $StoryWZ = new StoryWZ();
         $StoryWZ->setUser($app['authentication']->getUser());
         $StoryWZ->setRecord($Story);
         $app['EM']->persist($StoryWZ);
         $app['EM']->flush();
         if ($request->getRequestFormat() == 'json') {
             $data = ['success' => true, 'message' => $app->trans('Story created'), 'WorkZone' => $StoryWZ->getId(), 'story' => ['sbas_id' => $Story->get_sbas_id(), 'record_id' => $Story->get_record_id()]];
             return $app->json($data);
         } else {
             return $app->redirectPath('prod_stories_story', ['sbas_id' => $StoryWZ->getSbasId(), 'record_id' => $StoryWZ->getRecordId()]);
         }
     })->bind('prod_stories_do_create');
     $controllers->get('/{sbas_id}/{record_id}/', function (Application $app, $sbas_id, $record_id) {
         $Story = new \record_adapter($app, $sbas_id, $record_id);
         $html = $app['twig']->render('prod/WorkZone/Story.html.twig', ['Story' => $Story]);
         return new Response($html);
     })->bind('prod_stories_story')->assert('sbas_id', '\\d+')->assert('record_id', '\\d+');
     $controllers->post('/{sbas_id}/{record_id}/addElements/', function (Application $app, Request $request, $sbas_id, $record_id) {
         $Story = new \record_adapter($app, $sbas_id, $record_id);
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) {
             throw new AccessDeniedHttpException('You can not add document to this Story');
         }
         $n = 0;
         $records = RecordsRequest::fromRequest($app, $request, true);
         foreach ($records as $record) {
             if ($Story->hasChild($record)) {
                 continue;
             }
             $Story->appendChild($record);
             $n++;
         }
         $data = ['success' => true, 'message' => $app->trans('%quantity% records added', ['%quantity%' => $n])];
         if ($request->getRequestFormat() == 'json') {
             return $app->json($data);
         } else {
             return $app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id, 'record_id' => $record_id]);
         }
     })->assert('sbas_id', '\\d+')->assert('record_id', '\\d+');
     $controllers->post('/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/', function (Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id) {
         $Story = new \record_adapter($app, $sbas_id, $record_id);
         $record = new \record_adapter($app, $child_sbas_id, $child_record_id);
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) {
             throw new AccessDeniedHttpException('You can not add document to this Story');
         }
         $Story->removeChild($record);
         $data = ['success' => true, 'message' => $app->trans('Record removed from story')];
         if ($request->getRequestFormat() == 'json') {
             return $app->json($data);
         } else {
             return $app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id, 'record_id' => $record_id]);
         }
     })->bind('prod_stories_story_remove_element')->assert('sbas_id', '\\d+')->assert('record_id', '\\d+')->assert('child_sbas_id', '\\d+')->assert('child_record_id', '\\d+');
     /**
      * Get the Basket reorder form
      */
     $controllers->get('/{sbas_id}/{record_id}/reorder/', function (Application $app, $sbas_id, $record_id) {
         $story = new \record_adapter($app, $sbas_id, $record_id);
         if (!$story->is_grouping()) {
             throw new \Exception('This is not a story');
         }
         return new Response($app['twig']->render('prod/Story/Reorder.html.twig', ['story' => $story]));
     })->bind('prod_stories_story_reorder')->assert('sbas_id', '\\d+')->assert('record_id', '\\d+');
     $controllers->post('/{sbas_id}/{record_id}/reorder/', function (Application $app, $sbas_id, $record_id) {
         $ret = ['success' => false, 'message' => $app->trans('An error occured')];
         try {
             $story = new \record_adapter($app, $sbas_id, $record_id);
             if (!$story->is_grouping()) {
//.........这里部分代码省略.........
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:101,代码来源:Story.php

示例11: removeRecord

 /**
  * {@inheritdoc}
  */
 public function removeRecord(\record_adapter $record)
 {
     $connbas = $record->get_databox()->get_connection();
     $sql = "DELETE FROM prop WHERE record_id = :record_id";
     $stmt = $connbas->prepare($sql);
     $stmt->execute([':record_id' => $record->get_record_id()]);
     $stmt->closeCursor();
     $sql = "DELETE FROM idx WHERE record_id = :record_id";
     $stmt = $connbas->prepare($sql);
     $stmt->execute([':record_id' => $record->get_record_id()]);
     $stmt->closeCursor();
     $sql = "DELETE FROM thit WHERE record_id = :record_id";
     $stmt = $connbas->prepare($sql);
     $stmt->execute([':record_id' => $record->get_record_id()]);
     $stmt->closeCursor();
     unset($stmt, $connbas);
     return $this;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:21,代码来源:PhraseaEngine.php

示例12: create

 public static function create(Application $app, \record_adapter $record, $name, MediaInterface $media)
 {
     $databox = $record->get_databox();
     $connbas = $databox->get_connection();
     $path = $media->getFile()->getPath();
     $newname = $media->getFile()->getFilename();
     $params = [':path' => $path, ':file' => $newname, ':width' => 0, ':height' => 0, ':mime' => $media->getFile()->getMimeType(), ':size' => $media->getFile()->getSize(), ':dispatched' => 1];
     if (method_exists($media, 'getWidth') && null !== $media->getWidth()) {
         $params[':width'] = $media->getWidth();
     }
     if (method_exists($media, 'getHeight') && null !== $media->getHeight()) {
         $params[':height'] = $media->getHeight();
     }
     try {
         $sql = 'SELECT subdef_id FROM subdef
                 WHERE record_id = :record_id AND name = :name';
         $stmt = $connbas->prepare($sql);
         $stmt->execute([':record_id' => $record->get_record_id(), ':name' => $name]);
         $row = $stmt->fetch(PDO::FETCH_ASSOC);
         $stmt->closeCursor();
         if (!$row) {
             throw new \Exception_Media_SubdefNotFound('Require the real one');
         }
         $sql = "UPDATE subdef\n              SET path = :path, file = :file\n                  , width = :width , height = :height, mime = :mime\n                  , size = :size, dispatched = :dispatched, updated_on = NOW()\n              WHERE subdef_id = :subdef_id";
         $params[':subdef_id'] = $row['subdef_id'];
     } catch (\Exception_Media_SubdefNotFound $e) {
         $sql = "INSERT INTO subdef\n              (record_id, name, path, file, width\n                , height, mime, size, dispatched, created_on, updated_on)\n              VALUES (:record_id, :name, :path, :file, :width, :height\n                , :mime, :size, :dispatched, NOW(), NOW())";
         $params[':record_id'] = $record->get_record_id();
         $params[':name'] = $name;
     }
     $stmt = $connbas->prepare($sql);
     $stmt->execute($params);
     $stmt->closeCursor();
     $subdef = new self($app, $record, $name);
     $subdef->delete_data_from_cache();
     if ($subdef->get_permalink() instanceof media_Permalink_Adapter) {
         $subdef->get_permalink()->delete_data_from_cache();
     }
     if ($name === 'thumbnail') {
         $app['phraseanet.thumb-symlinker']->symlink($subdef->get_pathfile());
     }
     unset($media);
     return $subdef;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:44,代码来源:subdef.php

示例13: removeRecord

 /**
  * {@inheritdoc}
  */
 public function removeRecord(\record_adapter $record)
 {
     if (!$this->rt_conn) {
         throw new RuntimeException('Unable to connect to sphinx real-time index');
     }
     $CRCdatabox = $this->CRCdatabox($record->get_databox());
     $indexes = ["metadatas" . $CRCdatabox, "metadatas" . $CRCdatabox . "_stemmed_en", "metadatas" . $CRCdatabox . "_stemmed_fr", "metadatas" . $CRCdatabox . "_stemmed_de", "metadatas" . $CRCdatabox . "_stemmed_nl"];
     $RTindexes = ["metas_realtime" . $CRCdatabox, "metas_realtime_stemmed_fr_" . $CRCdatabox, "metas_realtime_stemmed_en_" . $CRCdatabox, "metas_realtime_stemmed_nl_" . $CRCdatabox, "metas_realtime_stemmed_de_" . $CRCdatabox];
     foreach ($record->get_caption()->get_fields(null, true) as $field) {
         foreach ($field->get_values() as $value) {
             foreach ($indexes as $index) {
                 $this->sphinx->UpdateAttributes($index, ["deleted"], [$value->getId() => [1]]);
             }
             foreach ($RTindexes as $index) {
                 $this->rt_conn->exec("DELETE FROM " . $index . " WHERE id = " . $value->getId());
             }
         }
     }
     $indexes = ["documents" . $CRCdatabox, "documents" . $CRCdatabox . "_stemmed_fr", "documents" . $CRCdatabox . "_stemmed_en", "documents" . $CRCdatabox . "_stemmed_de", "documents" . $CRCdatabox . "_stemmed_nl"];
     $RTindexes = ["docs_realtime" . $CRCdatabox, "docs_realtime_stemmed_fr_" . $CRCdatabox, "docs_realtime_stemmed_en_" . $CRCdatabox, "docs_realtime_stemmed_nl_" . $CRCdatabox, "docs_realtime_stemmed_de_" . $CRCdatabox];
     foreach ($indexes as $index) {
         $this->sphinx->UpdateAttributes($index, ["deleted"], [$record->get_record_id() => [1]]);
     }
     foreach ($RTindexes as $index) {
         $this->rt_conn->exec("DELETE FROM " . $index . " WHERE id = " . $record->get_record_id());
     }
     return $this;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:31,代码来源:SphinxSearchEngine.php

示例14: excerpt

 /**
  * {@inheritdoc}
  */
 public function excerpt($query, $fields, \record_adapter $record, SearchEngineOptions $options = null)
 {
     if (null === $options) {
         $options = new SearchEngineOptions();
     }
     $this->applyOptions($options);
     $index = '';
     // in this case search is done on metas
     if ($options->getFields() || $options->getBusinessFieldsOn()) {
         if ($options->isStemmed() && $options->getLocale()) {
             $index = 'metadatas' . $this->CRCdatabox($record->get_databox()) . '_stemmed_' . $options->getLocale();
         } else {
             $index = 'metadatas' . $this->CRCdatabox($record->get_databox());
         }
     } else {
         if ($options->isStemmed() && $options->getLocale()) {
             $index = 'documents' . $this->CRCdatabox($record->get_databox()) . '_stemmed_' . $options->getLocale();
         } else {
             $index = 'documents' . $this->CRCdatabox($record->get_databox());
         }
     }
     $opts = ['before_match' => "[[em]]", 'after_match' => "[[/em]]"];
     $fields_to_send = [];
     foreach ($fields as $k => $f) {
         $fields_to_send[$k] = $f['value'];
     }
     return $this->sphinx->BuildExcerpts($fields_to_send, $index, $query, $opts);
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:31,代码来源:SphinxSearchEngine.php

示例15: updateMetadatas

 /**
  * Update the metadatas of a record
  *
  * @param \record_adapter $record
  * @param string          $xml
  */
 protected function updateMetadatas(\record_adapter $record, $xml)
 {
     $metas = $record->get_databox()->get_meta_structure();
     $datas = $metadatas = [];
     if (false !== ($sxe = simplexml_load_string($xml))) {
         $fields = $sxe->xpath('/record/description');
         if ($fields && is_array($fields)) {
             foreach ($fields[0] as $fieldname => $value) {
                 $fieldname = trim($fieldname);
                 $value = trim($value);
                 if (null === ($databox_field = $metas->get_element_by_name($fieldname))) {
                     continue;
                 }
                 if ($databox_field->is_multi()) {
                     $new_value = \caption_field::get_multi_values($value, $databox_field->get_separator());
                     if (isset($datas[$databox_field->get_id()])) {
                         $value = array_unique(array_merge($datas[$databox_field->get_id()], $new_value));
                     } else {
                         $value = $new_value;
                     }
                 } else {
                     $new_value = $value;
                     if (isset($datas[$databox_field->get_id()])) {
                         $value = $datas[$databox_field->get_id()] . ' ' . $new_value;
                     } else {
                         $value = $new_value;
                     }
                 }
                 $datas[$databox_field->get_id()] = $value;
             }
         }
     }
     foreach ($datas as $meta_struct_id => $values) {
         if (is_array($values)) {
             foreach ($values as $value) {
                 $metadatas[] = ['meta_struct_id' => $meta_struct_id, 'meta_id' => null, 'value' => $value];
             }
         } else {
             $metadatas[] = ['meta_struct_id' => $meta_struct_id, 'meta_id' => null, 'value' => $values];
         }
     }
     $record->set_metadatas($metadatas, true);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:49,代码来源:Step35.php


注:本文中的record_adapter::get_databox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。