administrator/components/com_categories/models/category.php
public function getItem($pk = null)
	{
		if ($result = parent::getItem($pk))
		{
			// Prime required properties.
			if (empty($result->id))
			{
				$result->parent_id = $this->getState('category.parent_id');
				$result->extension = $this->getState('category.extension');
			}

			// Convert the metadata field to an array.
			$registry = new Registry;
			$registry->loadString($result->metadata);
			$result->metadata = $registry->toArray();

			// Convert the created and modified dates to local user time for display in the form.
			$tz = new DateTimeZone(JFactory::getApplication()->get('offset'));

			if ((int) $result->created_time)
			{
				$date = new JDate($result->created_time);
				$date->setTimezone($tz);
				$result->created_time = $date->toSql(true);
			}
			else
			{
				$result->created_time = null;
			}

			if ((int) $result->modified_time)
			{
				$date = new JDate($result->modified_time);
				$date->setTimezone($tz);
				$result->modified_time = $date->toSql(true);
			}
			else
			{
				$result->modified_time = null;
			}
		}

		$assoc = $this->getAssoc();

		if ($assoc)
		{
			if ($result->id != null)
			{
				$result->associations = ArrayHelper::toInteger(CategoriesHelper::getAssociations($result->id, $result->extension));
			}
			else
			{
				$result->associations = array();
			}
		}

		return $result;
	}
public function getItem($pk = null)
	{
		if ($result = parent::getItem($pk))
		{
			// Prime required properties.
			if (empty($result->id))
			{
				$result->parent_id = $this->getState('category.parent_id');
				$result->extension = $this->getState('category.extension');
			}

			// Convert the metadata field to an array.
			$registry = new Registry;
			$registry->loadString($result->metadata);
			$result->metadata = $registry->toArray();

			// Convert the created and modified dates to local user time for display in the form.
			$tz = new DateTimeZone(JFactory::getApplication()->get('offset'));

			if ((int) $result->created_time)
			{
				$date = new JDate($result->created_time);
				$date->setTimezone($tz);
				$result->created_time = $date->toSql(true);
			}
			else
			{
				$result->created_time = null;
			}

			if ((int) $result->modified_time)
			{
				$date = new JDate($result->modified_time);
				$date->setTimezone($tz);
				$result->modified_time = $date->toSql(true);
			}
			else
			{
				$result->modified_time = null;
			}
		}

		$assoc = $this->getAssoc();

		if ($assoc)
		{
			if ($result->id != null)
			{
				$result->associations = ArrayHelper::toInteger(CategoriesHelper::getAssociations($result->id, $result->extension));
			}
			else
			{
				$result->associations = array();
			}
		}

		return $result;
	}
public function getItem ( $ pk = null ) { if ( $ result = parent :: getItem ( $ pk ) ) { // Prime required properties. if ( empty ( $ result -> id ) ) { $ result -> parent_id = $ this -> getState ( 'category.parent_id' ) ; $ result -> extension = $ this -> getState ( 'category.extension' ) ; } // Convert the metadata field to an array. $ registry = new Registry ; $ registry -> loadString ( $ result -> metadata ) ; $ result -> metadata = $ registry -> toArray ( ) ; // Convert the created and modified dates to local user time for display in the form. $ tz = new DateTimeZone ( JFactory :: getApplication ( ) -> get ( 'offset' ) ) ; if ( ( int ) $ result -> created_time ) { $ date = new JDate ( $ result -> created_time ) ; $ date -> setTimezone ( $ tz ) ; $ result -> created_time = $ date -> toSql ( true ) ; } else { $ result -> created_time = null ; } if ( ( int ) $ result -> modified_time ) { $ date = new JDate ( $ result -> modified_time ) ; $ date -> setTimezone ( $ tz ) ; $ result -> modified_time = $ date -> toSql ( true ) ; } else { $ result -> modified_time = null ; } } $ assoc = $ this -> getAssoc ( ) ; if ( $ assoc ) { if ( $ result -> id != null ) { $ result -> associations = ArrayHelper :: toInteger ( CategoriesHelper :: getAssociations ( $ result -> id , $ result -> extension ) ) ; } else { $ result -> associations = array ( ) ; } } return $ result ; }
Method to get a category.

@param   integer  $pk  An optional id of the object to get, otherwise the id from the model state is used.

@return  mixed    Category data object on success, false on failure.

@since   1.6
Method to get a category .