Commit 26415c5f authored by Laurent's avatar Laurent
Browse files

hotline #101798 better performances of article content generation. Put...

hotline #101798 better performances of article content generation. Put calendar ajax content in cache
parent d8335c74
Pipeline #8980 passed with stage
in 42 minutes and 32 seconds
- ticket #101798 : Amélioratiom du temps d'affichage de l'agenda
\ No newline at end of file
......@@ -228,18 +228,28 @@ class CmsController extends ZendAfi_Controller_Action {
public function calendarAction() {
$this->_initCalendarAndPreferences();
if ($this->_getParam('render') === 'ajax') {
$content = $this->view->calendarContent($this->view->calendar,
$this->view->preferences);
$script_loader = Class_ScriptLoader::getInstance();
$scripts = $script_loader
->addAdminScript('onload_utils')
->addJQueryReady('setupAnchorsTarget();')
->html();
if ($this->_getParam('render') !== 'ajax')
return;
$this->_helper->HTMLAjaxResponse($scripts . $content);
}
$cache_key = [$this->_request->getParams(),
Class_Profil::getCurrentProfil()->getId(),
__CLASS__,
__FUNCTION__];
$content = (new Storm_Cache())
->memoize($cache_key,
function()
{
return $this->view->calendarContent($this->view->calendar,
$this->view->preferences);
});
$script_loader = Class_ScriptLoader::getInstance();
$scripts = $script_loader
->addAdminScript('onload_utils')
->addJQueryReady('setupAnchorsTarget();')
->html();
$this->_helper->HTMLAjaxResponse($scripts . $content);
}
......
......@@ -26,7 +26,7 @@
->addInlineScript(sprintf('var baseUrl="%s"; var imagesUrl="%s"; var cssUrl="%s"; var userFilesUrl="%s"',
BASE_URL, URL_IMG, URL_CSS, USERFILESURL))
->addAdminScripts(['onload_utils', 'global', 'toolbar', 'common'])
->addAdminScripts(['onload_utils', 'global', 'common'])
->addOPACScripts(['menu',
'avis',
'recherche',
......
......@@ -762,7 +762,7 @@ class Class_Profil extends Storm_Model_Abstract {
$cfg_accueil = $this->getCfgAccueilAsArray();
$banner_boxes = [];
foreach ($cfg_accueil['modules'] as $id => $module) {
if ($module['division'] == self::DIV_BANNIERE)
if (isset($module['division']) && ($module['division'] == self::DIV_BANNIERE))
$banner_boxes[$id] = $module;
}
......
......@@ -45,19 +45,31 @@ class ZendAfi_View_Helper_TagArticleInfo extends ZendAfi_View_Helper_BaseHelper
}
protected function _dayMonth($strdate) {
return strftime('%a %d %b', strtotime($strdate));
}
protected function _hour($strdate) {
return strftime('%Hh', strtotime($strdate));
}
public function renderDateDebut($article) {
return
$this->renderItem(
$this->view->getHumanDate($article->getEventsDebut(),
'EEE d MMM'),
'event_start_date', $this->_('Commence le'));
$this->_dayMonth($article->getEventsDebut()),
'event_start_date',
$this->_('Commence le'));
}
public function renderHeureDebut($article) {
return
$this->renderItem($this->view->getHumanDate($article->getEventsDebut(),"HH'h'mm"),
'event_start_hour',$this->_('à'));
$this->renderItem(
$this->_hour($article->getEventsDebut()),
'event_start_hour',
$this->_('à'));
}
......@@ -65,15 +77,16 @@ class ZendAfi_View_Helper_TagArticleInfo extends ZendAfi_View_Helper_BaseHelper
public function renderDateFin($article) {
return
$this->renderItem(
$this->view->getHumanDate($article->getEventsFin(),
'EEE d MMM'),
'event_end_date',$this->_('finit le'));
$this->_dayMonth($article->getEventsFin()),
'event_end_date',
$this->_('finit le'));
}
public function renderHeureFin($article) {
return
$this->renderItem($this->view->getHumanDate($article->getEventsFin(),"HH'h'mm"),
$this->renderItem(
$this->_hour($article->getEventsFin()),
'event_end_hour',
$this->_('à'));
......
......@@ -16,12 +16,12 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_TagArticleInfoEvent extends ZendAfi_View_Helper_TagArticleInfo {
public function tagArticleInfoEvent($article,$title) {
return
return
'<span class="article_info_date">'.
$this->renderDateDebut($article).
$this->renderHeureDebut($article).
......@@ -39,36 +39,36 @@ class ZendAfi_View_Helper_TagArticleInfoEvent extends ZendAfi_View_Helper_TagArt
public function renderItem($html, $class, $libelle = NULL) {
return
$html
return
$html
? '<span class="'.$class.'">'.$html.'</span>'
: '';
}
public function renderDateDebut($article) {
return
$debut = strtotime($article->getEventsDebut());
return
$this->renderItem(
$this->view->getHumanDate($article->getEventsDebut(),
'd'),
'event_start_date_day').
strftime('%d', $debut),
'event_start_date_day').
$this->renderItem(
$this->view->getHumanDate($article->getEventsDebut(),
'MMMM'),
'event_start_date_month');
strftime('%B', $debut),
'event_start_date_month');
}
public function renderDateFin($article) {
return
$fin = strtotime($article->getEventsFin());
return
$this->renderItem(
$this->view->getHumanDate($article->getEventsFin(),
'd'),
'event_end_date_day').
strftime('%d', $fin),
'event_end_date_day').
$this->renderItem(
$this->view->getHumanDate($article->getEventsFin(),
'MMMM'),
'event_end_date_month');
strftime('%B', $fin),
'event_end_date_month');
}
}
......
......@@ -108,11 +108,7 @@ abstract class CmsControllerCalendarActionTestCase extends AbstractControllerTes
class CmsControllerCalendarActionCacheTest extends CmsControllerCalendarActionTestCase {
public function setUp() {
parent::setUp();
$cache = Storm_Test_ObjectWrapper::mock();
$cache->whenCalled('save')
->answers(true);
Storm_Cache::setDefaultZendCache($cache);
Storm_Cache::beVolatile();
$module_cal = new ZendAfi_View_Helper_Accueil_Calendar(1, $this->cfg_accueil['modules']['1']);
$module_cal->setView(new ZendAfi_Controller_Action_Helper_View());
}
......@@ -1165,13 +1161,28 @@ class CmsControllerCalendarActionWithOutDateTest extends AbstractControllerTestC
->answers([])
->beStrict();
Class_AdminVar::set('CACHE_ACTIF', '1');
Storm_Cache::beVolatile();
$this->dispatch('/cms/calendar/render/ajax', true);
}
/** @test */
public function gatArticleByPreferencesShouldBeCallWithEventDAteAfter() {
$this->assertXPathContentContains('//div', 'Kitchen', $this->_response->getBody());
public function getArticleByPreferencesShouldBeCallWithEventDAteAfter() {
$this->assertXPathContentContains('//div', 'Kitchen');
}
/** @test */
public function calendarContentShouldBeCached() {
$this->bootstrap();
Class_Article::getLoader()
->clearAllRedirections()
->whenCalled('getArticlesByPreferences')
->never();
$this->dispatch('/cms/calendar/render/ajax', true);
$this->assertXPathContentContains('//div', 'Kitchen');
}
}
......
......@@ -1081,13 +1081,13 @@ class CmsControllerArticleViewTest extends CmsControllerWithFeteDeLaFriteTestCas
/** @test **/
public function articleInfoShouldContainsDateDebut() {
$this->assertXPathContentContains('//dl[@class="article_info"]/dd[@class="event_start_date"]','sam 3 sept.');
$this->assertXPathContentContains('//dl[@class="article_info"]/dd[@class="event_start_date"]','sam. 03 sept.');
}
/** @test **/
public function articleInfoShouldContainsDateFin() {
$this->assertXPathContentContains('//dl[@class="article_info"]/dd[@class="event_end_date"]','mer 5 oct.');
$this->assertXPathContentContains('//dl[@class="article_info"]/dd[@class="event_end_date"]','mer. 05 oct.');
}
......
Markdown is supported
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