CoreFiles by mySites.guru
compare.php78 lines, 2,799 bytes, from Joomla_4.0.0-alpha9-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha8
md5
54cb94828a79353b86b20fed14ba499f
sha1
f436c7f5a4dd2a431b592221cb76f2255ca6dc34
sha256
7915d2c7856baaadbeed71e8ef33fae82d892f144ba770ea02d4eca0e63780e3
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_contenthistory
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;

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

$version2 = $this->items[0];
$version1 = $this->items[1];
$object1  = $version1->data;
$object2  = $version2->data;

HTMLHelper::_('script', 'vendor/diff/diff.min.js', array('version' => 'auto', 'relative' => true));
HTMLHelper::_('script', 'com_contenthistory/admin-compare-compare.min.js', array('version' => 'auto', 'relative' => true));
?>
<fieldset>

	<h2 class="mb-3"><?php echo Text::sprintf('COM_CONTENTHISTORY_COMPARE_TITLE'); ?></h2>

	<table id="diff" class="table table-sm">
		<thead>
			<tr>
				<th style="width:25%"><?php echo Text::_('COM_CONTENTHISTORY_PREVIEW_FIELD'); ?></th>
				<th><?php echo Text::_('COM_CONTENTHISTORY_COMPARE_OLD'); ?></th>
				<th><?php echo Text::_('COM_CONTENTHISTORY_COMPARE_NEW'); ?></th>
				<th><?php echo Text::_('COM_CONTENTHISTORY_COMPARE_DIFF'); ?></th>
			</tr>
		</thead>
		<tbody>
		<?php foreach ($object1 as $name => $value) : ?>
			<?php if ($value->value != $object2->$name->value) : ?>
			<tr>
				<?php if (is_object($value->value)) : ?>
					<td>
						<strong><?php echo $value->label; ?></strong>
					</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<?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><em>&nbsp;&nbsp;<?php echo $subValue->label; ?></em></td>
									<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 endif; ?>
						<?php endif; ?>
					<?php endforeach; ?>
				<?php else : ?>
					<td>
						<strong><?php echo $value->label; ?></strong>
					</td>
					<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>
				<?php endif; ?>
			</tr>
		<?php endif; ?>
		<?php endforeach; ?>
		</tbody>
	</table>

</fieldset>

The same content is in 4 releases, Joomla 4.0.0-alpha7 to 4.0.0-alpha10. See them all, or every version of this file.