From 7ba46abaffdd213d05b7e1849144e2d3b3782085 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 27 May 2013 23:49:39 +0200 Subject: [PATCH] Address github annotations --- composer.json | 1 - composer.lock | 50 +------ lib/Alchemy/Phrasea/Application.php | 18 --- .../Phrasea/Controller/Admin/Fields.php | 46 +++--- lib/Alchemy/Phrasea/Metadata/TagProvider.php | 136 +++++++++--------- .../web/admin/fields/templates.html.twig | 6 +- .../tests/fixtures/admin/fields/templates | 10 +- 7 files changed, 95 insertions(+), 172 deletions(-) diff --git a/composer.json b/composer.json index 7d12655fb6..7f961139f3 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,6 @@ "gedmo/doctrine-extensions" : "~2.3.0", "imagine/imagine" : "dev-ColorSpaces@dev", "jms/serializer" : "~0.10", - "jms/twig-js" : "dev-master", "mediavorus/mediavorus" : "~0.3", "media-alchemyst/media-alchemyst" : "~0.2, >=0.2.3", "monolog/monolog" : "~1.3.0", diff --git a/composer.lock b/composer.lock index d50f5e444a..a45538e139 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "b996280dc670585a8647ca983149a73e", + "hash": "5aeb56bf583572c3c4d4da8f930f55ed", "packages": [ { "name": "BadFaith/BadFaith", @@ -939,53 +939,6 @@ ], "time": "2013-03-28 16:41:24" }, - { - "name": "jms/twig-js", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/twig.js.git", - "reference": "159542ed93a61801c1502497a65efbfd97628090" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/twig.js/zipball/159542ed93a61801c1502497a65efbfd97628090", - "reference": "159542ed93a61801c1502497a65efbfd97628090", - "shasum": "" - }, - "require": { - "php": ">=5.3.2", - "twig/twig": ">=1.8,<2.0-dev" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "TwigJs": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache2" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "twig.js, flexible, secure, and high-performance templating engine for Javascript", - "keywords": [ - "templating" - ], - "time": "2013-03-26 10:59:54" - }, { "name": "media-alchemyst/media-alchemyst", "version": "0.2.5", @@ -2471,7 +2424,6 @@ "dailymotion/sdk": 20, "data-uri/data-uri": 20, "imagine/imagine": 20, - "jms/twig-js": 20, "mrclay/minify": 20, "neutron/silex-imagine-provider": 20, "neutron/silex-badfaith-provider": 20, diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 2acaacc756..7d60fdfc57 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -114,8 +114,6 @@ use Silex\Provider\WebProfilerServiceProvider; use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser; use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; use Unoconv\UnoconvServiceProvider; -use TwigJs\Twig\TwigJsExtension; -use TwigJs\JsCompiler; use XPDF\PdfToText; use XPDF\XPDFServiceProvider; @@ -500,22 +498,6 @@ class Application extends SilexApplication return $twig; }) ); - - $this['twig.js.compiler'] = $this->share(function(Application $app) { - $compiler = new JsCompiler($app['twig']); - $compiler->setFilterFunction('trans', 'i18n.t'); - - return $compiler; - }); - - $this['twig.js'] = $this->share(function(Application $app) { - $twig = clone $app['twig']; - $twig->addExtension(new TwigJsExtension()); - $twig->getExtension('escaper')->setDefaultStrategy(false); - $twig->setCompiler($app['twig.js.compiler']); - - return $twig; - }); } /** diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php index ce693f9868..2966952305 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php @@ -11,7 +11,6 @@ namespace Alchemy\Phrasea\Controller\Admin; -use Alchemy\Phrasea\Application as PhraseaApplication; use Alchemy\Phrasea\Metadata\TagProvider; use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController; use Silex\Application; @@ -114,7 +113,7 @@ class Fields implements ControllerProviderInterface $fields[] = $field->toArray(); } catch (\Exception $e) { $connection->rollback(); - $app->abort(500, _(sprintf('Field %s could not be saved, please try again or contact an admin', $jsonField['name']))); + $app->abort(500, _(sprintf('Field %s could not be saved, please try again or contact an admin.', $jsonField['name']))); break; } } @@ -127,30 +126,22 @@ class Fields implements ControllerProviderInterface public function getLanguage(Application $app, Request $request) { return $app->json(array( - 'something_wrong' => _('Something wrong happened, please try again or contact an admin'), - 'created_success' => _('%s field has been created with success'), - 'deleted_success' => _('%s field has been deleted with success'), + 'something_wrong' => _('Something wrong happened, please try again or contact an admin.'), + 'created_success' => _('%s field has been created with success.'), + 'deleted_success' => _('%s field has been deleted with success.'), 'are_you_sure_delete' => _('Do you really want to delete the field %s ?'), - 'validation_blank' => _('Field can not be blank'), - 'validation_name_exists' => _('Field name already exists'), - 'validation_tag_invalid' => _('Field source is not valid'), - 'field_error' => _('Field %s contains errors'), - 'fields_save' => _('Your configuration has been successfuly saved'), + 'validation_blank' => _('Field can not be blank.'), + 'validation_name_exists' => _('Field name already exists.'), + 'validation_tag_invalid' => _('Field source is not valid.'), + 'field_error' => _('Field %s contains errors.'), + 'fields_save' => _('Your configuration has been successfuly saved.'), )); } public function displayApp(Application $app, Request $request, $sbas_id) { - $languages = array(); - - foreach (PhraseaApplication::getAvailableLanguages() as $code => $language) { - $data = explode('_', $code); - $languages[$data[0]] = $language; - } - return $app['twig']->render('/admin/fields/index.html.twig', array( - 'sbas_id' => $sbas_id, - 'languages' => $languages, + 'sbas_id' => $sbas_id )); } @@ -178,8 +169,8 @@ class Fields implements ControllerProviderInterface $vocabulary = VocabularyController::get($app, $type); return $app->json(array( - 'type' => $vocabulary->getType(), - 'name' => $vocabulary->getName(), + 'type' => $vocabulary->getType(), + 'name' => $vocabulary->getName(), )); } @@ -232,15 +223,14 @@ class Fields implements ControllerProviderInterface $this->updateFieldWithData($app, $field, $data); $field->save(); } catch (\Exception $e) { - $app->abort(500, _(sprintf('Field %s could not be created, please try again or contact an admin', $data['name']))); + $app->abort(500, _(sprintf('Field %s could not be created, please try again or contact an admin.', $data['name']))); } return $app->json($field->toArray(), 201, array( 'location' => $app->path('admin_fields_show_field', array( 'sbas_id' => $sbas_id, 'id' => $field->get_id() - )) - )); + )))); } public function listFields(Application $app, $sbas_id) { @@ -347,7 +337,7 @@ class Fields implements ControllerProviderInterface $class = sprintf('\databox_Field_DCES_%s', $dcesElement); if (!class_exists($class)) { - throw new BadRequestHttpException(sprintf('DCES element %s does not exist', $dcesElement)); + throw new BadRequestHttpException(sprintf('DCES element %s does not exist.', $dcesElement)); } $field->set_dces_element(new $class()); @@ -366,7 +356,7 @@ class Fields implements ControllerProviderInterface private function validateNameField(\databox_descriptionStructure $metaStructure, array $field) { if (null !== $metaStructure->get_element_by_name($field['name'])) { - throw new BadRequestHttpException(_(sprintf('Field %s already exists', $field['name']))); + throw new BadRequestHttpException(_(sprintf('Field %s already exists.', $field['name']))); } } @@ -375,7 +365,7 @@ class Fields implements ControllerProviderInterface try { \databox_field::loadClassFromTagName($field['tag']); } catch(\Exception_Databox_metadataDescriptionNotFound $e) { - throw new BadRequestHttpException(_(sprintf('Provided tag %s is unknown', $field['tag']))); + throw new BadRequestHttpException(_(sprintf('Provided tag %s is unknown.', $field['tag']))); } } @@ -385,7 +375,7 @@ class Fields implements ControllerProviderInterface $data = @json_decode($body, true); if (JSON_ERROR_NONE !== json_last_error()) { - throw new BadRequestHttpException('Body must contain a valid JSON payload'); + throw new BadRequestHttpException('Body must contain a valid JSON payload.'); } return $data; diff --git a/lib/Alchemy/Phrasea/Metadata/TagProvider.php b/lib/Alchemy/Phrasea/Metadata/TagProvider.php index 2a7358e302..216cfdf6be 100644 --- a/lib/Alchemy/Phrasea/Metadata/TagProvider.php +++ b/lib/Alchemy/Phrasea/Metadata/TagProvider.php @@ -21,26 +21,26 @@ class TagProvider extends ExiftoolTagProvider $this['Phraseanet'] = $this->share(function(){ return array( - 'PdfText' => new \Alchemy\Phrasea\Metadata\Tag\PdfText(), + 'PdfText' => new \Alchemy\Phrasea\Metadata\Tag\PdfText(), 'TfArchivedate' => new \Alchemy\Phrasea\Metadata\Tag\TfArchivedate(), - 'TfAtime' => new \Alchemy\Phrasea\Metadata\Tag\TfAtime(), - 'TfBasename' =>new \Alchemy\Phrasea\Metadata\Tag\TfBasename(), - 'TfBits' => new \Alchemy\Phrasea\Metadata\Tag\TfBits(), - 'TfChannels' => new \Alchemy\Phrasea\Metadata\Tag\TfChannels(), - 'TfCtime' => new \Alchemy\Phrasea\Metadata\Tag\TfCtime(), - 'TfDirname' => new \Alchemy\Phrasea\Metadata\Tag\TfDirname(), - 'TfDuration' => new \Alchemy\Phrasea\Metadata\Tag\TfDuration(), - 'TfEditdate' => new \Alchemy\Phrasea\Metadata\Tag\TfEditdate(), - 'TfExtension' => new \Alchemy\Phrasea\Metadata\Tag\TfExtension(), - 'TfFilename' => new \Alchemy\Phrasea\Metadata\Tag\TfFilename(), - 'TfFilepath' => new \Alchemy\Phrasea\Metadata\Tag\TfFilepath(), - 'TfHeight' => new \Alchemy\Phrasea\Metadata\Tag\TfHeight(), - 'TfMimetype' => new \Alchemy\Phrasea\Metadata\Tag\TfMimetype(), - 'TfMtime' => new \Alchemy\Phrasea\Metadata\Tag\TfMtime(), - 'TfQuarantine' => new \Alchemy\Phrasea\Metadata\Tag\TfQuarantine(), - 'TfRecordid' => new \Alchemy\Phrasea\Metadata\Tag\TfRecordid(), - 'TfSize' => new \Alchemy\Phrasea\Metadata\Tag\TfSize(), - 'TfWidth' => new \Alchemy\Phrasea\Metadata\Tag\TfWidth(), + 'TfAtime' => new \Alchemy\Phrasea\Metadata\Tag\TfAtime(), + 'TfBasename' => new \Alchemy\Phrasea\Metadata\Tag\TfBasename(), + 'TfBits' => new \Alchemy\Phrasea\Metadata\Tag\TfBits(), + 'TfChannels' => new \Alchemy\Phrasea\Metadata\Tag\TfChannels(), + 'TfCtime' => new \Alchemy\Phrasea\Metadata\Tag\TfCtime(), + 'TfDirname' => new \Alchemy\Phrasea\Metadata\Tag\TfDirname(), + 'TfDuration' => new \Alchemy\Phrasea\Metadata\Tag\TfDuration(), + 'TfEditdate' => new \Alchemy\Phrasea\Metadata\Tag\TfEditdate(), + 'TfExtension' => new \Alchemy\Phrasea\Metadata\Tag\TfExtension(), + 'TfFilename' => new \Alchemy\Phrasea\Metadata\Tag\TfFilename(), + 'TfFilepath' => new \Alchemy\Phrasea\Metadata\Tag\TfFilepath(), + 'TfHeight' => new \Alchemy\Phrasea\Metadata\Tag\TfHeight(), + 'TfMimetype' => new \Alchemy\Phrasea\Metadata\Tag\TfMimetype(), + 'TfMtime' => new \Alchemy\Phrasea\Metadata\Tag\TfMtime(), + 'TfQuarantine' => new \Alchemy\Phrasea\Metadata\Tag\TfQuarantine(), + 'TfRecordid' => new \Alchemy\Phrasea\Metadata\Tag\TfRecordid(), + 'TfSize' => new \Alchemy\Phrasea\Metadata\Tag\TfSize(), + 'TfWidth' => new \Alchemy\Phrasea\Metadata\Tag\TfWidth(), ); }); } @@ -58,101 +58,101 @@ class TagProvider extends ExiftoolTagProvider $table = parent::getLookupTable(); $table['phraseanet'] = array( - 'pdftext' => array( - 'tagname' => 'PdfText', - 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\PdfText', - 'namespace' => 'Phraseanet'), + 'pdftext' => array( + 'tagname' => 'PdfText', + 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\PdfText', + 'namespace' => 'Phraseanet'), 'tfarchivedate' => array( 'tagname' => 'TfArchivedate', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfArchivedate', 'namespace' => 'Phraseanet' ), - 'tfatime' => array( + 'tfatime' => array( 'tagname' => 'TfAtime', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfAtime', 'namespace' => 'Phraseanet' ), - 'tfbasename' => array( - 'tagname' => 'TfBasename', - 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfBasename', - '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' + 'tfbits' => array( + 'tagname' => 'TfBits', + 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfBits', + 'namespace' => 'Phraseanet' ), - 'tfchannels' => array( + 'tfchannels' => array( 'tagname' => 'TfChannels', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfChannels', 'namespace' => 'Phraseanet' ), - 'tTfCtime' => array( - 'tagname' => 'TfCtime', - 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfCtime', - 'namespace' => 'Phraseanet' + 'tTfCtime' => array( + 'tagname' => 'TfCtime', + 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfCtime', + 'namespace' => 'Phraseanet' ), - 'tfdirname' => array( - 'tagname' => 'TfDirname', - 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDirname', - 'namespace' => 'Phraseanet' + 'tfdirname' => array( + 'tagname' => 'TfDirname', + 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDirname', + 'namespace' => 'Phraseanet' ), - 'tfduration' => array( - 'tagname' => 'TfDuration', - 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDuration', - 'namespace' => 'Phraseanet' + 'tfduration' => array( + 'tagname' => 'TfDuration', + 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDuration', + 'namespace' => 'Phraseanet' ), - 'tfeditdate' => array( - 'tagname' => 'TfEditdate', - 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfEditdate', - 'namespace' => 'Phraseanet' + 'tfeditdate' => array( + 'tagname' => 'TfEditdate', + 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfEditdate', + 'namespace' => 'Phraseanet' ), - 'tfextension' => array( - 'tagname' => 'TfExtension', - 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfExtension', - 'namespace' => 'Phraseanet' + 'tfextension' => array( + 'tagname' => 'TfExtension', + 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfExtension', + 'namespace' => 'Phraseanet' ), - 'tffilename' => array( - 'tagname' => 'TfFilename', - 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfFilename', - 'namespace' => 'Phraseanet' + 'tffilename' => array( + 'tagname' => 'TfFilename', + 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfFilename', + 'namespace' => 'Phraseanet' ), - 'tffilepath' => array( + 'tffilepath' => array( 'tagname' => 'TfFilepath', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfFilepath', 'namespace' => 'Phraseanet' ), - 'tfheight' => array( - 'tagname' => 'TfHeight', - 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfHeight', - 'namespace' => 'Phraseanet' + 'tfheight' => array( + 'tagname' => 'TfHeight', + 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfHeight', + 'namespace' => 'Phraseanet' ), - 'tfmimetype' => array( + 'tfmimetype' => array( 'tagname' => 'TfMimetype', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfMimetype', 'namespace' => 'Phraseanet' ), - 'tfmtime' => array( + 'tfmtime' => array( 'tagname' => 'TfMtime', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfMtime', 'namespace' => 'Phraseanet' ), - 'tfquarantine' => array( + 'tfquarantine' => array( 'tagname' => 'TfQuarantine', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfQuarantine', 'namespace' => 'Phraseanet' ), - 'tfrecordid' => array( + 'tfrecordid' => array( 'tagname' => 'TfRecordid', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfRecordid', 'namespace' => 'Phraseanet' ), - 'tfsize' => array( + 'tfsize' => array( 'tagname' => 'TfSize', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfSize', 'namespace' => 'Phraseanet' ), - 'tfwidth' => array( + 'tfwidth' => array( 'tagname' => 'TfWidth', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfWidth', 'namespace' => 'Phraseanet' diff --git a/templates/web/admin/fields/templates.html.twig b/templates/web/admin/fields/templates.html.twig index fc2c3df91e..a4702e5f32 100644 --- a/templates/web/admin/fields/templates.html.twig +++ b/templates/web/admin/fields/templates.html.twig @@ -39,7 +39,7 @@