本文整理汇总了PHP中plgFabrik_Element::getFilterValue方法的典型用法代码示例。如果您正苦于以下问题:PHP plgFabrik_Element::getFilterValue方法的具体用法?PHP plgFabrik_Element::getFilterValue怎么用?PHP plgFabrik_Element::getFilterValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plgFabrik_Element
的用法示例。
在下文中一共展示了plgFabrik_Element::getFilterValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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
* @param string intial $condition
* @param string eval - how the value should be handled
* @return array (value condition) values should be in mySQL format
*/
function getFilterValue($value, $condition, $eval)
{
$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'));
$filterType =& $this->getElement()->filter_type;
switch ($filterType) {
case 'field':
case 'dropdown':
$mysql = $this->tableDateToMySQL($value);
if ($mysql !== false) {
$value = $mysql;
}
if (!$params->get('date_showtime', 0) || $exactTime == false) {
//$$$ rob turn into a ranged filter to search the entire day
$value = (array) $value;
$condition = 'BETWEEN';
$value[1] = date("Y-m-d H:i:s", strtotime($this->addDays($value[0], 1)) - 1);
}
break;
case 'ranged':
$value = (array) $value;
foreach ($value as &$v) {
$mysql = $this->tableDateToMySQL($v);
if ($mysql !== false) {
$v = $mysql;
}
}
break;
}
$this->_resetToGMT = true;
return parent::getFilterValue($value, $condition, $eval);
}
示例3: 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
//.........这里部分代码省略.........