| 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 48 and line 56, i.e. "RssfitjNews" for the module "News" |
|---|
| 40 | * Step 3: Modify the word in line 49 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 | if (file_exists(XOOPS_ROOT_PATH.'/modules/xfsection/include/groupaccess.php')) |
|---|
| 47 | include_once XOOPS_ROOT_PATH.'/modules/xfsection/include/groupaccess.php'; |
|---|
| 48 | class RssfitjXfsection{ |
|---|
| 49 | var $dirname = 'xfsection'; |
|---|
| 50 | var $modname; |
|---|
| 51 | |
|---|
| 52 | /* |
|---|
| 53 | * private |
|---|
| 54 | * Nothing here so far |
|---|
| 55 | */ |
|---|
| 56 | function RssfitjXfsection(){ |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | /* |
|---|
| 60 | * public |
|---|
| 61 | * return module name |
|---|
| 62 | */ |
|---|
| 63 | function getDirName(){ |
|---|
| 64 | return $this->dirname; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | /* |
|---|
| 68 | * private, do not modify |
|---|
| 69 | * Load the module |
|---|
| 70 | */ |
|---|
| 71 | function loadModule(){ |
|---|
| 72 | global $module_handler; |
|---|
| 73 | $mod = $module_handler->getByDirname($this->dirname); |
|---|
| 74 | if( !$mod || !$mod->getVar('isactive') ){ |
|---|
| 75 | return false; |
|---|
| 76 | } |
|---|
| 77 | $this->modname = $mod->getVar('name'); |
|---|
| 78 | return $mod; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | /* |
|---|
| 82 | * public |
|---|
| 83 | * Grab the entries of your module here |
|---|
| 84 | */ |
|---|
| 85 | function grabEntries(&$obj){ |
|---|
| 86 | global $xoopsDB; |
|---|
| 87 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 88 | $ret = array(); |
|---|
| 89 | $i = 0; |
|---|
| 90 | |
|---|
| 91 | if ($obj->getVar('rssfj_param')) { |
|---|
| 92 | $rcdId=explode(',',$obj->getVar('rssfj_param')); |
|---|
| 93 | $tarray=array(); |
|---|
| 94 | $Tarray=array(); |
|---|
| 95 | $Carray=array(); |
|---|
| 96 | $carray=array(); |
|---|
| 97 | foreach ($rcdId as $eachId) { |
|---|
| 98 | if (substr($eachId,0,1)=='T') |
|---|
| 99 | array_push($Tarray,substr($eachId,1,strlen($eachId)-1)); |
|---|
| 100 | if (substr($eachId,0,1)=='N' || substr($eachId,0,1)=='t') |
|---|
| 101 | array_push($tarray,substr($eachId,1,strlen($eachId)-1)); |
|---|
| 102 | if (substr($eachId,0,1)=='C') |
|---|
| 103 | array_push($Carray,substr($eachId,1,strlen($eachId)-1)); |
|---|
| 104 | if (substr($eachId,0,1)=='c') |
|---|
| 105 | array_push($carray,substr($eachId,1,strlen($eachId)-1)); |
|---|
| 106 | } |
|---|
| 107 | $add_sql=""; |
|---|
| 108 | if (count($Tarray)) { |
|---|
| 109 | $add_sql.=" AND ("; |
|---|
| 110 | foreach($Tarray as $TopicId) { |
|---|
| 111 | $add_sql .= "a.articleid=".$TopicId." OR "; |
|---|
| 112 | } |
|---|
| 113 | $add_sql = substr($add_sql,0,strlen($add_sql)-4); |
|---|
| 114 | $add_sql .= ")"; |
|---|
| 115 | } |
|---|
| 116 | if (count($tarray)) { |
|---|
| 117 | $add_sql.=" AND NOT("; |
|---|
| 118 | foreach($tarray as $TopicId) { |
|---|
| 119 | $add_sql .= "a.articleid=".$TopicId." OR "; |
|---|
| 120 | } |
|---|
| 121 | $add_sql = substr($add_sql,0,strlen($add_sql)-4); |
|---|
| 122 | $add_sql .= ")"; |
|---|
| 123 | } |
|---|
| 124 | if (count($Carray)) { |
|---|
| 125 | $add_sql.=" AND ("; |
|---|
| 126 | foreach($Carray as $CatId) { |
|---|
| 127 | $add_sql .= "a.categoryid=".$CatId." OR "; |
|---|
| 128 | } |
|---|
| 129 | $add_sql = substr($add_sql,0,strlen($add_sql)-4); |
|---|
| 130 | $add_sql .= ")"; |
|---|
| 131 | } |
|---|
| 132 | if (count($carray)) { |
|---|
| 133 | $add_sql.=" AND NOT("; |
|---|
| 134 | foreach($carray as $CatId) { |
|---|
| 135 | $add_sql .= "a.categoryid=".$CatId." OR "; |
|---|
| 136 | } |
|---|
| 137 | $add_sql = substr($add_sql,0,strlen($add_sql)-4); |
|---|
| 138 | $add_sql .= ")"; |
|---|
| 139 | } |
|---|
| 140 | } else { |
|---|
| 141 | $add_sql=""; |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | $sql = "SELECT a.articleid, a.categoryid, a.title as atitle, a.published, a.expired, a.counter, a.groupid, a.maintext, a.summary, b.title as btitle FROM ".$xoopsDB->prefix("xfs_article")." a, ".$xoopsDB->prefix("xfs_category")." b WHERE a.published < ".time()." AND a.published > 0 AND (a.expired = 0 OR a.expired > ".time().") AND a.noshowart = 0 AND a.offline = 0 AND a.categoryid = b.id".$add_sql." ORDER BY published DESC"; |
|---|
| 145 | |
|---|
| 146 | $result = $xoopsDB->query($sql, $obj->getVar('rssfj_grab'), 0); |
|---|
| 147 | while( $row = $xoopsDB->fetchArray($result) ){ |
|---|
| 148 | if(checkAccess($row["groupid"])){ |
|---|
| 149 | $link = XOOPS_URL.'/modules/'.$this->dirname.'/article.php?articleid='.$row['articleid']; |
|---|
| 150 | // required items |
|---|
| 151 | $desc=$this->modname." : ".$row['btitle'].">>".$row['atitle']; |
|---|
| 152 | $ret[$i]['title'] = $myts->makeTareaData4Show($desc); |
|---|
| 153 | $ret[$i]['link'] = $link; |
|---|
| 154 | $ret[$i]['guid'] = $link; |
|---|
| 155 | $ret[$i]['timestamp'] = $row['published']; |
|---|
| 156 | // $desc = !empty($row['summary']) ? $row['summary'] : $row['maintext']; |
|---|
| 157 | $desc = $row['summary']."::". $row['maintext']; |
|---|
| 158 | $ret[$i]['description'] = $myts->makeTareaData4Show($desc); |
|---|
| 159 | // optional items |
|---|
| 160 | $ret[$i]['category'] = $this->modname; |
|---|
| 161 | $ret[$i]['domain'] = XOOPS_URL.'/modules/'.$this->dirname.'/'; |
|---|
| 162 | $i++; |
|---|
| 163 | } |
|---|
| 164 | } |
|---|
| 165 | return $ret; |
|---|
| 166 | } |
|---|
| 167 | } |
|---|
| 168 | ?> |
|---|