Example #1
0
 /**
  * A fall back method for timestamp fields.  Will convert the DB value to a
  * Unix timestamp and then format it with PHP's date() function.  (How
  * retro!)  You can customize the format with setDateFormat().
  *
  * @param FieldInterface $field
  * @param array $rowData
  * @return string
  */
 protected function renderDbTimestamp(DbField $field, array $rowData)
 {
     $value = $rowData[$field->getName()];
     $timestamp = strtotime($value);
     // Hack for handling GMT offsets in WordPress.
     if ($timestamp && function_exists('get_option')) {
         $timezoneString = get_option('timezone_string');
         if ($timezoneString) {
             $offset = timezone_offset_get(new DateTimeZone($timezoneString), date_create($value));
             $timestamp += $offset;
         }
     }
     if ($timestamp) {
         return $this->view->escapeHtml(date($this->dateFormat . ' ' . $this->timeFormat, $timestamp));
     } else {
         return '';
     }
 }
Example #2
0
 /**
  * A fall back method for timestamp fields.  Will convert the DB value to a
  * Unix timestamp and then format it with PHP's date() function.  (How
  * retro!)  You can customize the format with setDateFormat().
  *
  * @param FieldInterface $field
  * @param array $rowData
  * @return string
  */
 protected function renderDbTimestamp(DbField $field, array $rowData)
 {
     $value = $rowData[$field->getName()];
     $timestamp = strtotime($value);
     return $this->view->escapeHtml(date($this->dateFormat . ' ' . $this->timeFormat, $timestamp));
 }
Example #3
0
 /**
  * If no custom callback is defined for a field, it will fall back to this
  * method to find a suitable callback.  In the case of the Header helper,
  * we fall back to all field's just returning their label.
  *
  * @param FieldInterface $field
  * @return callable
  */
 public function detectCallableForField(FieldInterface $field)
 {
     return function () use($field) {
         return $this->view->escapeHtml($field->getLabel());
     };
 }