本文整理汇总了PHP中record_adapter::get_type方法的典型用法代码示例。如果您正苦于以下问题:PHP record_adapter::get_type方法的具体用法?PHP record_adapter::get_type怎么用?PHP record_adapter::get_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类record_adapter
的用法示例。
在下文中一共展示了record_adapter::get_type方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
示例3: getAction
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);
}
示例4: getDevices
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 [];
}
}
示例5: 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));
}
示例6: serialize
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];
}
示例7: upload
/**
*
* @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;
}
}
示例8: upload
/**
*
* @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;
}
}
示例9: testChangeType
/**
* @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);
}
示例10: connect
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();
}
//.........这里部分代码省略.........
示例11: upload
/**
*
* @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;
}
}
示例12: list_record
/**
* 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()];
}