1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-24 16:31:48 +02:00

Closes #4978 - {NEWS_MODIFIED} shortcode added.

This commit is contained in:
Cameron
2023-02-11 09:09:16 -08:00
parent 6b828a9ac5
commit f5096ae47d
2 changed files with 39 additions and 20 deletions

View File

@@ -593,36 +593,54 @@ class news_shortcodes extends e_shortcode
return "<a ".$style." href='".e107::getUrl()->create('news/list/category', $category)."'>".$category_name."</a>";
}
function sc_news_date($parm=null)
private function formatDate($date, $parm)
{
$date = ($this->news_item['news_start'] > 0) ? $this->news_item['news_start'] : $this->news_item['news_datestamp'];
$con = e107::getDate();
$tp = e107::getParser();
$tp = e107::getParser();
if(empty($parm))
{
return $tp->toDate($date, 'long');
$ret = $tp->toDate($date, 'long');
}
switch($parm)
else
{
case 'long':
return $tp->toDate($date, 'long');
break;
case 'short':
return $tp->toDate($date, 'short');
break;
case 'forum':
return $con->convert_date($date, 'forum');
break;
default :
return $tp->toDate($date,$parm);
// return date($parm, $date);
break;
$ret = '';
switch($parm)
{
case 'long':
$ret = $tp->toDate($date, 'long');
break;
case 'short':
$ret = $tp->toDate($date, 'short');
break;
case 'forum':
$ret = $con->convert_date($date, 'forum');
break;
default :
$ret = $tp->toDate($date, $parm);
break;
}
}
return $ret;
}
function sc_news_date($parm=null)
{
$date = ($this->news_item['news_start'] > 0) ? $this->news_item['news_start'] : $this->news_item['news_datestamp'];
return $this->formatDate($date, $parm);
}
function sc_news_modified($parm=null)
{
return $this->formatDate($this->news_item['news_modified'], $parm);
}
function sc_news_author_avatar($parm=null)
{

View File

@@ -549,6 +549,7 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit
'news_meta_description' => 'Description for Facebook and search engines.',
'news_meta_robots' => '',
'news_datestamp' => '1454367600',
'news_modified' => '1654101979',
'news_author' => '1',
'news_category' => '1',
'news_allow_comments' => '0',