Source for file content.php
Documentation is available at content.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Base class for implementing UCM
* @package Joomla.Libraries
* The related table object
* The alias for the content table
* Instantiate JUcmContent.
* @param JTable $table The table object
* @param sring $alias The type alias
* @param JUcmType $type The type object
public function __construct(JTable $table =
null, $alias =
null, JUcmType $type =
null)
$this->alias = isset
($alias) ?
$alias :
$input->get('option') .
'.' .
$input->get('view');
$this->table =
JTable::getInstance($tableObject->special->type, $tableObject->special->prefix, $tableObject->special->config);
* Method to save the data
* @param array $original The original data to be saved
* @param JUcmType $type The UCM Type object
public function save($original =
null, JUcmType $type =
null)
$type =
$type ?
$type :
$this->type;
$ucmData =
$original ?
$this->mapData($original, $type) :
$this->ucmData;
// Store the Common fields
$this->store($ucmData['common']);
// Store the special fields
if (isset
($ucmData['special']))
$this->store($ucmData['special'], $table, '');
* Delete content from the Core Content table
* @param mixed $pk The string/array of id's to delete
* @param JUcmType $type The content type object
* @return boolean True if success
public function delete($pk, JUcmType $type =
null)
$type =
$type ?
$type :
$this->type;
$query =
$db->getQuery(true)
->delete('#__ucm_content')
->where($db->quoteName('core_type_id') .
' = ' . (int)
$type->type_id)
->where($db->quoteName('core_content_item_id') .
' IN (' .
$pk .
')');
* Map the original content to the Core Content fields
* @param array $original The original data array
* @param JUcmType $type Type object for this data
* @return object $ucmData The mapped UCM data
public function mapData($original, JUcmType $type =
null)
$contentType = isset
($type) ?
$type :
$this->type;
$fields =
json_decode($contentType->type->field_mappings);
$common =
(is_object($fields->common)) ?
$fields->common :
$fields->common[0];
foreach ($common as $i =>
$field)
$ucmData['common'][$i] =
$original[$field];
$special =
(is_object($fields->special)) ?
$fields->special :
$fields->special[0];
foreach ($special as $i =>
$field)
$ucmData['special'][$i] =
$original[$field];
$ucmData['common']['core_type_alias'] =
$contentType->type->type_alias;
$ucmData['common']['core_type_id'] =
$contentType->type->type_id;
if (isset
($ucmData['special']))
$ucmData['special']['ucm_id'] =
$ucmData['common']['ucm_id'];
* Store data to the appropriate table
* @param array $data Data to be stored
* @param JTable $table JTable Object
* @param boolean $primaryKey Flag that is true for data that are using #__ucm_content as their primary table
* @return Boolean true on success
protected function store($data, JTable $table =
null, $primaryKey =
null)
$typeId =
$this->getType()->type->type_id;
$primaryKey =
$primaryKey ?
$primaryKey :
$this->getPrimaryKey($typeId, $data['core_content_item_id']);
// Store the core UCM mappings
$baseData['ucm_type_id'] =
$typeId;
$baseData['ucm_item_id'] =
$data['core_content_item_id'];
if (parent::store($baseData))
$primaryKey =
$this->getPrimaryKey($typeId, $data['core_content_item_id']);
return parent::store($data, $table, $primaryKey);
* Get the value of the primary key from #__ucm_base
* @param string $typeId The ID for the type
* @param integer $contentItemId Value of the primary key in the legacy or secondary table
* @return integer The integer of the primary key
$queryccid =
$db->getQuery(true);
$queryccid->select($db->quoteName('ucm_id'))
->from($db->quoteName('#__ucm_base'))
$db->quoteName('ucm_item_id') .
' = ' .
$db->quote($contentItemId),
$db->quoteName('ucm_type_id') .
' = ' .
$db->quote($typeId)
$db->setQuery($queryccid);
$primaryKey =
$db->loadResult();
Documentation generated on Tue, 19 Nov 2013 14:56:49 +0100 by phpDocumentor 1.4.3