/** * Return the value of a generic item * * Gets the value of a generic item. This implementation adds the field * feature to the TIP_Module::getItem() method. * * Getting an item performs some search operations with this priority: * * - Try to get the field in the current row throught getField(). * * - If the field is not found but the current view is not a TIP_Data_View * (that is, it is not a TIP_Data_View object), it scans the view stack * for the last view that was of TIP_Data_View type and checks if $id is * present as a field in the current row. * This because views others than TIP_Data_View are considered "weaks", * that is their values are not built from real data fields. * * - Summary value of the current view throught getSummary(). * * - Chain-up the parent method TIP_Module::getItem(). * * The first succesful search operation will stop the sequence. * * @param string $id The item id * @return mixed|null The value of the item or null if not found */ public function getItem($id) { if (!is_null($value = $this->getField($id))) { return $value; } if (isset($this->_view) && !$this->_view instanceof TIP_Data_View) { // Find the last TIP_Data_View $stack =& $this->_views; end($stack); do { prev($stack); $view_id = key($stack); } while (isset($view_id) && !$stack[$view_id] instanceof TIP_Data_View); if (isset($view_id) && !is_null($value = $stack[$view_id]->getField($id))) { return $value; } } $value = $this->getSummary($id); if (!is_null($value)) { return $value; } return parent::getItem($id); }
/** * Return the value of a generic item * * Gets the value of a generic item. This implementation adds form * specific features to the TIP_Module::getItem() method, such as * the ability to get information from the current element or from * the current section. * * @param string $id The item id * @return mixed|null The value of the item or null if not found */ public function getItem($id) { if (isset($this->_element_view) && !is_null($value = $this->_element_view->getField($id))) { return $value; } if (isset($this->_section_view) && !is_null($value = $this->_section_view->getField($id))) { return $value; } return parent::getItem($id); }