/** * Find all date variables in the template. The return value * will be passed to process for the main parsing loop. * * @param String The tagdata to be parsed * @param Object The preparser object. * @return Array Found date tags. */ public function pre_process($tagdata, EE_Channel_preparser $pre) { $prefix = $pre->prefix(); $entry_date = array(); $gmt_date = array(); $gmt_entry_date = array(); $edit_date = array(); $gmt_edit_date = array(); $expiration_date = array(); $week_date = array(); $date_vars = array('entry_date', 'gmt_date', 'gmt_entry_date', 'edit_date', 'gmt_edit_date', 'expiration_date', 'recent_comment_date', 'week_date'); ee()->load->helper('date'); foreach ($date_vars as $val) { if (!$pre->has_tag($val)) { continue; } $full_val = $prefix . $val; if (preg_match_all("/" . LD . $full_val . "\\s+format=([\"'])([^\\1]*?)\\1" . RD . "/s", $tagdata, $matches)) { for ($j = 0; $j < count($matches[0]); $j++) { $matches[0][$j] = str_replace(array(LD, RD), '', $matches[0][$j]); switch ($val) { case 'entry_date': $entry_date[$matches[0][$j]] = $matches[2][$j]; break; case 'gmt_date': $gmt_date[$matches[0][$j]] = $matches[2][$j]; break; case 'gmt_entry_date': $gmt_entry_date[$matches[0][$j]] = $matches[2][$j]; break; case 'edit_date': $edit_date[$matches[0][$j]] = $matches[2][$j]; break; case 'gmt_edit_date': $gmt_edit_date[$matches[0][$j]] = $matches[2][$j]; break; case 'expiration_date': $expiration_date[$matches[0][$j]] = $matches[2][$j]; break; case 'recent_comment_date': $recent_comment_date[$matches[0][$j]] = $matches[2][$j]; break; case 'week_date': $week_date[$matches[0][$j]] = $matches[2][$j]; break; } } } } return call_user_func_array('compact', $date_vars); }
/** * Find all custom date variables in the template. The return value * will be passed to process for the main parsing loop. * * @param String The tagdata to be parsed * @param Object The preparser object. * @return Array Found custom date tags. */ public function pre_process($tagdata, EE_Channel_preparser $pre) { $prefix = $pre->prefix(); $channel = $pre->channel(); $custom_date_fields = array(); if (count($channel->dfields) == 0) { return $custom_date_fields; } foreach ($channel->dfields as $site_id => $dfields) { foreach ($dfields as $key => $value) { if (!$pre->has_tag($key)) { continue; } $key = $prefix . $key; if (preg_match_all("/" . LD . $key . "\\s+format=[\"'](.*?)[\"']" . RD . "/s", $tagdata, $matches)) { for ($j = 0; $j < count($matches[0]); $j++) { $matches[0][$j] = str_replace(array(LD, RD), '', $matches[0][$j]); $custom_date_fields[$matches[0][$j]] = $matches[1][$j]; } } } } return $custom_date_fields; }
/** * Quick check if they're using switch * * @param array A list of "disabled" features * @return Boolean Is disabled? */ public function disabled(array $disabled, EE_Channel_preparser $pre) { return !$pre->has_tag('switch'); }