| 103 | | |
| 104 | | ############################################################################### |
| 105 | | # Gregarius - A PHP based RSS aggregator. |
| 106 | | # Copyright (C) 2003 - 2006 Marco Bonetti |
| 107 | | # |
| 108 | | ############################################################################### |
| 109 | | # This program is free software and open source software; you can redistribute |
| 110 | | # it and/or modify it under the terms of the GNU General Public License as |
| 111 | | # published by the Free Software Foundation; either version 2 of the License, |
| 112 | | # or (at your option) any later version. |
| 113 | | # |
| 114 | | # This program is distributed in the hope that it will be useful, but WITHOUT |
| 115 | | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 116 | | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 117 | | # more details. |
| 118 | | # |
| 119 | | # You should have received a copy of the GNU General Public License along |
| 120 | | # with this program; if not, write to the Free Software Foundation, Inc., |
| 121 | | # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit |
| 122 | | # http://www.gnu.org/licenses/gpl.html |
| 123 | | # |
| 124 | | ############################################################################### |
| 125 | | # E-mail: mbonetti at gmail dot com |
| 126 | | # Web page: http://gregarius.net/ |
| 127 | | # |
| 128 | | ############################################################################### |
| 129 | | |
| 130 | | define('ALL_CHANNELS_ID', -1); |
| 131 | | |
| 132 | | function rss_toolkit_folders_combo($name, $selected = -1) { |
| 133 | | $ret = "\n<select name=\"$name\" id=\"$name\">\n"; |
| 134 | | if (getConfig('rss.config.absoluteordering')) { |
| 135 | | $sql = " order by position asc"; |
| 136 | | } else { |
| 137 | | $sql = " order by name asc"; |
| 138 | | } |
| 139 | | $res = rss_query("select id, name from " .getTable("folders") . $sql); |
| 140 | | while (list($id, $name) = rss_fetch_row($res)) { |
| 141 | | $ret .= "\t<option value=\"$id\"" |
| 142 | | .($selected > -1 && $selected == $id ? " selected=\"selected\"":"") |
| 143 | | .">" . (($name == "")?LBL_HOME_FOLDER:$name) ."</option>\n"; |
| 144 | | } |
| 145 | | $ret .= "</select>\n"; |
| 146 | | |
| 147 | | return $ret; |
| 148 | | } |
| 149 | | |
| 150 | | function rss_toolkit_channels_combo($id, $all_channels_id = ALL_CHANNELS_ID, $selected = 0) { |
| 151 | | $ret = "\t\t<select name=\"$id\" id=\"$id\">\n" |
| 152 | | ."\t\t\t<option value=\"". $all_channels_id ."\"" |
| 153 | | .(0 == $selected?" selected=\"selected\"":"") |
| 154 | | .">" . LBL_ALL . "</option>\n"; |
| 155 | | |
| 156 | | $sql = "select " |
| 157 | | ." c.id, c.title, f.name, f.id " |
| 158 | | ." from " . getTable("channels") ." c, " . getTable("folders"). " f " |
| 159 | | ." where f.id=c.parent "; |
| 160 | | |
| 161 | | if (hidePrivate()) { |
| 162 | | $sql .=" and not(c.mode & " . RSS_MODE_PRIVATE_STATE .") "; |
| 163 | | } |
| 164 | | |
| 165 | | $sql .=" and not(c.mode & " . RSS_MODE_DELETED_STATE .") "; |
| 166 | | |
| 167 | | $sql .= " order by " |
| 168 | | .((getConfig('rss.config.absoluteordering'))?"f.position asc, c.position asc":"f.name asc, c.title asc"); |
| 169 | | |
| 170 | | $res = rss_query($sql); |
| 171 | | $prev_parent = -1; |
| 172 | | |
| 173 | | while (list ($id_, $title_, $parent_, $parent_id_) = rss_fetch_row($res)) { |
| 174 | | if ($prev_parent != $parent_id_) { |
| 175 | | if ($prev_parent > -1) { |
| 176 | | $ret .="\t\t\t</optgroup>\n"; |
| 177 | | } |
| 178 | | if ($parent_ == "") { |
| 179 | | $parent_ = LBL_HOME_FOLDER; |
| 180 | | } |
| 181 | | $ret .= "\t\t\t<optgroup label=\"$parent_ /\">\n"; |
| 182 | | $prev_parent = $parent_id_; |
| 183 | | } |
| 184 | | |
| 185 | | if (strlen($title_) > 25) { |
| 186 | | $title_ = substr($title_, 0, 22)."..."; |
| 187 | | } |
| 188 | | |
| 189 | | $ret .= "\t\t\t\t<option value=\"$id_\"".($selected == $id_ ? " selected=\"selected\"" : "").">$title_</option>\n"; |
| 190 | | } |
| 191 | | |
| 192 | | if ($prev_parent != 0) { |
| 193 | | $ret .= "\t\t\t</optgroup>\n"; |
| 194 | | } |
| 195 | | |
| 196 | | $ret .= "\t\t</select>\n"; |
| 197 | | |
| 198 | | |
| 199 | | return $ret; |
| 200 | | } |
| 201 | | |
| 202 | | ?> |