File manager - Edit - /home/opticamezl/www/newok/UCM.zip
Back
PK F�\��]_ UCMContent.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\UCM; use Joomla\CMS\Factory; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Table\Table; use Joomla\CMS\Table\TableInterface; use Joomla\Database\ParameterType; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Base class for implementing UCM * * @since 3.1 */ class UCMContent extends UCMBase { /** * The related table object * * @var Table * @since 3.1 */ protected $table; /** * The UCM data array * * @var array[] * @since 3.1 */ public $ucmData; /** * Instantiate UCMContent. * * @param TableInterface $table The table object * @param string $alias The type alias * @param UCMType $type The type object * * @since 3.1 */ public function __construct(TableInterface $table = null, $alias = null, UCMType $type = null) { parent::__construct($alias, $type); if ($table) { $this->table = $table; } else { $tableObject = json_decode($this->type->type->table); $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 UCMType $type The UCM Type object * * @return boolean true * * @since 3.1 */ public function save($original = null, UCMType $type = null) { $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'])) { $table = $this->table; $this->store($ucmData['special'], $table, ''); } return true; } /** * Delete content from the Core Content table * * @param mixed $pk Array or comma-separated string of ids to delete * @param UCMType $type The content type object * * @return boolean True if success * * @since 3.1 */ public function delete($pk, UCMType $type = null) { $db = Factory::getDbo(); $type = $type ?: $this->type; if (!\is_array($pk)) { $pk = explode(',', $pk); } $query = $db->getQuery(true) ->delete($db->quoteName('#__ucm_content')) ->where($db->quoteName('core_type_id') . ' = :typeId') ->whereIn($db->quoteName('core_content_item_id'), $pk) ->bind(':typeId', $type->type_id, ParameterType::INTEGER); $db->setQuery($query); $db->execute(); return true; } /** * Map the original content to the Core Content fields * * @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, UCMType $type = null) { $contentType = $type ?: $this->type; $fields = json_decode($contentType->type->field_mappings); $ucmData = []; $common = \is_object($fields->common) ? $fields->common : $fields->common[0]; foreach ($common as $i => $field) { if ($field && $field !== 'null' && \array_key_exists($field, $original)) { $ucmData['common'][$i] = $original[$field]; } } if (\array_key_exists('special', $ucmData)) { $special = \is_object($fields->special) ? $fields->special : $fields->special[0]; foreach ($special as $i => $field) { if ($field && $field !== 'null' && \array_key_exists($field, $original)) { $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']; } $this->ucmData = $ucmData; return $this->ucmData; } /** * Store data to the appropriate table * * @param array $data Data to be stored * @param TableInterface $table Table 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, TableInterface $table = null, $primaryKey = null) { $table = $table ?: Table::getInstance('Corecontent'); $typeId = $this->getType()->type->type_id; $primaryKey = $primaryKey ?: $this->getPrimaryKey($typeId, $data['core_content_item_id']); if (!$primaryKey) { // Store the core UCM mappings $baseData = []; $baseData['ucm_type_id'] = $typeId; $baseData['ucm_item_id'] = $data['core_content_item_id']; $baseData['ucm_language_id'] = ContentHelper::getLanguageId($data['core_language']); 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 integer $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 * * @since 3.1 */ public function getPrimaryKey($typeId, $contentItemId) { $db = Factory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('ucm_id')) ->from($db->quoteName('#__ucm_base')) ->where( [ $db->quoteName('ucm_item_id') . ' = :itemId', $db->quoteName('ucm_type_id') . ' = :typeId', ] ) ->bind(':itemId', $contentItemId, ParameterType::INTEGER) ->bind(':typeId', $typeId, ParameterType::INTEGER); $db->setQuery($query); return $db->loadResult(); } } PK F�\�(�� � UCM.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\UCM; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Interface to handle UCM * * @since 3.1 */ interface UCM { } PK F�\�{�֜ � UCMType.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\UCM; use Joomla\Application\AbstractApplication; use Joomla\CMS\Factory; use Joomla\Database\DatabaseDriver; use Joomla\Database\ParameterType; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * UCM Class for handling content types * * @property-read string $core_content_id * @property-read string $core_type_alias * @property-read string $core_title * @property-read string $core_alias * @property-read string $core_body * @property-read string $core_state * * @property-read string $core_checked_out_time * @property-read string $core_checked_out_user_id * @property-read string $core_access * @property-read string $core_params * @property-read string $core_featured * @property-read string $core_metadata * @property-read string $core_created_user_id * @property-read string $core_created_by_alias * @property-read string $core_created_time * @property-read string $core_modified_user_id * @property-read string $core_modified_time * @property-read string $core_language * @property-read string $core_publish_up * @property-read string $core_publish_down * @property-read string $core_content_item_id * @property-read string $asset_id * @property-read string $core_images * @property-read string $core_urls * @property-read string $core_hits * @property-read string $core_version * @property-read string $core_ordering * @property-read string $core_metakey * @property-read string $core_metadesc * @property-read string $core_catid * @property-read string $core_typeid * * @since 3.1 */ class UCMType implements UCM { /** * The UCM Type * * @var UCMType * @since 3.1 */ public $type; /** * The Database object * * @var DatabaseDriver * @since 3.1 */ protected $db; /** * The alias for the content type * * @var string * @since 3.1 */ protected $alias; /** * Class constructor * * @param string $alias The alias for the item * @param DatabaseDriver $database The database object * @param AbstractApplication $application The application object * * @since 3.1 */ public function __construct($alias = null, DatabaseDriver $database = null, AbstractApplication $application = null) { $this->db = $database ?: Factory::getDbo(); $app = $application ?: Factory::getApplication(); // Make the best guess we can in the absence of information. $this->alias = $alias ?: $app->getInput()->get('option') . '.' . $app->getInput()->get('view'); $this->type = $this->getTypeByAlias($this->alias); } /** * Get the Content Type * * @param integer $pk The primary key of the alias type * * @return object The UCM Type data * * @since 3.1 */ public function getType($pk = null) { if (!$pk) { return $this->getTypeByAlias($this->alias); } $query = $this->db->getQuery(true) ->select($this->db->quoteName('ct') . '.*') ->from($this->db->quoteName('#__content_types', 'ct')) ->where($this->db->quoteName('ct.type_id') . ' = :pk') ->bind(':pk', $pk, ParameterType::INTEGER); $this->db->setQuery($query); return $this->db->loadObject(); } /** * Get the Content Type from the alias * * @param string $typeAlias The alias for the type * * @return object The UCM Type data * * @since 3.2 */ public function getTypeByAlias($typeAlias = null) { $query = $this->db->getQuery(true) ->select($this->db->quoteName('ct') . '.*') ->from($this->db->quoteName('#__content_types', 'ct')) ->where($this->db->quoteName('ct.type_alias') . ' = :alias') ->bind(':alias', $typeAlias); $this->db->setQuery($query); return $this->db->loadObject(); } /** * Get the Content Type from the table class name * * @param string $tableName The table for the type * * @return mixed The UCM Type data if found, false if no match is found * * @since 3.2 */ public function getTypeByTable($tableName) { $query = $this->db->getQuery(true) ->select($this->db->quoteName('ct') . '.*') ->from($this->db->quoteName('#__content_types', 'ct')); $this->db->setQuery($query); $types = $this->db->loadObjectList(); foreach ($types as $type) { $tableFromType = json_decode($type->table); $tableNameFromType = $tableFromType->special->prefix . $tableFromType->special->type; if ($tableNameFromType === $tableName) { return $type; } } return false; } /** * Retrieves the UCM type ID * * @param string $alias The string of the type alias * * @return mixed The ID of the requested type or false if type is not found * * @since 3.1 */ public function getTypeId($alias = null) { if (!$alias) { $alias = $this->alias; } $query = $this->db->getQuery(true) ->select($this->db->quoteName('ct.type_id')) ->from($this->db->quoteName('#__content_types', 'ct')) ->where($this->db->quoteName('ct.type_alias') . ' = :alias') ->bind(':alias', $alias); $this->db->setQuery($query); $id = $this->db->loadResult(); if (!$id) { return false; } return $id; } /** * Method to expand the field mapping * * @param boolean $assoc True to return an associative array. * * @return mixed Array or object with field mappings. Defaults to object. * * @since 3.2 */ public function fieldmapExpand($assoc = false) { if (!empty($this->type->field_mappings)) { return $this->fieldmap = json_decode($this->type->field_mappings, $assoc); } else { return false; } } /** * Magic method to get the name of the field mapped to a ucm field (core_something). * * @param string $ucmField The name of the field in JTableCorecontent * * @return string The name mapped to the $ucmField for a given content type * * @since 3.2 */ public function __get($ucmField) { if (!isset($this->fieldmap)) { $this->fieldmapExpand(false); } return $this->fieldmap->common->$ucmField ?? null; } } PK F�\�x*�� � UCMBase.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\UCM; use Joomla\CMS\Factory; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Table\Table; use Joomla\CMS\Table\TableInterface; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Base class for implementing UCM * * @since 3.1 */ class UCMBase implements UCM { /** * The UCM type object * * @var UCMType * @since 3.1 */ protected $type; /** * The alias for the content table * * @var string * @since 3.1 */ protected $alias; /** * Instantiate the UCMBase. * * @param string $alias The alias string * @param UCMType $type The type object * * @since 3.1 */ public function __construct($alias = null, UCMType $type = null) { // Setup dependencies. $input = Factory::getApplication()->getInput(); $this->alias = $alias ?: $input->get('option') . '.' . $input->get('view'); $this->type = $type ?: $this->getType(); } /** * Store data to the appropriate table * * @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, TableInterface $table = null, $primaryKey = null) { if (!$table) { $table = Table::getInstance('Ucm'); } $ucmId = $data['ucm_id'] ?? null; $primaryKey = $primaryKey ?: $ucmId; if (isset($primaryKey)) { $table->load($primaryKey); } try { $table->bind($data); } catch (\RuntimeException $e) { throw new \Exception($e->getMessage(), 500, $e); } try { $table->store(); } catch (\RuntimeException $e) { throw new \Exception($e->getMessage(), 500, $e); } return true; } /** * Get the UCM Content type. * * @return UCMType The UCM content type * * @since 3.1 */ public function getType() { if (!$this->type) { $this->type = new UCMType($this->alias); } return $this->type; } /** * Method to map the base ucm fields * * @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, UCMType $type = null) { $type = $type ?: $this->type; $data = [ 'ucm_type_id' => $type->id, 'ucm_item_id' => $original[$type->primary_key], 'ucm_language_id' => ContentHelper::getLanguageId($original['language']), ]; return $data; } } PK F�\��]_ UCMContent.phpnu �[��� PK F�\�(�� � V UCM.phpnu �[��� PK F�\�{�֜ � 3 UCMType.phpnu �[��� PK F�\�x*�� � 9 UCMBase.phpnu �[��� PK + �E
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0.05 |
proxy
|
phpinfo
|
Settings