Skip to content

Commit

Permalink
Merge branch '4.0-dev' into 4.0-dev-com-contenthistory-null-date
Browse files Browse the repository at this point in the history
  • Loading branch information
richard67 committed Oct 26, 2019
2 parents 0fd6efe + eaac415 commit e494e80
Show file tree
Hide file tree
Showing 79 changed files with 1,354 additions and 289 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function getCsvData($data): Generator
$disabledText = Text::_('COM_ACTIONLOGS_DISABLED');

// Header row
yield ['Id', 'Message', 'Date', 'Extension', 'User', 'Ip'];
yield ['Id', 'Action', 'Extension', 'Date', 'Name', 'IP Address'];

foreach ($data as $log)
{
Expand All @@ -71,8 +71,8 @@ public static function getCsvData($data): Generator
yield array(
'id' => $log->id,
'message' => self::escapeCsvFormula(strip_tags(static::getHumanReadableLogMessage($log, false))),
'date' => (new Date($log->log_date, new \DateTimeZone('UTC')))->format('Y-m-d H:i:s T'),
'extension' => self::escapeCsvFormula(Text::_($extension)),
'date' => (new Date($log->log_date, new \DateTimeZone('UTC')))->format('Y-m-d H:i:s T'),
'name' => self::escapeCsvFormula($log->name),
'ip_address' => self::escapeCsvFormula($log->ip_address === 'COM_ACTIONLOGS_DISABLED' ? $disabledText : $log->ip_address)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
<option value="a.extension DESC">COM_ACTIONLOGS_EXTENSION_DESC</option>
<option value="a.log_date ASC">JDATE_ASC</option>
<option value="a.log_date DESC">JDATE_DESC</option>
<option value="a.user_id ASC">COM_ACTIONLOGS_NAME_ASC</option>
<option value="a.user_id DESC">COM_ACTIONLOGS_NAME_DESC</option>
<option value="a.user_id ASC">JGLOBAL_NAME_ASC</option>
<option value="a.user_id DESC">JGLOBAL_NAME_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE `#__content_frontpage` ADD COLUMN `featured_up` datetime;
ALTER TABLE `#__content_frontpage` ADD COLUMN `featured_down` datetime;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE `#__content_types`
SET `field_mappings` = REPLACE(`field_mappings`,'"core_created_time":"registerdate"','"core_created_time":"registerDate"')
WHERE `type_alias` = 'com_users.user';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "#__content_frontpage" ADD COLUMN "featured_up" timestamp without time zone;
ALTER TABLE "#__content_frontpage" ADD COLUMN "featured_down" timestamp without time zone;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE "#__content_types"
SET "field_mappings" = REPLACE("field_mappings",'"core_created_time":"registerdate"','"core_created_time":"registerDate"')
WHERE "type_alias" = 'com_users.user';
4 changes: 2 additions & 2 deletions administrator/components/com_banners/forms/filter_banners.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.name ASC">COM_BANNERS_HEADING_NAME_ASC</option>
<option value="a.name DESC">COM_BANNERS_HEADING_NAME_DESC</option>
<option value="a.name ASC">JGLOBAL_NAME_ASC</option>
<option value="a.name DESC">JGLOBAL_NAME_DEC</option>
<option value="category_title ASC">JCATEGORY_ASC</option>
<option value="category_title DESC">JCATEGORY_DESC</option>
<option value="a.sticky ASC">COM_BANNERS_HEADING_STICKY_ASC</option>
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_banners/forms/filter_tracks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
default="b.name ASC"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="b.name ASC">COM_BANNERS_HEADING_NAME_ASC</option>
<option value="b.name DESC">COM_BANNERS_HEADING_NAME_DESC</option>
<option value="b.name ASC">JGLOBAL_NAME_ASC</option>
<option value="b.name DESC">JGLOBAL_NAME_DESC</option>
<option value="cl.name ASC">COM_BANNERS_HEADING_CLIENT_ASC</option>
<option value="cl.name DESC">COM_BANNERS_HEADING_CLIENT_DESC</option>
<option value="a.track_type ASC">COM_BANNERS_HEADING_TYPE_ASC</option>
Expand Down
30 changes: 24 additions & 6 deletions administrator/components/com_content/Model/ArticleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ public function getForm($data = array(), $loadData = true)
{
// Disable fields for display.
$form->setFieldAttribute('featured', 'disabled', 'true');
$form->setFieldAttribute('featured_up', 'disabled', 'true');
$form->setFieldAttribute('featured_down', 'disabled', 'true');
$form->setFieldAttribute('ordering', 'disabled', 'true');
$form->setFieldAttribute('publish_up', 'disabled', 'true');
$form->setFieldAttribute('publish_down', 'disabled', 'true');
Expand All @@ -641,6 +643,8 @@ public function getForm($data = array(), $loadData = true)
// Disable fields while saving.
// The controller has already verified this is an article you can edit.
$form->setFieldAttribute('featured', 'filter', 'unset');
$form->setFieldAttribute('featured_up', 'filter', 'unset');
$form->setFieldAttribute('featured_down', 'filter', 'unset');
$form->setFieldAttribute('ordering', 'filter', 'unset');
$form->setFieldAttribute('publish_up', 'filter', 'unset');
$form->setFieldAttribute('publish_down', 'filter', 'unset');
Expand Down Expand Up @@ -943,7 +947,7 @@ public function save($data)
{
if (isset($data['featured']))
{
$this->featured($this->getState($this->getName() . '.id'), $data['featured']);
$this->featured($this->getState($this->getName() . '.id'), $data['featured'], $data['featured_up'], $data['featured_down']);
}

// Let's check if we have workflow association (perhaps something went wrong before)
Expand Down Expand Up @@ -997,12 +1001,14 @@ public function save($data)
/**
* Method to toggle the featured setting of articles.
*
* @param array $pks The ids of the items to toggle.
* @param integer $value The value to toggle to.
* @param array $pks The ids of the items to toggle.
* @param integer $value The value to toggle to.
* @param string|Date $featuredUp The date which item featured up.
* @param string|Date $featuredDown The date which item featured down.
*
* @return boolean True on success.
*/
public function featured($pks, $value = 0)
public function featured($pks, $value = 0, $featuredUp = null, $featuredDown = null)
{
// Sanitize the ids.
$pks = (array) $pks;
Expand Down Expand Up @@ -1048,6 +1054,18 @@ public function featured($pks, $value = 0)

$oldFeatured = $db->loadColumn();

// Update old featured articles
if (count($oldFeatured))
{
$query = $db->getQuery(true)
->update($db->quoteName('#__content_frontpage'))
->set('featured_up = ' . (empty($featuredUp) ? 'NULL' : $db->quote($featuredUp)))
->set('featured_down = ' . (empty($featuredDown) ? 'NULL' : $db->quote($featuredDown)))
->where('content_id IN (' . implode(',', $oldFeatured) . ')');
$db->setQuery($query);
$db->execute();
}

// We diff the arrays to get a list of the articles that are newly featured
$newFeatured = array_diff($pks, $oldFeatured);

Expand All @@ -1056,12 +1074,12 @@ public function featured($pks, $value = 0)

foreach ($newFeatured as $pk)
{
$tuples[] = $pk . ', 0';
$tuples[] = implode(',', [$pk, 0, (empty($featuredUp) ? 'NULL' : $db->quote($featuredUp)), (empty($featuredDown) ? 'NULL' : $db->quote($featuredDown))]);
}

if (count($tuples))
{
$columns = array('content_id', 'ordering');
$columns = array('content_id', 'ordering', 'featured_up', 'featured_down');
$query = $db->getQuery(true)
->insert($db->quoteName('#__content_frontpage'))
->columns($db->quoteName($columns))
Expand Down
10 changes: 8 additions & 2 deletions administrator/components/com_content/Model/ArticlesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function __construct($config = array())
'created_by_alias', 'a.created_by_alias',
'ordering', 'a.ordering',
'featured', 'a.featured',
'featured_up', 'fp.featured_up',
'featured_down', 'fp.featured_down',
'language', 'a.language',
'hits', 'a.hits',
'publish_up', 'a.publish_up',
Expand Down Expand Up @@ -206,8 +208,8 @@ protected function getListQuery()
$this->getState(
'list.select',
'a.id, a.asset_id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid' .
', a.state, a.access, a.created, a.created_by, a.created_by_alias, a.modified, a.ordering, a.featured, a.language, a.hits' .
', a.publish_up, a.publish_down, a.introtext, a.note'
', a.state, a.access, a.created, a.created_by, a.created_by_alias, a.modified, a.ordering, a.featured, fp.featured_up, fp.featured_down' .
', a.language, a.hits, a.publish_up, a.publish_down, a.introtext, a.note'
)
);
$query->from('#__content AS a');
Expand All @@ -216,6 +218,10 @@ protected function getListQuery()
$query->select('l.title AS language_title, l.image AS language_image')
->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');

// Join over the front page table.
$query->select('fp.ordering')
->join('LEFT', '#__content_frontpage AS fp ON fp.content_id = a.id');

// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
Expand Down
6 changes: 4 additions & 2 deletions administrator/components/com_content/Model/FeaturedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public function __construct($config = array())
'created_by_alias', 'a.created_by_alias',
'ordering', 'a.ordering',
'featured', 'a.featured',
'featured_up', 'fp.featured_up',
'featured_down', 'fp.featured_down',
'language', 'a.language',
'hits', 'a.hits',
'publish_up', 'a.publish_up',
Expand Down Expand Up @@ -88,7 +90,7 @@ protected function getListQuery()
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.state, a.access, a.created, a.hits,' .
'a.created_by, a.featured, a.language, a.created_by_alias, a.publish_up, a.publish_down, a.note'
'a.created_by, a.featured, fp.featured_up, fp.featured_down, a.language, a.created_by_alias, a.publish_up, a.publish_down, a.note'
)
);
$query->from('#__content AS a');
Expand All @@ -97,7 +99,7 @@ protected function getListQuery()
$query->select('l.title AS language_title, l.image AS language_image')
->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');

// Join over the content table.
// Join over the front page table.
$query->select('fp.ordering')
->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id');

Expand Down
22 changes: 22 additions & 0 deletions administrator/components/com_content/forms/article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,28 @@
<option value="1">JYES</option>
</field>

<field
name="featured_up"
type="calendar"
label="COM_CONTENT_FIELD_FEATURED_UP_LABEL"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
showon="featured:1"
/>

<field
name="featured_down"
type="calendar"
label="COM_CONTENT_FIELD_FEATURED_DOWN_LABEL"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
showon="featured:1"
/>

<field
name="rules"
type="rules"
Expand Down
17 changes: 10 additions & 7 deletions administrator/components/com_content/tmpl/articles/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\Button\ActionButton;
use Joomla\CMS\Button\FeaturedButton;
use Joomla\CMS\Button\PublishedButton;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
Expand Down Expand Up @@ -80,11 +80,6 @@

$assoc = Associations::isEnabled();

// Configure featured button renderer.
$featuredButton = (new ActionButton(['tip_title' => 'JGLOBAL_TOGGLE_FEATURED']))
->addState(0, 'articles.featured', 'unfeatured', 'COM_CONTENT_UNFEATURED')
->addState(1, 'articles.unfeatured', 'featured', 'COM_CONTENT_FEATURED');

HTMLHelper::_('script', 'com_content/admin-articles-workflow-buttons.js', ['relative' => true, 'version' => 'auto']);
?>

Expand Down Expand Up @@ -228,7 +223,15 @@
<?php endif; ?>
</td>
<td class="text-center d-none d-md-table-cell">
<?php echo $featuredButton->render($item->featured, $i, ['disabled' => !$canChange]); ?>
<?php

$options = [
'disabled' => !$canChange
];

echo (new FeaturedButton)
->render($item->featured, $i, $options, $item->featured_up, $item->featured_down);
?>
</td>
<td class="article-status">
<div class="d-flex">
Expand Down
16 changes: 10 additions & 6 deletions administrator/components/com_content/tmpl/featured/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\Button\ActionButton;
use Joomla\CMS\Button\FeaturedButton;
use Joomla\CMS\Button\PublishedButton;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
Expand Down Expand Up @@ -66,10 +66,6 @@
// @todo mode the script to a file
$this->document->addScriptDeclaration($js);

$featuredButton = (new ActionButton(['tip_title' => 'JGLOBAL_TOGGLE_FEATURED']))
->addState(0, 'articles.featured', 'unfeatured', 'COM_CONTENT_UNFEATURED')
->addState(1, 'articles.unfeatured', 'featured', 'COM_CONTENT_FEATURED');

HTMLHelper::_('script', 'com_content/admin-articles-workflow-buttons.js', ['relative' => true, 'version' => 'auto']);

?>
Expand Down Expand Up @@ -211,7 +207,15 @@
<?php endif; ?>
</td>
<td class="text-center">
<?php echo $featuredButton->render($item->featured, $i, ['disabled' => !$canChange]); ?>
<?php

$options = [
'disabled' => !$canChange
];

echo (new FeaturedButton)
->render($item->featured, $i, $options, $item->featured_up, $item->featured_down);
?>
</td>
<td class="article-status">
<div class="d-flex">
Expand Down

0 comments on commit e494e80

Please sign in to comment.