本文整理汇总了PHP中record_adapter::isStory方法的典型用法代码示例。如果您正苦于以下问题:PHP record_adapter::isStory方法的具体用法?PHP record_adapter::isStory怎么用?PHP record_adapter::isStory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类record_adapter
的用法示例。
在下文中一共展示了record_adapter::isStory方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find_substitute_file
/**
* Find a substitution file for a sibdef
*
* @return \media_subdef
*/
protected function find_substitute_file()
{
if ($this->record->isStory()) {
$this->mime = 'image/png';
$this->width = 256;
$this->height = 256;
$this->path = $this->app['root.path'] . '/www/assets/common/images/icons/substitution/';
$this->file = 'regroup_thumb.png';
$this->url = Url::factory('/assets/common/images/icons/substitution/regroup_thumb.png');
} else {
$mime = $this->record->get_mime();
$mime = trim($mime) != '' ? str_replace('/', '_', $mime) : 'application_octet-stream';
$this->mime = 'image/png';
$this->width = 256;
$this->height = 256;
$this->path = $this->app['root.path'] . '/www/assets/common/images/icons/substitution/';
$this->file = str_replace('+', '%20', $mime) . '.png';
$this->url = Url::factory('/assets/common/images/icons/substitution/' . $this->file);
}
$this->is_physically_present = false;
if (!file_exists($this->path . $this->file)) {
$this->path = $this->app['root.path'] . '/www/assets/common/images/icons/';
$this->file = 'substitution.png';
$this->url = Url::factory('/assets/common/images/icons/' . $this->file);
}
return $this;
}
示例2: 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->isStory()) {
throw new \InvalidArgumentException('Unable to fetch a story from string');
}
return new static($story);
}
示例3: 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');
}
示例4: 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));
}
示例5: serialize
public function serialize(\record_adapter $record)
{
$caption = $business = $status = [];
$technicalInformation = $record->get_technical_infos()->getValues();
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->isStory() ? 'story' : 'record', 'uuid' => $record->getUuid(), 'caption' => $caption, 'status' => $status, 'caption-business' => $business];
}
示例6: testUploadRecordStatus
/**
* @covers Alchemy\Phrasea\Controller\Prod\Upload::upload
*/
public function testUploadRecordStatus()
{
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
$params = ['base_id' => self::$DI['collection']->get_base_id(), 'forceAction' => Manager::FORCE_RECORD, 'status' => [self::$DI['collection']->get_base_id() => [4 => 1]]];
$files = ['files' => [new UploadedFile($this->tmpFile, 'KIKOO.JPG')]];
self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']);
$response = self::$DI['client']->getResponse();
$this->checkJsonResponse($response);
$datas = json_decode($response->getContent(), true);
$this->assertTrue($datas['success']);
$this->assertEquals('record', $datas['element']);
$this->assertEquals(Manager::RECORD_CREATED, $datas['code']);
$id = explode('_', $datas['id']);
$record = new \record_adapter(self::$DI['app'], $id[0], $id[1]);
$this->assertFalse($record->isStory());
$this->assertEquals(1, substr(strrev($record->get_status()), 4, 1));
$this->assertEquals([], $datas['reasons']);
}
示例7: load_list
/**
*
* @param array $lst
* @param Boolean $flatten_groupings
*
* @return set_selection
*/
public function load_list(array $lst, $flatten_groupings = false)
{
foreach ($lst as $basrec) {
$basrec = explode('_', $basrec);
if (count($basrec) == 2) {
try {
$record = new record_adapter($this->app, (int) $basrec[0], (int) $basrec[1], count($this->elements));
} catch (\Exception $e) {
continue;
}
if ($record->isStory() && $flatten_groupings === true) {
foreach ($record->get_children() as $rec) {
$this->add_element($rec);
}
} else {
$this->add_element($record);
}
}
}
return $this;
}
示例8: mirror
/**
* @param record_adapter $record
*/
private function mirror(record_adapter $record)
{
$this->mime = $record->getMimeType();
$this->sha256 = $record->getSha256();
$this->original_name = $record->getOriginalName();
$this->type = $record->getType();
$this->isStory = $record->isStory();
$this->uuid = $record->getUuid();
$this->updated = $record->getUpdated();
$this->created = $record->getCreated();
$this->base_id = $record->getBaseId();
$this->collection_id = $record->getCollectionId();
}
示例9: __construct
/**
*
* @param Application $app
* @param string $lst
* @param integer $sstid
* @param integer $storyWZid
* @return set_export
*/
public function __construct(Application $app, $lst, $sstid, $storyWZid = null)
{
$this->app = $app;
$download_list = [];
$remain_hd = [];
if ($storyWZid) {
$repository = $app['repo.story-wz'];
$storyWZ = $repository->findByUserAndId($this->app, $app->getAuthenticatedUser(), $storyWZid);
$lst = $storyWZ->getRecord($this->app)->get_serialize_key();
}
if ($sstid != "") {
$repository = $app['repo.baskets'];
/* @var $repository Alchemy\Phrasea\Model\Repositories\BasketRepository */
$Basket = $repository->findUserBasket($sstid, $app->getAuthenticatedUser(), false);
$this->exportName = str_replace([' ', '\\', '/'], '_', $Basket->getName()) . "_" . date("Y-n-d");
foreach ($Basket->getElements() as $basket_element) {
$base_id = $basket_element->getRecord($this->app)->get_base_id();
$record_id = $basket_element->getRecord($this->app)->get_record_id();
if (!isset($remain_hd[$base_id])) {
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app->getAclForUser($app->getAuthenticatedUser())->remaining_download($base_id);
} else {
$remain_hd[$base_id] = false;
}
}
$current_element = $download_list[] = new record_exportElement($app, $basket_element->getRecord($this->app)->get_sbas_id(), $record_id, $Basket->getName(), $remain_hd[$base_id]);
$remain_hd[$base_id] = $current_element->get_remain_hd();
}
} else {
$this->exportName = "Export_" . date("Y-n-d") . '_' . mt_rand(100, 999);
$tmp_lst = explode(';', $lst);
$n = 1;
foreach ($tmp_lst as $basrec) {
$basrec = explode('_', $basrec);
if (count($basrec) != 2) {
continue;
}
try {
$record = new record_adapter($this->app, $basrec[0], $basrec[1]);
} catch (\Exception_Record_AdapterNotFound $e) {
continue;
}
if ($record->isStory()) {
foreach ($record->get_children() as $child_basrec) {
$base_id = $child_basrec->get_base_id();
$record_id = $child_basrec->get_record_id();
if (!isset($remain_hd[$base_id])) {
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app->getAclForUser($app->getAuthenticatedUser())->remaining_download($base_id);
} else {
$remain_hd[$base_id] = false;
}
}
$current_element = $download_list[] = new record_exportElement($app, $child_basrec->get_sbas_id(), $record_id, $record->get_title(null, null, true) . '_' . $n, $remain_hd[$base_id]);
$remain_hd[$base_id] = $current_element->get_remain_hd();
}
} else {
$base_id = $record->get_base_id();
$record_id = $record->get_record_id();
if (!isset($remain_hd[$base_id])) {
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app->getAclForUser($app->getAuthenticatedUser())->remaining_download($base_id);
} else {
$remain_hd[$base_id] = false;
}
}
$current_element = $download_list[$basrec[0] . '_' . $basrec[1]] = new record_exportElement($app, $record->get_sbas_id(), $record_id, '', $remain_hd[$base_id]);
$remain_hd[$base_id] = $current_element->get_remain_hd();
}
$n++;
}
}
$this->elements = $download_list;
$display_download = [];
$display_orderable = [];
$this->total_download = 0;
$this->total_order = 0;
$this->total_ftp = 0;
$this->businessFieldsAccess = false;
foreach ($this->elements as $download_element) {
if ($app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) {
$this->businessFieldsAccess = true;
}
foreach ($download_element->get_downloadable() as $name => $properties) {
if (!isset($display_download[$name])) {
$display_download[$name] = ['size' => 0, 'total' => 0, 'available' => 0, 'refused' => []];
}
$display_download[$name]['total']++;
if ($properties !== false) {
$display_download[$name]['available']++;
$display_download[$name]['label'] = $properties['label'];
$display_download[$name]['class'] = $properties['class'];
//.........这里部分代码省略.........
示例10: listStory
/**
* Retrieve detailed information about one story
*
* @param Request $request
* @param \record_adapter $story
* @return array
* @throws \Exception
*/
public function listStory(Request $request, \record_adapter $story)
{
if (!$story->isStory()) {
return Result::createError($request, 404, 'Story not found')->createResponse();
}
$records = array_map(function (\record_adapter $record) use($request) {
return $this->listRecord($request, $record);
}, array_values($story->get_children()->get_elements()));
$caption = $story->get_caption();
$format = function (\caption_record $caption, $dcField) {
$field = $caption->get_dc_field($dcField);
if (!$field) {
return null;
}
return $field->get_serialized_values();
};
return ['@entity@' => self::OBJECT_TYPE_STORY, 'databox_id' => $story->getDataboxId(), 'story_id' => $story->getRecordId(), 'updated_on' => $story->getUpdated()->format(DATE_ATOM), 'created_on' => $story->getCreated()->format(DATE_ATOM), 'collection_id' => $story->getCollectionId(), 'base_id' => $story->getBaseId(), 'thumbnail' => $this->listEmbeddableMedia($request, $story, $story->get_thumbnail()), 'uuid' => $story->getUuid(), 'metadatas' => ['@entity@' => self::OBJECT_TYPE_STORY_METADATA_BAG, 'dc:contributor' => $format($caption, \databox_Field_DCESAbstract::Contributor), 'dc:coverage' => $format($caption, \databox_Field_DCESAbstract::Coverage), 'dc:creator' => $format($caption, \databox_Field_DCESAbstract::Creator), 'dc:date' => $format($caption, \databox_Field_DCESAbstract::Date), 'dc:description' => $format($caption, \databox_Field_DCESAbstract::Description), 'dc:format' => $format($caption, \databox_Field_DCESAbstract::Format), 'dc:identifier' => $format($caption, \databox_Field_DCESAbstract::Identifier), 'dc:language' => $format($caption, \databox_Field_DCESAbstract::Language), 'dc:publisher' => $format($caption, \databox_Field_DCESAbstract::Publisher), 'dc:relation' => $format($caption, \databox_Field_DCESAbstract::Relation), 'dc:rights' => $format($caption, \databox_Field_DCESAbstract::Rights), 'dc:source' => $format($caption, \databox_Field_DCESAbstract::Source), 'dc:subject' => $format($caption, \databox_Field_DCESAbstract::Subject), 'dc:title' => $format($caption, \databox_Field_DCESAbstract::Title), 'dc:type' => $format($caption, \databox_Field_DCESAbstract::Type)], 'records' => $records];
}
示例11: reorderAction
public function reorderAction(Request $request, $sbas_id, $record_id)
{
try {
$story = new \record_adapter($this->app, $sbas_id, $record_id);
if (!$story->isStory()) {
throw new \Exception('This is not a story');
}
if (!$this->getAclForUser()->has_right_on_base($story->get_base_id(), 'canmodifrecord')) {
throw new ControllerException($this->app->trans('You can not edit this story'));
}
$sql = 'UPDATE regroup SET ord = :ord WHERE rid_parent = :parent_id AND rid_child = :children_id';
$stmt = $story->get_databox()->get_connection()->prepare($sql);
foreach ($request->request->get('element') as $record_id => $ord) {
$params = [':ord' => $ord, ':parent_id' => $story->get_record_id(), ':children_id' => $record_id];
$stmt->execute($params);
}
$stmt->closeCursor();
$this->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($story));
$ret = ['success' => true, 'message' => $this->app->trans('Story updated')];
} catch (ControllerException $e) {
$ret = ['success' => false, 'message' => $e->getMessage()];
} catch (\Exception $e) {
$ret = ['success' => false, 'message' => $this->app->trans('An error occured')];
}
return $this->app->json($ret);
}