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


PHP record_adapter::get_subdefs方法代码示例

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


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

示例1: bootTestCase

 public function bootTestCase()
 {
     $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . "/../../files/iphone_pic.jpg"), self::$DI['collection']);
     self::$recordonbleu = record_adapter::createFromFile($file, self::$DI['app']);
     self::$DI['app']['subdef.generator']->generateSubdefs(self::$recordonbleu);
     foreach (self::$recordonbleu->get_subdefs() as $subdef) {
         if ($subdef->get_name() == 'document') {
             continue;
         }
         if (!self::$objectPresent) {
             self::$objectPresent = $subdef;
             continue;
         }
         if (!self::$objectNotPresent) {
             self::$objectNotPresent = $subdef;
             continue;
         }
     }
     self::$objectNotPresent->remove_file();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:20,代码来源:subdefTest.php

示例2: refresh

 /**
  * @param Application $app
  * @param int         $sbas_id
  *
  * @return cache_databox
  */
 public static function refresh(Application $app, $sbas_id)
 {
     if (self::$refreshing) {
         return;
     }
     self::$refreshing = true;
     $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
     $date = new \DateTime('-3 seconds');
     $last_update = null;
     try {
         $last_update = $app['phraseanet.appbox']->get_data_from_cache('memcached_update_' . $sbas_id);
     } catch (\Exception $e) {
     }
     if ($last_update) {
         $last_update = new \DateTime($last_update);
     } else {
         $last_update = new \DateTime('-10 years');
     }
     if ($date <= $last_update) {
         self::$refreshing = false;
         return;
     }
     $connsbas = $databox->get_connection();
     $sql = 'SELECT type, value FROM memcached WHERE site_id = :site_id';
     $stmt = $connsbas->prepare($sql);
     $stmt->execute([':site_id' => $app['conf']->get('servername')]);
     $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     foreach ($rs as $row) {
         switch ($row['type']) {
             case 'record':
                 $key = 'record_' . $sbas_id . '_' . $row['value'];
                 $databox->delete_data_from_cache($key);
                 $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SUBDEFS;
                 $databox->delete_data_from_cache($key);
                 $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_GROUPING;
                 $databox->delete_data_from_cache($key);
                 $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_MIME;
                 $databox->delete_data_from_cache($key);
                 $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_ORIGINAL_NAME;
                 $databox->delete_data_from_cache($key);
                 $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SHA256;
                 $databox->delete_data_from_cache($key);
                 $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_STATUS;
                 $databox->delete_data_from_cache($key);
                 $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_TECHNICAL_DATAS;
                 $databox->delete_data_from_cache($key);
                 $sql = 'DELETE FROM memcached
           WHERE site_id = :site_id AND type="record" AND value = :value';
                 $params = [':site_id' => $app['conf']->get('servername'), ':value' => $row['value']];
                 $stmt = $connsbas->prepare($sql);
                 $stmt->execute($params);
                 $stmt->closeCursor();
                 $record = new \record_adapter($app, $sbas_id, $row['value']);
                 $record->get_caption()->delete_data_from_cache();
                 foreach ($record->get_subdefs() as $subdef) {
                     $subdef->delete_data_from_cache();
                 }
                 break;
             case 'structure':
                 $app['phraseanet.appbox']->delete_data_from_cache(\appbox::CACHE_LIST_BASES);
                 $app['phraseanet.appbox']->delete_data_from_cache(\appbox::CACHE_SBAS_IDS);
                 $sql = 'DELETE FROM memcached
           WHERE site_id = :site_id AND type="structure" AND value = :value';
                 $params = [':site_id' => $app['conf']->get('servername'), ':value' => $row['value']];
                 $stmt = $connsbas->prepare($sql);
                 $stmt->execute($params);
                 $stmt->closeCursor();
                 break;
         }
     }
     $date = new \DateTime();
     $now = $date->format(DATE_ISO8601);
     $app['phraseanet.appbox']->set_data_to_cache($now, 'memcached_update_' . $sbas_id);
     $conn = $app['phraseanet.appbox']->get_connection();
     $sql = 'UPDATE sitepreff SET memcached_update = :date';
     $stmt = $conn->prepare($sql);
     $stmt->execute([':date' => $now]);
     $stmt->closeCursor();
     self::$refreshing = false;
     return;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:88,代码来源:databox.php

示例3: applyAction

 public function applyAction(Request $request)
 {
     $records = RecordsRequest::fromRequest($this->app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, ['canmodifrecord']);
     $databoxes = $records->databoxes();
     if (count($databoxes) !== 1) {
         throw new \Exception('Unable to edit on multiple databoxes');
     }
     /** @var \databox $databox */
     $databox = reset($databoxes);
     if ($request->request->get('act_option') == 'SAVEGRP' && $request->request->get('newrepresent') && $records->isSingleStory()) {
         try {
             $reg_record = $records->singleStory();
             $newsubdef_reg = new \record_adapter($this->app, $reg_record->get_sbas_id(), $request->request->get('newrepresent'));
             foreach ($newsubdef_reg->get_subdefs() as $name => $value) {
                 if (!in_array($name, ['thumbnail', 'preview'])) {
                     continue;
                 }
                 if ($value->get_type() !== \media_subdef::TYPE_IMAGE) {
                     continue;
                 }
                 $media = $this->app->getMediaFromUri($value->get_pathfile());
                 $this->getSubDefinitionSubstituer()->substitute($reg_record, $name, $media);
                 $this->getDispatcher()->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($reg_record));
                 $this->getDataboxLogger($reg_record->get_databox())->log($reg_record, \Session_Logger::EVENT_SUBSTITUTE, $name == 'document' ? 'HD' : $name, '');
             }
         } catch (\Exception $e) {
         }
     }
     if (!is_array($request->request->get('mds'))) {
         return $this->app->json(['message' => '', 'error' => false]);
     }
     $elements = $records->toArray();
     foreach ($request->request->get('mds') as $rec) {
         try {
             $record = $databox->get_record($rec['record_id']);
         } catch (\Exception $e) {
             continue;
         }
         $key = $record->get_serialize_key();
         if (!array_key_exists($key, $elements)) {
             continue;
         }
         $statbits = $rec['status'];
         $editDirty = $rec['edit'];
         if ($editDirty == '0') {
             $editDirty = false;
         } else {
             $editDirty = true;
         }
         if (isset($rec['metadatas']) && is_array($rec['metadatas'])) {
             $record->set_metadatas($rec['metadatas']);
             $this->getDispatcher()->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($record));
         }
         $newstat = $record->get_status();
         $statbits = ltrim($statbits, 'x');
         if (!in_array($statbits, ['', 'null'])) {
             $mask_and = ltrim(str_replace(['x', '0', '1', 'z'], ['1', 'z', '0', '1'], $statbits), '0');
             if ($mask_and != '') {
                 $newstat = \databox_status::operation_and_not($newstat, $mask_and);
             }
             $mask_or = ltrim(str_replace('x', '0', $statbits), '0');
             if ($mask_or != '') {
                 $newstat = \databox_status::operation_or($newstat, $mask_or);
             }
             $record->set_binary_status($newstat);
         }
         $record->write_metas()->get_collection()->reset_stamp($record->get_record_id());
         if ($statbits != '') {
             $this->getDataboxLogger($databox)->log($record, \Session_Logger::EVENT_STATUS, '', '');
         }
         if ($editDirty) {
             $this->getDataboxLogger($databox)->log($record, \Session_Logger::EVENT_EDIT, '', '');
         }
     }
     return $this->app->json(['success' => true]);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:76,代码来源:EditController.php

示例4: doExport

 protected function doExport(Application $app, Task $task, FtpExport $export)
 {
     $settings = simplexml_load_string($task->getSettings());
     $proxy = (string) $settings->proxy;
     $proxyport = (string) $settings->proxyport;
     $state = "";
     $ftp_server = $export->getAddr();
     $ftp_user_name = $export->getLogin();
     $ftp_user_pass = $export->getPwd();
     $ftpLog = $ftp_user_name . "@" . \p4string::addEndSlash($ftp_server) . $export->getDestfolder();
     if ($export->getCrash() == 0) {
         $line = $this->translator->trans('task::ftp:Etat d\'envoi FTP vers le serveur "%server%" avec le compte "%username%" et pour destination le dossier : "%directory%"', ['%server%' => $ftp_server, '%username%' => $ftp_user_name, '%directory%' => $export->getDestfolder()]) . PHP_EOL;
         $state .= $line;
         $this->log('debug', $line);
     }
     $state .= $line = $this->translator->trans("task::ftp:TENTATIVE no %number%, %date%", ['%number%' => $export->getCrash() + 1, '%date%' => "  (" . date('r') . ")"]) . PHP_EOL;
     $this->log('debug', $line);
     try {
         $ssl = $export->isSsl();
         $ftp_client = $app['phraseanet.ftp.client']($ftp_server, 21, 300, $ssl, $proxy, $proxyport);
         $ftp_client->login($ftp_user_name, $ftp_user_pass);
         if ($export->isPassif()) {
             try {
                 $ftp_client->passive(true);
             } catch (\Exception $e) {
                 $this->log('debug', $e->getMessage());
             }
         }
         if (trim($export->getDestfolder()) != '') {
             try {
                 $ftp_client->chdir($export->getDestFolder());
                 $export->setDestfolder('/' . $export->getDestfolder());
             } catch (\Exception $e) {
                 $this->log('debug', $e->getMessage());
             }
         } else {
             $export->setDestfolder('/');
         }
         if (trim($export->getFoldertocreate()) != '') {
             try {
                 $ftp_client->mkdir($export->getFoldertocreate());
             } catch (\Exception $e) {
                 $this->log('debug', $e->getMessage());
             }
             try {
                 $new_dir = $ftp_client->add_end_slash($export->getDestfolder()) . $export->getFoldertocreate();
                 $ftp_client->chdir($new_dir);
             } catch (\Exception $e) {
                 $this->log('debug', $e->getMessage());
             }
         }
         $obj = [];
         $basefolder = '';
         if (!in_array(trim($export->getDestfolder()), ['.', './', ''])) {
             $basefolder = \p4string::addEndSlash($export->getDestfolder());
         }
         $basefolder .= $export->getFoldertocreate();
         if (in_array(trim($basefolder), ['.', './', ''])) {
             $basefolder = '/';
         }
         foreach ($export->getElements() as $exportElement) {
             if ($exportElement->isDone()) {
                 continue;
             }
             $base_id = $exportElement->getBaseId();
             $record_id = $exportElement->getRecordId();
             $subdef = $exportElement->getSubdef();
             $localfile = null;
             try {
                 $sbas_id = \phrasea::sbasFromBas($app, $base_id);
                 $record = new \record_adapter($app, $sbas_id, $record_id);
                 $sdcaption = $app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_XML, $exportElement->isBusinessfields());
                 $remotefile = $exportElement->getFilename();
                 if ($subdef == 'caption') {
                     $desc = $app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_XML, $exportElement->isBusinessfields());
                     $localfile = sys_get_temp_dir() . '/' . md5($desc . time() . mt_rand());
                     if (file_put_contents($localfile, $desc) === false) {
                         throw new \Exception('Impossible de creer un fichier temporaire');
                     }
                 } elseif ($subdef == 'caption-yaml') {
                     $desc = $app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_YAML, $exportElement->isBusinessfields());
                     $localfile = sys_get_temp_dir() . '/' . md5($desc . time() . mt_rand());
                     if (file_put_contents($localfile, $desc) === false) {
                         throw new \Exception('Impossible de creer un fichier temporaire');
                     }
                 } else {
                     $sd = $record->get_subdefs();
                     if (!$sd || !isset($sd[$subdef])) {
                         continue;
                     }
                     $localfile = $sd[$subdef]->get_pathfile();
                     if (!file_exists($localfile)) {
                         throw new \Exception('Le fichier local n\'existe pas');
                     }
                 }
                 $current_folder = rtrim(str_replace('//', '/', $basefolder . $exportElement->getFolder()), '/');
                 if ($ftp_client->pwd() != $current_folder) {
                     try {
                         $ftp_client->chdir($current_folder);
                     } catch (\Exception $e) {
//.........这里部分代码省略.........
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:101,代码来源:FtpJob.php

示例5: connect


//.........这里部分代码省略.........
         try {
             if ($sbas_id === 0) {
                 throw new \Exception('Invalid sbas_id');
             }
             $VC = VocabularyController::get($app, $vocabulary);
             $databox = $app['phraseanet.appbox']->get_databox($sbas_id);
         } catch (\Exception $e) {
             $datas['message'] = $app->trans('Vocabulary not found');
             return $app->json($datas);
         }
         $query = $request->query->get('query');
         $results = $VC->find($query, $app['authentication']->getUser(), $databox);
         $list = [];
         foreach ($results as $Term) {
             /* @var $Term \Alchemy\Phrasea\Vocabulary\Term */
             $list[] = ['id' => $Term->getId(), 'context' => $Term->getContext(), 'value' => $Term->getValue()];
         }
         $datas['success'] = true;
         $datas['results'] = $list;
         return $app->json($datas);
     });
     $controllers->post('/apply/', function (Application $app, Request $request) {
         $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, ['canmodifrecord']);
         if (count($records->databoxes()) !== 1) {
             throw new \Exception('Unable to edit on multiple databoxes');
         }
         if ($request->request->get('act_option') == 'SAVEGRP' && $request->request->get('newrepresent') && $records->isSingleStory()) {
             try {
                 $reg_record = $records->singleStory();
                 $newsubdef_reg = new \record_adapter($app, $reg_record->get_sbas_id(), $request->request->get('newrepresent'));
                 if ($newsubdef_reg->get_type() !== 'image') {
                     throw new \Exception('A reg image must come from image data');
                 }
                 foreach ($newsubdef_reg->get_subdefs() as $name => $value) {
                     if (!in_array($name, ['thumbnail', 'preview'])) {
                         continue;
                     }
                     $media = $app['mediavorus']->guess($value->get_pathfile());
                     $app['subdef.substituer']->substitute($reg_record, $name, $media);
                     $app['phraseanet.logger']($reg_record->get_databox())->log($reg_record, \Session_Logger::EVENT_SUBSTITUTE, $name == 'document' ? 'HD' : $name, '');
                 }
             } catch (\Exception $e) {
             }
         }
         if (!is_array($request->request->get('mds'))) {
             return $app->json(['message' => '', 'error' => false]);
         }
         $databoxes = $records->databoxes();
         $databox = array_pop($databoxes);
         $meta_struct = $databox->get_meta_structure();
         $write_edit_el = false;
         $date_obj = new \DateTime();
         foreach ($meta_struct->get_elements() as $meta_struct_el) {
             if ($meta_struct_el->get_tag() instanceof TfEditdate) {
                 $write_edit_el = $meta_struct_el;
             }
         }
         $elements = $records->toArray();
         foreach ($request->request->get('mds') as $rec) {
             try {
                 $record = $databox->get_record($rec['record_id']);
             } catch (\Exception $e) {
                 continue;
             }
             $key = $record->get_serialize_key();
             if (!array_key_exists($key, $elements)) {
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:67,代码来源:Edit.php

示例6: doExecute

 /**
  * {@inheritdoc}
  */
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $availableTypes = array('document', 'audio', 'video', 'image', 'flash', 'map');
     $typesOption = $input->getArgument('type');
     $recordsType = explode(',', $typesOption);
     $recordsType = array_filter($recordsType, function ($type) use($availableTypes) {
         return in_array($type, $availableTypes);
     });
     if (count($recordsType) === 0) {
         $output->write(sprintf('Invalid records type provided %s', implode(', ', $availableTypes)));
         return;
     }
     $subdefsOption = $input->getArgument('subdefs');
     $subdefsName = explode(',', $subdefsOption);
     if (count($subdefsOption) === 0) {
         $output->write('No subdef options provided');
         return;
     }
     $sqlCount = "SELECT COUNT(DISTINCT(r.record_id)) AS nb_records" . " FROM record r LEFT JOIN subdef s ON (r.record_id = s.record_id AND s.name IN (?))" . " WHERE r.type IN (?)";
     $types = array(Connection::PARAM_STR_ARRAY, Connection::PARAM_STR_ARRAY);
     $params = array($subdefsName, $recordsType);
     if (null !== ($min = $input->getOption('min_record'))) {
         $sqlCount .= " AND (r.record_id >= ?)";
         $params[] = (int) $min;
         $types[] = \PDO::PARAM_INT;
     }
     if (null !== ($max = $input->getOption('max_record'))) {
         $sqlCount .= " AND (r.record_id <= ?)";
         $params[] = (int) $max;
         $types[] = \PDO::PARAM_INT;
     }
     $substitutionOnly = $input->getOption('substitution-only');
     $withSubstitution = $input->getOption('with-substitution');
     if (false === $withSubstitution) {
         if (true === $substitutionOnly) {
             $sqlCount .= " AND (ISNULL(s.substit) OR s.substit = 1)";
         } else {
             $sqlCount .= " AND (ISNULL(s.substit) OR s.substit = 0)";
         }
     } elseif ($substitutionOnly) {
         throw new InvalidArgumentException('Conflict, you can not ask for --substitution-only && --with-substitution parameters at the same time');
     }
     list($sqlCount, $stmtParams) = SQLParserUtils::expandListParameters($sqlCount, $params, $types);
     $databox = $this->container->findDataboxById($input->getArgument('databox'));
     $output->writeln($sqlCount);
     $connection = $databox->get_connection();
     $stmt = $connection->prepare($sqlCount);
     $stmt->execute($stmtParams);
     $row = $stmt->fetch();
     $totalRecords = $row['nb_records'];
     if ($totalRecords === 0) {
         return;
     }
     /** @var HelperSet $helperSet */
     $helperSet = $this->getHelperSet();
     /** @var ProgressBar $progress */
     $progress = $helperSet->get('progress');
     $progress->start($output, $totalRecords);
     $progress->display();
     $sql = "SELECT DISTINCT(r.record_id)" . " FROM record r LEFT JOIN subdef s ON (r.record_id = s.record_id AND s.name IN (?))" . " WHERE r.type IN (?)";
     $types = array(Connection::PARAM_STR_ARRAY, Connection::PARAM_STR_ARRAY);
     $params = array($subdefsName, $recordsType);
     if ($min) {
         $sql .= " AND (r.record_id >= ?)";
         $params[] = (int) $min;
         $types[] = \PDO::PARAM_INT;
     }
     if ($max) {
         $sql .= " AND (r.record_id <= ?)";
         $params[] = (int) $max;
         $types[] = \PDO::PARAM_INT;
     }
     if (false === $withSubstitution) {
         if (true === $substitutionOnly) {
             $sql .= " AND (ISNULL(s.substit) OR s.substit = 1)";
         } else {
             $sql .= " AND (ISNULL(s.substit) OR s.substit = 0)";
         }
     }
     list($sql, $stmtParams) = SQLParserUtils::expandListParameters($sql, $params, $types);
     $connection = $databox->get_connection();
     $stmt = $connection->prepare($sql);
     $stmt->execute($stmtParams);
     $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     foreach ($rows as $row) {
         $output->write(sprintf(' (#%s)', $row['record_id']));
         $record = new \record_adapter($this->container, $databox->get_sbas_id(), $row['record_id']);
         /** @var media_subdef[] $subdefs */
         $subdefs = array_filter($record->get_subdefs(), function (media_subdef $subdef) use($subdefsName) {
             return in_array($subdef->get_name(), $subdefsName);
         });
         foreach ($subdefs as $subdef) {
             $subdef->remove_file();
             if ($withSubstitution && $subdef->is_substituted() || $substitutionOnly) {
                 $subdef->set_substituted(false);
             }
         }
//.........这里部分代码省略.........
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:101,代码来源:BuildSubdefs.php


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