本文整理汇总了PHP中Shineisp_Commons_Utilities::isDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Shineisp_Commons_Utilities::isDate方法的具体用法?PHP Shineisp_Commons_Utilities::isDate怎么用?PHP Shineisp_Commons_Utilities::isDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shineisp_Commons_Utilities
的用法示例。
在下文中一共展示了Shineisp_Commons_Utilities::isDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
public function search()
{
$params = array();
$module = $this->module;
$request = $this->getRequest();
$requested_parameters = array();
$columns = $this->config['datagrid']['columns'];
// Check if we have a POST request
if (!$request->isPost()) {
return $this->_helper->redirector('index');
}
$post = $this->getRequest()->getParams();
if ($post) {
$exclude = array('module' => null, 'controller' => null, 'action' => null, 'item' => null, 'actions' => null);
// Get only the fields visible in the search form and not all the fields of the form
foreach ($post as $index => $parameter) {
// Exclude some form items
if (!array_key_exists($index, $exclude)) {
// Loop of the datagrid columns
foreach ($columns as $column) {
// Check if the selected column matches the form item
if ($column['alias'] == $index) {
// Check if the value is not empty
if (!empty($parameter)) {
// Check the data types
if ($column['type'] == "string") {
$params['search'][$index] = array('method' => 'andWhere', 'criteria' => "{$index} like ?", 'value' => '%' . $parameter . '%');
} elseif ($column['type'] == "date") {
// Check if the field date value is a range of dates
if (is_array($parameter) && !empty($parameter[0]) && !empty($parameter[1])) {
// Check if the value is a date
if (Shineisp_Commons_Utilities::isDate($parameter[0]) && Shineisp_Commons_Utilities::isDate($parameter[1])) {
// Convert the date
$date_1 = Shineisp_Commons_Utilities::formatDateIn($parameter[0]);
$date_2 = Shineisp_Commons_Utilities::formatDateIn($parameter[1]);
// Build the criteria
$params['search'][$index] = array('method' => 'andWhere', 'criteria' => "{$index} between ? and ?", 'value' => array($date_1, $date_2));
}
// Check if the field date value has only one date
} elseif (is_array($parameter) && !empty($parameter[0]) && empty($parameter[1])) {
// Check if the value is a date
if (Shineisp_Commons_Utilities::isDate($parameter[0])) {
// Convert the date
$date = Shineisp_Commons_Utilities::formatDateIn($parameter[0]);
// Build the criteria
$params['search'][$index] = array('method' => 'andWhere', 'criteria' => "{$index} = ?", 'value' => $date);
}
}
} else {
$params['search'][$index] = array('method' => 'andWhere', 'criteria' => "{$index} = ?", 'value' => $parameter);
}
}
}
}
}
}
$this->session->{$module}->filters = $params;
// Check if it is an ajax request
if ($this->getRequest()->isXmlHttpRequest()) {
die(json_encode(array('reload' => "/admin/" . $this->module . "/list")));
} else {
$this->redirector->gotoUrl("/admin/" . $this->module . "/list");
}
}
}
示例2: formatSearchvalue
public static function formatSearchvalue($value)
{
// If is a numeric
if (is_numeric($value)) {
return $value;
}
// If is a date
if (Shineisp_Commons_Utilities::isDate($value)) {
return Shineisp_Commons_Utilities::formatDateOut($value);
}
$value = addslashes($value);
return $value;
}