From: Carsten K. <car...@us...> - 2002-01-03 15:40:43
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv29040 Modified Files: Toolbar.php Log Message: Cleaned up sytnax errors. Finalized local variables. Eliminated WikiURL(''') "action" hackage. Converted raw plugins to WikiURLs. (Some of these functions are working, so some chunks in the xhtml templates can be replaced with new ${tokens} to call these functions. Please help... to update Template.php accordingly; see comments in Toolbar.php for info how to call these functions.) Index: Toolbar.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/Toolbar.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Toolbar.php 2002/01/03 02:17:11 1.2 --- Toolbar.php 2002/01/03 15:40:40 1.3 *************** *** 4,89 **** require_once("lib/WikiPlugin.php"); - /* - - FIXME: This is a stub for a Toolbar class to eventually replace the - PHP logic currently embedded in the html templates, used to build the - Wiki commands and navigation links at the bottom of the screen. - - If you feel inspired please contribute here. - - (This is all in a state of flux, so don't count on any of this being - the same tomorrow...) - - */ - - class Toolbar - { - function Toolbar() { - //$this->_tmpl = $this->_munge_input($tmpl); - //$this->_tmpl = $tmpl; - //$this->_tname = $tname; - //$this->_vars = array(); - } - - function appenditem($item) { - - /* - - identify: command or info-display? - - is WikiPlugin? - locale - - future: - toolbar style, text-only or graphic buttons? - -if text-only, use " | " as item separator - */ - - } - - - } - - class WikiToolbar - extends Toolbar - { - /** - * Constructor. - * - */ - function WikiToolbar($tname) { - - /* - build_html_toolbar() - send html back to transform (or whatever will be calling this) - */ - - } - - function build_html_Toolbar() { - - /* - toolbars could be an array of commands or labels - - which toolbar? - - label, info display only (Modification date) - - label, info display only ("See Goodstyle Tips for editing".) - - Search navigation (FindPage, LikePages, search field) - - Wiki navigation (RecentChanges, RandomPages, WantedPages, Top10 etc.) - - Logo navigation (Homepage) - - label and command ("You are logged in as Bogouser. | SignOut") - - which toolbar items? - loop - requires user authenticated? - - check is authenticated - - check is admin - appenditem - endloop - return $html - */ - - } - } - function separator() { /* --- 4,7 ---- *************** *** 106,127 **** } ! // There is still some work to do before these functions ! // can be used as ${tokens} in the xhtml templates: // ! // Plugins and [pagename] need to be dealt with. // ! // Which variables are to be passed to the functions is not finalised yet. // ! // The raw html should also be replaced with calls to // Element() and/or QElement() ! //BrowsePage stuff ! function toolbar_Warning_IsCurrent($IS_CURRENT, $BROWSE, $PAGEURL) { $html = ""; ! if (! $IS_CURRENT) { $html .= "<p><strong>" ._("Note:") ."</strong> " ._("You are viewing an old revision of this page."); ! $html .= "<a href=\"" .${BROWSE} .${PAGEURL} ."\">" ._("View the current version") ."</a>.</p>"; $html .= "<hr class=\"ignore\" noshade=\"noshade\" />"; } --- 24,63 ---- } + /* + + These functions will replace the PHP logic currently embedded in + the html templates, used to build the Wiki commands and navigation + links at the bottom of the screen. + + If you feel inspired please contribute here! + + (This is all in a state of flux, so don't count on any of this being + the same tomorrow...) ! */ ! ! // Some of these functions are ready to be used as ${tokens} ! // in the xhtml templates. // ! // FIXME: ! // IncludePage plugin for EditHelp needs to be dealt with. // ! // Plugins shuold be cleaned up, in this state they won't display ! // any mouseover text // ! // The raw html should be replaced with calls to // Element() and/or QElement() + + // BrowsePage stuff ! //Calling function should provide: ! //$is_current = ($current->getVersion() == $revision->getVersion()) ! //$pageurl = (rawurlencode($pagename)) ! function toolbar_Warning_IsCurrent($is_current, $pageurl) { $html = ""; ! if (!$is_current) { $html .= "<p><strong>" ._("Note:") ."</strong> " ._("You are viewing an old revision of this page."); ! $html .= "<a href=\"" .WikiURL('') .$pageurl ."\">" ._("View the current version") ."</a>.</p>"; $html .= "<hr class=\"ignore\" noshade=\"noshade\" />"; } *************** *** 129,178 **** } ! function toolbar_Info_LastModified($IS_CURRENT, $LASTMODIFIED, $VERSION) { $html = ""; ! if ($IS_CURRENT) { ! $html .= sprintf(_("Last edited on %s."),$LASTMODIFIED); } else { ! $html .= sprintf(_("Version %s, saved on %s."),$VERSION,$LASTMODIFIED); } return $html; } ! function toolabr_action_PageActions($page, $user, $IS_CURRENT, $ACTION, $VERSION) { $html = ""; ! if ($page->get('locked') && !$user->is_admin()) { $html .= _("Page locked"); } else { ! if ($IS_CURRENT) { ! $html .= "<a class=\"wikiaction\" href=\"" .${ACTION} ."edit\">" ._("Edit") ."</a>"; } else { ! $html .= "<a class=\"wikiaction\" href=\"" .${ACTION} ."edit&version=" .${VERSION}; $html .= ">" ._("Edit old revision") ."</a>"; } } ! if ($user->is_admin()) { ! if ($page->get('locked')) { ! $html .= separator() ."<a class=\"wikiadmin\" href=\"" .${ACTION} ."unlock\">" ._("Unlock page") ."</a>"; } else { ! $html .= separator() ."<a class=\"wikiadmin\" href=\"" .{$ACTION} ."lock\">" ._("Lock page") ."</a>"; } ! $html .= separator() ."<a class=\"wikiadmin\" href=\"" .{$ACTION} ."remove\">" ._("Remove page") ."</a>"; } ! $html .= separator() ."<?plugin-link PageHistory page=\"[pagename]\""; ! if ($IS_CURRENT) { ! $html .= separator() ."<a class=\"wikiaction\" href=\"" .${ACTION} ."diff&previous=major\">" ._("Diff") ."</a>"; } else { $html .= separator() ."<a class=\"wikiaction\""; ! $html .= "href=\"" .${ACTION} ."diff&version=" .${VERSION} ."&previous=major\">" ._("Diff") ."</a>"; } $html .= ! $html .= separator() .LinkExistingWikiWord(_("BackLinks")); return $html; } ! function toolbar_action_SearchActions($page, $CHARSET) { $html = ""; ! $html .= "<form action=\"" .WikiURL(_("TitleSearch")) ."\" method=\"get\" accept-charset=\"" .${CHARSET} ."\">"; $html .= LinkExistingWikiWord(_("RecentChanges")); $html .= separator() .LinkExistingWikiWord(_("FindPage")); --- 65,130 ---- } ! //Calling function should provide: ! //$is_current = ($current->getVersion() == $revision->getVersion()) ! //$lastmodified = (strftime($datetimeformat, $revision->get('mtime'))) ! //$version = ($revision->getVersion()) ! function toolbar_Info_LastModified($is_current, $lastmodified, $version) { $html = ""; ! if ($is_current) { ! $html .= sprintf(_("Last edited on %s.") $lastmodified); } else { ! $html .= sprintf(_("Version %s, saved on %s."),$version, $lastmodified); } return $html; } ! //Calling function should provide: ! //$pagelocked = ($page->get('locked')) ! //$userisadmin = ($user->is_admin()) ! //$is_current = ($current->getVersion() == $revision->getVersion()) ! //$version = ($revision->getVersion())) ! //$pagename = ($page->getName()) ! function toolabr_action_PageActions($pagelocked, $userisadmin, $is_current, $version, $pagename) { $html = ""; ! if ($pagelocked && !$userisadmin) { $html .= _("Page locked"); } else { ! if ($is_current) { ! $html .= "<a class=\"wikiaction\" href=\"" .WikiURL($pagename, array('action' => 'edit')) ."\">" ._("Edit") ."</a>"; } else { ! $html .= "<a class=\"wikiaction\" href=\"" .WikiURL($pagename, array('action' => 'edit&version=' .$version)); $html .= ">" ._("Edit old revision") ."</a>"; } } ! if ($userisadmin) { ! if ($pagelocked) { ! $html .= separator() ."<a class=\"wikiadmin\" href=\"" .WikiURL($pagename, array('action' => 'unlock')) ."\">" ._("Unlock page") ."</a>"; } else { ! $html .= separator() ."<a class=\"wikiadmin\" href=\"" .WikiURL($pagename, array('action' => 'lock')) ."\">" ._("Lock page") ."</a>"; } ! $html .= separator() ."<a class=\"wikiadmin\" href=\"" .WikiURL($pagename, array('action' => 'remove')) ."\">" ._("Remove page") ."</a>"; } ! //$html .= separator() ."<?plugin-link PageHistory page=\"" .$pagename ."\""; ! $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL(_("PageHistory"), array('page' => $pagename)) ."\">" ._("PageHistory") ."</a>"; ! ! if ($is_current) { ! $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL($pagename, array('action' => 'diff&previous=major')) ."\">" ._("Diff") ."</a>"; } else { $html .= separator() ."<a class=\"wikiaction\""; ! $html .= "href=\"" . WikiURL($pagename, array('action' => 'diff&version=' .$version .'&previous=major')) ."\">" ._("Diff") ."</a>"; } $html .= ! //$html .= separator() ."<?plugin-link BackLinks page=\"" .$pagename ."\""; ! $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL(_("BackLinks"), array('page' => $pagename)) ."\">" ._("BackLinks") ."</a>"; return $html; } ! //Calling function should provide: ! //$pagename = ($page->getName()) ! //$charset = (CHARSET) ! function toolbar_action_SearchActions($pagename, $charset) { $html = ""; ! $html .= "<form action=\"" .WikiURL(_("TitleSearch")) ."\" method=\"get\" accept-charset=\"" .$charset ."\">"; $html .= LinkExistingWikiWord(_("RecentChanges")); $html .= separator() .LinkExistingWikiWord(_("FindPage")); *************** *** 182,209 **** $html .= " onmouseover=\"window.status='" ._("Quick Search") ."'; return true;"; $html .= " onmouseout=\"window.status=''; return true;\" /></span>"; ! $html .= separator() ."<?plugin-link LikePages page=\"[pagename]\" ?>"; $html .= "</form>"; return $html; } ! function toolbar_User_UserSignInOut($user, $USERID, $ACTION) { ! $html = ""; ! if ($user->is_authenticated()) { ! $html .= sprintf(_("You are signed in as %s"), LinkWikiWord($USERID)); ! $html .= separator() ."<a class=\"wikiaction\" href=\"" .${ACTION} ."logout\">" ._("SignOut") ."</a>"; } else { ! $html .= "<a class=\"wikiaction\" href=\"" .${ACTION} ."login\">" ._("SignIn") ."</a>"; } return $html; } ! function toolbar_action_Logo($BROWSE, $WIKI_NAME, $LOGO) { $html = ""; $html .= "<div>"; ! $html .= "<a class=\"wikilink\" href=\"" .${BROWSE} ._("HomePage") ."\">"; ! $html .= "<img alt=\"" .${WIKI_NAME} .":" ._("HomePage"); ! $html .= " src=\"" .${LOGO} ."\""; ! $html .= " border=\"0\" ."\" align=\"right\" />"; ! $html .= "</a></div>" return $html; } --- 134,170 ---- $html .= " onmouseover=\"window.status='" ._("Quick Search") ."'; return true;"; $html .= " onmouseout=\"window.status=''; return true;\" /></span>"; ! ! //$html .= separator() ."<?plugin-link LikePages page=\"" .$pagename ."\" ?>"; ! $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL(_("LikePages"), array('page' => $pagename)) ."\">" ._("LikePages") ."</a>"; ! $html .= "</form>"; return $html; } ! //Calling function should provide: ! //$userauth = ($user->is_authenticated() ! //$userid = ($user->id()) ! function toolbar_User_UserSignInOut($userauth, $userid) { ! $html = ""; ! if ($userauth) { ! $html .= sprintf(_("You are signed in as %s"), LinkWikiWord($userid)); ! $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL($pagename, array('action' => 'logout')) ."\">" ._("SignOut") ."</a>"; } else { ! $html .= "<a class=\"wikiaction\" href=\"" . WikiURL($pagename, array('action' => 'login')) ."\">" ._("SignIn") ."</a>"; } return $html; } ! //Calling function should provide: ! //$wiki_name = (WIKI_NAME) ! //$logo = ($logo) ! function toolbar_action_Logo($wiki_name, $logo) { $html = ""; $html .= "<div>"; ! $html .= "<a class=\"wikilink\" href=\"" .WikiURL(_("HomePage")) ."\">"; ! $html .= "<img alt=\"" .$wiki_name .":" ._("HomePage"); ! $html .= " src=\"" . DataURL($logo) ."\""; ! $html .= " border=\"0\" align=\"right\" />"; ! $html .= "</a></div>"; return $html; } *************** *** 211,218 **** function toolbar_action_Navigation() { $html = ""; ! $html .= _("RecentChanges"); ! // $html .= separator() ._("RandomPage"); ! // $html .= separator() ._("WantedPages"); ! // $html .= separator() ._("SandBox"); return $html; } --- 172,181 ---- function toolbar_action_Navigation() { $html = ""; ! $html .= LinkExistingWikiWord(_("RecentChanges")); ! //$html .= separator() ."<?plugin-link RandomPage page=\"" .$pagename ."\" ?>"; ! $html .= separator() ."<a class=\"wikiaction\" href=\"" . WikiURL(_("RandomPage"), array('page' => $pagename)) ."\">" ._("RandomPage") ."</a>"; ! //$html .= separator() ."<?plugin-link WantedPages ?>"; ! $html .= separator() ."<a class=\"wikiaction\" href=\"" . LinkExistingWikiWord(_("WantedPages")) ."\">" ._("WantedPages") ."</a>"; ! // $html .= separator() .LinkExistingWikiWord(_("SandBox")); return $html; } *************** *** 221,237 **** //EditPage stuff ! function toolbar_Warning_Preview($PREVIEW_CONTENT) { $html = ""; ! if (!empty($PREVIEW_CONTENT)) { $html .= "<p><strong>" ._("Preview only! Changes not saved.") ."</strong></p>"; - $html .= "<div class="wikitext">" .${PREVIEW_CONTENT} ."</div>"; - $html .= "<hr class=\"ignore\" noshade />"; } return $html; } ! function toolbar_Warning_OldRevision() { $html = ""; ! if (!$IS_CURRENT) { $html .= "<p><strong>" ._("Warning: You are editing an old revision."); $html .= " " ._("Saving this page will overwrite the current version.") ."</strong></p>"; --- 184,202 ---- //EditPage stuff ! //Calling function should provide: ! //$ispreview = (!empty($PREVIEW_CONTENT)) ! function toolbar_Warning_Preview($ispreview) { $html = ""; ! if ($ispreview) { $html .= "<p><strong>" ._("Preview only! Changes not saved.") ."</strong></p>"; } return $html; } ! //Calling function should provide: ! //$is_current = ($current->getVersion() == $revision->getVersion()) ! function toolbar_Warning_OldRevision($is_current) { $html = ""; ! if (!$is_current) { $html .= "<p><strong>" ._("Warning: You are editing an old revision."); $html .= " " ._("Saving this page will overwrite the current version.") ."</strong></p>"; *************** *** 241,253 **** } ! function toolbar_User_AuthorSignInOut() { $html = ""; if ($user->is_authenticated()) { ! $html .= sprintf(_("You are signed in as %s."), LinkWikiWord($USERID)); } else { ! $html .= sprintf(_("Author will be logged as %s."),"<em>${USERID}</em>"); ! $html .= separator() ."<a class=\"wikiaction\" href=\"" .${ACTION} ."login\">"; ! $html .= _("SignIn") ."<small>*</small></a>"; ! $html .= "<br><small>*backup and reload after signing in</small>"; } return $html; --- 206,218 ---- } ! //$userid = ($user->id()) ! function toolbar_User_AuthorSignInOut($userid) { $html = ""; if ($user->is_authenticated()) { ! $html .= sprintf(_("You are signed in as %s."), LinkWikiWord($userid)); } else { ! $html .= sprintf(_("Author will be logged as %s."),"<em>" .$userid ."</em>"); ! $html .= separator() ."<a class=\"wikiaction\" href=\"" .WikiURL($pagename, array('action' => 'login')) ."\">" ._("SignIn") ."</a>"; ! $html .= "<small>*</small><br><small>*backup and reload after signing in</small>"; } return $html; *************** *** 261,264 **** --- 226,230 ---- } + //FIXME: plugin IncludePage function toolbar_Info_EditHelp() { $html = ""; *************** *** 268,271 **** --- 234,313 ---- return $html; } + + + // This is a stub for a Toolbar class to eventually replace the + // functions above. + // + + class Toolbar + { + function Toolbar() { + //$this->_tmpl = $this->_munge_input($tmpl); + //$this->_tmpl = $tmpl; + //$this->_tname = $tname; + //$this->_vars = array(); + } + + function appenditem($item) { + + /* + + identify: command or info-display? + - is WikiPlugin? + locale + + future: + toolbar style, text-only or graphic buttons? + -if text-only, use " | " as item separator + */ + + } + + + } + + class WikiToolbar + extends Toolbar + { + /** + * Constructor. + * + */ + function WikiToolbar($tname) { + + /* + build_html_toolbar() + send html back to transform (or whatever will be calling this) + */ + + } + + function build_html_Toolbar() { + + /* + toolbars could be an array of commands or labels + + which toolbar? + - label, info display only (Modification date) + - label, info display only ("See Goodstyle Tips for editing".) + - Search navigation (FindPage, LikePages, search field) + - Wiki navigation (RecentChanges, RandomPages, WantedPages, Top10 etc.) + - Logo navigation (Homepage) + - label and command ("You are logged in as Bogouser. | SignOut") + + which toolbar items? + loop + requires user authenticated? + - check is authenticated + - check is admin + appenditem + endloop + return $html + */ + + } + } + + // Local Variables: |