public function getItem($pk = null) { $pk = !empty($pk) ? $pk : (int) JFactory::getApplication()->input->getint('id'); $table = $this->getTable(); if ($pk > 0) { // Attempt to load the row. $return = $table->load($pk); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return false; } } // Convert to the JObject before adding other data. $properties = $table->getProperties(1); $item = JArrayHelper::toObject($properties, 'JObject'); if (property_exists($item, 'params')) { $registry = new Registry(); $registry->loadString($item->params); $item->params = $registry->toArray(); } return $item; }
/** * format - prune the registry based on xml config * * @param string XMLpath * @param Registry registry * * @return array */ public static function format($xmlFilePath, $uri, Registry $registry) { $xml = file_get_contents($xmlFilePath); $xmlParser = new XMLParser(); $params = $xmlParser->parse($xml, $uri, 'outputParam'); unset($xmlParser); $output = array(); if (count($params) < 1) { if (self::PARANOID_MODE) { error_log('XML is missing CherryPicker configs for ' . $uri); throw new XMLNodeNotConfiguredException('XML is missing CherryPicker configs for ' . $uri); } //not paranoid? ok - dump the whole registry to the user foreach ($registry->toArray() as $key => $value) { $output[self::trimNamespacing($key)] = $registry->{$key}; } return $output; } foreach ($params as $key) { self::formatValue($key, $output, $registry); } return $output; }
/** * Merge a Registry object into this one * * @param Registry $source Source Registry object to merge. [@note Framework typehints this param] * @param boolean $recursive True to support recursive merge the children values. * * @return Registry Return this object to support chaining. * * @since 1.0 */ public function merge($source, $recursive = false) { if (!$source instanceof Registry) { return false; } $data = $source->toArray(); $array = array(); foreach ($data as $k => $v) { if ($v !== null && $v !== '') { $array[$k] = $v; } } $this->bindData($this->data, $array, $recursive); return $this; }