| 1 | <?php |
|---|
| 2 | ############################################################################### |
|---|
| 3 | ## RSSFit - Extendable XML news feed generator ## |
|---|
| 4 | ## Copyright (c) 2004 NS Tai (aka tuff) ## |
|---|
| 5 | ## <http://www.brandycoke.com/> ## |
|---|
| 6 | ## Modified By 2005 CACHE RSSfitJ ## |
|---|
| 7 | ## <http://gyakubiki.kir.jp/> ## |
|---|
| 8 | ############################################################################### |
|---|
| 9 | ## XOOPS - PHP Content Management System ## |
|---|
| 10 | ## Copyright (c) 2000 XOOPS.org ## |
|---|
| 11 | ## <http://www.xoops.org/> ## |
|---|
| 12 | ############################################################################### |
|---|
| 13 | ## This program is free software; you can redistribute it and/or modify ## |
|---|
| 14 | ## it under the terms of the GNU General Public License as published by ## |
|---|
| 15 | ## the Free Software Foundation; either version 2 of the License, or ## |
|---|
| 16 | ## (at your option) any later version. ## |
|---|
| 17 | ## ## |
|---|
| 18 | ## You may not change or alter any portion of this comment or credits ## |
|---|
| 19 | ## of supporting developers from this source code or any supporting ## |
|---|
| 20 | ## source code which is considered copyrighted (c) material of the ## |
|---|
| 21 | ## original comment or credit authors. ## |
|---|
| 22 | ## ## |
|---|
| 23 | ## This program is distributed in the hope that it will be useful, ## |
|---|
| 24 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## |
|---|
| 25 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## |
|---|
| 26 | ## GNU General Public License for more details. ## |
|---|
| 27 | ## ## |
|---|
| 28 | ## You should have received a copy of the GNU General Public License ## |
|---|
| 29 | ## along with this program; if not, write to the Free Software ## |
|---|
| 30 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## |
|---|
| 31 | ############################################################################### |
|---|
| 32 | ## Author of this file: CACHE ## |
|---|
| 33 | ## URL: http://gyakubiki.kir.jp/ ## |
|---|
| 34 | ## Project: RSSFitJ ## |
|---|
| 35 | ############################################################################### |
|---|
| 36 | /* |
|---|
| 37 | * Step 0: Stop here if you are not sure what you are doing, it's no fun at all |
|---|
| 38 | * Step 1: Clone this file and rename as rssfitj.[mod_dir].php |
|---|
| 39 | * Step 2: Replace the text "RssfitjSample" with "Rssfitj[mod_dir]" at line 47 and line 55, i.e. "RssfitjNews" for the module "News" |
|---|
| 40 | * Step 3: Modify the word in line 48 from 'sample' to [mod_dir] |
|---|
| 41 | * Step 4: Modify the function "grabEntries" to satisfy your needs |
|---|
| 42 | * Step 5: Move the new plug-in file to the plugins folder, i.e. your-xoops-root/modules/rss/plugins |
|---|
| 43 | * Step 6: Install your plug-in by pointing your browser to your-xoops-url/modules/rss/admin/index.php |
|---|
| 44 | * [mod_dir]: Name of the driectory of your module, i.e. 'news' |
|---|
| 45 | */ |
|---|
| 46 | |
|---|
| 47 | class RssfitjXoopsfaq{ |
|---|
| 48 | var $dirname = 'xoopsfaq'; |
|---|
| 49 | var $modname; |
|---|
| 50 | |
|---|
| 51 | /* |
|---|
| 52 | * private |
|---|
| 53 | * Nothing here so far |
|---|
| 54 | */ |
|---|
| 55 | function RssfitjXoopsfaq(){ |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | /* |
|---|
| 59 | * public |
|---|
| 60 | * return module name |
|---|
| 61 | */ |
|---|
| 62 | function getDirName(){ |
|---|
| 63 | return $this->dirname; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | /* |
|---|
| 67 | * private |
|---|
| 68 | * Load the module |
|---|
| 69 | */ |
|---|
| 70 | function loadModule(){ |
|---|
| 71 | global $module_handler; |
|---|
| 72 | $mod = $module_handler->getByDirname($this->dirname); |
|---|
| 73 | if( !$mod || !$mod->getVar('isactive') ){ |
|---|
| 74 | return false; |
|---|
| 75 | } |
|---|
| 76 | $this->modname = $mod->getVar('name'); |
|---|
| 77 | return $mod; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | /* |
|---|
| 81 | * public |
|---|
| 82 | * Grab the entries of your module here |
|---|
| 83 | */ |
|---|
| 84 | function grabEntries(&$obj){ |
|---|
| 85 | global $xoopsDB; |
|---|
| 86 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 87 | $ret = array(); |
|---|
| 88 | $i = 0; |
|---|
| 89 | |
|---|
| 90 | if ($obj->getVar('rssfj_param')) { |
|---|
| 91 | $rcdId=explode(',',$obj->getVar('rssfj_param')); |
|---|
| 92 | $Tarray=array(); |
|---|
| 93 | $tarray=array(); |
|---|
| 94 | $Carray=array(); |
|---|
| 95 | $carray=array(); |
|---|
| 96 | foreach ($rcdId as $eachId) { |
|---|
| 97 | if (substr($eachId,0,1)=='T') |
|---|
| 98 | array_push($Tarray,substr($eachId,1,strlen($eachId)-1)); |
|---|
| 99 | if (substr($eachId,0,1)=='N' || substr($eachId,0,1)=='t') |
|---|
| 100 | array_push($tarray,substr($eachId,1,strlen($eachId)-1)); |
|---|
| 101 | if (substr($eachId,0,1)=='C') |
|---|
| 102 | array_push($Carray,substr($eachId,1,strlen($eachId)-1)); |
|---|
| 103 | if (substr($eachId,0,1)=='c') |
|---|
| 104 | array_push($carray,substr($eachId,1,strlen($eachId)-1)); |
|---|
| 105 | } |
|---|
| 106 | $add_sql=""; |
|---|
| 107 | if (count($Tarray)) { |
|---|
| 108 | $add_sql.=" AND ("; |
|---|
| 109 | foreach($Tarray as $TopicId) { |
|---|
| 110 | $add_sql .= "l.contents_id=".$TopicId." OR "; |
|---|
| 111 | } |
|---|
| 112 | $add_sql = substr($add_sql,0,strlen($add_sql)-4); |
|---|
| 113 | $add_sql .= ")"; |
|---|
| 114 | } |
|---|
| 115 | if (count($tarray)) { |
|---|
| 116 | $add_sql.=" AND NOT("; |
|---|
| 117 | foreach($tarray as $TopicId) { |
|---|
| 118 | $add_sql .= "l.contents_id=".$TopicId." OR "; |
|---|
| 119 | } |
|---|
| 120 | $add_sql = substr($add_sql,0,strlen($add_sql)-4); |
|---|
| 121 | $add_sql .= ")"; |
|---|
| 122 | } |
|---|
| 123 | if (count($Carray)) { |
|---|
| 124 | $add_sql.=" AND ("; |
|---|
| 125 | foreach($Carray as $CatId) { |
|---|
| 126 | $add_sql .= "l.category_id=".$CatId." OR "; |
|---|
| 127 | } |
|---|
| 128 | $add_sql = substr($add_sql,0,strlen($add_sql)-4); |
|---|
| 129 | $add_sql .= ")"; |
|---|
| 130 | } |
|---|
| 131 | if (count($carray)) { |
|---|
| 132 | $add_sql.=" AND NOT("; |
|---|
| 133 | foreach($carray as $CatId) { |
|---|
| 134 | $add_sql .= "l.category_id=".$CatId." OR "; |
|---|
| 135 | } |
|---|
| 136 | $add_sql = substr($add_sql,0,strlen($add_sql)-4); |
|---|
| 137 | $add_sql .= ")"; |
|---|
| 138 | } |
|---|
| 139 | } else { |
|---|
| 140 | $add_sql=""; |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | // The following example code grabs the latest entries from the module MyLinks |
|---|
| 144 | $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"; |
|---|
| 145 | |
|---|
| 146 | $result = $xoopsDB->query($sql, $obj->getVar('rssfj_grab'), 0); |
|---|
| 147 | while( $row = $xoopsDB->fetchArray($result) ){ |
|---|
| 148 | // required items |
|---|
| 149 | $link = XOOPS_URL.'/modules/'.$this->dirname.'/index.php?cat_id='.$row['category_id'].'#q'.$row['contents_id']; |
|---|
| 150 | // The title of the item |
|---|
| 151 | $desc=$this->modname." : ".$row['category_title'].">>".$row['contents_title']; |
|---|
| 152 | $ret[$i]['title'] = $myts->makeTareaData4Show($desc); |
|---|
| 153 | $ret[$i]['link'] = $link; // The URL of the item |
|---|
| 154 | $ret[$i]['guid'] = $link; // Unique identifier, usually url |
|---|
| 155 | $ret[$i]['timestamp'] = $row['contents_time']; // Item modification date, |
|---|
| 156 | // must be in Unix time format |
|---|
| 157 | $desc = $row['contents_contents']; // The item synopsis, or |
|---|
| 158 | // description, whatever |
|---|
| 159 | $ret[$i]['description'] = $myts->makeTareaData4Show($desc); |
|---|
| 160 | // optional items |
|---|
| 161 | $ret[$i]['category'] = $this->modname; |
|---|
| 162 | $ret[$i]['domain'] = XOOPS_URL.'/modules/'.$this->dirname.'/'; |
|---|
| 163 | |
|---|
| 164 | $i++; |
|---|
| 165 | } |
|---|
| 166 | return $ret; |
|---|
| 167 | } |
|---|
| 168 | } |
|---|
| 169 | ?> |
|---|