示例#1
0
文件: date.php 项目: glauberm/cinevi
 /**
  * Shows the data formatted for the list view
  *
  * @param   string   $data     Elements data
  * @param   stdClass &$thisRow All the data in the lists current row
  * @param   array    $opts     Rendering options
  *
  * @return  string    formatted value
  */
 public function renderListData($data, stdClass &$thisRow, $opts = array())
 {
     if ($data == '') {
         return parent::renderListData($data, $thisRow, $opts);
     }
     // @TODO: deal with time options (currently can be defined in date_table_format param).
     $timeZone = new DateTimeZone($this->config->get('offset'));
     $params = $this->getParams();
     $data = FabrikWorker::JSONtoData($data, true);
     $f = $params->get('date_table_format', 'Y-m-d');
     $format = array();
     if (strstr($f, '%')) {
         FabDate::strftimeFormatToDateFormat($f);
     }
     foreach ($data as $d) {
         if (FabrikWorker::isDate($d)) {
             $date = JFactory::getDate($d);
             if ($this->shouldApplyTz('list')) {
                 $date->setTimeZone($timeZone);
             }
             if ($f == '{age}') {
                 $format[] = date('Y') - $date->format('Y', true);
             } else {
                 $format[] = $date->format($f, true);
             }
         } else {
             $format[] = '';
         }
     }
     $data = json_encode($format);
     return parent::renderListData($data, $thisRow, $opts);
 }
示例#2
0
 /**
  * Shows the data formatted for the list view
  *
  * @param   string    $data      elements data
  * @param   stdClass  &$thisRow  all the data in the lists current row
  *
  * @return  string	formatted value
  */
 public function renderListData($data, stdClass &$thisRow)
 {
     $params = $this->getParams();
     $groupModel = $this->getGroupModel();
     $labeldata = array();
     if (!$groupModel->isJoin() && $groupModel->canRepeat()) {
         $opts = $this->_getOptionVals();
         $name = $this->getFullName(false, true, false) . '_raw';
         // If coming from fabrikemail plugin $thisRow is empty
         if (isset($thisRow->{$name})) {
             $data = $thisRow->{$name};
         }
         if (!is_array($data)) {
             $data = json_decode($data, true);
         }
         foreach ($data as $d) {
             foreach ($opts as $opt) {
                 if ($opt->value == $d) {
                     $labeldata[] = $opt->text;
                     break;
                 }
             }
         }
         $data = json_encode($labeldata);
     }
     // $$$ rob add links and icons done in parent::renderListData();
     return parent::renderListData($data, $thisRow);
 }