Lançado Adianti Framework 7.6!
Clique aqui para saber mais
menu

Adianti Solutions

API

Adianti, Framework, PHP, MVC, Active record, Front controller, IDE, RAD, Web, multiplataforma, geração de código, desenvolvimento rápido, relatórios, formulários, listagens, datagrids, gráficos, banco de dados, padrões de projeto, design patterns API do Adianti Framework.
API Docs
code
Selecione a classe

Source for file TFullCalendar.php

Documentation is available at TFullCalendar.php

  1. <?php
  2. namespace Adianti\Widget\Util;
  3.  
  4. use Adianti\Core\AdiantiCoreTranslator;
  5. use Adianti\Control\TAction;
  6. use Adianti\Widget\Base\TScript;
  7. use Adianti\Widget\Base\TElement;
  8. use Adianti\Util\AdiantiTemplateHandler;
  9.  
  10. use stdClass;
  11.  
  12. /**
  13.  * FullCalendar Widget
  14.  *
  15.  * @version    7.4
  16.  * @package    widget
  17.  * @subpackage util
  18.  * @author     Pablo Dall'Oglio
  19.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  20.  * @license    http://www.adianti.com.br/framework-license
  21.  */
  22. class TFullCalendar extends TElement
  23. {
  24.     protected $current_date;
  25.     protected $event_action;
  26.     protected $day_action;
  27.     protected $update_action;
  28.     protected $reload_action;
  29.     protected $default_view;
  30.     protected $min_time;
  31.     protected $max_time;
  32.     protected $events;
  33.     protected $enabled_days;
  34.     protected $popover;
  35.     protected $poptitle;
  36.     protected $popcontent;
  37.     protected $resizable;
  38.     protected $movable;
  39.     protected $options;
  40.     protected $full_height;
  41.  
  42.  
  43.     /**
  44.      * Class Constructor
  45.      * @param $current_date Current date of calendar
  46.      * @param $default_view Default view (month, agendaWeek, agendaDay, listWeeky)
  47.      */
  48.     public function __construct($current_date NULL$default_view 'month')
  49.     {
  50.         parent::__construct('div');
  51.         $this->current_date = $current_date $current_date date('Y-m-d');
  52.         $this->default_view = $default_view;
  53.         $this->{'class''tfullcalendar';
  54.         $this->{'id'}    'tfullcalendar_' mt_rand(10000000001999999999);
  55.         $this->min_time  '00:00:00';
  56.         $this->max_time  '24:00:00';
  57.         $this->enabled_days [0,1,2,3,4,5,6];
  58.         $this->popover FALSE;
  59.         $this->resizable TRUE;
  60.         $this->movable TRUE;
  61.         $this->full_height FALSE;
  62.         $this->options [];
  63.     }
  64.     
  65.     /**
  66.      * Set extra datepicker options (ex: autoclose, startDate, daysOfWeekDisabled, datesDisabled)
  67.      * @link https://fullcalendar.io/docs/view-specific-options
  68.      */
  69.     public function setOption($option$value)
  70.     {
  71.         $this->options[$option$value;
  72.     }
  73.     
  74.     /**
  75.      * Define use full height
  76.      */
  77.     public function enableFullHeight($full_height TRUE)
  78.     {
  79.         $this->full_height $full_height;
  80.     }
  81.  
  82.     /**
  83.      * Define height
  84.      */
  85.     public function setHeight($height)
  86.     {
  87.         $this->options['expandRows'true;
  88.         $this->options['height'$height;
  89.     }
  90.  
  91.     /**
  92.      * Define the time range
  93.      */
  94.     public function setTimeRange($min_time$max_time)
  95.     {
  96.         $this->min_time $min_time;
  97.         $this->max_time $max_time;
  98.     }
  99.     
  100.     /**
  101.      * Enable these days
  102.      */
  103.     public function enableDays($days)
  104.     {
  105.         $this->enabled_days $days;
  106.     }
  107.     
  108.     /**
  109.      * Set the current date of calendar
  110.      * @param $date Current date of calendar
  111.      */
  112.     public function setCurrentDate($date)
  113.     {
  114.         $this->current_date $date;
  115.     }
  116.     
  117.     /**
  118.      * Set the current view of calendar
  119.      * @param $view Current view of calendar (month, agendaWeek, agendaDay, listWeek)
  120.      */
  121.     public function setCurrentView($view)
  122.     {
  123.         $this->default_view $view;
  124.     }
  125.     
  126.     /**
  127.      * Define the reload action
  128.      * @param $action reload action
  129.      */
  130.     public function setReloadAction(TAction $action)
  131.     {
  132.         $this->reload_action $action;
  133.     }
  134.     
  135.     /**
  136.      * Define the event click action
  137.      * @param $action event click action
  138.      */
  139.     public function setEventClickAction(TAction $action)
  140.     {
  141.         $this->event_action $action;
  142.     }
  143.     
  144.     /**
  145.      * Define the day click action
  146.      * @param $action day click action
  147.      */
  148.     public function setDayClickAction(TAction $action)
  149.     {
  150.         $this->day_action $action;
  151.     }
  152.     
  153.     /**
  154.      * Define the event update action
  155.      * @param $action event updaet action
  156.      */
  157.     public function setEventUpdateAction(TAction $action)
  158.     {
  159.         $this->update_action $action;
  160.     }
  161.     
  162.     /**
  163.      * Enable popover
  164.      * @param $title Title
  165.      * @param $content Content
  166.      */
  167.     public function enablePopover($title$content)
  168.     {
  169.         $this->popover TRUE;
  170.         $this->poptitle $title;
  171.         $this->popcontent $content;
  172.     }
  173.     
  174.     /**
  175.      * Disable event resize
  176.      */
  177.     public function disableResizing()
  178.     {
  179.         $this->resizable FALSE;
  180.     }
  181.     
  182.     /**
  183.      * Disable event dragging
  184.      */
  185.     public function disableDragging()
  186.     {
  187.         $this->movable FALSE;
  188.     }
  189.     
  190.     /**
  191.      * Add an event
  192.      * @param $id Event id
  193.      * @param $title Event title
  194.      * @param $start Event start time
  195.      * @param $end Event end time
  196.      * @param $url Event url
  197.      * @param $color Event color
  198.      */
  199.     public function addEvent($id$title$start$end NULL$url NULL$color NULL$object NULL)
  200.     {
  201.         $event new stdClass;
  202.         $event->{'id'$id;
  203.         
  204.         if ($this->popover and !empty($object))
  205.         {
  206.             $poptitle   AdiantiTemplateHandler::replace($this->poptitle$object);
  207.             $popcontent AdiantiTemplateHandler::replace($this->popcontent$object);
  208.             $event->{'title'self::renderPopover($title$poptitle$popcontent);
  209.         }
  210.         else
  211.         {
  212.             $event->{'title'$title;
  213.         }
  214.         $event->{'start'$start;
  215.         $event->{'end'$end;
  216.         $event->{'url'$url $url '';
  217.         $event->{'color'$color;
  218.         
  219.         $this->events[$event;
  220.     }
  221.     
  222.     /**
  223.      * Render title popover
  224.      * @param $title Event title
  225.      * @param $poptitle Popover Title
  226.      * @param $popcontent Popover Content
  227.      */
  228.     public static function renderPopover($title$poptitle$popcontent)
  229.     {
  230.         return "<div popover='true' poptitle='{$poptitle}' popcontent='{$popcontent}' style='display:inline;cursor:pointer'> {$title} </div>";
  231.     }
  232.     
  233.     /**
  234.      * Show the callendar and execute required scripts
  235.      */
  236.     public function show()
  237.     {
  238.         $id $this->{'id'};
  239.         
  240.         $language strtolowerAdiantiCoreTranslator::getLanguage() );
  241.         $reload_action_string '';
  242.         $event_action_string  '';
  243.         $day_action_string    '';
  244.         $update_action_string '';
  245.         $options json_encode($this->options);
  246.         
  247.         if ($this->event_action)
  248.         {
  249.             if ($this->event_action->isStatic())
  250.             {
  251.                 $this->event_action->setParameter('static''1');
  252.             }
  253.             $event_action_string $this->event_action->serialize();
  254.         }
  255.         
  256.         if ($this->day_action)
  257.         {
  258.             if ($this->day_action->isStatic())
  259.             {
  260.                 $this->day_action->setParameter('static''1');
  261.             }
  262.             $day_action_string $this->day_action->serialize();
  263.         }
  264.         
  265.         if ($this->update_action)
  266.         {
  267.             $update_action_string $this->update_action->serialize(FALSE);
  268.         }
  269.         if ($this->reload_action)
  270.         {
  271.             $reload_action_string $this->reload_action->serialize(FALSE);
  272.             $this->events array('url' => 'engine.php?' $reload_action_string '&static=1');
  273.         }
  274.         
  275.         $events json_encode($this->events);
  276.         $editable ($this->update_action'true' 'false';
  277.         $movable ($this->movable'true' 'false';
  278.         $resizable ($this->resizable'true' 'false';
  279.         $full_height ($this->full_height'true' 'false';
  280.         $hidden_days json_encode(array_values(array_diff([0,1,2,3,4,5,6]$this->enabled_days)));
  281.         
  282.         $default_views [
  283.             'month' => 'dayGridMonth',
  284.             'agendaWeek' => 'timeGridWeek',
  285.             'agendaDay' => 'timeGridDay',
  286.             'listWeeky' => 'listWeek',
  287.         ];
  288.  
  289.         $default_view empty($default_views[$this->default_view])$this->default_view$default_views[$this->default_view];
  290.  
  291.         TScript::create("tfullcalendar_start( '{$id}', {$editable}, '{$default_view}', '{$this->current_date}', '$language', $events, '{$day_action_string}', '{$event_action_string}', '{$update_action_string}', '{$this->min_time}', '{$this->max_time}', $hidden_days, {$movable}, {$resizable}, '{$options}', {$full_height});");
  292.         parent::show();
  293.     }
  294. }