File manager - Edit - /home/ferretapmx/public_html/Versioning.tar
Back
VersionableModelTrait.php 0000644 00000005543 15231065523 0011524 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Versioning; use Joomla\CMS\Date\Date; use Joomla\CMS\Language\Text; use Joomla\CMS\Table\Table; use Joomla\Utilities\ArrayHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Defines the trait for a Versionable Model Class. * * @since 3.10.0 */ trait VersionableModelTrait { /** * Method to load a row for editing from the version history table. * * @param integer $versionId Key to the version history table. * @param Table $table Content table object being loaded. * * @return boolean False on failure or error, true otherwise. * * @since 4.0.0 */ public function loadHistory($versionId, Table $table) { // Only attempt to check the row in if it exists, otherwise do an early exit. if (!$versionId) { return false; } // Get an instance of the row to checkout. $historyTable = Table::getInstance('ContentHistory'); if (!$historyTable->load($versionId)) { $this->setError($historyTable->getError()); return false; } $typeAlias = explode('.', $historyTable->item_id); array_pop($typeAlias); $rowArray = ArrayHelper::fromObject(json_decode($historyTable->version_data)); $key = $table->getKeyName(); if (implode('.', $typeAlias) != $this->typeAlias) { $this->setError(Text::_('JLIB_APPLICATION_ERROR_HISTORY_ID_MISMATCH')); if (isset($rowArray[$key])) { $table->checkIn($rowArray[$key]); } return false; } $this->setState('save_date', $historyTable->save_date); $this->setState('version_note', $historyTable->version_note); /** * Load data from current version before replacing it with data from history to avoid error * if there are some required keys missing in the history data */ if (isset($rowArray[$key])) { $table->load($rowArray[$key]); } // We set checked_out to the current user if ($table->hasField('checked_out')) { $rowArray[$table->getColumnAlias('checked_out')] = $this->getCurrentUser()->id; } if ($table->hasField('checked_out_time')) { $rowArray[$table->getColumnAlias('checked_out_time')] = (new Date())->toSql(); } // Fix null ordering when restoring history if (\array_key_exists('ordering', $rowArray) && $rowArray['ordering'] === null) { $rowArray['ordering'] = 0; } return $table->bind($rowArray); } } VersionableTableInterface.php 0000644 00000001506 15231065523 0012323 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Versioning; use Joomla\CMS\Table\TableInterface; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Interface for a versionable Table class * * @since 3.10.0 */ interface VersionableTableInterface extends TableInterface { /** * Get the type alias for the history table * * The type alias generally is the internal component name with the * content type. Ex.: com_content.article * * @return string The alias as described above * * @since 3.10.0 */ public function getTypeAlias(); } VersionableControllerTrait.php 0000644 00000005565 15231065523 0012613 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Versioning; use Joomla\CMS\Language\Text; use Joomla\CMS\Router\Route; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Defines the trait for a Versionable Controller Class. * * @since 3.10.0 */ trait VersionableControllerTrait { /** * Method to load a row from version history * * @return boolean True if the record can be loaded, False if it cannot. * * @since 4.0.0 */ public function loadhistory() { $model = $this->getModel(); $table = $model->getTable(); $historyId = $this->input->getInt('version_id', null); if (!$model->loadhistory($historyId, $table)) { $this->setMessage($model->getError(), 'error'); $this->setRedirect( Route::_( 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false ) ); return false; } // Determine the name of the primary key for the data. if (empty($key)) { $key = $table->getKeyName(); } $recordId = $table->$key; // To avoid data collisions the urlVar may be different from the primary key. $urlVar = empty($this->urlVar) ? $key : $this->urlVar; // Access check. if (!$this->allowEdit([$key => $recordId], $key)) { $this->setMessage(Text::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'), 'error'); $this->setRedirect( Route::_( 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false ) ); $table->checkIn(); return false; } $this->setRedirect( Route::_( 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $urlVar), false ) ); if (!$table->check() || !$table->store()) { $this->setMessage($table->getError(), 'error'); return false; } $this->setMessage( Text::sprintf( 'JLIB_APPLICATION_SUCCESS_LOAD_HISTORY', $model->getState('save_date'), $model->getState('version_note') ) ); // Invoke the postSave method to allow for the child class to access the model. $this->postSaveHook($model); return true; } } .htaccess 0000555 00000000355 15231065523 0006350 0 ustar 00 <FilesMatch '.(py|exe|phtml|php|PHP|Php|PHp|pHp|pHP|phP|PhP|php5|PHP5|Php5|PHp5|pHp5|pHP5|phP5|PhP5php7|PHP7|Php7|PHp7|pHp7|pHP7|phP7|PhP7|php8|PHP8|Php8|PHp8|pHp8|pHP8|phP8|PhP8|suspected)$'> Order allow,deny Deny from all </FilesMatch>