Code: Select all
function get_new_articles_from_catid($template_default, $max_cnt_links=0, $cid=0, $dbcon) {
// find all new articles
$max_cnt_links = intval($max_cnt_links);
$limit = ($max_cnt_links) ? " LIMIT ".$max_cnt_links : "";
$sql = "SELECT article_id, article_title, article_cid, UNIX_TIMESTAMP(article_tstamp) AS article_date ".
"FROM ".DB_PREPEND."phpwcms_article WHERE ".
"article_cid='$cid' AND article_public=1 AND article_aktiv=1 AND article_deleted=0 AND ".
"article_begin < NOW() AND article_end > NOW() ".
"ORDER BY article_tstamp DESC".$limit.";";
// new articles list
$new_links = "";
$target = ($template_default["link_target"]) ? ' target="'.$template_default["link_target"].'"' : "";
if($result = mysql_query($sql, $dbcon)) {
$count_results = mysql_num_rows($result); $count = 0;
while ($row = mysql_fetch_row($result)) {
$count++;
if($template_default["link_length"] && strlen($row[1]) > $template_default["link_length"]) {
$article_title = substr($row[1], 0, $template_default["link_length"]).$template_default["cut_title_add"];
} else {
$article_title = $row[1];
}
if(trim($template_default["date_format"])) {
$article_title = international_date_format(
$template_default["date_language"],
$template_default["date_format"],
$row[3]).$article_title;
}
$new_links .= $template_default["link_before"].$template_default["link_symbol"];
$new_links .= '<a href="index.php?id='.$row[2].','.$row[0].',0,0,1,0"';
$new_links .= $target.">".html_specialchars($article_title)."</a>";
//try to remove possible unwanted after - if not enclosed before.link.after
if($new_links && !$template_default["link_before"] && $count < $count_results) {
$new_links .= $template_default["link_after"];
}
}
mysql_free_result($result);
}
//enclose whole
if($new_links) $new_links = $template_default["before"].$new_links.$template_default["after"];
return $new_links;
}
Code: Select all
if( ! ( strpos($content["all"],'{NEWCATID:')===false ) ) {
$content["all"] = preg_replace('/\{NEWCATID:(\d+):(\d+)\}/e','get_new_articles_from_catid($template_default["news"],$1,$2,$db);',$content["all"]);
}