From: <txm...@us...> - 2012-01-31 18:23:43
|
Revision: 8850 http://xoops.svn.sourceforge.net/xoops/?rev=8850&view=rev Author: txmodxoops Date: 2012-01-31 18:23:32 +0000 (Tue, 31 Jan 2012) Log Message: ----------- backup file Removed Paths: ------------- XoopsModules/xnews/trunk/timgno/xnews/class/class.newsstory.php~ XoopsModules/xnews/trunk/timgno/xnews/class/class.newstopic.php~ XoopsModules/xnews/trunk/timgno/xnews/class/class.sfiles.php~ XoopsModules/xnews/trunk/timgno/xnews/class/class.xnewstopic.php~ XoopsModules/xnews/trunk/timgno/xnews/class/stories.php~ XoopsModules/xnews/trunk/timgno/xnews/class/stories_files.php~ XoopsModules/xnews/trunk/timgno/xnews/class/topics.php~ XoopsModules/xnews/trunk/timgno/xnews/class/tree.php~ XoopsModules/xnews/trunk/timgno/xnews/class/xnews_stories.php~ Deleted: XoopsModules/xnews/trunk/timgno/xnews/class/class.newsstory.php~ =================================================================== --- XoopsModules/xnews/trunk/timgno/xnews/class/class.newsstory.php~ 2012-01-31 18:20:32 UTC (rev 8849) +++ XoopsModules/xnews/trunk/timgno/xnews/class/class.newsstory.php~ 2012-01-31 18:23:32 UTC (rev 8850) @@ -1,1490 +0,0 @@ -<?php -// $Id: class.newsstory.php,v 1.29 2004/09/02 17:04:08 hthouzard Exp $ -// ------------------------------------------------------------------------ // -// XOOPS - PHP Content Management System // -// Copyright (c) 2000 XOOPS.org // -// <http://www.xoops.org/> // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as stories_published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------- // -if (!defined('XOOPS_ROOT_PATH')) { - die('XOOPS root path not defined'); -} - -include_once XOOPS_ROOT_PATH.'/class/xoopsstory.php'; -include_once XOOPS_ROOT_PATH.'/include/comment_constants.php'; -include_once NW_MODULE_PATH . '/include/functions.php'; - -class xnews_NewsStory extends XoopsStory -{ - var $newstopic; // XoopsTopic object - var $rating; // news rating - var $stories_votes; // Number of stories_votes - var $description; // META, desciption - var $keywords; // META, keywords - var $picture; - var $topics_imgurl; - var $topics_title; - var $tags; - //var $imagerows; - //var $pdfrows; - - /** - * Constructor - */ - function xnews_NewsStory($stories_id=-1) - { - $this->db =& XoopsDatabaseFactory::getDatabaseConnection(); - $this->table = $this->db->prefix('xnews_stories'); - $this->topicstable = $this->db->prefix('xnews_topics'); - if (is_array($stories_id)) { - $this->makeStory($stories_id); - } elseif($stories_id != -1) { - $this->getStory(intval($stories_id)); - } - } - - /** - * Returns the number of stories stories_published before a date - */ - function GetCountStoriesPublishedBefore($timestamp, $stories_expired, $topicslist='') - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT count(*) as cpt FROM '.$db->prefix('xnews_stories').' WHERE stories_published <=' . $timestamp; - if($stories_expired) { - $sql .=' AND (stories_expired>0 AND stories_expired<='.time().')'; - } - if(strlen(trim($topicslist))>0) { - $sql .=' AND stories_topicid IN ('.$topicslist.')'; - } - $result = $db->query($sql); - list($count) = $db->fetchRow($result); - return $count; - } - - - /** - * Load the specified story from the database - */ - function getStory($stories_id) - { - $sql = 'SELECT s.*, t.* FROM '.$this->table.' s, '.$this->db->prefix('xnews_topics').' t WHERE (stories_id='.intval($stories_id).') AND (s.stories_topicid=t.topics_id)'; - $array = $this->db->fetchArray($this->db->query($sql)); - $this->makeStory($array); - } - - - /** - * Delete stories that were stories_published before a given date - */ - function DeleteBeforeDate($timestamp, $stories_expired, $topicslist='') - { - global $xoopsModule; - $mid= $xoopsModule->getVar('mid'); - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $prefix = $db->prefix('xnews_stories'); - $vote_prefix = $db->prefix('xnews_stories_votedata'); - $files_prefix = $db->prefix('xnews_stories_files'); - $sql = 'SELECT stories_id FROM '.$prefix.' WHERE stories_published <=' . $timestamp; - if($stories_expired) { - $sql .=' (AND stories_expired>0 AND stories_expired<='.time().')'; - } - if(strlen(trim($topicslist))>0) { - $sql .=' AND stories_topicid IN ('.$topicslist.')'; - } - $result = $db->query($sql); - while ($myrow = $db->fetchArray($result)) { - xoops_comment_delete($mid, $myrow['stories_id']); // Delete comments - xoops_notification_deletebyitem($mid, 'story', $myrow['stories_id']); // Delete notifications - $db->queryF('DELETE FROM '.$vote_prefix.' WHERE stories_id='.$myrow['stories_id']); // Delete stories_votes - // Remove files and records related to the files - $result2 = $db->query('SELECT * FROM '.$files_prefix.' WHERE stories_id='.$myrow['stories_id']); - while ($myrow2 = $db->fetchArray($result2)) { - $name = XOOPS_ROOT_PATH.'/uploads/'.$myrow2['downloadname']; - if(file_exists($name)) { - unlink($name); - } - $db->query('DELETE FROM '.$files_prefix.' WHERE fileid='.$myrow2['fileid']); - } - $db->queryF('DELETE FROM '.$prefix.' WHERE stories_id='.$myrow['stories_id']); // Delete the story - } - return true; - } - - function _searchPreviousOrNextArticle($stories_id, $next = true, $checkRight = false) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $ret = array(); - $stories_id = intval($stories_id); - if($next) { - $sql = 'SELECT stories_id, title FROM '.$db->prefix('xnews_stories').' WHERE (stories_published > 0 AND stories_published <= '.time().') AND (stories_expired = 0 OR stories_expired > '.time().') AND stories_id > '.$stories_id; - $orderBy = ' ORDER BY stories_id ASC'; - } else { - $sql = 'SELECT stories_id, title FROM '.$db->prefix('xnews_stories').' WHERE (stories_published > 0 AND stories_published <= '.time().') AND (stories_expired = 0 OR stories_expired > '.time().') AND stories_id < '.$stories_id; - $orderBy = ' ORDER BY stories_id DESC'; - } - if($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(count($topics) > 0) { - $sql .= ' AND stories_topicid IN ('.implode(',', $topics).')'; - } else { - return null; - } - } - $sql .= $orderBy; - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $result = $db->query($sql, 1); - if($result) { - $myts =& MyTextSanitizer::getInstance(); - while ( $row = $db->fetchArray($result) ) { - $ret = array('stories_id' => $row['stories_id'], 'title' => $myts->htmlSpecialChars($row['title'])); - } - } - return $ret; - } - - function getNextArticle($stories_id, $checkRight=false) - { - return $this->_searchPreviousOrNextArticle($stories_id, true, $checkRight); - } - - function getPreviousArticle($stories_id, $checkRight=false) - { - return $this->_searchPreviousOrNextArticle($stories_id, false, $checkRight); - } - - - /** - * Returns stories_published stories according to some options - */ - function getAllPublished($limit=0, $start=0, $checkRight=false, $topic=0, $stories_ihome=0, $asobject=true, $order = 'stories_published', $topics_frontpage=false) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $myts =& MyTextSanitizer::getInstance(); - $ret = array(); - $sql = 'SELECT s.*, t.* FROM '.$db->prefix('xnews_stories').' s, '. $db->prefix('xnews_topics').' t WHERE (s.stories_published > 0 AND s.stories_published <= '.time().') AND (s.stories_expired = 0 OR s.stories_expired > '.time().') AND (s.stories_topicid=t.topics_id) '; - if ($topic != 0) { - if (!is_array($topic)) { - if($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(!in_array ($topic,$topics)) { - return null; - } else { - $sql .= ' AND s.stories_topicid='.intval($topic).' AND (s.stories_ihome=1 OR s.stories_ihome=0)'; - } - } else { - $sql .= ' AND s.stories_topicid='.intval($topic).' AND (s.stories_ihome=1 OR s.stories_ihome=0)'; - } - } else { - if($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - $topic = array_intersect($topic,$topics); - } - if(count($topic)>0) { - $sql .= ' AND s.stories_topicid IN ('.implode(',', $topic).')'; - } else { - return null; - } - } - } else { - if($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(count($topics)>0) { - $topics = implode(',', $topics); - $sql .= ' AND s.stories_topicid IN ('.$topics.')'; - } else { - return null; - } - } - if (intval($stories_ihome) == 0) { - $sql .= ' AND s.stories_ihome=0'; - } - } - if($topics_frontpage) { - $sql .=' AND t.topics_frontpage=1'; - } - $sql .= " ORDER BY s.$order DESC"; - $result = $db->query($sql,intval($limit),intval($start)); - - while ( $myrow = $db->fetchArray($result) ) { - if ($asobject) { - $ret[] = new xnews_NewsStory($myrow); - } else { - $ret[$myrow['stories_id']] = $myts->htmlSpecialChars($myrow['title']); - } - } - return $ret; - } - - - /** - * Retourne la liste des articles aux archives (pour une p\xE9riode donn\xE9e) - */ - function getArchive($publish_start, $publish_end, $checkRight=false, $asobject=true, $order = 'stories_published') - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $myts =& MyTextSanitizer::getInstance(); - $ret = array(); - $sql = 'SELECT s.*, t.* FROM '.$db->prefix('xnews_stories').' s, ' .$db->prefix('xnews_topics').' t WHERE (s.stories_topicid=t.topics_id) AND (s.stories_published > ' . $publish_start . ' AND s.stories_published <= ' . $publish_end . ') AND (stories_expired = 0 OR stories_expired > '.time().') '; - - if($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(count($topics)>0) { - $topics = implode(',', $topics); - $sql .= ' AND stories_topicid IN ('.$topics.')'; - } else { - return null; - } - } - $sql .= " ORDER BY $order DESC"; - $result = $db->query($sql); - while ( $myrow = $db->fetchArray($result) ) { - if ($asobject) { - $ret[] = new xnews_NewsStory($myrow); - } else { - $ret[$myrow['stories_id']] = $myts->htmlSpecialChars($myrow['stories_title']); - } - } - return $ret; - } - - - /** - * Get the today's most readed article - * - * @param int $limit records limit - * @param int $start starting record - * @param boolean $checkRight Do we need to check permissions (by topics) ? - * @param int $topic limit the job to one topic - * @param int $stories_ihome Limit to articles stories_published in home page only ? - * @param boolean $asobject Do we have to return an array of objects or a simple array ? - * @param string $order Fields to sort on - */ - function getBigStory($limit=0, $start=0, $checkRight=false, $topic=0, $stories_ihome=0, $asobject=true, $order = 'stories_counter') - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $myts =& MyTextSanitizer::getInstance(); - $ret = array(); - $tdate = mktime(0,0,0,date('n'),date('j'),date('Y')); - $sql = 'SELECT s.*, t.* FROM '.$db->prefix('xnews_stories').' s, '. $db->prefix('xnews_topics').' t WHERE (s.stories_topicid=t.topics_id) AND (stories_published > '.$tdate.' AND stories_published < '.time().') AND (stories_expired > '.time().' OR stories_expired = 0) '; - - if ( intval($topic) != 0 ) { - if (!is_array($topic)) { - $sql .= ' AND stories_topicid='.intval($topic).' AND (stories_ihome=1 OR stories_ihome=0)'; - } - else { - if(count($topic)>0) { - $sql .= ' AND stories_topicid IN ('.implode(',', $topic).')'; - } else { - return null; - } - } - } else { - if ($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(count($topics)>0) { - $topics = implode(',', $topics); - $sql .= ' AND stories_topicid IN ('.$topics.')'; - } else { - return null; - } - } - if ( intval($stories_ihome) == 0 ) { - $sql .= ' AND stories_ihome=0'; - } - } - $sql .= " ORDER BY $order DESC"; - $result = $db->query($sql,intval($limit),intval($start)); - while ( $myrow = $db->fetchArray($result) ) { - if ( $asobject ) { - $ret[] = new xnews_NewsStory($myrow); - } else { - $ret[$myrow['stories_id']] = $myts->htmlSpecialChars($myrow['stories_title']); - } - } - return $ret; - // DNPROSSI SEO - $seo_enabled = xnews_getmoduleoption('seo_enable', NW_MODULE_DIR_NAME); - if ( $seo_enabled != 0 ) { - $xoopsTpl->assign('urlrewrite', true); - } else { - $xoopsTpl->assign('urlrewrite', false); - } - } - - - /** - * Get all articles stories_published by an author - * - * @param int $stories_uid author's id - * @param boolean $checkRight whether to check the user's rights to topics - */ - function getAllPublishedByAuthor($stories_uid, $checkRight=false, $asobject=true) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $myts =& MyTextSanitizer::getInstance(); - $ret = array(); - $tblstory=$db->prefix('xnews_stories'); - $tbltopics=$db->prefix('xnews_topics'); - - $sql = 'SELECT ' . $tblstory . '.*, '. $tbltopics . '.topics_title, '.$tbltopics.'.topics_color FROM '.$tblstory.','.$tbltopics .' WHERE ('.$tblstory.'.stories_topicid='.$tbltopics.'.topics_id) AND (stories_published > 0 AND stories_published <= '.time().') AND (stories_expired = 0 OR stories_expired > '.time().')'; - $sql .= ' AND stories_uid='.intval($stories_uid); - if ($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - $topics = implode(',', $topics); - if(xoops_trim($topics)!='') { - $sql .= ' AND stories_topicid IN ('.$topics.')'; - } - } - $sql .= ' ORDER BY '.$tbltopics.'.topics_title ASC, '.$tblstory.'.stories_published DESC'; - $result = $db->query($sql); - while ( $myrow = $db->fetchArray($result) ) - { - if ( $asobject ) { - $ret[] = new xnews_NewsStory($myrow); - } else { - if ( $myrow['stories_nohtml'] ) { - $html = 0; - } else { - $html = 1; - } - if ( $myrow['stories_nosmiley'] ) { - $smiley = 0; - } else { - $smiley = 1; - } - //DNPROSSI - dobr - if ( $myrow['stories_dobr'] ) { - $dobr = 0; - } else { - $dobr = 1; - } - $ret[$myrow['stories_id']] = array('title'=>$myts->displayTarea($myrow['stories_title'],$html,$smiley,1), - 'stories_topicid'=>intval($myrow['stories_topicid']), - 'stories_id'=>intval($myrow['stories_id']), - 'hometext'=>$myts->displayTarea($myrow['stories_hometext'],$html,$smiley,1,0,$dobr), - 'stories_counter'=>intval($myrow['stories_counter']), - 'created'=>intval($myrow['stories_created']), - 'topics_title'=>$myts->displayTarea($myrow['topics_title'],$html,$smiley,1), - 'topics_color'=>$myts->displayTarea($myrow['topics_color']), - 'stories_published'=>intval($myrow['stories_published']), - 'rating'=>(float)$myrow['stories_rating'], - 'stories_votes'=>intval($myrow['stories_votes'])); - } - } - return $ret; - } - - - /** - * Get all stories_expired stories - */ - function getAllExpired($limit=0, $start=0, $topic=0, $stories_ihome=0, $asobject=true) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $myts =& MyTextSanitizer::getInstance(); - $ret = array(); - $sql = 'SELECT * FROM '.$db->prefix('xnews_stories').' WHERE stories_expired <= '.time().' AND stories_expired > 0'; - if ( !empty($topic) ) { - $sql .= ' AND stories_topicid='.intval($topic).' AND (stories_ihome=1 OR stories_ihome=0)'; - } else { - if ( intval($stories_ihome) == 0 ) { - $sql .= ' AND stories_ihome=0'; - } - } - - $sql .= ' ORDER BY stories_expired DESC'; - $result = $db->query($sql,intval($limit),intval($start)); - while ( $myrow = $db->fetchArray($result) ) { - if ($asobject) { - $ret[] = new xnews_NewsStory($myrow); - } else { - $ret[$myrow['stories_id']] = $myts->htmlSpecialChars($myrow['stories_title']); - } - } - return $ret; - } - - - - /** - * Returns an array of object containing all the news to be automatically stories_published. - */ - function getAllAutoStory($limit=0, $asobject=true, $start=0) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $myts =& MyTextSanitizer::getInstance(); - $ret = array(); - $sql = 'SELECT * FROM '.$db->prefix('xnews_stories').' WHERE stories_published > '.time().' ORDER BY stories_published ASC'; - $result = $db->query($sql,intval($limit),intval($start)); - while ( $myrow = $db->fetchArray($result) ) { - if ( $asobject ) { - $ret[] = new xnews_NewsStory($myrow); - } else { - $ret[$myrow['stories_id']] = $myts->htmlSpecialChars($myrow['stories_title']); - } - } - return $ret; - } - - /** - * Get all submitted stories awaiting approval - * - * @param int $limit Denotes where to start the query - * @param boolean $asobject true will returns the stories as an array of objects, false will return stories_id => title - * @param boolean $checkRight whether to check the user's rights to topics - */ - function getAllSubmitted($limit=0, $asobject=true, $checkRight = false, $start=0) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $myts =& MyTextSanitizer::getInstance(); - $ret = array(); - $criteria = new CriteriaCompo(new Criteria('stories_published', 0)); - if ($checkRight) { - global $xoopsUser; - if (!is_object($xoopsUser)) { - return $ret; - } - $allowedtopics = xnews_MygetItemIds('xnews_approve'); - $criteria2 = new CriteriaCompo(); - foreach ($allowedtopics as $key => $stories_topicid) { - $criteria2->add(new Criteria('stories_topicid', $stories_topicid), 'OR'); - } - $criteria->add($criteria2); - } - $sql = 'SELECT s.*, t.* FROM '.$db->prefix('xnews_stories').' s, '.$db->prefix('xnews_topics').' t '; - $sql .= ' '.$criteria->renderWhere().' AND (s.stories_topicid=t.topics_id) ORDER BY stories_created DESC'; - $result = $db->query($sql,intval($limit),intval($start)); - while ( $myrow = $db->fetchArray($result) ) { - if ( $asobject ) { - $ret[] = new xnews_NewsStory($myrow); - } else { - $ret[$myrow['stories_id']] = $myts->htmlSpecialChars($myrow['title']); - } - } - return $ret; - } - - - /** - * Used in the module's admin to know the number of stories_expired, automated or pubilshed news - * - * @param int $storytype 1=Expired, 2=Automated, 3=New submissions, 4=Last stories_published stories - * @param bool $checkRight verify permissions or not ? - */ - function getAllStoriesCount($storytype=1, $checkRight = false) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT count(*) as cpt FROM '.$db->prefix('xnews_stories').' WHERE '; - switch($storytype) { - case 1: // Expired - $sql .='(stories_expired <= '.time().' AND stories_expired >0)'; - break; - case 2: // Automated - $sql .='(stories_published > '.time().')'; - break; - case 3: // New submissions - $sql .='(stories_published = 0)'; - break; - case 4: // Last stories_published stories - $sql .='(stories_published > 0 AND stories_published <= '.time().') AND (stories_expired = 0 OR stories_expired > '.time().')'; - break; - } - if($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(count($topics)>0) { - $topics = implode(',', $topics); - $sql .= ' AND stories_topicid IN ('.$topics.')'; - } else { - return 0; - } - } - $result = $db->query($sql); - $myrow = $db->fetchArray($result); - return $myrow['cpt']; - } - - - /** - * Get a list of stories (as objects) related to a specific topic - */ - function getByTopic($stories_topicid, $limit=0) - { - $ret = array(); - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT * FROM '.$db->prefix('xnews_stories').' WHERE stories_topicid='.intval($stories_topicid).' ORDER BY stories_published DESC'; - $result = $db->query($sql, intval($limit), 0); - while( $myrow = $db->fetchArray($result) ){ - $ret[] = new xnews_NewsStory($myrow); - } - return $ret; - } - - - /** - * Count the number of news stories_published for a specific topic - */ - function countPublishedByTopic($stories_topicid=0, $checkRight = false) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT COUNT(*) FROM '.$db->prefix('xnews_stories').' WHERE stories_published > 0 AND stories_published <= '.time().' AND (stories_expired = 0 OR stories_expired > '.time().')'; - if ( !empty($stories_topicid) ) { - $sql .= ' AND stories_topicid='.intval($stories_topicid); - } else { - $sql .= ' AND stories_ihome=0'; - if ($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(count($topics)>0) { - $topics = implode(',', $topics); - $sql .= ' AND stories_topicid IN ('.$topics.')'; - } else { - return null; - } - } - } - $result = $db->query($sql); - list($count) = $db->fetchRow($result); - return $count; - } - - - /** - * Internal function - */ - 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 . "'>"; - $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 .= "<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> ] "; - return $ret2; - } - - - /** - * Get the topic image url - */ - function topics_imgurl($format='S') - { - if(trim($this->topics_imgurl)=='') { - $this->topics_imgurl='blank.png'; - } - $myts =& MyTextSanitizer::getInstance(); - switch($format){ - case 'S': - $imgurl= $myts->htmlSpecialChars($this->topics_imgurl); - break; - case 'E': - $imgurl = $myts->htmlSpecialChars($this->topics_imgurl); - break; - case 'P': - $imgurl = $myts->stripSlashesGPC($this->topics_imgurl); - $imgurl = $myts->htmlSpecialChars($imgurl); - break; - case 'F': - $imgurl = $myts->stripSlashesGPC($this->topics_imgurl); - $imgurl = $myts->htmlSpecialChars($imgurl); - break; - } - return $imgurl; - } - - function topics_title($format='S') - { - $myts =& MyTextSanitizer::getInstance(); - switch($format){ - case 'S': - $title = $myts->htmlSpecialChars($this->topics_title); - break; - case 'E': - $title = $myts->htmlSpecialChars($this->topics_title); - break; - case 'P': - $title = $myts->stripSlashesGPC($this->topics_title); - $title = $myts->htmlSpecialChars($title); - break; - case 'F': - $title = $myts->stripSlashesGPC($this->topics_title); - $title = $myts->htmlSpecialChars($title); - break; - } - return $title; - } - - //DNPROSSI - Added picture substitute for topic images with article image - function imglink() - { - $topics_display = xnews_getmoduleoption('topicdisplay', NW_MODULE_DIR_NAME); - //DNPROSSI SEO - $seo_enabled = xnews_getmoduleoption('seo_enable', NW_MODULE_DIR_NAME); - $ret = ''; - $margin = ''; - if ( $this->topicalign() == 'left' ) { - $margin = "style='padding-right: 8px;'"; - } else { - $margin = "style='padding-left: 8px; padding-right: 5px'"; - } - - if(xoops_trim($this->picture()) == '') { - if ($this->topics_imgurl() != '' && file_exists(NW_TOPICS_FILES_PATH . '/'.$this->topics_imgurl())) { - 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) . "'>"; - $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>"; - } else { - $ret = "<img src='" . NW_TOPICS_FILES_URL . "/" . $this->topics_imgurl() . "' alt='" . $this->topics_title() . "' hspace='10' vspace='10' align='" . $this->topicalign() . "'" . $margin . " />"; - } - } - } else { - 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) . "'>"; - $ret .= "<img src='" . NW_TOPICS_FILES_URL . "/" . $this->picture() . "' alt='"; - $ret .= $this->topics_title() . "' hspace='10' vspace='10' align='"; - $ret .= $this->topicalign() . "'" . $margin . " /></a>"; - } else { - $ret = "<img src='" . NW_TOPICS_FILES_URL . "/" . $this->picture() . "' alt='" . $this->topics_title() . "' hspace='10' vspace='10' align='" . $this->topicalign() . "'" . $margin . " />"; - } - } - return $ret; - } - - function storylink() - { - $seo_enabled = xnews_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>"; - return $ret; - } - - function dobr() - { - return $this->dobr; - } - - function setDobr($value=0) - { - $this->dobr = $value; - } - - function textlink() - { - $topics_display = xnews_getmoduleoption('topicdisplay', NW_MODULE_DIR_NAME); - //DNPROSSI SEO - $seo_enabled = xnews_getmoduleoption('seo_enable', NW_MODULE_DIR_NAME); - $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>"; - - } - return $ret; - } - - /** - * Function used to prepare an article to be showed - */ - function prepare2show($filescount) - { - include_once NW_MODULE_PATH . '/include/functions.php'; - global $xoopsUser, $xoopsConfig, $xoopsModuleConfig; - $myts =& MyTextSanitizer::getInstance(); - $infotips = xnews_getmoduleoption('infotips', NW_MODULE_DIR_NAME); - //DNPROSSI SEO - $seo_enabled = xnews_getmoduleoption('seo_enable', NW_MODULE_DIR_NAME); - $story = array(); - $story['id'] = $this->stories_id(); - $story['poster'] = $this->uname(); - $story['author_name'] = $this->uname(); - $story['author_stories_uid'] = $this->stories_uid(); - if ( $story['poster'] != false ) { - $story['poster'] = "<a href='".XOOPS_URL."/userinfo.php?stories_uid=".$this->stories_uid()."'>".$story['poster']."</a>"; - } else { - if($xoopsModuleConfig['displayname']!=3) { - $story['poster'] = $xoopsConfig['anonymous']; - } - } - if ($xoopsModuleConfig['ratenews']) { - $story['rating'] = number_format($this->rating(), 2); - if ($this->stories_votes == 1) { - $story['stories_votes'] = _MA_NW_ONEVOTE; - } else { - $story['stories_votes'] = sprintf(_MA_NW_NUMVOTES,$this->stories_votes); - } - } - $story['posttimestamp'] = $this->stories_published(); - $story['posttime'] = formatTimestamp($story['posttimestamp'],xnews_getmoduleoption('dateformat', NW_MODULE_DIR_NAME)); - $story['topics_description'] = $myts->displayTarea($this->topics_description); - - $auto_summary = ''; - $tmp = ''; - $auto_summary = $this->auto_summary($this->bodytext(),$tmp); - - $story['text'] = $this->hometext(); - $story['text'] = str_replace('[summary]', $auto_summary, $story['text']); - - $introcount = strlen($story['text']); - $fullcount = strlen($this->bodytext()); - $totalcount = $introcount + $fullcount; - - $morelink = ''; - 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 (XOOPS_COMMENT_APPROVENONE != $xoopsModuleConfig['com_rule']) { - $morelink .= " | "; - } - } - if (XOOPS_COMMENT_APPROVENONE != $xoopsModuleConfig['com_rule']) { - $ccount = $this->comments(); - $story_path = ''; - //DNPROSSI SEO - if ( $seo_enabled != 0 ) $story_path = xnews_remove_accents($this->title()); - if ( $ccount == 0 ) { - $morelink .= _MA_NW_NO_COMMENT; - } else { - $morelink .= "<a href='" . xnews_seo_UrlGenerator(_MA_NW_SEO_ARTICLES, $this->stories_id(), $story_path); - if ( $ccount == 1 ) { - $morelink .= "'>"._MA_NW_ONECOMMENT."</a>"; - } else { - $morelink .= "'>"; - $morelink .= sprintf(_MA_NW_NUMCOMMENTS, $ccount); - $morelink .= "</a>"; - } - } - } - $story['morelink'] = $morelink; - $story['adminlink'] = ''; - - $approveprivilege = 0; - if(xnews_is_admin_group()) { - $approveprivilege = 1; - } - - if($xoopsModuleConfig['authoredit']==1 && (is_object($xoopsUser) && $xoopsUser->getVar('stories_uid')==$this->stories_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['imglink'] = ''; - $story['align'] = ''; - if ( $this->topicdisplay() ) { - $story['imglink'] = $this->imglink(); - $story['align'] = $this->topicalign(); - } - if($infotips>0) { - $story['infotips'] = ' title="'.xnews_make_infotips($this->hometext()).'"'; - } else { - $story['infotips'] = ''; - } - - //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($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>"; - } else { - $story['files_attached']= false; - $story['attached_link']=''; - } - return $story; - } - - /** - * Returns the user's name of the current story according to the module's option "displayname" - */ - function uname($stories_uid=0) - { - global $xoopsConfig; - include_once NW_MODULE_PATH . '/include/functions.php'; - static $tblusers = array(); - $option=-1; - if($stories_uid == 0) { - $stories_uid=$this->stories_uid(); - } - - if(is_array($tblusers) && array_key_exists($stories_uid,$tblusers)) { - return $tblusers[$stories_uid]; - } - - $option = xnews_getmoduleoption('displayname', NW_MODULE_DIR_NAME); - if (!$option) { - $option=1; - } - - switch($option) { - case 1: // Username - $tblusers[$stories_uid]=XoopsUser::getUnameFromId($stories_uid); - return $tblusers[$stories_uid]; - - case 2: // Display full name (if it is not empty) - $member_handler =& xoops_gethandler('member'); - $thisuser = $member_handler->getUser($stories_uid); - if (is_object($thisuser)) { - $return = $thisuser->getVar('name'); - if ($return == '') { - $return=$thisuser->getVar('uname'); - } - } else { - $return=$xoopsConfig['anonymous']; - } - $tblusers[$stories_uid]=$return; - return $return; - - case 3: // Nothing - $tblusers[$stories_uid]=''; - return ''; - } - } - - /** - * Function used to export news (in xml) and eventually the topics definitions - * Warning, permissions are not exported ! - * @param int $fromdate Starting date - * @param int $todate Ending date - * @param string $topiclist If not empty, a list of topics to limit to - * @param boolean $usetopicsdef Should we also export topics definitions ? - * @param boolean $asobject Return values as an object or not ? - */ - function NewsExport($fromdate, $todate, $topicslist='', $usetopicsdef=0, &$tbltopics, $asobject=true, $order = 'stories_published') - { - $ret=Array(); - $myts =& MyTextSanitizer::getInstance(); - if($usetopicsdef) { // We firt begin by exporting topics definitions - // Before all we must know wich topics to export - $sql = 'SELECT distinct stories_topicid FROM '.$this->db->prefix('xnews_stories').' WHERE (stories_published >=' . $fromdate . ' AND stories_published <= ' . $todate .')'; - if(strlen(trim($topicslist))>0) { - $sql .=' AND stories_topicid IN ('.$topicslist.')'; - } - $result = $this->db->query($sql); - while ( $myrow = $this->db->fetchArray($result) ) { - $tbltopics[]=$myrow['stories_topicid']; - } - } - - // Now we can search for the stories - $sql = 'SELECT s.*, t.* FROM '.$this->table.' s, '.$this->db->prefix('xnews_topics').' t WHERE (s.stories_topicid=t.topics_id) AND (s.stories_published >=' . $fromdate . ' AND s.stories_published <= ' . $todate .')'; - if(strlen(trim($topicslist))>0) { - $sql .=' AND stories_topicid IN ('.$topicslist.')'; - } - $sql .= " ORDER BY $order DESC"; - $result = $this->db->query($sql); - while ($myrow = $this->db->fetchArray($result)) { - if ($asobject) { - $ret[] = new xnews_NewsStory($myrow); - } else { - $ret[$myrow['stories_id']] = $myts->htmlSpecialChars($myrow['title']); - } - } - return $ret; - } - - - /** - * Create or update an article - */ - function store($approved=false) - { - $myts =& MyTextSanitizer::getInstance(); - $stories_counter = isset($this->stories_counter) ? $this->stories_counter : 0; - $title = $myts->censorString($this->title); - $title = $myts->addSlashes($title); - $hostname=$myts->addSlashes($this->hostname); - $type=$myts->addSlashes($this->type); - $hometext =$myts->addSlashes($myts->censorString($this->hometext)); - $bodytext =$myts->addSlashes($myts->censorString($this->bodytext)); - $description =$myts->addSlashes($myts->censorString($this->description)); - $keywords =$myts->addSlashes($myts->censorString($this->keywords)); - $picture = $myts->addSlashes($this->picture); - $tags = $myts->addSlashes($this->tags); - $stories_votes= intval($this->stories_votes); - $rating = (float)($this->rating); - if (!isset($this->nohtml) || $this->nohtml != 1) { - $this->nohtml = 0; - } - if (!isset($this->nosmiley) || $this->nosmiley != 1) { - $this->nosmiley = 0; - } - if (!isset($this->dobr) || $this->dobr != 1) { - $this->dobr = 0; - } - if (!isset($this->notifypub) || $this->notifypub != 1) { - $this->notifypub = 0; - } - if(!isset($this->topicdisplay) || $this->topicdisplay != 0) { - $this->topicdisplay = 1; - } - $stories_expired = !empty($this->stories_expired) ? $this->stories_expired : 0; - if (!isset($this->stories_id)) { - //$newpost = 1; - $newstories_id = $this->db->genId($this->table.'_stories_id_seq'); - $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())); - } 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()); - } - if (!$this->db->queryF($sql)) { - return false; - } - if (empty($newstories_id)) { - $newstories_id = $this->db->getInsertId(); - $this->stories_id = $newstories_id; - } - return $newstories_id; - } - - function picture() - { - return $this->picture; - } - - //DNPROSSI - 1.71 - function imagerows() - { - return $this->imagerows; - } - - function Setimagerows($imagerows) - { - $this->imagerows = $imagerows; - } - - //DNPROSSI - 1.71 - function pdfrows() - { - return $this->pdfrows; - } - - function Setpdfrows($pdfrows) - { - $this->pdfrows = $pdfrows; - } - - function rating() - { - return $this->rating; - } - - function stories_votes() - { - return $this->stories_votes; - } - - function tags() - { - return $this->tags; - } - - function Settags($tags) - { - $this->tags = $tags; - } - - function Setpicture($data) - { - $this->picture = $data; - } - - function Setdescription($data) - { - $this->description=$data; - } - - function Setkeywords($data) - { - $this->keywords=$data; - } - - function description($format='S') - { - $myts =& MyTextSanitizer::getInstance(); - switch(strtoupper($format)) { - case 'S': - $description= $myts->htmlSpecialChars($this->description); - break; - case 'P': - case 'F': - $description = $myts->htmlSpecialChars($myts->stripSlashesGPC($this->description)); - break; - case 'E': - $description = $myts->htmlSpecialChars($this->description); - break; - } - return $description; - } - - function keywords($format='S') - { - $myts =& MyTextSanitizer::getInstance(); - switch(strtoupper($format)) { - case 'S': - $keywords= $myts->htmlSpecialChars($this->keywords); - break; - case 'P': - case 'F': - $keywords = $myts->htmlSpecialChars($myts->stripSlashesGPC($this->keywords)); - break; - case 'E': - $keywords = $myts->htmlSpecialChars($this->keywords); - break; - } - return $keywords; - } - - /** - * Returns a random number of news - */ - function getRandomNews($limit=0, $start=0, $checkRight=false, $topic=0, $stories_ihome=0, $order='stories_published', $topics_frontpage=false) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $ret = $rand_keys = $ret3 = array(); - $sql = 'SELECT stories_id FROM '.$db->prefix('xnews_stories').' WHERE (stories_published > 0 AND stories_published <= '.time().') AND (stories_expired = 0 OR stories_expired > '.time().')'; - if ($topic != 0) { - if (!is_array($topic)) { - if($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(!in_array ($topic,$topics)) { - return null; - } else { - $sql .= ' AND stories_topicid='.intval($topic).' AND (stories_ihome=1 OR stories_ihome=0)'; - } - } else { - $sql .= ' AND stories_topicid='.intval($topic).' AND (stories_ihome=1 OR stories_ihome=0)'; - } - } else { - if(count($topic)>0) { - $sql .= ' AND stories_topicid IN ('.implode(',', $topic).')'; - } else { - return null; - } - } - } else { - if($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(count($topics)>0) { - $topics = implode(',', $topics); - $sql .= ' AND stories_topicid IN ('.$topics.')'; - } else { - return null; - } - } - if (intval($stories_ihome) == 0) { - $sql .= ' AND stories_ihome=0'; - } - } - if($topics_frontpage) { - $sql .=' AND t.topics_frontpage=1'; - } - $sql .= " ORDER BY $order DESC"; - $result = $db->query($sql); - - while ( $myrow = $db->fetchArray($result) ) { - $ret[] = $myrow['stories_id']; - } - $cnt=count($ret); - if($cnt) { - srand ((double) microtime() * 10000000); - if($limit>$cnt) { - $limit=$cnt; - } - $rand_keys = array_rand($ret, $limit); - if($limit>1) { - for($i=0;$i<$limit;$i++) { - $onestory=$ret[$rand_keys[$i]]; - $ret3[]= new xnews_NewsStory($onestory); - } - } else { - $ret3[]= new xnews_NewsStory($ret[$rand_keys]); - } - } - return $ret3; - } - - - - /** - * Returns statistics about the stories and topics - */ - function GetStats($limit) - { - $ret=array(); - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $tbls=$db->prefix('xnews_stories'); - $tblt=$db->prefix('xnews_topics'); - $tblf=$db->prefix('xnews_stories_files'); - - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - // Number of stories per topic, including stories_expired and non stories_published stories - $ret2=array(); - $sql="SELECT count(s.stories_id) as cpt, s.stories_topicid, t.topics_title FROM $tbls s, $tblt t WHERE s.stories_topicid=t.topics_id GROUP BY s.stories_topicid ORDER BY t.topics_title"; - $result = $db->query($sql); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_topicid']]=$myrow; - } - $ret['storiespertopic']=$ret2; - unset($ret2); - - // Total of reads per topic - $ret2=array(); - $sql="SELECT Sum(stories_counter) as cpt, stories_topicid FROM $tbls GROUP BY stories_topicid ORDER BY stories_topicid"; - $result = $db->query($sql); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_topicid']]=$myrow['cpt']; - } - $ret['readspertopic']=$ret2; - unset($ret2); - - // Attached files per topic - $ret2=array(); - $sql="SELECT Count(*) as cpt, s.stories_topicid FROM $tblf f, $tbls s WHERE f.stories_id=s.stories_id GROUP BY s.stories_topicid ORDER BY s.stories_topicid"; - $result = $db->query($sql); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_topicid']]=$myrow['cpt']; - } - $ret['filespertopic']=$ret2; - unset($ret2); - - // Expired articles per topic - $ret2=array(); - $sql="SELECT Count(stories_id) as cpt, stories_topicid FROM $tbls WHERE stories_expired>0 AND stories_expired<=".time()." GROUP BY stories_topicid ORDER BY stories_topicid"; - $result = $db->query($sql); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_topicid']]=$myrow['cpt']; - } - $ret['stories_expiredpertopic']=$ret2; - unset($ret2); - - // Number of unique authors per topic - $ret2=array(); - $sql="SELECT Count(Distinct(stories_uid)) as cpt, stories_topicid FROM $tbls GROUP BY stories_topicid ORDER BY stories_topicid"; - $result = $db->query($sql); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_topicid']]=$myrow['cpt']; - } - $ret['authorspertopic']=$ret2; - unset($ret2); - - // Most readed articles - $ret2=array(); - $sql="SELECT s.stories_id, s.stories_uid, s.title, s.stories_counter, s.stories_topicid, t.topics_title FROM $tbls s, $tblt t WHERE s.stories_topicid=t.topics_id ORDER BY s.stories_counter DESC"; - $result = $db->query($sql,intval($limit)); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_id']]=$myrow; - } - $ret['mostreadnews']=$ret2; - unset($ret2); - - // Less readed articles - $ret2=array(); - $sql="SELECT s.stories_id, s.stories_uid, s.title, s.stories_counter, s.stories_topicid, t.topics_title FROM $tbls s, $tblt t WHERE s.stories_topicid=t.topics_id ORDER BY s.stories_counter"; - $result = $db->query($sql,intval($limit)); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_id']]=$myrow; - } - $ret['lessreadnews']=$ret2; - unset($ret2); - - // Best rated articles - $ret2=array(); - $sql="SELECT s.stories_id, s.stories_uid, s.title, s.rating, s.stories_topicid, t.topics_title FROM $tbls s, $tblt t WHERE s.stories_topicid=t.topics_id ORDER BY s.rating DESC"; - $result = $db->query($sql,intval($limit)); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_id']]=$myrow; - } - $ret['besratednw']=$ret2; - unset($ret2); - - // Most readed authors - $ret2=array(); - $sql="SELECT Sum(stories_counter) as cpt, stories_uid FROM $tbls GROUP BY stories_uid ORDER BY cpt DESC"; - $result = $db->query($sql,intval($limit)); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_uid']]=$myrow['cpt']; - } - $ret['mostreadedauthors']=$ret2; - unset($ret2); - - // Best rated authors - $ret2=array(); - $sql="SELECT Avg(rating) as cpt, stories_uid FROM $tbls WHERE stories_votes > 0 GROUP BY stories_uid ORDER BY cpt DESC"; - $result = $db->query($sql,intval($limit)); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_uid']]=$myrow['cpt']; - } - $ret['bestratedauthors']=$ret2; - unset($ret2); - - // Biggest contributors - $ret2=array(); - $sql="SELECT Count(*) as cpt, stories_uid FROM $tbls GROUP BY stories_uid ORDER BY cpt DESC"; - $result = $db->query($sql,intval($limit)); - while ($myrow = $db->fetchArray($result) ) { - $ret2[$myrow['stories_uid']]=$myrow['cpt']; - } - $ret['biggestcontributors']=$ret2; - unset($ret2); - - return $ret; - } - - - /** - * Get the date of the older and most recent news - */ - function GetOlderRecentnews(&$older, &$recent) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT min(stories_published) as minpublish, max(stories_published) as maxpublish FROM '.$db->prefix('xnews_stories'); - $result = $db->query($sql); - if(!$result) { - $older = $recent = 0; - } else { - list($older, $recent) = $this->db->fetchRow($result); - } - } - - - /* - * Returns the author's IDs for the Who's who page - */ - function getWhosWho($checkRight=false, $limit=0, $start=0) - { - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $ret = array(); - $sql = 'SELECT distinct(stories_uid) as stories_uid FROM '.$db->prefix('xnews_stories').' WHERE (stories_published > 0 AND stories_published <= '.time().') AND (stories_expired = 0 OR stories_expired > '.time().')'; - if($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(count($topics)>0) { - $topics = implode(',', $topics); - $sql .= ' AND stories_topicid IN ('.$topics.')'; - } else { - return null; - } - } - $sql .= " ORDER BY stories_uid"; - $result = $db->query($sql); - while ( $myrow = $db->fetchArray($result) ) { - $ret[] = $myrow['stories_uid']; - } - return $ret; - } - - - /** - * Returns the content of the summary and the titles requires for the list selector - */ - function auto_summary($text, &$titles) - { - $auto_summary = ''; - if(xnews_getmoduleoption('enhanced_pagenav', NW_MODULE_DIR_NAME)) { - $expr_matches = array(); - $posdeb = preg_match_all('/(\[pagebreak:|\[pagebreak).*\]/iU', $text, $expr_matches); - if(count($expr_matches) > 0) { - $delimiters = $expr_matches[0]; - $arr_search = array('[pagebreak:', '[pagebreak', ']'); - $arr_replace = array('', '', ''); - $cpt = 1; - if(isset($titles) && is_array($titles)) { - $titles[] = strip_tags(sprintf(_MA_NW_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 />'; - $auto_summary .= $item; - - foreach($delimiters as $item) { - $cpt++; - $item = str_replace($arr_search, $arr_replace, $item); - 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 />'; - $auto_summary .= $item; - } - } - } - return $auto_summary; - } - - function hometext($format = 'Show') - { - $myts =& MyTextSanitizer::getInstance(); - $html = $smiley = $xcodes = 1; - $dobr = 0; - if ( $this->nohtml() ) { - $html = 0; - } - if ( $this->nosmiley() ) { - $smiley = 0; - } - if ( $this->dobr() ) { - $dobr = 1; - } - switch ( $format ) { - case 'Show': - $hometext = $myts->displayTarea($this->hometext,$html,$smiley,1,1,$dobr); - $tmp = ''; - $auto_summary = $this->auto_summary($this->bodytext('Show'),$tmp); - $hometext = str_replace('[summary]', $auto_summary, $hometext); - break; - case 'Edit': - $hometext = $myts->htmlSpecialChars($this->hometext); - break; - case 'Preview': - $hometext = $myts->previewTarea($this->hometext,$html,$smiley,1,1,$dobr); - break; - case 'InForm': - $hometext = $myts->stripSlashesGPC($this->hometext); - $hometext = $myts->htmlSpecialChars($hometext); - break; - } - return $hometext; - } - - function bodytext($format = 'Show') - { - $myts =& MyTextSanitizer::getInstance(); - $html = 1; - $smiley = 1; - $xcodes = 1; - $dobr = 0; - if ( $this->nohtml() ) { - $html = 0; - } - if ( $this->nosmiley() ) { - $smiley = 0; - } - if ( $this->dobr() ) { - $dobr = 1; - } - switch ( $format ) { - case 'Show': - $bodytext = $myts->displayTarea($this->bodytext,$html,$smiley,1,1,$dobr); - $tmp = ''; - $auto_summary = $this->auto_summary($bodytext,$tmp); - $bodytext = str_replace('[summary]', $auto_summary, $bodytext); - break; - case 'Edit': - $bodytext = $myts->htmlSpecialChars($this->bodytext); - break; - case 'Preview': - $bodytext = $myts->previewTarea($this->bodytext,$html,$smiley,1,1,$dobr); - break; - case 'InForm': - $bodytext = $myts->stripSlashesGPC($this->bodytext); - $bodytext = $myts->htmlSpecialChars($bodytext); - break; - } - return $bodytext; - } - - /** - * Returns stories by Ids - */ - function getStoriesByIds($ids, $checkRight = true, $asobject = true, $order = 'stories_published', $onlyOnline = true) - { - $limit = $start = 0; - $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $myts =& MyTextSanitizer::getInstance(); - $ret = array(); - $sql = 'SELECT s.*, t.* FROM '.$db->prefix('xnews_stories').' s, '. $db->prefix('xnews_topics').' t WHERE '; - if(is_array($ids) && count($ids) > 0) { - array_walk($ids, 'intval'); - } - $sql .= ' s.stories_id IN ('.implode(',', $ids).') '; - - if($onlyOnline) { - $sql .= ' AND (s.stories_published > 0 AND s.stories_published <= '.time().') AND (s.stories_expired = 0 OR s.stories_expired > '.time().') '; - } - $sql .= ' AND (s.stories_topicid=t.topics_id) '; - if($checkRight) { - $topics = xnews_MygetItemIds('xnews_view'); - if(count($topics)>0) { - $topics = implode(',', $topics); - $sql .= ' AND s.stories_topicid IN ('.$topics.')'; - } else { - return null; - } - } - $sql .= " ORDER BY s.$order DESC"; - $result = $db->query($sql,intval($limit),intval($start)); - - while ( $myrow = $db->fetchArray($result) ) { - if ($asobject) { - $ret[$myrow['stories_id']] = new xnews_NewsStory($myrow); - } else { - $ret[$myrow['stories_id']] = $myts->htmlSpecialChars($myrow['title']); - } - } - return $ret; - } - - //ADDED by wishcraft ver 1.89 - function xnews_stripeKey($xoops_key, $num = 7, $length = 32, $uu = 0) - { - $strip = floor(strlen($xoops_key) / $num); - for ($i = 0; $i < strlen($xoops_key); $i++) { - if ($i < $length) { - $uu++; - if ($uu == $strip) { - $ret .= substr($xoops_key, $i, 1) . '-'; - $uu = 0; - } else { - if (substr($xoops_key, $i, 1) != '-') { - $ret .= substr($xoops_key, $i, 1); - } else { - $uu--; - } - } - } - } - $ret = str_replace('--', '-', $ret); - if (substr($ret, 0, 1) == '-') { - $ret = substr($ret, 2, strlen($ret)); - } - if (substr($ret, strlen($ret) - 1, 1) == '-') { - $ret = substr($ret, 0, strlen($ret) - 1); - } - return $ret; - } -} -?> Deleted: XoopsModules/xnews/trunk/timgno/xnews/class/class.newstopic.php~ =================================================================== --- XoopsModules/xnews/trunk/timgno/xnews/class/class.newstopic.php~ 2012-01-31 18:20:32 UTC (rev 8849) +++ XoopsModules/xnews/trunk/timgno/xnews/class/class.newstopic.php~ 2012-01-31 18:23:32 UTC (rev 8850) @@ -1,519 +0,0 @@ -<?php -// $Id: class.newstopic.php,v 1.9 2004/09/02 17:04:08 hthouzard Exp $ -// ------------------------------------------------------------------------ // -// XOOPS - PHP Content Management System // -// Copyright (c) 2000 XOOPS.org // -// <http://www.xoops.org/> // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -if (!defined('XOOPS_ROOT_PATH')) { - die("XOOPS root path not defined"); -} - -include_once XOOPS_ROOT_PATH."/class/xoopsstory.php"; -include_once XOOPS_ROOT_PATH."/class/xoopstree.php"; -include_once NW_MODULE_PATH . "/include/functions.php"; - -class xnews_NewsTopic extends XoopsTopic -{ - var $menu; - var $topics_description; - var $topics_frontpage; - var $topics_rssurl; - var $topics_color; - - function xnews_NewsTopic($topicid=0) - { - $this->db =& Database::getInstance(); - $this->table = $this->db->prefix('xnews_topics'); - if ( is_array($topicid) ) { - $this->makeTopic($topicid); - } elseif ( $topicid != 0 ) { - $this->getTopic(intval($topicid)); - } else { - $this->topics_id = $topicid; - } - } - - function MakeMyTopicSelBox($none=0, $seltopic=-1, $selname="", $onchange="", $checkRight = false, $perm_type='xnews_view') - { - $perms=''; - if ($checkRight) { - global $xoopsUser; - $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($perm_type, $groups, $newsModule->getVar('mid')); - if(count($topics)>0) { - $topics = implode(',', $topics); - $perms = " AND topics_id IN (".$topics.") "; - } else { - return null; - } - } - - if ( $seltopic != -1 ) { - return $this->makeMySelBox("topics_title", "topics_title", $seltopic, $none, $selname, $onchange, $perms); - } elseif ( !empty($this->topics_id) ) { - return $this->makeMySelBox("topics_title", "topics_title", $this->topics_id, $none, $selname, $onchange, $perms); - } else { - return $this->makeMySelBox("topics_title", "topics_title", 0, $none, $selname, $onchange, $perms); - } - } - - /** - * makes a nicely ordered selection box - * - * @param int $preset_id is used to specify a preselected item - * @param int $none set $none to 1 to add a option with value 0 - */ - function makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="topics_id", $onchange="", $perms) - { - $myts =& MyTextSanitizer::getInsta... [truncated message content] |