Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function render($empty = FALSE)
 {
     if (!$empty || !empty($this->options['empty'])) {
         $argument = CalendarHelper::getDateArgumentHandler($this->view);
         $render = [];
         $header_text = $this->renderTextField($this->options['content']);
         if (!$this->options['pager_embed']) {
             $render = array('#theme' => 'calendar_header', '#title' => $header_text, '#empty' => $empty, '#granularity' => $argument->getGranularity());
         } else {
             if ($this->view->display_handler->renderPager()) {
                 $exposed_input = isset($this->view->exposed_raw_input) ? $this->view->exposed_raw_input : NULL;
                 $render = $this->view->renderPager($exposed_input);
                 // Override the exclude option of the pager.
                 $render['#exclude'] = FALSE;
                 $render['#items']['current'] = $header_text;
             }
         }
         return $render;
     }
     return array();
 }
Ejemplo n.º 2
0
 /**
  * Get select options for Views displays that support Calendar with set granularity.
  *
  * @param $granularity
  *
  * @return array
  */
 protected function viewOptionsForGranularity($granularity)
 {
     $options = [];
     $view_displays = Views::getApplicableViews('uses_route');
     foreach ($view_displays as $view_display) {
         list($view_id, $display_id) = $view_display;
         $view = View::load($view_id);
         $view_exec = $view->getExecutable();
         if ($argument = CalendarHelper::getDateArgumentHandler($view_exec, $display_id)) {
             if ($argument->getGranularity() == $granularity) {
                 $route_name = CalendarHelper::getDisplayRouteName($view_id, $display_id);
                 $options[$route_name] = $view->label() . ' : ' . $view_exec->displayHandlers->get($display_id)->display['display_title'];
             }
         }
     }
     return $options;
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     parent::init($view, $display, $options);
     $this->argument = CalendarHelper::getDateArgumentHandler($this->view);
 }