Changeset 303 for trunk/plugins

Show
Ignore:
Timestamp:
09/10/06 21:12:53 (2 years ago)
Author:
michiel
Message:

finished monhtly menu thingie plugin.

Fixes #51 and #91

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugins/altarchive.php

    r298 r303  
    1919 
    2020        /* methods */ 
     21        /* __construct {{{ */ 
    2122        public function __construct(&$mvblog) { 
    2223                $this->addHook("menu_archive_output", "altarchive"); 
     
    2425                $this->_mvblog =& $mvblog; 
    2526        } 
    26  
     27        /* }}} */ 
     28        /* activate {{{ */ 
    2729        public function activate() { 
    2830                /* get the months where we have articles */ 
     
    4648                } 
    4749        } 
    48  
     50        /* }}} */ 
     51        /* deactivate {{{ */ 
    4952        public function deactivate() { 
    5053                /* clear local variables */ 
    5154                unset($this->_count); 
    5255        } 
    53  
     56        /* }}} */ 
     57        /* altarchive {{{ */ 
    5458        public function altarchive($defaultmenu) { 
    5559                /* create url schema */ 
     
    8690                return $output; 
    8791        } 
    88  
     92        /* }}} */ 
     93        /* altarchiveCSS {{{ */ 
    8994        public function altarchiveCSS($data) { 
    90                 $output  = "\t<style type=\"text/css\">\n"; 
    91                 $output .= "\t\t.altarchive_month_noitems {\n"; 
    92                 $output .= "\t\t\ttext-align: center;\n"; 
    93                 $output .= "\t\t\tbackground-color: ".$this->_settings["altarchive_noitems_bg"].";\n"; 
    94                 $output .= "\t\t\tcolor: ".$this->_settings["altarchive_noitems_text"].";\n"; 
    95                 $output .= "\t\t\tborder: 1px solid #b0b0b0;\n"; 
    96                 $output .= "\t\t}\n"; 
    97                 $output .= "\t\t.altarchive_month_items {\n"; 
    98                 $output .= "\t\t\ttext-align: center;\n"; 
    99                 $output .= "\t\t\tbackground-color: ".$this->_settings["altarchive_items_bg"].";\n"; 
    100                 $output .= "\t\t\tborder: 1px solid #b0b0b0;\n"; 
    101                 $output .= "\t\t}\n"; 
    102                 $output .= "\t\t.altarchive_month_items a {\n"; 
    103                 $output .= "\t\t\tcolor: ".$this->_settings["altarchive_items_text"].";\n"; 
    104                 $output .= "\t\t}\n"; 
    105                 $output .= "\t</style>\n"; 
     95                if ($this->_settings["altarchive_showdefaultcss"]) { 
     96                        $output  = "\t<style type=\"text/css\">\n"; 
     97                        $output .= "\t\t.altarchive_month_noitems {\n"; 
     98                        $output .= "\t\t\ttext-align: center;\n"; 
     99                        $output .= "\t\t\tbackground-color: ".$this->_settings["altarchive_noitems_bg"].";\n"; 
     100                        $output .= "\t\t\tcolor: ".$this->_settings["altarchive_noitems_text"].";\n"; 
     101                        $output .= "\t\t\tborder: 1px solid #b0b0b0;\n"; 
     102                        $output .= "\t\t}\n"; 
     103                        $output .= "\t\t.altarchive_month_items {\n"; 
     104                        $output .= "\t\t\ttext-align: center;\n"; 
     105                        $output .= "\t\t\tbackground-color: ".$this->_settings["altarchive_items_bg"].";\n"; 
     106                        $output .= "\t\t\tborder: 1px solid #b0b0b0;\n"; 
     107                        $output .= "\t\t}\n"; 
     108                        $output .= "\t\t.altarchive_month_items a {\n"; 
     109                        $output .= "\t\t\tcolor: ".$this->_settings["altarchive_items_text"].";\n"; 
     110                        $output .= "\t\t}\n"; 
     111                        $output .= "\t</style>\n"; 
     112                } else { 
     113                        $output = ""; 
     114                } 
    106115                return $output; 
    107116        } 
     117        /* }}} */ 
     118        /* show_settings {{{ */ 
     119        public function show_settings() { 
     120                $output  = "<form name=\"acronym\" method=\"post\" action=\"index.php\">"; 
     121                $output .= "<input type=\"hidden\" name=\"action\" value=\"save_plugin_setting\" />"; 
     122                $output .= "<input type=\"hidden\" name=\"plugin\" value=\"altarchive\" />"; 
     123                $output .= "<table style=\"width: 220px;\"><tr>"; 
     124                $output .= "<td>".gettext("use default stylesheet?")."</td>"; 
     125                $output .= "<td><select name=\"altarchive_showdefaultcss\">"; 
     126                $output .= "<option value=\"1\""; 
     127                if ($this->_settings["altarchive_showdefaultcss"]) 
     128                        $output .= " selected=\"selected\""; 
     129                $output .= ">".gettext("yes")."</option>"; 
     130                $output .= "<option value=\"0\""; 
     131                if (!$this->_settings["altarchive_showdefaultcss"]) 
     132                        $output .= " selected=\"selected\""; 
     133                $output .= ">".gettext("no")."</option>"; 
     134                $output .= "</select></td>\n"; 
     135                $output .= "</tr><tr>"; 
     136                $output .= "<td colspan=\"2\"><input type=\"submit\" value=\"".gettext("Save")."\" /></td>"; 
     137                $output .= "</tr></table>"; 
    108138 
    109         public function show_settings() { 
    110                 echo "Coming soon..."; 
     139                $output .= "</form>"; 
     140                echo $output; 
    111141        } 
     142        /* }}} */ 
     143        /* save_setting {{{ */ 
     144        public function save_setting($requestdata) { 
     145                /* first look if the setting is already there */ 
     146                $sql = "SELECT COUNT(*) FROM settings WHERE settingname = 'altarchive_showdefaultcss'"; 
     147                $res = $this->_mvblog->db->query($sql); 
     148                $res->fetchInto($row); 
     149                if ($row[0]) { 
     150                        /* yes, so update */ 
     151                        $sql = sprintf("UPDATE settings SET settingvalue='%d' WHERE settingname='altarchive_showdefaultcss'", $requestdata["altarchive_showdefaultcss"]); 
     152                } else { 
     153                        /* no, so insert */ 
     154                        $sql = sprintf("INSERT INTO settings (settingname, settingvalue) VALUES ('altarchive_showdefaultcss', '%d')", $requestdata["altarchive_showdefaultcss"]); 
     155                } 
     156                $res = $this->_mvblog->db->query($sql); 
     157                $this->_settings["altarchive_showdefaultcss"] = sprintf("%d", $requestdata["altarchive_showdefaultcss"]); 
     158                $this->show_settings(); 
     159        } 
     160        /* }}} */ 
    112161} 
    113162?>