Skip to content
Permalink
Browse files

[4.0] Show changelog - GSoC Expand Extensions Manager #17536 redo (#2…

…4026)

Thanks to @NunoLopes96 for the majority of the work on this!
  • Loading branch information
roland-d authored and wilsonge committed Mar 25, 2019
1 parent 9ab2321 commit 48af582d80983c005fa9118f47760baa38b6f33b
@@ -0,0 +1,2 @@
ALTER TABLE `#__extensions` ADD COLUMN `changelogurl` text AFTER `element`;
ALTER TABLE `#__updates` ADD COLUMN `changelogurl` text AFTER `infourl`;
@@ -0,0 +1,2 @@
ALTER TABLE "#__extensions" ADD COLUMN "changelogurl" text;
ALTER TABLE "#__updates" ADD COLUMN "changelogurl" text;
@@ -11,11 +11,14 @@

defined('_JEXEC') or die;

use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\Component\Installer\Administrator\Model\ManageModel;
use Joomla\Utilities\ArrayHelper;

/**
@@ -49,6 +52,8 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu
*
* @return void
*
* @throws \Exception
*
* @since 1.6
*/
public function publish()
@@ -67,7 +72,7 @@ public function publish()
}
else
{
/* @var \Joomla\Component\Installer\Administrator\Model\ManageModel $model */
/** @var ManageModel $model */
$model = $this->getModel('manage');

// Change the state of the records.
@@ -98,14 +103,16 @@ public function publish()
*
* @return void
*
* @throws \Exception
*
* @since 1.5
*/
public function remove()
{
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));

/* @var \Joomla\Component\Installer\Administrator\Model\ManageModel $model */
/** @var ManageModel $model */
$model = $this->getModel('manage');

$eid = $this->input->get('cid', array(), 'array');
@@ -128,12 +135,37 @@ public function refresh()
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));

/* @var \Joomla\Component\Installer\Administrator\Model\ManageModel $model */
/** @var ManageModel $model */
$model = $this->getModel('manage');

$uid = $this->input->get('cid', array(), 'array');
$uid = ArrayHelper::toInteger($uid, array());
$model->refresh($uid);
$this->setRedirect(Route::_('index.php?option=com_installer&view=manage', false));
}

/**
* Load the changelog for a given extension.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function loadChangelog()
{
/** @var ManageModel $model */
$model = $this->getModel('manage');

$eid = $this->input->get('eid', 0, 'int');
$source = $this->input->get('source', 'manage', 'string');

if (!$eid)
{
return;
}

$output = $model->loadChangelog($eid, $source);

echo (new JsonResponse($output));
}
}
@@ -11,11 +11,14 @@

defined('_JEXEC') or die;

use Joomla\CMS\Changelog\Changelog;
use Joomla\CMS\Extension\ExtensionHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Installer\Installer;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Table\Extension;
use Joomla\Component\Templates\Administrator\Table\StyleTable;
use Joomla\Database\DatabaseQuery;

@@ -64,6 +67,8 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu
*
* @return void
*
* @throws \Exception
*
* @since 1.6
*/
protected function populateState($ordering = 'name', $direction = 'asc')
@@ -94,6 +99,8 @@ protected function populateState($ordering = 'name', $direction = 'asc')
*
* @return boolean True on success
*
* @throws \Exception
*
* @since 1.5
*/
public function publish(&$eid = array(), $value = 1)
@@ -117,7 +124,7 @@ public function publish(&$eid = array(), $value = 1)
}

// Get a table object for the extension type
$table = new \Joomla\CMS\Table\Extension($this->getDbo());
$table = new Extension($this->getDbo());

// Enable the extension in the table and store it in the database
foreach ($eid as $i => $id)
@@ -182,7 +189,7 @@ public function refresh($eid)

// Get an installer object for the extension type
$installer = Installer::getInstance();
$result = 0;
$result = 0;

// Uninstall the chosen extensions
foreach ($eid as $id)
@@ -200,6 +207,8 @@ public function refresh($eid)
*
* @return boolean True on success
*
* @throws \Exception
*
* @since 1.5
*/
public function remove($eid = array())
@@ -222,10 +231,10 @@ public function remove($eid = array())

// Get an installer object for the extension type
$installer = Installer::getInstance();
$row = new \Joomla\CMS\Table\Extension($this->getDbo());
$row = new \Joomla\CMS\Table\Extension($this->getDbo());

// Uninstall the chosen extensions
$msgs = array();
$msgs = array();
$result = false;

foreach ($eid as $id)
@@ -235,7 +244,7 @@ public function remove($eid = array())
$result = false;

$langstring = 'COM_INSTALLER_TYPE_TYPE_' . strtoupper($row->type);
$rowtype = Text::_($langstring);
$rowtype = Text::_($langstring);

if (strpos($rowtype, $langstring) !== false)
{
@@ -376,4 +385,79 @@ protected function getListQuery()

return $query;
}

/**
* Load the changelog details for a given extension.
*
* @param integer $eid The extension ID
* @param string $source The view the changelog is for, this is used to determine which version number to show
*
* @return string The output to show in the modal.
*
* @since __DEPLOY_VERSION__
*/
public function loadChangelog($eid, $source)
{
// Get the changelog URL
$db = $this->getDbo();
$query = $db->getQuery(true)
->select(
$db->quoteName(
array(
'extensions.element',
'extensions.type',
'extensions.changelogurl',
'extensions.manifest_cache',
'extensions.client_id'
)
)
)
->select($db->quoteName('updates.version', 'updateVersion'))
->from($db->quoteName('#__extensions', 'extensions'))
->leftJoin(
$db->quoteName('#__updates', 'updates')
. ' ON ' . $db->quoteName('updates.extension_id') . ' = ' . $db->quoteName('extensions.extension_id')
)
->where($db->quoteName('extensions.extension_id') . ' = ' . (int) $eid);
$db->setQuery($query);

$extensions = $db->loadObjectList();
$this->translate($extensions);
$extension = array_shift($extensions);

if (!$extension->changelogurl)
{
return '';
}

$changelog = new Changelog;
$changelog->setVersion($source === 'manage' ? $extension->version : $extension->updateVersion);
$changelog->loadFromXml($extension->changelogurl);

// Read all the entries
$entries = array(
'security' => array(),
'fix' => array(),
'addition' => array(),
'change' => array(),
'remove' => array(),
'language' => array(),
'note' => array()
);

array_walk(
$entries,
function (&$value, $name) use ($changelog) {
if ($field = $changelog->get($name))
{
$value = $changelog->get($name)->data;
}
}
);

$layout = new FileLayout('joomla.installer.changelog');
$output = $layout->render($entries);

return $output;
}
}
@@ -104,14 +104,34 @@
<?php echo $item->type_translated; ?>
</td>
<td class="d-none d-md-table-cell">
<?php echo @$item->version != '' ? $item->version : '&#160;'; ?>
<?php if ($item->version !== '') : ?>
<?php if ($item->changelogurl !== null) : ?>
<a href="#changelogModal" onclick="Joomla.loadChangelog(<?php echo $item->extension_id; ?>, 'manage'); return false;" data-toggle="modal">
<?php echo $item->version?>
</a>
<?php
echo HTMLHelper::_(
'bootstrap.renderModal',
'changelogModal',
array(
'title' => Text::sprintf('COM_INSTALLER_CHANGELOG_TITLE', $item->name, $item->version),
),
''
);
?>
<?php else : ?>
<?php echo $item->version; ?>
<?php endif; ?>
<?php else :
echo '&#160;';
endif; ?>
</td>
<td class="d-none d-md-table-cell">
<?php echo @$item->creationDate != '' ? $item->creationDate : '&#160;'; ?>
<?php echo isset($item->creationDate) && $item->creationDate !== '' ? $item->creationDate : '&#160;'; ?>
</td>
<td class="d-none d-md-table-cell">
<span class="editlinktip hasTooltip" title="<?php echo HTMLHelper::_('tooltipText', Text::_('COM_INSTALLER_AUTHOR_INFORMATION'), $item->author_info, 0); ?>">
<?php echo @$item->author != '' ? $item->author : '&#160;'; ?>
<?php echo isset($item->author) && $item->author !== '' ? $item->author : '&#160;'; ?>
</span>
</td>
<td class="d-none d-md-table-cell">
@@ -27,14 +27,13 @@
<?php if ($this->showMessage) : ?>
<?php echo $this->loadTemplate('message'); ?>
<?php endif; ?>

<?php if ($this->ftp) : ?>
<?php echo $this->loadTemplate('ftp'); ?>
<?php endif; ?>
<?php echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php if (empty($this->items)) : ?>
<div class="alert alert-info">
<?php echo JText::_('COM_INSTALLER_MSG_UPDATE_NOUPDATES'); ?>
<?php echo Text::_('COM_INSTALLER_MSG_UPDATE_NOUPDATES'); ?>
</div>
<?php else : ?>
<table class="table">
@@ -43,9 +42,9 @@
</caption>
<thead>
<tr>
<td style="width:1%" class="text-center">
<th style="width:1%" class="text-center">
<?php echo HTMLHelper::_('grid.checkall'); ?>
</td>
</th>
<th scope="col">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_INSTALLER_HEADING_NAME', 'u.name', $listDirn, $listOrder); ?>
</th>
@@ -61,8 +60,11 @@
<th scope="col">
<?php echo Text::_('COM_INSTALLER_NEW_VERSION'); ?>
</th>
<th scope="col" class="d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_INSTALLER_HEADING_FOLDER', 'folder_translated', $listDirn, $listOrder); ?>
<th scope="col">
<?php echo Text::_('COM_INSTALLER_CHANGELOG'); ?>
</th>
<th class="d-none d-md-table-cell">
<?php echo JHtml::_('searchtools.sort', 'COM_INSTALLER_HEADING_FOLDER', 'folder_translated', $listDirn, $listOrder); ?>
</th>
<th scope="col" class="d-none d-md-table-cell">
<?php echo Text::_('COM_INSTALLER_HEADING_INSTALLTYPE'); ?>
@@ -102,6 +104,28 @@
<td>
<span class="badge badge-success"><?php echo $item->version; ?></span>
</td>
<td class="hidden-sm-down text-center">
<?php if ($item->changelogurl !== null) : ?>
<a href="#changelogModal" class="btn btn-info btn-xs" onclick="Joomla.loadChangelog(<?php echo $item->extension_id; ?>, 'update'); return false;" data-toggle="modal">
<?php echo Text::_('COM_INSTALLER_CHANGELOG'); ?>
</a>
<?php
echo HTMLHelper::_(
'bootstrap.renderModal',
'changelogModal',
array(
'title' => Text::sprintf('COM_INSTALLER_CHANGELOG_TITLE', $item->name, $item->version),
),
''
);
?>
<?php else:?>
<span>
<?php echo Text::_('COM_INSTALLER_TYPE_NONAPPLICABLE')?>
</span>

<?php endif; ?>
</td>
<td class="d-none d-md-table-cell">
<?php echo $item->folder_translated; ?>
</td>
@@ -6,6 +6,15 @@
COM_INSTALLER="Installer"
COM_INSTALLER_AUTHOR_INFORMATION="Author Information"
COM_INSTALLER_CACHETIMEOUT_LABEL="Updates Caching (in hours)"
COM_INSTALLER_CHANGELOG="Changelog"
COM_INSTALLER_CHANGELOG_ADDITION="New Features"
COM_INSTALLER_CHANGELOG_CHANGE="Changes"
COM_INSTALLER_CHANGELOG_FIX="Bug Fixes"
COM_INSTALLER_CHANGELOG_LANGUAGE="Language"
COM_INSTALLER_CHANGELOG_NOTE="Notes"
COM_INSTALLER_CHANGELOG_REMOVE="Removed Features"
COM_INSTALLER_CHANGELOG_SECURITY="Security Fixes"
COM_INSTALLER_CHANGELOG_TITLE="Changelog - %s - %s"
COM_INSTALLER_CONFIGURATION="Installer: Options"
COM_INSTALLER_CONFIRM_UNINSTALL="Are you sure you want to uninstall? Confirming will permanently delete the selected item(s)!"
COM_INSTALLER_CURRENT_VERSION="Installed"

0 comments on commit 48af582

Please sign in to comment.
You can’t perform that action at this time.