本文整理汇总了PHP中record_adapter::is_grouping方法的典型用法代码示例。如果您正苦于以下问题:PHP record_adapter::is_grouping方法的具体用法?PHP record_adapter::is_grouping怎么用?PHP record_adapter::is_grouping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类record_adapter
的用法示例。
在下文中一共展示了record_adapter::is_grouping方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find_substitute_file
/**
* Find a substitution file for a sibdef
*
* @return \media_subdef
*/
protected function find_substitute_file()
{
if ($this->record->is_grouping()) {
$this->mime = 'image/png';
$this->width = 256;
$this->height = 256;
$this->path = $this->app['root.path'] . '/www/skins/icons/substitution/';
$this->file = 'regroup_thumb.png';
$this->url = '/skins/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/skins/icons/substitution/';
$this->file = str_replace('+', '%20', $mime) . '.png';
$this->url = '/skins/icons/substitution/' . $this->file;
}
$this->is_physically_present = false;
if (!file_exists($this->path . $this->file)) {
$this->path = $this->app['root.path'] . '/www/skins/icons/';
$this->file = 'substitution.png';
$this->url = '/skins/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->is_grouping()) {
throw new \InvalidArgumentException('Unable to fetch a story from string');
}
return new static($story);
}
示例3: attachStories
public function attachStories(Application $app, Request $request)
{
if (!$request->request->get('stories')) {
throw new BadRequestHttpException('Missing parameters stories');
}
$StoryWZRepo = $app['EM']->getRepository('Phraseanet:StoryWZ');
$alreadyFixed = $done = 0;
$stories = $request->request->get('stories', []);
foreach ($stories as $element) {
$element = explode('_', $element);
$Story = new \record_adapter($app, $element[0], $element[1]);
if (!$Story->is_grouping()) {
throw new \Exception('You can only attach stories');
}
if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_base($Story->get_base_id())) {
throw new AccessDeniedHttpException('You do not have access to this Story');
}
if ($StoryWZRepo->findUserStory($app, $app['authentication']->getUser(), $Story)) {
$alreadyFixed++;
continue;
}
$StoryWZ = new StoryWZ();
$StoryWZ->setUser($app['authentication']->getUser());
$StoryWZ->setRecord($Story);
$app['EM']->persist($StoryWZ);
$done++;
}
$app['EM']->flush();
if ($alreadyFixed === 0) {
if ($done <= 1) {
$message = $app->trans('%quantity% Story attached to the WorkZone', ['%quantity%' => $done]);
} else {
$message = $app->trans('%quantity% Stories attached to the WorkZone', ['%quantity%' => $done]);
}
} else {
if ($done <= 1) {
$message = $app->trans('%quantity% Story attached to the WorkZone, %quantity_already% already attached', ['%quantity%' => $done, '%quantity_already%' => $alreadyFixed]);
} else {
$message = $app->trans('%quantity% Stories attached to the WorkZone, %quantity_already% already attached', ['%quantity%' => $done, '%quantity_already%' => $alreadyFixed]);
}
}
if ($request->getRequestFormat() == 'json') {
return $app->json(['success' => true, 'message' => $message]);
}
return $app->redirectPath('prod_workzone_show');
}
示例4: 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;
}
示例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->is_grouping() ? '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();
}
}
示例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: connect
public function connect(Application $app)
{
$app['controller.prod.story'] = $this;
$controllers = $app['controllers_factory'];
$app['firewall']->addMandatoryAuthentication($controllers);
$controllers->get('/create/', function (Application $app) {
return $app['twig']->render('prod/Story/Create.html.twig', []);
})->bind('prod_stories_create');
$controllers->post('/', function (Application $app, Request $request) {
/* @var $request \Symfony\Component\HttpFoundation\Request */
$collection = \collection::get_from_base_id($app, $request->request->get('base_id'));
if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($collection->get_base_id(), 'canaddrecord')) {
throw new AccessDeniedHttpException('You can not create a story on this collection');
}
$Story = \record_adapter::createStory($app, $collection);
$records = RecordsRequest::fromRequest($app, $request, true);
foreach ($records as $record) {
if ($Story->hasChild($record)) {
continue;
}
$Story->appendChild($record);
}
$metadatas = [];
foreach ($collection->get_databox()->get_meta_structure() as $meta) {
if ($meta->get_thumbtitle()) {
$value = $request->request->get('name');
} else {
continue;
}
$metadatas[] = ['meta_struct_id' => $meta->get_id(), 'meta_id' => null, 'value' => $value];
break;
}
$Story->set_metadatas($metadatas)->rebuild_subdefs();
$StoryWZ = new StoryWZ();
$StoryWZ->setUser($app['authentication']->getUser());
$StoryWZ->setRecord($Story);
$app['EM']->persist($StoryWZ);
$app['EM']->flush();
if ($request->getRequestFormat() == 'json') {
$data = ['success' => true, 'message' => $app->trans('Story created'), 'WorkZone' => $StoryWZ->getId(), 'story' => ['sbas_id' => $Story->get_sbas_id(), 'record_id' => $Story->get_record_id()]];
return $app->json($data);
} else {
return $app->redirectPath('prod_stories_story', ['sbas_id' => $StoryWZ->getSbasId(), 'record_id' => $StoryWZ->getRecordId()]);
}
})->bind('prod_stories_do_create');
$controllers->get('/{sbas_id}/{record_id}/', function (Application $app, $sbas_id, $record_id) {
$Story = new \record_adapter($app, $sbas_id, $record_id);
$html = $app['twig']->render('prod/WorkZone/Story.html.twig', ['Story' => $Story]);
return new Response($html);
})->bind('prod_stories_story')->assert('sbas_id', '\\d+')->assert('record_id', '\\d+');
$controllers->post('/{sbas_id}/{record_id}/addElements/', function (Application $app, Request $request, $sbas_id, $record_id) {
$Story = new \record_adapter($app, $sbas_id, $record_id);
if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) {
throw new AccessDeniedHttpException('You can not add document to this Story');
}
$n = 0;
$records = RecordsRequest::fromRequest($app, $request, true);
foreach ($records as $record) {
if ($Story->hasChild($record)) {
continue;
}
$Story->appendChild($record);
$n++;
}
$data = ['success' => true, 'message' => $app->trans('%quantity% records added', ['%quantity%' => $n])];
if ($request->getRequestFormat() == 'json') {
return $app->json($data);
} else {
return $app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id, 'record_id' => $record_id]);
}
})->assert('sbas_id', '\\d+')->assert('record_id', '\\d+');
$controllers->post('/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/', function (Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id) {
$Story = new \record_adapter($app, $sbas_id, $record_id);
$record = new \record_adapter($app, $child_sbas_id, $child_record_id);
if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) {
throw new AccessDeniedHttpException('You can not add document to this Story');
}
$Story->removeChild($record);
$data = ['success' => true, 'message' => $app->trans('Record removed from story')];
if ($request->getRequestFormat() == 'json') {
return $app->json($data);
} else {
return $app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id, 'record_id' => $record_id]);
}
})->bind('prod_stories_story_remove_element')->assert('sbas_id', '\\d+')->assert('record_id', '\\d+')->assert('child_sbas_id', '\\d+')->assert('child_record_id', '\\d+');
/**
* Get the Basket reorder form
*/
$controllers->get('/{sbas_id}/{record_id}/reorder/', function (Application $app, $sbas_id, $record_id) {
$story = new \record_adapter($app, $sbas_id, $record_id);
if (!$story->is_grouping()) {
throw new \Exception('This is not a story');
}
return new Response($app['twig']->render('prod/Story/Reorder.html.twig', ['story' => $story]));
})->bind('prod_stories_story_reorder')->assert('sbas_id', '\\d+')->assert('record_id', '\\d+');
$controllers->post('/{sbas_id}/{record_id}/reorder/', function (Application $app, $sbas_id, $record_id) {
$ret = ['success' => false, 'message' => $app->trans('An error occured')];
try {
$story = new \record_adapter($app, $sbas_id, $record_id);
if (!$story->is_grouping()) {
//.........这里部分代码省略.........
示例8: 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->is_grouping());
$this->assertEquals(1, substr(strrev($record->get_status()), 4, 1));
$this->assertEquals([], $datas['reasons']);
}
示例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['EM']->getRepository('\\Entities\\StoryWZ');
$storyWZ = $repository->findByUserAndId($this->app, $app['authentication']->getUser(), $storyWZid);
$lst = $storyWZ->getRecord($this->app)->get_serialize_key();
}
if ($sstid != "") {
$repository = $app['EM']->getRepository('Phraseanet:Basket');
/* @var $repository Alchemy\Phrasea\Model\Repositories\BasketRepository */
$Basket = $repository->findUserBasket($sstid, $app['authentication']->getUser(), 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['acl']->get($app['authentication']->getUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['acl']->get($app['authentication']->getUser())->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->is_grouping()) {
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['acl']->get($app['authentication']->getUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['acl']->get($app['authentication']->getUser())->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['acl']->get($app['authentication']->getUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['acl']->get($app['authentication']->getUser())->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['acl']->get($app['authentication']->getUser())->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: list_story
/**
* Retrieve detailled informations about one story
*
* @param \record_adapter $story
*
* @return array
*/
public function list_story(Application $app, Request $request, \record_adapter $story)
{
if (!$story->is_grouping()) {
return Result::createError($request, 404, 'Story not found')->createResponse();
}
$that = $this;
$records = array_map(function (\record_adapter $record) use($that, $app) {
return $that->list_record($app, $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->get_sbas_id(), 'story_id' => $story->get_record_id(), 'updated_on' => $story->get_modification_date()->format(DATE_ATOM), 'created_on' => $story->get_creation_date()->format(DATE_ATOM), 'collection_id' => \phrasea::collFromBas($app, $story->get_base_id()), 'thumbnail' => $this->list_embedable_media($app, $story, $story->get_thumbnail()), 'uuid' => $story->get_uuid(), '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: 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->is_grouping() && $flatten_groupings === true) {
foreach ($record->get_children() as $rec) {
$this->add_element($rec);
}
} else {
$this->add_element($record);
}
}
}
return $this;
}