Changeset 688 for trunk/plugins/altarchive.php
- Timestamp:
- 10/31/07 23:36:55 (14 months ago)
- Files:
-
- 1 modified
-
trunk/plugins/altarchive.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/altarchive.php
r687 r688 64 64 else 65 65 $url = "index.php?action=archive&m="; 66 /* this should be a setting for this plugin */67 66 /* years to show */ 68 $years = 3; 67 if (array_key_exists("altarchive_showyears", $this->_settings)) 68 $years = $this->_settings["altarchive_showyears"]; 69 else 70 $years = 3; 69 71 $output = ""; 70 72 for ($i=date("Y"); $i>date("Y")-$years; $i--) { … … 136 138 $output .= "</select></td>\n"; 137 139 $output .= "</tr><tr>"; 140 $output .= "<td>".gettext("years to show")."</td>"; 141 $output .= "<td><select name=\"altarchive_showyears\">"; 142 for ($i=1;$i<10;$i++) { 143 $output .= "<option value=\"$i\""; 144 if (array_key_exists("altarchive_showyears", $this->_settings) && $this->_settings["altarchive_showyears"] == $i) 145 $output .= " selected=\"selected\""; 146 $output .= ">$i</option>"; 147 } 148 $output .= "</select></td>"; 149 $output .= "</tr><tr>"; 138 150 $output .= "<td colspan=\"2\"><input type=\"submit\" value=\"".gettext("Save")."\" /></td>"; 139 151 $output .= "</tr></table>"; … … 158 170 $res = $this->_mvblog->db->exec($sql); 159 171 $this->_settings["altarchive_showdefaultcss"] = sprintf("%d", $requestdata["altarchive_showdefaultcss"]); 172 /* first look if the setting is already there */ 173 $sql = "SELECT COUNT(*) FROM settings WHERE settingname = 'altarchive_showyears'"; 174 $res = $this->_mvblog->db->query($sql); 175 $row = $res->fetchRow(); 176 if ($row[0]) { 177 /* yes, so update */ 178 $sql = sprintf("UPDATE settings SET settingvalue='%d' WHERE settingname='altarchive_showyears'", $requestdata["altarchive_showyears"]); 179 } else { 180 /* no, so insert */ 181 $sql = sprintf("INSERT INTO settings (settingname, settingvalue) VALUES ('altarchive_showyears', '%d')", $requestdata["altarchive_showyears"]); 182 } 183 $res = $this->_mvblog->db->exec($sql); 184 $this->_settings["altarchive_showyears"] = sprintf("%d", $requestdata["altarchive_showyears"]); 160 185 $this->show_settings(); 161 186 }
