Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 /**
  * @covers Alchemy\Phrasea\Controller\Prod\Upload::upload
  * @covers Alchemy\Phrasea\Controller\Prod\Upload::getJsonResponse
  */
 public function testUploadWithoutB64Image()
 {
     self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\\Phrasea\\Notification\\Deliverer')->disableOriginalConstructor()->getMock();
     $params = ['base_id' => self::$DI['collection']->get_base_id()];
     $files = ['files' => [new UploadedFile($this->tmpFile, 'KIKOO.JPG')]];
     /** @var Client $client */
     $client = self::$DI['client'];
     $client->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']);
     $response = $client->getResponse();
     $this->checkJsonResponse($response);
     $datas = json_decode($response->getContent(), true);
     $this->assertTrue($datas['success']);
     if ($datas['element'] == 'record') {
         $id = explode('_', $datas['id']);
         $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]);
         $this->assertFalse($record->get_thumbnail()->is_physically_present());
     }
 }
Exemplo n.º 3
0
 /**
  * Retrieve detailled informations about one story
  *
  * @param record_adapter $story
  *
  * @return array
  */
 public function list_story(record_adapter $story)
 {
     if (!$story->is_grouping()) {
         throw new \API_V1_exception_notfound('Story not found');
     }
     $that = $this;
     $records = array_map(function (\record_adapter $record) use($that) {
         return $that->list_record($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($this->app, $story->get_base_id()), 'thumbnail' => $this->list_embedable_media($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];
 }