* refactor global options handling in toplevel/options
authorJeremy Laine <jeremy.laine@m4x.org>
Thu, 20 Jul 2006 22:27:36 +0000 (22:27 +0000)
committerJeremy Laine <jeremy.laine@m4x.org>
Thu, 20 Jul 2006 22:27:36 +0000 (22:27 +0000)
* add global option to set the default stylesheet for new barrels
* add style.css from doc.polytechnique.org

Makefile
htdocs/toplevel/options.php
include/Barrel.php
include/diogenes.globals.inc.php.in
styles/default_blue.css [moved from style.css with 100% similarity]
styles/funky_doc.css [new file with mode: 0644]
templates/toplevel-options.tpl

index c0b9ad0..cb82e4d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ LIB_DIST = libdiogenes-$(VERSION)
 PKG_FILES = AUTHORS ChangeLog COPYING README Makefile \
             cvs.pl style.css
            
-PKG_DIRS = config htdocs include locale po plugins templates
+PKG_DIRS = config htdocs include locale po plugins styles templates
 
 LIB_FILES = COPYING
 LIB_BASE = include/diogenes
index 15e4a33..77fbef5 100644 (file)
@@ -9,44 +9,45 @@ $page = new $globals->toplevel(true);
 
 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "";
 
+$rw_str_opts = array ('menu_style', 'menu_theme', 'template_dir', 'template', 'html_editor', 'word_import', 'barrel_style_sheet');
+$rw_bool_opts = array('debugdatabase', 'debugplugins', 'validatepages');
+$ro_opts = array ('menu_styles', 'menu_themes', 'html_editors', 'word_imports', 'style_sheets');
+
 switch ($action) {
 case "options":
-  $globals->updateOption("menu_style", $_REQUEST['menu_style']);
-  if (isset($_REQUEST['menu_theme']))
-    $globals->updateOption("menu_theme", $_REQUEST['menu_theme']);
-  $globals->updateOption("template_dir", $_REQUEST['template_dir']);
-  $globals->updateOption("template", $_REQUEST['template']);
-  $globals->updateOption("html_editor", $_REQUEST['html_editor']);
-  $globals->updateOption("word_import", $_REQUEST['word_import']);
-  $globals->updateOption("debugdatabase", $_REQUEST['debugdatabase'] ? 1 : 0);
-  $globals->updateOption("debugplugins", $_REQUEST['debugplugins'] ? 1 : 0);
-  $globals->updateOption("validatepages", $_REQUEST['validatepages'] ? 1 : 0);
+  foreach ($rw_str_opts as $opt_name)
+  {
+    if (isset($_REQUEST[$opt_name]))
+      $globals->updateOption($opt_name, $_REQUEST[$opt_name]);
+  }
+  foreach ($rw_bool_opts as $opt_name)
+  {
+    if (isset($_REQUEST[$opt_name]))
+      $globals->updateOption($opt_name, $_REQUEST[$opt_name] ? 1 : 0);
+  }
   break;
 }
 
 
 // fill out values
-$page->assign('menu_styles', $globals->menu_styles);
-$page->assign('menu_style', $globals->menu_style);
+$all_opts = array_merge($ro_opts, $rw_str_opts, $ro_opts);
+$all_opts = array_merge($all_opts, $rw_bool_opts);
+foreach ($all_opts as $opt_name)
+{
+  if (!isset($globals->$opt_name)) {
+    $page->info("warning : unknown option '$opt_name'");
+  } else {
+    $page->assign($opt_name, $globals->$opt_name);
+  }
+}
+/*
 if ($globals->menu_style == 1 || $globals->menu_style == 2) {
   $page->assign('menu_themes', $globals->menu_themes);
   $page->assign('menu_theme', $globals->menu_theme);
 }
-$page->assign('template_dir', $globals->template_dir);
-$page->assign('template', $globals->template);
+*/
 $page->assign('templates', $page->getTemplates());
 
-$page->assign('validatepages', $globals->validatepages);
-
-$page->assign('html_editors', $globals->html_editors);
-$page->assign('html_editor', $globals->html_editor);
-
-$page->assign('word_imports', $globals->word_imports);
-$page->assign('word_import', $globals->word_import);
-
-$page->assign('debugdatabase', $globals->debugdatabase);
-$page->assign('debugplugins', $globals->debugplugins);
-
 // translations
 $page->assign('greeting', __("Global options"));
 $page->toolbar(__("Mode"), array( __("standard"), array(__("expert"), "options_expert.php")));
index cc41014..21dd5c2 100644 (file)
@@ -164,12 +164,14 @@ class Diogenes_Barrel
     $homepage = mysql_insert_id();
     $globals->db->query("update {$alias}_page set location='',title='Home',perms='public' where PID='$homepage'");
 
-    /* create home page & copy CSS template */
+    /* create home page */
     $rcs = new $globals->rcs($caller,$alias,$_SESSION['session']->username,true);
     $rcs->newdir("",$homepage);
     $rcs->commit($homepage,$globals->htmlfile,"");
-    $rcs->commit($homepage,$globals->cssfile,
-                        file_get_contents("{$globals->root}/{$globals->cssfile}") );
+
+    /* copy CSS template */
+    $def_css = file_get_contents("{$globals->root}/styles/{$globals->barrel_style_sheet}.css");
+    $rcs->commit($homepage,$globals->cssfile, $def_css);
   }
 
   
index 90ed1fb..18d074e 100644 (file)
@@ -116,6 +116,15 @@ class DiogenesGlobals extends DiogenesCoreGlobals {
                            'lush' => 'lush',
                            'mozilla' => 'mozilla'
                           );
+
+   /** Available style sheets */
+   var $style_sheets = array(
+                           'default_blue' => 'Default Blue',
+                           'funky_doc' => 'Funky Doc',
+                          );
+  
+  /** Default stylesheet for new barrels */
+  var $barrel_style_sheet = 'default_blue';
   
   /** The HTML editor to use (ekit, kafenio) */
   var $html_editor = "kafenio";
similarity index 100%
rename from style.css
rename to styles/default_blue.css
diff --git a/styles/funky_doc.css b/styles/funky_doc.css
new file mode 100644 (file)
index 0000000..c35583e
--- /dev/null
@@ -0,0 +1,188 @@
+/* insert your CSS customisations below */
+
+body {
+  background-color: #fff;
+  color: inherit;
+}
+
+#header {
+    background: #f5f8fc;
+    border: 1px solid #69c;
+    margin: 0 1em;
+    color: #369;
+}
+
+#header .logo { display: none; }
+#header .titlebar { margin: 0px; }
+#header .site { font-size: 20pt !important; letter-spacing: 0px }
+#header .page { color: #690; font-size: 20pt !important }
+
+#header .page:before { content: ' [ '; }
+#header .page:after { content: ' ] '; }
+
+#sidebar {
+    width: 14em;
+    font-family: "Trebuchet MS",Verdana,Geneva,Arial,Helvetica,sans-serif;
+    font-size: 10pt;
+    padding: 0px;
+    margin: 1em;
+    background: #f5f8fc;
+    border: 1px solid #69c;
+}
+
+#main {
+    font-family: "Trebuchet MS",Verdana,Geneva,Arial,Helvetica,sans-serif;
+    background: #f5f8fc;
+    border: 1px solid #69c;
+    line-height:125%;
+    padding: 0em 1em 1em 1em;
+    margin: 1em 1em 1em 15em;
+}
+
+#main p  { padding: 0px; margin: 1ex 1em; text-align: justify }
+#main ul { margin: 1ex 1em; }
+#main li { margin-top: 1ex; margin-bottom: 1ex; text-align: justify }
+
+h1 {
+    color: #369;
+    font-size: 130%;
+    border-bottom: 2px solid #369;
+    padding: 4px;
+    margin: 2em 0em 1em 0em;
+}
+
+h2 {
+    color: #369;
+    padding: 0px 4px;
+    margin: 1em 0em 0.5em 0em;
+    font-size: 100%;
+    font-weight: bold;
+    border-bottom: 1px dotted #369;
+}
+
+#main a:link, #main a:visited { color: #f60; background: transparent; }
+#main a:active, #main a:hover { color: #369; background: transparent; }
+
+.header {
+  background-color: #99aabb;
+  color: #202040;
+}
+
+.menu {
+    font-weight: bold;
+    background: transparent;
+    width: 14em;
+}
+
+.menu .item {
+    background: transparent;
+}
+
+.menu .item a {
+    color: #690;
+    background: transparent;
+    border: 1px dotted #fff;
+    display: block;
+    padding: 1px 4px;
+    text-align: left;
+    font-size: 80%;
+    font-family: Bitstream Vera Sans,Verdana,sans-serif;
+    text-decoration: none;
+    white-space: nowrap;
+}
+
+.menu .item a.top, .menu .item a.top:hover {
+    color: #f90;
+    background: transparent;
+    border-top: none;
+    border-left: none;
+    border-right: none;
+    border-bottom: 3px solid #f90;
+    text-transform: uppercase;
+    text-align: left;
+    padding: 0px 1ex;
+    margin: 1ex 0ex;
+}
+
+.menu .item a.odd {
+    color: #690;
+    background: transparent;
+}
+
+.menu .item a:hover {
+    color: #690;
+    background: #eaf2db;
+    border: 1px dotted #690;
+}
+
+.menu .item a.top[href]:hover {
+    color: #000;
+    background: transparent;
+    border-top: none;
+    border-left: none;
+    border-right: none;
+    border-bottom: 3px solid #000;
+}
+
+/* table class 'light' */
+table.light {
+    border-collapse: collapse;
+    color: inherit;
+    background: #fff;
+    border: 1px solid #a2c2e1;
+    width: 98%;
+    margin-left: 1%;
+}
+
+table.light tr.odd {
+    color: inherit;
+    background: #fff;
+}
+table.light tr.even {
+    color: inherit;
+    background: #eee;
+}
+
+
+table.light th {
+    color: #369;
+    background: #d6e1ec;
+    font-weight: bold;
+    text-align: center;
+    vertical-align: middle;
+    padding: 0px 4px;
+}
+
+code, div code {
+    display: block;
+    background: white;
+    border: 1px dotted #2050a0;
+    color: inherit;
+    font-family: monospaced;
+    font-size: 10pt;
+    padding: 1em;
+    margin: 1em 2em;
+}
+
+code pre {
+    padding: 0px;
+    margin: 0px;
+}
+
+tt { font-size: 10pt; }
+
+li > code, p > code, tt.code {
+    display: inline;
+    border: 1px dotted #2050a0;
+    background: #fff;
+    color: inherit;
+    padding: 0 2px 0 2px;
+    margin: 0ex;
+}
+
+#main p.version {
+    text-align: center;
+    font-family: georgia;
+    font-size: 9pt;
+    margin-top: 4em;
+}
index f4d8647..67b65ee 100644 (file)
@@ -23,6 +23,9 @@
   <td>{html_options name='template' selected=$template options=$templates}</td>
 </tr>
 <tr>
+  <td>{$msg_site_style_sheet}</td>
+  <td>{html_options name='barrel_style_sheet' selected=$barrel_style_sheet options=$style_sheets}</td>
+<tr>
   <td>{$msg_validate_pages}</td>
   <td><input type="checkbox" name="validatepages"{if $validatepages} checked="checked"{/if}/></td>
 </tr>