Modified Files:
news_admin.php news_functions.php news_view.php
Log Message:
added hide/sticky news options for admins
Index: news_view.php
===================================================================
RCS file: /cvsroot/flatnuke/flatnuke/flatnews/include/news_view.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** news_view.php 22 Jul 2009 14:40:56 -0000 1.4
--- news_view.php 31 Jul 2009 18:56:15 -0000 1.5
***************
*** 26,31 ****
$ntitle = $data['title'];
} else $ntitle = "<img src=\"themes/$theme/images/news.png\" alt=\"News\" /> ".$data['title'];
!
! OpenTableTitle($ntitle);
$w3c_title = _ARGOMENTO.": ".eregi_replace("\.png$|\.gif$|\.jpeg$|\.jpg$","",$data['category']);
echo "<a href=\"index.php?mod=none_Search&where=news&find=".$data['category']."\">";
--- 26,38 ----
$ntitle = $data['title'];
} else $ntitle = "<img src=\"themes/$theme/images/news.png\" alt=\"News\" /> ".$data['title'];
!
! //controllo se è nascosta
! if (eregi("^hide_",$news))
! $ntitle = "<span style=\"color : #ff0000; text-decoration : line-through;\">$ntitle</span>";
! //se la news è in evidenza metto un'icona accanto al titolo
! $ontopstring="";
! if (eregi("^top_",$news))
! $ontopstring = "<img src='forum/icons/ontop.png' alt='Ontop' /> ";
! OpenTableTitle($ontopstring.$ntitle);
$w3c_title = _ARGOMENTO.": ".eregi_replace("\.png$|\.gif$|\.jpeg$|\.jpg$","",$data['category']);
echo "<a href=\"index.php?mod=none_Search&where=news&find=".$data['category']."\">";
***************
*** 44,48 ****
}
echo "<br /><br />";
! echo stripslashes($data['header']);
create_footer_news($section,$news,$data);
CloseTableTitle($newsfile);
--- 51,55 ----
}
echo "<br /><br />";
! echo stripslashes(tag2html($data['header'],"home"));
create_footer_news($section,$news,$data);
CloseTableTitle($newsfile);
***************
*** 76,81 ****
// echo "SECTION $section";
! $newslist = list_news($section);
!
// calculate current page limits
$totpages = (count($newslist)%$newspp!=0) ? (intval(count($newslist)/($newspp)+1)) : (intval(count($newslist)/$newspp));
--- 83,90 ----
// echo "SECTION $section";
! if (is_admin())
! $newslist = list_news($section,"true","true");
! else $newslist = list_news($section,"true","false");
!
// calculate current page limits
$totpages = (count($newslist)%$newspp!=0) ? (intval(count($newslist)/($newspp)+1)) : (intval(count($newslist)/$newspp));
***************
*** 149,153 ****
// add 1 visit to the news (if you aren't admin or moderator)
if (!is_admin() or is_news_moderator())
! news_add_read($news);
// read news contents
$title = $data['title'];
--- 158,162 ----
// add 1 visit to the news (if you aren't admin or moderator)
if (!is_admin() or is_news_moderator())
! news_add_read($section,$news);
// read news contents
$title = $data['title'];
***************
*** 156,159 ****
--- 165,171 ----
$body = $data['body'];
// print news
+ if (eregi("^hide_",$news))
+ $title = "<span style=\"color : #ff0000; text-decoration : line-through;\">$title</span>";
+ //controllo se la news è nascosta
if(defined('_THEME_VER')) {
if(_THEME_VER > 0)
***************
*** 176,180 ****
echo "<br /><br />";
! print stripslashes($header)."<br /><br />".stripslashes($body);
// footer
echo "<div class='footnews'>\n";
--- 188,192 ----
echo "<br /><br />";
! print stripslashes(tag2html($header,"home"))."<br /><br />".stripslashes(tag2html($body,"home"));
// footer
echo "<div class='footnews'>\n";
***************
*** 183,188 ****
echo $news_link['link_comment']." ";
echo $news_link['link_print']." ";
! if (is_admin()) echo $news_link['link_modify']." ";
! if (is_admin()) echo $news_link['link_delete']." ";
echo "</div>\n";
// comments
--- 195,206 ----
echo $news_link['link_comment']." ";
echo $news_link['link_print']." ";
! if (is_admin() or is_news_moderator()) {
! echo $news_link['link_modify']." ";
! echo $news_link['link_delete']." ";
! if (eregi("^top_",$news)) echo$news_link['link_normal']." ";
! else echo $news_link['link_ontop']." ";
! if (eregi("^hide_",$news)) echo $news_link['link_show']." ";
! else echo $news_link['link_hide']." ";
! }
echo "</div>\n";
// comments
***************
*** 258,262 ****
// search previous and next news
! $newslist = list_news($section);
$key = array_search("$news",$newslist);
--- 276,280 ----
// search previous and next news
! $newslist = list_news($section,"false","false");
$key = array_search("$news",$newslist);
***************
*** 311,316 ****
echo $news_link['link_comment']." ";
echo $news_link['link_print']." ";
! if (is_admin() or is_news_moderator()) echo $news_link['link_modify']." ";
! if (is_admin() or is_news_moderator()) echo $news_link['link_delete']." ";
// print_r($news_link);
echo "</div>";
--- 329,341 ----
echo $news_link['link_comment']." ";
echo $news_link['link_print']." ";
! if (is_admin() or is_news_moderator()) {
! echo $news_link['link_modify']." ";
! echo $news_link['link_delete']." ";
! if (eregi("^top_",$news)) echo$news_link['link_normal']." ";
! else echo $news_link['link_ontop']." ";
! if (eregi("^hide_",$news)) echo $news_link['link_show']." ";
! else echo $news_link['link_hide']." ";
! }
!
// print_r($news_link);
echo "</div>";
***************
*** 383,387 ****
// link to read the full news
! $ret_strings['link_read'] = "<img src='themes/$theme/images/read.png' alt='Read' /> ";
$ret_strings['link_read'] .= "<a href='index.php?$modstring"."action=viewnews&news=$news' title=\""._FLEGGI." news: $title\"";
//COMMENTATO PER LA PERDITA NELLE PRESTAZIONI
--- 408,412 ----
// link to read the full news
! $ret_strings['link_read'] = "<img src='themes/$theme/images/read.png' alt='Read' /> ";
$ret_strings['link_read'] .= "<a href='index.php?$modstring"."action=viewnews&news=$news' title=\""._FLEGGI." news: $title\"";
//COMMENTATO PER LA PERDITA NELLE PRESTAZIONI
***************
*** 390,394 ****
$ret_strings['link_read'] .= "><b>"._LEGGITUTTO."</b></a>";
// link to comment the news
! $ret_strings['link_comment'] = "<img src='themes/$theme/images/comment.png' alt='Comment' /> ";
$ret_strings['link_comment'] .= "<a href='index.php?$modstring"."action=addcommentinterface&news=$news' title=\""._ADDCOMM." news: $title\">";
$commenti = count($data['comments']);
--- 415,419 ----
$ret_strings['link_read'] .= "><b>"._LEGGITUTTO."</b></a>";
// link to comment the news
! $ret_strings['link_comment'] = "<img src='themes/$theme/images/comment.png' alt='Comment' /> ";
$ret_strings['link_comment'] .= "<a href='index.php?$modstring"."action=addcommentinterface&news=$news' title=\""._ADDCOMM." news: $title\">";
$commenti = count($data['comments']);
***************
*** 398,421 ****
$ret_strings['link_comment'] .= _COMMENTI." ($commenti)</a>";
// link to print the news
! $ret_strings['link_print'] = "<img src='themes/$theme/images/print.png' alt='Print' /> ";
$ret_strings['link_print'] .= "<a href='print.php?news=$news' target='new' title=\""._STAMPA." news: $title\">"._STAMPA."</a>";
if(is_admin()) {
// link to modify the news
! $ret_strings['link_modify'] = "<img src='themes/$theme/images/modify.png' alt='Modify' /> ";
$ret_strings['link_modify'] .= "<a href='index.php?$modstring"."action=editnewsinterface&news=$news' title=\""._MODIFICA." news: $title\">"._MODIFICA."</a>";
// link to delete the news
! $ret_strings['link_delete'] = "<img src='themes/$theme/images/delete.png' alt='Delete' /> ";
$ret_strings['link_delete'] .= "<a href='index.php?$modstring"."action=deletenewsinterface&news=$news' title=\""._ELIMINA." news: $title\">"._ELIMINA."</a>";
// link to hide the news
! $ret_strings['link_hide'] = "<img src='forum/icons/hide.png' alt='Hide' /> ";
$ret_strings['link_hide'] .= "<a href='index.php?$modstring"."action=hidenews&news=$news' title=\"Hide news: $title\">Nascondi</a>";
// link to un-hide the news
! $ret_strings['link_show'] = "<img src='forum/icons/show.png' alt='Show' /> ";
$ret_strings['link_show'] .= "<a href='index.php?$modstring"."action=shownews&news=$news' title=\"Show news: $title\">Mostra</a>";
// link to set on top the news
! $ret_strings['link_ontop'] = "<img src='forum/icons/ontop.png' alt='Ontop' /> ";
$ret_strings['link_ontop'] .= "<a href='index.php?$modstring"."action=ontopnews&news=$news' title=\"Set news on top: $title\">Evidenzia</a>";
// link to hide the news
! $ret_strings['link_normal'] = "<img src='forum/icons/normal.png' alt='Normal' /> ";
$ret_strings['link_normal'] .= "<a href='index.php?$modstring"."action=normalnews&news=$news' title=\"Set news normal: $title\">Normale</a>";
}
--- 423,446 ----
$ret_strings['link_comment'] .= _COMMENTI." ($commenti)</a>";
// link to print the news
! $ret_strings['link_print'] = "<img src='themes/$theme/images/print.png' alt='Print' /> ";
$ret_strings['link_print'] .= "<a href='print.php?news=$news' target='new' title=\""._STAMPA." news: $title\">"._STAMPA."</a>";
if(is_admin()) {
// link to modify the news
! $ret_strings['link_modify'] = "<img src='themes/$theme/images/modify.png' alt='Modify' /> ";
$ret_strings['link_modify'] .= "<a href='index.php?$modstring"."action=editnewsinterface&news=$news' title=\""._MODIFICA." news: $title\">"._MODIFICA."</a>";
// link to delete the news
! $ret_strings['link_delete'] = "<img src='themes/$theme/images/delete.png' alt='Delete' /> ";
$ret_strings['link_delete'] .= "<a href='index.php?$modstring"."action=deletenewsinterface&news=$news' title=\""._ELIMINA." news: $title\">"._ELIMINA."</a>";
// link to hide the news
! $ret_strings['link_hide'] = "<img src='forum/icons/hide.png' alt='Hide' /> ";
$ret_strings['link_hide'] .= "<a href='index.php?$modstring"."action=hidenews&news=$news' title=\"Hide news: $title\">Nascondi</a>";
// link to un-hide the news
! $ret_strings['link_show'] = "<img src='forum/icons/show.png' alt='Show' /> ";
$ret_strings['link_show'] .= "<a href='index.php?$modstring"."action=shownews&news=$news' title=\"Show news: $title\">Mostra</a>";
// link to set on top the news
! $ret_strings['link_ontop'] = "<img src='forum/icons/ontop.png' alt='Ontop' /> ";
$ret_strings['link_ontop'] .= "<a href='index.php?$modstring"."action=ontopnews&news=$news' title=\"Set news on top: $title\">Evidenzia</a>";
// link to hide the news
! $ret_strings['link_normal'] = "<img src='forum/icons/normal.png' alt='Normal' /> ";
$ret_strings['link_normal'] .= "<a href='index.php?$modstring"."action=normalnews&news=$news' title=\"Set news normal: $title\">Normale</a>";
}
Index: news_admin.php
===================================================================
RCS file: /cvsroot/flatnuke/flatnuke/flatnews/include/news_admin.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** news_admin.php 22 Jul 2009 14:40:56 -0000 1.5
--- news_admin.php 31 Jul 2009 18:56:15 -0000 1.6
***************
*** 399,401 ****
--- 399,486 ----
flatnews_logf("EDIT COMMENT: comment $number doesn't exists in the news $news in the section $section");
}
+
+ /**
+ * Mette le news in evidenza
+ *
+ * @param string $section la sezione contenente la news
+ * @param string $news la news da mettere in evidenza o meno
+ * @param booelan $sticky true se la news deve essere in evidenza, false in caso contrario
+ * @author Aldo Boccacci
+ */
+ function set_news_ontop($section,$news,$ontop){
+ $section = getparam($section,PAR_NULL,SAN_FLAT);
+ $news = getparam($news,PAR_NULL,SAN_FLAT);
+ $newsfile = get_news_file($section,$news);
+ if (!check_path($newsfile,get_fn_dir("sections"),TRUE)) flatnews_die("\$newsfile is not valid!".strip_tags($newsfile),__FILE__,__LINE__);
+
+ if (!check_var($ontop,"boolean")) flatnews_die("\$sticky must be a boolean value!",__FILE__,__LINE__);
+
+ if (file_exists($newsfile)){
+ if (!is_writeable($newsfile))
+ flatnews_die("File ".strip_tags($newsfile)." is not writable",__FILE__,__LINE__);
+ if ($ontop==TRUE){
+ if (!eregi("^top_",$news)){
+ rename($newsfile,get_news_dir($section)."top_$news.fn.php");
+ flatnews_logf("news $news in the section $section is set on top.");
+ }
+ }
+ else if ($ontop==FALSE){
+ if (eregi("^top_",$news)){
+ rename($newsfile,get_news_dir($section).eregi_replace("^top_","",$news).".fn.php");
+ flatnews_logf("news $news in the section $section is set normal.");
+ }
+ }
+ }
+ else flatnews_die("File ".strip_tags($newsfile)." doesn't exists",__FILE__,__LINE__);
+
+ $modstring="";
+ if (get_mod()!="") $modstring = "?mod=".get_mod();
+
+ echo "<div align=\"center\"><a href=\"index.php$modstring\" >"._RETURN."</a>
+ </div>";
+ echo "<meta http-equiv=\"Refresh\" content=\"1; URL=index.php$modstring\" >";
+ }
+
+ /**
+ * Nasconde o mostra la news
+ *
+ * @param string $section la sezione contenente la news
+ * @param string $news la news da nascondere o meno
+ * @param booelan $sticky true se la news deve essere nascosta, false in caso contrario
+ * @author Aldo Boccacci
+ */
+ function hide_news($section,$news,$hide){
+ $section = getparam($section,PAR_NULL,SAN_FLAT);
+ $news = getparam($news,PAR_NULL,SAN_FLAT);
+ $newsfile = get_news_file($section,$news);
+ if (!check_path($newsfile,get_fn_dir("sections"),TRUE)) flatnews_die("\$newsfile is not valid!".strip_tags($newsfile),__FILE__,__LINE__);
+
+ if (!check_var($hide,"boolean")) flatnews_die("\$hide must be a boolean value!",__FILE__,__LINE__);
+
+ if (file_exists($newsfile)){
+ if (!is_writeable($newsfile))
+ flatnews_die("File ".strip_tags($newsfile)." is not writable",__FILE__,__LINE__);
+ if ($hide==TRUE){
+ if (!eregi("^hide_",$news)){
+ rename($newsfile,get_news_dir($section)."hide_$news.fn.php");
+ flatnews_logf("news $news in the section $section is hidden.");
+ }
+ }
+ else if ($hide==FALSE){
+ if (eregi("^hide_",$news)){
+ rename($newsfile,get_news_dir($section).eregi_replace("^hide_","",$news).".fn.php");
+ flatnews_logf("news $news in the section $section is visible.");
+ }
+ }
+ }
+ else flatnews_die("File ".strip_tags($newsfile)." doesn't exists",__FILE__,__LINE__);
+
+ $modstring="";
+ if (get_mod()!="") $modstring = "?mod=".get_mod();
+
+ echo "<div align=\"center\"><a href=\"index.php$modstring\" >"._RETURN."</a>
+ </div>";
+ echo "<meta http-equiv=\"Refresh\" content=\"1; URL=index.php$modstring\" >";
+ }
+
?>
\ No newline at end of file
Index: news_functions.php
===================================================================
RCS file: /cvsroot/flatnuke/flatnuke/flatnews/include/news_functions.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** news_functions.php 22 Jul 2009 14:40:56 -0000 1.6
--- news_functions.php 31 Jul 2009 18:56:15 -0000 1.7
***************
*** 1,5 ****
<?
include_once("functions.php");
- include_once("shared.php");
include_once("download/fd+.php");
--- 1,4 ----
***************
*** 664,668 ****
// if (!check_path($newsfile,"",true)) return FALSE;
! if (is_admin()) return TRUE;
//**************************************
--- 663,671 ----
// if (!check_path($newsfile,"",true)) return FALSE;
! if (is_admin())
! return TRUE;
!
! if (!is_admin() and eregi("^hide_",$news))
! return FALSE;
//**************************************
***************
*** 674,678 ****
$string = "";
$string = get_file($newsfile);
! return TRUE;
//la news è nascosta?
$newshidden = "false";
--- 677,681 ----
$string = "";
$string = get_file($newsfile);
! // return TRUE;
//la news è nascosta?
$newshidden = "false";
***************
*** 698,701 ****
--- 701,821 ----
/**
+ * Elenca le news della sezione specificata
+ *
+ * @param string $section la sezione
+ * @param boolean $first_on_top indica se elencare prima le news in evidenza
+ * @param booean $show_hidden indica se mostrare le news
+ * @author Aldo Boccacci
+ * @return un array contenente l'elenco delle news della sezione spedificata
+ */
+ function list_news($section,$first_on_top="false",$show_hidden="true"){
+ $section = getparam($section,PAR_NULL,SAN_FLAT);
+ if (!check_var($first_on_top,"boolean")) flatnews_die("\$first_on_top must be a boolean! ",__FILE__,__LINE__);
+ if (!check_var($show_hidden,"boolean")) flatnews_die("\$show_hidden must be a boolean! ",__FILE__,__LINE__);
+
+ if (!is_dir(get_news_dir($section))) return array();
+
+ $sortednews = array();
+ //news on top
+ if ($first_on_top=="true"){
+ $important_news = array();
+ $important_news = glob(get_news_dir($section)."/top_*.fn.php");
+ $isortednews=array();
+
+ $inews="";
+ if (count($important_news)>0){
+ foreach ($important_news as $inews){
+ $inews = basename($inews);
+ $inews = eregi_replace("\.fn\.php$","",$inews);
+ $time = "";
+ $newsdata = array();
+ $time = get_news_time($inews);
+ if ($show_hidden=="false" and preg_match("/^hide_/",basename($inews)))
+ continue;
+ $isortednews[$time] = $inews;
+ }
+ }
+ if (count($isortednews)!=0)
+ krsort($isortednews);
+
+ $nnews = array();
+ $nnews = glob(get_news_dir($section)."/*.fn.php");
+ // $nnews = "";
+ $nsortednews = array();
+ //news normali
+ if (count($nnews)>0){
+ foreach ($nnews as $nnews){
+ $nnews = basename($nnews);
+ $nnews = eregi_replace("\.fn\.php$","",$nnews);
+ if (preg_match("/^top_/",basename($nnews))) continue;
+ $time = get_news_time($nnews);
+
+ if ($show_hidden=="false" and preg_match("/^hide_/",basename($nnews)))
+ continue;
+ $nsortednews[$time] = $nnews;
+ }
+ }
+ if (count($nsortednews)!=0)
+ krsort($nsortednews);
+
+ if (count($isortednews)!=0){
+ foreach ($isortednews as $news){
+ $sortednews[] = $news;
+ }
+ }
+ if (count($nsortednews)!=0){
+ foreach ($nsortednews as $news){
+ $sortednews[] = $news;
+ }
+ }
+
+ }
+ else {
+ // $news = array();
+
+
+ $fdirectory = opendir(get_news_dir($section));
+ $tmpfile="";
+ $newsarray = array();
+ while ($tmpfile = readdir($fdirectory)) {
+ if (preg_match("/\.fn\.php$/",$tmpfile)) {
+ $tmpfile = eregi_replace("\.fn\.php$","",$tmpfile);
+ // echo "$tmpfile<br>";
+ // $news[]="$root/$group/$argument/".$tmpfile;
+ array_push($newsarray, $tmpfile);
+ }
+ }
+
+ // $news = "";
+ $sortednews = array();
+ for ($count=0;$count<count($newsarray);$count++){
+ $news = $newsarray[$count];
+ //controllo se e' nascosto
+
+ if ($show_hidden=="false" and preg_match("/^hide_/",basename($news)))
+ continue;
+
+ $time = get_news_time($news);
+
+ $sortednewstmp[$time] = $news;
+ }
+ krsort($sortednewstmp);
+
+ for ($i=0;$i<count($sortednewstmp);$i++){
+ //controlla
+ $sortednewskey[] = $i;
+ }
+ //per avere un array avente per key i numeri da 0 a n
+ array_combine($sortednewskey,$sortednewstmp);
+
+ }
+
+ //restituisco l'array
+ return $sortednews;
+
+
+ }
+
+ /**
* Elenca le news controllando anche che l'utente collegato abbia i permessi per vederle.
*
***************
*** 706,710 ****
* @since 0.1
*/
! function list_news($section,$all=FALSE){
$section = getparam($section,PAR_NULL,SAN_FLAT);
if (!check_var($all,"boolean")) flatnews_die("\$all must be boolean",__FILE__,__LINE__);
--- 826,830 ----
* @since 0.1
*/
! function list_newsold($section,$all=FALSE){
$section = getparam($section,PAR_NULL,SAN_FLAT);
if (!check_var($all,"boolean")) flatnews_die("\$all must be boolean",__FILE__,__LINE__);
***************
*** 857,861 ****
$data = load_news($section, $news);
$data['reads']= $data['reads']+1;
! save_news($news, $data);
}
--- 977,981 ----
$data = load_news($section, $news);
$data['reads']= $data['reads']+1;
! save_news($section,$news, $data);
}
***************
*** 931,935 ****
if (!check_path($section,"",FALSE)) flatnews_die("\$section is not valid!",__FILE__,__LINE__);
if ($news_array==NULL)
! $news_array = list_news($section,TRUE);
$datastring="<fn:newslist>";
--- 1051,1055 ----
if (!check_path($section,"",FALSE)) flatnews_die("\$section is not valid!",__FILE__,__LINE__);
if ($news_array==NULL)
! $news_array = list_news($section,"true","true");
$datastring="<fn:newslist>";
***************
*** 943,946 ****
--- 1063,1082 ----
}
+ /**
+ * Restituisce la data della news nel formato restituito dalla funzione time()
+ *
+ * @param string $news la news
+ * @return la data della news
+ * @author Aldo Boccacci
+ */
+ function get_news_time($news){
+ $news = getparam($news,PAR_NULL,SAN_FLAT);
+ //rimuovo le parti che non indicano la data della news
+ $time = eregi_replace("^hide_|^top_","",basename($news));
+ $time = eregi_replace("\.fn\.php$","",$time);
+ if (check_var($time,"digit"))
+ return $time;
+ else return NULL;
+ }
?>
\ No newline at end of file