1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 22:27:34 +02:00

Show activation start date instead of post date if set

This commit is contained in:
bugrain
2009-12-03 20:47:46 +00:00
parent 940a681267
commit 31525e6321

View File

@@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt) * Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: news_shortcodes.php,v 1.31 2009-10-23 18:14:42 secretr Exp $ * $Id: news_shortcodes.php,v 1.32 2009-12-03 20:46:39 bugrain Exp $
* *
* News shortcode batch * News shortcode batch
*/ */
@@ -111,12 +111,12 @@ class news_shortcodes
{ {
return ''; return '';
} }
if (vartrue($pref['multilanguage'])) if (vartrue($pref['multilanguage']))
{ // Can have multilanguage news table, monlingual comment table. If the comment table is multilingual, it'll only count entries in the current language { // Can have multilanguage news table, monlingual comment table. If the comment table is multilingual, it'll only count entries in the current language
$news_item['news_comment_total'] = $sql->db_Count("comments", "(*)", "WHERE comment_item_id='".$news_item['news_id']."' AND comment_type='0' "); $news_item['news_comment_total'] = $sql->db_Count("comments", "(*)", "WHERE comment_item_id='".$news_item['news_id']."' AND comment_type='0' ");
} }
//XXX - ??? - another query? We should cache it in news table. //XXX - ??? - another query? We should cache it in news table.
if ($pref['comments_icon'] && $news_item['news_comment_total']) if ($pref['comments_icon'] && $news_item['news_comment_total'])
{ {
@@ -166,24 +166,25 @@ class news_shortcodes
function sc_newsdate($parm) function sc_newsdate($parm)
{ {
$date = ($this->news_item['news_start'] > 0) ? $this->news_item['news_start'] : $this->news_item['news_datestamp'];
$con = new convert; $con = new convert;
if($parm == '') if($parm == '')
{ {
return $con->convert_date($this->news_item['news_datestamp'], 'long'); return $con->convert_date($date, 'long');
} }
switch($parm) switch($parm)
{ {
case 'long': case 'long':
return $con->convert_date($this->news_item['news_datestamp'], 'long'); return $con->convert_date($date, 'long');
break; break;
case 'short': case 'short':
return $con->convert_date($this->news_item['news_datestamp'], 'short'); return $con->convert_date($date, 'short');
break; break;
case 'forum': case 'forum':
return $con->convert_date($this->news_item['news_datestamp'], 'forum'); return $con->convert_date($date, 'forum');
break; break;
default : default :
return date($parm, $this->news_item['news_datestamp']); return date($parm, $date);
break; break;
} }
} }
@@ -242,7 +243,7 @@ class news_shortcodes
function sc_extended($parm) function sc_extended($parm)
{ {
if ($this->news_item['news_extended'] && ($this->param['current_action'] != 'extend' || $parm == 'force')) if ($this->news_item['news_extended'] && ($this->param['current_action'] != 'extend' || $parm == 'force'))
{ {
if (defined('PRE_EXTENDEDSTRING')) if (defined('PRE_EXTENDEDSTRING'))
@@ -295,11 +296,11 @@ class news_shortcodes
case 'src': case 'src':
return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail'] ? e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail'] : ''); return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail'] ? e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail'] : '');
break; break;
case 'tag': case 'tag':
return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail'] ? "<img class='news_image' src='".e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail']."' alt='' style='".$this->param['thumbnail']."' />" : ''); return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail'] ? "<img class='news_image' src='".e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail']."' alt='' style='".$this->param['thumbnail']."' />" : '');
break; break;
default: default:
return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail']) ? "<a href='".$this->e107->url->getUrl('core:news', 'main', "action=extend&id={$this->news_item['news_id']}&catid={$this->news_item['news_category']}&sef={$this->news_item['news_rewrite_string']}")."'><img class='news_image' src='".e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail']."' alt='' style='".$this->param['thumbnail']."' /></a>" : ''; return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail']) ? "<a href='".$this->e107->url->getUrl('core:news', 'main', "action=extend&id={$this->news_item['news_id']}&catid={$this->news_item['news_category']}&sef={$this->news_item['news_rewrite_string']}")."'><img class='news_image' src='".e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail']."' alt='' style='".$this->param['thumbnail']."' /></a>" : '';
break; break;
@@ -313,11 +314,11 @@ class news_shortcodes
case 'src': case 'src':
return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail'] ? e_IMAGE_ABS.$this->news_item['news_thumbnail'] : ''); return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail'] ? e_IMAGE_ABS.$this->news_item['news_thumbnail'] : '');
break; break;
case 'tag': case 'tag':
return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail'] ? "<img class='news_image' src='".e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail']."' alt='' style='".$this->param['thumbnail']."' />" : ''); return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail'] ? "<img class='news_image' src='".e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail']."' alt='' style='".$this->param['thumbnail']."' />" : '');
break; break;
default: default:
return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail']) ? "<a href='".$this->e107->url->getUrl('core:news', 'main', "action=extend&id={$this->news_item['news_id']}&catid={$this->news_item['news_category']}&sef={$this->news_item['news_rewrite_string']}")."'><img class='news_image' src='".e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail']."' alt='' style='".$this->param['thumbnail']."' /></a>" : ''; return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail']) ? "<a href='".$this->e107->url->getUrl('core:news', 'main', "action=extend&id={$this->news_item['news_id']}&catid={$this->news_item['news_category']}&sef={$this->news_item['news_rewrite_string']}")."'><img class='news_image' src='".e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail']."' alt='' style='".$this->param['thumbnail']."' /></a>" : '';
break; break;
@@ -352,26 +353,26 @@ class news_shortcodes
{ {
$category_icon = e_IMAGE_ABS.'icons/'.$category_icon; $category_icon = e_IMAGE_ABS.'icons/'.$category_icon;
} }
//TODO - remove inline styles //TODO - remove inline styles
if($this->param['caticon'] == ''){$this->param['caticon'] = 'border:0px';} if($this->param['caticon'] == ''){$this->param['caticon'] = 'border:0px';}
switch($parm) switch($parm)
{ {
case 'src': case 'src':
return $category_icon; return $category_icon;
break; break;
case 'tag': case 'tag':
return "<img class='news_image' src='{$category_icon}' alt='' style='".$this->param['caticon']."' />"; return "<img class='news_image' src='{$category_icon}' alt='' style='".$this->param['caticon']."' />";
break; break;
default: default:
return "<a href='".$this->e107->url->getUrl('core:news', 'main', "action=list&id={$this->news_item['news_category']}&sef={$this->news_item['news_category_rewrite_string']}")."'><img style='".$this->param['caticon']."' src='".$category_icon."' alt='' /></a>"; return "<a href='".$this->e107->url->getUrl('core:news', 'main', "action=list&id={$this->news_item['news_category']}&sef={$this->news_item['news_category_rewrite_string']}")."'><img style='".$this->param['caticon']."' src='".$category_icon."' alt='' /></a>";
break; break;
} }
} }
/** /**
* Example usage: {NEWSITEM_SCHOOK=mysc_name|my_var1=val1&myvar2=myval2} * Example usage: {NEWSITEM_SCHOOK=mysc_name|my_var1=val1&myvar2=myval2}
* will fire {MYSC_NAME=news_id=1&my_var1=val1&myvar2=myval2} * will fire {MYSC_NAME=news_id=1&my_var1=val1&myvar2=myval2}
@@ -380,7 +381,7 @@ class news_shortcodes
* $newsdata = e107::getRegistry('core/news/schook_data'); * $newsdata = e107::getRegistry('core/news/schook_data');
* //returns array('data' => (array) $current_news_data, 'params' => array() $current_params) * //returns array('data' => (array) $current_news_data, 'params' => array() $current_params)
* </code> * </code>
* *
* @param string $parm * @param string $parm
* @return string * @return string
*/ */