| 
     
      
      
      From: <txm...@us...> - 2012-02-03 11:58:46
      
     
   | 
Revision: 8875
          http://xoops.svn.sourceforge.net/xoops/?rev=8875&view=rev
Author:   txmodxoops
Date:     2012-02-03 11:58:33 +0000 (Fri, 03 Feb 2012)
Log Message:
-----------
Added Files
Revision Files
Modified Paths:
--------------
    XoopsModules/xnews/branches/timgno/xnews/admin/importer.php
    XoopsModules/xnews/branches/timgno/xnews/admin/stories.php
    XoopsModules/xnews/branches/timgno/xnews/admin/topics.php
    XoopsModules/xnews/branches/timgno/xnews/class/class.newsstory.php
    XoopsModules/xnews/branches/timgno/xnews/class/class.xnewsstory.php
    XoopsModules/xnews/branches/timgno/xnews/class/xnews_topics.php
    XoopsModules/xnews/branches/timgno/xnews/include/functions.php
    XoopsModules/xnews/branches/timgno/xnews/index.php
    XoopsModules/xnews/branches/timgno/xnews/ratenews.php
    XoopsModules/xnews/branches/timgno/xnews/sql/mysql.sql
    XoopsModules/xnews/branches/timgno/xnews/templates/xnews_item.html
    XoopsModules/xnews/branches/timgno/xnews/xoops_version.php
Added Paths:
-----------
    XoopsModules/xnews/branches/timgno/xnews/class/class.newsimport.php
Modified: XoopsModules/xnews/branches/timgno/xnews/admin/importer.php
===================================================================
--- XoopsModules/xnews/branches/timgno/xnews/admin/importer.php	2012-02-02 17:05:21 UTC (rev 8874)
+++ XoopsModules/xnews/branches/timgno/xnews/admin/importer.php	2012-02-03 11:58:33 UTC (rev 8875)
@@ -22,15 +22,15 @@
 {
     $topic = new xni_NewsTopic(0, $to_module_subprefix);
 	
-	$topic->topic_pid = $arrCat['topic_pid'];
-	$topic->topic_title = $arrCat['topic_title'];
-	$topic->topic_description = $arrCat['topic_description'];
+	$topic->topic_pid = $arrCat['topics_pid'];
+	$topic->topic_title = $arrCat['topics_title'];
+	$topic->topic_description = $arrCat['topics_description'];
 	$topic->menu = $arrCat['menu'];
-	$topic->topic_frontpage = $arrCat['topic_frontpage'];
-	$topic->topic_rssurl = $arrCat['topic_rssurl'];
-	$topic->topic_color = $arrCat['topic_color'];
+	$topic->topic_frontpage = $arrCat['topics_frontpage'];
+	$topic->topic_rssurl = $arrCat['topics_rssurl'];
+	$topic->topic_color = $arrCat['topics_color'];
 	//DNPROSSI - Added for version 1.69
-	if ( isset($arrCat['topic_weight'] ) ) { $topic->topic_weight = $arrCat['topic_weigth']; } 
+	if ( isset($arrCat['topics_weight'] ) ) { $topic->topic_weight = $arrCat['topics_weigth']; } 
 	
 	if ($from_module_dirname == 'news') 
 	{
@@ -44,15 +44,15 @@
 	}
 		
     // Category image
-    if ( ($arrCat['topic_imgurl'] != 'blank.gif') && ($arrCat['topic_imgurl'] != '') ) 
+    if ( ($arrCat['topics_imgurl'] != 'blank.gif') && ($arrCat['topic_imgurl'] != '') ) 
     {
-		if ($arrCat['topic_imgurl'] == 'xoops.gif') 
+		if ($arrCat['topics_imgurl'] == 'xoops.gif') 
         {
-			$topic->topic_imgurl = $arrCat['topic_imgurl'];
+			$topic->topic_imgurl = $arrCat['topics_imgurl'];
 		}
 		else
 		{
-			if ( copy($sourcepath . $arrCat['topic_imgurl'], $destinationpath . $arrCat['topic_imgurl']) ) 
+			if ( copy($sourcepath . $arrCat['topic_imgurl'], $destinationpath . $arrCat['topics_imgurl']) ) 
 			{
 				$topic->topic_imgurl = $arrCat['topic_imgurl'];
 				echo sprintf(_AM_XNI_IMPORTED_FILE, $topic->topic_imgurl()) . "<br />";
@@ -75,21 +75,21 @@
 	// Saving topic permissions
 	if ($from_module_dirname == 'news') 
 	{
-		$groupsIds = $gperm_handler->getGroupIds('news_approve', $arrCat['topic_id'], $news_module_id);
+		$groupsIds = $gperm_handler->getGroupIds('news_approve', $arrCat['topics_id'], $news_module_id);
 		xni_savePermissions($to_module_dirname, $groupsIds, $topic->topic_id(), $to_module_subprefix . 'approve');
-		$groupsIds = $gperm_handler->getGroupIds('news_view', $arrCat['topic_id'], $news_module_id);
+		$groupsIds = $gperm_handler->getGroupIds('news_view', $arrCat['topics_id'], $news_module_id);
 		xni_savePermissions($to_module_dirname, $groupsIds, $topic->topic_id(), $to_module_subprefix . 'view');
-		$groupsIds = $gperm_handler->getGroupIds('news_submit', $arrCat['topic_id'], $news_module_id);
+		$groupsIds = $gperm_handler->getGroupIds('news_submit', $arrCat['topics_id'], $news_module_id);
 		xni_savePermissions($to_module_dirname, $groupsIds, $topic->topic_id(), $to_module_subprefix . 'submit');
 	    // echo intval($topic->topic_id()) . '<br/>';
 	}
 	else
 	{
-		$groupsIds = $gperm_handler->getGroupIds($from_module_subprefix . 'approve', $arrCat['topic_id'], $news_module_id);
+		$groupsIds = $gperm_handler->getGroupIds($from_module_subprefix . 'approve', $arrCat['topics_id'], $news_module_id);
 		xni_savePermissions($to_module_dirname, $groupsIds, $topic->topic_id(), $to_module_subprefix . 'approve');
-		$groupsIds = $gperm_handler->getGroupIds($from_module_subprefix . 'view', $arrCat['topic_id'], $news_module_id);
+		$groupsIds = $gperm_handler->getGroupIds($from_module_subprefix . 'view', $arrCat['topics_id'], $news_module_id);
 		xni_savePermissions($to_module_dirname, $groupsIds, $topic->topic_id(), $to_module_subprefix . 'view');
-		$groupsIds = $gperm_handler->getGroupIds($from_module_subprefix . 'submit', $arrCat['topic_id'], $news_module_id);
+		$groupsIds = $gperm_handler->getGroupIds($from_module_subprefix . 'submit', $arrCat['topics_id'], $news_module_id);
 		xni_savePermissions($to_module_dirname, $groupsIds, $topic->topic_id(), $to_module_subprefix . 'submit');
 	}		
 		
@@ -97,7 +97,7 @@
 
     echo sprintf(_AM_XNI_IMPORT_CATEGORY_SUCCESS, $topic->topic_title());
 
-    $sql = "SELECT * FROM " . $xoopsDB->prefix($from_module_subprefix . 'stories') .  " WHERE topicid=" . $arrCat['topic_id'];
+    $sql = "SELECT * FROM " . $xoopsDB->prefix($from_module_subprefix . 'stories') .  " WHERE stories_topicid=" . $arrCat['topics_id'];
     $resultArticles = $xoopsDB->query($sql);
     while ($arrArticle = $xoopsDB->fetchArray($resultArticles)) 
     {            
Modified: XoopsModules/xnews/branches/timgno/xnews/admin/stories.php
===================================================================
--- XoopsModules/xnews/branches/timgno/xnews/admin/stories.php	2012-02-02 17:05:21 UTC (rev 8874)
+++ XoopsModules/xnews/branches/timgno/xnews/admin/stories.php	2012-02-03 11:58:33 UTC (rev 8875)
@@ -39,7 +39,7 @@
 xoops_cp_header();
 // Options
 $op = xnews_CleanVars($_REQUEST, 'op', 'default', 'string');
-
+$prune_op = xnews_CleanVars($_REQUEST, 'prune_op', 'default_prune', 'string');
 //Menu admin
 $storiesAdmin = new ModuleAdmin();
 switch ($op) 
@@ -147,8 +147,9 @@
 	break;
 	
 	case "new_stories":
-	    echo $storiesAdmin->addNavigation('stories.php');                                
-        $storiesAdmin->addItemButton(_AM_XNEWS_STORIESLIST, 'stories.php?op=default', 'list');                  
+	    echo $storiesAdmin->addNavigation('stories.php');         	
+        $storiesAdmin->addItemButton(_AM_XNEWS_DELETESTORIES, 'stories.php?op=del_stories&prune_op=default_prune', 'delete');  		  
+        $storiesAdmin->addItemButton(_AM_XNEWS_STORIESLIST, 'stories.php?op=default', 'list'); 		
         echo $storiesAdmin->renderButton();
 		// Create a New Story
     	$obj =& $storiesHandler->create();
@@ -156,11 +157,16 @@
 	break;
 	
 	case "edit_stories":
+		echo $storiesAdmin->addNavigation('stories.php');    
+        $storiesAdmin->addItemButton(_AM_XNEWS_NEWSTORY, 'stories.php?op=new_stories', 'add'); 
+        $storiesAdmin->addItemButton(_AM_XNEWS_DELETESTORIES, 'stories.php?op=del_stories&prune_op=default_prune', 'delete'); 		
+        $storiesAdmin->addItemButton(_AM_XNEWS_STORIESLIST, 'stories.php?op=default', 'list'); 		
+        echo $storiesAdmin->renderButton();
 		$obj = $storiesHandler->get($_REQUEST["stories_id"]);
 		$form = $obj->getForm();
 	break;
 	
-	case "delete_stories":
+	case "del_story":
 		$obj =& $storiesHandler->get($_REQUEST["stories_id"]);
 		if (isset($_REQUEST["ok"]) && $_REQUEST["ok"] == 1) {
 			if ( !$GLOBALS["xoopsSecurity"]->check() ) {
@@ -172,10 +178,70 @@
 				echo $obj->getHtmlErrors();
 			}
 		} else {
-			xoops_confirm(array("ok" => 1, "stories_id" => $_REQUEST["stories_id"], "op" => "delete_stories"), $_SERVER["REQUEST_URI"], sprintf(_AM_XNEWS_FORMSUREDEL, $obj->getVar("stories")));
+			xoops_confirm(array("ok" => 1, "stories_id" => $_REQUEST["stories_id"], "op" => "del_story"), $_SERVER["REQUEST_URI"], sprintf(_AM_XNEWS_FORMSUREDEL, $obj->getVar("stories")));
 		}
 	break;
 	
+	case "del_stories":
+	    switch($prune_op) 
+		{
+		    case 'default_prune': 
+			default:
+			    echo $storiesAdmin->addNavigation('stories.php');    
+                $storiesAdmin->addItemButton(_AM_XNEWS_NEWSTORY, 'stories.php?op=new_stories', 'add'); 	                 
+                $storiesAdmin->addItemButton(_AM_XNEWS_STORIESLIST, 'stories.php?op=default', 'list'); 		
+                echo $storiesAdmin->renderButton();
+				
+				/*$obj = $storiesHandler->get($_REQUEST["stories_topicid"]);
+		        $sform = $obj->getFormPrune();*/
+			break;
+			
+			case 'prunenews':			    
+	            $timestamp=intval($_POST['prune_date']);
+	            $expired= intval($_POST['expired']);
+	            $topiclist='';
+	            if(isset($_POST['pruned_topics'])) {
+		            $topiclist=$_POST['pruned_topics'];
+	            }
+
+	            if(intval($_POST['ok'])==1) {
+		            $story = new nw_NewsStory();		            
+		            $count=$story->GetCountStoriesPublishedBefore($timestamp,$expired,$topiclist);
+		            $msg=sprintf(_AM_XNEWS_PRUNE_DELETED,$count);
+		            $story->DeleteBeforeDate($timestamp,$expired,$topiclist);
+		            unset($story);
+		            nw_updateCache();
+		            redirect_header( 'index.php', 3, $msg);
+	            }
+			break;
+			
+			case 'confirmbeforetoprune':
+			    global $dateformat;
+	            $story = new nw_NewsStory();	            
+	            $topiclist='';
+	            if(isset($_POST['pruned_topics'])) {
+		            $topiclist=implode(',',$_POST['pruned_topics']);
+	            }
+	            echo '<h2>' . _AM_XNEWS_PRUNENEWS . '</h2>';
+	            $expired=0;
+	            if(isset($_POST['onlyexpired'])) {
+		            $expired = intval($_POST['onlyexpired']);
+	            }
+	            $date=$_POST['prune_date'];
+	            $timestamp=mktime(0,0,0,intval(substr($date,5,2)), intval(substr($date,8,2)), intval(substr($date,0,4)));
+	            $count=$story->GetCountStoriesPublishedBefore($timestamp, $expired, $topiclist);
+	            if($count) {
+		            $displaydate=formatTimestamp($timestamp,$dateformat);
+		            $msg=sprintf(_AM_XNEWS_PRUNE_CONFIRM,$displaydate, $count);
+		            xoops_confirm(array( 'prune_op' => 'prunenews', 'expired' => $expired, 'pruned_topics' => $topiclist, 'prune_date' => $timestamp, 'ok' => 1), 'index.php', $msg);
+	            } else {
+		            printf(_AM_XNEWS_NOTHING_PRUNE);
+	            }
+	            unset($story);
+			break;		
+		}
+	break;
+	
 	case "update_online_stories":
 		
 	if (isset($_REQUEST["stories_id"])) {
@@ -193,11 +259,12 @@
 	case "default":
 	default:
         echo $storiesAdmin->addNavigation('stories.php');           
-        $storiesAdmin->addItemButton(_AM_XNEWS_NEWSTORY, 'stories.php?op=new_stories', 'add');           
+        $storiesAdmin->addItemButton(_AM_XNEWS_NEWSTORY, 'stories.php?op=new_stories', 'add');      
+        $storiesAdmin->addItemButton(_AM_XNEWS_DELETESTORIES, 'stories.php?op=del_stories&prune_op=default_prune', 'delete'); 		
         echo $storiesAdmin->renderButton();
 		
 		$criteria = new CriteriaCompo();
-		$criteri->add(new Criteria('stories_topicid', '0', '>'));
+		$criteria->add(new Criteria('stories_topicid', '0', '>'));
 		$criteria->setSort("stories_id");		
 		$numrows = $storiesHandler->getCount();
 		if (isset($_REQUEST['limit'])) {
@@ -291,7 +358,7 @@
 					}
 						echo "<td align=\"center\" width=\"10%\">
 								<a href=\"stories.php?op=edit_stories&stories_id=".$stories_arr[$i]->getVar("stories_id")."\"><img src=\"". $pathImageIcon ."/edit.png\" alt=\""._EDIT."\" title=\""._EDIT."\"></a>
-								<a href=\"stories.php?op=delete_stories&stories_id=".$stories_arr[$i]->getVar("stories_id")."\"><img src=\"". $pathImageIcon ."/delete.png\" alt=\""._DELETE."\" title=\""._DELETE."\"></a>
+								<a href=\"stories.php?op=del_story&stories_id=".$stories_arr[$i]->getVar("stories_id")."\"><img src=\"". $pathImageIcon ."/delete.png\" alt=\""._DELETE."\" title=\""._DELETE."\"></a>
 							  </td>";
 						echo "</tr>";
 					}	
Modified: XoopsModules/xnews/branches/timgno/xnews/admin/topics.php
===================================================================
--- XoopsModules/xnews/branches/timgno/xnews/admin/topics.php	2012-02-02 17:05:21 UTC (rev 8874)
+++ XoopsModules/xnews/branches/timgno/xnews/admin/topics.php	2012-02-03 11:58:33 UTC (rev 8875)
@@ -158,7 +158,7 @@
             echo $topicsAdmin->renderButton();
 		    
 		    $criteria = new CriteriaCompo();
-			$criteri->add(new Criteria('topics_id', '0', '>'));
+			$criteria->add(new Criteria('topics_id', '0', '>'));
 		    $criteria->setSort("topics_id");
 		    $numrows = $topicsHandler->getCount();
 			if (isset($_REQUEST['limit'])) {
Added: XoopsModules/xnews/branches/timgno/xnews/class/class.newsimport.php
===================================================================
--- XoopsModules/xnews/branches/timgno/xnews/class/class.newsimport.php	                        (rev 0)
+++ XoopsModules/xnews/branches/timgno/xnews/class/class.newsimport.php	2012-02-03 11:58:33 UTC (rev 8875)
@@ -0,0 +1,18 @@
+<?php
+
+// better place this on a separate file so you can reuse it
+class xni_TableObject extends XoopsObject
+{
+    /**
+     * constructor
+     */
+    function xni_TableObject($row, $id_name = 'cid', $pid_name = 'pid', $title_name = 'title')
+    {
+        $this->XoopsObject();
+        $this->initVar($id_name, XOBJ_DTYPE_INT, $row[$id_name]);
+        $this->initVar($pid_name, XOBJ_DTYPE_INT, $row[$pid_name]);
+        $this->initVar($title_name, XOBJ_DTYPE_TXTBOX, $row[$title_name]);
+    }
+}
+
+?>
Modified: XoopsModules/xnews/branches/timgno/xnews/class/class.newsstory.php
===================================================================
--- XoopsModules/xnews/branches/timgno/xnews/class/class.newsstory.php	2012-02-02 17:05:21 UTC (rev 8874)
+++ XoopsModules/xnews/branches/timgno/xnews/class/class.newsstory.php	2012-02-03 11:58:33 UTC (rev 8875)
@@ -570,12 +570,12 @@
 	 */
 	function adminlink()
 	{
-		//<img src='" . NW_MODULE_URL . "/images/leftarrow22.png' border='0' alt='" . _MA_NW_PREVIOUS_ARTICLE . "'/></a>";
-		$ret2 = "<a href='" . NW_MODULE_URL . "/submit.php?op=edit&stories_id=" . $this->stories_id() . "' title='" . _EDIT . "'>";
+		//<img src='" . NW_MODULE_URL . "/images/leftarrow22.png' border='0' alt='" . _MA_XNEWS_PREVIOUS_ARTICLE . "'/></a>";
+		$ret2 = "<a href='" . NW_MODULE_URL . "/submit.php?op=edit&stories_id=" . $this->storyid() . "' title='" . _EDIT . "'>";
 		$ret2 .= "<img src='" . NW_MODULE_URL . "/images/edit_block.png' width='22px' height='22px' border='0' alt='" . _EDIT . "'/></a>   ";
-		$ret2 .= "<a href='" . NW_MODULE_URL . "/admin/index.php?op=delete&stories_id=" . $this->stories_id() . "' title='" . _DELETE . "'>";
+		$ret2 .= "<a href='" . NW_MODULE_URL . "/admin/index.php?op=delete&stories_id=" . $this->storyid() . "' title='" . _DELETE . "'>";
 		$ret2 .= "<img src='" . NW_MODULE_URL . "/images/delete_block.png' width='24px' height='24px' border='0' alt='" . _DELETE . "'/></a>   ";
-		//$ret = " [ <a href='" . NW_MODULE_URL . "/submit.php?op=edit&stories_id=".$this->stories_id()."'>"._EDIT."</a> | <a href='".NW_MODULE_URL . "/admin/index.php?op=delete&stories_id=".$this->stories_id()."'>"._DELETE."</a> ] ";
+		//$ret = " [ <a href='" . NW_MODULE_URL . "/submit.php?op=edit&stories_id=".$this->storyid()."'>"._EDIT."</a> | <a href='".NW_MODULE_URL . "/admin/index.php?op=delete&stories_id=".$this->storyid()."'>"._DELETE."</a> ] ";
 		return $ret2;
 	}
 
@@ -649,8 +649,8 @@
 				if ( $topics_display == 1 ) {
 					//DNPROSSI SEO
 					$cat_path = '';
-					if ( $seo_enabled != 0 ) $cat_path = xnews_remove_accents($this->topics_title());
-					$ret = "<a href='" . xnews_seo_UrlGenerator(_MA_NW_SEO_TOPICS, $this->stories_topicid(), $cat_path) . "'>";
+					if ( $seo_enabled != 0 ) $cat_path = nw_remove_accents($this->topics_title());
+					$ret = "<a href='" . nw_seo_UrlGenerator(_MA_XNEWS_SEO_TOPICS, $this->topicid(), $cat_path) . "'>";
 					$ret .= "<img src='" . NW_TOPICS_FILES_URL . "/" . $this->topics_imgurl() . "' alt='";
 					$ret .= $this->topics_title() . "' hspace='10' vspace='10' align='";
 					$ret .= $this->topicalign() . "'" . $margin . " /></a>";
@@ -662,8 +662,8 @@
 			if ( $topics_display == 1 ) {
 				//DNPROSSI SEO
 				$cat_path = '';
-				if ( $seo_enabled != 0 ) $cat_path = xnews_remove_accents($this->topics_title());
-				$ret = "<a href='" . xnews_seo_UrlGenerator(_MA_NW_SEO_TOPICS, $this->stories_topicid(), $cat_path) . "'>";
+				if ( $seo_enabled != 0 ) $cat_path = nw_remove_accents($this->topics_title());
+				$ret = "<a href='" . nw_seo_UrlGenerator(_MA_XNEWS_SEO_TOPICS, $this->topicid(), $cat_path) . "'>";
 				$ret .= "<img src='" . NW_TOPICS_FILES_URL . "/" . $this->picture() . "' alt='";
 				$ret .= $this->topics_title() . "' hspace='10' vspace='10' align='";
 				$ret .= $this->topicalign() . "'" . $margin . " /></a>";
@@ -676,11 +676,11 @@
 
 	function storylink()
 	{
-		$seo_enabled = xnews_getmoduleoption('seo_enable', NW_MODULE_DIR_NAME);
+		$seo_enabled = xoops_getmoduleoption('seo_enable', NW_MODULE_DIR_NAME);
 		$ret = '';
 		$story_path = '';
-		if ( $seo_enabled != 0 ) $story_path = xnews_remove_accents($this->title());
-			$ret = "<a href='" . xnews_seo_UrlGenerator(_MA_NW_SEO_ARTICLES, $this->stories_id(), $story_path) . "'>" . $this->title() . "</a>";
+		if ( $seo_enabled != 0 ) $story_path = nw_remove_accents($this->title());
+			$ret = "<a href='" . nw_seo_UrlGenerator(_MA_XNEWS_SEO_ARTICLES, $this->storyid(), $story_path) . "'>" . $this->title() . "</a>";
 		return $ret;
 	}
 
@@ -702,8 +702,8 @@
 		$ret = '';
 		$cat_path = '';
 		if ( $topics_display == 1 ) {
-			if ( $seo_enabled != 0 ) $cat_path = xnews_remove_accents($this->topics_title());
-			$ret = "<a href='" . xnews_seo_UrlGenerator(_MA_NW_SEO_TOPICS, $this->stories_topicid(), $cat_path) . "'>" . $this->topics_title() . "</a>";
+			if ( $seo_enabled != 0 ) $cat_path = nw_remove_accents($this->topics_title());
+			$ret = "<a href='" . nw_seo_UrlGenerator(_MA_XNEWS_SEO_TOPICS, $this->topicid(), $cat_path) . "'>" . $this->topics_title() . "</a>";
 			
 		}
 		return $ret;
@@ -721,12 +721,12 @@
 	    //DNPROSSI SEO
 	    $seo_enabled = xnews_getmoduleoption('seo_enable', NW_MODULE_DIR_NAME);
 	    $story = array();
-	    $story['id'] = $this->stories_id();
+	    $story['id'] = $this->storyid();
 	    $story['poster'] = $this->uname();
 	    $story['author_name'] = $this->uname();
-	    $story['author_stories_uid'] = $this->stories_uid();
+	    $story['author_stories_uid'] = $this->uid();
 	    if ( $story['poster'] != false ) {
-	        $story['poster'] = "<a href='".XOOPS_URL."/userinfo.php?stories_uid=".$this->stories_uid()."'>".$story['poster']."</a>";
+	        $story['poster'] = "<a href='".XOOPS_URL."/userinfo.php?stories_uid=".$this->uid()."'>".$story['poster']."</a>";
 	    } else {
 			if($xoopsModuleConfig['displayname']!=3) {
 				$story['poster'] = $xoopsConfig['anonymous'];
@@ -735,12 +735,12 @@
 		if ($xoopsModuleConfig['ratenews']) {
 			$story['rating'] = number_format($this->rating(), 2);
 			if ($this->stories_votes == 1) {
-				$story['stories_votes'] = _MA_NW_ONEVOTE;
+				$story['stories_votes'] = _MA_XNEWS_ONEVOTE;
 			} else {
-				$story['stories_votes'] = sprintf(_MA_NW_NUMVOTES,$this->stories_votes);
+				$story['stories_votes'] = sprintf(_MA_XNEWS_NUMVOTES,$this->stories_votes);
 			}
 		}
-	    $story['posttimestamp'] = $this->stories_published();
+	    $story['posttimestamp'] = $this->published();
 	    $story['posttime'] = formatTimestamp($story['posttimestamp'],xnews_getmoduleoption('dateformat', NW_MODULE_DIR_NAME));
 		$story['topics_description'] = $myts->displayTarea($this->topics_description);
 
@@ -759,10 +759,10 @@
 	    if ( $fullcount > 1 ) {
 			$story_path = '';
 			//DNPROSSI SEO
-			if ( $seo_enabled != 0 ) $story_path = xnews_remove_accents($this->title());
-			$morelink .= "<a href='" . xnews_seo_UrlGenerator(_MA_NW_SEO_ARTICLES, $this->stories_id(), $story_path) . "'>";
-			$morelink .= _MA_NW_READMORE . "</a>";
-        	//$morelink .= " | ".sprintf(_MA_NW_BYTESMORE, $totalcount);
+			if ( $seo_enabled != 0 ) $story_path = nw_remove_accents($this->title());
+			$morelink .= "<a href='" . nw_seo_UrlGenerator(_MA_XNEWS_SEO_ARTICLES, $this->storyid(), $story_path) . "'>";
+			$morelink .= _MA_XNEWS_READMORE . "</a>";
+        	//$morelink .= " | ".sprintf(_MA_XNEWS_BYTESMORE, $totalcount);
         	if (XOOPS_COMMENT_APPROVENONE != $xoopsModuleConfig['com_rule']) {
 				$morelink .= " | ";
 			}
@@ -771,16 +771,16 @@
 	        $ccount = $this->comments();
 	        $story_path = '';
 	        //DNPROSSI SEO
-			if ( $seo_enabled != 0 ) $story_path = xnews_remove_accents($this->title());
+			if ( $seo_enabled != 0 ) $story_path = nw_remove_accents($this->title());
 	        if ( $ccount == 0 ) {
-	            $morelink .= _MA_NW_NO_COMMENT;
+	            $morelink .= _MA_XNEWS_NO_COMMENT;
 	        } else {
-	            $morelink .= "<a href='" . xnews_seo_UrlGenerator(_MA_NW_SEO_ARTICLES, $this->stories_id(), $story_path);
+	            $morelink .= "<a href='" . nw_seo_UrlGenerator(_MA_XNEWS_SEO_ARTICLES, $this->storyid(), $story_path);
 	            if ( $ccount == 1 ) {
-	                $morelink .= "'>"._MA_NW_ONECOMMENT."</a>";
+	                $morelink .= "'>"._MA_XNEWS_ONECOMMENT."</a>";
 	            } else {
 	                $morelink .= "'>";
-	                $morelink .= sprintf(_MA_NW_NUMCOMMENTS, $ccount);
+	                $morelink .= sprintf(_MA_XNEWS_NUMCOMMENTS, $ccount);
 	                $morelink .= "</a>";
 	            }
 	        }
@@ -789,17 +789,17 @@
 	    $story['adminlink'] = '';
 
 	    $approveprivilege = 0;
-	    if(xnews_is_admin_group()) {
+	    if(nw_is_admin_group()) {
 	        $approveprivilege = 1;
 	    }
 
-	    if($xoopsModuleConfig['authoredit']==1 && (is_object($xoopsUser) && $xoopsUser->getVar('stories_uid')==$this->stories_uid())) {
+	    if($xoopsModuleConfig['authoredit']==1 && (is_object($xoopsUser) && $xoopsUser->getVar('stories_uid')==$this->uid())) {
 	    	$approveprivilege = 1;
 	    }
 	    if ($approveprivilege) {
 	        $story['adminlink'] = $this->adminlink();
 	    }
-	    $story['mail_link'] = 'mailto:?subject='.sprintf(_MA_NW_INTARTICLE,$xoopsConfig['sitename']).'&body='.sprintf(_MA_NW_INTARTFOUND, $xoopsConfig['sitename']).':  '.NW_MODULE_URL . '/article.php?stories_id='.$this->stories_id();
+	    $story['mail_link'] = 'mailto:?subject='.sprintf(_MA_XNEWS_INTARTICLE,$xoopsConfig['sitename']).'&body='.sprintf(_MA_XNEWS_INTARTFOUND, $xoopsConfig['sitename']).':  '.NW_MODULE_URL . '/article.php?stories_id='.$this->storyid();
 	    $story['imglink'] = '';
 	    $story['align'] = '';
 	    if ( $this->topicdisplay() ) {
@@ -814,12 +814,12 @@
 		
 	    //DNPROSSI SEO
 	    $story_path = '';
-	    if ( $seo_enabled != 0 ) $story_path = xnews_remove_accents($this->title());
-		$story['title'] = "<a href='" . xnews_seo_UrlGenerator(_MA_NW_SEO_ARTICLES, $this->stories_id(), $story_path) . "'>" . $this->title() . "</a>";
-	    $story['hits'] = $this->stories_counter();
+	    if ( $seo_enabled != 0 ) $story_path = nw_remove_accents($this->title());
+		$story['title'] = "<a href='" . nw_seo_UrlGenerator(_MA_XNEWS_SEO_ARTICLES, $this->storyid(), $story_path) . "'>" . $this->title() . "</a>";
+	    $story['hits'] = $this->counter();
 		if($filescount>0) {
 			$story['files_attached']= true;
-			$story['attached_link']="<a href='".NW_MODULE_URL . '/article.php?stories_id='.$this->stories_id()."' title='"._MA_NW_ATTACHEDLIB."'><img src='".NW_MODULE_URL . '/images/attach.png'."' title='"._MA_NW_ATTACHEDLIB."'></a>";
+			$story['attached_link']="<a href='".NW_MODULE_URL . '/article.php?stories_id='.$this->storyid()."' title='"._MA_XNEWS_ATTACHEDLIB."'><img src='".NW_MODULE_URL . '/images/attach.png'."' title='"._MA_XNEWS_ATTACHEDLIB."'></a>";
 		} else {
 			$story['files_attached']= false;
 			$story['attached_link']='';
@@ -837,7 +837,7 @@
 		static $tblusers = array();
 		$option=-1;
 		if($stories_uid == 0) {
-			$stories_uid=$this->stories_uid();
+			$stories_uid=$this->uid();
 		}
 
 		if(is_array($tblusers) && array_key_exists($stories_uid,$tblusers)) {
@@ -958,10 +958,10 @@
 			$created = time();
 			$stories_published = ( $this->approved ) ? intval($this->stories_published) : 0;
 			//DNPROSSI - ADD TAGS FOR UPDATES - ADDED imagerows, pdfrows			
-			$sql = sprintf("INSERT INTO %s (stories_id, stories_uid, title, created, stories_published, stories_expired, hostname, nohtml, nosmiley, hometext, bodytext, stories_counter, stories_topicid, stories_ihome, notifypub, story_type, topicdisplay, topicalign, comments, rating, stories_votes, description, keywords, picture, dobr, tags, imagerows, pdfrows) VALUES (%u, %u, '%s', %u, %u, %u, '%s', %u, %u, '%s', '%s', %u, %u, %u, %u, '%s', %u, '%s', %u, %u, %u, '%s', '%s', '%s', '%u','%s', %u, %u)", $this->table, $newstories_id, intval($this->stories_uid()), $title, $created, $stories_published, $stories_expired, $hostname, intval($this->nohtml()), intval($this->nosmiley()), $hometext, $bodytext, $stories_counter, intval($this->stories_topicid()), intval($this->stories_ihome()), intval($this->notifypub()), $type, intval($this->topicdisplay()), $this->topicalign, intval($this->comments()), $rating, $stories_votes, $description, $keywords, $picture, intval($this->dobr()), $tags, intval($this->imagerows()), intval($this->pdfrows()));
+			$sql = sprintf("INSERT INTO %s (stories_id, stories_uid, title, created, stories_published, stories_expired, hostname, nohtml, nosmiley, hometext, bodytext, stories_counter, stories_topicid, stories_ihome, notifypub, story_type, topicdisplay, topicalign, comments, rating, stories_votes, description, keywords, picture, dobr, tags, imagerows, pdfrows) VALUES (%u, %u, '%s', %u, %u, %u, '%s', %u, %u, '%s', '%s', %u, %u, %u, %u, '%s', %u, '%s', %u, %u, %u, '%s', '%s', '%s', '%u','%s', %u, %u)", $this->table, $newstories_id, intval($this->uid()), $title, $created, $stories_published, $stories_expired, $hostname, intval($this->nohtml()), intval($this->nosmiley()), $hometext, $bodytext, $stories_counter, intval($this->topicid()), intval($this->stories_ihome()), intval($this->notifypub()), $type, intval($this->topicdisplay()), $this->topicalign, intval($this->comments()), $rating, $stories_votes, $description, $keywords, $picture, intval($this->dobr()), $tags, intval($this->imagerows()), intval($this->pdfrows()));
 		} else {
-			$sql = sprintf("UPDATE %s SET title='%s', stories_published=%u, stories_expired=%u, nohtml=%u, nosmiley=%u, hometext='%s', bodytext='%s', stories_topicid=%u, stories_ihome=%u, topicdisplay=%u, topicalign='%s', comments=%u, rating=%u, stories_votes=%u, stories_uid=%u, description='%s', keywords='%s', picture='%s', dobr='%u', tags='%s', imagerows='%u', pdfrows='%u' WHERE stories_id = %u", $this->table, $title, intval($this->stories_published()), $stories_expired, intval($this->nohtml()), intval($this->nosmiley()), $hometext, $bodytext, intval($this->stories_topicid()), intval($this->stories_ihome()), intval($this->topicdisplay()), $this->topicalign, intval($this->comments()), $rating, $stories_votes, intval($this->stories_uid()), $description, $keywords, $picture, intval($this->dobr()), $tags, intval($this->imagerows()), intval($this->pdfrows()), intval($this->stories_id()));
-			$newstories_id = intval($this->stories_id());
+			$sql = sprintf("UPDATE %s SET title='%s', stories_published=%u, stories_expired=%u, nohtml=%u, nosmiley=%u, hometext='%s', bodytext='%s', stories_topicid=%u, stories_ihome=%u, topicdisplay=%u, topicalign='%s', comments=%u, rating=%u, stories_votes=%u, stories_uid=%u, description='%s', keywords='%s', picture='%s', dobr='%u', tags='%s', imagerows='%u', pdfrows='%u' WHERE stories_id = %u", $this->table, $title, intval($this->published()), $stories_expired, intval($this->nohtml()), intval($this->nosmiley()), $hometext, $bodytext, intval($this->topicid()), intval($this->stories_ihome()), intval($this->topicdisplay()), $this->topicalign, intval($this->comments()), $rating, $stories_votes, intval($this->uid()), $description, $keywords, $picture, intval($this->dobr()), $tags, intval($this->imagerows()), intval($this->pdfrows()), intval($this->storyid()));
+			$newstories_id = intval($this->storyid());
 		}
 		if (!$this->db->queryF($sql)) {
 			return false;
@@ -1325,9 +1325,9 @@
 				$arr_replace = array('', '', '');
 				$cpt = 1;
 				if(isset($titles) && is_array($titles)) {
-					$titles[] = strip_tags(sprintf(_MA_NW_PAGE_AUTO_SUMMARY,1, $this->title()));
+					$titles[] = strip_tags(sprintf(_MA_XNEWS_PAGE_AUTO_SUMMARY,1, $this->title()));
 				}
-				$item = "<a href='".NW_MODULE_URL . '/article.php?stories_id='.$this->stories_id()."&page=0'>".sprintf(_MA_NW_PAGE_AUTO_SUMMARY,1, $this->title()).'</a><br />';
+				$item = "<a href='".NW_MODULE_URL . '/article.php?stories_id='.$this->storyid()."&page=0'>".sprintf(_MA_XNEWS_PAGE_AUTO_SUMMARY,1, $this->title()).'</a><br />';
 				$auto_summary .= $item;
 
 				foreach($delimiters as $item) {
@@ -1336,8 +1336,8 @@
 					if(xoops_trim($item) == '') {
 						$item = $cpt;
 					}
-					$titles[] = strip_tags(sprintf(_MA_NW_PAGE_AUTO_SUMMARY,$cpt, $item));
-					$item = "<a href='".NW_MODULE_URL . '/article.php?stories_id='.$this->stories_id().'&page='.($cpt-1)."'>".sprintf(_MA_NW_PAGE_AUTO_SUMMARY,$cpt, $item).'</a><br />';
+					$titles[] = strip_tags(sprintf(_MA_XNEWS_PAGE_AUTO_SUMMARY,$cpt, $item));
+					$item = "<a href='".NW_MODULE_URL . '/article.php?stories_id='.$this->storyid().'&page='.($cpt-1)."'>".sprintf(_MA_XNEWS_PAGE_AUTO_SUMMARY,$cpt, $item).'</a><br />';
 					$auto_summary .= $item;
 				}
     		}
Modified: XoopsModules/xnews/branches/timgno/xnews/class/class.xnewsstory.php
===================================================================
--- XoopsModules/xnews/branches/timgno/xnews/class/class.xnewsstory.php	2012-02-02 17:05:21 UTC (rev 8874)
+++ XoopsModules/xnews/branches/timgno/xnews/class/class.xnewsstory.php	2012-02-03 11:58:33 UTC (rev 8875)
@@ -185,4 +185,4 @@
 		return $keywords;
 	}
 }
-?>
+?>
\ No newline at end of file
Modified: XoopsModules/xnews/branches/timgno/xnews/class/xnews_topics.php
===================================================================
--- XoopsModules/xnews/branches/timgno/xnews/class/xnews_topics.php	2012-02-02 17:05:21 UTC (rev 8874)
+++ XoopsModules/xnews/branches/timgno/xnews/class/xnews_topics.php	2012-02-03 11:58:33 UTC (rev 8875)
@@ -182,6 +182,41 @@
 			$form->display();
 			return $form;
 		}
+		
+		function getFormPrune($action = false)
+		{
+		    if ($action === false) {
+				$action = $_SERVER["REQUEST_URI"];
+			}
+			include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php");
+			$sform = new XoopsThemeForm(_AM_NW_PRUNENEWS, 'pruneform', $action, 'post');
+	        $sform->addElement(new XoopsFormTextDateSelect(_AM_NW_PRUNE_BEFORE, 'prune_date', 15, time()), true);
+	        $onlyexpired=new xoopsFormCheckBox('', 'onlyexpired');
+	        $onlyexpired->addOption(1, _AM_NW_PRUNE_EXPIREDONLY);
+	        $sform->addElement($onlyexpired, false);
+	        $sform->addElement(new XoopsFormHidden('prune_op', 'confirmbeforetoprune'), false);
+	        $topiclist=new XoopsFormSelect(_AM_NW_PRUNE_TOPICS, 'pruned_topics', '', 5, true);	                       
+			// For topics pid			    
+            $criteria = new CriteriaCompo();
+            $criteria->setSort('topics_weight ASC, topics_title');
+            $criteria->setOrder('ASC');
+            $allTopics = $topicsHandler->getall($criteria);
+            $mytree = new XoopsObjectTree($allTopics, 'topics_id', 'topics_pid');  	            
+	        $topics_arr = $$mytree->getAllChild('topics_pid');
+	        if(count($topics_arr)) {
+		        foreach ($topics_arr as $onetopic) {
+			        $topiclist->addOption($onetopic->getVar("topics_id"), $onetopic->getVar("topics_title"));
+		        }
+	        }
+	        $topiclist->setDescription(_AM_NW_EXPORT_PRUNE_DSC);
+	        $sform->addElement($topiclist,false);
+	        $button_tray = new XoopsFormElementTray('' ,'');
+	        $submit_btn = new XoopsFormButton('', 'post', _SUBMIT, 'submit');
+	        $button_tray->addElement($submit_btn);
+	        $sform->addElement($button_tray);
+	        $sform->display();
+			return $form;
+		}
 	}
 	class xnewsxnews_topicsHandler extends XoopsPersistableObjectHandler 
 	{
Modified: XoopsModules/xnews/branches/timgno/xnews/include/functions.php
===================================================================
--- XoopsModules/xnews/branches/timgno/xnews/include/functions.php	2012-02-02 17:05:21 UTC (rev 8874)
+++ XoopsModules/xnews/branches/timgno/xnews/include/functions.php	2012-02-03 11:58:33 UTC (rev 8875)
@@ -310,8 +310,203 @@
     }
     return $Path;
 }
+
+/**
+ * Returns a module's option
+ *
+ * Return's a module's option (for the news module)
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+ * @param string $option	module option's name
+ */
+function nw_getmoduleoption($option, $repmodule)
+{
+	global $xoopsModuleConfig, $xoopsModule;
+	static $tbloptions= Array();
+	if(is_array($tbloptions) && array_key_exists($option, $tbloptions)) {
+		return $tbloptions[$option];
+	}
+
+	$retval = false;
+	if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule && $xoopsModule->getVar('isactive'))) {
+		if(isset($xoopsModuleConfig[$option])) {
+			$retval= $xoopsModuleConfig[$option];
+		}
+	} else {
+		$module_handler =& xoops_gethandler('module');
+		$module =& $module_handler->getByDirname($repmodule);
+		$config_handler =& xoops_gethandler('config');
+		if ($module) {
+		    $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
+	    	if(isset($moduleConfig[$option])) {
+	    		$retval= $moduleConfig[$option];
+	    	}
+		}
+	}
+	$tbloptions[$option]=$retval;
+	return $retval;
+}
+
+
+/**
+ * Updates rating data in item table for a given item
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+ */
+function nw_updaterating($storyid)
+{
+	global $xoopsDB;
+	$query = 'SELECT rating FROM '.$xoopsDB->prefix('nw_stories_votedata').' WHERE storyid = '.$storyid;
+	$voteresult = $xoopsDB->query($query);
+	$votesDB = $xoopsDB->getRowsNum($voteresult);
+	$totalrating = 0;
+	while(list($rating)=$xoopsDB->fetchRow($voteresult)){
+		$totalrating += $rating;
+	}
+	$finalrating = $totalrating/$votesDB;
+	$finalrating = number_format($finalrating, 4);
+	$sql = sprintf("UPDATE %s SET rating = %u, votes = %u WHERE storyid = %u", $xoopsDB->prefix('nw_stories'), $finalrating, $votesDB, $storyid);
+	$xoopsDB->queryF($sql);
+}
+
+/**
+ * Internal function for permissions
+ *
+ * Returns a list of all the permitted topics Ids for the current user
+ *
+ * @return array $topics	Permitted topics Ids
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+ */
+function nw_MygetItemIds($permtype='nw_view')
+{
+	global $xoopsUser;
+	static $tblperms = array();
+	if(is_array($tblperms) && array_key_exists($permtype,$tblperms)) {
+		return $tblperms[$permtype];
+	}
+
+   	$module_handler =& xoops_gethandler('module');
+   	$newsModule =& $module_handler->getByDirname(NW_MODULE_DIR_NAME);
+   	$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
+   	$gperm_handler =& xoops_gethandler('groupperm');
+   	$topics = $gperm_handler->getItemIds($permtype, $groups, $newsModule->getVar('mid'));
+   	$tblperms[$permtype] = $topics;
+    return $topics;
+}
+
+function nw_html2text($document)
+{
+	// PHP Manual:: function preg_replace
+	// $document should contain an HTML document.
+	// This will remove HTML tags, javascript sections
+	// and white space. It will also convert some
+	// common HTML entities to their text equivalent.
+
+	$search = array ("'<script[^>]*?>.*?</script>'si",  // Strip out javascript
+	                 "'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
+	                 "'([\r\n])[\s]+'",                // Strip out white space
+	                 "'&(quot|#34);'i",                // Replace HTML entities
+	                 "'&(amp|#38);'i",
+	                 "'&(lt|#60);'i",
+	                 "'&(gt|#62);'i",
+	                 "'&(nbsp|#160);'i",
+	                 "'&(iexcl|#161);'i",
+	                 "'&(cent|#162);'i",
+	                 "'&(pound|#163);'i",
+	                 "'&(copy|#169);'i",
+	                 "'&#(\d+);'e");                    // evaluate as php
+
+	$replace = array ("",
+	                 "",
+	                 "\\1",
+	                 "\"",
+	                 "&",
+	                 "<",
+	                 ">",
+	                 " ",
+	                 chr(161),
+	                 chr(162),
+	                 chr(163),
+	                 chr(169),
+	                 "chr(\\1)");
+
+	$text = preg_replace($search, $replace, $document);
+	return $text;
+}
+
+/**
+ * Is Xoops 2.3.x ?
+ *
+ * @return boolean need to say it ?
+ */
+function nw_isX23()
+{
+	$x23 = false;
+	$xv = str_replace('XOOPS ','',XOOPS_VERSION);
+	if(substr($xv,2,1) >= '3') {
+		$x23 = true;
+	}
+	return $x23;
+}
+
+/**
+ * version of xoops
+ *
+ * @return string
+ */
+function nw_xoops_version()
+{
+	$xv = '';
+	$xv = str_replace('XOOPS ','',XOOPS_VERSION);
+	$xv = substr($xv,0,3);
+	return $xv;
+}
+
+/**
+ * Retreive an editor according to the module's option "form_options"
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+ */
+//function &nw_getWysiwygForm($caption, $name, $value = '', $rows, $cols, $supplemental='')
+function &nw_getWysiwygForm($caption, $name, $value, $rows, $cols, $width, $height, $supplemental)
+{
+	$editor_option = strtolower(nw_getmoduleoption('form_options', NW_MODULE_DIR_NAME));
+	$editor = false;
+	$editor_configs=array();
+	$editor_configs['name'] =$name;
+	$editor_configs['value'] = $value;
+	$editor_configs['rows'] = $rows;
+	$editor_configs['cols'] = $cols;
+	$editor_configs['width'] = $width;
+	$editor_configs['height'] = $height;
+	$editor_configs['editor'] = $editor_option;
 	
+	$editor = new XoopsFormEditor($caption, $name, $editor_configs);
+    
+	return $editor;
+}
+
 /**
+ * Internal function
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+ */
+function nw_DublinQuotes($text) {
+	return str_replace("\"", ' ',$text);
+}
+
+
+/**
  * Creates all the meta datas :
  * - For Mozilla/Netscape and Opera the site navigation's bar
  * - The Dublin's Core Metadata
@@ -323,6 +518,771 @@
  * @author Instant Zero (http://xoops.instant-zero.com)
  * @copyright (c) Instant Zero
  */
+function nw_CreateMetaDatas($story = null)
+{
+	global $xoopsConfig, $xoTheme, $xoopsTpl;
+	$content = '';
+	$myts =& MyTextSanitizer::getInstance();
+	include_once NW_MODULE_PATH . '/class/class.newstopic.php';
+
+	/**
+	 * Firefox and Opera Navigation's Bar
+	 */
+	if(nw_getmoduleoption('sitenavbar', NW_MODULE_DIR_NAME)) {
+		$content .= sprintf("<link rel=\"Home\" title=\"%s\" href=\"%s/\" />\n",$xoopsConfig['sitename'],XOOPS_URL);
+		$content .= sprintf("<link rel=\"Contents\" href=\"%s\" />\n",NW_MODULE_URL . '/index.php');
+		$content .= sprintf("<link rel=\"Search\" href=\"%s\" />\n",XOOPS_URL.'/search.php');
+		$content .= sprintf("<link rel=\"Glossary\" href=\"%s\" />\n",NW_MODULE_URL . '/archive.php');
+		$content .= sprintf("<link rel=\"%s\" href=\"%s\" />\n",$myts->htmlSpecialChars(_MA_XNEWS_SUBMITNEWS), NW_MODULE_URL . '/submit.php');
+		$content .= sprintf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s\" href=\"%s/\" />\n",$xoopsConfig['sitename'], XOOPS_URL.'/backend.php');
+
+		// Create chapters
+		include_once XOOPS_ROOT_PATH.'/class/tree.php';
+		include_once NW_MODULE_PATH . '/class/class.newstopic.php';
+		$xt = new nw_NewsTopic();
+		$allTopics = $xt->getAllTopics(nw_getmoduleoption('restrictindex', NW_MODULE_DIR_NAME));
+		$topic_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid');
+		$topics_arr = $topic_tree->getAllChild(0);
+		foreach ($topics_arr as $onetopic) {
+			$content .= sprintf("<link rel=\"Chapter\" title=\"%s\" href=\"%s\" />\n",$onetopic->topic_title(),NW_MODULE_URL . '/index.php?topic_id='.$onetopic->topic_id());
+		}
+	}
+
+	/**
+	 * Meta Keywords and Description
+ 	 * If you have set this module's option to 'yes' and if the information was entered, then they are rendered in the page else they are computed
+ 	 */
+	$meta_keywords = '';
+	if(isset($story) && is_object($story)) {
+		if(xoops_trim($story->keywords()) != '') {
+			$meta_keywords = $story->keywords();
+		} else {
+			$meta_keywords = nw_createmeta_keywords($story->hometext().' '.$story->bodytext());
+		}
+		if(xoops_trim($story->description())!='') {
+			$meta_description = strip_tags($story->description);
+		} else {
+			$meta_description = strip_tags($story->title);
+		}
+		if(isset($xoTheme) && is_object($xoTheme)) {
+			$xoTheme->addMeta( 'meta', 'keywords', $meta_keywords);
+			$xoTheme->addMeta( 'meta', 'description', $meta_description);
+		} elseif(isset($xoopsTpl) && is_object($xoopsTpl)) {	// Compatibility for old Xoops versions
+			$xoopsTpl->assign('xoops_meta_keywords', $meta_keywords);
+			$xoopsTpl->assign('xoops_meta_description', $meta_description);
+		}
+	}
+
+	/**
+	 * Dublin Core's meta datas
+	 */
+	if(nw_getmoduleoption('dublincore', NW_MODULE_DIR_NAME) && isset($story) && is_object($story)) {
+		$config_handler =& xoops_gethandler('config');
+		$xoopsConfigMetaFooter =& $config_handler->getConfigsByCat(XOOPS_CONF_METAFOOTER);
+		$content .= '<meta name="DC.Title" content="'.nw_DublinQuotes($story->title())."\" />\n";
+		$content .= '<meta name="DC.Creator" content="'.nw_DublinQuotes($story->uname())."\" />\n";
+		$content .= '<meta name="DC.Subject" content="'.nw_DublinQuotes($meta_keywords)."\" />\n";
+		$content .= '<meta name="DC.Description" content="'.nw_DublinQuotes($story->title())."\" />\n";
+		$content .= '<meta name="DC.Publisher" content="'.nw_DublinQuotes($xoopsConfig['sitename'])."\" />\n";
+		$content .= '<meta name="DC.Date.created" scheme="W3CDTF" content="'.date('Y-m-d',$story->created)."\" />\n";
+		$content .= '<meta name="DC.Date.issued" scheme="W3CDTF" content="'.date('Y-m-d',$story->published)."\" />\n";
+		$content .= '<meta name="DC.Identifier" content="'.NW_MODULE_URL . '/article.php?storyid='.$story->storyid()."\" />\n";
+		$content .= '<meta name="DC.Source" content="'.XOOPS_URL."\" />\n";
+		$content .= '<meta name="DC.Language" content="'._LANGCODE."\" />\n";
+		$content .= '<meta name="DC.Relation.isReferencedBy" content="'.NW_MODULE_URL . '/index.php?topic_id='.$story->topicid()."\" />\n";
+		if(isset($xoopsConfigMetaFooter['meta_copyright'])) {
+			$content .= '<meta name="DC.Rights" content="'.nw_DublinQuotes($xoopsConfigMetaFooter['meta_copyright'])."\" />\n";
+		}
+	}
+
+	/**
+	 * Firefox 2 micro summaries
+	 */
+	if(nw_getmoduleoption('firefox_microsummaries', NW_MODULE_DIR_NAME)) {
+		$content .= sprintf("<link rel=\"microsummary\" href=\"%s\" />\n",NW_MODULE_URL . '/micro_summary.php');
+	}
+
+	if(isset($xoopsTpl) && is_object($xoopsTpl)) {
+		$xoopsTpl->assign('xoops_module_header', $content);
+	}
+}
+
+
+
+/**
+ * Create the meta keywords based on the content
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+ */
+function nw_createmeta_keywords($content)
+{
+	include NW_MODULE_PATH . '/config.php';
+	include_once NW_MODULE_PATH . '/class/blacklist.php';
+	include_once NW_MODULE_PATH . '/class/registryfile.php';
+
+	if(!$cfg['meta_keywords_auto_generate']) {
+		return '';
+	}
+	$registry = new nw_registryfile('nw_metagen_options.txt');
+	$tcontent = '';
+	$tcontent = $registry->getfile();
+	if(xoops_trim($tcontent) != '') {
+		list($keywordscount, $keywordsorder) = explode(',',$tcontent);
+	} else {
+		$keywordscount = $cfg['meta_keywords_count'];
+		$keywordsorder = $cfg['meta_keywords_order'];
+	}
+
+	$tmp = array();
+	// Search for the "Minimum keyword length"
+	if(isset($_SESSION['nw_keywords_limit'])) {
+		$limit = $_SESSION['nw_keywords_limit'];
+	} else {
+		$config_handler =& xoops_gethandler('config');
+		$xoopsConfigSearch =& $config_handler->getConfigsByCat(XOOPS_CONF_SEARCH);
+		$limit = $xoopsConfigSearch['keyword_min'];
+		$_SESSION['nw_keywords_limit'] = $limit;
+	}
+	$myts =& MyTextSanitizer::getInstance();
+	$content = str_replace ("<br />", " ", $content);
+	$content= $myts->undoHtmlSpecialChars($content);
+	$content= strip_tags($content);
+	$content=strtolower($content);
+	$search_pattern=array(" ","\t","\r\n","\r","\n",",",".","'",";",":",")","(",'"','?','!','{','}','[',']','<','>','/','+','-','_','\\','*');
+	$replace_pattern=array(' ',' ',' ',' ',' ',' ',' ',' ','','','','','','','','','','','','','','','','','','','');
+	$content = str_replace($search_pattern, $replace_pattern, $content);
+	$keywords = explode(' ',$content);
+	switch($keywordsorder) {
+		case 0:	// Ordre d'apparition dans le texte
+			$keywords = array_unique($keywords);
+			break;
+		case 1:	// Ordre de fr\xE9quence des mots
+			$keywords = array_count_values($keywords);
+			asort($keywords);
+			$keywords = array_keys($keywords);
+			break;
+		case 2:	// Ordre inverse de la fr\xE9quence des mots
+			$keywords = array_count_values($keywords);
+			arsort($keywords);
+			$keywords = array_keys($keywords);
+			break;
+	}
+	// Remove black listed words
+	$metablack = new nw_blacklist();
+	$words = $metablack->getAllKeywords();
+	$keywords = $metablack->remove_blacklisted($keywords);
+
+	foreach($keywords as $keyword) {
+		if(strlen($keyword)>=$limit && !is_numeric($keyword)) {
+			$tmp[] = $keyword;
+		}
+	}
+	$tmp = array_slice($tmp, 0, $keywordscount);
+	if(count($tmp) > 0) {
+		return implode(',',$tmp);
+	} else {
+		if(!isset($config_handler) || !is_object($config_handler)) {
+			$config_handler =& xoops_gethandler('config');
+		}
+		$xoopsConfigMetaFooter =& $config_handler->getConfigsByCat(XOOPS_CONF_METAFOOTER);
+		if(isset($xoopsConfigMetaFooter['meta_keywords'])) {
+			return $xoopsConfigMetaFooter['meta_keywords'];
+		} else {
+			return '';
+		}
+	}
+}
+
+
+/**
+ * Remove module's cache
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+*/
+function nw_updateCache() {
+	global $xoopsModule;
+	$folder = $xoopsModule->getVar('dirname');
+	$tpllist = array();
+	include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php';
+	include_once XOOPS_ROOT_PATH.'/class/template.php';
+	$tplfile_handler =& xoops_gethandler('tplfile');
+	$tpllist = $tplfile_handler->find(null, null, null, $folder);
+	$xoopsTpl = new XoopsTpl();
+	xoops_template_clear_module_cache($xoopsModule->getVar('mid'));			// Clear module's blocks cache
+
+	// Remove cache for each page.
+	foreach ($tpllist as $onetemplate) {
+		if( $onetemplate->getVar('tpl_type') == 'module' ) {
+			// Note, I've been testing all the other methods (like the one of Smarty) and none of them run, that's why I have used this code
+			$files_del = array();
+			$files_del = glob(XOOPS_CACHE_PATH.'/*'.$onetemplate->getVar('tpl_file').'*');
+			if(count($files_del) >0) {
+				foreach($files_del as $one_file) {
+					unlink($one_file);
+				}
+			}
+		}
+	}
+}
+
+/**
+ * Verify that a mysql table exists
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+*/
+function nw_TableExists($tablename)
+{
+	global $xoopsDB;
+	$result=$xoopsDB->queryF("SHOW TABLES LIKE '$tablename'");
+	return($xoopsDB->getRowsNum($result) > 0);
+}
+
+/**
+ * Verify that a field exists inside a mysql table
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+*/
+function nw_FieldExists($fieldname,$table)
+{
+	global $xoopsDB;
+	$result=$xoopsDB->queryF("SHOW COLUMNS FROM	$table LIKE '$fieldname'");
+	return($xoopsDB->getRowsNum($result) > 0);
+}
+
+/**
+ * Add a field to a mysql table
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+ */
+function nw_AddField($field, $table)
+{
+	global $xoopsDB;
+	$result=$xoopsDB->queryF('ALTER TABLE ' . $table . " ADD $field;");
+	return $result;
+}
+
+/**
+ * Verify that the current user is a member of the Admin group
+ */
+function nw_is_admin_group()
+{
+	global $xoopsUser, $xoopsModule;
+	if(is_object($xoopsUser)) {
+		if(in_array('1',$xoopsUser->getGroups())) {
+			return true;
+		} else {
+			if($xoopsUser->isAdmin($xoopsModule->mid())) {
+				return true;
+			} else {
+				return false;
+			}
+		}
+	} else {
+		return false;
+	}
+}
+
+
+/**
+ * Verify if the current "user" is a bot or not
+ *
+ * If you have a problem with this function, insert the folowing code just before the line if(isset($_SESSION['nw_cache_bot'])) { :
+ * return false;
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+ */
+function nw_isbot()
+{
+	if(isset($_SESSION['nw_cache_bot'])) {
+		return $_SESSION['nw_cache_bot'];
+	} else {
+		// Add here every bot you know separated by a pipe | (not matter with the upper or lower cases)
+		// If you want to see the result for yourself, add your navigator's user agent at the end (mozilla for example)
+		$botlist='AbachoBOT|Arachnoidea|ASPSeek|Atomz|cosmos|crawl25-public.alexa.com|CrawlerBoy Pinpoint.com|Crawler|DeepIndex|EchO!|exabot|Excalibur Internet Spider|FAST-WebCrawler|Fluffy the spider|GAIS Robot/1.0B2|GaisLab data gatherer|Google|Googlebot-Image|googlebot|Gulliver|ia_archiver|Infoseek|Links2Go|Lycos_Spider_(modspider)|Lycos_Spider_(T-Rex)|MantraAgent|Mata Hari|Mercator|MicrosoftPrototypeCrawler|Mo...@so...|MSNBOT|NEC Research Agent|NetMechanic|Nokia-WAPToolkit|nttdirectory_robot|Openfind|Oracle Ultra Search|PicoSearch|Pompos|Scooter|Slider_Search_v1-de|Slurp|Slurp.so|SlySearch|Spider|Spinne|SurferF3|Surfnomore Spider|suzuran|teomaagent1|TurnitinBot|Ultraseek|VoilaBot|vspider|W3C_Validator|Web Link Validator|WebTrends|WebZIP|whatUseek_winona|WISEbot|Xenu Link Sleuth|ZyBorg';
+		$botlist=strtoupper($botlist);
+		$currentagent=strtoupper(xoops_getenv('HTTP_USER_AGENT'));
+		$retval=false;
+		$botarray=explode('|',$botlist);
+		foreach($botarray as $onebot) {
+			if(strstr($currentagent,$onebot)) {
+				$retval=true;
+				break;
+			}
+		}
+	}
+	$_SESSION['nw_cache_bot']=$retval;
+	return $retval;
+}
+
+
+/**
+ * Create an infotip
+ *
+ * @package News
+ * @author Instant Zero (http://xoops.instant-zero.com)
+ * @copyright (c) Instant Zero
+ */
+function nw_make_infotips($text)
+{
+	$infotips = nw_getmoduleoption('infotips', NW_MODULE_DIR_NAME);
+	if($infotips>0) {
+		$myts =& MyTextSanitizer::getInstance();
+		//DNPROSSI changed xoops_substr to mb_substr for utf-8 support
+		return $myts->htmlSpecialChars(mb_substr(strip_tags($text),0,$infotips,'UTF-8'));
+	}
+}
+
+/**
+ * @author   Monte Ohrt <monte at ohrt dot com>, modified by Amos Robinson
+ *           <amos dot robinson at gmail dot com>
+ */
+function nw_close_tags($string)
+{
+	// match opened tags
+	if(preg_match_all('/<([a-z\:\-]+)[^\/]>/', $string, $start_tags)) {
+		$start_tags = $start_tags[1];
+		// match closed tags
+		if(preg_match_all('/<\/([a-z]+)>/', $string, $end_tags)) {
+			$complete_tags = array();
+   			$end_tags = $end_tags[1];
+
+   			foreach($start_tags as $key => $val) {
+        		$posb = array_search($val, $end_tags);
+       			if(is_integer($posb)) {
+          			unset($end_tags[$posb]);
+       			} else {
+					$complete_tags[] = $val;
+				}
+			}
+		} else {
+			$complete_tags = $start_tags;
+		}
+
+		$complete_tags = array_reverse($complete_tags);
+		for($i = 0; $i < count($complete_tags); $i++) {
+			$string .= '</' . $complete_tags[$i] . '>';
+		}
+	}
+	return $string;
+}
+
+/**
+ * Smarty truncate_tagsafe modifier plugin
+ *
+ * Type:     modifier<br>
+ * Name:     truncate_tagsafe<br>
+ * Purpose:  Truncate a string to a certain length if necessary,
+ *           optionally splitting in the middle of a word, and
+ *           appending the $etc string or inserting $etc into the middle.
+ *           Makes sure no tags are left half-open or half-closed
+ *           (e.g. "Banana in a <a...")
+ * @author   Monte Ohrt <monte at ohrt dot com>, modified by Amos Robinson
+ *           <amos dot robinson at gmail dot com>
+ * @param string
+ * @param integer
+ * @param string
+ * @param boolean
+ * @param boolean
+ * @return string
+ */
+function nw_truncate_tagsafe($string, $length = 80, $etc = '...', $break_words = false)
+{
+	if ($length == 0) return '';
+	if (strlen($string) > $length) {
+		$length -= strlen($etc);
+		if (!$break_words) {
+			$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
+			$string = preg_replace('/<[^>]*$/', '', $string);
+			$string = nw_close_tags($string);
+		}
+		return $string . $etc;
+	} else {
+		return $string;
+	}
+}
+
+/**
+ * Resize a Picture to some given dimensions (using the wideImage library)
+ *
+ * @param string $src_path	Picture's source
+ * @param string $dst_path	Picture's destination
+ * @param integer $param_width Maximum picture's width
+ * @param integer $param_height	Maximum picture's height
+ * @param boolean $keep_original	Do we have to keep the original picture ?
+ * @param string $fit	Resize mode (see the wideImage library for more information)
+ */
+function nw_resizePicture($src_path , $dst_path, $param_width , $param_height, $keep_original = false, $fit = 'inside')
+{
+	require_once NW_MODULE_PATH . '/class/wideimage/WideImage.inc.php';
+	$resize = true;
+    $pictureDimensions = getimagesize($src_path);
+    if (is_array($pictureDimensions)) {
+        $pictureWidth = $pictureDimensions[0];
+        $pictureHeight = $pictureDimensions[1];
+        if ($pictureWidth < $param_width && $pictureHeight < $param_height) {
+            $resize = false;
+        }
+    }
+
+	$img = wiImage::load($src_path);
+	if ($resize) {
+		$result = $img->resize($param_width, $param_height, $fit);
+		$result->saveToFile($dst_path);
+ 	} else {
+        @copy($src_path, $dst_path);
+    }
+	if(!$keep_original) {
+		@unlink( $src_path ) ;
+	}
+	return true;
+}
+
+function nw_latestnews_mk_chkbox($options, $number) {
+	$chk   = "";
+	if ($options[$number] == 1) {
+		$chk = " checked='checked'";
+	}
+	$chkbox = "<input type='radio' name='options[$number]' value='1'".$chk." /> "._YES."  ";
+	$chk   = "";
+	if ($options[$number] == 0) {
+		$chk = " checked='checked'";
+	}
+	$chkbox .= "<input type='radio' name='options[$number]' value='0'".$chk." /> "._NO."</td></tr>";
+	return $chkbox;
+}
+
+function nw_latestnews_mk_select($options, $number) {
+	$slc   = "";
+	if ($options[$number] == 1) {
+		$slc = " checked='checked'";
+	}
+	$select = "<input type='radio' name='options[$number]' value='1'".$slc." /> "._LEFT."  ";
+	$slc   = "";
+	if ($options[$number] == 0) {
+		$slc = " checked='checked'";
+	}
+	$select .= "<input type='radio' name='options[$number]' value='0'".$slc." /> "._RIGHT."</td></tr>";
+	return $select;
+}
+
+function nw_remove_numbers($string) {
+  		$vowels = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " ");
+  		$string = str_replace($vowels, '', $string);
+  		return $string;
+}
+  	
+function nw_prepareFolder($folder) {
+    if(!is_dir($folder)) 
+    {
+        mkdir($folder, 0777);
+		file_put_contents($folder.'/index.html', '<script>history.go(-1);</script>');
+	}
+}
+
+//DNPROSSI SEO
+function nw_remove_accents($chain){
+	/**
+    * if XOOPS ML is present, let's sanitize the title with the current language
+    */
+    $myts = MyTextSanitizer::getInstance();
+    if (method_exists($myts, 'formatForML')) {
+    	$chain = $myts->formatForML($chain);
+    }
+    
+	/**
+    * if xLanguage is present, let's prepare the title with the current language
+    */
+	$module_handler =& xoops_gethandler('module');
+	$xlanguage = $module_handler->getByDirname('xlanguage');
+	if ( is_object($xlanguage) && $xlanguage->getVar('isactive') == true ) 
+	{ 
+		require_once XOOPS_ROOT_PATH.'/modules/xlanguage/include/functions.php';
+		$chain = xlanguage_ml($chain); 
+	} 	
+    
+    $chain = rawurlencode($chain);
+    //$chain = utf8_decode($chain);
+    
+    // Transform punctuation
+    //                 Tab     Space      !        "        #        %        &        '        (        )        ,        /        :        ;        <        =        >        ?        @        [        \        ]        ^        {        |        }        ~       .
+    $pattern = array("/%09/", "/%20/", "/%21/", "/%22/", "/%23/", "/%25/", "/%26/", "/%27/", "/%28/", "/%29/", "/%2C/", "/%2F/", "/%3A/", "/%3B/", "/%3C/", "/%3D/", "/%3E/", "/%3F/", "/%40/", "/%5B/", "/%5C/", "/%5D/", "/%5E/", "/%7B/", "/%7C/", "/%7D/", "/%7E/", "/%39/","/\./");
+    $rep_pat = array(  "-"  ,   "-"  ,   ""   ,   ""   ,   ""   , "-100" ,   ""   ,   "-"  ,   ""   ,   ""   ,   ""   ,   "-"  ,   ""   ,   ""   ,   ""   ,   "-"  ,   ""   ,   ""   , "-at-" ,   ""   ,   "-"   ,  ""   ,   "-"  ,   ""   ,   "-"  ,   ""   ,   "-"  ,   "-"   , "" );
+    $chain   = preg_replace($pattern, $rep_pat, $chain);
+    
+    return $chain;
+}
+
+function nw_seo_UrlGenerator($op, $id, $short_url = "") 
+{
+    if ( nw_getmoduleoption('seo_enable', NW_MODULE_DIR_NAME) != 0 )
+    {
+    	if ( !empty($short_url) ) $short_url = $short_url;
+		
+		switch($op) {
+			case _MA_XNEWS_SEO_PDF:
+				$short_url .= nw_getmoduleoption('seo_endofurl_pdf', NW_MODULE_DIR_NAME);
+				break;
+			case _MA_XNEWS_SEO_PRINT:
+				$short_url .= nw_getmoduleoption('seo_endofurl', NW_MODULE_DIR_NAME);
+				break;
+			case _MA_XNEWS_SEO_ARTICLES:
+				$short_url .= nw_getmoduleoption('seo_endofurl', NW_MODULE_DIR_NAME);
+				break;
+			case _MA_XNEWS_SEO_TOPICS:
+				$short_url .= nw_getmoduleoption('seo_endofurl', NW_MODULE_DIR_NAME);
+				break;
+		}
+        if ( nw_getmoduleoption('seo_enable', NW_MODULE_DIR_NAME) == 1 ) 
+        {   
+			// generate SEO url using htaccess
+            $seo_path = "";
+            if ( nw_getmoduleoption('seo_path', NW_MODULE_DIR_NAME) != '' ) {
+				// generate SEO url using seo path eg news, info, blog
+				$seo_path = "/" . strtolower(nw_getmoduleoption('seo_path', NW_MODULE_DIR_NAME)); 
+				if ( nw_getmoduleoption('seo_level', NW_MODULE_DIR_NAME) == 0 ) 
+				{
+					// generate SEO url using root level htaccess
+					$seo_path .= ".";
+					return XOOPS_URL . "/" . NW_MODULE_DIR_NAME . $seo_path . "${op}.${id}/${short_url}"; 
+				} else {
+					// generate SEO url using module level htaccess
+					$seo_path .= ".";
+					return NW_MODULE_URL . $seo_path . "${op}.${id}/${short_url}"; 
+				}
+			} else {
+				// generate SEO url with no seo path
+				$seo_path = "/" . strtolower(nw_getmoduleoption('seo_path', NW_MODULE_DIR_NAME));
+				if ( nw_getmoduleoption('seo_level', NW_MODULE_DIR_NAME) == 0 ) 
+				{
+					// generate SEO url using root level htaccess
+					return XOOPS_URL . "/" . NW_MODULE_DIR_NAME . $seo_path . "${op}.${id}/${short_url}"; 
+				} else {
+					// generate SEO url using module level htaccess
+					return NW_MODULE_URL . $seo_path . "${op}.${id}/${short_url}"; 
+				}
+			}   
+        } else if ( nw_getmoduleoption('seo_enable', NW_MODULE_DIR_NAME) == 2 ) {
+            // generate SEO url using path-info
+            $seo_path = "";
+            if ( nw_getmoduleoption('seo_path', NW_MODULE_DIR_NAME) != "" ) {
+				$seo_path = strtolower(nw_getmoduleoption('seo_path', NW_MODULE_DIR_NAME)) . "."; 
+			}
+            return NW_MODULE_URL . "/index.php/". $seo_path . "${op}.${id}/${short_url}";
+        } else {
+      ...
 
[truncated message content] |