Skip to content
Snippets Groups Projects
Commit b82aa091 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

rel #19211 : viewnotice should use common record thumbnail helper

parent 1add76f5
Branches
Tags
1 merge request!1152Dev#19211 recuperation des visuels cd dans le champ 959
......@@ -52,18 +52,9 @@ $script_loader = Class_ScriptLoader::getInstance()
<div class="notice_vignette">
<?php
if ($this->notice->hasVignette()) {
echo $this->tag('a',
$this->tagImg($this->notice->getUrlVignette(),
['style' => 'width:100px;',
'alt' => $this->_('Vignette')]),
['id' => 'vignette',
'href' => $this->notice->getUrlImage(),
'title' => htmlentities($this->notice->getTitrePrincipal())]);
$script_loader->addJQueryReady('$("a#vignette").butterfly({closeButton:false});');
}
else
echo $this->notice_Vignette($this->notice);
echo $this->notice_Vignette($this->notice,
[],
ZendAfi_View_Helper_Notice_Vignette::MODE_VIEW);
if ($this->display_modifier_vignette_link)
echo sprintf('<a href="#" onclick="showPopWin(\'%s\', 750, 350); return false;">%s</a>',
......
......@@ -18,38 +18,96 @@
* 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_Notice_Vignette extends Zend_View_Helper_HtmlElement {
const MODE_RESULT = 'result';
const MODE_VIEW = 'view';
public function notice_Vignette($record, $preferences=[], $strategy=null) {
if (!$strategy
|| !in_array($strategy, [static::MODE_RESULT, static::MODE_VIEW]))
$strategy = static::MODE_RESULT;
return $this->_newStrategy($strategy)
->render($this->view, $record, $preferences);
}
protected function _newStrategy($named) {
$class_name = 'ZendAfi_View_Helper_Notice_VignetteStrategy' . ucfirst($named);
return new $class_name();
}
}
abstract class ZendAfi_View_Helper_Notice_VignetteStrategy {
use Trait_Translator;
public function notice_Vignette($notice, $preferences=[]) {
protected $_view, $_record, $_preferences;
public function render($view, $record, $preferences) {
$this->view = $view;
$this->_record = $record;
$this->_preferences = $preferences;
if (!$notice->getUrlVignette())
$notice->fetchUrlVignette();
$this->_ensureUrl();
return 'NO' == $this->_record->getUrlVignette()
? $this->_renderNoThumbnail()
: $this->_renderThumbnail();
}
if($notice->getUrlVignette() != 'NO')
return $this->imgVignette($notice, $preferences);
return $this->view->notice_HtmlThumbnail($notice, $preferences);
protected function _ensureUrl() {
return $this->_record->hasUrlVignette()
? $this->_record->getUrlVignette() : $this->_record->fetchUrlVignette();
}
public function imgVignette($notice, $preferences) {
$img = $notice->fetchUrlVignette();
protected function _renderNoThumbnail() {
return $this->view->notice_HtmlThumbnail($this->_record, $this->_preferences);
}
return $this->linkTagForNoticeUrlVignetteTitle($notice, $img, Class_WebService_Vignette::getSource($img), $preferences);
abstract protected function _renderThumbnail();
protected function _renderImage() {
$url = $this->_record->fetchUrlVignette();
return $this->view->tagImg($this->view->absoluteUrl($url),
['width' => '90px',
'alt' => $this->_('Vignette'),
'title' => Class_WebService_Vignette::getSource($url),
'style' => 'border:0']);
}
}
public function linkTagForNoticeUrlVignetteTitle($notice, $url, $title, $preferences) {
$img = $this->view->tagImg($this->view->absoluteUrl($url),
['width' => '90',
'alt' => $this->_('Vignette'),
'title' => $title,
'style' => 'border:0']);
return $this->view->tagAnchor($this->view->urlNotice($notice, $preferences),
$img);
class ZendAfi_View_Helper_Notice_VignetteStrategyResult
extends ZendAfi_View_Helper_Notice_VignetteStrategy {
protected function _renderThumbnail() {
return $this->view->tagAnchor($this->view->urlNotice($this->_record,
$this->_preferences),
$this->_renderImage());
}
}
?>
\ No newline at end of file
class ZendAfi_View_Helper_Notice_VignetteStrategyView
extends ZendAfi_View_Helper_Notice_VignetteStrategy {
protected function _renderThumbnail() {
Class_ScriptLoader::getInstance()
->addJQueryReady('$("a#vignette").butterfly({closeButton:false});');
return $this->view->tagAnchor($this->view->absoluteUrl($this->_record->getUrlImage()),
$this->_renderImage(),
['id' => 'vignette',
'title' => htmlentities($this->_record->getTitrePrincipal())]);
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment