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; }
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; }
public function getAction(Request $request, $sbas_id, $record_id, $subdef) { $databox = $this->appbox->get_databox((int) $sbas_id); $record = new \record_adapter($this->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) { /** @var \databox_subdef $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 (!$this->acl->get($this->authentication->getUser())->has_access_to_subdef($record, $subdef)) { throw new AccessDeniedHttpException(sprintf('User has not access to subdef %s', $subdef)); } $stamp = false; $watermark = !$this->acl->get($this->authentication->getUser())->has_right_on_base($record->get_base_id(), 'nowatermark'); if ($watermark && !$all_access) { $subdef_class = null; try { $subdef_class = $databox->get_subdef_structure()->get_subdef($record->get_type(), $subdef)->get_class(); } catch (\Exception_Databox_SubdefNotFound $e) { } if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $this->acl->get($this->authentication->getUser())->has_preview_grant($record)) { $watermark = false; } elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $this->acl->get($this->authentication->getUser())->has_hd_grant($record)) { $watermark = false; } } if ($watermark && !$all_access) { $repository = $this->app['repo.basket-elements']; $ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $this->authentication->getUser()); $ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $this->authentication->getUser()); if ($ValidationByRecord && count($ValidationByRecord) > 0) { $watermark = false; } elseif ($ReceptionByRecord && count($ReceptionByRecord) > 0) { $watermark = false; } } } return $this->deliverContent($request, $record, $subdef, $watermark, $stamp); }
public function getDevices() { if ($this->get_name() == 'document') { return [\databox_subdef::DEVICE_ALL]; } try { return $this->record->get_databox()->get_subdef_structure()->get_subdef($this->record->get_type(), $this->get_name())->getDevices(); } catch (\Exception_Databox_SubdefNotFound $e) { return []; } }
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)); }
public function serialize(\record_adapter $record) { $technicalInformation = $caption = $business = $status = []; foreach ($record->get_technical_infos() as $name => $value) { $technicalInformation[$name] = $value; } foreach ($record->get_caption()->get_fields(null, true) as $field) { $isDate = $field->get_databox_field()->get_type() === \databox_field::TYPE_DATE; $isBusiness = $field->get_databox_field()->isBusiness(); $vi = $field->get_values(); if ($field->is_multi()) { $values = []; foreach ($vi as $value) { $values[] = $this->sanitizeSerializedValue($value->getValue()); } $value = implode(' ' . $field->get_databox_field()->get_separator(false) . ' ', $values); } else { $value = $this->sanitizeSerializedValue(array_pop($vi)->getValue()); } if ($isDate) { try { $date = new \DateTime($value); $value = $date->format(DATE_ATOM); } catch (\Exception $e) { continue; } } if ($isBusiness) { $business[$field->get_databox_field()->get_name()] = $value; } $caption[$field->get_databox_field()->get_name()] = $value; } $i = 0; foreach (preg_split('//', strrev($record->get_status()), -1, PREG_SPLIT_NO_EMPTY) as $val) { $status['status-' . $i] = (int) $val; $i++; } return ['databox_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), 'collection_id' => $record->get_collection()->get_coll_id(), 'base_id' => $record->get_base_id(), 'mime_type' => $record->get_mime(), 'title' => $record->get_title(), 'original_name' => $record->get_original_name(), 'updated_on' => $record->get_modification_date()->format(DATE_ATOM), 'created_on' => $record->get_creation_date()->format(DATE_ATOM), 'sha256' => $record->get_sha256(), 'technical_informations' => $technicalInformation, 'phrasea_type' => $record->get_type(), 'type' => $record->is_grouping() ? 'story' : 'record', 'uuid' => $record->get_uuid(), 'caption' => $caption, 'status' => $status, 'caption-business' => $business]; }
/** * * @param record_adapter $record * @param array $options * @return string */ public function upload(record_adapter $record, array $options = []) { switch ($record->get_type()) { case self::ELEMENT_TYPE_VIDEO: $url_file = $this->_api->uploadFileWithToken($record->get_hd_file()->getRealPath(), $this->oauth_token); $options = array_merge(['url' => $url_file], $options); $video = $this->_api->call('POST /me/videos', $options, $this->oauth_token); return $video["id"]; break; default: throw new Bridge_Exception_InvalidRecordType('Unknown format'); break; } }
/** * * @param record_adapter $record * @param array $options * @return string The new distant Id */ public function upload(record_adapter $record, array $options = []) { switch ($record->get_type()) { case 'video': $video_entry = new Zend_Gdata_YouTube_VideoEntry(); $filesource = new Zend_Gdata_App_MediaFileSource($record->get_hd_file()->getRealPath()); $filesource->setContentType($record->get_hd_file()->get_mime()); $filesource->setSlug($record->get_title()); $video_entry->setMediaSource($filesource); $video_entry->setVideoTitle($options['title']); $video_entry->setVideoDescription($options['description']); $video_entry->setVideoCategory($options['category']); $video_entry->SetVideoTags(explode(' ', $options['tags'])); $video_entry->setVideoDeveloperTags(['phraseanet']); if ($options['privacy'] == "public") { $video_entry->setVideoPublic(); } else { $video_entry->setVideoPrivate(); } $app_entry = $this->_api->insertEntry($video_entry, self::UPLOAD_URL, 'Zend_Gdata_YouTube_VideoEntry'); /* * set major protocole version to 2 otherwise you get exception when calling getVideoId * but setting setMajorProtocolVersion to 2 at the new entry introduce a new bug with getVideoState * @see http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/7d86cac0d3f90e3f/d9291d7314f99be7?pli=1 */ $app_entry->setMajorProtocolVersion(2); return $app_entry->getVideoId(); break; default: throw new Bridge_Exception_InvalidRecordType('Unknown format'); break; } }
/** * @covers Alchemy\Phrasea\Controller\Prod\Property::changeType */ public function testChangeType() { $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']); $record2 = \record_adapter::createFromFile($file, self::$DI['app']); self::$DI['client']->request('POST', '/prod/records/property/type/', ['lst' => implode(';', [$record->get_serialize_key(), $record2->get_serialize_key()]), 'types' => [$record->get_serialize_key() => 'document', $record2->get_serialize_key() => 'flash']]); $response = self::$DI['client']->getResponse(); $datas = (array) json_decode($response->getContent()); $this->assertArrayHasKey('success', $datas); $this->assertTrue($datas['success']); $this->assertArrayHasKey('updated', $datas); $record = new \record_adapter(self::$DI['app'], $record->get_sbas_id(), $record->get_record_id()); $record2 = new \record_adapter(self::$DI['app'], $record2->get_sbas_id(), $record2->get_record_id()); $this->assertEquals('document', $record->get_type()); $this->assertEquals('flash', $record2->get_type()); $record->delete(); $record2->delete(); unset($response, $datas, $record2, $record, $file); }
public function connect(Application $app) { $app['controller.prod.edit'] = $this; $controllers = $app['controllers_factory']; $app['firewall']->addMandatoryAuthentication($controllers); $controllers->before(function (Request $request) use($app) { $app['firewall']->requireNotGuest()->requireRight('modifyrecord'); }); $controllers->post('/', function (Application $app, Request $request) { $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, ['canmodifrecord']); $thesaurus = false; $status = $ids = $elements = $suggValues = $fields = $JSFields = []; $databox = null; $multipleDataboxes = count($records->databoxes()) > 1; if (1 === count($records->databoxes())) { $databoxes = $records->databoxes(); $databox = array_pop($databoxes); /** * generate javascript fields */ foreach ($databox->get_meta_structure() as $meta) { $fields[] = $meta; $separator = $meta->get_separator(); /** @Ignore */ $JSFields[$meta->get_id()] = ['meta_struct_id' => $meta->get_id(), 'name' => $meta->get_name(), '_status' => 0, '_value' => '', '_sgval' => [], 'required' => $meta->is_required(), 'label' => $meta->get_label($app['locale']), 'readonly' => $meta->is_readonly(), 'type' => $meta->get_type(), 'format' => '', 'explain' => '', 'tbranch' => $meta->get_tbranch(), 'maxLength' => $meta->get_tag()->getMaxLength(), 'minLength' => $meta->get_tag()->getMinLength(), 'multi' => $meta->is_multi(), 'separator' => $separator, 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null, 'vocabularyRestricted' => $meta->getVocabularyControl() ? $meta->isVocabularyRestricted() : false]; if (trim($meta->get_tbranch()) !== '') { $thesaurus = true; } } /** * generate javascript sugg values */ foreach ($records->collections() as $collection) { /* @var $record record_adapter */ $suggValues['b' . $collection->get_base_id()] = []; if ($sxe = simplexml_load_string($collection->get_prefs())) { $z = $sxe->xpath('/baseprefs/sugestedValues'); if (!$z || !is_array($z)) { continue; } foreach ($z[0] as $ki => $vi) { // les champs $field = $databox->get_meta_structure()->get_element_by_name($ki); if (!$field || !$vi) { continue; } $suggValues['b' . $collection->get_base_id()][$field->get_id()] = []; foreach ($vi->value as $oneValue) { $suggValues['b' . $collection->get_base_id()][$field->get_id()][] = (string) $oneValue; } } } unset($collection); } /** * generate javascript status */ if ($app['acl']->get($app['authentication']->getUser())->has_right('changestatus')) { $dbstatus = \databox_status::getDisplayStatus($app); if (isset($dbstatus[$databox->get_sbas_id()])) { foreach ($dbstatus[$databox->get_sbas_id()] as $n => $statbit) { $status[$n] = []; $status[$n]['label0'] = $statbit['labels_off_i18n'][$app['locale']]; $status[$n]['label1'] = $statbit['labels_on_i18n'][$app['locale']]; $status[$n]['img_off'] = $statbit['img_off']; $status[$n]['img_on'] = $statbit['img_on']; $status[$n]['_value'] = 0; } } } /** * generate javascript elements */ foreach ($databox->get_meta_structure() as $field) { $databox_fields[$field->get_id()] = ['dirty' => false, 'meta_struct_id' => $field->get_id(), 'values' => []]; } foreach ($records as $record) { $indice = $record->get_number(); $elements[$indice] = ['bid' => $record->get_base_id(), 'rid' => $record->get_record_id(), 'sselcont_id' => null, '_selected' => false, 'fields' => $databox_fields]; $elements[$indice]['statbits'] = []; if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'chgstatus')) { foreach ($status as $n => $s) { $tmp_val = substr(strrev($record->get_status()), $n, 1); $elements[$indice]['statbits'][$n]['value'] = $tmp_val == '1' ? '1' : '0'; $elements[$indice]['statbits'][$n]['dirty'] = false; } } $elements[$indice]['originalname'] = $record->get_original_name(); foreach ($record->get_caption()->get_fields(null, true) as $field) { $meta_struct_id = $field->get_meta_struct_id(); if (!isset($JSFields[$meta_struct_id])) { continue; } $values = []; foreach ($field->get_values() as $value) { $type = $id = null; if ($value->getVocabularyType()) { $type = $value->getVocabularyType()->getType(); $id = $value->getVocabularyId(); } $values[$value->getId()] = ['meta_id' => $value->getId(), 'value' => $value->getValue(), 'vocabularyId' => $id, 'vocabularyType' => $type]; } $elements[$indice]['fields'][$meta_struct_id] = ['dirty' => false, 'meta_struct_id' => $meta_struct_id, 'values' => $values]; } $elements[$indice]['subdefs'] = []; $thumbnail = $record->get_thumbnail(); $elements[$indice]['subdefs']['thumbnail'] = ['url' => $thumbnail->get_url(), 'w' => $thumbnail->get_width(), 'h' => $thumbnail->get_height()]; $elements[$indice]['preview'] = $app['twig']->render('common/preview.html.twig', ['record' => $record]); $elements[$indice]['type'] = $record->get_type(); } } $params = ['multipleDataboxes' => $multipleDataboxes, 'recordsRequest' => $records, 'databox' => $databox, 'JSonStatus' => json_encode($status), 'JSonRecords' => json_encode($elements), 'JSonFields' => json_encode($JSFields), 'JSonIds' => json_encode(array_keys($elements)), 'status' => $status, 'fields' => $fields, 'JSonSuggValues' => json_encode($suggValues), 'thesaurus' => $thesaurus]; return $app['twig']->render('prod/actions/edit_default.html.twig', $params); }); $controllers->get('/vocabulary/{vocabulary}/', function (Application $app, Request $request, $vocabulary) { $datas = ['success' => false, 'message' => '', 'results' => []]; $sbas_id = (int) $request->query->get('sbas_id'); 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)) { continue; } $statbits = $rec['status']; $editDirty = $rec['edit']; if ($editDirty == '0') { $editDirty = false; } else { $editDirty = true; } if (is_array($rec['metadatas'])) { $record->set_metadatas($rec['metadatas']); } /** * todo : this should not work */ if ($write_edit_el instanceof \databox_field) { $fields = $record->get_caption()->get_fields([$write_edit_el->get_name()], true); $field = array_pop($fields); $meta_id = null; if ($field && !$field->is_multi()) { $values = $field->get_values(); $meta_id = array_pop($values)->getId(); } $metas = [['meta_struct_id' => $write_edit_el->get_id(), 'meta_id' => $meta_id, 'value' => $date_obj->format('Y-m-d h:i:s')]]; $record->set_metadatas($metas, true); } $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($app, $newstat, $mask_and); } $mask_or = ltrim(str_replace('x', '0', $statbits), '0'); if ($mask_or != '') { $newstat = \databox_status::operation_or($app, $newstat, $mask_or); } $record->set_binary_status($newstat); } $record->write_metas()->get_collection()->reset_stamp($record->get_record_id()); if ($statbits != '') { $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_STATUS, '', ''); } if ($editDirty) { $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_EDIT, '', ''); } } return $app->json(['success' => true]); }); return $controllers; }
/** * * @param record_adapter $record * @param array $options * @return string The new distant Id */ public function upload(record_adapter $record, array $options = []) { $uploader = new Phlickr_Uploader($this->_api); $privacy = $this->get_default_privacy(); $uploader->setPerms($privacy['public'], $privacy['friends'], $privacy['family']); $type = $record->get_type() == 'image' ? self::ELEMENT_TYPE_PHOTO : $record->get_type(); switch ($type) { case self::ELEMENT_TYPE_PHOTO: return $uploader->upload($record->get_hd_file()->getRealPath(), $options['title'], $options['description'], $options['tags'], true); break; default: throw new Bridge_Exception_InvalidRecordType('Unknown format'); break; } }
/** * Retrieve detailled informations about one record * * @param record_adapter $record * @return array */ public function list_record(record_adapter $record) { $technicalInformation = []; foreach ($record->get_technical_infos() as $name => $value) { $technicalInformation[] = ['name' => $name, 'value' => $value]; } return ['databox_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), 'mime_type' => $record->get_mime(), 'title' => $record->get_title(), 'original_name' => $record->get_original_name(), 'updated_on' => $record->get_modification_date()->format(DATE_ATOM), 'created_on' => $record->get_creation_date()->format(DATE_ATOM), 'collection_id' => phrasea::collFromBas($this->app, $record->get_base_id()), 'sha256' => $record->get_sha256(), 'thumbnail' => $this->list_embedable_media($record->get_thumbnail()), 'technical_informations' => $technicalInformation, 'phrasea_type' => $record->get_type(), 'uuid' => $record->get_uuid()]; }