]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/blog/themeinfo.php
Performance optimization: Do not derive from Sidebar.
[SourceForge/phpwiki.git] / themes / blog / themeinfo.php
1 <?php
2 rcs_id('$Id: themeinfo.php,v 1.6 2007-01-07 18:48:20 rurban Exp $');
3
4 /**
5  * This file defines a blog theme for PhpWiki, 
6  * based on Rui Carmo's excellent http://the.taoofmac.com/space/ 
7  * which is based on the Kubrick theme: http://binarybonsai.com/kubrick/
8  * The layout was designed and built by Michael Heilemann,
9  * whose blog you will find at http://binarybonsai.com/
10  *
11  * [Stanley Kubrick]"Good afternoon, gentlemen. I am a HAL 9000
12  * computer. I became operational at the H.A.L. plant in Urbana,
13  * Illinois on the 12th of January 1992. My instructor was
14  * Mr. Langley, and he taught me to sing a song. If you'd like to hear
15  * it I can sing it for you."
16  *
17  * The CSS, XHTML and design is released under GPL:
18  * http://www.opensource.org/licenses/gpl-license.php 
19  *
20  * Default is a one-person (ADMIN_USER) blog (at the BlogHomePage), but 
21  * other blogs are also enabled for every authenticated user.
22  *
23  * Actionbar: Edit, Home, About, Archives, News, ..., Info  [ Search ]
24  * PageTrail: > .. > ..
25  * Right sidebar boxes: Archives, Syndication, Links, GoogleAds
26  *
27  * For the livesearch feature (autodropdown of the results while you tip) 
28  * you'll have to copy livesearch.js from http://blog.bitflux.ch/wiki/LiveSearch
29  * to themes/default/, change the liveSearchReq.open line to:
30 liveSearchReq.open("GET", liveSearchURI + "?format=livesearch&paging=none&limit=25&s=" + document.forms.searchform.s.value);
31  * and define ENABLE_LIVESEARCH in config.ini to true.
32  * 
33  * Better autodropdown's are in consideration:
34  *   http://momche.net/publish/article.php?page=acdropdown)
35  *
36  * Happy blogging.
37  */
38
39 require_once('lib/Theme.php');
40 // Oh holy shit. This creates the wrong theme, which would result in double initializations.
41 // So never derive from themes
42 //require_once('themes/Sidebar/themeinfo.php');
43
44 class Theme_blog extends Theme {
45
46     function Theme_blog ($theme_name='blog') {
47         $this->Theme($theme_name);
48         $this->calendarInit(true);
49     }
50     
51     function _findFile ($file, $missing_okay=false) {
52         if (file_exists($this->_path . "themes/".$this->_name."/$file"))
53             return "themes/".$this->_name."/$file";
54         if (file_exists($this->_path . "themes/Sidebar/$file"))
55             return "themes/Sidebar/$file";
56         return parent::_findFile($file, $missing_okay);
57     }
58
59     function _labelForAction ($action) {
60         switch ($action) {
61             case 'edit':   return _("Edit");
62             case 'diff':   return _("Diff");
63             case 'logout': return _("SignOut");
64             case 'login':  return _("SignIn");
65             case 'lock':   return _("Lock");
66             case 'unlock': return _("Unlock");
67             case 'remove': return _("Remove");
68             default:
69                 return gettext(ucfirst($action));
70         }
71     }
72
73     function getRecentChangesFormatter ($format) {
74         include_once($this->file('lib/RecentChanges.php'));
75         if (preg_match('/^rss|^sidebar/', $format))
76             return false;       // use default
77         if ($format == 'box')
78             return '_blog_RecentChanges_BoxFormatter';
79         return '_blog_RecentChanges_Formatter';
80     }
81     
82     /* TODO: use the blog summary as label instead of the pagename */
83     function linkExistingWikiWord($wikiword, $linktext = '', $version = false) {
84         global $request;
85         if ($version !== false and !$this->HTML_DUMP_SUFFIX)
86             $url = WikiURL($wikiword, array('version' => $version));
87         else
88             $url = WikiURL($wikiword);
89
90         // Extra steps for dumping page to an html file.
91         if ($this->HTML_DUMP_SUFFIX) {
92             $url = preg_replace('/^\./', '%2e', $url); // dot pages
93         }
94
95         $link = HTML::a(array('href' => $url));
96
97         if (isa($wikiword, 'WikiPageName'))
98              $default_text = $wikiword->shortName;
99          else
100              $default_text = $wikiword;
101          
102         if (!empty($linktext)) {
103             $link->pushContent($linktext);
104             $link->setAttr('class', 'named-wiki');
105             $link->setAttr('title', $this->maybeSplitWikiWord($default_text));
106         }
107         else {
108             //TODO: check if wikiblog
109             $link->pushContent($this->maybeSplitWikiWord($default_text));
110             $link->setAttr('class', 'wiki');
111         }
112         if ($request->getArg('frame'))
113             $link->setAttr('target', '_top');
114         return $link;
115     }
116 }
117
118 $WikiTheme = new Theme_blog('blog');
119 define("PAGETRAIL_ARROW", " ยป ");
120
121 // CSS file defines fonts, colors and background images for this
122 // style.
123
124 // override sidebar definitions:
125 $WikiTheme->setDefaultCSS(_("blog"), 'Kubrick.css');
126
127 $WikiTheme->addButtonAlias(_("(diff)"), "[diff]" );
128 $WikiTheme->addButtonAlias("...", "alltime");
129
130 $WikiTheme->setButtonSeparator("");
131
132 /**
133  * WikiWords can automatically be split by inserting spaces between
134  * the words. The default is to leave WordsSmashedTogetherLikeSo.
135  */
136 $WikiTheme->setAutosplitWikiWords(false);
137
138 /**
139  * If true (default) show create '?' buttons on not existing pages, even if the 
140  * user is not signed in.
141  * If false, anon users get no links and it looks cleaner, but then they 
142  * cannot easily fix missing pages.
143  */
144 $WikiTheme->setAnonEditUnknownLinks(false);
145
146 /*
147  * You may adjust the formats used for formatting dates and times
148  * below.  (These examples give the default formats.)
149  * Formats are given as format strings to PHP strftime() function See
150  * http://www.php.net/manual/en/function.strftime.php for details.
151  * Do not include the server's zone (%Z), times are converted to the
152  * user's time zone.
153  */
154 //$WikiTheme->setDateFormat("%B %d, %Y");
155 $WikiTheme->setDateFormat("%A, %B %e, %Y"); // must not contain time
156 $WikiTheme->setTimeFormat("%H:%M:%S");
157
158 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
159 // (c-file-style: "gnu")
160 // Local Variables:
161 // mode: php
162 // tab-width: 8
163 // c-basic-offset: 4
164 // c-hanging-comment-ender-p: nil
165 // indent-tabs-mode: nil
166 // End:   
167 ?>