示例#1
0
 /**
  *
  * child classes can then call this function with
  * return parent::renderListData($data, $oAllRowsData);
  * to perform rendering that is applicable to all plugins
  *
  * shows the data formatted for the table view
  * @param string data
  * @param object all the data in the tables current row
  * @return string formatted value
  */
 function renderListData($data, $oAllRowsData)
 {
     $params =& $this->getParams();
     $groupModel =& $this->_group;
     $labeldata = array();
     if (!$groupModel->isJoin() && $groupModel->canRepeat()) {
         $opts =& $this->_getOptionVals();
         $name = $this->getFullName(false, true, false) . "_raw";
         //if coming from fabrikemail plugin oAllRowsdata is empty
         if (isset($oAllRowsData->{$name})) {
             $data = $oAllRowsData->{$name};
         }
         if (!is_array($data)) {
             //$data = explode(GROUPSPLITTER, $data);
             $data = json_decode($data, true);
         }
         foreach ($data as $d) {
             foreach ($opts as $opt) {
                 if ($opt->value == $d) {
                     $labeldata[] = $opt->text;
                     break;
                 }
             }
         }
     } else {
         $labeldata[] = $data;
     }
     $data = json_encode($labeldata);
     // $$$ rob add links and icons done in parent::renderListData();
     return parent::renderListData($data, $oAllRowsData);
 }
示例#2
0
 /**
  * Shows the data formatted for the list view
  *
  * @param   string  $data      elements data
  * @param   object  &$thisRow  all the data in the lists current row
  *
  * @return  string	formatted value
  */
 public function renderListData($data, &$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;
                 }
             }
         }
     } else {
         // $$$ hugh - $data may already be JSON encoded, so we don't want to double-encode.
         if (!FabrikWorker::isJSON($data)) {
             $labeldata = (array) $data;
         } else {
             // $$$ hugh - yeah, I know, kinda silly to decode right before we encode,
             // should really refactor so encoding goes in this if/else structure!
             $labeldata = (array) json_decode($data);
         }
         foreach ($labeldata as &$l) {
             $l = $this->getLabelForValue($l, $l);
         }
     }
     $data = json_encode($labeldata);
     // $$$ rob add links and icons done in parent::renderListData();
     return parent::renderListData($data, $thisRow);
 }