diff --git a/libraries/classmap.php b/libraries/classmap.php index b433e29d0b720..2b1237ec7a7cb 100644 --- a/libraries/classmap.php +++ b/libraries/classmap.php @@ -137,3 +137,8 @@ JLoader::registerAlias('JSchemaChangeitemMysql', '\\Joomla\\CMS\\Schema\\ChangeItem\\MysqlChangeItem', '4.0'); JLoader::registerAlias('JSchemaChangeitemPostgresql', '\\Joomla\\CMS\\Schema\\ChangeItem\\PostgresqlChangeItem', '4.0'); JLoader::registerAlias('JSchemaChangeitemSqlsrv', '\\Joomla\\CMS\\Schema\\ChangeItem\\SqlsrvChangeItem', '4.0'); + +JLoader::registerAlias('JUcm', '\\Joomla\\CMS\\Ucm\\Ucm', '4.0'); +JLoader::registerAlias('JUcmBase', '\\Joomla\\CMS\\Ucm\\UcmBase', '4.0'); +JLoader::registerAlias('JUcmContent', '\\Joomla\\CMS\\Ucm\\UcmContent', '4.0'); +JLoader::registerAlias('JUcmType', '\\Joomla\\CMS\\Ucm\\UcmType', '4.0'); diff --git a/libraries/cms/ucm/ucm.php b/libraries/cms/ucm/ucm.php deleted file mode 100644 index 583d4f4d5a11e..0000000000000 --- a/libraries/cms/ucm/ucm.php +++ /dev/null @@ -1,19 +0,0 @@ -input; + $input = \JFactory::getApplication()->input; $this->alias = isset($alias) ? $alias : $input->get('option') . '.' . $input->get('view'); $this->type = isset($type) ? $type : $this->getType(); @@ -52,20 +57,20 @@ public function __construct($alias = null, JUcmType $type = null) /** * Store data to the appropriate table * - * @param array $data Data to be stored - * @param JTableInterface $table JTable Object - * @param string $primaryKey The primary key name + * @param array $data Data to be stored + * @param TableInterface $table Table Object + * @param string $primaryKey The primary key name * * @return boolean True on success * * @since 3.1 * @throws Exception */ - protected function store($data, JTableInterface $table = null, $primaryKey = null) + protected function store($data, TableInterface $table = null, $primaryKey = null) { if (!$table) { - $table = JTable::getInstance('Ucm'); + $table = Table::getInstance('Ucm'); } $ucmId = isset($data['ucm_id']) ? $data['ucm_id'] : null; @@ -80,18 +85,18 @@ protected function store($data, JTableInterface $table = null, $primaryKey = nul { $table->bind($data); } - catch (RuntimeException $e) + catch (\RuntimeException $e) { - throw new Exception($e->getMessage(), 500, $e); + throw new \Exception($e->getMessage(), 500, $e); } try { $table->store(); } - catch (RuntimeException $e) + catch (\RuntimeException $e) { - throw new Exception($e->getMessage(), 500, $e); + throw new \Exception($e->getMessage(), 500, $e); } return true; @@ -100,7 +105,7 @@ protected function store($data, JTableInterface $table = null, $primaryKey = nul /** * Get the UCM Content type. * - * @return JUcmType The UCM content type + * @return UcmType The UCM content type * * @since 3.1 */ @@ -108,7 +113,7 @@ public function getType() { if (!$this->type) { - $this->type = new JUcmType($this->alias); + $this->type = new UcmType($this->alias); } return $this->type; @@ -117,21 +122,21 @@ public function getType() /** * Method to map the base ucm fields * - * @param array $original Data array - * @param JUcmType $type UCM Content Type + * @param array $original Data array + * @param UcmType $type UCM Content Type * * @return array Data array of UCM mappings * * @since 3.1 */ - public function mapBase($original, JUcmType $type = null) + public function mapBase($original, UcmType $type = null) { $type = $type ?: $this->type; $data = array( 'ucm_type_id' => $type->id, 'ucm_item_id' => $original[$type->primary_key], - 'ucm_language_id' => JHelperContent::getLanguageId($original['language']), + 'ucm_language_id' => ContentHelper::getLanguageId($original['language']), ); return $data; diff --git a/libraries/cms/ucm/content.php b/libraries/src/Joomla/CMS/Ucm/UcmContent.php similarity index 68% rename from libraries/cms/ucm/content.php rename to libraries/src/Joomla/CMS/Ucm/UcmContent.php index fc118cd735a2f..0c61eee071f37 100644 --- a/libraries/cms/ucm/content.php +++ b/libraries/src/Joomla/CMS/Ucm/UcmContent.php @@ -1,25 +1,30 @@ type->type->table); - $this->table = JTable::getInstance($tableObject->special->type, $tableObject->special->prefix, $tableObject->special->config); + $this->table = Table::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 + * @param array $original The original data to be saved + * @param UcmType $type The UCM Type object * * @return boolean true * * @since 3.1 */ - public function save($original = null, JUcmType $type = null) + public function save($original = null, UcmType $type = null) { $type = $type ?: $this->type; $ucmData = $original ? $this->mapData($original, $type) : $this->ucmData; @@ -87,16 +92,16 @@ public function save($original = null, JUcmType $type = null) /** * 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 + * @param mixed $pk The string/array of id's to delete + * @param UcmType $type The content type object * * @return boolean True if success * * @since 3.1 */ - public function delete($pk, JUcmType $type = null) + public function delete($pk, UcmType $type = null) { - $db = JFactory::getDbo(); + $db = \JFactory::getDbo(); $type = $type ?: $this->type; if (is_array($pk)) @@ -118,14 +123,14 @@ public function delete($pk, JUcmType $type = null) /** * Map the original content to the Core Content fields * - * @param array $original The original data array - * @param JUcmType $type Type object for this data + * @param array $original The original data array + * @param UcmType $type Type object for this data * * @return array $ucmData The mapped UCM data * * @since 3.1 */ - public function mapData($original, JUcmType $type = null) + public function mapData($original, UcmType $type = null) { $contentType = isset($type) ? $type : $this->type; @@ -172,17 +177,17 @@ public function mapData($original, JUcmType $type = null) /** * Store data to the appropriate table * - * @param array $data Data to be stored - * @param JTableInterface $table JTable Object - * @param boolean $primaryKey Flag that is true for data that are using #__ucm_content as their primary table + * @param array $data Data to be stored + * @param TableInterface $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 * * @since 3.1 */ - protected function store($data, JTableInterface $table = null, $primaryKey = null) + protected function store($data, TableInterface $table = null, $primaryKey = null) { - $table = $table ?: JTable::getInstance('Corecontent'); + $table = $table ?: Table::getInstance('Corecontent'); $typeId = $this->getType()->type->type_id; $primaryKey = $primaryKey ?: $this->getPrimaryKey($typeId, $data['core_content_item_id']); @@ -193,7 +198,7 @@ protected function store($data, JTableInterface $table = null, $primaryKey = nul $baseData = array(); $baseData['ucm_type_id'] = $typeId; $baseData['ucm_item_id'] = $data['core_content_item_id']; - $baseData['ucm_language_id'] = JHelperContent::getLanguageId($data['core_language']); + $baseData['ucm_language_id'] = ContentHelper::getLanguageId($data['core_language']); if (parent::store($baseData)) { @@ -216,7 +221,7 @@ protected function store($data, JTableInterface $table = null, $primaryKey = nul */ public function getPrimaryKey($typeId, $contentItemId) { - $db = JFactory::getDbo(); + $db = \JFactory::getDbo(); $queryccid = $db->getQuery(true); $queryccid->select($db->quoteName('ucm_id')) ->from($db->quoteName('#__ucm_base')) diff --git a/libraries/cms/ucm/type.php b/libraries/src/Joomla/CMS/Ucm/UcmType.php similarity index 88% rename from libraries/cms/ucm/type.php rename to libraries/src/Joomla/CMS/Ucm/UcmType.php index d4ff99e665e73..9f35fec62cbe3 100644 --- a/libraries/cms/ucm/type.php +++ b/libraries/src/Joomla/CMS/Ucm/UcmType.php @@ -1,14 +1,17 @@ db = $database ?: JFactory::getDbo(); - $app = $application ?: JFactory::getApplication(); + $this->db = $database ?: \JFactory::getDbo(); + $app = $application ?: \JFactory::getApplication(); // Make the best guess we can in the absence of information. $this->alias = $alias ?: $app->input->get('option') . '.' . $app->input->get('view');