diff --git a/library/Class/Album.php b/library/Class/Album.php index 1ed6fb0ba1d5b3b549a68584340c4a7904ce8438..877be8dc88752c3f0e7890779843ed63c5107aca 100644 --- a/library/Class/Album.php +++ b/library/Class/Album.php @@ -65,7 +65,7 @@ class AlbumLoader extends Storm_Model_Loader { class Class_Album extends Storm_Model_Abstract { - use Trait_TimeSource, Trait_Indexable, Trait_StaticFileSystem; + use Trait_TimeSource, Trait_Indexable, Trait_StaticFileSystem, Trait_Translator; const BASE_PATH = 'album/'; const THUMBS_PATH = 'thumbs/'; @@ -89,6 +89,8 @@ class Class_Album extends Storm_Model_Abstract { const STATUS_DRAFT = 1; const STATUS_VALIDATED = 3; + const RIGHT_PUBLIC_DOMAIN_KEY = 1; + const RIGHT_OTHER_KEY = 2; protected static $DEFAULT_THUMBNAIL_VALUES; @@ -1600,5 +1602,10 @@ class Class_Album extends Storm_Model_Abstract { public function renderOn($view) { return (new Class_Album_Renderer($this))->renderOn($view); } + + + public static function getPublicDomain() { + return (new self())->_('Domaine public'); + } } ?> \ No newline at end of file diff --git a/library/Class/Album/Item.php b/library/Class/Album/Item.php index dda6ace6a37b70ce065cfc2ef495474b26c8e1ea..2ae3e5ea47340838be8b8230ac1f0c20efd26fc3 100644 --- a/library/Class/Album/Item.php +++ b/library/Class/Album/Item.php @@ -32,19 +32,27 @@ class Class_Album_Item extends Storm_Model_Abstract { public function getQuantityOnTotal() { - return $this->getQuantity() . ' / ' . $this->getAlbum()->getUsageConstraints()->getLoanQuantity(); + return $this->getQuantity() . ' / ' . $this->getAlbumUsageConstraints()->getLoanQuantity(); } + public function getLiveQuantity() { - return $this->getLoanCount() . ' / ' . $this->getAlbum()->getUsageConstraints()->getLoanAllowedNumberOfUsers(); + return $this->getLoanCount() . ' / ' . $this->getAlbumUsageConstraints()->getLoanAllowedNumberOfUsers(); } + public function getDuration() { - return $this->getAlbum()->getUsageConstraints()->getLoanDuration(); + return $this->getAlbumUsageConstraints()->getLoanDuration(); } + public function getLicenseExpiration() { - return $this->getAlbum()->getUsageConstraints()->getAvailabilityRemainingDaysBeforeEndDate(); + return $this->getAlbumUsageConstraints()->getAvailabilityRemainingDaysBeforeEndDate(); + } + + + protected function getAlbumUsageConstraints() { + return $this->getAlbum()->getUsageConstraints(); } } ?> \ No newline at end of file diff --git a/library/Class/WebService/BibNumerique/Dilicom/Book.php b/library/Class/WebService/BibNumerique/Dilicom/Book.php index 432b16c5a1f103c0d7188f30e0ea136c5437feee..3cccfd1e429de5d888cf18bc6b0314d184056713 100644 --- a/library/Class/WebService/BibNumerique/Dilicom/Book.php +++ b/library/Class/WebService/BibNumerique/Dilicom/Book.php @@ -35,7 +35,7 @@ class Class_WebService_BibNumerique_Dilicom_Book extends Class_WebService_BibNum ->setISBN($this->_isbn) ->setSousTitre($this->_subtitle) ->addEditor($this->getEditeur()) - ->setDroits(2) + ->setDroits(Class_Album::RIGHT_OTHER_KEY) ->setUsageConstraints($this->_usage_constraints) ->addItem(new Class_Album_Item()); diff --git a/library/ZendAfi/Form/Album.php b/library/ZendAfi/Form/Album.php index ef8cc3776c74d78fe2e2f110452c13c6d9618e2c..ffd5c19d584bdeeb2498be0b9b65751897678adc 100644 --- a/library/ZendAfi/Form/Album.php +++ b/library/ZendAfi/Form/Album.php @@ -20,11 +20,6 @@ */ class ZendAfi_Form_Album extends ZendAfi_Form { - const RIGHT_PUBLIC_DOMAIN_KEY = 1; - const RIGHT_OTHER_KEY = 2; - const RIGHT_PUBLIC_DOMAIN = 'Domaine public'; - - protected $_simple_elements = ['titre', 'cat_id', 'type_doc_id', @@ -124,10 +119,11 @@ class ZendAfi_Form_Album extends ZendAfi_Form { public function init() { parent::init(); + Class_ScriptLoader::getInstance() ->addInlineScript('function toggleAlbumRights() { var target = $("#droits_precision").parent().parent(); - (' . self::RIGHT_OTHER_KEY . ' == $("input[name=\'droits\']:checked").val()) ? + (' . Class_Album::RIGHT_OTHER_KEY . ' == $("input[name=\'droits\']:checked").val()) ? target.show() : target.hide(); }') @@ -290,11 +286,11 @@ class ZendAfi_Form_Album extends ZendAfi_Form { * @return ZendAfi_Form_Album */ public function addRightsFor($album) { - $current = (self::RIGHT_PUBLIC_DOMAIN == $album->getDroits() || $album->isNew()) - ? self::RIGHT_PUBLIC_DOMAIN_KEY - : self::RIGHT_OTHER_KEY; + $current = (Class_Album::getPublicDomain() == $album->getDroits() || $album->isNew()) + ? Class_Album::RIGHT_PUBLIC_DOMAIN_KEY + : Class_Album::RIGHT_OTHER_KEY; - $current_precision = (self::RIGHT_PUBLIC_DOMAIN != $album->getDroits()) + $current_precision = (Class_Album::getPublicDomain() != $album->getDroits()) ? $album->getDroits() : ''; @@ -303,8 +299,8 @@ class ZendAfi_Form_Album extends ZendAfi_Form { ['label' => 'Droits', 'value' => $current, 'separator' => '', - 'multiOptions' => [self::RIGHT_PUBLIC_DOMAIN_KEY => self::RIGHT_PUBLIC_DOMAIN, - self::RIGHT_OTHER_KEY => $this->_('Autre, Précisez')]]) + 'multiOptions' => [Class_Album::RIGHT_PUBLIC_DOMAIN_KEY => Class_Album::getPublicDomain(), + Class_Album::RIGHT_OTHER_KEY => $this->_('Autre, Précisez')]]) ->addElement('text', 'droits_precision', ['label' => '', @@ -359,14 +355,10 @@ class ZendAfi_Form_Album extends ZendAfi_Form { public function isPublicDomain() { - return self::RIGHT_PUBLIC_DOMAIN == $this->droits->getValue(); + return Class_Album::getPublicDomain() == $this->droits->getValue(); } - public function getPublicDomain() { - return self::RIGHT_PUBLIC_DOMAIN; - } - public function populateFrbrUrl($url) { $values = ['frbr_type' => [], 'frbr_url' => [$url]]; $this->frbr_multi diff --git a/library/ZendAfi/View/Helper/TagModelTable.php b/library/ZendAfi/View/Helper/TagModelTable.php index dd940ed0c33ca3f14a30b3a97d95d905afff5c2c..4a1c7b0028503aa181b244b112b1c80276be5965 100644 --- a/library/ZendAfi/View/Helper/TagModelTable.php +++ b/library/ZendAfi/View/Helper/TagModelTable.php @@ -18,7 +18,7 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class ZendAfi_View_Helper_TagModelTable extends Zend_View_Helper_HtmlElement { +class ZendAfi_View_Helper_TagModelTable extends ZendAfi_View_Helper_BaseHelper { /** @var boolean */ protected $_hasActions = false; /** @var int */ @@ -45,7 +45,7 @@ class ZendAfi_View_Helper_TagModelTable extends Zend_View_Helper_HtmlElement { $this->_hasActions = 0 < count($actions); $this->_cols_count = count($attribs) + ($this->_hasActions ? 1 : 0); - $html = $this->tag('table', + $html = $this->_tag('table', $this->head($cols) .$this->tbody($models, $attribs, $actions, $group_by, $callbacks), ['id' => $id, @@ -59,18 +59,18 @@ class ZendAfi_View_Helper_TagModelTable extends Zend_View_Helper_HtmlElement { if(!$pager) return ''; - $first = $this->view->tag('span', '|<<' , ['class' => 'first', + $first = $this->_tag('span', '|<<' , ['class' => 'first', 'style' => 'cursor:pointer']); - $previous = $this->view->tag('span', '<' , ['class' => 'first', + $previous = $this->_tag('span', '<' , ['class' => 'first', 'style' => 'cursor:pointer']); - $page_display = $this->tag('input', '', ['class' => 'pagedisplay']); + $page_display = $this->_tag('input', '', ['class' => 'pagedisplay']); - $next = $this->view->tag('span', '>' , ['class' => 'next', + $next = $this->_tag('span', '>' , ['class' => 'next', 'style' => 'cursor:pointer']); - $last = $this->view->tag('span', '>>|' , ['class' => 'last', + $last = $this->_tag('span', '>>|' , ['class' => 'last', 'style' => 'cursor:pointer']); $select = $this->view->formSelect('pagesize', @@ -86,24 +86,24 @@ class ZendAfi_View_Helper_TagModelTable extends Zend_View_Helper_HtmlElement { $last . $select; - $form = $this->tag('form', $html); + $form = $this->_tag('form', $html); - return $this->tag('div', $form, ['class' => 'pager model_table_pager']); + return $this->_tag('div', $form, ['class' => 'pager model_table_pager']); } public function head($cols) { $cols_html = ''; foreach ($cols as $col) - $cols_html .= $this->tag('th', $col); + $cols_html .= $this->_tag('th', $col); - $actions = $this->_hasActions ? $this->tag('th', $this->view->_('Actions'), + $actions = $this->_hasActions ? $this->_tag('th', $this->view->_('Actions'), ['class' => 'actions', 'data-sorter' => 'false', 'style' => 'width:80px;']) : ''; - return $this->tag('thead', - $this->tag('tr', $cols_html . $actions)); + return $this->_tag('thead', + $this->_tag('tr', $cols_html . $actions)); } @@ -122,9 +122,8 @@ class ZendAfi_View_Helper_TagModelTable extends Zend_View_Helper_HtmlElement { $groups['no_group'] = $models; } - return $this - ->tag('tbody', - $this->renderGroupsAsTableRows($groups, $attribs, $actions, $callbacks)); + return $this->_tag('tbody', + $this->renderGroupsAsTableRows($groups, $attribs, $actions, $callbacks)); } @@ -133,8 +132,8 @@ class ZendAfi_View_Helper_TagModelTable extends Zend_View_Helper_HtmlElement { foreach ($groups as $name => $groupModels) { if ('no_group' != $name && '' != $name) - $rows .= $this->tag('tr', - $this->tag('td', + $rows .= $this->_tag('tr', + $this->_tag('td', $this->view->escape($name), ['style' => 'background-color:#888;color:white;font-size:120%;padding:2px 10px;font-weight:bold;', 'colspan' => $this->_cols_count])); @@ -163,13 +162,13 @@ class ZendAfi_View_Helper_TagModelTable extends Zend_View_Helper_HtmlElement { foreach ($attribs as $attrib) { $callback = (array_key_exists($attrib, $callbacks)) ? $callbacks[$attrib] : $default_callback; - $cols .= $this->tag('td', $callback($model, $attrib)); + $cols .= $this->_tag('td', $callback($model, $attrib)); } $actions = ($this->_hasActions) ? - $this->tag('td', $this->renderModelActions($model, $actions)) : ''; + $this->_tag('td', $this->renderModelActions($model, $actions)) : ''; - return $this->tag('tr', $cols . $actions); + return $this->_tag('tr', $cols . $actions); } @@ -201,12 +200,5 @@ class ZendAfi_View_Helper_TagModelTable extends Zend_View_Helper_HtmlElement { 'id' => $model->getId()), is_a($content, 'Closure') ? $content($model) : $content); } - - - /** shortcut to $this->view->tag() */ - protected function tag() { - return call_user_func_array([$this->view, 'tag'], func_get_args()); - } } - ?> diff --git a/tests/library/Class/WebService/Dilicom/ONIXParserTest.php b/tests/library/Class/WebService/Dilicom/ONIXParserTest.php index 55de39d7b87f6d25b8f5df3507b5e721e864e408..89cd3c50e209ba9c4176e29d702c26056a3fe91d 100644 --- a/tests/library/Class/WebService/Dilicom/ONIXParserTest.php +++ b/tests/library/Class/WebService/Dilicom/ONIXParserTest.php @@ -93,9 +93,9 @@ class DilicomONIXParserTest extends Storm_Test_ModelTestCase { /** @test */ - public function albumRightShouldBe2() { + public function albumRightShouldBeOther() { $album = $this->_book->import(); - $this->assertEquals(2, $album->getDroits()); + $this->assertEquals(Class_Album::RIGHT_OTHER_KEY, $album->getDroits()); }