本文整理汇总了PHP中FabrikWorker::inFormProcess方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::inFormProcess方法的具体用法?PHP FabrikWorker::inFormProcess怎么用?PHP FabrikWorker::inFormProcess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikWorker
的用法示例。
在下文中一共展示了FabrikWorker::inFormProcess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValue
/**
* Get the GMT Date time - tz offset applied in render() if needed
*
* @param array $data Form data date will be GMT if store as local OFF, otherwise as local time
* @param int $repeatCounter When repeating joined groups we need to know what part of the array to access
* @param array $opts Options
*
* @return string value Date as GMT time
*/
public function getValue($data, $repeatCounter = 0, $opts = array())
{
$params = $this->getParams();
$alwaysToday = $params->get('date_alwaystoday', false);
$defaultToday = $params->get('date_defaulttotoday', false);
$formModel = $this->getFormModel();
$value = parent::getValue($data, $repeatCounter, $opts);
$db = FabrikWorker::getDbo();
if (is_array($value)) {
// Submission posted as array but date & time in date key. Can be keyed to 0 if parent class casts string to array.
$value = FArrayHelper::getValue($value, 'date', FArrayHelper::getValue($value, 0));
}
// in some corner cases, date will be db name quoted, like in CSV export after an advanced search!
$value = trim($value, "'");
//if ($input->get('task') == 'form.process' || ($app->isAdmin() && $input->get('task') == 'process'))
if (FabrikWorker::inFormProcess()) {
// Don't mess with posted value - can cause double offsets - instead do in _indStoareDBFormat();
return $value;
}
// Element could be a date element (in which case no time stored) - check for both datetime and date null dates.
$nullDate = $db->getNullDate();
$shortNullDate = explode(' ', $nullDate);
$shortNullDate = FArrayHelper::getValue($shortNullDate, 0);
$isNullDate = $nullDate == $value || $shortNullDate == $value;
if (!(($formModel->isNewRecord() || $this->newGroup) && $defaultToday) && $value == '') {
if (($value == '' || $isNullDate) && !$alwaysToday) {
return $value;
}
if ($alwaysToday && $formModel->isEditable()) {
$value = '';
}
}
// Don't offset if null date.
if ($isNullDate) {
return $value;
}
$timeZone = new DateTimeZone($this->config->get('offset'));
$date = JFactory::getDate($value, $timeZone);
// Querystring value passed into new record
if ($formModel->isNewRecord() && $value !== '') {
// OK for : Default to current = no Local time = yes
if (!$defaultToday) {
$date = new DateTime($date, $timeZone);
return $date->format('Y-m-d H:i:s');
}
// Ok for : Default to current = yes, Local time = yes OR no
$date = new DateTime($date, $timeZone);
$date->setTimeZone(new DateTimeZone('UTC'));
return $date->format('Y-m-d H:i:s');
}
// If value = '' don't offset it (not sure what the logic is but testing seems to indicate this to be true)
$local = $formModel->hasErrors() || $value == '' || $params->get('date_store_as_local', 0) == 1 ? false : true;
$value = $date->toSQL($local);
return $value;
}