Example #1
0
 /**
  * Create the html element used as the UI control for the datepicker button.
  * The href must keep only active filters.
  *
  * @param array           $args         Populated args for the view
  * @param int|string|null $initial_date The datepicker's initially set date
  * @return Ai1ec_Generic_Html_Tag
  */
 public function create_datepicker_link(array $args, $initial_date = null)
 {
     $settings = $this->_registry->get('model.settings');
     $date_system = $this->_registry->get('date.system');
     $date_format_pattern = $date_system->get_date_pattern_by_key($settings->get('input_date_format'));
     if (null === $initial_date) {
         // If exact_date argument was provided, use its value to initialize
         // datepicker.
         if (isset($args['exact_date']) && $args['exact_date'] !== false && $args['exact_date'] !== null) {
             $initial_date = $args['exact_date'];
         } else {
             $initial_date = $date_system->current_time();
         }
     }
     // Convert initial date to formatted date if required.
     if (Ai1ec_Validation_Utility::is_valid_time_stamp($initial_date)) {
         $initial_date = $date_system->format_date($initial_date, $settings->get('input_date_format'));
     }
     $href_args = array('action' => $args['action'], 'cat_ids' => $args['cat_ids'], 'tag_ids' => $args['tag_ids'], 'exact_date' => "__DATE__");
     $data_href = $this->create_href_helper_instance($href_args);
     $attributes = array('data-date' => $initial_date, 'data-date-format' => $date_format_pattern, 'data-date-weekstart' => $settings->get('week_start_day'), 'href' => '#', 'data-href' => $data_href->generate_href());
     $loader = $this->_registry->get('theme.loader');
     $file = $loader->get_file('date-icon.png');
     $args = array('attributes' => $attributes, 'data_type' => $args['data_type'], 'icon_url' => $file->get_url(), 'text_date' => __('Choose a date using calendar', AI1EC_PLUGIN_NAME));
     return $loader->get_file('datepicker_link.twig', $args);
 }
 /**
  * Create the html element used as the UI control for the datepicker button.
  * The href must keep only active filters.
  *
  * @param array           $args         Populated args for the view
  * @param int|string|null $initial_date The datepicker's initially set date
  * @return Ai1ec_Generic_Html_Tag
  */
 public static function create_datepicker_link(array $args, $initial_date = null)
 {
     global $ai1ec_settings, $ai1ec_view_helper;
     $link = Ai1ec_Helper_Factory::create_generic_html_tag('a');
     $date_format_pattern = Ai1ec_Time_Utility::get_date_pattern_by_key($ai1ec_settings->input_date_format);
     if ($initial_date == null) {
         // If exact_date argument was provided, use its value to initialize
         // datepicker.
         if (isset($args['exact_date']) && $args['exact_date'] !== false && $args['exact_date'] !== null) {
             $initial_date = $args['exact_date'];
         } else {
             $initial_date = Ai1ec_Time_Utility::gmt_to_local(Ai1ec_Time_Utility::current_time());
         }
     }
     // Convert initial date to formatted date if required.
     if (Ai1ec_Validation_Utility::is_valid_time_stamp($initial_date)) {
         $initial_date = Ai1ec_Time_Utility::format_date(Ai1ec_Time_Utility::gmt_to_local($initial_date), $ai1ec_settings->input_date_format);
     }
     $link->add_class('ai1ec-minical-trigger btn');
     $link->set_attribute('data-date', $initial_date);
     $link->set_attribute('data-date-format', $date_format_pattern);
     $link->set_attribute('data-date-weekstart', $ai1ec_settings->week_start_day);
     $link->set_attribute_expr($args['data_type']);
     $text = '<img src="' . esc_attr($ai1ec_view_helper->get_theme_img_url('date-icon.png')) . '" class="ai1ec-icon-datepicker" />';
     $link->set_text($text);
     $href_args = array('action' => $args['action'], 'cat_ids' => $args['cat_ids'], 'tag_ids' => $args['tag_ids'], 'exact_date' => "__DATE__");
     $data_href = self::create_href_helper_instance($href_args);
     $link->set_attribute('data-href', $data_href->generate_href());
     $link->set_attribute('href', '#');
     return $link;
 }
Example #3
0
 /**
  * Get the exact date from request if available, or else from settings.
  *
  * @param Ai1ec_Abstract_Query settings
  *
  * @return boolean|int
  */
 private function get_exact_date(Ai1ec_Abstract_Query $request)
 {
     $settings = $this->_registry->get('model.settings');
     // Preprocess exact_date.
     // Check to see if a date has been specified.
     $exact_date = $request->get('exact_date');
     $use_key = $exact_date;
     if (null === ($exact_date = $this->_exact_dates->get($use_key))) {
         $exact_date = $use_key;
         // Let's check if we have a date
         if (false !== $exact_date) {
             // If it's not a timestamp
             if (!Ai1ec_Validation_Utility::is_valid_time_stamp($exact_date)) {
                 // Try to parse it
                 $exact_date = $this->return_gmtime_from_exact_date($exact_date);
                 if (false === $exact_date) {
                     return null;
                 }
             }
         }
         // Last try, let's see if an exact date is set in settings.
         if (false === $exact_date && $settings->get('exact_date') !== '') {
             $exact_date = $this->return_gmtime_from_exact_date($settings->get('exact_date'));
         }
         $this->_exact_dates->set($use_key, $exact_date);
     }
     return $exact_date;
 }
 /**
  * Get the exact date from request if available, or else from settings.
  *
  * @param Ai1ec_Abstract_Query $request
  * @return boolean|int
  */
 private function get_exact_date(Ai1ec_Abstract_Query $request)
 {
     global $ai1ec_settings;
     // Preprocess exact_date.
     // Check to see if a date has been specified.
     $exact_date = $request->get('exact_date');
     // Let's check if we have a date
     if (false !== $exact_date) {
         // If it's not a timestamp
         if (!Ai1ec_Validation_Utility::is_valid_time_stamp($exact_date)) {
             // Try to parse it
             $exact_date = $this->return_gmtime_from_exact_date($exact_date);
         }
     }
     // Last try, let's see if an exact date is set in settings.
     if (false === $exact_date && $ai1ec_settings->exact_date !== '') {
         $exact_date = $this->return_gmtime_from_exact_date($ai1ec_settings->exact_date);
     }
     return $exact_date;
 }