/** * get the value * * @param array $data * @param int $repeatCounter * @param array options * @return unknown */ function getValue($data, $repeatCounter = 0, $opts = array()) { //cludge for 2 scenarios if (array_key_exists('rowid', $data)) { //when validating the data on form submission $key = 'rowid'; } else { //when rendering the element to the form $key = '__pk_val'; } //empty(data) when you are saving a new record and this element is in a joined group // $$$ hugh - added !array_key_exists(), as ... well, rowid doesn't always exist in the query string // $$$ rob replaced ALL references to rowid with __pk_val as rowid doesnt exists in the data :O //$$$ rob //($this->_inRepeatGroup && $this->_inJoin && $this->_repeatGroupTotal == $repeatCounter) //is for saying that the last record in a repeated join group should be treated as if it was in a new form // $$$ rob - erm why on earth would i want to do that! ?? (see above!) - test case: // form with joined data - make record with on repeated group (containing this element) // edit record and the commented out if statement below meant the user dd reverted // to the current logged in user and not the previously selected one if (empty($data) || !array_key_exists($key, $data) || array_key_exists($key, $data) && empty($data[$key])) { //if (empty($data) || !array_key_exists($key, $data) || (array_key_exists($key, $data) && empty($data[$key])) || ($this->_inRepeatGroup && $this->_inJoin && $this->_repeatGroupTotal == $repeatCounter)) { //new record //$$$ rob huh - whats with this else statement - the code is the same for both??? // $$$ hugh - I was chasing a bug with user elements in joined data, but this bit was a blind alley // just forgot to get rid of it. /*if($this->_inRepeatGroup && $this->_inJoin && $this->_repeatGroupTotal == $repeatCounter && $this->_editable) { $user =& JFactory::getUser(); // $$$ hugh - need to actually set $this->default $element = $this->getElement(); $element->default = $user->get('id'); return $element->default; }else{ $user =& JFactory::getUser(); // $$$ hugh - need to actually set $this->default $element = $this->getElement(); $element->default = $user->get('id'); return $element->default; }*/ // $$$rob - if no search form data submitted for the search element then the default // selection was being applied instead // $$$ rob - added check on task to ensure that we are searching and not submitting a form // as otherwise not empty valdiation failed on user element if (JArrayHelper::getValue($opts, 'use_default', true) == false && !in_array(JRequest::getCmd('task'), array('processForm', 'view'))) { return ''; } else { return $this->getDefaultValue($data); } } $res = parent::getValue($data, $repeatCounter, $opts); return $res; }
/** * 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) { return parent::renderListData($data, $oAllRowsData); }
/** * 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->getGroup(); if (!$groupModel->isJoin() && $groupModel->canRepeat()) { $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); } $labeldata = array(); $aAllRowsData = JArrayHelper::fromObject($oAllRowsData); $repeatCounter = 0; $this->_resetCache(); foreach ($data as $d) { $opts = $this->_getOptionVals($aAllRowsData, $repeatCounter); $repeatCounter++; foreach ($opts as $opt) { if ($opt->value == $d) { $labeldata[] = $opt->text; break; } } } } else { $labeldata[] = $data; } //$data = implode(GROUPSPLITTER, $labeldata); $data = json_encode($labeldata); // $$$ rob add links and icons done in parent::renderListData(); return parent::renderListData($data, $oAllRowsData); }
/** * 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) { return parent::renderListData($data, $thisRow); }