Merge branch '3.7'

This commit is contained in:
Romain Neutron
2013-01-09 11:25:14 +01:00
86 changed files with 1605 additions and 758 deletions

View File

@@ -21,11 +21,14 @@ before_script:
- git clone git://github.com/alchemy-fr/Phraseanet-Extension.git
- sh -c "cd Phraseanet-Extension && phpize && ./configure && make && sudo make install"
- echo "extension=phrasea2.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
- wget http://pecl.php.net/get/gmagick-1.1.0RC2.tgz
- tar -xzf gmagick-1.1.0RC2.tgz
- sh -c "cd gmagick-1.1.0RC2 && phpize && ./configure --with-gmagick=/usr/local && make && sudo make install"
- echo "extension=gmagick.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
- bin/setup system:upgrade -y
- wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz
- tar -xzf imagick-3.1.0RC2.tgz
- sh -c "cd imagick-3.1.0RC2 && phpize && ./configure --with-imagick=/usr/local && make && sudo make install"
- echo "extension=imagick.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
# - wget http://pecl.php.net/get/gmagick-1.1.0RC2.tgz
# - tar -xzf gmagick-1.1.0RC2.tgz
# - sh -c "cd gmagick-1.1.0RC2 && phpize && ./configure --with-gmagick=/usr/local && make && sudo make install"
# - echo "extension=gmagick.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
notifications:
irc:
@@ -39,4 +42,4 @@ notifications:
php:
- 5.3
- 5.4
- 5.5

View File

@@ -5,47 +5,23 @@ Phraseanet 3.8 - Digital Asset Management application
#Features :
Metadatas Management (include Thesaurus and DublinCore Mapping)
Search Engine (Sphinx Search Integration)
RestFull APIS (See Developer Documentation https://docs.phraseanet.com/Devel)
Bridge to Youtube/Dailymotion/Flickr
- Metadatas Management (include Thesaurus and DublinCore Mapping)
- Search Engine (Sphinx Search Integration)
- RestFull APIS (See Developer Documentation https://docs.phraseanet.com/Devel)
- Bridge to Youtube/Dailymotion/Flickr
#Documentation :
https://docs.phraseanet.com/
#Easy Installation
#Installation
Get the latest sources here https://github.com/alchemy-fr/Phraseanet/downloads
You **must** not download the source from GitHub, but download a packaged version here :
**Setup your webserver**
https://sourceforge.net/projects/phraseanet/files/
***Nginx***
<pre>
server {
listen 80;
server_name subdomain.domain.tld;
root /path/to/Phraseanet/www;
index index.php;
location /download {
internal;
alias /path/to/Phraseanet/tmp/download;
}
location /lazaret {
internal;
alias /path/to/Phraseanet/tmp/lazaret;
}
}
</pre>
Let's go !
And follow the install steps described at https://docs.phraseanet.com/Admin/
#License
Phraseanet is licensed under GPL-v3 license.
[1]: http://developer.phraseanet.com/

View File

@@ -61,6 +61,7 @@ $finder
->directories()
->name('test')
->name('tests')
->name('functionnal-tests')
->name('Tests')
->name('test-suite')
->name('test_script')

View File

@@ -0,0 +1,4 @@
dailymotion:
public_key:
secret_key:
dev_token:

View File

@@ -0,0 +1,79 @@
<?php
require_once __DIR__ . '/../../lib/classes/bootstrap.class.php';
require_once __DIR__ . '/../../vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Yaml\Yaml;
\bootstrap::register_autoloads();
$core = \bootstrap::execute('dev');
$console = new Application('Functionnal tests for dailymotion API');
$console
->register('upload:dailymotion')
->setDescription('Test upload on dailymotion API')
->setCode(function (InputInterface $input, OutputInterface $output) use ($core) {
try {
$configuration = Yaml::parse(__DIR__. '/config/keys.conf.yml');
} catch(\Exception $e) {
$output->writeln('<error>could not parse configuration file</error>');
return;
}
$appbox = \appbox::get_instance($core);
$found = false;
foreach ($appbox->get_databoxes() as $databox) {
/* @var $databox \databox */
$sql = 'SELECT record_id FROM record WHERE type="video" AND (
mime="video/mp4" OR mime="video/quicktime" OR mime="video/x-msvideo" OR mime="video/x-msvideo"
) LIMIT 1';
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute();
$rows = $stmt->fetch(\PDO::FETCH_ASSOC);
if(1 === count($rows)) {
$found = true;
$record = $databox->get_record($rows['record_id']);
break;
}
unset($stmt);
}
if (!$found) {
$output->writeln('<error>No video found, </error>');
return;
}
$bridge = new \Bridge_Api_Dailymotion($core['Registry'], new \Bridge_Api_Auth_OAuth2());
$bridge->set_oauth_token($configuration['dailymotion']['dev_token']);
$options = array();
$samples = array(
'title' => $record->get_title(),
'description' => 'Upload functionnal test',
'tags' => 'phraseanet upload test dm api',
'private' => true,
);
foreach($bridge->get_fields() as $field) {
$options[$field['name']] = isset($samples[$field['name']]) ? $samples[$field['name']] : uniqid('test_upload');
}
try {
$idVideo = $bridge->upload($record, $options);
$output->writeln(sprintf('<info>video id is %s</info>', $idVideo));
} catch(\Bridge_Exception_ActionAuthNeedReconnect $e) {
$output->writeln(sprintf('<error>Invalid token %s</error>', $configuration['dailymotion']['dev_token']));
} catch(\Exception $e) {
$output->writeln(sprintf('<error>%s : %s -> %s</error>',get_class($e), $e->getMessage(), $e->getTraceAsString()));
}
});
$console->run();

View File

@@ -361,6 +361,26 @@ return call_user_func(function($environment = 'prod') {
return $app['api']->add_record($app, $request)->get_response();
});
/**
* Route : /search/
*
* Method : GET or POST
*
* Parameters :
* bases[] : array
* status[] : array
* fields[] : array
* record_type : boolean
* media_type : string
*
* Response :
* Array containing an array of records and stories collection
*
*/
$app->match('/search/', function() use ($app) {
return $app['api']->search($app['request'])->get_response();
});
/**
* Route : /records/search/
*
@@ -656,6 +676,41 @@ return call_user_func(function($environment = 'prod') {
$app->get('/feeds/{wrong_feed_id}/content/', $bad_request_exception);
/**
* Route : /stories/DATABOX_ID/RECORD_ID/embed/
*
* Method : GET
*
* Parameters :
* DATABOX_ID : required INT
* RECORD_ID : required INT
*
*/
$app->get('/stories/{databox_id}/{story_id}/embed/', function($databox_id, $story_id) use ($app) {
$result = $app['api']->get_story_embed($app['request'], $databox_id, $story_id);
return $result->get_response();
}
)->assert('databox_id', '\d+')->assert('story_id', '\d+');
$app->get('/stories/{any_id}/{anyother_id}/embed/', $bad_request_exception);
$app->get('/stories/{databox_id}/{story_id}/', function($databox_id, $story_id) use ($app) {
$result = $app['api']->get_story($app['request'], $databox_id, $story_id);
return $result->get_response();
})->assert('databox_id', '\d+')->assert('story_id', '\d+');
$app->get('/stories/{any_id}/{anyother_id}/', $bad_request_exception);
$app->get('/stories/{databox_id}/{story_id}/', function($databox_id, $story_id) use ($app) {
$result = $app['api']->get_story($app['request'], $databox_id, $story_id);
return $result->get_response();
})->assert('databox_id', '\d+')->assert('story_id', '\d+');
$app->get('/stories/{any_id}/{anyother_id}/', $bad_request_exception);
/**
* Route Errors
*/

View File

@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Request;
@@ -135,13 +136,16 @@ return call_user_func(function($environment = 'prod') {
* Token endpoint - used to exchange an authorization grant for an access token.
*/
$app->post('/token', function(\Silex\Application $app, Request $request) {
if ( ! $request->isSecure()) {
throw new HttpException(400, 'This route requires the use of the https scheme', null, array('content-type' => 'application/json'));
}
$app['oauth']->grantAccessToken();
ob_flush();
flush();
return;
})->requireHttps();
});
/**
* Error Handler

View File

@@ -29,7 +29,7 @@ class MetaField implements AttributeInterface
/**
*
* @var mixed
* @var array
*/
protected $value;
@@ -37,15 +37,10 @@ class MetaField implements AttributeInterface
* Constructor
*
* @param \databox_field $databox_field The databox field
* @param string $value A scalar value
*
* @throws \InvalidArgumentException When value is not scalar
* @param array $value An array of scalar values
*/
public function __construct(\databox_field $databox_field, $value)
public function __construct(\databox_field $databox_field, array $value)
{
if (!is_scalar($value)) {
throw new \InvalidArgumentException('Databox field only accept scalar values');
}
$this->databox_field = $databox_field;
$this->value = $value;
}
@@ -79,7 +74,7 @@ class MetaField implements AttributeInterface
/**
* {@inheritdoc}
*
* @return mixed A scalar value
* @return array An array of scalar values
*/
public function getValue()
{

View File

@@ -24,7 +24,7 @@ use MediaVorus\Exception\FileNotFoundException;
use PHPExiftool\Writer;
use PHPExiftool\Driver\TagFactory;
use PHPExiftool\Driver\Metadata\Metadata;
use PHPExiftool\Driver\Metadata\MetadataBag;
use PHPExiftool\Driver\Metadata\MetadataBag as ExiftoolMetadataBag;
use PHPExiftool\Driver\Value\Mono as MonoValue;
use PHPExiftool\Exiftool;
use PHPExiftool\Exception\ExceptionInterface as PHPExiftoolException;
@@ -133,7 +133,7 @@ class File
if ($write) {
$value = new MonoValue($this->uuid);
$metadatas = new MetadataBag();
$metadatas = new ExiftoolMetadataBag();
foreach ($availableUUIDs as $tagname) {
$metadatas->add(new Metadata(TagFactory::getFromRDFTagname($tagname), $value));

View File

@@ -320,7 +320,7 @@ class Manager
$metadatas[$key] = array();
}
$metadatas[$key] = array_merge($metadatas[$key], array($attribute->getValue()));
$metadatas[$key] = array_merge($metadatas[$key], $attribute->getValue());
break;
case AttributeInterface::NAME_METADATA:

View File

@@ -0,0 +1,27 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Border;
interface MetaBagInterface
{
/**
* Converts a MetaBag to an acceptable array of metadata for a record update
*
* The structure of the array depends of the target databox description
* structure.
*
* @param \databox_descriptionStructure $metadatasStructure
*
* @return array
*/
public function toMetadataArray(\databox_descriptionStructure $structure);
}

View File

@@ -0,0 +1,83 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Border;
use Doctrine\Common\Collections\ArrayCollection;
/**
* MetaFieldsBad is a collection of MetaField attributes indexed by field names.
*
* It's used to handle field-oriented metadata before a record insertion.
*/
class MetaFieldsBag extends ArrayCollection implements MetaBagInterface
{
/**
* {@inheritdoc}
*/
public function toMetadataArray(\databox_descriptionStructure $metadatasStructure)
{
$metas = array();
$unicode = new \unicode();
foreach ($metadatasStructure as $databox_field) {
if ($this->containsKey($databox_field->get_name())) {
if ($databox_field->is_multi()) {
$values = $this->get($databox_field->get_name())->getValue();
$tmp = array();
foreach ($values as $value) {
foreach (\caption_field::get_multi_values($value, $databox_field->get_separator()) as $v) {
$tmp[] = $v;
}
}
$values = array_unique($tmp);
foreach ($values as $value) {
$value = $unicode->substituteCtrlCharacters($value, ' ');
$value = $unicode->toUTF8($value);
if ($databox_field->get_type() == 'date') {
$value = $unicode->parseDate($value);
}
$metas[] = array(
'meta_struct_id' => $databox_field->get_id(),
'value' => $value,
'meta_id' => null
);
}
} else {
$values = $this->get($databox_field->get_name())->getValue();
$value = array_shift($values);
$value = $unicode->substituteCtrlCharacters($value, ' ');
$value = $unicode->toUTF8($value);
if ($databox_field->get_type() == 'date') {
$value = $unicode->parseDate($value);
}
$metas[] = array(
'meta_struct_id' => $databox_field->get_id(),
'value' => $value,
'meta_id' => null
);
}
}
}
return $metas;
}
}

View File

@@ -0,0 +1,91 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Border;
use Doctrine\Common\Collections\ArrayCollection;
/**
* MetaFieldsBad is a collection of Metadata attributes indexed by metadata
* source.
*
* It's used to handle source-oriented metadata before a record insertion.
*/
class MetadataBag extends ArrayCollection implements MetaBagInterface
{
/**
* {@inheritdoc}
*/
public function toMetadataArray(\databox_descriptionStructure $metadatasStructure)
{
$metas = array();
$unicode = new \unicode();
foreach ($metadatasStructure as $databox_field) {
if ('' === $databox_field->get_tag()->getTagname()) {
// skipping fields without sources
continue;
}
if ($this->containsKey($databox_field->get_tag()->getTagname())) {
if ($databox_field->is_multi()) {
$values = $this->get($databox_field->get_tag()->getTagname())->getValue()->asArray();
$tmp = array();
foreach ($values as $value) {
foreach (\caption_field::get_multi_values($value, $databox_field->get_separator()) as $v) {
$tmp[] = $v;
}
}
$values = array_unique($tmp);
foreach ($values as $value) {
$value = $unicode->substituteCtrlCharacters($value, ' ');
$value = $unicode->toUTF8($value);
if ($databox_field->get_type() == 'date') {
$value = $unicode->parseDate($value);
}
$metas[] = array(
'meta_struct_id' => $databox_field->get_id(),
'value' => $value,
'meta_id' => null
);
}
} else {
$value = $this->get($databox_field->get_tag()->getTagname())->getValue()->asString();
$value = $unicode->substituteCtrlCharacters($value, ' ');
$value = $unicode->toUTF8($value);
if ($databox_field->get_type() == 'date') {
$value = $unicode->parseDate($value);
}
$metas[] = array(
'meta_struct_id' => $databox_field->get_id(),
'value' => $value,
'meta_id' => null
);
}
}
}
unset($unicode);
return $metas;
}
}

View File

@@ -49,16 +49,16 @@ class CreateCollection extends Command
$new_collection = \collection::create($app, $databox, $this->container['phraseanet.appbox'], $input->getArgument('collname'));
if ($new_collection && $input->getOption('duplicate_rights_from_base_id')) {
if ($new_collection && $input->getOption('base_id_rights')) {
$query = new \User_Query($this->container);
$total = $query->on_base_ids(array($input->getOption('duplicate_rights_from_base_id')))->get_total();
$total = $query->on_base_ids(array($input->getOption('base_id_rights')))->get_total();
$n = 0;
while ($n < $total) {
$results = $query->limit($n, 40)->execute()->get_results();
foreach ($results as $user) {
$user->ACL()->duplicate_right_from_bas($input->getOption('duplicate_rights_from_base_id'), $new_collection->get_base_id());
$user->ACL()->duplicate_right_from_bas($input->getOption('base_id_rights'), $new_collection->get_base_id());
}
$n+=40;
}

View File

@@ -461,7 +461,7 @@ class Databox implements ControllerProviderInterface
if ($databox->get_record_amount() > 0) {
$msg = _('admin::base: vider la base avant de la supprimer');
} else {
$databox->unmount_databox($app['phraseanet.appbox']);
$databox->unmount_databox();
$app['phraseanet.appbox']->write_databox_pic($app['media-alchemyst'], $app['filesystem'], $databox, null, \databox::PIC_PDF);
$databox->delete();
$success = true;
@@ -744,7 +744,7 @@ class Databox implements ControllerProviderInterface
try {
$databox = $app['phraseanet.appbox']->get_databox($databox_id);
$databox->unmount_databox($app['phraseanet.appbox']);
$databox->unmount_databox();
$success = true;
} catch (\Exception $e) {

View File

@@ -70,15 +70,16 @@ class Description implements ControllerProviderInterface
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfAtime',
'namespace' => 'Phraseanet'
),
'tfbasename' => array(
'tagname' => 'TfBasename',
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfBasename',
'namespace' => 'Phraseanet'
),
'tfbits' => array(
'tagname' => 'TfBits',
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfBits',
'namespace' => 'Phraseanet'
),
'tfbasename' => array(
'tagname' => 'TfBasename',
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfBasename',
'namespace' => 'Phraseanet'),
'tfchannels' => array(
'tagname' => 'TfChannels',
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfChannels',
@@ -89,6 +90,11 @@ class Description implements ControllerProviderInterface
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfCtime',
'namespace' => 'Phraseanet'
),
'tfdirname' => array(
'tagname' => 'TfDirname',
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDirname',
'namespace' => 'Phraseanet'
),
'tfduration' => array(
'tagname' => 'TfDuration',
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDuration',
@@ -129,9 +135,9 @@ class Description implements ControllerProviderInterface
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfMtime',
'namespace' => 'Phraseanet'
),
'tfdirname' => array(
'tagname' => 'TfDirname',
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDirname',
'tfquarantine' => array(
'tagname' => 'TfQuarantine',
'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfQuarantine',
'namespace' => 'Phraseanet'
),
'tfrecordid' => array(

View File

@@ -123,7 +123,7 @@ class TaskManager implements ControllerProviderInterface
ob_flush();
flush();
}
});
}, 200, array('Content-Type' => 'text/html'));
});

View File

@@ -253,7 +253,6 @@ class Lazaret implements ControllerProviderInterface
return $app->json($ret);
}
$lazaretFile = $app['EM']->find('Entities\LazaretFile', $file_id);
/* @var $lazaretFile \Entities\LazaretFile */
@@ -286,8 +285,11 @@ class Lazaret implements ControllerProviderInterface
if ($keepAttributes) {
//add attribute
foreach ($lazaretFile->getAttributes() as $attr) {
$metaFields = new Border\MetaFieldsBag();
$metadataBag = new Border\MetadataBag();
foreach ($lazaretFile->getAttributes() as $attr) {
//Check which ones to keep
if (!!count($attributesToKeep)) {
if (!in_array($attr->getId(), $attributesToKeep)) {
@@ -305,9 +307,8 @@ class Lazaret implements ControllerProviderInterface
switch ($attribute->getName()) {
case AttributeInterface::NAME_METADATA:
/**
* @todo romain neutron
*/
$value = $attribute->getValue();
$metadataBag->set($value->getTag()->getTagname(), new \PHPExiftool\Driver\Metadata\Metadata($value->getTag(), $value->getValue()));
break;
case AttributeInterface::NAME_STORY:
$attribute->getValue()->appendChild($record);
@@ -316,12 +317,16 @@ class Lazaret implements ControllerProviderInterface
$record->set_binary_status($attribute->getValue());
break;
case AttributeInterface::NAME_METAFIELD:
/**
* @todo romain neutron
*/
$metaFields->set($attribute->getField()->get_name(), $attribute->getValue());
break;
}
}
$datas = $metadataBag->toMetadataArray($record->get_databox()->get_meta_structure());
$record->set_metadatas($datas);
$fields = $metaFields->toMetadataArray($record->get_databox()->get_meta_structure());
$record->set_metadatas($fields);
}
//Delete lazaret file

View File

@@ -131,9 +131,15 @@ class Tooltip implements ControllerProviderInterface
{
$record = new \record_adapter($app, $sbas_id, $record_id);
try {
$document = $record->get_subdef('document');
} catch(\Exception $e) {
$document = null;
}
return $app['twig']->render(
'prod/Tooltip/TechnicalDatas.html.twig'
, array('record' => $record, 'document' => $record->get_subdef('document'))
, array('record' => $record, 'document' => $document)
);
}

View File

@@ -302,7 +302,8 @@ class Upload implements ControllerProviderInterface
foreach ($user->ACL()->get_granted_base(array('canaddrecord')) as $collection) {
$databox = $collection->get_databox();
if (!isset($collections[$databox->get_sbas_id()])) {
if ( ! isset($collections[$databox->get_sbas_id()])) {
$collections[$databox->get_sbas_id()] = array(
'databox' => $databox,
'databox_collections' => array()

View File

@@ -65,6 +65,25 @@ class BasketElementRepository extends EntityRepository
return $query->getResult();
}
public function findElementsByDatabox(\databox $databox)
{
$dql = 'SELECT e
FROM Entities\BasketElement e
JOIN e.basket b
LEFT JOIN b.validation s
LEFT JOIN s.participants p
WHERE e.sbas_id = :sbas_id';
$params = array(
'sbas_id' => $databox->get_sbas_id(),
);
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
return $query->getResult();
}
/**
*
* @param \record_adapter $record

View File

@@ -30,7 +30,7 @@ class StoryWZRepository extends EntityRepository
foreach ($stories as $key => $story) {
try {
$story->getRecord($app)->get_title();
} catch (\Exception_Record_AdapterNotFound $e) {
} catch (\Exception_NotFound $e) {
$this->getEntityManager()->remove($story);
unset($stories[$key]);
}
@@ -67,7 +67,7 @@ class StoryWZRepository extends EntityRepository
if ($story) {
try {
$story->getRecord($app)->get_title();
} catch (\Exception_Record_AdapterNotFound $e) {
} catch (\Exception_NotFound $e) {
$this->getEntityManager()->remove($story);
throw new \Exception_NotFound('Story not found');
}
@@ -95,7 +95,7 @@ class StoryWZRepository extends EntityRepository
if ($story) {
try {
$record = $story->getRecord($app);
} catch (\Exception_Record_AdapterNotFound $e) {
} catch (\Exception_NotFound $e) {
$this->getEntityManager()->remove($story);
$this->getEntityManager()->flush();
$story = null;
@@ -121,7 +121,31 @@ class StoryWZRepository extends EntityRepository
foreach ($stories as $key => $story) {
try {
$record = $story->getRecord();
} catch (\Exception_Record_AdapterNotFound $e) {
} catch (\Exception_NotFound $e) {
$this->getEntityManager()->remove($story);
$this->getEntityManager()->flush();
unset($stories[$key]);
}
}
return $stories;
}
public function findByDatabox(\databox $databox)
{
$dql = 'SELECT s FROM Entities\StoryWZ s WHERE s.sbas_id = :sbas_id';
$query = $this->_em->createQuery($dql);
$query->setParameters(array(
'sbas_id' => $databox->get_sbas_id(),
));
$stories = $query->getResult();
foreach ($stories as $key => $story) {
try {
$record = $story->getRecord();
} catch (\Exception_NotFound $e) {
$this->getEntityManager()->remove($story);
$this->getEntityManager()->flush();
unset($stories[$key]);

View File

@@ -26,7 +26,7 @@ class API_V1_adapter extends API_V1_Abstract
*
* @var string
*/
protected $version = '1.2';
protected $version = '1.3';
/**
* Application context
@@ -35,6 +35,9 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected $app;
const OBJECT_TYPE_STORY = 'http://api.phraseanet.com/api/objects/story';
const OBJECT_TYPE_STORY_METADATA_BAG = 'http://api.phraseanet.com/api/objects/story-metadata-bag';
/**
* API constructor
*
@@ -814,9 +817,41 @@ class API_V1_adapter extends API_V1_Abstract
);
}
/**
* Search for results
*
* @param Request $request
* @return \API_V1_result
*/
public function search(Request $request)
{
$result = new API_V1_result($request, $this);
list($ret, $search_result) = $this->prepare_search_request($request);
$ret['results'] = array('records' => array(), 'stories' => array());
foreach ($search_result->get_datas()->get_elements() as $record) {
if ($record->is_grouping()) {
$ret['results']['stories'][] = $this->list_story($record);
} else {
$ret['results']['records'][] = $this->list_record($record);
}
}
/**
* @todo donner des highlights
*/
$result->set_datas($ret);
return $result;
}
/**
* Get an API_V1_result containing the results of a records search
*
* Deprecated in favor of search
*
* @param Request $request
* @param int $databox_id
* @param string $response_type
@@ -826,6 +861,22 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new API_V1_result($request, $this);
list($ret, $search_result) = $this->prepare_search_request($request);
foreach ($search_result->get_datas()->get_elements() as $record) {
$ret['results'][] = $this->list_record($record);
}
/**
* @todo donner des highlights
*/
$result->set_datas($ret);
return $result;
}
private function prepare_search_request(Request $request)
{
$search_type = ($request->get('search_type')
&& in_array($request->get('search_type'), array(0, 1))) ?
$request->get('search_type') : 0;
@@ -921,16 +972,7 @@ class API_V1_adapter extends API_V1_Abstract
'query' => $search_engine->get_query(),
);
foreach ($search_result->get_datas()->get_elements() as $record) {
$ret['results'][] = $this->list_record($record);
}
/**
* @todo donner des highlights
*/
$result->set_datas($ret);
return $result;
return array($ret, $search_result);
}
/**
@@ -946,17 +988,25 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new API_V1_result($request, $this);
$containers = $this->app['phraseanet.appbox']
$that = $this;
$baskets = array_map(function ($basket) use ($that) {
return $that->list_basket($basket);
}, (array) $this->app['phraseanet.appbox']
->get_databox($databox_id)
->get_record($record_id)
->get_container_baskets($this->app['EM'], $this->app['phraseanet.user']);
->get_container_baskets($this->app['EM'], $this->app['phraseanet.user'])
);
$ret = array();
foreach ($containers as $basket) {
$ret[] = $this->list_basket($basket);
}
$record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id);
$result->set_datas(array("baskets" => $ret));
$stories = array_map(function ($story) use ($that) {
return $that->list_story($story);
}, array_values($record->get_grouping_parents()->get_elements()));
$result->set_datas(array(
"baskets" => $baskets,
"stories" => $stories,
));
return $result;
}
@@ -1045,6 +1095,38 @@ class API_V1_adapter extends API_V1_Abstract
return $result;
}
/**
* Get an API_V1_result containing the story embed files
*
* @param Request $request
* @param int $databox_id
* @param int $record_id
* @param string $response_type
* @return API_V1_result
*/
public function get_story_embed(Request $request, $databox_id, $record_id)
{
$result = new API_V1_result($request, $this);
$record = $this->app['phraseanet.appbox']
->get_databox($databox_id)
->get_record($record_id);
$ret = array();
$devices = $request->get('devices', array());
$mimes = $request->get('mimes', array());
foreach ($record->get_embedable_medias($devices, $mimes) as $name => $media) {
$ret[] = $this->list_embedable_media($media, $this->app['phraseanet.registry']);
}
$result->set_datas(array("embed" => $ret));
return $result;
}
public function set_record_metadatas(Request $request, $databox_id, $record_id)
{
$result = new API_V1_result($request, $this);
@@ -1165,6 +1247,30 @@ class API_V1_adapter extends API_V1_Abstract
return $result;
}
/**
* Return detailed informations about one story
*
* @param Request $request
* @param int $databox_id
* @param int $story_id
* @return API_V1_result
*/
public function get_story(Request $request, $databox_id, $story_id)
{
$result = new API_V1_result($request, $this);
$databox = $this->app['phraseanet.appbox']->get_databox($databox_id);
try {
$story = $databox->get_record($story_id);
$result->set_datas(array('story' => $this->list_story($story)));
} catch (Exception_NotFound $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Story Not Found'));
} catch (Exception $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured'));
}
return $result;
}
/**
* Return the baskets list of the authenticated user
*
@@ -1737,7 +1843,7 @@ class API_V1_adapter extends API_V1_Abstract
* @param \Entities\Basket $basket
* @return array
*/
protected function list_basket(\Entities\Basket $basket)
public function list_basket(\Entities\Basket $basket)
{
$ret = array(
'basket_id' => $basket->getId(),
@@ -1793,7 +1899,7 @@ class API_V1_adapter extends API_V1_Abstract
* @param record_adapter $record
* @return array
*/
protected function list_record(record_adapter $record)
public function list_record(record_adapter $record)
{
$technicalInformation = array();
foreach ($record->get_technical_infos() as $name => $value) {
@@ -1820,6 +1926,67 @@ class API_V1_adapter extends API_V1_Abstract
);
}
/**
* Retrieve detailled informations about one story
*
* @param record_adapter $story
* @return array
*/
public function list_story(record_adapter $story, $includeChildren = true)
{
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 array(
'@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(), $this->app['phraseanet.registry']),
'uuid' => $story->get_uuid(),
'metadatas' => array(
'@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,
);
}
/**
* List all databoxes of the current appbox
*

View File

@@ -161,6 +161,16 @@ class API_V1_result
return $this;
}
/**
* Return response data
*
* @return array
*/
public function get_datas()
{
return (array) $this->response;
}
/**
* Format the data and return serialized string
*

View File

@@ -195,6 +195,18 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I
return array(self::CONTAINER_TYPE_PLAYLIST => _('Playlists'));
}
public function get_oauth_token()
{
return $this->oauth_token;
}
public function set_oauth_token($oauth_token)
{
$this->oauth_token = $oauth_token;
return $this;
}
/**
*
* @param string $type
@@ -847,9 +859,8 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I
$datas = array(
'title' => $request->get('title_' . $key),
'description' => $request->get('description_' . $key),
'category' => $request->get('category_' . $key),
'tag' => $request->get('tags_' . $key),
'privacy' => $request->get('privacy_' . $key),
'private' => $request->get('privacy_' . $key) === 'private' ? true : false,
);
return $datas;
@@ -865,9 +876,8 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I
$datas = array(
'title' => $request->get('modif_title'),
'description' => $request->get('modif_description'),
'category' => $request->get('modif_category'),
'tags' => $request->get('modif_tags'),
'privacy' => $request->get('modif_privacy'),
'private' => $request->get('modif_privacy') === 'private' ? true : false,
);
return $datas;
@@ -908,7 +918,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I
*
* @return array
*/
private function get_fields()
public function get_fields()
{
return array(
array(
@@ -930,7 +940,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I
'required' => false
)
, array(
'name' => 'privacy',
'name' => 'private',
'length' => '0',
'length_min' => '0',
'required' => true

View File

@@ -91,8 +91,13 @@ class appbox extends base
if ($pic_type === collection::PIC_LOGO) {
//resize collection logo
$imageSpec = new ImageSpecification();
$media = $this->app['mediavorus']->guess($filename);
if($media->getWidth() > 120 || $media->getHeight() > 24) {
$imageSpec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO);
$imageSpec->setDimensions(120, 24);
}
$tmp = tempnam(sys_get_temp_dir(), 'tmpdatabox') . '.jpg';

View File

@@ -222,7 +222,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
*/
public function get_dc_field($label)
{
$fields = $this->get_fields();
$fields = $this->retrieve_fields();
if (isset($this->dces_elements[$label])) {
return $fields[$this->dces_elements[$label]];
}

View File

@@ -322,7 +322,7 @@ class databox extends base
return $ret;
}
public function unmount_databox(appbox $appbox)
public function unmount_databox()
{
foreach ($this->get_collections() as $collection) {
$collection->unmount_collection($this->app);
@@ -346,6 +346,16 @@ class databox extends base
$n+=50;
}
foreach ($this->app['EM']->getRepository('\Entities\StoryWZ')->findByDatabox($this) as $story) {
$this->app['EM']->remove($story);
}
foreach ($this->app['EM']->getRepository('\Entities\BasketElement')->findElementsByDatabox($this) as $element) {
$this->app['EM']->remove($element);
}
$this->app['EM']->flush();
$params = array(':site_id' => $this->app['phraseanet.registry']->get('GV_sit'));
$sql = 'DELETE FROM clients WHERE site_id = :site_id';
@@ -359,16 +369,16 @@ class databox extends base
$stmt->closeCursor();
$sql = "DELETE FROM sbas WHERE sbas_id = :sbas_id";
$stmt = $appbox->get_connection()->prepare($sql);
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':sbas_id' => $this->get_sbas_id()));
$stmt->closeCursor();
$sql = "DELETE FROM sbasusr WHERE sbas_id = :sbas_id";
$stmt = $appbox->get_connection()->prepare($sql);
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':sbas_id' => $this->get_sbas_id()));
$stmt->closeCursor();
$appbox->delete_data_from_cache(appbox::CACHE_LIST_BASES);
$this->app['phraseanet.appbox']->delete_data_from_cache(appbox::CACHE_LIST_BASES);
return;
}

View File

@@ -1094,7 +1094,7 @@ class module_report_activity extends module_report
$stmt->closeCursor();
foreach ($rs as $row) {
$date = $this->app['date-formatter']->getPrettyString(new DateTime($row['ddate']));
$date = $app['date-formatter']->getPrettyString(new DateTime($row['ddate']));
$result[$date] = $row['activity'];
}

View File

@@ -382,7 +382,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function get_embedable_medias($devices = null, $mimes = null)
{
return $this->getSubdfefByDeviceAndMime($devices, $mimes);
}
@@ -715,9 +714,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$searchDevices = array_merge((array) $devices, (array) databox_subdef::DEVICE_ALL);
$type = $this->is_grouping() ? 'image' : $this->get_type();
foreach ($this->databox->get_subdef_structure() as $group => $databoxSubdefs) {
if ($this->get_type() != $group) {
if ($type != $group) {
continue;
}

View File

@@ -339,7 +339,7 @@ class recordutils_image extends recordutils
return $pathOut;
}
if ($app['phraseanet.registry']->get('GV_pathcomposite') &&
if ($app['phraseanet.registry']->get('composite_binary') &&
file_exists($app['phraseanet.registry']->get('GV_RootPath') . 'config/wm/' . $base_id)) {
$builder = ProcessBuilder::create(array(

View File

@@ -453,7 +453,7 @@ class set_export extends set_abstract
if ($rename_title) {
$title = strip_tags($download_element->get_title(null, null, true));
$files[$id]['export_name'] = $unicode->remove_nonazAZ09($title, true);
$files[$id]['export_name'] = $unicode->remove_nonazAZ09($title, true, true, true);
$rename_done = true;
} else {
$files[$id]["export_name"] = $infos['filename'];
@@ -611,8 +611,8 @@ class set_export extends set_abstract
$file_names[] = mb_strtolower($name);
$files[$id]["export_name"] = $name;
$files[$id]["export_name"] = $unicode->remove_nonazAZ09($files[$id]["export_name"]);
$files[$id]["original_name"] = $unicode->remove_nonazAZ09($files[$id]["original_name"]);
$files[$id]["export_name"] = $unicode->remove_nonazAZ09($files[$id]["export_name"], true, true, true);
$files[$id]["original_name"] = $unicode->remove_nonazAZ09($files[$id]["original_name"], true, true, true);
$i = 0;
$name = utf8_decode($files[$id]["export_name"]);
@@ -769,7 +769,11 @@ class set_export extends set_abstract
$unicode = new \unicode();
$disposition = $disposition === 'attachment' ? ResponseHeaderBag::DISPOSITION_ATTACHMENT : ResponseHeaderBag::DISPOSITION_INLINE;
$headerDisposition = $response->headers->makeDisposition($disposition, $exportname, $unicode->remove_nonazAZ09($exportname));
$headerDisposition = $response->headers->makeDisposition(
$disposition,
str_replace(array('/', '\\'), '', $exportname),
$unicode->remove_nonazAZ09($exportname, true, true, true)
);
if (is_file($file)) {
if ($app['phraseanet.registry']->get('GV_modxsendfile')) {
@@ -825,6 +829,7 @@ class set_export extends set_abstract
*/
public static function stream_data($data, $exportname, $mime, $disposition = 'attachment')
{
$unicode = new \unicode();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
@@ -835,7 +840,7 @@ class set_export extends set_abstract
header("Content-Length: " . strlen($data));
header("Cache-Control: max-age=3600, must-revalidate ");
header("Content-Disposition: " . $disposition
. "; filename=" . $exportname . ";");
. "; filename=" . str_replace(array('/', '\\'), '', $exportname) . ";");
echo $data;

View File

@@ -10,8 +10,10 @@
use Alchemy\Phrasea\Metadata\Tag as PhraseaTag;
use Alchemy\Phrasea\Border\Attribute as BorderAttribute;
use Alchemy\Phrasea\Border\MetadataBag;
use Alchemy\Phrasea\Border\MetaFieldsBag;
use PHPExiftool\Driver\Metadata\MetadataBag as ExiftoolMetadataBag;
use PHPExiftool\Driver\Metadata\Metadata;
use PHPExiftool\Driver\Metadata\MetadataBag;
use Symfony\Component\Filesystem\Exception\IOException;
/**
@@ -1614,22 +1616,20 @@ class task_period_archive extends task_abstract
$metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas());
if ($captionFile !== null && true === $this->dependencyContainer['filesystem']->exists($captionFile)) {
$caption = $this->readXMLForDatabox($metadatasStructure, $captionFile);
$metaFields = $this->readXMLForDatabox($metadatasStructure, $captionFile);
$captionStatus = $this->parseStatusBit(@simplexml_load_file($captionFile));
if ($captionStatus) {
$status = databox_status::operation_or($this->dependencyContainer, $status, $captionStatus);
}
$metadatas = $this->mergeForDatabox($metadatasStructure, $metadatas, $caption);
}
$metas = $this->bagToArray($metadatasStructure, $metadatas);
$story = record_adapter::createStory($this->dependencyContainer, $collection);
$story->substitute_subdef('document', $media, $this->dependencyContainer);
$story->set_metadatas($metas, true);
$story->set_metadatas($metadatas->toMetadataArray($metadatasStructure), true);
$story->set_metadatas($metaFields->toMetadataArray($metadatasStructure), true);
$story->set_binary_status(databox_status::operation_or($this->dependencyContainer, $stat0, $stat1));
$story->rebuild_subdefs();
$story->reindex();
@@ -1679,14 +1679,12 @@ class task_period_archive extends task_abstract
$metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas());
if ($captionFile !== null && true === $this->dependencyContainer['filesystem']->exists($captionFile)) {
$caption = $this->readXMLForDatabox($metadatasStructure, $captionFile);
$metaFields = $this->readXMLForDatabox($metadatasStructure, $captionFile);
$captionStatus = $this->parseStatusBit(@simplexml_load_file($captionFile));
if ($captionStatus) {
$status = databox_status::operation_or($this->dependencyContainer, $status, $captionStatus);
}
$metadatas = $this->mergeForDatabox($metadatasStructure, $metadatas, $caption);
}
$file = new \Alchemy\Phrasea\Border\File($this->dependencyContainer, $media, $collection);
@@ -1703,6 +1701,10 @@ class task_period_archive extends task_abstract
$file->addAttribute(new BorderAttribute\Metadata($meta));
}
foreach ($metaFields as $metaField) {
$file->addAttribute($metaField);
}
if ($grp_rid) {
$file->addAttribute(new BorderAttribute\Story(new record_adapter($this->dependencyContainer, $databox->get_sbas_id(), $grp_rid)));
}
@@ -2047,10 +2049,10 @@ class task_period_archive extends task_abstract
* indexed by **FieldNames**
*
* @param \databox_descriptionStructure $metadatasStructure The databox structure related
* @param MetadataBag $bag The metadata bag
* @param ExiftoolMetadataBag $bag The metadata bag
* @return MetadataBag
*/
protected function getIndexByFieldName(\databox_descriptionStructure $metadatasStructure, MetadataBag $bag)
protected function getIndexByFieldName(\databox_descriptionStructure $metadatasStructure, ExiftoolMetadataBag $bag)
{
$ret = new MetadataBag();
@@ -2063,121 +2065,6 @@ class task_period_archive extends task_abstract
return $ret;
}
/**
* Map a bag of metadatas indexed by **FieldNames** to an array ready for
* \record_adapter metadatas submission
*
* @param \databox_descriptionStructure $metadatasStructure The databox structure related
* @param MetadataBag $metadatas The metadata bag
* @return array
*/
protected function bagToArray(\databox_descriptionStructure $metadatasStructure, MetadataBag $metadatas)
{
$metas = array();
$unicode = new \unicode();
foreach ($metadatasStructure as $databox_field) {
if ($metadatas->containsKey($databox_field->get_tag()->getTagname())) {
if ($databox_field->is_multi()) {
$values = $metadatas->get($databox_field->get_tag()->getTagname())->getValue()->asArray();
$tmp = array();
foreach ($values as $value) {
foreach (\caption_field::get_multi_values($value, $databox_field->get_separator()) as $v) {
$tmp[] = $v;
}
}
$values = array_unique($tmp);
foreach ($values as $value) {
$value = $unicode->substituteCtrlCharacters($value, ' ');
$value = $unicode->toUTF8($value);
if ($databox_field->get_type() == 'date') {
$value = $unicode->parseDate($value);
}
$metas[] = array(
'meta_struct_id' => $databox_field->get_id(),
'value' => $value,
'meta_id' => null
);
}
} else {
$value = $metadatas->get($databox_field->get_tag()->getTagname())->getValue()->asString();
$value = $unicode->substituteCtrlCharacters($value, ' ');
$value = $unicode->toUTF8($value);
if ($databox_field->get_type() == 'date') {
$value = $unicode->parseDate($value);
}
$metas[] = array(
'meta_struct_id' => $databox_field->get_id(),
'value' => $metadatas->get($databox_field->get_tag()->getTagname())->getValue()->asString(),
'meta_id' => null
);
}
}
}
unset($unicode);
return $metas;
}
/**
* Merge two bags of metadatas indexed by **FieldNames**
* Return a bag indexed by **FieldNames**
*
* @param \databox_descriptionStructure $metadatasStructure The databox structure related
* @param MetadataBag $bag1 The first metadata bag
* @param MetadataBag $bag2 The second metadata bag
* @return \PHPExiftool\Driver\Metadata\MetadataBag
*/
protected function mergeForDatabox(\databox_descriptionStructure $metadatasStructure, MetadataBag $bag1, MetadataBag $bag2)
{
$metadatasBag = new MetadataBag();
foreach ($metadatasStructure as $databox_field) {
$value = array();
$tag = $databox_field->get_tag();
foreach (array($bag1, $bag2) as $bag) {
if ( ! $bag->containsKey($databox_field->get_name())) {
continue;
}
if ($databox_field->is_multi()) {
$value = array_unique(array_merge($value, $bag->get($databox_field->get_name())->getValue()->asArray()));
} else {
$value = $bag->get($databox_field->get_name())->getValue()->asString();
}
}
if ( ! $value) {
continue;
}
if ($databox_field->is_multi()) {
$value = new \PHPExiftool\Driver\Value\Multi($value);
} else {
$value = new \PHPExiftool\Driver\Value\Mono($value);
}
$metadatasBag->set($databox_field->get_name(), new PHPExiftool\Driver\Metadata\Metadata($tag, $value));
}
return $metadatasBag;
}
protected function readXMLForDatabox(\databox_descriptionStructure $metadatasStructure, $pathfile)
{
if (false === $this->dependencyContainer['filesystem']->exists($pathfile)) {
@@ -2188,10 +2075,7 @@ class task_period_archive extends task_abstract
throw new \InvalidArgumentException(sprintf('Invalid XML file %s', $pathfile));
}
/**
* @todo update with metafield, ensure that metafield primes on metadata
*/
$metadataBag = new MetadataBag();
$metadataBag = new MetaFieldsBag();
foreach ($sxcaption->description->children() as $tagname => $field) {
$field = trim($field);
@@ -2201,27 +2085,18 @@ class task_period_archive extends task_abstract
continue;
}
$tag = $meta->get_tag();
if ($meta->is_multi()) {
$fields = caption_field::get_multi_values($field, $meta->get_separator());
if ( ! $metadataBag->containsKey($meta->get_name())) {
$values = new \PHPExiftool\Driver\Value\Multi($fields);
$values = $fields;
} else {
$values = $metadataBag->get($meta->get_name())->getValue();
foreach ($fields as $f) {
$values->addValue($f);
}
$values = array_merge($metadataBag->get($meta->get_name())->getValue(), $fields);
}
/**
* fail if not tagname defined
*/
$metadataBag->set($meta->get_name(), new \PHPExiftool\Driver\Metadata\Metadata($tag, $values));
$metadataBag->set($meta->get_name(), new BorderAttribute\MetaField($meta, $values));
} else {
$metadataBag->set($meta->get_name(), new \PHPExiftool\Driver\Metadata\Metadata($tag, new \PHPExiftool\Driver\Value\Mono($field)));
$metadataBag->set($meta->get_name(), new BorderAttribute\MetaField($meta, array($field)));
}
}

View File

@@ -189,7 +189,7 @@
</div>
<div>
<p>{% trans 'export::mail: contenu du mail' %}</p>
<textarea rows="10" style="width:100%; white-space:pre;" name="textmail" id="sendmail_message"></textarea>
<textarea rows="6" style="width:90%; white-space:pre;resize:none;" name="textmail" id="sendmail_message"></textarea>
</div>
<div>
<p>{% trans 'export::mail: fichiers joint' %}</p>
@@ -679,10 +679,16 @@
$('#order .order_button_loader').css('visibility','hidden');
if(!data.error) {
var title = '{% trans "Success" %}';
} else {
var title = '{% trans "Warning !" %}';
}
var options = {
size : 'Alert',
closeButton: true,
title : '{% trans "Warning !" %}'
title : title
};
p4.Dialog.Create(options, 2).setContent(data.message);

View File

@@ -1,4 +1,8 @@
{% trans 'Record_id' %} : {{ record.get_record_id() }}<br/>
{% if record.is_grouping() %}
{% trans 'Story_id' %} : {{ record.get_record_id() }}<br/>
{% else %}
{% trans 'Record_id' %} : {{ record.get_record_id() }}<br/>
{% endif %}
{% if record.is_grouping() == false %}

View File

@@ -7,7 +7,6 @@
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="/include/minify/g=lightboxie6"></script>
<script type="text/javascript" src="include/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
{% endblock %}
{% block stylesheet %}

View File

@@ -7,7 +7,6 @@
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="/include/minify/g=lightboxie6"></script>
<script type="text/javascript" src="include/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
{% endblock %}
{% block stylesheet %}

View File

@@ -7,7 +7,6 @@
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="/include/minify/g=lightbox"></script>
<script type="text/javascript" src="/include/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
{% endblock %}
{% block stylesheet %}

View File

@@ -1,9 +1,8 @@
{% if basket_element and basket_element.getBasket().getValidation() %}
<div class="notes_wrapper">
<div class="notes_overlay">
</div>
<div class="notes">
<div>
<div class="notes_wrapper">
<div class="notes_overlay"></div>
<div class="notes well-small">
<div class="well-small">
<h2 class="title15">{% trans 'validation:: votre note' %}</h2>
</div>
<hr/>
@@ -29,5 +28,5 @@
</div>
</form>
</div>
</div>
</div>
{% endif %}

View File

@@ -1,33 +1,33 @@
<span style="padding:10px 4px 7px;">
{% if basket_element %}
<button class="previous_button play" title="{% trans 'boutton::precedent' %}">
<img src="/skins/lightbox/prev.png" />
<button class="previous_button play btn btn-mini" title="{% trans 'boutton::precedent' %}">
<i class="icon-chevron-left"></i>
</button>
<button class="previous_button pause" title="{% trans 'boutton::precedent' %}">
<img src="/skins/lightbox/prev_pause.png" />
<button class="previous_button pause btn btn-mini btn-inverse" title="{% trans 'boutton::precedent' %}">
<i class="icon-chevron-left icon-white"></i>
</button>
<button class="play_button" title="{% trans 'boutton::demarrer' %}">
<img src="/skins/lightbox/play.png" />
<button class="play_button btn btn-mini" title="{% trans 'boutton::demarrer' %}">
<i class="icon-play"></i>
</button>
<button class="pause_button" title="{% trans 'boutton::pause' %}">
<img src="/skins/lightbox/pause.png" />
<button class="pause_button btn btn-mini" title="{% trans 'boutton::pause' %}">
<i class="icon-pause"></i>
</button>
<button class="next_button play" title="{% trans 'boutton::suivant' %}">
<img src="/skins/lightbox/next.png" />
<button class="next_button play btn btn-mini" title="{% trans 'boutton::suivant' %}">
<i class="icon-chevron-right"></i>
</button>
<button class="next_button pause" title="{% trans 'boutton::suivant' %}">
<img src="/skins/lightbox/next_pause.png" />
<button class="next_button pause btn btn-mini btn-inverse" title="{% trans 'boutton::suivant' %}">
<i class="icon-chevron-right icon-white"></i>
</button>
<button class="download_button" title="{% trans 'boutton::telecharger' %}">
<img src="/skins/lightbox/save.png"/>
<button class="download_button btn btn-mini btn-inverse" title="{% trans 'boutton::telecharger' %}">
<i class="icon-download icon-white"></i>
</button>
<form name="download_form" style="display:none;">
<input type="hidden" name="basrec" value="{{basket_element.getRecord(app).get_serialize_key()}}"/>
</form>
|
{% if basket_element.getBasket().getValidation() %}
<button class="comment_button">
<img src="/skins/lightbox/note.png"/>
<button class="comment_button btn btn-mini btn-inverse">
<i class="icon-edit icon-white"></i>
{% set n = 0 %}
{% for validationData in basket_element.getValidationDatas() %}
{% if validationData.getNote() %}

View File

@@ -7,7 +7,6 @@
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="/include/minify/g=lightbox"></script>
<script type="text/javascript" src="/include/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
{% endblock %}
{% block stylesheet %}
@@ -50,7 +49,7 @@
</tr>
</table>
</div>
<div class="container PNB">
<div class="container PNB record_display_box">
{% if basket_element %}
{% set bask_prev = basket_element.getRecord(app).get_preview() %}

View File

@@ -13,6 +13,7 @@
{% endtrans %}
{% endif %}
</li>
{% if element.get_ratings is defined %}
{% set nb_rating = element.get_ratings|default(0) %}
{% if element.get_rating > 0 %}
<li>
@@ -23,4 +24,5 @@
{% endtrans %}
</li>
{% endif %}
{% endif %}
</ul>

View File

@@ -368,7 +368,7 @@ $(function() {
var account_id = $('form[name="current_datas"] input[name="account_id"]').val();
$('input[name="account_id"]', $form).val(account_id);
var $panel = $('#pub_tabs .ui-tabs-panel');
var $panel = $('#pub_tabs .ui-tabs-panel:visible');
$.ajax({
type : 'GET',

View File

@@ -1026,7 +1026,6 @@
</script>
<script type="text/javascript" src="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/g=prod"></script>
<script type="text/javascript" src="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/f=include/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
$(document).ready(function(){
p4.reg_delete="{% if app['phraseanet.user'].getPrefs("warning_on_delete_story") %}true{% else %}false{% endif %}";

View File

@@ -1,12 +1,13 @@
<div id="lazaretBox" class="container-fluid">
{% if lazaretFiles is not none %}
{% if lazaretFiles|length > 0 %}
<div class="btn-group" style="text-align:center; padding:5px;">
<button class="btn empty-lazaret" title="{% trans "Empty quarantine"%}">
<img src="/skins/icons/delete.png">{% trans "Empty quarantine"%}
</button>
</div>
{% if lazaretFiles is not none %}
{% if lazaretFiles|length > 0 %}
<ul>
{% for file in lazaretFiles %}
<li class="row-fluid wrapper-item well">

View File

@@ -18,11 +18,11 @@
</ul>
{# upload tab content #}
<div id="tab-upload">
{% if collections|length > 0 %}
<form id="fileupload" enctype="multipart/form-data" method="POST" action="/prod/upload/">
<div id="uploadBoxLeft" class="well">
{# <h5 style="margin-top: 10px;">{% trans 'Choose files to add' %} :</h5> #}
{# action bar #}
<table id="addFileList">
<tr>
@@ -55,7 +55,6 @@
<div class='settings-box'>
<h5>{% trans 'upload:: Destination (collection) :' %} :</h5>
{# collections list #}
{% if collections|length > 0 %}
<select name="base_id" class="span3" style="margin-left: 10px;">
{% for sbasId, availableCollections in collections %}
<optgroup label="{{ availableCollections['databox'].get_viewname() }}" class="select-label">
@@ -100,9 +99,6 @@
</div>
{% endfor %}
{% endfor %}
{% else %}
{% trans 'You can not upload files' %}
{% endif %}
</div>
{# upload box #}
@@ -134,6 +130,9 @@
</div>
</form>
{% else %}
{% trans 'You can not upload files' %}
{% endif %}
</div>
</div>
</div>
@@ -339,7 +338,7 @@ $(document).ready(function () {
return false;
},
fail: function(){
//disabled cancel-all button, if queue is emepty and last upload fail
//disabled cancel-all button, if queue is empty and last upload fail
if (UploaderManager.Queue.isEmpty()){
$("#cancel-all").attr("disabled", true);
}
@@ -396,10 +395,12 @@ $(document).ready(function () {
if (errorThrown === 'abort') {
return false;
} else {
data.context.find('.upload-record p.error').append(jqXHR.responseText);
data.context.find('.upload-record p.error').append(jqXHR.status + " " + jqXHR.statusText).show();
}
//Remove data
UploaderManager.removeData(data.uploadIndex);
// Remove cancel button
$('button.remove-element', data.context).remove();
});
//cancel request

View File

@@ -514,7 +514,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
* @covers \API_V1_adapter::get_record
* @covers \API_V1_adapter::list_record
*/
public function testDataboxRecordRoute()
public function testRecordRoute()
{
$this->setToken(self::$token);
@@ -536,6 +536,41 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
}
/**
* @covers \API_V1_adapter::get_story
* @covers \API_V1_adapter::list_story
*/
public function testStoryRoute()
{
$this->setToken(self::$token);
self::$DI['app']['session']->set('usr_id', self::$DI['user']->get_id());
if (!self::$DI['record_story_1']->hasChild(self::$DI['record_1'])) {
self::$DI['record_story_1']->appendChild(self::$DI['record_1']);
}
self::$DI['app']['session']->remove('usr_id');
$route = '/stories/' . self::$DI['record_story_1']->get_sbas_id() . '/' . self::$DI['record_story_1']->get_record_id() . '/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType()));
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
$this->evaluateResponse200(self::$DI['client']->getResponse());
$this->evaluateMeta200($content);
$this->evaluateGoodStory($content['response']['story']);
$this->assertGreaterThan(0, $content['response']['story']['records']);
$route = '/stories/1234567890/1/';
$this->evaluateNotFoundRoute($route, array('GET'));
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$route = '/stories/kjslkz84spm/sfsd5qfsd5/';
$this->evaluateBadRequestRoute($route, array('GET'));
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
}
/**
* @covers \API_V1_adapter::get_databox_collections
* @covers \API_V1_adapter::list_databox_collections
@@ -741,6 +776,75 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
}
/**
* @covers \API_V1_adapter::search
* @covers \API_V1_adapter::list_record
* @covers \API_V1_adapter::list_story
*/
public function testSearchRoute()
{
$this->setToken(self::$token);
$crawler = self::$DI['client']->request('POST', '/search/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType()));
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
$this->evaluateResponse200(self::$DI['client']->getResponse());
$this->evaluateMeta200($content);
$response = $content['response'];
$this->evaluateSearchResponse($response);
$this->assertArrayHasKey('stories', $response['results']);
$this->assertArrayHasKey('records', $response['results']);
$found = false;
foreach ($response['results']['records'] as $record) {
$this->evaluateGoodRecord($record);
$found = true;
}
if (!$found) {
$this->fail('Unable to find record back');
}
}
/**
* @covers \API_V1_adapter::search
* @covers \API_V1_adapter::list_record
* @covers \API_V1_adapter::list_story
*/
public function testSearchRouteWithStories()
{
$this->setToken(self::$token);
self::$DI['record_story_1'];
$crawler = self::$DI['client']->request('POST', '/search/', $this->getParameters(array('search_type' => 1)), array(), array('HTTP_Accept' => $this->getAcceptMimeType()));
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
$this->evaluateResponse200(self::$DI['client']->getResponse());
$this->evaluateMeta200($content);
$response = $content['response'];
$this->evaluateSearchResponse($response);
$this->assertArrayHasKey('stories', $response['results']);
$this->assertArrayHasKey('records', $response['results']);
$found = false;
foreach ($response['results']['stories'] as $story) {
$this->evaluateGoodStory($story);
$found = true;
}
if (!$found) {
$this->fail('Unable to find story back');
}
}
/**
* @covers \API_V1_adapter::search_records
* @covers \API_V1_adapter::list_record
@@ -756,27 +860,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$response = $content['response'];
$this->assertArrayHasKey('available_results', $response);
$this->assertArrayHasKey('total_results', $response);
$this->assertArrayHasKey('error', $response);
$this->assertArrayHasKey('warning', $response);
$this->assertArrayHasKey('query_time', $response);
$this->assertArrayHasKey('search_indexes', $response);
$this->assertArrayHasKey('suggestions', $response);
$this->assertArrayHasKey('results', $response);
$this->assertArrayHasKey('query', $response);
$this->assertTrue(is_int($response['available_results']), 'Le nombre de results dispo est un int');
$this->assertTrue(is_int($response['total_results']), 'Le nombre de results est un int');
$this->assertTrue(is_string($response['error']), 'Error est une string');
$this->assertTrue(is_string($response['warning']), 'Warning est une string');
// $this->assertTrue(is_string($response['query_time']));
$this->assertTrue(is_string($response['search_indexes']));
$this->assertTrue(is_array($response['suggestions']));
$this->assertTrue(is_array($response['results']));
$this->assertTrue(is_string($response['query']));
$this->evaluateSearchResponse($response);
foreach ($response['results'] as $record) {
$this->evaluateGoodRecord($record);
@@ -897,6 +981,43 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
}
/**
* @covers \API_V1_adapter::get_record_embed
* @covers \API_V1_adapter::list_embedable_media
* @covers \API_V1_adapter::list_permalink
*/
public function testStoriesEmbedRoute()
{
$this->setToken(self::$token);
$media = self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../testfiles/cestlafete.jpg');
self::$DI['record_story_1']->substitute_subdef('preview', $media, self::$DI['app']);
self::$DI['record_story_1']->substitute_subdef('thumbnail', $media, self::$DI['app']);
$keys = array_keys(self::$DI['record_story_1']->get_subdefs());
$route = '/stories/' . self::$DI['record_story_1']->get_sbas_id() . '/' . self::$DI['record_story_1']->get_record_id() . '/embed/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType()));
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
$this->evaluateResponse200(self::$DI['client']->getResponse());
$this->evaluateMeta200($content);
$this->assertArrayHasKey('embed', $content['response']);
foreach ($content['response']['embed'] as $embed) {
$this->checkEmbed($embed, self::$DI['record_story_1']);
}
$route = '/stories/24892534/51654651553/embed/';
$this->evaluateNotFoundRoute($route, array('GET'));
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$route = '/stories/any_bad_id/sfsd5qfsd5/embed/';
$this->evaluateBadRequestRoute($route, array('GET'));
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
}
/**
* @covers \API_V1_adapter::get_record_embed
*/
@@ -2059,7 +2180,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->assertArrayHasKey('response', $content);
$this->assertTrue(is_array($content['meta']), 'Le bloc meta est un array');
$this->assertTrue(is_array($content['response']), 'Le bloc reponse est un array');
$this->assertEquals('1.2', $content['meta']['api_version']);
$this->assertEquals('1.3', $content['meta']['api_version']);
$this->assertNotNull($content['meta']['response_time']);
$this->assertEquals('UTF-8', $content['meta']['charset']);
}
@@ -2219,6 +2340,61 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
}
}
protected function evaluateGoodStory($story)
{
$this->assertArrayHasKey('databox_id', $story);
$this->assertTrue(is_int($story['databox_id']));
$this->assertArrayHasKey('story_id', $story);
$this->assertTrue(is_int($story['story_id']));
$this->assertArrayHasKey('updated_on', $story);
$this->assertDateAtom($story['updated_on']);
$this->assertArrayHasKey('created_on', $story);
$this->assertDateAtom($story['created_on']);
$this->assertArrayHasKey('collection_id', $story);
$this->assertTrue(is_int($story['collection_id']));
$this->assertArrayHasKey('thumbnail', $story);
$this->assertArrayHasKey('uuid', $story);
$this->assertArrayHasKey('@entity@', $story);
$this->assertEquals(\API_V1_adapter::OBJECT_TYPE_STORY, $story['@entity@']);
$this->assertTrue(\uuid::is_valid($story['uuid']));
if ( ! is_null($story['thumbnail'])) {
$this->assertTrue(is_array($story['thumbnail']));
$this->assertArrayHasKey('player_type', $story['thumbnail']);
$this->assertTrue(is_string($story['thumbnail']['player_type']));
$this->assertArrayHasKey('permalink', $story['thumbnail']);
$this->assertArrayHasKey('mime_type', $story['thumbnail']);
$this->assertTrue(is_string($story['thumbnail']['mime_type']));
$this->assertArrayHasKey('height', $story['thumbnail']);
$this->assertTrue(is_int($story['thumbnail']['height']));
$this->assertArrayHasKey('width', $story['thumbnail']);
$this->assertTrue(is_int($story['thumbnail']['width']));
$this->assertArrayHasKey('filesize', $story['thumbnail']);
$this->assertTrue(is_int($story['thumbnail']['filesize']));
}
$this->assertArrayHasKey('records', $story);
$this->assertInternalType('array', $story['records']);
foreach ($story['metadatas'] as $key => $metadata) {
if (null !== $metadata) {
$this->assertInternalType('string', $metadata);
}
if ($key === '@entity@') {
continue;
}
$this->assertEquals(0, strpos($key, 'dc:'));
}
$this->assertArrayHasKey('@entity@', $story['metadatas']);
$this->assertEquals(\API_V1_adapter::OBJECT_TYPE_STORY_METADATA_BAG, $story['metadatas']['@entity@']);
foreach ($story['records'] as $record) {
$this->evaluateGoodRecord($record);
}
}
protected function evaluateRecordsCaptionResponse($content)
{
$this->assertArrayHasKey('caption_metadatas', $content['response']);
@@ -2313,4 +2489,28 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
{
unset($_GET['oauth_token']);
}
private function evaluateSearchResponse($response)
{
$this->assertArrayHasKey('available_results', $response);
$this->assertArrayHasKey('total_results', $response);
$this->assertArrayHasKey('error', $response);
$this->assertArrayHasKey('warning', $response);
$this->assertArrayHasKey('query_time', $response);
$this->assertArrayHasKey('search_indexes', $response);
$this->assertArrayHasKey('suggestions', $response);
$this->assertArrayHasKey('results', $response);
$this->assertArrayHasKey('query', $response);
$this->assertTrue(is_int($response['available_results']), 'Le nombre de results dispo est un int');
$this->assertTrue(is_int($response['total_results']), 'Le nombre de results est un int');
$this->assertTrue(is_string($response['error']), 'Error est une string');
$this->assertTrue(is_string($response['warning']), 'Warning est une string');
$this->assertTrue(is_string($response['search_indexes']));
$this->assertTrue(is_array($response['suggestions']));
$this->assertTrue(is_array($response['results']));
$this->assertTrue(is_string($response['query']));
}
}

View File

@@ -138,4 +138,13 @@ class oauthv2_application_test extends \PhraseanetWebTestCaseAuthenticatedAbstra
$this->assertRegExp("/" . $this->queryParameters["scope"] . "/", self::$DI['client']->getResponse()->getContent());
$this->assertRegExp("/" . $this->queryParameters["state"] . "/", self::$DI['client']->getResponse()->getContent());
}
public function testGetTokenNotHTTPS()
{
$this->setQueryParameters('grant_type', 'authorization_code');
$this->setQueryParameters('code', '12345678918');
self::$DI['client']->request('POST', '/token', $this->queryParameters);
$this->assertEquals(400, self::$DI['client']->getResponse()->getStatusCode());
}
}

View File

@@ -46,8 +46,8 @@ class ApplicationOverviewTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue($response->isOk());
$this->assertNotNull($response->getEtag());
$this->assertInstanceOf('DateTime', $response->getLastModified());
$this->assertNull($response->getMaxAge());
$this->assertNull($response->getTtl());
$this->assertEquals(0, $response->getMaxAge());
$this->assertEquals(0, $response->getTtl());
$this->assertGreaterThanOrEqual(0, $response->getAge());
$this->assertNull($response->getExpires());

View File

@@ -61,7 +61,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
$this->markTestSkipped('No databox field found');
}
$metafield = new MetaField($databox_field, 'value');
$metafield = new MetaField($databox_field, array('value'));
$attribute = Factory::getFileAttribute(self::$DI['app'], AttributeInterface::NAME_METAFIELD, $metafield->asString());

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Border\Attribute;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
@@ -19,7 +28,7 @@ class MetaFieldTest extends \PhraseanetPHPUnitAbstract
*/
public function setUp()
{
$this->value = "Un éléphant ça trompe";
$this->value = array("Un éléphant ça trompe");
foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $databox_field) {
$this->databox_field = $databox_field;
break;
@@ -48,17 +57,8 @@ class MetaFieldTest extends \PhraseanetPHPUnitAbstract
*/
public function testConstruct()
{
new MetaField($this->databox_field, 0.57);
new MetaField($this->databox_field, 3);
}
/**
* @covers Alchemy\Phrasea\Border\Attribute\MetaField::__construct
* @expectedException \InvalidArgumentException
*/
public function testConstructFail()
{
new MetaField($this->databox_field, array(22));
new MetaField($this->databox_field, array(0.57));
new MetaField($this->databox_field, array(3));
}
/**

View File

@@ -170,7 +170,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$value = new \PHPExiftool\Driver\Value\Mono(current($data));
$tofetch [$databox_field->get_name()] = $data;
$file->addAttribute(new Attribute\MetaField($databox_field, current($data)));
$file->addAttribute(new Attribute\MetaField($databox_field, array(current($data))));
}
}
if ($first) {
@@ -277,7 +277,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
} else {
$tofetchField [$databox_field->get_name()] = $data;
$file->addAttribute(new Attribute\MetaField($databox_field, current($data)));
$file->addAttribute(new Attribute\MetaField($databox_field, array(current($data))));
}
}

View File

@@ -0,0 +1,76 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Border;
use Alchemy\Phrasea\Border\Attribute\MetaField;
require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class MetaFieldsBagTest extends \PhraseanetPHPUnitAbstract
{
/**
* @var MetaFieldsBag
*/
protected $object;
public function setUp()
{
parent::setUp();
$this->object = new MetaFieldsBag;
}
/**
* @covers Alchemy\Phrasea\Border\MetadataBag::toMetadataArray
*/
public function testToMetadataArray()
{
$structure = self::$DI['collection']->get_databox()->get_meta_structure();
$monoAdded = $multiAdded = false;
foreach ($structure as $databox_field) {
if (!$monoAdded) {
$this->object->set($databox_field->get_name(), new MetaField($databox_field, array('mono value')));
$monoAdded = $databox_field->get_id();
} elseif (!$multiAdded) {
if ($databox_field->is_multi()) {
$this->object->set($databox_field->get_name(), new MetaField($databox_field, array('multi', 'value')));
$multiAdded = $databox_field->get_id();
}
} else {
break;
}
}
if (!$multiAdded || !$monoAdded) {
$this->markTestSkipped('Unable to find multi value field');
}
$this->assertEquals(array(
array(
'meta_struct_id' => $monoAdded,
'value' => 'mono value',
'meta_id' => null
),
array(
'meta_struct_id' => $multiAdded,
'value' => 'multi',
'meta_id' => null
),
array(
'meta_struct_id' => $multiAdded,
'value' => 'value',
'meta_id' => null
),
), $this->object->toMetadataArray($structure));
}
}

View File

@@ -0,0 +1,81 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Border;
use PHPExiftool\Driver\Metadata\Metadata;
use PHPExiftool\Driver\Value\Mono;
use PHPExiftool\Driver\Value\Multi;
require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class MetadataBagTest extends \PhraseanetPHPUnitAbstract
{
/**
* @var MetadataBag
*/
protected $object;
public function setUp()
{
parent::setUp();
$this->object = new MetadataBag;
}
/**
* @covers Alchemy\Phrasea\Border\MetadataBag::toMetadataArray
*/
public function testToMetadataArray()
{
$structure = self::$DI['collection']->get_databox()->get_meta_structure();
$valueMono = new Mono('mono value');
$valueMulti = new Multi(array('multi', 'value'));
$monoAdded = $multiAdded = false;
foreach ($structure as $databox_field) {
if (!$monoAdded) {
$this->object->set($databox_field->get_tag()->getTagname(), new Metadata($databox_field->get_tag(), $valueMono));
$monoAdded = $databox_field->get_id();
} elseif (!$multiAdded) {
if ($databox_field->is_multi()) {
$this->object->set($databox_field->get_tag()->getTagname(), new Metadata($databox_field->get_tag(), $valueMulti));
$multiAdded = $databox_field->get_id();
}
} else {
break;
}
}
if (!$multiAdded || !$monoAdded) {
$this->markTestSkipped('Unable to find multi value field');
}
$this->assertEquals(array(
array(
'meta_struct_id' => $monoAdded,
'value' => 'mono value',
'meta_id' => null
),
array(
'meta_struct_id' => $multiAdded,
'value' => 'multi',
'meta_id' => null
),
array(
'meta_struct_id' => $multiAdded,
'value' => 'value',
'meta_id' => null
),
), $this->object->toMetadataArray($structure));
}
}

View File

@@ -69,7 +69,7 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true);
$base = $this->createDatabox();
$base->unmount_databox(self::$DI['app']['phraseanet.appbox']);
$base->unmount_databox();
self::$DI['client']->request('POST', '/admin/databoxes/mount/', array(
'new_dbname' => 'unit_test_db'
@@ -87,7 +87,7 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
try {
$databox = self::$DI['app']['phraseanet.appbox']->get_databox($databoxId);
$databox->unmount_databox(self::$DI['app']['phraseanet.appbox']);
$databox->unmount_databox();
$databox->delete();
} catch (\Exception_DataboxNotFound $e) {
$this->fail('databox not mounted');
@@ -149,7 +149,7 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$explode = explode('/', $uriRedirect);
$databoxId = $explode[3];
$databox = self::$DI['app']['phraseanet.appbox']->get_databox($databoxId);
$databox->unmount_databox(self::$DI['app']['phraseanet.appbox']);
$databox->unmount_databox();
$databox->delete();
unset($stmt, $databox);

View File

@@ -68,13 +68,11 @@ class TaskManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract {
}
public function testRouteTaskManager_scheduler_log() {
$task_manager = new \task_manager(self::$DI['app']);
self::$DI['client']->request('GET', '/admin/task-manager/scheduler/log');
self::$DI['client']->request(
'GET', '/admin/task-manager/scheduler/log', array()
);
$response = self::$DI['client']->getResponse();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
}
}

View File

@@ -25,8 +25,6 @@ class Feed_Entry_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$auth = new Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
self::$feed = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$feed_title, self::$feed_subtitle);
$publisher = Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], self::$feed, self::$DI['user']);

View File

@@ -36,8 +36,6 @@ class Feed_Entry_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$auth = new Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
self::$feed = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$feed_title, self::$feed_subtitle);
$publisher = Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], self::$feed, self::$DI['user']);

View File

@@ -31,8 +31,6 @@ class Feed_Entry_ItemTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$auth = new Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
self::$feed = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$feed_title, self::$feed_subtitle);
$publisher = Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], self::$feed, self::$DI['user']);

View File

@@ -15,8 +15,6 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$auth = new Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
self::$object = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$title, self::$subtitle);
}

View File

@@ -15,8 +15,6 @@ class Feed_AggregateTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$auth = new Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
$objects[] = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$title, self::$subtitle);
$objects[] = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$title, self::$subtitle);

View File

@@ -15,8 +15,6 @@ class Feed_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$auth = new Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
self::$object = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$title, self::$subtitle);
self::$object->set_public(true);
}

View File

@@ -19,8 +19,7 @@ class Feed_Publisher_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$auth = new Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
self::$feed = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$title, self::$subtitle);
$publishers = self::$feed->get_publishers();
self::$object = array_pop($publishers);

View File

@@ -2,6 +2,7 @@
require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
use Alchemy\Phrasea\Border\File as BorderFile;
use Symfony\Component\HttpFoundation\Request;
class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
@@ -87,7 +88,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_version()
{
$this->assertEquals('1.2', $this->object->get_version());
$this->assertEquals('1.3', $this->object->get_version());
}
public function testGet_databoxes()
@@ -157,23 +158,199 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
}
}
public function testSearch_records()
public function testSearch_recordsWithRecords()
{
$request = new Request(array('record_type' => "image"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
/**
* to remove after having merge SearchEngine PR
*/
\phrasea::start(self::$DI['app']['phraseanet.configuration']);
$auth = new \Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
$record = \record_adapter::createFromFile(BorderFile::buildFromPathfile(__DIR__ . '/../../testfiles/cestlafete.jpg', self::$DI['collection'], self::$DI['app']), self::$DI['app']);
$request = new Request(array('record_type' => "image", 'search_type' => 0), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$result = $this->object->search_records($request);
$this->assertEquals(200, $result->get_http_code());
$this->assertEquals('application/json', $result->get_content_type());
$this->assertTrue(is_array(json_decode($result->format(), true)));
$data = json_decode($result->format(), true);
$found = false;
foreach ($data['response']['results'] as $retRecord) {
if($retRecord['record_id'] == $record->get_record_id() && $retRecord['databox_id'] == $record->get_sbas_id()) {
$found = true;
break;
}
}
if (!$found) {
$this->fail('unable to find the record back');
}
}
public function testSearch_recordsWithStories()
{
/**
* to remove after having merge SearchEngine PR
*/
\phrasea::start(self::$DI['app']['phraseanet.configuration']);
$auth = new \Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
$story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']);
if (!$story->hasChild(self::$DI['record_1'])) {
$story->appendChild(self::$DI['record_1']);
}
$request = new Request(array('search_type' => 1), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$result = $this->object->search_records($request);
$this->assertEquals(200, $result->get_http_code());
$this->assertEquals('application/json', $result->get_content_type());
$this->assertTrue(is_array(json_decode($result->format(), true)));
$data = json_decode($result->format(), true);
$found = false;
foreach ($data['response']['results'] as $retStory) {
if($retStory['record_id'] == $story->get_record_id() && $retStory['databox_id'] == $story->get_sbas_id()) {
$found = true;
break;
}
}
if (!$found) {
$this->fail('unable to find the story back');
}
}
public function testSearchWithStories()
{
/**
* to remove after having merge SearchEngine PR
*/
\phrasea::start(self::$DI['app']['phraseanet.configuration']);
$auth = new \Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
$story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']);
if (!$story->hasChild(self::$DI['record_1'])) {
$story->appendChild(self::$DI['record_1']);
}
$request = new Request(array('search_type' => 1), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$result = $this->object->search($request);
$this->assertEquals(200, $result->get_http_code());
$this->assertEquals('application/json', $result->get_content_type());
$this->assertTrue(is_array(json_decode($result->format(), true)));
$data = json_decode($result->format(), true);
$this->assertArrayHasKey('records', $data['response']['results']);
$this->assertArrayHasKey('stories', $data['response']['results']);
$found = false;
foreach ($data['response']['results']['stories'] as $retStory) {
if($retStory['story_id'] == $story->get_record_id() && $retStory['databox_id'] == $story->get_sbas_id()) {
$found = true;
break;
}
}
if (!$found) {
$this->fail('unable to find the story back');
}
}
public function testSearchWithRecords()
{
/**
* to remove after having merge SearchEngine PR
*/
\phrasea::start(self::$DI['app']['phraseanet.configuration']);
$auth = new \Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
$record = \record_adapter::createFromFile(BorderFile::buildFromPathfile(__DIR__ . '/../../testfiles/cestlafete.jpg', self::$DI['collection'], self::$DI['app']), self::$DI['app']);
$request = new Request(array('search_type' => 0), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$result = $this->object->search($request);
$this->assertEquals(200, $result->get_http_code());
$this->assertEquals('application/json', $result->get_content_type());
$this->assertTrue(is_array(json_decode($result->format(), true)));
$data = json_decode($result->format(), true);
$this->assertArrayHasKey('records', $data['response']['results']);
$this->assertArrayHasKey('stories', $data['response']['results']);
$found = false;
foreach ($data['response']['results']['records'] as $retRecord) {
if($retRecord['record_id'] == $record->get_record_id() && $retRecord['databox_id'] == $record->get_sbas_id()) {
$found = true;
break;
}
}
if (!$found) {
$this->fail('unable to find the record back');
}
}
public function testGet_record_related()
{
$basketElement = $this->insertOneBasketElement();
$basketElement->setRecord(self::$DI['record_1']);
$story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']);
if (!$story->hasChild(self::$DI['record_1'])) {
$story->appendChild(self::$DI['record_1']);
}
self::$DI['app']['EM']->flush($basketElement);
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$result = $this->object->get_record_related($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id());
$this->assertEquals(200, $result->get_http_code());
$this->assertEquals('application/json', $result->get_content_type());
$this->assertTrue(is_array(json_decode($result->format(), true)));
$data = json_decode($result->format(), true);
$this->assertArrayHasKey('baskets', $data['response']);
$this->assertArrayHasKey('stories', $data['response']);
$found = false;
foreach ($data['response']['baskets'] as $bask) {
if ($bask['basket_id'] == $basketElement->getBasket()->getId()) {
$found = true;
break;
}
}
if (!$found) {
$this->fail('unable to find the basket back');
}
$found = false;
foreach ($data['response']['stories'] as $retStory) {
if ($retStory['story_id'] == $story->get_record_id() && $retStory['databox_id'] == $story->get_sbas_id()) {
$found = true;
break;
}
}
if (!$found) {
$this->fail('unable to find the story back');
}
}
public function testGet_record_metadatas()
@@ -222,7 +399,6 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$caption_field_value = caption_Field_Value::create(self::$DI['app'], databox_field::get_instance(self::$DI['app'], $databox, 1), self::$DI['record_1'], 'my value');
}
//valide metas
$metadatas = array();
foreach (self::$DI['record_1']->get_databox()->get_meta_structure()->get_elements() as $field) {
@@ -478,30 +654,6 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$feed->delete();
}
public function testSearch_users()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
public function testGet_user_acces()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
public function testAdd_user()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
protected function checkResponseField(API_V1_result $result, $field, $type)
{
$response = json_decode($result->format(), true);

View File

@@ -43,7 +43,14 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals(0, sizeof(get_class_methods($response->response)));
$this->checkResponseFieldMeta($response, "api_version", "my_super_version1.0", PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
$this->checkResponseFieldMeta($response, "request", "GET my/base/path/my/request/uri", PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
// $this->checkResponseFieldMeta($response, "response_time", $date->format(DATE_ATOM), PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
$date = new \DateTime();
$now = $date->format('U');
$date_query = \DateTime::createFromFormat(DATE_ATOM, $response->meta->response_time);
$now_query = $date_query->format('U');
$this->assertLessThan(1, $now_query - $now);
$this->assertDateAtom($response->meta->response_time);
$date = new DateTime();
@@ -143,6 +150,42 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->checkResponseFieldResponse($response, "bob", array("bob"), PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY);
}
public function testGet_datas()
{
$server = array(
"HTTP_ACCEPT" => "application/json"
, 'REQUEST_METHOD' => 'GET'
, 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename'
, "REQUEST_URI" => "my/base/path/my/request/uri"
, 'PHP_SELF' => 'my/base/path'
);
$request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
$data = array("pirouette" => "cacahuete", "black" => true, "bob" => array("bob"));
$api_result = new API_V1_result($request, $this->api);
$api_result->set_datas($data);
$this->assertEquals($data, $api_result->get_datas());
}
public function testGet_Emptydatas()
{
$server = array(
"HTTP_ACCEPT" => "application/json"
, 'REQUEST_METHOD' => 'GET'
, 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename'
, "REQUEST_URI" => "my/base/path/my/request/uri"
, 'PHP_SELF' => 'my/base/path'
);
$request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
$data = array();
$api_result = new API_V1_result($request, $this->api);
$api_result->set_datas($data);
$this->assertEquals($data, $api_result->get_datas());
}
protected function checkResponseFieldMeta(stdClass $response, $field, $expected_value, $type)
{
$this->assertObjectHasAttribute($field, $response->meta);

View File

@@ -97,10 +97,38 @@ class caption_recordTest extends PhraseanetPHPUnitAbstract
*/
public function testGet_dc_field()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$field = null;
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
foreach ($databox->get_meta_structure() as $meta) {
$meta->set_dces_element(new databox_Field_DCES_Contributor());
$field = $meta;
$set = true;
break;
}
break;
}
if (!$meta) {
$this->markTestSkipped('Unable to set a DC field');
}
$captionField = self::$DI['record_1']->get_caption()->get_field($field->get_name());
if (!$captionField) {
self::$DI['record_1']->set_metadatas(array(
array(
'meta_id' => null,
'meta_struct_id' => $meta->get_id(),
'value' => array('HELLO MO !'),
)
));
$value = 'HELLO MO !';
} else {
$value = $captionField->get_serialized_values();
}
$this->assertEquals($value, self::$DI['record_1']->get_caption()->get_dc_field(databox_Field_DCESAbstract::Contributor)->get_serialized_values());
}
/**

View File

@@ -55,8 +55,10 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
}
}
$story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']);
self::$objectNotPresent->remove_file();
self::$storyPresent = self::$DI['record_story_1']->get_subdef('thumbnail');
self::$storyPresent = $story->get_subdef('thumbnail');
}
/**

View File

@@ -181,6 +181,10 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_rollover_thumbnail()
{
if (!extension_loaded('\Gmagick')) {
$this->markTestSkipped('\Gmagick required to build animated gifs');
}
$this->assertNull(self::$DI['record_1']->get_rollover_thumbnail());
}

View File

@@ -0,0 +1,28 @@
<?php
require_once __DIR__ . '/../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
class set_exportTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
public function testStreamFileExportName()
{
$response = \set_export::stream_file(self::$DI['app'], __DIR__ . '/../testfiles/HelloWorld.pdf', 'to1\/\àçÂto.jpg', 'application/pdf');
$explode = explode(';', $response->headers->get('content-disposition'));
$filenameData = explode('=', $explode[1]);
$fallbackData = explode('\'\'', $explode[2]);
$filename = array_pop($filenameData);
$filenameFallback = array_pop($fallbackData);
$this->assertEquals('"to1acato.jpg"', $filename);
$this->assertEquals('to1àçÂto.jpg', rawurldecode($filenameFallback));
}
public function testStreamFilenotFound()
{
$response = \set_export::stream_file(self::$DI['app'], __DIR__ . '/../testfiles/Unknown.pdf', 'to1\/\\o.jpg', 'application/pdf');
$this->assertEquals(404, $response->getStatusCode());
}
}

View File

@@ -425,7 +425,7 @@ class task_period_archiveTest extends \PhraseanetPHPUnitAbstract
$bagByName = self::$object->getIndexByFieldNameTester($meta_struct, $media->getMetadatas());
$this->assertInstanceOf('\\PHPExiftool\\Driver\\Metadata\\MetadataBag', $bagByName);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\MetadataBag', $bagByName);
if (count($bagByName) == 0) {
$this->markTestSkipped('No enough data to tests');
@@ -438,162 +438,6 @@ class task_period_archiveTest extends \PhraseanetPHPUnitAbstract
}
}
/**
* @covers task_period_archive::bagToArray
*/
public function testBagToArray()
{
$meta_struct = self::$DI['collection']->get_databox()->get_meta_structure();
$bag = new PHPExiftool\Driver\Metadata\MetadataBag();
$first_multi = $first_mono = false;
$toFetch = array();
foreach ($meta_struct as $databox_field) {
$tagname = $databox_field->get_tag()->getTagname();
if ( ! $tagname) {
continue;
}
if($databox_field->get_type() == 'date') {
$date = new \DateTime();
$bag->set($tagname, new PHPExiftool\Driver\Metadata\Metadata(
$databox_field->get_tag(),
new \PHPExiftool\Driver\Value\Mono($date->format('Y/m/d H:i:s'))
));
$toFetch[$tagname] = array($date->format('Y/m/d H:i:s'));
} elseif ($databox_field->is_multi()) {
if ($first_multi) {
$bag->set($tagname, new PHPExiftool\Driver\Metadata\Metadata(
$databox_field->get_tag(),
new \PHPExiftool\Driver\Value\Mono('c-multi-' . $databox_field->get_id())
));
$toFetch[$tagname][] = 'c-multi-' . $databox_field->get_id();
} else {
$bag->set($tagname, new PHPExiftool\Driver\Metadata\Metadata(
$databox_field->get_tag(),
new \PHPExiftool\Driver\Value\Multi(array('a-multi-' . $databox_field->get_id(), 'b-multi-' . $databox_field->get_id()))
));
$toFetch[$tagname][] = 'a-multi-' . $databox_field->get_id();
$toFetch[$tagname][] = 'b-multi-' . $databox_field->get_id();
}
$first_multi = false;
} else {
if ($first_mono) {
$bag->set($tagname, new PHPExiftool\Driver\Metadata\Metadata(
$databox_field->get_tag(),
new \PHPExiftool\Driver\Value\Multi(array('a-mono-' . $databox_field->get_id(), 'b-mono-' . $databox_field->get_id()))
));
$toFetch[$tagname] = array('b-mono-' . $databox_field->get_id());
} else {
$bag->set($tagname, new PHPExiftool\Driver\Metadata\Metadata(
$databox_field->get_tag(),
new \PHPExiftool\Driver\Value\Mono('c-mono-' . $databox_field->get_id())
));
$toFetch[$tagname] = array('c-mono-' . $databox_field->get_id());
}
$first_mono = false;
}
}
$array = self::$object->bagToArrayTester($meta_struct, $bag);
$written = $id_done = array();
foreach ($array as $meta) {
$databox_field = $meta_struct->get_element($meta['meta_struct_id']);
$tagname = $databox_field->get_tag()->getTagname();
if ( ! $databox_field->is_multi() && isset($id_done[$databox_field->get_id()])) {
$this->fail('No duplicate for mono values');
}
$id_done[$databox_field->get_id()] = true;
$written[$tagname][] = $meta['value'];
$written[$tagname] = array_unique($written[$tagname]);
}
foreach ($written as $tagname => $values) {
$this->assertEquals($values, $toFetch[$tagname]);
}
}
/**
* @covers task_period_archive::mergeForDatabox
* @todo Implement testMergeForDatabox().
*/
public function testMergeForDatabox()
{
$meta_struct = self::$DI['collection']->get_databox()->get_meta_structure();
$bag1 = new PHPExiftool\Driver\Metadata\MetadataBag();
$bag2 = new PHPExiftool\Driver\Metadata\MetadataBag();
$tofetch = array();
foreach ($meta_struct as $databox_field) {
$tofetch[$databox_field->get_name()] = array();
if ($databox_field->is_multi()) {
$values = array('a-multi-' . $databox_field->get_id(), 'b-multi-' . $databox_field->get_id());
$bag1->set(
$databox_field->get_name(), new PHPExiftool\Driver\Metadata\Metadata(
$databox_field->get_tag(),
new PHPExiftool\Driver\Value\Multi($values)
)
);
$tofetch[$databox_field->get_name()] = array_merge($tofetch[$databox_field->get_name()], $values);
$values = array('a-multi-' . $databox_field->get_id(), 'd-multi-' . $databox_field->get_id());
$bag2->set(
$databox_field->get_name(), new PHPExiftool\Driver\Metadata\Metadata(
$databox_field->get_tag(),
new PHPExiftool\Driver\Value\Multi($values)
)
);
$tofetch[$databox_field->get_name()] = array_values(array_unique(array_merge($tofetch[$databox_field->get_name()], $values)));
} else {
$value = 'a-mono-' . $databox_field->get_id();
$bag1->set(
$databox_field->get_name(), new PHPExiftool\Driver\Metadata\Metadata(
$databox_field->get_tag(),
new PHPExiftool\Driver\Value\Mono($value)
)
);
$value = 'b-mono-' . $databox_field->get_id();
$bag2->set(
$databox_field->get_name(), new PHPExiftool\Driver\Metadata\Metadata(
$databox_field->get_tag(),
new PHPExiftool\Driver\Value\Mono($value)
)
);
$tofetch[$databox_field->get_name()] = array($value);
}
}
$bag = self::$object->mergeForDataboxTester($meta_struct, $bag1, $bag2);
$found = array();
foreach ($bag as $fieldname => $metadata) {
$found[$fieldname] = $metadata->getValue()->asArray();
}
foreach ($tofetch as $fieldname => $tofound) {
$this->assertEquals($tofound, $found[$fieldname]);
}
}
/**
* @covers task_period_archive::readXMLForDatabox
* @expectedException \InvalidArgumentException
@@ -631,7 +475,7 @@ class task_period_archiveTest extends \PhraseanetPHPUnitAbstract
$found = array();
foreach ($bag as $fieldname => $metadata) {
$found[$fieldname] = $metadata->getValue()->asArray();
$found[$fieldname] = $metadata->getValue();
}
foreach ($tofetch as $fieldname => $values) {
@@ -684,16 +528,6 @@ class archiveTester extends task_period_archive
return parent::getIndexByFieldName($meta_struct, $bag);
}
public function bagToArrayTester($meta_struct, $bag)
{
return parent::bagToArray($meta_struct, $bag);
}
public function mergeForDataboxTester($meta_struct, $bag1, $bag2)
{
return parent::mergeForDatabox($meta_struct, $bag1, $bag2);
}
public function readXMLForDataboxTester($meta_struct, $pathfile)
{
return parent::readXMLForDatabox($meta_struct, $pathfile);

View File

@@ -53,7 +53,6 @@ $user = User_Adapter::getInstance($usr_id, $app);
</style>
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/include/minify/f=include/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<link rel="stylesheet" type="text/css" href="/include/jslibs/jquery-ui-1.8.17/css/dark-hive/jquery-ui-1.8.17.custom.css" />
<link type="text/css" rel="stylesheet" href="/include/minify/f=include/jslibs/jquery.contextmenu.css,skins/common/main.css" />
<?php

View File

@@ -784,20 +784,12 @@ function evt_dwnl(lst)
var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['export']: ''});
dialog.getDomElement().bind("dialogbeforeclose", function(event, ui) {
tinyMCE.execCommand('mceRemoveControl',true,'sendmail_message');
tinyMCE.execCommand('mceRemoveControl',true,'order_usage');
});
$.post("/prod/export/multi-export/", datas, function(data) {
dialog.setContent(data);
$('.tabs', dialog.getDomElement()).tabs();
tinyMCE.execCommand('mceAddControl',true,'sendmail_message');
tinyMCE.execCommand('mceAddControl',true,'order_usage');
$('.close_button', dialog.getDomElement()).bind('click',function(){
dialog.Close();
});

View File

@@ -183,16 +183,19 @@ var p4 = p4 || {};
if (typeof bits !== 'number') {
throw bits + ' is not a number';
}
if (bits >= 1073741824) {
return (bits / 1073741824).toFixed(2) + ' Gbit/s';
// 1 byte = 8 bits
var bytes = (bits >> 3);
if (bytes >= (1 << 30)) {
return (bytes / (1 << 30)).toFixed(2) + ' Go/s';
}
if (bits >= 1048576) {
return (bits / 1048576).toFixed(2) + ' Mbit/s';
if (bytes >= (1 << 20)) {
return (bytes / (1 << 20)).toFixed(2) + ' Mo/s';
}
if (bits >= 1024) {
return (bits / 1024).toFixed(2) + ' Kbit/s';
if (bytes >= (1 << 10)) {
return (bytes / (1 << 10)).toFixed(2) + ' Ko/s';
}
return bits + ' bit/s';
return bytes + ' o/s';
},
pourcent: function(current, total){
return (current/ total * 100).toFixed(2)

View File

@@ -2410,20 +2410,12 @@ function downloadThis(datas)
{
var dialog = p4.Dialog.Create({title: language['export']});
dialog.getDomElement().bind("dialogbeforeclose", function(event, ui) {
tinyMCE.execCommand('mceRemoveControl',true,'sendmail_message');
tinyMCE.execCommand('mceRemoveControl',true,'order_usage');
});
$.post("/prod/export/multi-export/", datas, function(data) {
dialog.setContent(data);
$('.tabs', dialog.getDomElement()).tabs();
tinyMCE.execCommand('mceAddControl',true,'sendmail_message');
tinyMCE.execCommand('mceAddControl',true,'order_usage');
$('.close_button', dialog.getDomElement()).bind('click',function(){
dialog.Close();
});

View File

@@ -479,20 +479,12 @@ function download(value)
{
var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['export']: ''});
dialog.getDomElement().bind("dialogbeforeclose", function(event, ui) {
tinyMCE.execCommand('mceRemoveControl',true,'sendmail_message');
tinyMCE.execCommand('mceRemoveControl',true,'order_usage');
});
$.post("/prod/export/multi-export/", "lst="+value, function(data) {
dialog.setContent(data);
$('.tabs', dialog.getDomElement()).tabs();
tinyMCE.execCommand('mceAddControl',true,'sendmail_message');
tinyMCE.execCommand('mceAddControl',true,'order_usage');
$('.close_button', dialog.getDomElement()).bind('click',function(){
dialog.Close();
});

View File

@@ -414,24 +414,12 @@ function display_basket_element(compare, sselcont_id)
var options_container = $('.options',container);
$('.download_button', options_container).button({
text : false
// ,
// icons : {
// primary: 'ui-icon-disk'
// }
}).bind('click',function(){
$('.download_button', options_container).bind('click',function(){
// $(this).blur();
download($(this).next('form[name=download_form]').find('input').val());
});
$('.comment_button', options_container).button({
text : true
// ,
// icons : {
// primary: 'ui-icon-comment'
// }
}).bind('click',function()
$('.comment_button', options_container).bind('click',function()
{
// $(this).blur();
if($('.container', container).hasClass('note_editing'))
@@ -447,35 +435,17 @@ function display_basket_element(compare, sselcont_id)
activate_notes(container);
$('.previous_button', options_container).button({
text : false
// ,
// icons : {
// primary: 'ui-icon-seek-prev'
// }
}).bind('click',function(){
$('.previous_button', options_container).bind('click',function(){
// $(this).blur();
get_prev();
});
$('.play_button', options_container).button({
text : false
// ,
// icons : {
// primary: 'ui-icon-play'
// }
}).bind('click',function(){
$('.play_button', options_container).bind('click',function(){
// $(this).blur();
slideshow(true);
});
$('.pause_button', options_container).button({
text : false
// ,
// icons : {
// primary: 'ui-icon-pause'
// }
}).bind('click',function(){
$('.pause_button', options_container).bind('click',function(){
// $(this).blur();
slideshow(false);
});
@@ -489,13 +459,7 @@ function display_basket_element(compare, sselcont_id)
$('.pause_button, .next_button.pause, .previous_button.pause', options_container).hide();
}
$('.next_button', options_container).button({
text : false
// ,
// icons : {
// primary: 'ui-icon-seek-next'
// }
}).bind('click',function(){
$('.next_button', options_container).bind('click',function(){
// $(this).blur();
slideshow(false);
get_next();
@@ -1078,20 +1042,12 @@ function download(value)
{
var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['export']: ''});
dialog.getDomElement().bind("dialogbeforeclose", function(event, ui) {
tinyMCE.execCommand('mceRemoveControl',true,'sendmail_message');
tinyMCE.execCommand('mceRemoveControl',true,'order_usage');
});
$.post("/prod/export/multi-export/", "lst="+value, function(data) {
dialog.setContent(data);
$('.tabs', dialog.getDomElement()).tabs();
tinyMCE.execCommand('mceAddControl',true,'sendmail_message');
tinyMCE.execCommand('mceAddControl',true,'order_usage');
$('.close_button', dialog.getDomElement()).bind('click',function(){
dialog.Close();
});

View File

@@ -473,6 +473,7 @@ table th i {
top: -100%;
height: 100%;
width: 100%;
left:0px;
}
.record_display_box .note_wrapper {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B