source: temp/test-xoops.ec-cube.net/html/modules/rssj/plugins/rssfitj.xoopspoll.php @ 405

Revision 405, 6.0 KB checked in by root, 20 years ago (diff)
Line 
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
47class RssfitjXoopspoll{
48    var $dirname = 'xoopspoll';
49    var $modname;
50   
51    /*
52    * private
53    * Nothing here so far
54    */
55    function RssfitjXoopspoll(){
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    //  The following example code grabs the latest entries from the module MyLinks
91
92        if ($obj->getVar('rssfj_param')) {
93            $rcdId=explode(',',$obj->getVar('rssfj_param'));
94            $Tarray=array();
95            $tarray=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            }
102            $add_sql="";
103            if (count($Tarray)) {
104                $add_sql.=" AND (";
105                foreach($Tarray as $TopicId) {
106                    $add_sql .= "poll_id=".$TopicId." OR ";
107                }
108                $add_sql = substr($add_sql,0,strlen($add_sql)-4);
109                $add_sql .= ")";
110            }
111            if (count($tarray)) {
112                $add_sql.=" AND NOT(";
113                foreach($tarray as $TopicId) {
114                    $add_sql .= "poll_id=".$TopicId." OR ";
115                }
116                $add_sql = substr($add_sql,0,strlen($add_sql)-4);
117                $add_sql .= ")";
118            }
119        } else {
120            $add_sql="";
121        }
122
123        $sql = "SELECT poll_id, question, end_time, description FROM ".$xoopsDB->prefix("xoopspoll_desc")." WHERE poll_id >= 0".$add_sql." ORDER BY end_time DESC";
124        $result = $xoopsDB->query($sql, $obj->getVar('rssfj_grab'), 0);
125        while( $row = $xoopsDB->fetchArray($result) ){
126        //  required items
127            $link = XOOPS_URL.'/modules/'.$this->dirname.'/pollresults.php?poll_id='.$row['poll_id'];
128                                                    // The title of the item
129            $desc=$this->modname." : ".$row['question'];
130            $ret[$i]['title'] = $myts->makeTareaData4Show($desc);
131            $ret[$i]['link'] = $link;               // The URL of the item
132            $ret[$i]['guid'] = $link;               // Unique identifier, usually url
133            $ret[$i]['timestamp'] = $row['end_time'];   // Item modification date,
134                                                    // must be in Unix time format
135            $desc = $row['description'];            // The item synopsis, or
136                                                    // description, whatever
137            $ret[$i]['description'] = $myts->makeTareaData4Show($desc);
138        //  optional items
139            $ret[$i]['category'] = $this->modname;
140            $ret[$i]['domain'] = XOOPS_URL.'/modules/'.$this->dirname.'/';
141           
142            $i++;
143        }
144        return $ret;
145    }
146}
147?>
Note: See TracBrowser for help on using the repository browser.