[Mvblog-commits] r688 - trunk/plugins
mvblog-commits at lists.three-dimensional.net
mvblog-commits at lists.three-dimensional.net
Wed Oct 31 23:36:55 CET 2007
Author: michiel
Date: 2007-10-31 23:36:55 +0100 (Wed, 31 Oct 2007)
New Revision: 688
Modified:
trunk/plugins/altarchive.php
Log:
make the ammount of years to show in the altarchive
plugin a plugin setting instead of a hardcoded 3.
Modified: trunk/plugins/altarchive.php
===================================================================
--- trunk/plugins/altarchive.php 2007-10-31 22:25:14 UTC (rev 687)
+++ trunk/plugins/altarchive.php 2007-10-31 22:36:55 UTC (rev 688)
@@ -63,9 +63,11 @@
$url = "archive/";
else
$url = "index.php?action=archive&m=";
- /* this should be a setting for this plugin */
/* years to show */
- $years = 3;
+ if (array_key_exists("altarchive_showyears", $this->_settings))
+ $years = $this->_settings["altarchive_showyears"];
+ else
+ $years = 3;
$output = "";
for ($i=date("Y"); $i>date("Y")-$years; $i--) {
$output .= "<b>".$i."</b><br />\n";
@@ -135,6 +137,16 @@
$output .= ">".gettext("no")."</option>";
$output .= "</select></td>\n";
$output .= "</tr><tr>";
+ $output .= "<td>".gettext("years to show")."</td>";
+ $output .= "<td><select name=\"altarchive_showyears\">";
+ for ($i=1;$i<10;$i++) {
+ $output .= "<option value=\"$i\"";
+ if (array_key_exists("altarchive_showyears", $this->_settings) && $this->_settings["altarchive_showyears"] == $i)
+ $output .= " selected=\"selected\"";
+ $output .= ">$i</option>";
+ }
+ $output .= "</select></td>";
+ $output .= "</tr><tr>";
$output .= "<td colspan=\"2\"><input type=\"submit\" value=\"".gettext("Save")."\" /></td>";
$output .= "</tr></table>";
@@ -157,6 +169,19 @@
}
$res = $this->_mvblog->db->exec($sql);
$this->_settings["altarchive_showdefaultcss"] = sprintf("%d", $requestdata["altarchive_showdefaultcss"]);
+ /* first look if the setting is already there */
+ $sql = "SELECT COUNT(*) FROM settings WHERE settingname = 'altarchive_showyears'";
+ $res = $this->_mvblog->db->query($sql);
+ $row = $res->fetchRow();
+ if ($row[0]) {
+ /* yes, so update */
+ $sql = sprintf("UPDATE settings SET settingvalue='%d' WHERE settingname='altarchive_showyears'", $requestdata["altarchive_showyears"]);
+ } else {
+ /* no, so insert */
+ $sql = sprintf("INSERT INTO settings (settingname, settingvalue) VALUES ('altarchive_showyears', '%d')", $requestdata["altarchive_showyears"]);
+ }
+ $res = $this->_mvblog->db->exec($sql);
+ $this->_settings["altarchive_showyears"] = sprintf("%d", $requestdata["altarchive_showyears"]);
$this->show_settings();
}
/* }}} */
More information about the Mvblog-commits
mailing list