本文整理汇总了PHP中record_adapter::get_base_id方法的典型用法代码示例。如果您正苦于以下问题:PHP record_adapter::get_base_id方法的具体用法?PHP record_adapter::get_base_id怎么用?PHP record_adapter::get_base_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类record_adapter
的用法示例。
在下文中一共展示了record_adapter::get_base_id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: 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];
}
示例3: has_status_access_to_record
public function has_status_access_to_record(record_adapter $record)
{
return 0 === ((bindec($record->get_status()) ^ $this->get_mask_xor($record->get_base_id())) & $this->get_mask_and($record->get_base_id()));
}
示例4: doReportInformationDocument
/**
* Display information about a document
*
* @param Request $request
* @return JsonResponse
*/
public function doReportInformationDocument(Request $request)
{
$config = ['photo' => [$this->app->trans('report:: document'), 0, 0, 0, 0], 'record_id' => [$this->app->trans('report:: record id'), 0, 0, 0, 0], 'date' => [$this->app->trans('report:: date'), 0, 0, 0, 0], 'type' => [$this->app->trans('phrseanet:: sous definition'), 0, 0, 0, 0], 'titre' => [$this->app->trans('report:: titre'), 0, 0, 0, 0], 'taille' => [$this->app->trans('report:: poids'), 0, 0, 0, 0]];
$config_dl = ['ddate' => [$this->app->trans('report:: date'), 0, 0, 0, 0], 'user' => [$this->app->trans('report:: utilisateurs'), 0, 0, 0, 0], 'final' => [$this->app->trans('phrseanet:: sous definition'), 0, 0, 0, 0], 'coll_id' => [$this->app->trans('report:: collections'), 0, 0, 0, 0], 'comment' => [$this->app->trans('report:: commentaire'), 0, 0, 0, 0], 'fonction' => [$this->app->trans('report:: fonction'), 0, 0, 0, 0], 'activite' => [$this->app->trans('report:: activite'), 0, 0, 0, 0], 'pays' => [$this->app->trans('report:: pays'), 0, 0, 0, 0], 'societe' => [$this->app->trans('report:: societe'), 0, 0, 0, 0]];
//format conf according user preferences
if ('' !== ($columnsList = $request->request->get('list_column', ''))) {
$new_conf = $config_dl;
$columns = explode(',', $columnsList);
foreach (array_keys($config_dl) as $col) {
if (!in_array($col, $columns)) {
unset($new_conf[$col]);
}
}
$config_dl = $new_conf;
}
try {
$record = new \record_adapter($this->app, $request->request->get('sbasid'), $request->request->get('rid'));
} catch (\Exception $e) {
$this->app->abort(404);
}
$what = new \module_report_nav($this->app, $request->request->get('dmin'), $request->request->get('dmax'), $request->request->get('sbasid'), $request->request->get('collection'));
$what->setPeriode('');
$what->setCsv(false);
$what->setPrint(false);
/** @var \record_adapter $record */
$reportArray = $what->buildTabUserWhat($record->get_base_id(), $record->get_record_id(), $config);
$title = $what->getTitle();
$html = $this->render('report/ajax_data_content.html.twig', ['result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false]);
$from = $request->request->get('from', '');
if ('TOOL' === $from) {
$what->setTitle('');
return $this->app->json(['rs' => $html, 'display_nav' => false, 'title' => $title]);
}
if ('DASH' !== $from && 'PUSHDOC' !== $from) {
$download = new \module_report_download($this->app, $request->request->get('dmin'), $request->request->get('dmax'), $request->request->get('sbasid'), $request->request->get('collection'));
$mapColumnTitleToSqlField = $download->getTransQueryString();
$currentfilter = [];
if ('' !== ($serializedFilter = $request->request->get('liste_filter', ''))) {
$currentfilter = @unserialize(urldecode($serializedFilter));
}
$filter = new \module_report_filter($this->app, $currentfilter, $mapColumnTitleToSqlField);
if ('' !== ($filterColumn = $request->request->get('filter_column', ''))) {
$field = current(explode(' ', $filterColumn));
$value = $request->request->get('filter_value', '');
if ($request->request->get('liste') == 'on') {
return $this->app->json(['diag' => $this->render('report/colFilter.html.twig', ['result' => $download->colFilter($field), 'field' => $field]), 'title' => $this->app->trans('filtrer les resultats sur la colonne %colonne%', ['%colonne%' => $field])]);
}
if ($field === $value) {
$filter->removeFilter($field);
} else {
$filter->addFilter($field, '=', $value);
}
}
$filter->addfilter('record_id', '=', $record->get_record_id());
$download->setFilter($filter->getTabFilter());
$download->setOrder('ddate', 'DESC');
$download->setTitle($this->app->trans('report:: historique des telechargements'));
$download->setConfig(false);
$reportArray = $download->buildReport($config_dl);
if ($request->request->get('printcsv') == 'on') {
$download->setPrettyString(false);
return $this->getCSVResponse($download, 'info_document');
}
$html .= $this->render('report/ajax_data_content.html.twig', ['result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false]);
return $this->app->json(['rs' => $html, 'display_nav' => false, 'title' => $title]);
}
if ($this->getConf()->get(['registry', 'modules', 'anonymous-report']) == false && $from !== 'DOC' && $from !== 'DASH' && $from !== 'GEN' && $from !== 'PUSHDOC') {
$conf = ['identifiant' => [$this->app->trans('report:: identifiant'), 0, 0, 0, 0], 'nom' => [$this->app->trans('report:: nom'), 0, 0, 0, 0], 'mail' => [$this->app->trans('report:: email'), 0, 0, 0, 0], 'adresse' => [$this->app->trans('report:: adresse'), 0, 0, 0, 0], 'tel' => [$this->app->trans('report:: telephone'), 0, 0, 0, 0]];
$info = new \module_report_nav($this->app, $request->request->get('dmin'), $request->request->get('dmax'), $request->request->get('sbasid'), $request->request->get('collection'));
$info->setPeriode('');
$info->setConfig(false);
$info->setTitle($this->app->trans('report:: utilisateur'));
$reportArray = $info->buildTabGrpInfo(false, [], $request->request->get('user'), $conf, false);
if ($request->request->get('printcsv') == 'on' && isset($download)) {
return $this->getCSVResponse($this->app, $info, 'info_user');
}
$html .= $this->render('report/ajax_data_content.html.twig', ['result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false]);
return $this->app->json(['rs' => $html, 'display_nav' => false, 'title' => $title]);
}
return $this->app->json(['rs' => $html, 'display_nav' => false, 'title' => $title]);
}
示例5: 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()) {
//.........这里部分代码省略.........
示例6: __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'];
//.........这里部分代码省略.........
示例7: 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];
}
示例8: 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);
}