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


PHP record_adapter类代码示例

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


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

示例1: __construct

 /**
  *
  * @param Application      $app
  * @param record_adapter $record
  * @param databox          $databox
  *
  * @return caption_record
  */
 public function __construct(Application $app, \record_adapter $record, databox $databox)
 {
     $this->app = $app;
     $this->sbas_id = $record->get_sbas_id();
     $this->record = $record;
     $this->databox = $databox;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:15,代码来源:record.php

示例2: generateSubdefPathname

 private function generateSubdefPathname(\record_adapter $record, \databox_subdef $subdef, $oldVersion = null)
 {
     if ($oldVersion) {
         $pathdest = \p4string::addEndSlash(pathinfo($oldVersion, PATHINFO_DIRNAME));
     } else {
         $pathdest = \databox::dispatch($this->filesystem, $subdef->get_path());
     }
     return $pathdest . $record->get_record_id() . '_' . $subdef->get_name() . '.' . $this->getExtensionFromSpec($subdef->getSpecs());
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:9,代码来源:SubdefGenerator.php

示例3: 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

示例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: displayTechnicalDatas

 public function displayTechnicalDatas(Application $app, $sbas_id, $record_id)
 {
     $record = new \record_adapter($app, $sbas_id, $record_id);
     try {
         $document = $record->get_subdef('document');
     } catch (\Exception $e) {
         $document = null;
     }
     return $app['twig']->render('prod/Tooltip/TechnicalDatas.html.twig', ['record' => $record, 'document' => $document]);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:10,代码来源:Tooltip.php

示例6: log

 public function log(record_adapter $record, $action, $final, $comment)
 {
     $sql = 'INSERT INTO log_docs
       (id, log_id, date, record_id, action, final, comment)
       VALUES (null, :log_id, NOW(), :record_id, :action, :final, :comm)';
     $stmt = $this->databox->get_connection()->prepare($sql);
     $params = [':log_id' => $this->get_id(), ':record_id' => $record->get_record_id(), ':action' => $action, ':final' => $final, ':comm' => $comment];
     $stmt->execute($params);
     $stmt->closeCursor();
     return $this;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:11,代码来源:Logger.php

示例7: loadFromString

 /**
  * {@inheritdoc}
  *
  * @return Story
  */
 public static function loadFromString(Application $app, $string)
 {
     $ids = explode('_', $string);
     try {
         $story = new \record_adapter($app, $ids[0], $ids[1]);
     } catch (NotFoundHttpException $e) {
         throw new \InvalidArgumentException('Unable to fetch a story from string');
     }
     if (!$story->is_grouping()) {
         throw new \InvalidArgumentException('Unable to fetch a story from string');
     }
     return new static($story);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:18,代码来源:Story.php

示例8: attachStories

 public function attachStories(Request $request)
 {
     if (!$request->request->get('stories')) {
         throw new BadRequestHttpException('Missing parameters stories');
     }
     $storyWZRepo = $this->getStoryWZRepository();
     $alreadyFixed = $done = 0;
     $stories = $request->request->get('stories', []);
     $user = $this->getAuthenticatedUser();
     $acl = $this->getAclForUser($user);
     $manager = $this->getEntityManager();
     foreach ($stories as $element) {
         $element = explode('_', $element);
         $story = new \record_adapter($this->app, $element[0], $element[1]);
         if (!$story->isStory()) {
             throw new \Exception('You can only attach stories');
         }
         if (!$acl->has_access_to_base($story->get_base_id())) {
             throw new AccessDeniedHttpException('You do not have access to this Story');
         }
         if ($storyWZRepo->findUserStory($this->app, $user, $story)) {
             $alreadyFixed++;
             continue;
         }
         $storyWZ = new StoryWZ();
         $storyWZ->setUser($user);
         $storyWZ->setRecord($story);
         $manager->persist($storyWZ);
         $done++;
     }
     $manager->flush();
     if ($alreadyFixed === 0) {
         if ($done <= 1) {
             $message = $this->app->trans('%quantity% Story attached to the WorkZone', ['%quantity%' => $done]);
         } else {
             $message = $this->app->trans('%quantity% Stories attached to the WorkZone', ['%quantity%' => $done]);
         }
     } else {
         if ($done <= 1) {
             $message = $this->app->trans('%quantity% Story attached to the WorkZone, %quantity_already% already attached', ['%quantity%' => $done, '%quantity_already%' => $alreadyFixed]);
         } else {
             $message = $this->app->trans('%quantity% Stories attached to the WorkZone, %quantity_already% already attached', ['%quantity%' => $done, '%quantity_already%' => $alreadyFixed]);
         }
     }
     if ($request->getRequestFormat() == 'json') {
         return $this->app->json(['success' => true, 'message' => $message]);
     }
     return $this->app->redirectPath('prod_workzone_show');
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:49,代码来源:WorkzoneController.php

示例9: datas

 /**
  *
  * @param  Array   $datas
  * @param  boolean $unread
  * @return Array
  */
 public function datas(array $data, $unread)
 {
     $reason = $data['reason'];
     $account_id = $data['account_id'];
     $sbas_id = $data['sbas_id'];
     $rid = $data['record_id'];
     try {
         $account = Bridge_Account::load_account($this->app, $account_id);
         $record = new record_adapter($this->app, $sbas_id, $rid);
     } catch (\Exception $e) {
         return [];
     }
     $ret = ['text' => $this->app->trans("L'upload concernant le record %title% sur le compte %bridge_name% a echoue pour les raisons suivantes : %reason%", ['%title%' => $record->get_title(), '%bridge_name%' => $account->get_api()->get_connector()->get_name(), '%reason%' => $reason]), 'class' => ''];
     return $ret;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:21,代码来源:bridgeuploadfail.php

示例10: buildResult

 /**
  * @desc build the result from the specified sql
  * @param  array         $champ all the field from the request displayed in a array
  * @param  string        $sql   the request from buildreq
  * @return $this->result
  */
 protected function buildResult(Application $app, $rs)
 {
     $i = 0;
     $pref = parent::getPreff($app, $this->sbas_id);
     foreach ($rs as $row) {
         if ($this->enable_limit && $i > $this->nb_record) {
             break;
         }
         foreach ($this->champ as $column) {
             $this->formatResult($column, $row[$column], $i);
         }
         if (array_key_exists('record_id', $row)) {
             try {
                 $record = new \record_adapter($app, $this->sbas_id, $row['record_id']);
             } catch (\Exception_Record_AdapterNotFound $e) {
                 continue;
             }
             foreach ($pref as $field) {
                 try {
                     $this->result[$i][$field] = $record->get_caption()->get_field($field)->get_serialized_values();
                 } catch (\Exception $e) {
                     $this->result[$i][$field] = '';
                 }
             }
         }
         $i++;
     }
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:34,代码来源:download.php

示例11: testRemoveElementFromStory

 public function testRemoveElementFromStory()
 {
     $story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']);
     $records = [self::$DI['record_1'], self::$DI['record_2']];
     foreach ($records as $record) {
         $story->appendChild($record);
     }
     $totalRecords = $story->get_children()->get_count();
     $n = 0;
     foreach ($records as $record) {
         /* @var $record \record_adapter */
         $route = sprintf("/prod/story/%s/%s/delete/%s/%s/", $story->get_sbas_id(), $story->get_record_id(), $record->get_sbas_id(), $record->get_record_id());
         if ($n % 2 === 0) {
             $crawler = self::$DI['client']->request('POST', $route);
             $response = self::$DI['client']->getResponse();
             $this->assertEquals(302, $response->getStatusCode());
         } else {
             $crawler = self::$DI['client']->request('POST', $route, [], [], ["HTTP_ACCEPT" => "application/json"]);
             $response = self::$DI['client']->getResponse();
             $this->assertEquals(200, $response->getStatusCode());
             $data = json_decode($response->getContent(), true);
             $this->assertTrue($data['success']);
         }
         $n++;
         $this->assertEquals($totalRecords - $n, $story->get_children()->get_count());
     }
     $story->delete();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:28,代码来源:StoryTest.php

示例12: 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

示例13: delete_data_from_cache

 /**
  * Part of the cache_cacheableInterface
  *
  * @param  string        $option
  * @return caption_field
  */
 public function delete_data_from_cache($option = null)
 {
     $this->value = $this->VocabularyId = $this->VocabularyType = null;
     $this->record->delete_data_from_cache(record_adapter::CACHE_TITLE);
     try {
         $this->record->get_caption()->get_field($this->databox_field->get_name())->delete_data_from_cache();
     } catch (\Exception $e) {
     }
     unset(self::$localCache[$this->get_cache_key($option)]);
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:16,代码来源:Value.php

示例14: testRenewUrl

 /**
  * @covers Alchemy\Phrasea\Controller\Prod\Records::renewUrl
  */
 public function testRenewUrl()
 {
     $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']);
     $record = \record_adapter::createFromFile($file, self::$DI['app']);
     $this->XMLHTTPRequest('POST', '/prod/records/renew-url/', ['lst' => $record->get_serialize_key()]);
     $response = self::$DI['client']->getResponse();
     $datas = (array) json_decode($response->getContent());
     $this->assertTrue(count($datas) > 0);
     $record->delete();
     unset($response, $datas, $record);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:14,代码来源:RecordsTest.php

示例15: connect

 public function connect(Application $app)
 {
     $app['controller.datafiles'] = $this;
     $controllers = $app['controllers_factory'];
     $that = $this;
     $controllers->before(function (Request $request) use($app) {
         if (!$app['authentication']->isAuthenticated()) {
             $app->abort(403, sprintf('You are not authorized to access %s', $request->getRequestUri()));
         }
     });
     $controllers->get('/{sbas_id}/{record_id}/{subdef}/', function ($sbas_id, $record_id, $subdef, PhraseaApplication $app) use($that) {
         $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
         $record = new \record_adapter($app, $sbas_id, $record_id);
         $stamp = $watermark = false;
         if ($subdef != 'thumbnail') {
             $all_access = false;
             $subdefStruct = $databox->get_subdef_structure();
             if ($subdefStruct->getSubdefGroup($record->get_type())) {
                 foreach ($subdefStruct->getSubdefGroup($record->get_type()) as $subdefObj) {
                     if ($subdefObj->get_name() == $subdef) {
                         if ($subdefObj->get_class() == 'thumbnail') {
                             $all_access = true;
                         }
                         break;
                     }
                 }
             }
             if (!$record->has_subdef($subdef) || !$record->get_subdef($subdef)->is_physically_present()) {
                 throw new NotFoundHttpException();
             }
             if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_subdef($record, $subdef)) {
                 throw new AccessDeniedHttpException(sprintf('User has not access to subdef %s', $subdef));
             }
             $stamp = false;
             $watermark = !$app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'nowatermark');
             if ($watermark && !$all_access) {
                 $subdef_class = $databox->get_subdef_structure()->get_subdef($record->get_type(), $subdef)->get_class();
                 if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $app['acl']->get($app['authentication']->getUser())->has_preview_grant($record)) {
                     $watermark = false;
                 } elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $app['acl']->get($app['authentication']->getUser())->has_hd_grant($record)) {
                     $watermark = false;
                 }
             }
             if ($watermark && !$all_access) {
                 $repository = $app['EM']->getRepository('Phraseanet:BasketElement');
                 /* @var $repository BasketElementRepository */
                 $ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $app['authentication']->getUser());
                 $ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $app['authentication']->getUser());
                 if ($ValidationByRecord && count($ValidationByRecord) > 0) {
                     $watermark = false;
                 } elseif ($ReceptionByRecord && count($ReceptionByRecord) > 0) {
                     $watermark = false;
                 }
             }
         }
         return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
     })->bind('datafile')->assert('sbas_id', '\\d+')->assert('record_id', '\\d+');
     return $controllers;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:59,代码来源:Datafiles.php


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