Skip to content
Snippets Groups Projects
RenderArticle.php 3.05 KiB
Newer Older
<?php
/**
 * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
 *
 * BOKEH is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation.
 *
 * There are special exceptions to the terms and conditions of the AGPL as it
 * is applied to this software (see README file).
 *
 * BOKEH is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * 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
 */


class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper {

  public function renderArticle($article) {
Ghislain Loas's avatar
Ghislain Loas committed
    $wrapper = (new Intonation_Library_View_Wrapper_Article)
      ->setModel($article)
Ghislain Loas's avatar
Ghislain Loas committed
      ->setWidgetContext(((new Intonation_Library_Widget_Carousel_NullContext)
                          ->setDropdownDirection('')))
Ghislain Loas's avatar
Ghislain Loas committed
      ->setView($this->view);
    $grid_content = $this->_injectLocation($article->getLieu());

    if ( ($osm_data = $wrapper->getOsmData()) && ($osm_wrapper = $osm_data->getwrapper()))
      $grid_content [] = $this->_div(['class' => 'article_location_data'],
                                     $this->view->renderingVertical($osm_wrapper));
    $location_content = $this->view->grid($grid_content);
    $full_content = $article->getFullContentWithCookiesConsent();
    $body_content = [$article->getCacherTitre()
                     ? ''
                     : $this->_tag('h2',
                                   $article->getTitre(),
                                   ['class' => 'card-title']),
                     $this->view->tagArticleEvent($article),
                     $this->_tag('p',
                                 $this->view->renderCKEditorWidgets($full_content),
                                 ['class' => 'card-text']),

    if (Class_AdminVar::isModuleEnabled('ENABLE_ARTICLES_TIMINGS'))
      $body_content []= $this->view->article_RenderEventTimings($article);

    $body = $this->_tag('div',
                        implode($body_content),
                        ['class' => 'card-body']);

Ghislain Loas's avatar
Ghislain Loas committed
    $footer = $this->view->renderActionsInRow($wrapper->getActions());

    return $this->_tag('div',
                       ['class' => 'card card_article']);
  }


  protected function _injectLocation($location) {
    if (!$location)
      return [];

    return [$this->_div(['class' => 'article_location_header'],
                        $this->_tag('h2', $this->_('Lieu de l\'événement'))),

            $this->_div(['class' => 'article_location_static_map'],
                        $this->view->mapForLieu($location, ['size' => '']))];
  }