]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pref/prefs.php
move addInstance call to instances plugin
[tt-rss.git] / classes / pref / prefs.php
index ad5dff4add1e70c1b41cf2697d0a65b28763ec49..21b25c6319d44e3b3fc4d070d7b978612e002d7f 100644 (file)
@@ -2,7 +2,7 @@
 class Pref_Prefs extends Handler_Protected {
 
        function csrf_ignore($method) {
-               $csrf_ignored = array("index", "updateself");
+               $csrf_ignored = array("index", "updateself", "customizecss");
 
                return array_search($method, $csrf_ignored) !== false;
        }
@@ -113,8 +113,6 @@ class Pref_Prefs extends Handler_Protected {
                        WHERE $profile_qpart AND owner_uid = ".$_SESSION["uid"]);
 
                initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]);
-
-               print "PREFS_THEME_CHANGED";
        }
 
        function index() {
@@ -389,11 +387,7 @@ class Pref_Prefs extends Handler_Protected {
                                parameters: dojo.objectToQuery(this.getValues()),
                                onComplete: function(transport) {
                                        var msg = transport.responseText;
-                                       if (msg.match('PREFS_THEME_CHANGED')) {
-                                               window.location.reload();
-                                       } else {
-                                               notify_info(msg);
-                                       }
+                                       notify_info(msg);
                        } });
                }
                </script>";
@@ -496,6 +490,14 @@ class Pref_Prefs extends Handler_Protected {
                                print "<button dojoType=\"dijit.form.Button\"
                                        onclick=\"customizeCSS()\">" . __('Customize') . "</button>";
 
+                       } else if ($pref_name == "USER_CSS_THEME") {
+
+                               $themes = array_map("basename", glob("themes/*.css"));
+
+                               print_select($pref_name, $value, $themes,
+                                       'dojoType="dijit.form.Select"');
+
+
                        } else if ($pref_name == "DEFAULT_ARTICLE_LIMIT") {
 
                                $limits = array(15, 30, 45, 60);
@@ -868,5 +870,33 @@ class Pref_Prefs extends Handler_Protected {
                global $pluginhost;
                $pluginhost->clear_data($pluginhost->get_plugin($name));
        }
+
+       function customizeCSS() {
+               $value = get_pref($this->link, "USER_STYLESHEET");
+
+               $value = str_replace("<br/>", "\n", $value);
+
+               print_notice(T_sprintf("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target=\"_blank\" class=\"visibleLink\" href=\"%s\">This file</a> can be used as a baseline.", "tt-rss.css"));
+
+               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
+               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
+               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
+
+               print "<table width='100%'><tr><td>";
+               print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
+                       style='font-size : 12px; width : 100%; height: 200px;'
+                       placeHolder='body#ttrssMain { font-size : 14px; };'
+                       name='value'>$value</textarea>";
+               print "</td></tr></table>";
+
+               print "<div class='dlgButtons'>";
+               print "<button dojoType=\"dijit.form.Button\"
+                       onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> ";
+               print "<button dojoType=\"dijit.form.Button\"
+                       onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
+               print "</div>";
+
+       }
+
 }
 ?>