## ## Modified By 2005 CACHE RSSfitJ ## ## ## ############################################################################### ## XOOPS - PHP Content Management System ## ## Copyright (c) 2000 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 ## ############################################################################### ## Author of this file: CACHE ## ## URL: http://gyakubiki.kir.jp/ ## ## Project: RSSFitJ ## ############################################################################### /* * Step 0: Stop here if you are not sure what you are doing, it's no fun at all * Step 1: Clone this file and rename as rssfitj.[mod_dir].php * Step 2: Replace the text "RssfitjSample" with "Rssfitj[mod_dir]" at line 47 and line 55, i.e. "RssfitjNews" for the module "News" * Step 3: Modify the word in line 48 from 'sample' to [mod_dir] * Step 4: Modify the function "grabEntries" to satisfy your needs * Step 5: Move the new plug-in file to the plugins folder, i.e. your-xoops-root/modules/rss/plugins * Step 6: Install your plug-in by pointing your browser to your-xoops-url/modules/rss/admin/index.php * [mod_dir]: Name of the driectory of your module, i.e. 'news' */ class RssfitjXoopsfaq{ var $dirname = 'xoopsfaq'; var $modname; /* * private * Nothing here so far */ function RssfitjXoopsfaq(){ } /* * public * return module name */ function getDirName(){ return $this->dirname; } /* * private * Load the module */ function loadModule(){ global $module_handler; $mod = $module_handler->getByDirname($this->dirname); if( !$mod || !$mod->getVar('isactive') ){ return false; } $this->modname = $mod->getVar('name'); return $mod; } /* * public * Grab the entries of your module here */ function grabEntries(&$obj){ global $xoopsDB; $myts =& MyTextSanitizer::getInstance(); $ret = array(); $i = 0; if ($obj->getVar('rssfj_param')) { $rcdId=explode(',',$obj->getVar('rssfj_param')); $Tarray=array(); $tarray=array(); $Carray=array(); $carray=array(); foreach ($rcdId as $eachId) { if (substr($eachId,0,1)=='T') array_push($Tarray,substr($eachId,1,strlen($eachId)-1)); if (substr($eachId,0,1)=='N' || substr($eachId,0,1)=='t') array_push($tarray,substr($eachId,1,strlen($eachId)-1)); if (substr($eachId,0,1)=='C') array_push($Carray,substr($eachId,1,strlen($eachId)-1)); if (substr($eachId,0,1)=='c') array_push($carray,substr($eachId,1,strlen($eachId)-1)); } $add_sql=""; if (count($Tarray)) { $add_sql.=" AND ("; foreach($Tarray as $TopicId) { $add_sql .= "l.contents_id=".$TopicId." OR "; } $add_sql = substr($add_sql,0,strlen($add_sql)-4); $add_sql .= ")"; } if (count($tarray)) { $add_sql.=" AND NOT("; foreach($tarray as $TopicId) { $add_sql .= "l.contents_id=".$TopicId." OR "; } $add_sql = substr($add_sql,0,strlen($add_sql)-4); $add_sql .= ")"; } if (count($Carray)) { $add_sql.=" AND ("; foreach($Carray as $CatId) { $add_sql .= "l.category_id=".$CatId." OR "; } $add_sql = substr($add_sql,0,strlen($add_sql)-4); $add_sql .= ")"; } if (count($carray)) { $add_sql.=" AND NOT("; foreach($carray as $CatId) { $add_sql .= "l.category_id=".$CatId." OR "; } $add_sql = substr($add_sql,0,strlen($add_sql)-4); $add_sql .= ")"; } } else { $add_sql=""; } // The following example code grabs the latest entries from the module MyLinks $sql = "SELECT l.contents_id, l.contents_order, l.category_id, l.contents_title, l.contents_contents, l.contents_time, c.category_id, c.category_title FROM ".$xoopsDB->prefix("xoopsfaq_contents")." l, ".$xoopsDB->prefix("xoopsfaq_categories")." c WHERE l.category_id=c.category_id".$add_sql." ORDER BY l.contents_time DESC"; $result = $xoopsDB->query($sql, $obj->getVar('rssfj_grab'), 0); while( $row = $xoopsDB->fetchArray($result) ){ // required items $link = XOOPS_URL.'/modules/'.$this->dirname.'/index.php?cat_id='.$row['category_id'].'#q'.$row['contents_id']; // The title of the item $desc=$this->modname." : ".$row['category_title'].">>".$row['contents_title']; $ret[$i]['title'] = $myts->makeTareaData4Show($desc); $ret[$i]['link'] = $link; // The URL of the item $ret[$i]['guid'] = $link; // Unique identifier, usually url $ret[$i]['timestamp'] = $row['contents_time']; // Item modification date, // must be in Unix time format $desc = $row['contents_contents']; // The item synopsis, or // description, whatever $ret[$i]['description'] = $myts->makeTareaData4Show($desc); // optional items $ret[$i]['category'] = $this->modname; $ret[$i]['domain'] = XOOPS_URL.'/modules/'.$this->dirname.'/'; $i++; } return $ret; } } ?>