本文整理汇总了PHP中FabrikWorker::isDate方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::isDate方法的具体用法?PHP FabrikWorker::isDate怎么用?PHP FabrikWorker::isDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikWorker
的用法示例。
在下文中一共展示了FabrikWorker::isDate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCopyRow
/**
* Called when copy row list plugin called
*
* @param mixed $val Value to copy into new record
*
* @return mixed value to copy into new record
*/
public function onCopyRow($val)
{
if (!FabrikWorker::isDate($val)) {
return $val;
}
$params = $this->getParams();
if ($params->get('date_showtime', 0)) {
$storeAsLocal = (int) $params->get('date_store_as_local', 0);
if (!$storeAsLocal) {
$date = JFactory::getDate($val);
$timeZone = new DateTimeZone($this->config->get('offset'));
$date->setTimeZone($timeZone);
$val = $date->toSql(true);
}
}
return $val;
}
示例2: render
/**
* draws the form element
* @param int repeat group counter
* @return string returns element html
*/
function render($data, $repeatCounter = 0)
{
$this->_data = $data;
//need to store this for reuse in getCalOpts 3.0
$config = JFactory::getConfig();
$tzoffset = new DateTimeZone($config->get('offset'));
$db = FabrikWorker::getDbo();
$aNullDates = $this->getNullDates();
FabrikHelperHTML::loadcalendar();
$name = $this->getHTMLName($repeatCounter);
$id = $this->getHTMLId($repeatCounter);
$params = $this->getParams();
$element = $this->getElement();
$format = $params->get('date_form_format', $params->get('date_table_format', '%Y-%m-%d'));
$timeformat = $params->get('date_time_format');
//value should be in mySQL format
$value = $this->getValue($data, $repeatCounter);
$store_as_local = (int) $params->get('date_store_as_local', 0);
if ($params->get('date_showtime', 0) && !$element->hidden) {
//cant have names as simply [] as json only picks up the last one
$timeElName = $name . "[time]";
$name .= '[date]';
}
$readonly = $params->get('date_allow_typing_in_field', true) == false ? ' readonly="readonly" ' : "";
$calopts = array('class' => 'fabrikinput inputbox', 'size' => $element->width, 'maxlength' => '19');
if ($params->get('date_allow_typing_in_field', true) == false) {
$calopts['readonly'] = 'readonly';
}
$str = "<div class=\"fabrikSubElementContainer\" id=\"{$id}\">";
if (!in_array($value, $aNullDates) && FabrikWorker::isDate($value)) {
$oDate = JFactory::getDate($value);
//if we are coming back from a validation then we don't want to re-offset the date
if (JRequest::getVar('Submit', '') == '' || $params->get('date_defaulttotoday', 0)) {
// $$$ rob - if not time selector then the date gets stored as 2009-11-13 00:00:00
//if we have a -1 timezone then date gets set to 2009-11-12 23:00:00
//then shown as 2009-11-12 which is wrong
if ($params->get('date_showtime') && !$store_as_local) {
$oDate->setTimeZone($tzoffset);
}
}
//get the formatted date
$date = $oDate->toFormat($format, true);
if (!$this->_editable) {
$time = $params->get('date_showtime', 0) ? " " . $oDate->toFormat($timeformat, true) : '';
return $date . $time;
}
//get the formatted time
if ($params->get('date_showtime', 0)) {
$time = $oDate->toFormat($timeformat, true);
}
} else {
if (!$this->_editable) {
return '';
}
$date = '';
$time = '';
}
$str .= $this->calendar($date, $name, $id . "_cal", $format, $calopts, $repeatCounter);
if ($params->get('date_showtime', 0)) {
$timelength = strlen($timeformat);
$str .= "\n<input class=\"inputbox fabrikinput timeField\" {$readonly} size=\"{$timelength}\" value=\"{$time}\" name=\"{$timeElName}\" />";
$str .= "\n" . '<img src="' . COM_FABRIK_LIVESITE . 'plugins/fabrik_element/kdate/images/time.gif" alt="time" class="timeButton" />';
}
$str .= "</div>";
return $str;
}
示例3: getFilterValue
/**
* this builds an array containing the filters value and condition
* If no date time option, then we change the filter into a ranged filter to search
* the whole day for records.
* @param string initial $value all filters should submit as sql format
* @param string intial $condition
* @param string eval - how the value should be handled
* @return array (value condition) values in sql format
*/
function getFilterValue($value, $condition, $eval)
{
// if its a search all value it may not be a date - so use parent method.
// see http://fabrikar.com/forums/showthread.php?t=25255
if (!FabrikWorker::isDate($value)) {
if ($this->rangeFilterSet) {
// its alreay been set as a range expression - so split that into an array
$condition = 'between';
$value = explode(' AND ', $value);
foreach ($value as &$v) {
$v = str_replace(array("'", '"'), '', $v);
}
}
return parent::getFilterValue($value, $condition, FABRIKFILTER_QUERY);
}
$params = $this->getParams();
$store_as_local = (int) $params->get('date_store_as_local', 0);
if (!$params->get('date_showtime', 0) || $store_as_local) {
$this->_resetToGMT = false;
}
$exactTime = $this->formatContainsTime($params->get('date_table_format'));
// $$$ rob if filtering in querystring and ranged value set then force filter type to range
$filterType = is_array($value) ? 'range' : $this->getElement()->filter_type;
switch ($filterType) {
case 'range':
// ranged dates should be sent in sql format
break;
case 'field':
case 'dropdown':
case 'auto-complete':
default:
//odity when filtering from qs
$value = str_replace("'", '', $value);
// parse through JDate, to allow for special filters such as 'now' 'tomorrow' etc
// for searches on simply the year - JDate will presume its a timestamp and mung the results
// so we have to use this specific format string to get now and next
if (is_numeric($value) && strlen($value) == 4) {
// will only work on php 5.3.6
$value = JFactory::getDate('first day of January ' . $value)->toSql();
$next = JFactory::getDate('first day of January ' . ($value + 1));
} elseif ($this->isMonth($value)) {
$value = JFactory::getDate('first day of ' . $this->untranslateMonth($value))->toSql();
$next = JFactory::getDate('last day of ' . $this->untranslateMonth($value))->setTime(23, 59, 59);
} else {
$value = JFactory::getDate($value)->toSql();
$next = JFactory::getDate(strtotime($this->addDays($value, 1)) - 1);
}
// only set to a range if condition is matching (so dont set to range for < or > conditions)
if ($condition == 'contains' || $condition == '=' || $condition == 'REGEXP') {
if (!$params->get('date_showtime', 0) || $exactTime == false) {
//$$$ rob turn into a ranged filter to search the entire day
// values should be in sql format
$value = (array) $value;
$condition = 'BETWEEN';
$value[1] = $next->toSql();
// set a flat to stop getRangedFilterValue from adding an additional day to end value
$this->rangeFilterSet = true;
}
}
break;
}
$this->_resetToGMT = true;
$value = parent::getFilterValue($value, $condition, $eval);
return $value;
}
示例4: render
/**
* Draws the html form element
*
* @param array $data to preopulate element with
* @param int $repeatCounter repeat group counter
*
* @return string elements html
*/
public function render($data, $repeatCounter = 0)
{
/**
* Jaanus: needed also here to not to show 0000-00-00 in detail view;
* see also 58, added && !in_array($value, $aNullDates) (same reason).
*/
$db = JFactory::getDbo();
$aNullDates = array('0000-00-000000-00-00', '0000-00-00 00:00:00', '0000-00-00', '', $db->getNullDate());
$name = $this->getHTMLName($repeatCounter);
$id = $this->getHTMLId($repeatCounter);
$params = $this->getParams();
$element = $this->getElement();
$monthlabels = array(JText::_('January'), JText::_('February'), JText::_('March'), JText::_('April'), JText::_('May'), JText::_('June'), JText::_('July'), JText::_('August'), JText::_('September'), JText::_('October'), JText::_('November'), JText::_('December'));
$monthlabels = array(JText::_('January'), JText::_('February'), JText::_('March'), JText::_('April'), JText::_('May'), JText::_('June'), JText::_('July'), JText::_('August'), JText::_('September'), JText::_('October'), JText::_('November'), JText::_('December'));
$monthnumbers = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
$daysys = array('01', '02', '03', '04', '05', '06', '07', '08', '09');
$daysimple = array('1', '2', '3', '4', '5', '6', '7', '8', '9');
$bits = array();
/**
* $$$ rob - not sure why we are setting $data to the form's data
* but in table view when getting read only filter value from url filter this
* _form_data was not set to no readonly value was returned
* added little test to see if the data was actually an array before using it
*/
if (is_array($this->getFormModel()->data)) {
$data = $this->_form->_data;
}
$value = $this->getValue($data, $repeatCounter);
$fd = $params->get('details_date_format', 'd.m.Y');
$dateandage = (int) $params->get('details_dateandage', '0');
if (!$this->isEditable()) {
if (!in_array($value, $aNullDates)) {
// Avoid 0000-00-00
list($year, $month, $day) = strstr($value, '-') ? explode('-', $value) : explode(',', $value);
$daydisp = str_replace($daysys, $daysimple, $day);
$monthdisp = str_replace($monthnumbers, $monthlabels, $month);
$thisyear = date('Y');
$nextyear = date('Y') + 1;
$lastyear = date('Y') - 1;
// $$$ rob - all this below is nice but ... you still need to set a default
$detailvalue = '';
$year = JString::ltrim($year, '0');
if (FabrikWorker::isDate($value)) {
$date = JFactory::getDate($value);
$detailvalue = $date->toFormat($fd);
}
if (date('m-d') < $month . '-' . $day) {
$ageyear = $lastyear;
} else {
$ageyear = $thisyear;
}
if ($fd == 'd.m.Y') {
$detailvalue = $day . '.' . $month . '.' . $year;
} else {
if ($fd == 'm.d.Y') {
$detailvalue = $month . '/' . $day . '/' . $year;
}
if ($fd == 'D. month YYYY') {
$detailvalue = $daydisp . '. ' . $monthdisp . ' ' . $year;
}
if ($fd == 'Month d, YYYY') {
$detailvalue = $monthdisp . ' ' . $daydisp . ', ' . $year;
}
if ($fd == '{age}') {
$detailvalue = $ageyear - $year;
}
if ($fd == '{age} d.m') {
$mdvalue = $daydisp . '. ' . $monthdisp;
}
if ($fd == '{age} m.d') {
$mdvalue = $monthdisp . ' ' . $daydisp;
}
if ($fd == '{age} d.m' || $fd == '{age} m.d') {
// Always actual age
$detailvalue = $ageyear - $year;
if (date('m-d') == $month . '-' . $day) {
$detailvalue .= '<font color = "#CC0000"><b> ' . JText::_('TODAY') . '!</b></font>';
if (date('m') == '12') {
$detailvalue .= ' / ' . $nextyear . ': ' . ($nextyear - $year);
}
} else {
$detailvalue .= ' (' . $mdvalue;
if (date('m-d') < $month . '-' . $day) {
$detailvalue .= ': ' . ($thisyear - $year);
} else {
$detailvalue .= '';
}
if (date('m') == '12') {
$detailvalue .= ' / ' . $nextyear . ': ' . ($nextyear - $year);
} else {
$detailvalue .= '';
}
//.........这里部分代码省略.........
示例5: listFormat
/**
* Format a date based on list age/date format options
*
* @param string $d Date
*
* @since 3.0.9
*
* @return string|number
*/
private function listFormat($d)
{
if (!FabrikWorker::isDate($d)) {
return '';
}
$params = $this->getParams();
$monthLabels = array(FText::_('January'), FText::_('February'), FText::_('March'), FText::_('April'), FText::_('May'), FText::_('June'), FText::_('July'), FText::_('August'), FText::_('September'), FText::_('October'), FText::_('November'), FText::_('December'));
$monthNumbers = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
$daySys = array('01', '02', '03', '04', '05', '06', '07', '08', '09');
$daySimple = array('1', '2', '3', '4', '5', '6', '7', '8', '9');
$jubileum = array('0', '25', '75');
$ft = $params->get('list_date_format', 'd.m.Y');
$fta = $params->get('list_age_format', 'no');
/**
* $$$ rob default to a format date
* $date = JFactory::getDate($d);
* $dateDisplay = $date->toFormat($ft);
* Jaanus: sorry, but in this manner the element doesn't work with dates earlier than 1901
*/
list($year, $month, $day) = explode('-', $d);
$dayDisplay = str_replace($daySys, $daySimple, $day);
$monthDisplay = str_replace($monthNumbers, $monthLabels, $month);
$nextYear = date('Y') + 1;
$lastYear = date('Y') - 1;
$thisYear = date('Y');
$year = JString::ltrim($year, '0');
$dmy = $day . '.' . $month . '.' . $year;
$mdy = $month . '.' . $day . '.' . $year;
$dmy_slash = $day . '/' . $month . '/' . $year;
$dMonthYear = $dayDisplay . '. ' . $monthDisplay . ' ' . $year;
$monthDYear = $monthDisplay . ' ' . $dayDisplay . ', ' . $year;
$dMonth = $dayDisplay . ' ' . $monthDisplay;
if ($ft == "d.m.Y") {
$dateDisplay = $dmy;
} else {
switch ($ft) {
case 'm.d.Y':
$dateDisplay = $mdy;
break;
case 'd/m/Y':
$dateDisplay = $dmy_slash;
break;
case 'D. month YYYY':
$dateDisplay = $dMonthYear;
break;
case 'Month d, YYYY':
$dateDisplay = $monthDYear;
break;
default:
$dateDisplay = $dMonth;
break;
}
}
if ($fta == 'no') {
return $dateDisplay;
} else {
if (date('m-d') == $month . '-' . $day) {
if ($fta == '{age}') {
return '<span style="color:#DD0000"><b>' . ($thisYear - $year) . '</b></span>';
} else {
if ($fta == '{age} date') {
return '<span style="color:#DD0000"><b>' . $dateDisplay . ' (' . ($thisYear - $year) . ')</b></span>';
}
if ($fta == '{age} this') {
return '<span style="color:#DD0000"><b>' . ($thisYear - $year) . ' (' . $dateDisplay . ')</b></span>';
}
if ($fta == '{age} next') {
return '<span style="color:#DD0000"><b>' . ($nextYear - $year) . ' (' . $dateDisplay . ')</b></span>';
}
}
} else {
if ($fta == '{age} date') {
if (date('m-d') > $month . '-' . $day) {
return $dateDisplay . ' (' . ($thisYear - $year) . ')';
} else {
return $dateDisplay . ' (' . ($lastYear - $year) . ')';
}
} else {
if ($fta == '{age}') {
if (date('m-d') > $month . '-' . $day) {
return $thisYear - $year;
} else {
return $lastYear - $year;
}
} else {
if ($fta == '{age} this') {
if (in_array(substr($thisYear - $year, -1), $jubileum) || in_array(substr($thisYear - $year, -2), $jubileum)) {
return '<b>' . ($thisYear - $year) . ' (' . $dateDisplay . ')</b>';
} else {
return $thisYear - $year . ' (' . $dateDisplay . ')';
}
//.........这里部分代码省略.........
示例6: getFilterValue
/**
* Builds an array containing the filters value and condition
*
* @param string $value initial value
* @param string $condition intial $condition
* @param string $eval how the value should be handled
*
* @return array (value condition)
*/
public function getFilterValue($value, $condition, $eval)
{
/* if its a search all value it may not be a date - so use parent method.
* see http://fabrikar.com/forums/showthread.php?t=25255
*/
if (!FabrikWorker::isDate($value)) {
if ($this->rangeFilterSet) {
// Its alreay been set as a range expression - so split that into an array
$condition = 'between';
$value = explode(' AND ', $value);
foreach ($value as &$v) {
$v = str_replace(array("'", '"'), '', $v);
}
}
return parent::getFilterValue($value, $condition, FABRIKFILTER_QUERY);
}
$params = $this->getParams();
$store_as_local = (int) $params->get('date_store_as_local', 0);
if (!$params->get('date_showtime', 0) || $store_as_local) {
$this->resetToGMT = false;
}
$exactTime = $this->formatContainsTime($params->get('date_table_format'));
// $$$ rob if filtering in querystring and ranged value set then force filter type to range
$filterType = is_array($value) ? 'range' : $this->getElement()->filter_type;
switch ($filterType) {
case 'range':
// Ranged dates should be sent in sql format
break;
case 'field':
case 'dropdown':
case 'auto-complete':
default:
// Odity when filtering from qs
$value = str_replace("'", '', $value);
/**
* parse through JDate, to allow for special filters such as 'now' 'tomorrow' etc
* for searches on simply the year - JDate will presume its a timestamp and mung the results
* so we have to use this specific format string to get now and next
*/
if (is_numeric($value) && JString::strlen($value) == 4) {
// Will only work on php 5.3.6
$value = JFactory::getDate('first day of January ' . $value)->toSql();
$next = JFactory::getDate('first day of January ' . ($value + 1));
} elseif ($this->isMonth($value)) {
$value = JFactory::getDate('first day of ' . $this->untranslateMonth($value))->toSql();
$next = JFactory::getDate('last day of ' . $this->untranslateMonth($value))->setTime(23, 59, 59);
} elseif (trim(JString::strtolower($value)) === 'last week') {
$value = JFactory::getDate('last week')->toSql();
$next = JFactory::getDate();
} elseif (trim(JString::strtolower($value)) === 'last month') {
$value = JFactory::getDate('last month')->toSql();
$next = JFactory::getDate();
} elseif (trim(JString::strtolower($value)) === 'last year') {
$value = JFactory::getDate('last year')->toSql();
$next = JFactory::getDate();
} elseif (trim(JString::strtolower($value)) === 'next week') {
$value = JFactory::getDate()->toSql();
$next = JFactory::getDate('next week');
} elseif (trim(JString::strtolower($value)) === 'next month') {
$value = JFactory::getDate()->toSql();
$next = JFactory::getDate('next month');
} elseif (trim(JString::strtolower($value)) === 'next year') {
$value = JFactory::getDate()->toSql();
$next = JFactory::getDate('next year');
} else {
$value = JFactory::getDate($value)->toSql();
/**
* $$$ hugh - strip time if not needed. Specific case is element filter,
* first time submitting filter from list, will have arbitrary "now" time.
* Dunno if this will break anything else!
*/
if (!$exactTime) {
$value = $this->setMySQLTimeToZero($value);
}
$next = JFactory::getDate(strtotime($this->addDays($value, 1)) - 1);
/**
* $$$ now we need to reset $value to GMT.
* Probably need to take $store_as_local into account here?
*/
$this->resetToGMT = true;
$value = $this->toMySQLGMT(JFactory::getDate($value));
$this->resetToGMT = false;
}
// Only set to a range if condition is matching (so dont set to range for < or > conditions)
if ($condition == 'contains' || $condition == '=' || $condition == 'REGEXP') {
if (!$params->get('date_showtime', 0) || $exactTime == false) {
// $$$ rob turn into a ranged filter to search the entire day values should be in sql format
$value = (array) $value;
$condition = 'BETWEEN';
$value[1] = $next->toSql();
// Set a flat to stop getRangedFilterValue from adding an additional day to end value
//.........这里部分代码省略.........