当前位置: 首页>>代码示例>>PHP>>正文


PHP DateField::dataValue方法代码示例

本文整理汇总了PHP中DateField::dataValue方法的典型用法代码示例。如果您正苦于以下问题:PHP DateField::dataValue方法的具体用法?PHP DateField::dataValue怎么用?PHP DateField::dataValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateField的用法示例。


在下文中一共展示了DateField::dataValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dataValue

 function dataValue()
 {
     $valDate = $this->dateField->dataValue();
     $valTime = $this->timeField->dataValue();
     // Only date is actually required, time is optional
     if ($valDate) {
         if (!$valTime) {
             $valTime = '00:00:00';
         }
         return $valDate . ' ' . $valTime;
     } else {
         // TODO
         return null;
     }
 }
开发者ID:Raiser,项目名称:Praktikum,代码行数:15,代码来源:DatetimeField.php

示例2: testMDYFormat

 function testMDYFormat()
 {
     /* We get MM-DD-YYYY format as the data value for YYYY-MM-DD input value */
     $dateField = new DateField('Date', 'Date', '03/04/2003');
     $this->assertEquals($dateField->dataValue(), '2003-04-03');
     /* Even if input value hasn't got leading 0's in it we still get the correct data value */
     $dateField2 = new DateField('Date', 'Date', '3/4/03');
     $this->assertEquals($dateField2->dataValue(), '03-4-3');
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:9,代码来源:DateFieldTest.php

示例3: getList

 public function getList()
 {
     $context = $this->getSearchContext();
     $params = $this->request->requestVar('q');
     $list = $context->getResults($params);
     if ($this->request->requestVar('ID') === null && $this->request->param('ID') == 'field') {
         return $list;
     }
     if (!empty($params['Name'])) {
         $list = $list->filterAny(array('Name:PartialMatch' => $params['Name'], 'Title:PartialMatch' => $params['Name']));
     }
     if (!empty($params['AssetCategory'])) {
         switch ($params['AssetCategory']) {
             case 'file':
                 $list = $list->filter('ClassName', 'CloudinaryFile');
                 break;
             case 'image':
                 $list = $list->filter('ClassName', 'CloudinaryImage');
                 break;
             case 'video':
                 $list = $list->filter('ClassName', 'CloudinaryVideo');
                 break;
             case 'youtube':
                 $list = $list->filter('ClassName', 'YoutubeVideo');
                 break;
             case 'vimeo':
                 $list = $list->filter('ClassName', 'VimeoVideo');
                 break;
         }
     }
     // Date filter
     if (!empty($params['CreatedFrom'])) {
         $fromDate = new DateField(null, null, $params['CreatedFrom']);
         $list = $list->filter("Created:GreaterThanOrEqual", $fromDate->dataValue() . ' 00:00:00');
     }
     if (!empty($params['CreatedTo'])) {
         $toDate = new DateField(null, null, $params['CreatedTo']);
         $list = $list->filter("Created:LessThanOrEqual", $toDate->dataValue() . ' 23:59:59');
     }
     return $list;
 }
开发者ID:helpfulrobot,项目名称:mademedia-silverstripe-cloudinary,代码行数:41,代码来源:CloudinaryAdmin.php

示例4: getList

 /**
  * Returns the files and subfolders contained in the currently selected folder,
  * defaulting to the root node. Doubles as search results, if any search parameters
  * are set through {@link SearchForm()}.
  * 
  * @return SS_List
  */
 public function getList()
 {
     $folder = $this->currentPage();
     $context = $this->getSearchContext();
     // Overwrite name filter to search both Name and Title attributes
     $context->removeFilterByName('Name');
     $params = $this->getRequest()->requestVar('q');
     $list = $context->getResults($params);
     // Don't filter list when a detail view is requested,
     // to avoid edge cases where the filtered list wouldn't contain the requested
     // record due to faulty session state (current folder not always encoded in URL, see #7408).
     if (!$folder->ID && $this->getRequest()->requestVar('ID') === null && $this->getRequest()->param('ID') == 'field') {
         return $list;
     }
     // Re-add previously removed "Name" filter as combined filter
     // TODO Replace with composite SearchFilter once that API exists
     if (!empty($params['Name'])) {
         $list = $list->filterAny(array('Name:PartialMatch' => $params['Name'], 'Title:PartialMatch' => $params['Name']));
     }
     // Always show folders at the top
     $list = $list->sort('(CASE WHEN "File"."ClassName" = \'Folder\' THEN 0 ELSE 1 END), "Name"');
     // If a search is conducted, check for the "current folder" limitation.
     // Otherwise limit by the current folder as denoted by the URL.
     if (empty($params) || !empty($params['CurrentFolderOnly'])) {
         $list = $list->filter('ParentID', $folder->ID);
     }
     // Category filter
     if (!empty($params['AppCategory']) && !empty(File::config()->app_categories[$params['AppCategory']])) {
         $exts = File::config()->app_categories[$params['AppCategory']];
         $list = $list->filter('Name:PartialMatch', $exts);
     }
     // Date filter
     if (!empty($params['CreatedFrom'])) {
         $fromDate = new DateField(null, null, $params['CreatedFrom']);
         $list = $list->filter("Created:GreaterThanOrEqual", $fromDate->dataValue() . ' 00:00:00');
     }
     if (!empty($params['CreatedTo'])) {
         $toDate = new DateField(null, null, $params['CreatedTo']);
         $list = $list->filter("Created:LessThanOrEqual", $toDate->dataValue() . ' 23:59:59');
     }
     return $list;
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:49,代码来源:AssetAdmin.php

示例5: setValue

 /**
  * Sets the internal value to ISO date format, based on either a database value in ISO date format,
  * or a form submssion in the user date format. Uses the individual date and time fields
  * to take care of the actual formatting and value conversion.
  * 
  * Value setting happens *before* validation, so we have to set the value even if its not valid.
  * 
  * Caution: Only converts user timezones when value is passed as array data (= form submission).
  * Weak indication, but unfortunately the framework doesn't support a distinction between
  * setting a value from the database, application logic, and user input.
  * 
  * @param string|array $val String expects an ISO date format. Array notation with 'date' and 'time'
  *  keys can contain localized strings. If the 'dmyfields' option is used for {@link DateField},
  *  the 'date' value may contain array notation was well (see {@link DateField->setValue()}).
  */
 function setValue($val)
 {
     // If timezones are enabled, assume user data needs to be reverted to server timezone
     if ($this->getConfig('usertimezone')) {
         // Accept user input on timezone, but only when timezone support is enabled
         $userTz = is_array($val) && array_key_exists('timezone', $val) ? $val['timezone'] : null;
         if (!$userTz) {
             $userTz = $this->getConfig('usertimezone');
         }
         // fall back to defined timezone
     } else {
         $userTz = null;
     }
     if (empty($val)) {
         $this->value = null;
         $this->dateField->setValue(null);
         $this->timeField->setValue(null);
     } else {
         // Case 1: String setting from database, in ISO date format
         if (is_string($val) && Zend_Date::isDate($val, $this->getConfig('datavalueformat'), $this->locale)) {
             $this->value = $val;
         } elseif (is_array($val) && array_key_exists('date', $val) && array_key_exists('time', $val)) {
             $dataTz = date_default_timezone_get();
             // If timezones are enabled, assume user data needs to be converted to server timezone
             if ($userTz) {
                 date_default_timezone_set($userTz);
             }
             // Uses sub-fields to temporarily write values and delegate dealing with their normalization,
             // actual sub-field value setting happens later
             $this->dateField->setValue($val['date']);
             $this->timeField->setValue($val['time']);
             if ($this->dateField->dataValue() && $this->timeField->dataValue()) {
                 $userValueObj = new Zend_Date(null, null, $this->locale);
                 $userValueObj->setDate($this->dateField->dataValue(), $this->dateField->getConfig('datavalueformat'));
                 $userValueObj->setTime($this->timeField->dataValue(), $this->timeField->getConfig('datavalueformat'));
                 if ($userTz) {
                     $userValueObj->setTimezone($dataTz);
                 }
                 $this->value = $userValueObj->get($this->getConfig('datavalueformat'), $this->locale);
                 unset($userValueObj);
             } else {
                 // Validation happens later, so set the raw string in case Zend_Date doesn't accept it
                 $this->value = sprintf($this->getConfig('datetimeorder'), $val['date'], $val['time']);
             }
             if ($userTz) {
                 date_default_timezone_set($dataTz);
             }
         } else {
             $this->dateField->setValue($val);
             if (is_string($val)) {
                 $this->timeField->setValue($val);
             }
             $this->value = $val;
         }
         // view settings (dates might differ from $this->value based on user timezone settings)
         if (Zend_Date::isDate($this->value, $this->getConfig('datavalueformat'), $this->locale)) {
             $valueObj = new Zend_Date($this->value, $this->getConfig('datavalueformat'), $this->locale);
             if ($userTz) {
                 $valueObj->setTimezone($userTz);
             }
             // Set view values in sub-fields
             if ($this->dateField->getConfig('dmyfields')) {
                 $this->dateField->setValue($valueObj->toArray());
             } else {
                 $this->dateField->setValue($valueObj->get($this->dateField->getConfig('dateformat'), $this->locale));
             }
             $this->timeField->setValue($valueObj->get($this->timeField->getConfig('timeformat'), $this->locale));
         }
     }
 }
开发者ID:,项目名称:,代码行数:85,代码来源:

示例6: pagesIncluded

 /**
  * Retun an array of maps containing the keys, 'ID' and 'ParentID' for each page to be displayed
  * in the search.
  * 
  * @return Array
  */
 public function pagesIncluded()
 {
     $sng = singleton('SiteTree');
     $ids = array();
     $query = new DataQuery('SiteTree');
     $query->setQueriedColumns(array('ID', 'ParentID'));
     foreach ($this->params as $name => $val) {
         $SQL_val = Convert::raw2sql($val);
         switch ($name) {
             case 'Term':
                 $query->whereAny(array("\"URLSegment\" LIKE '%{$SQL_val}%'", "\"Title\" LIKE '%{$SQL_val}%'", "\"MenuTitle\" LIKE '%{$SQL_val}%'", "\"Content\" LIKE '%{$SQL_val}%'"));
                 break;
             case 'LastEditedFrom':
                 $fromDate = new DateField(null, null, $SQL_val);
                 $query->where("\"LastEdited\" >= '{$fromDate->dataValue()}'");
                 break;
             case 'LastEditedTo':
                 $toDate = new DateField(null, null, $SQL_val);
                 $query->where("\"LastEdited\" <= '{$toDate->dataValue()}'");
                 break;
             case 'ClassName':
                 if ($val && $val != 'All') {
                     $query->where("\"ClassName\" = '{$SQL_val}'");
                 }
                 break;
             default:
                 if (!empty($val) && $sng->hasDatabaseField($name)) {
                     $filter = $sng->dbObject($name)->defaultSearchFilter();
                     $filter->setValue($val);
                     $filter->apply($query);
                 }
         }
     }
     foreach ($query->execute() as $row) {
         $ids[] = array('ID' => $row['ID'], 'ParentID' => $row['ParentID']);
     }
     return $ids;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:44,代码来源:CMSSiteTreeFilter.php

示例7: testMDYFormat

 /**
  * Note: This is mostly tested for legacy reasons
  */
 public function testMDYFormat()
 {
     $dateField = new DateField('Date', 'Date');
     $dateField->setConfig('dateformat', 'd/M/Y');
     $dateField->setValue('31/03/2003');
     $this->assertEquals($dateField->dataValue(), '2003-03-31', "We get MM-DD-YYYY format as the data value for YYYY-MM-DD input value");
     $dateField2 = new DateField('Date', 'Date');
     $dateField2->setConfig('dateformat', 'd/M/Y');
     $dateField2->setValue('04/3/03');
     $this->assertEquals($dateField2->dataValue(), '2003-03-04', "Even if input value hasn't got leading 0's in it we still get the correct data value");
 }
开发者ID:normann,项目名称:sapphire,代码行数:14,代码来源:DateFieldTest.php

示例8: applyDefaultFilters

 /**
  * Applies the default filters to a specified DataList of pages
  *
  * @param DataList $query Unfiltered query
  * @return DataList Filtered query
  */
 protected function applyDefaultFilters($query)
 {
     $sng = singleton('SiteTree');
     foreach ($this->params as $name => $val) {
         if (empty($val)) {
             continue;
         }
         switch ($name) {
             case 'Term':
                 $query = $query->filterAny(array('URLSegment:PartialMatch' => $val, 'Title:PartialMatch' => $val, 'MenuTitle:PartialMatch' => $val, 'Content:PartialMatch' => $val));
                 break;
             case 'LastEditedFrom':
                 $fromDate = new DateField(null, null, $val);
                 $query = $query->filter("LastEdited:GreaterThanOrEqual", $fromDate->dataValue() . ' 00:00:00');
                 break;
             case 'LastEditedTo':
                 $toDate = new DateField(null, null, $val);
                 $query = $query->filter("LastEdited:LessThanOrEqual", $toDate->dataValue() . ' 23:59:59');
                 break;
             case 'ClassName':
                 if ($val != 'All') {
                     $query = $query->filter('ClassName', $val);
                 }
                 break;
             default:
                 if ($sng->hasDatabaseField($name)) {
                     $filter = $sng->dbObject($name)->defaultSearchFilter();
                     $filter->setValue($val);
                     $query = $query->alterDataQuery(array($filter, 'apply'));
                 }
         }
     }
     return $query;
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:40,代码来源:CMSSiteTreeFilter.php


注:本文中的DateField::dataValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。