source: temp/test-xoops.ec-cube.net/html/modules/xoopspoll/blocks/xoopspoll.php @ 678

Revision 678, 3.1 KB checked in by uehara, 20 years ago (diff)
Line 
1<?php
2// $Id: xoopspoll.php,v 1.2 2005/03/18 12:52:49 onokazu Exp $
3//  ------------------------------------------------------------------------ //
4//                XOOPS - PHP Content Management System                      //
5//                    Copyright (c) 2000 XOOPS.org                           //
6//                       <http://www.xoops.org/>                             //
7//  ------------------------------------------------------------------------ //
8//  This program is free software; you can redistribute it and/or modify     //
9//  it under the terms of the GNU General Public License as published by     //
10//  the Free Software Foundation; either version 2 of the License, or        //
11//  (at your option) any later version.                                      //
12//                                                                           //
13//  You may not change or alter any portion of this comment or credits       //
14//  of supporting developers from this source code or any supporting         //
15//  source code which is considered copyrighted (c) material of the          //
16//  original comment or credit authors.                                      //
17//                                                                           //
18//  This program is distributed in the hope that it will be useful,          //
19//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21//  GNU General Public License for more details.                             //
22//                                                                           //
23//  You should have received a copy of the GNU General Public License        //
24//  along with this program; if not, write to the Free Software              //
25//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26//  ------------------------------------------------------------------------ //
27include_once XOOPS_ROOT_PATH.'/modules/xoopspoll/class/xoopspoll.php';
28include_once XOOPS_ROOT_PATH.'/modules/xoopspoll/class/xoopspolloption.php';
29include_once XOOPS_ROOT_PATH.'/modules/xoopspoll/language/'.$xoopsConfig['language'].'/main.php';
30
31function b_xoopspoll_show()
32{
33    $block = array();
34    $polls =& XoopsPoll::getAll(array('display=1'), true, 'weight ASC, end_time DESC');
35    $count = count($polls);
36    $block['lang_vote'] = _PL_VOTE;
37    $block['lang_results'] = _PL_RESULTS;
38    for ($i = 0; $i < $count; $i++) {
39        $options_arr =& XoopsPollOption::getAllByPollId($polls[$i]->getVar('poll_id'), 3);
40        $option_type = 'radio';
41        $option_name = 'option_id';
42        if ($polls[$i]->getVar('multiple') == 1) {
43            $option_type = 'checkbox';
44            $option_name .= '[]';
45        }
46        foreach ($options_arr as $option) {
47            $options[] = array('id' => $option->getVar('option_id'), 'text' => $option->getVar('option_text'));
48        }
49        $poll = array('id' => $polls[$i]->getVar('poll_id'), 'question' => $polls[$i]->getVar('question'), 'option_type' => $option_type, 'option_name' => $option_name, 'options' => $options);
50        $block['polls'][] =& $poll;
51        unset($options);
52        unset($poll);
53    }
54    return $block;
55}
56?>
Note: See TracBrowser for help on using the repository browser.