Esempio n. 1
0
 /**
  *
  * @param  Array   $datas
  * @param  boolean $unread
  * @return Array
  */
 public function datas(array $data, $unread)
 {
     $reason = $data['reason'];
     $account_id = $data['account_id'];
     $sbas_id = $data['sbas_id'];
     $rid = $data['record_id'];
     try {
         $account = Bridge_Account::load_account($this->app, $account_id);
         $record = new record_adapter($this->app, $sbas_id, $rid);
     } catch (\Exception $e) {
         return [];
     }
     $ret = ['text' => $this->app->trans("L'upload concernant le record %title% sur le compte %bridge_name% a echoue pour les raisons suivantes : %reason%", ['%title%' => $record->get_title(), '%bridge_name%' => $account->get_api()->get_connector()->get_name(), '%reason%' => $reason]), 'class' => ''];
     return $ret;
 }
Esempio n. 2
0
 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];
 }
Esempio n. 3
0
 public function connect(Application $app)
 {
     $app['controller.prod.tools'] = $this;
     $controllers = $app['controllers_factory'];
     $app['firewall']->addMandatoryAuthentication($controllers);
     $controllers->before(function (Request $request) use($app) {
         $app['firewall']->requireRight('doctools');
     });
     $controllers->get('/', function (Application $app, Request $request) {
         $records = RecordsRequest::fromRequest($app, $request, false);
         $metadatas = false;
         $record = null;
         if (count($records) == 1) {
             $record = $records->first();
             if (!$record->is_grouping()) {
                 try {
                     $metadatas = $app['exiftool.reader']->files($record->get_subdef('document')->get_pathfile())->first()->getMetadatas();
                 } catch (PHPExiftoolException $e) {
                 } catch (\Exception_Media_SubdefNotFound $e) {
                 }
             }
         }
         $var = ['records' => $records, 'record' => $record, 'metadatas' => $metadatas];
         return $app['twig']->render('prod/actions/Tools/index.html.twig', $var);
     });
     $controllers->post('/rotate/', function (Application $app, Request $request) {
         $return = ['success' => true, 'errorMessage' => ''];
         $records = RecordsRequest::fromRequest($app, $request, false);
         $rotation = in_array($request->request->get('rotation'), ['-90', '90', '180']) ? $request->request->get('rotation', 90) : 90;
         foreach ($records as $record) {
             foreach ($record->get_subdefs() as $name => $subdef) {
                 if ($name == 'document') {
                     continue;
                 }
                 try {
                     $subdef->rotate($rotation, $app['media-alchemyst'], $app['mediavorus']);
                 } catch (\Exception $e) {
                 }
             }
         }
         return $app->json($return);
     })->bind('prod_tools_rotate');
     $controllers->post('/image/', function (Application $app, Request $request) {
         $return = ['success' => true];
         $selection = RecordsRequest::fromRequest($app, $request, false, ['canmodifrecord']);
         foreach ($selection as $record) {
             $substituted = false;
             foreach ($record->get_subdefs() as $subdef) {
                 if ($subdef->is_substituted()) {
                     $substituted = true;
                     break;
                 }
             }
             if (!$substituted || $request->request->get('ForceThumbSubstit') == '1') {
                 $record->rebuild_subdefs();
             }
         }
         return $app->json($return);
     })->bind('prod_tools_image');
     $controllers->post('/hddoc/', function (Application $app, Request $request) {
         $success = false;
         $message = $app->trans('An error occured');
         if ($file = $request->files->get('newHD')) {
             if ($file->isValid()) {
                 $fileName = $file->getClientOriginalName();
                 try {
                     $tempoDir = tempnam(sys_get_temp_dir(), 'substit');
                     unlink($tempoDir);
                     mkdir($tempoDir);
                     $tempoFile = $tempoDir . DIRECTORY_SEPARATOR . $fileName;
                     if (false === rename($file->getPathname(), $tempoFile)) {
                         throw new RuntimeException('Error while renaming file');
                     }
                     $record = new \record_adapter($app, $request->get('sbas_id'), $request->get('record_id'));
                     $media = $app['mediavorus']->guess($tempoFile);
                     $app['subdef.substituer']->substitute($record, 'document', $media);
                     $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_SUBSTITUTE, 'HD', '');
                     if ((int) $request->request->get('ccfilename') === 1) {
                         $record->set_original_name($fileName);
                         $app['phraseanet.SE']->updateRecord($record);
                     }
                     unlink($tempoFile);
                     rmdir($tempoDir);
                     $success = true;
                     $message = $app->trans('Document has been successfully substitued');
                 } catch (\Exception $e) {
                     $message = $app->trans('file is not valid');
                 }
             } else {
                 $message = $app->trans('file is not valid');
             }
         } else {
             $app->abort(400, 'Missing file parameter');
         }
         return $app['twig']->render('prod/actions/Tools/iframeUpload.html.twig', ['success' => $success, 'message' => $message]);
     })->bind('prod_tools_hd_substitution');
     $controllers->post('/chgthumb/', function (Application $app, Request $request) {
         $success = false;
         $message = $app->trans('An error occured');
         if ($file = $request->files->get('newThumb')) {
             if ($file->isValid()) {
                 try {
                     $fileName = $file->getClientOriginalName();
                     $tempoDir = tempnam(sys_get_temp_dir(), 'substit');
                     unlink($tempoDir);
                     mkdir($tempoDir);
                     $tempoFile = $tempoDir . DIRECTORY_SEPARATOR . $fileName;
                     if (false === rename($file->getPathname(), $tempoFile)) {
                         throw new RuntimeException('Error while renaming file');
                     }
                     $record = new \record_adapter($app, $request->get('sbas_id'), $request->get('record_id'));
                     $media = $app['mediavorus']->guess($tempoFile);
                     $app['subdef.substituer']->substitute($record, 'thumbnail', $media);
                     $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_SUBSTITUTE, 'thumbnail', '');
                     unlink($tempoFile);
                     rmdir($tempoDir);
                     $success = true;
                     $message = $app->trans('Thumbnail has been successfully substitued');
                 } catch (\Exception $e) {
                     $message = $app->trans('file is not valid');
                 }
             } else {
                 $message = $app->trans('file is not valid');
             }
         } else {
             $app->abort(400, 'Missing file parameter');
         }
         return $app['twig']->render('prod/actions/Tools/iframeUpload.html.twig', ['success' => $success, 'message' => $message]);
     })->bind('prod_tools_thumbnail_substitution');
     $controllers->post('/thumb-extractor/confirm-box/', function (Application $app, Request $request) {
         $return = ['error' => false, 'datas' => ''];
         $template = 'prod/actions/Tools/confirm.html.twig';
         try {
             $record = new \record_adapter($app, $request->request->get('sbas_id'), $request->request->get('record_id'));
             $var = ['video_title' => $record->get_title(), 'image' => $request->request->get('image', '')];
             $return['datas'] = $app['twig']->render($template, $var);
         } catch (\Exception $e) {
             $return['datas'] = $app->trans('an error occured');
             $return['error'] = true;
         }
         return $app->json($return);
     });
     $controllers->post('/thumb-extractor/apply/', function (Application $app, Request $request) {
         $return = ['success' => false, 'message' => ''];
         try {
             $record = new \record_adapter($app, $request->request->get('sbas_id'), $request->request->get('record_id'));
             $dataUri = DataURI\Parser::parse($request->request->get('image', ''));
             $path = $app['root.path'] . '/tmp';
             $name = sprintf('extractor_thumb_%s', $record->get_serialize_key());
             $fileName = sprintf('%s/%s.png', $path, $name);
             file_put_contents($fileName, $dataUri->getData());
             $media = $app['mediavorus']->guess($fileName);
             $app['subdef.substituer']->substitute($record, 'thumbnail', $media);
             $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_SUBSTITUTE, 'thumbnail', '');
             unset($media);
             $app['filesystem']->remove($fileName);
             $return['success'] = true;
         } catch (\Exception $e) {
             $return['message'] = $e->getMessage();
         }
         return $app->json($return);
     });
     return $controllers;
 }
Esempio n. 4
0
 /**
  *
  * @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;
     }
 }
Esempio n. 5
0
 /**
  *
  * @return String
  */
 public function get_title($highlight = '', SearchEngineInterface $search_engine = null)
 {
     if ($this->title) {
         return $this->title;
     }
     $this->title = collection::getLogo($this->get_base_id(), $this->app) . ' ';
     switch ($this->env) {
         case "RESULT":
             $this->title .= $this->app->trans('preview:: resultat numero %number%', ['%number%' => '<span id="current_result_n">' . ($this->number + 1) . '</span> : ']);
             $this->title .= parent::get_title($highlight, $search_engine);
             break;
         case "BASK":
             $this->title .= $this->name . ' - ' . parent::get_title($highlight, $search_engine) . ' (' . $this->get_number() . '/' . $this->total . ') ';
             break;
         case "REG":
             $title = parent::get_title();
             if ($this->get_number() == 0) {
                 $this->title .= $title;
             } else {
                 $this->title .= sprintf('%s %s', $title, $this->get_number() . '/' . $this->total);
             }
             break;
         default:
             $this->title .= parent::get_title($highlight, $search_engine);
             break;
     }
     return $this->title;
 }
Esempio n. 6
0
 /**
  * Return basic information about a record
  *
  * @param integer $bid base id
  * @param integer $rid record id
  * @param array   $tab config for the html table
  *
  * @return array
  */
 public function buildTabUserWhat($bid, $rid, $tab = false)
 {
     $this->initialize();
     $sbas_id = phrasea::sbasFromBas($this->app, $bid);
     try {
         $record = new record_adapter($this->app, $sbas_id, $rid);
     } catch (\Exception_Record_AdapterNotFound $e) {
         return $this->report;
     }
     $this->setDisplay($tab);
     $this->champ = ['photo', 'record_id', 'date', 'type', 'titre', 'taille'];
     $document = $record->get_subdef('document');
     $this->title = $this->app->trans('report:: Information sur l\'enregistrement numero %number%', ['%number%' => (int) $rid]);
     $x = $record->get_thumbnail();
     $this->result[] = ['photo' => "<img style='width:" . $x->get_width() . "px;height:" . $x->get_height() . "px;'\n                        src='" . $x->get_url() . "'>", 'record_id' => $record->get_record_id(), 'date' => $this->app['date-formatter']->getPrettyString($document->get_creation_date()), 'type' => $document->get_mime(), 'titre' => $record->get_title(), 'taille' => $document->get_size()];
     $this->setDisplayNav();
     $this->setReport();
     return $this->report;
 }
Esempio n. 7
0
 public function submitConfirmBoxAction(Request $request)
 {
     $template = 'prod/actions/Tools/confirm.html.twig';
     try {
         $record = new \record_adapter($this->app, $request->request->get('sbas_id'), $request->request->get('record_id'));
         $var = ['video_title' => $record->get_title(), 'image' => $request->request->get('image', '')];
         $return = ['error' => false, 'datas' => $this->render($template, $var)];
     } catch (\Exception $e) {
         $return = ['error' => true, 'datas' => $this->app->trans('an error occured')];
     }
     return $this->app->json($return);
 }
Esempio n. 8
0
 /**
  *
  * @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'];
                 $this->total_download++;
                 $display_download[$name]['size'] += $download_element->get_size($name);
             } else {
                 $display_download[$name]['refused'][] = $download_element->get_thumbnail();
             }
         }
         foreach ($download_element->get_orderable() as $name => $properties) {
             if (!isset($display_orderable[$name])) {
                 $display_orderable[$name] = ['total' => 0, 'available' => 0, 'refused' => []];
             }
             $display_orderable[$name]['total']++;
             if ($properties !== false) {
                 $display_orderable[$name]['available']++;
                 $this->total_order++;
             } else {
                 $display_orderable[$name]['refused'][] = $download_element->get_thumbnail();
             }
         }
     }
     foreach ($display_download as $name => $values) {
         $display_download[$name]['size'] = (int) $values['size'];
     }
     $display_ftp = [];
     $hasadminright = $app['acl']->get($app['authentication']->getUser())->has_right('addrecord') || $app['acl']->get($app['authentication']->getUser())->has_right('deleterecord') || $app['acl']->get($app['authentication']->getUser())->has_right('modifyrecord') || $app['acl']->get($app['authentication']->getUser())->has_right('coll_manage') || $app['acl']->get($app['authentication']->getUser())->has_right('coll_modify_struct');
     $this->ftp_datas = [];
     if ($this->app['conf']->get(['registry', 'ftp', 'ftp-enabled']) && ($hasadminright || $this->app['conf']->get(['registry', 'ftp', 'ftp-user-access']))) {
         $display_ftp = $display_download;
         $this->total_ftp = $this->total_download;
         $lst_base_id = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base());
         if ($hasadminright) {
             $sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.*\n                  FROM (\n                    FtpCredential INNER JOIN Users ON (\n                        FtpCredential.active = 1 AND FtpCredential.user_id = Users.id\n                    ) INNER JOIN basusr ON (\n                        Users.id=basusr.usr_id\n                        AND (basusr.base_id=\n                        '" . implode("' OR basusr.base_id='", $lst_base_id) . "'\n                            )\n                         )\n                      )\n                  GROUP BY Users.id  ";
             $params = [];
         } elseif ($this->app['conf']->get(['registry', 'ftp', 'ftp-user-access'])) {
             $sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.*\n                  FROM (\n                    FtpCredential INNER JOIN Users ON (\n                        FtpCredential.active = 1 AND FtpCredential.id = Users.id\n                    ) INNER JOIN basusr ON (\n                        Users.id=basusr.usr_id\n                        AND Users.id = :usr_id\n                        AND (basusr.base_id=\n                        '" . implode("' OR basusr.base_id='", $lst_base_id) . "'\n                          )\n                        )\n                      )\n                  GROUP BY Users.id  ";
             $params = [':usr_id' => $app['authentication']->getUser()->getId()];
         }
         $datas[] = ['name' => $app->trans('export::ftp: reglages manuels'), 'usr_id' => '0', 'address' => '', 'login' => '', 'password' => '', 'ssl' => false, 'dest_folder' => '', 'prefix_folder' => 'Export_' . date("Y-m-d_H.i.s"), 'passive' => false, 'max_retry' => 5, 'sendermail' => $app['authentication']->getUser()->getEmail()];
         $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
         $stmt->execute($params);
         $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $stmt->closeCursor();
         foreach ($rs as $row) {
             $datas[] = ['name' => $row["usr_login"], 'usr_id' => $row['usr_id'], 'address' => $row['address'], 'login' => $row['login'], 'password' => $row['password'], 'ssl' => !!$row['tls'], 'dest_folder' => $row['reception_folder'], 'prefix_folder' => strlen(trim($row['repository_prefix_name'])) > 0 ? trim($row['repository_prefix_name']) : 'Export_' . date("Y-m-d_H.i.s"), 'passive' => !!$row['passive'], 'max_retry' => $row['max_retry'], 'usr_mail' => $row['usr_mail'], 'sender_mail' => $app['authentication']->getUser()->getEmail()];
         }
         $this->ftp_datas = $datas;
     }
     $this->display_orderable = $display_orderable;
     $this->display_download = $display_download;
     $this->display_ftp = $display_ftp;
     return $this;
 }
Esempio n. 9
0
 /**
  * Retrieve detailled informations about one record
  *
  * @param  \record_adapter $record
  *
  * @return array
  */
 public function list_record(Application $app, \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($app, $record->get_base_id()), 'sha256' => $record->get_sha256(), 'thumbnail' => $this->list_embedable_media($app, $record, $record->get_thumbnail()), 'technical_informations' => $technicalInformation, 'phrasea_type' => $record->get_type(), 'uuid' => $record->get_uuid()];
 }
 /**
  *
  * @param  Array   $datas
  * @param  boolean $unread
  * @return Array
  */
 public function datas($datas, $unread)
 {
     $sx = simplexml_load_string($datas);
     $reason = (string) $sx->reason;
     $account_id = (int) $sx->account_id;
     $sbas_id = (int) $sx->sbas_id;
     $rid = (int) $sx->record_id;
     try {
         $account = Bridge_Account::load_account($this->app, $account_id);
         $record = new record_adapter($this->app, $sbas_id, $rid);
     } catch (\Exception $e) {
         return [];
     }
     $ret = ['text' => $this->app->trans("L'upload concernant le record %title% sur le compte %bridge_name% a echoue pour les raisons suivantes : %reason%", ['%title%' => $record->get_title(), '%bridge_name%' => $account->get_api()->get_connector()->get_name(), '%reason%' => $reason]), 'class' => ''];
     return $ret;
 }
Esempio n. 11
0
 /**
  * Retrieve detailed information about one record
  *
  * @param Request          $request
  * @param \record_adapter $record
  * @return array
  */
 public function listRecord(Request $request, \record_adapter $record)
 {
     $technicalInformation = [];
     foreach ($record->get_technical_infos()->getValues() as $name => $value) {
         $technicalInformation[] = ['name' => $name, 'value' => $value];
     }
     $data = ['databox_id' => $record->getDataboxId(), 'record_id' => $record->getRecordId(), 'mime_type' => $record->getMimeType(), 'title' => $record->get_title(), 'original_name' => $record->get_original_name(), 'updated_on' => $record->getUpdated()->format(DATE_ATOM), 'created_on' => $record->getCreated()->format(DATE_ATOM), 'collection_id' => $record->getCollectionId(), 'base_id' => $record->getBaseId(), 'sha256' => $record->getSha256(), 'thumbnail' => $this->listEmbeddableMedia($request, $record, $record->get_thumbnail()), 'technical_informations' => $technicalInformation, 'phrasea_type' => $record->getType(), 'uuid' => $record->getUuid()];
     if ($request->attributes->get('_extended', false)) {
         $subdefs = $caption = [];
         foreach ($record->get_embedable_medias([], []) as $name => $media) {
             if (null !== ($subdef = $this->listEmbeddableMedia($request, $record, $media))) {
                 $subdefs[] = $subdef;
             }
         }
         foreach ($record->get_caption()->get_fields() as $field) {
             $caption[] = ['meta_structure_id' => $field->get_meta_struct_id(), 'name' => $field->get_name(), 'value' => $field->get_serialized_values(';')];
         }
         $extendedData = ['subdefs' => $subdefs, 'metadata' => $this->listRecordCaption($record->get_caption()), 'status' => $this->listRecordStatus($record), 'caption' => $caption];
         $data = array_merge($data, $extendedData);
     }
     return $data;
 }