Codice PHP:
// ARTICLES
function articles() {
global $categorySEF, $subcatSEF, $articleSEF, $_ID, $_POS, $_catID, $_XNAME;
$frontpage = s('display_page');
$title_not_found = '<h2>'.l('none_yet').'</h2>';
if (_ADMIN) {
$visible='';
$title_not_found .= '<p>'.l('create_new').'
<a href="'._SITE.'administration/" title="'.l('administration').'">'.l('administration').'</a></p>';
} else {
$visible =' AND a.visible=\'YES\' ';
}
if ($_ID || (!$_catID && $frontpage != 0)) {
if (!$_ID) $_ID = $frontpage;
// article or page, id as indentifier
$query_articles = 'SELECT
a.id AS aid,title,a.seftitle AS asef,text,a.date,
a.displaytitle,a.displayinfo,a.commentable,a.visible
FROM '._PRE.'articles'.' AS a
WHERE id ='.$_ID.$visible;
} else {
if (s('display_pagination') == 'on') $on = true; else $on = false;
if ($on == true) {
if ($articleSEF) {
$SEF = $articleSEF;
} elseif ($subcatSEF) {
$SEF = $subcatSEF;
} else {
$SEF = $categorySEF;
}
// pagination
$currentPage = strpos($SEF, l('paginator')) === 0 ? str_replace(l('paginator'), '', $SEF) : '';
if ($_catID) {
$count = 'SELECT COUNT(a.id) AS num
FROM '._PRE.'articles'.' AS a
WHERE position = 1
AND a.published =1
AND category = '.$_catID.$visible.'
GROUP BY category';
} else {
$count = 'SELECT COUNT(a.id) AS num
FROM '._PRE.'articles'.' AS a
LEFT OUTER JOIN '._PRE.'categories'.' as c
ON category = c.id
LEFT OUTER JOIN '._PRE.'categories'.' as x
ON c.subcat = x.id AND (x.published =\'YES\')
WHERE show_on_home = \'YES\' '.$visible.'
AND position = 1
AND a.published =1
AND c.published =\'YES\'
GROUP BY show_on_home';
}
$count = mysql_query($count);
if ($count) {
$r = mysql_fetch_array($count);
$num = $r['num'];
}
}
if ($num === 0 ) {
echo $title_not_found;
} else {
$articleCount = s('article_limit');
$article_limit = (empty($articleCount) || $articleCount < 1) ? 100 : $articleCount;
$totalPages = ceil($num/$article_limit);
if (!isset($currentPage) || !is_numeric($currentPage) || $currentPage < 1) {
$currentPage = 1;
}
// get the rows for category
if ($_catID) {
$query_articles = 'SELECT
a.id AS aid,title,a.seftitle AS asef,text,a.date,
a.displaytitle,a.displayinfo,a.commentable,a.visible
FROM '._PRE.'articles'.' AS a
WHERE position = 1
AND a.published =1
AND category = '.$_catID.$visible.'
ORDER BY artorder ASC,date DESC
LIMIT '.($currentPage - 1) * $article_limit.','.$article_limit;
} else {
$query_articles = 'SELECT
a.id AS aid,title,a.seftitle AS asef,text,a.date,
displaytitle,displayinfo,commentable,a.visible,
c.name AS name,c.seftitle AS csef,
x.name AS xname,x.seftitle AS xsef
FROM '._PRE.'articles'.' AS a
LEFT OUTER JOIN '._PRE.'categories'.' as c
ON category = c.id
LEFT OUTER JOIN '._PRE.'categories'.' as x
ON c.subcat = x.id AND x.published =\'YES\'
WHERE show_on_home = \'YES\'
AND position = 1
AND a.published =1
AND c.published =\'YES\''.$visible.'
ORDER BY date DESC
LIMIT '.($currentPage - 1) * $article_limit.','.$article_limit;
}
}
}
$result = mysql_query($query_articles);
$numrows = mysql_num_rows($result);
if (!$result || !$numrows) {
if (_ADMIN) {
echo $title_not_found;
}
echo '<ul class="vertical">';
menu_articles(0,10,1);
echo '</ul>';
} else {
$link = '<a href="'._SITE;
while ($r = mysql_fetch_array($result)) {
$infoline = $r['displayinfo'] == 'YES' ? true : false;
$text = stripslashes($r['text']);
if (!empty($currentPage)) {
$short_display = strpos($text, '[break]');
$shorten = $short_display == 0 ? 9999000 : $short_display;
} else {
$shorten = 9999000;
}
$comments_query = 'SELECT id FROM '._PRE.'comments'.'
WHERE articleid = '.$r['aid'].' AND approved = \'True\'';
$comments_result = mysql_query($comments_query);
$comments_num = mysql_num_rows($comments_result);
$a_date_format = date(s('date_format'), strtotime($r['date']));
if ($r['csef']) $uri = $r['xsef'] ? $r['xsef'].'/'.$r['csef'] : $r['csef'];
elseif ($_XNAME) $uri = $categorySEF.'/'.$subcatSEF;
else $uri = $categorySEF;
$title = $r['title'];
if ($r['displaytitle'] == 'YES') {
if (!$_ID) {
echo '<h2 class="big">'.$link.$uri.'/'.$r['asef'].'/">'.$title.'</a></h2>';
} else {
echo '<h2>'.$title.'</h2>';
}
}
file_include(str_replace('[break]', '',$text), $shorten);
$commentable = $r['commentable'];
$visiblity = $r['visible'] == 'YES' ?
'<a href="'._SITE.'?action=process&task=hide&item=snews_articles&id='.$r['aid'].'&back='.$uri.'">'.l('hide').'</a>' :
l('hidden').' ( <a href="'._SITE.'?action=process&task=show&item=snews_articles&id='.$r['aid'].'&back='.$uri.'">'.l('show').'</a> )' ;
$edit_link = $link.'?action=admin_article&id='.$r['aid'].'" title="'.$title.'">'.l('edit').'</a> ';
$edit_link.= ' '.l('divider').' '.$visiblity;
if (!empty($currentPage)) {
if ($infoline == true) {
$tag = explode(',', tags('infoline'));
foreach ($tag as $tag) {
switch (true) {
case ($tag == 'date'):
echo $a_date_format;
break;
case ($tag == 'readmore' && strlen($r['text']) > $shorten):
echo $link.$uri.'/'.$r['asef'].'/">'.l('read_more').'</a> ';
break;
case ($tag == 'comments' && ($commentable == 'YES' || $commentable == 'FREEZ')):
echo $link.$uri.'/'.$r['asef'].'/#'.l('comment').'1">
'.l('comments').' ('.$comments_num.')</a> ';
break;
case ($tag == 'edit' && _ADMIN):
echo ' '.$edit_link;
break;
case ($tag != 'readmore' && $tag != 'comments' && $tag != 'edit'):
echo $tag;
break;
}
}
} else if (_ADMIN) {
echo '<p>'.$edit_link.'</p>';
}
} else if (empty($currentPage)) {
if ($infoline == true) {
$tag = explode(',', tags('infoline'));
foreach ($tag as $tag ) {
switch ($tag) {
case 'date':
echo $a_date_format;
break;
case 'readmore':
case 'comments': ;
break;
case 'edit':
if (_ADMIN) {
echo ' '.$edit_link;
}
break;
default:
echo $tag;
}
}
} else if (_ADMIN) {
echo '<p>'.$edit_link.'</p>';
}
}
}
if (!empty($currentPage) && ($num> $article_limit) && $on) {
paginator( $currentPage, $totalPages, l('paginator'));
}
if (!empty($_POS) && empty($currentPage) && $infoline == true) {
if ($commentable == 'YES') {
comment('unfreezed');
} else if ($commentable == 'FREEZ') {
comment('freezed');
}
}
}
}
Questa di sopra è la parte che viene mostrata in Home..ed è quella che mi spunta bianca! :(