diff --git a/e107_core/shortcodes/batch/news_shortcodes.php b/e107_core/shortcodes/batch/news_shortcodes.php index 0ae766c76..86a1bf131 100644 --- a/e107_core/shortcodes/batch/news_shortcodes.php +++ b/e107_core/shortcodes/batch/news_shortcodes.php @@ -593,36 +593,54 @@ class news_shortcodes extends e_shortcode return "".$category_name.""; } - 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) { diff --git a/e107_tests/tests/unit/e_parse_shortcodeTest.php b/e107_tests/tests/unit/e_parse_shortcodeTest.php index 3ff1e9462..c2431808d 100644 --- a/e107_tests/tests/unit/e_parse_shortcodeTest.php +++ b/e107_tests/tests/unit/e_parse_shortcodeTest.php @@ -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',