Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Table\TableInterface;
use Joomla\CMS\Versioning\VersionableModelInterface;
use Joomla\CMS\Versioning\VersionableModelTrait;
use Joomla\Component\Categories\Administrator\Helper\CategoriesHelper;
use Joomla\Database\ParameterType;
Expand All @@ -30,7 +29,7 @@
*
* @since 1.6
*/
class BannerModel extends AdminModel implements VersionableModelInterface
class BannerModel extends AdminModel
{
use VersionableModelTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Versioning\VersionableModelInterface;
use Joomla\CMS\Versioning\VersionableModelTrait;

// phpcs:disable PSR1.Files.SideEffects
Expand All @@ -25,7 +24,7 @@
*
* @since 1.6
*/
class ClientModel extends AdminModel implements VersionableModelInterface
class ClientModel extends AdminModel
{
use VersionableModelTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Table\Category;
use Joomla\CMS\UCM\UCMType;
use Joomla\CMS\Versioning\VersionableModelInterface;
use Joomla\CMS\Versioning\VersionableModelTrait;
use Joomla\Component\Categories\Administrator\Helper\CategoriesHelper;
use Joomla\Database\ParameterType;
Expand All @@ -44,7 +43,7 @@
*
* @since 1.6
*/
class CategoryModel extends AdminModel implements VersionableModelInterface
class CategoryModel extends AdminModel
{
use VersionableModelTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\String\PunycodeHelper;
use Joomla\CMS\Versioning\VersionableModelInterface;
use Joomla\CMS\Versioning\VersionableModelTrait;
use Joomla\Component\Categories\Administrator\Helper\CategoriesHelper;
use Joomla\Database\ParameterType;
Expand All @@ -34,7 +33,7 @@
*
* @since 1.6
*/
class ContactModel extends AdminModel implements VersionableModelInterface
class ContactModel extends AdminModel
{
use VersionableModelTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use Joomla\CMS\Table\TableInterface;
use Joomla\CMS\Tag\TaggableTableInterface;
use Joomla\CMS\UCM\UCMType;
use Joomla\CMS\Versioning\VersionableModelInterface;
use Joomla\CMS\Versioning\VersionableModelTrait;
use Joomla\CMS\Workflow\Workflow;
use Joomla\Component\Categories\Administrator\Helper\CategoriesHelper;
Expand All @@ -50,7 +49,7 @@
* @since 1.6
*/

class ArticleModel extends AdminModel implements WorkflowModelInterface, VersionableModelInterface
class ArticleModel extends AdminModel implements WorkflowModelInterface
{
use WorkflowBehaviorTrait;
use VersionableModelTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use Joomla\Filesystem\Path;
use Joomla\Utilities\ArrayHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -76,18 +75,8 @@ public static function decodeFields($jsonString)

if (\is_object($object)) {
foreach ($object as $name => $value) {
if (!\is_null($value)) {
if (\is_object($value)) {
$object->$name = ArrayHelper::fromObject($value);
continue;
}

if (str_starts_with($value, '{')) {
$object->$name = json_decode($value);
continue;
}

$object->$name = $value;
if (!\is_null($value) && $subObject = json_decode($value)) {
$object->$name = $subObject;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@

use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
use Joomla\Utilities\ArrayHelper;

/** @var \Joomla\Component\Contenthistory\Administrator\View\Compare\HtmlView $this */

Session::checkToken('get') or die(Text::_('JINVALID_TOKEN'));

$version2 = $this->items[0];
$version1 = $this->items[1];
$object1 = ArrayHelper::fromObject($version1->data);
$object2 = ArrayHelper::fromObject($version2->data);
$object1 = $version1->data;
$object2 = $version2->data;

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->getDocument()->getWebAssetManager();
Expand All @@ -44,70 +43,40 @@
</tr>
</thead>
<tbody>
<?php foreach ($object1 as $name => $value1) : ?>
<?php if (isset($value1['value']) && isset($object2[$name]['value'])) : ?>
<?php $value2 = $object2[$name]['value']; ?>
<?php
if (is_array($value1)) : ?>
<?php if (is_array($value1['value'])) : ?>
<tr>
<td colspan="4">
<strong><?php echo $value1['label']; ?></strong>
</td>
</tr>
<?php $keys = array_keys($value1['value']); ?>
<?php if (isset($value2['value']) && is_array($value2['value'])) :?>
<?php $keys = array_merge(array_keys($value1['value']), array_keys($value2['value'])); ?>
<?php endif; ?>
<?php foreach ($keys as $key) : ?>
<?php foreach ($object1 as $name => $value) : ?>
<?php if (isset($value->value) && isset($object2->$name->value) && $value->value != $object2->$name->value) : ?>
<?php if (is_object($value->value)) : ?>
<tr>
<td colspan="4">
<strong><?php echo $value->label; ?></strong>
</td>
</tr>
<?php foreach ($value->value as $subName => $subValue) : ?>
<?php $newSubValue = $object2->$name->value->$subName->value ?? ''; ?>
<?php if ($subValue->value || $newSubValue) : ?>
<?php if ($subValue->value != $newSubValue) : ?>
<tr>
<td></td>
<td class="original">
<?php if (isset($value1['value'][$key])) : ?>
<?php $currentvalue1 = $value1['value'][$key]; ?>
<?php if (is_array($value1['value'][$key])) : ?>
<?php $currentvalue1 = implode(' | ', $value1['value'][$key]); ?>
<?php echo htmlspecialchars($key . ': ' . $currentvalue1, ENT_COMPAT, 'UTF-8'); ?>
<?php else : ?>
<?php echo htmlspecialchars($key . ': ' . $currentvalue1, ENT_COMPAT, 'UTF-8'); ?>
<?php endif;?>
<?php else : ?>
<?php echo Text::_('JUNDEFINED');?>
<?php endif; ?>
</td>
<td class="changed">
<?php if (isset($value2['value'][$key])) : ?>
<?php $currentvalue2 = $value2['value'][$key]; ?>
<?php if (is_array($value2['value'][$key])) : ?>
<?php $currentvalue2 = implode(' | ', $value1['value'][$key]); ?>
<?php echo htmlspecialchars($key . ': ' . $currentvalue2, ENT_COMPAT, 'UTF-8'); ?>
<?php else : ?>
<?php echo htmlspecialchars($key . ': ' . $currentvalue2, ENT_COMPAT, 'UTF-8'); ?>
<?php endif;?>
<?php else : ?>
<?php echo Text::_('JUNDEFINED');?>
<?php endif; ?>
<th scope="row"><em>&nbsp;&nbsp;<?php echo $subValue->label; ?></em></th>
<td class="original"><?php echo htmlspecialchars($subValue->value, ENT_COMPAT, 'UTF-8'); ?></td>
<td class="changed" ><?php echo htmlspecialchars($newSubValue, ENT_COMPAT, 'UTF-8'); ?></td>
<td class="diff">&nbsp;</td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr>
<th scope="row">
<?php
echo $value1['label']; ?>
</th>
<?php $currentvalue1 = is_array($value1['value']) ? json_encode($value1['value']) : $value1['value']; ?>
<td class="original"><?php
echo htmlspecialchars($currentvalue1); ?></td>
<?php $currentvalue2 = is_array($value2) ? json_encode($value2) : $value2; ?>
<td class="changed"><?php
echo htmlspecialchars($currentvalue2, ENT_COMPAT, 'UTF-8'); ?></td>
<td class="diff">&nbsp;</td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php else : ?>
<tr>
<th scope="row">
<?php echo $value->label; ?>
</th>
<td class="original"><?php echo htmlspecialchars($value->value); ?></td>
<?php $object2->$name->value = is_object($object2->$name->value) ? json_encode($object2->$name->value) : $object2->$name->value; ?>
<td class="changed"><?php echo htmlspecialchars($object2->$name->value, ENT_COMPAT, 'UTF-8'); ?></td>
<td class="diff">&nbsp;</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,14 @@
<?php $subValue->value = (\is_object($subValue->value) || \is_array($subValue->value)) ? \json_encode($subValue->value, \JSON_UNESCAPED_UNICODE) : $subValue->value; ?>
<tr>
<th scope="row"><em>&nbsp;&nbsp;<?php echo $subValue->label; ?></em></th>
<td>
<?php if (\is_array($subValue->value)) : ?>
<?php echo json_decode($subValue->value); ?>
<?php else : ?>
<?php echo $subValue->value; ?>
<?php endif; ?>
</td>
<td><?php echo $subValue->value; ?></td>
</tr>
<?php endif; ?>

<?php endforeach; ?>
<?php else : ?>
<tr>
<th scope="row"><?php echo $value->label; ?></th>
<td>
<?php if (\is_array($value->value)) : ?>
<?php echo json_encode($value->value); ?>
<?php else : ?>
<?php echo $value->value; ?>
<?php endif; ?>
</td>
<td><?php echo $value->value; ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\LanguageHelper;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Versioning\VersionableModelInterface;
use Joomla\CMS\Versioning\VersionableModelTrait;
use Joomla\Component\Categories\Administrator\Helper\CategoriesHelper;
use Joomla\Registry\Registry;
Expand All @@ -31,7 +30,7 @@
*
* @since 1.6
*/
class NewsfeedModel extends AdminModel implements VersionableModelInterface
class NewsfeedModel extends AdminModel
{
use VersionableModelTrait;

Expand Down
3 changes: 1 addition & 2 deletions administrator/components/com_tags/src/Model/TagModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Versioning\VersionableModelInterface;
use Joomla\CMS\Versioning\VersionableModelTrait;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
Expand All @@ -29,7 +28,7 @@
*
* @since 3.1
*/
class TagModel extends AdminModel implements VersionableModelInterface
class TagModel extends AdminModel
{
use VersionableModelTrait;

Expand Down
3 changes: 1 addition & 2 deletions administrator/components/com_users/src/Model/NoteModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Versioning\VersionableModelInterface;
use Joomla\CMS\Versioning\VersionableModelTrait;

// phpcs:disable PSR1.Files.SideEffects
Expand All @@ -25,7 +24,7 @@
*
* @since 2.5
*/
class NoteModel extends AdminModel implements VersionableModelInterface
class NoteModel extends AdminModel
{
use VersionableModelTrait;

Expand Down
1 change: 0 additions & 1 deletion administrator/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ JFIELD_PLG_SEARCH_SEARCHLIMIT_LABEL="Search Limit"
JFIELD_PUBLISHED_DESC="Set publication status."
JFIELD_READMORE_DESC="Add a custom text instead of Read More."
JFIELD_READMORE_LABEL="Read More Text"
JFIELD_RULES_LABEL="Group Permissions"
JFIELD_SPACER_LABEL="<span style=\"width:auto\"><hr></span>"
JFIELD_TITLE_DESC="Title"
JFIELD_VERSION_HISTORY_DESC="This button allows you to open a window to view older versions of this item."
Expand Down
36 changes: 0 additions & 36 deletions libraries/src/MVC/Model/AdminModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
use Joomla\CMS\Table\TableInterface;
use Joomla\CMS\Tag\TaggableTableInterface;
use Joomla\CMS\UCM\UCMType;
use Joomla\CMS\Versioning\VersionableModelInterface;
use Joomla\CMS\Versioning\Versioning;
use Joomla\Database\ParameterType;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
Expand Down Expand Up @@ -1461,19 +1459,6 @@ public function save($data)
}
}

if ($this instanceof VersionableModelInterface) {
// Merge table data and data so that we write all data to the history
$tableData = ArrayHelper::fromObject($table);

$historyData = array_merge($tableData, $data);

// We have to set the key for new items, would be always 0 otherwise
$historyData[$key] = $this->getState($this->getName() . '.id');


$this->saveHistory($historyData, $context);
}

if ($app->getInput()->get('task') == 'editAssociations') {
return $this->redirectToAssociations($data);
}
Expand Down Expand Up @@ -1761,25 +1746,4 @@ protected function redirectToAssociations($data)

return true;
}

/**
* Method to save the history.
*
* @param array $data The form data.
* @param string $context The model context.
*
* @return boolean True on success, False on error.
*
* @since 6.0.0
*/
protected function saveHistory(array $data, string $context)
{
$id = $this->getState($this->getName() . '.id');

$versionNote = \array_key_exists('version_note', $data) ? $data['version_note'] : '';

$result = Versioning::store($context, $id, ArrayHelper::toObject($data), $versionNote);

return $result;
}
}
Loading
Loading