| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | ############################################################################### |
|---|
| 4 | # Gregarius - A PHP based RSS aggregator. |
|---|
| 5 | # Copyright (C) 2003 - 2006 Marco Bonetti |
|---|
| 6 | # |
|---|
| 7 | ############################################################################### |
|---|
| 8 | # This program is free software and open source software; you can redistribute |
|---|
| 9 | # it and/or modify it under the terms of the GNU General Public License as |
|---|
| 10 | # published by the Free Software Foundation; either version 2 of the License, |
|---|
| 11 | # or (at your option) any later version. |
|---|
| 12 | # |
|---|
| 13 | # This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 16 | # more details. |
|---|
| 17 | # |
|---|
| 18 | # You should have received a copy of the GNU General Public License along |
|---|
| 19 | # with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 20 | # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit |
|---|
| 21 | # http://www.gnu.org/licenses/gpl.html |
|---|
| 22 | # |
|---|
| 23 | ############################################################################### |
|---|
| 24 | # E-mail: mbonetti at gmail dot com |
|---|
| 25 | # Web page: http://gregarius.net/ |
|---|
| 26 | # |
|---|
| 27 | ############################################################################### |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | class SideMenu { |
|---|
| 31 | |
|---|
| 32 | var $items; |
|---|
| 33 | var $ctnr = ""; |
|---|
| 34 | var $activeElement; |
|---|
| 35 | |
|---|
| 36 | function SideMenu() { |
|---|
| 37 | $this -> items = array(); |
|---|
| 38 | $this -> activeElement = isset($_COOKIE['side']) ? $_COOKIE['side']:"FeedList"; |
|---|
| 39 | $GLOBALS['rss']->sideMenu = $this; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | function addMenu($label, $id, $action="") { |
|---|
| 43 | $this -> items[] = |
|---|
| 44 | array( |
|---|
| 45 | "label" => $label, |
|---|
| 46 | "id" => $id, |
|---|
| 47 | "action" => $action, |
|---|
| 48 | "class" => ($id == $this-> activeElement ? "active":"") |
|---|
| 49 | ); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | function setContainer($ctnr) { |
|---|
| 53 | $this -> ctnr = $ctnr; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | function render() { |
|---|
| 57 | rss_plugin_hook('rss.plugins.sidemenu', null); |
|---|
| 58 | foreach ($this -> items as $item) { |
|---|
| 59 | echo "<" . |
|---|
| 60 | $this -> ctnr |
|---|
| 61 | .' class="'.$item['class']. '"' |
|---|
| 62 | .' id="sidemenu'.$item['id']. '"' |
|---|
| 63 | .">" |
|---|
| 64 | .'<a href="#" onclick="'. $item["action"] .'; return false;">' |
|---|
| 65 | .$item["label"] |
|---|
| 66 | .'</a>' |
|---|
| 67 | ."</" . $this -> ctnr . ">\n"; |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | ?> |
|---|