]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/Toolbar.php
Some template sections have been simplified with tokens. Template.php recognises...
[SourceForge/phpwiki.git] / lib / Toolbar.php
1 <?php rcs_id('$Id: Toolbar.php,v 1.5 2002-01-03 19:12:39 carstenklapp Exp $');
2
3 //require_once("lib/ErrorManager.php");
4 //require_once("lib/WikiPlugin.php");
5
6 function separator() {
7 /*
8     $toolbar_style = "text";
9     select ( $toolbar_style ) {
10     case "text" :
11         $separator = " | ";
12         break;
13     case "list" :
14         $separator = ", ";
15         break;
16     case "image" :
17         $separator = "<img alt=\" | \" src=\"" .DATA_URL( '$placeholder' ) ."\" />";
18         break;
19     }
20     return $separator;
21 */
22     // just using a hardcoded separator for now
23     return " | ";
24 }
25
26 /*
27
28 These functions will replace the PHP logic currently embedded in
29 the html templates, used to build the Wiki commands and navigation
30 links at the bottom of the screen.
31
32 If you feel inspired please contribute here!
33
34 (This is all in a state of flux, so don't count on any of this being
35 the same tomorrow...)
36
37 */
38
39 // Some of these functions are ready to be used as ${tokens}
40 // in the xhtml templates.
41 //
42 // FIXME:
43 // IncludePage plugin for EditHelp needs to be dealt with.
44 //
45 // Plugins shuold be cleaned up, in this state they won't display
46 // any mouseover text
47 //
48 // The raw html should be replaced with calls to
49 // Element() and/or QElement()
50
51
52 // BrowsePage stuff
53
54 //Calling function should provide: - done
55 //$is_current = ($current->getVersion() == $revision->getVersion());
56 //$pagename = ($pagename);
57 function toolbar_Warning_IsCurrent($is_current, $pagename) {
58     $html = "";
59     if (!$is_current) {
60         $html .= "<p><strong>" ._("Note:") ."</strong> " ._("You are viewing an old revision of this page.");
61         $html .= "<a href=\"" .WikiURL('') .rawurlencode($pagename) ."\"> " ._("View the current version") ."</a></p>";
62         $html .= "<hr class=\"ignore\" noshade=\"noshade\" />";
63     }
64     return $html;
65 }
66
67 //Calling function should provide: - done
68 //$is_current = ($current->getVersion() == $revision->getVersion());
69 //$lastmodified = (strftime($datetimeformat, $revision->get('mtime')));
70 //$version = ($revision->getVersion());
71 function toolbar_Info_LastModified($is_current, $lastmodified, $version) {
72     $html = "";
73     if ($is_current) {
74        $html .= sprintf(_("Last edited on %s."), $lastmodified);
75     } else {
76        $html .= sprintf(_("Version %s, saved on %s."),$version, $lastmodified);
77     }
78     return $html;
79 }
80
81 //Calling function should provide:
82 //$pagelocked = ($page->get('locked'));
83 //$userisadmin = ($user->is_admin());
84 //$is_current = ($current->getVersion() == $revision->getVersion());
85 //$version = ($revision->getVersion());
86 //$pagename = ($page->getName());
87 function toolabr_action_PageActions($pagelocked, $userisadmin, $is_current, $version, $pagename) {
88     $html = "";
89     if ($pagelocked && !$userisadmin) {
90         $html .= _("Page locked");
91     } else {
92         if ($is_current) {
93             $html .= "<a class=\"wikiaction\" href=\"" .WikiURL($pagename, array('action' => 'edit')) ."\">" ._("Edit") ."</a>";
94         } else {
95             $html .= "<a class=\"wikiaction\" href=\"" .WikiURL($pagename, array('action' => 'edit&amp;version=' .$version));
96             $html .= ">" ._("Edit old revision") ."</a>";
97         }
98     }
99     if ($userisadmin) {
100         if ($pagelocked) {
101             $html .= separator() ."<a class=\"wikiadmin\" href=\"" .WikiURL($pagename, array('action' => 'unlock')) ."\">" ._("Unlock page") ."</a>";
102         } else {
103             $html .= separator() ."<a class=\"wikiadmin\" href=\"" .WikiURL($pagename, array('action' => 'lock')) ."\">" ._("Lock page") ."</a>";
104         }
105         $html .= separator() ."<a class=\"wikiadmin\" href=\"" .WikiURL($pagename, array('action' => 'remove')) ."\">" ._("Remove page") ."</a>";
106     }
107         //$html .= separator() ."<plugin-link PageHistory page=\"" .$pagename ."\"";
108         $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL(_("PageHistory"), array('page' => $pagename)) ."\">" ._("PageHistory") ."</a>";
109
110     if ($is_current) {
111         $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL($pagename, array('action' => 'diff&amp;previous=major')) ."\">" ._("Diff") ."</a>";
112     } else {
113         $html .= separator() ."<a class=\"wikiaction\"";
114         $html .= "href=\"" . WikiURL($pagename, array('action' => 'diff&amp;version=' .$version .'&amp;previous=major')) ."\">" ._("Diff") ."</a>";
115     }
116         //$html .= separator() ."<plugin-link BackLinks page=\"" .$pagename ."\"";
117         $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL(_("BackLinks"), array('page' => $pagename)) ."\">" ._("BackLinks") ."</a>";
118
119     return $html;
120 }
121
122 //Calling function should provide:
123 //$pagename = ($page->getName());
124 //$charset = (CHARSET);
125 function toolbar_action_SearchActions($pagename, $charset) {
126     $html = "";
127     $html .= "<form action=\"" .WikiURL(_("TitleSearch")) ."\" method=\"get\" accept-charset=\"" .$charset ."\">";
128     $html .= toolbar_action_Navigation($pagename) .separator() .LinkExistingWikiWord(_("FindPage"));
129     $html .= separator() ."<span><input type=\"hidden\" name=\"auto_redirect\" value=\"1\" />";
130     $html .= "<input type=\"text\"  name=\"s\" size=\"12\"";
131     $html .= " title=" ._("Quick Search");
132     $html .= " onmouseover=\"window.status='" ._("Quick Search") ."'; return true;";
133     $html .= " onmouseout=\"window.status=''; return true;\" /></span>";
134
135     //$html .= separator() ."<plugin-link LikePages page=\"" .$pagename ."\" >";
136     $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL(_("LikePages"), array('page' => $pagename)) ."\">" ._("LikePages") ."</a>";
137
138 //    $html .= "</form>";
139     return $html;
140 }
141
142 //Calling function should provide: done - WARNING: hackage! $pagename is not being passed here yet
143 //$userauth = ($user->is_authenticated();
144 //$userid = ($user->id());
145 //$pagename = ($pagename);
146 function toolbar_User_UserSignInOut($userauth, $userid, $pagename) {
147     $html = "";
148     if ($userauth) {
149         $html .= sprintf(_("You are signed in as %s"), LinkWikiWord($userid));
150         $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL($pagename, array('action' => 'logout')) ."\">" ._("SignOut") ."</a>";
151     } else {
152         $html .= "<a class=\"wikiaction\" href=\"" . WikiURL($pagename, array('action' => 'login')) ."\">" ._("SignIn") ."</a>";
153     }
154     return $html;
155 }
156
157 //Calling function should provide: - done
158 //$wiki_name = (WIKI_NAME);
159 //$logo = ($logo);
160 function toolbar_action_Logo($wiki_name, $logo) {
161     $html = "";
162     $html .= "<a class=\"wikilink\" href=\"" .WikiURL(_("HomePage")) ."\">";
163     $html .= "<img alt=\"" .$wiki_name .":" ._("HomePage") ."\"";
164     $html .= " src=\"" . DataURL($logo) ."\"";
165     $html .= " border=\"0\" align=\"right\" /></a>";
166     return $html;
167 }
168
169 //Calling function should provide: - done
170 //$pagename = ($pagename);
171 function toolbar_action_Navigation($pagename) {
172     $html = "";
173     $html .= LinkExistingWikiWord(_("RecentChanges"));
174     //$html .= separator() ."<plugin-link RandomPage page=\"" .$pagename ."\" >";
175     //FIXME: What to use instead of WikiURL?
176 //    $html .= separator() ."<a class=\"wikiaction\" href=\"" .WikiURL('_("RandomPage")', array('page' => $pagename)) ."\">" ._("RandomPage") ."</a>";
177     //$html .= separator() ."<plugin-link WantedPages >";
178 //    $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL(_("WantedPages")) ."\">" ._("WantedPages") ."</a>";
179 //    $html .= separator() .LinkExistingWikiWord(_("SandBox"));
180     return $html;
181 }
182
183
184 //EditPage stuff
185
186 //Calling function should provide:
187 //$ispreview = (!empty($PREVIEW_CONTENT));
188 function toolbar_Warning_Preview($ispreview) {
189     $html = "";
190     if ($ispreview) {
191         $html .= "<p><strong>" ._("Preview only!  Changes not saved.") ."</strong></p>";
192     }
193     return $html;
194 }
195
196 //Calling function should provide:
197 //$is_current = ($current->getVersion() == $revision->getVersion());
198 function toolbar_Warning_OldRevision($is_current) {
199     $html = "";
200     if (!$is_current) {
201         $html .= "<p><strong>" ._("Warning: You are editing an old revision.");
202         $html .= " " ._("Saving this page will overwrite the current version.") ."</strong></p>";
203         $html .= "<hr class=\"ignore\" noshade />";
204     }
205     return $html;
206 }
207
208 //$userid = ($user->id())
209 function toolbar_User_AuthorSignInOut($userid) {
210     $html = "";
211     if ($user->is_authenticated()) {
212         $html .= sprintf(_("You are signed in as %s."), LinkWikiWord($userid));
213     } else {
214         $html .= sprintf(_("Author will be logged as %s."),"<em>" .$userid ."</em>");
215         $html .= separator() ."<a class=\"wikiaction\" href=\"" .WikiURL($pagename, array('action' => 'login')) ."\">" ._("SignIn") ."</a>";
216         $html .= "<small>*</small><br><small>*backup and reload after signing in</small>";
217     }
218     return $html;
219 }
220
221 function toolbar_Info_EditTips() {
222     $html = "";
223     $html .= sprintf(_("You can change the size of the editing area in %s."), LinkExistingWikiWord(_("UserPreferences")));
224     $html .= sprintf(_("See %s tips for editing."),LinkExistingWikiWord(_("GoodStyle")));
225     return $html;
226 }
227
228 //FIXME: plugin IncludePage
229 function toolbar_Info_EditHelp() {
230     $html = "";
231     $html .= "<div class=\"wiki-edithelp\">";
232     $html .= "<plugin IncludePage page=" ._("TextFormattingRules") ."section=" ._("Synopsis") ."quiet=1>";
233     $html .= "</div>";
234     return $html;
235 }
236
237
238 // This is a stub for a Toolbar class to eventually replace the
239 // functions above.
240 // 
241
242 class Toolbar
243 {
244     function Toolbar() {
245         //$this->_tmpl = $this->_munge_input($tmpl);
246         //$this->_tmpl = $tmpl;
247         //$this->_tname = $tname;
248         //$this->_vars = array();
249     }
250
251    function appenditem($item) {
252
253     /*
254
255         identify: command or info-display?
256         - is WikiPlugin?
257         locale
258
259         future:
260             toolbar style, text-only or graphic buttons?
261             -if text-only, use " | " as item separator
262     */
263
264    }
265
266
267 }
268
269 class WikiToolbar
270 extends Toolbar
271 {
272     /**
273      * Constructor.
274      *
275      */
276     function WikiToolbar($tname) {
277
278     /*
279         build_html_toolbar()
280         send html back to transform (or whatever will be calling this)
281     */
282
283     }
284
285     function build_html_Toolbar() {
286
287     /*
288         toolbars could be an array of commands or labels
289
290         which toolbar?
291         - label, info display only (Modification date)
292         - label, info display only ("See Goodstyle Tips for editing".)
293         - Search navigation (FindPage, LikePages, search field)
294         - Wiki navigation (RecentChanges, RandomPages, WantedPages, Top10 etc.)
295         - Logo navigation (Homepage)
296         - label and command ("You are logged in as Bogouser. | SignOut")
297
298         which toolbar items?
299         loop
300             requires user authenticated?
301             - check is authenticated
302             - check is admin
303             appenditem
304         endloop
305         return $html
306     */
307
308     }
309 }
310
311
312
313 // Local Variables:
314 // mode: php
315 // tab-width: 8
316 // c-basic-offset: 4
317 // c-hanging-comment-ender-p: nil
318 // indent-tabs-mode: nil
319 // End:  
320 ?>