From 3a20ed01f504504e6a2cb1441b1449c7d021dad5 Mon Sep 17 00:00:00 2001 From: rurban Date: Sat, 2 Jun 2007 18:23:49 +0000 Subject: [PATCH] Added accesskeys git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@5727 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/EditToolbar.php | 44 +++++++++++++++++++++++++++----------------- lib/HtmlElement.php | 25 +++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/lib/EditToolbar.php b/lib/EditToolbar.php index 4a47d4ec8..b42513236 100644 --- a/lib/EditToolbar.php +++ b/lib/EditToolbar.php @@ -1,5 +1,5 @@ getDbh(); // regenerate if number of pages changes (categories, pages, templates) @@ -92,6 +91,7 @@ msg_repl_close = '"._("Close")."' global $WikiTheme; $toolbar = "document.writeln(\"
\");\n"; + $accessKeyPrefix = $WikiTheme->tooltipAccessKeyPrefix(); if (ENABLE_EDIT_TOOLBAR) { $username = $GLOBALS['request']->_user->UserName(); @@ -105,71 +105,75 @@ msg_repl_close = '"._("Close")."' "open"=>"", "close"=>"", "sample"=>_("Bold text"), - "tip"=>_("Bold text")), + "title"=>_("Bold text [alt-b]")), array("image"=>"ed_format_italic.png", "open"=>"", "close"=>"", "sample"=>_("Italic text"), - "tip"=>_("Italic text")), + "title"=>_("Italic text [alt-i]")), array("image"=>"ed_pagelink.png", "open"=>"[", "close"=>"]", "sample"=>_("optional label | PageName"), - "tip"=>_("Link to page")), + "title"=>_("Link to page")), array("image"=>"ed_link.png", "open"=>"[", "close"=>"]", "sample"=>_("optional label | http://www.example.com"), - "tip"=>_("External link (remember http:// prefix)")), + "title"=>_("External link (remember http:// prefix)")), array("image"=>"ed_headline.png", "open"=>"\\n!!! ", "close"=>"\\n", "sample"=>_("Headline text"), - "tip"=>_("Level 1 headline")), + "title"=>_("Level 1 headline")), array("image"=>"ed_image.png", "open"=>"[ ", "close"=>" ]", "sample"=>_("Example.jpg"), - "tip"=>_("Embedded image")), + "title"=>_("Embedded image")), array("image"=>"ed_nowiki.png", "open"=>"\\\\n", "close"=>"\\n\\", "sample"=>_("Insert non-formatted text here"), - "tip"=>_("Ignore wiki formatting")), + "title"=>_("Ignore wiki formatting")), array("image"=>"ed_sig.png", "open" => $signature, "close" => "", "sample"=>"", - "tip"=>_("Your signature")), + "title"=>_("Your signature")), array("image"=>"ed_hr.png", "open"=>"\\n----\\n", "close"=>"", "sample"=>"", - "tip"=>_("Horizontal line")) + "title"=>_("Horizontal line")) ); $btn = new SubmitImageButton(_("Save"), "edit[save]", 'toolbar', $WikiTheme->getImageURL("ed_save.png")); $btn->addTooltip(_("Save")); + $btn->setAccesskey("s"); $toolbar .= ('document.writeln("'.addslashes($btn->asXml()).'");'."\n"); // preview not supported yet on Wikiblog if (empty($WikiTheme->_headers_printed)) { $btn = new SubmitImageButton(_("Preview"), "edit[preview]", 'toolbar', $WikiTheme->getImageURL("ed_preview.png")); $btn->addTooltip(_("Preview")); + $btn->setAccesskey("p"); $toolbar .= ('document.writeln("'.addslashes($btn->asXml()).'");'."\n"); } foreach ($toolarray as $tool) { + global $WikiTheme; $image = $WikiTheme->getImageURL($tool["image"]); $open = $tool["open"]; $close = $tool["close"]; $sample = addslashes( $tool["sample"] ); - // Note that we use the tip both for the ALT tag and the TITLE tag of the image. + // Note that we use the title both for the ALT tag and the TITLE tag of the image. // Older browsers show a "speedtip" type message only for ALT. // Ideally these should be different, realistically they // probably don't need to be. - $tip = addslashes( $tool["tip"] ); - $toolbar .= ("addTagButton('$image','$tip','$open','$close','$sample');\n"); + $tool = $WikiTheme->fixAccesskey($tool); + $title = addslashes( $tool["title"] ); + $toolbar .= ("addTagButton('$image','$title','$open','$close','$sample');\n"); } $toolbar .= ("addInfobox('" . addslashes( _("Click a button to get an example text") ) @@ -194,7 +198,8 @@ msg_repl_close = '"._("Close")."' (array('class'=>"toolbar", 'src' => $sr_btn, 'alt' =>_("Search & Replace"), - 'title'=>_("Search & Replace"), + 'title'=>_("Search & Replace")." [$accessKeyPrefix-h]", + 'accesskey' => 'h', 'onclick'=>"replace()"))); } else { $sr_html = ''; @@ -336,9 +341,11 @@ msg_repl_close = '"._("Close")."' } // result is cached. Esp. the args are expensive + // FIXME! function templatePulldown($query, $case_exact=false, $regex='auto') { + global $request; require_once('lib/TextSearchQuery.php'); - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; $page_iter = $dbi->titleSearch(new TextSearchQuery($query, $case_exact, $regex)); $count = 0; if ($page_iter->count()) { @@ -371,6 +378,9 @@ msg_repl_close = '"._("Close")."' /* $Log: not supported by cvs2svn $ +Revision 1.11 2007/02/17 14:16:21 rurban +move define_f after toolbar.js + Revision 1.10 2007/01/07 18:42:19 rurban Improve id: edit: to edit-. Move search&replace js from body (defined in EditToolbar) to the toolbar.js. Support actionpages. Add tb-name argument to showPulldown diff --git a/lib/HtmlElement.php b/lib/HtmlElement.php index 2c010bf3b..924e43ec2 100644 --- a/lib/HtmlElement.php +++ b/lib/HtmlElement.php @@ -1,4 +1,4 @@ -setAttr('title', $tooltip_text); + if ($accesskey) $this->setAccesskey($accesskey); // FIXME: this should be initialized from title by an onLoad() function. // (though, that may not be possible.) @@ -75,6 +76,23 @@ class HtmlElement extends XmlElement $this->setAttr('onmouseout', "window.status='';return true;"); } + function setAccesskey ($key) { + global $WikiTheme; + if (strlen($key) != 1) return; + $this->setAttr("accesskey", $key); + + if (!empty($this->_attr['title'])) { + if (preg_match("/\[(alt-)?(.)\]$/", $this->_attr['title'], $m)) + { + $this->_attr['title'] = preg_replace("/\[(alt-)?(.)\]$/", "[".$WikiTheme->tooltipAccessKeyPrefix()."-\\2]", $this->_attr['title']); + } else { + $this->_attr['title'] .= " [".$WikiTheme->tooltipAccessKeyPrefix()."-$key]"; + } + } else { + $this->_attr['title'] = "[".$WikiTheme->tooltipAccessKeyPrefix()."-$key]"; + } + } + function emptyTag () { if (($this->_properties & HTMLTAG_EMPTY) == 0) return $this->startTag() . "_tag>"; @@ -539,6 +557,9 @@ function IfJavaScript($if_content = false, $else_content = false) { /** $Log: not supported by cvs2svn $ + Revision 1.48 2007/05/24 18:51:35 rurban + add param (for YouTube) + Revision 1.47 2005/08/06 12:53:36 rurban beautify SCRIPT lines -- 2.45.0