From: Erik Moeller Date: Sun, 11 Jan 2004 04:11:43 +0000 (+0000) Subject: New edit toolbar for bold, italic, links, headlines, math, images, media, X-Git-Tag: 1.3.0beta1~1173 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=0ecb335f9147449825dae404d2f6d9b36c8d7dfa;p=lhc%2Fweb%2Fwiklou.git New edit toolbar for bold, italic, links, headlines, math, images, media, sigs, horizontal lines (more can be added easily). Select text and click to apply, or just click to see an example. Mouseover should show speedtips. Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE --- diff --git a/includes/EditPage.php b/includes/EditPage.php index efe60d494f..72be47615d 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -116,10 +116,10 @@ class EditPage { return; } # If article is new, insert it. - - $aid = $this->mTitle->getArticleID(); + + $aid = $this->mTitle->getArticleID(); if ( 0 == $aid ) { - # we need to strip Windoze linebreaks because some browsers + # we need to strip Windoze linebreaks because some browsers # append them and the string comparison fails if ( ( "" == $wpTextbox1 ) || ( wfMsg( "newarticletext" ) == rtrim( preg_replace("/\r/","",$wpTextbox1) ) ) ) { @@ -134,8 +134,8 @@ class EditPage { # Don't check for conflict when appending a comment - this should always work $this->mArticle->clear(); # Force reload of dates, etc. - if ( $section!="new" && ( $this->mArticle->getTimestamp() != $wpEdittime ) ) { - $isConflict = true; + if ( $section!="new" && ( $this->mArticle->getTimestamp() != $wpEdittime ) ) { + $isConflict = true; } $u = $wgUser->getID(); @@ -180,7 +180,7 @@ class EditPage { } else { $s = wfMsg( "editing", $this->mTitle->getPrefixedText() ); - if($section!="") { + if($section!="") { if($section=="new") { $s.=wfMsg("commentedit"); } else { @@ -206,11 +206,11 @@ class EditPage { $kblength = (int)(strlen( $wpTextbox1 ) / 1024); if( $kblength > 29 ) { - $wgOut->addHTML( "" . + $wgOut->addHTML( "" . wfMsg( "longpagewarning", $kblength ) . "" ); } - + $rows = $wgUser->getOption( "rows" ); $cols = $wgUser->getOption( "cols" ); @@ -222,7 +222,7 @@ class EditPage { if ( "no" == $redirect ) { $q .= "&redirect=no"; } $action = wfEscapeHTML( wfLocalUrl( $this->mTitle->getPrefixedURL(), $q ) ); - $summary = wfMsg( "summary" ); + $summary = wfMsg( "summary" ); $subject = wfMsg("subject"); $minor = wfMsg( "minoredit" ); $watchthis = wfMsg ("watchthis"); @@ -239,38 +239,44 @@ class EditPage { $wpTextbox1 = wfEscapeHTML( $wpTextbox1 ); $wpTextbox2 = wfEscapeHTML( $wpTextbox2 ); $wpSummary = wfEscapeHTML( $wpSummary ); - + + + if($wgUser->getOption("showtoolbar")) { + // prepare toolbar for edit buttons + $toolbar=$sk->getEditToolbar(); + } + // activate checkboxes if user wants them to be always active if (!$wpPreview && $wgUser->getOption("watchdefault")) $wpWatchthis=1; - if (!$wpPreview && $wgUser->getOption("minordefault")) $wpMinoredit=1; - + if (!$wpPreview && $wgUser->getOption("minordefault")) $wpMinoredit=1; + // activate checkbox also if user is already watching the page, // require wpWatchthis to be unset so that second condition is not // checked unnecessarily if (!$wpWatchthis && !$wpPreview && $this->mTitle->userIsWatching()) $wpWatchthis=1; - + if ( 0 != $wgUser->getID() ) { $checkboxhtml= "". "". "". "
"; - + } else { $checkboxhtml=""; } if ( "preview" == $formtype) { - - $previewhead="

" . wfMsg( "preview" ) . "

\n

" . + + $previewhead="

" . wfMsg( "preview" ) . "

\n

" . wfMsg( "note" ) . wfMsg( "previewnote" ) . "

\n"; if ( $isConflict ) { $previewhead.="

" . wfMsg( "previewconflict" ) . "

\n"; } $previewtext = wfUnescapeHTML( $wpTextbox1 ); - + if($wgUser->getOption("previewontop")) { $wgOut->addHTML($previewhead); $wgOut->addWikiText( $this->mArticle->preSaveTransform( $previewtext ) ."\n\n"); @@ -293,6 +299,7 @@ class EditPage { $wgOut->setOnloadHandler( "document.editform.wpTextbox1.focus()" ); } $wgOut->addHTML( " +{$toolbar}
{$commentsubject} @@ -303,8 +310,8 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
{$editsummary} {$checkboxhtml} - - + + {$cancel} | {$edithelp}

{$copywarn} diff --git a/includes/Skin.php b/includes/Skin.php index e5638f77c9..7af2d63090 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1923,6 +1923,98 @@ class Skin { return "
[".$url."]
"; } + + // This function is called by EditPage.php and shows a bulletin board style + // toolbar for common editing functions. It can be disabled in the user preferences. + // The necsesary JavaScript code can be found in style/wikibits.js. + function getEditToolbar() { + + global $wgUploadPath; + + // toolarray an array of arrays which each include the filename of + // the button image (without path), the opening tag, the closing tag, + // and optionally a sample text that is inserted between the two when no + // selection is highlighted. + // The tip text is shown when the user moves the mouse over the button. + $toolarray=array( + array( "image"=>"button_bold.gif", + "open"=>"\\'\\'\\'", + "close"=>"\\'\\'\\'", + "sample"=>wfMsg("bold_sample"), + "tip"=>wfMsg("bold_tip")), + array( "image"=>"button_italic.gif", + "open"=>"\\'\\'", + "close"=>"\\'\\'", + "sample"=>wfMsg("italic_sample"), + "tip"=>wfMsg("italic_tip")), + array( "image"=>"button_link.gif", + "open"=>"[[", + "close"=>"]]", + "sample"=>wfMsg("link_sample"), + "tip"=>wfMsg("link_tip")), + array( "image"=>"button_extlink.gif", + "open"=>"[", + "close"=>"]", + "sample"=>wfMsg("extlink_sample"), + "tip"=>wfMsg("extlink_tip")), + array( "image"=>"button_headline.gif", + "open"=>"\\n== ", + "close"=>" ==\\n", + "sample"=>wfMsg("headline_sample"), + "tip"=>wfMsg("headline_tip")), + array( "image"=>"button_math.gif", + "open"=>"\\", + "close"=>"\\", + "sample"=>wfMsg("math_sample"), + "tip"=>wfMsg("math_tip")), + array( "image"=>"button_image.gif", + "open"=>"[[Image:", + "close"=>"]]", + "sample"=>wfMsg("image_sample"), + "tip"=>wfMsg("image_tip")), + array( "image"=>"button_media.gif", + "open"=>"[[Media:", + "close"=>"]]", + "sample"=>wfMsg("media_sample"), + "tip"=>wfMsg("media_tip")), + array( "image"=>"button_sig.gif", + "open"=>"--~~~~", + "close"=>"", + "sample"=>"", + "tip"=>wfMsg("sig_tip")), + array( "image"=>"button_hr.gif", + "open"=>"\\n----\\n", + "close"=>"", + "sample"=>"", + "tip"=>wfMsg("hr_tip")) + ); + $toolbar.=" +
"; + foreach($toolarray as $tool) { + + $image=$tool["image"]; + $open=$tool["open"]; + $close=$tool["close"]; + $sample=$tool["sample"]; + + // Note that we use the tip 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=$tool["tip"]; + + $toolbar.= + "". + "\"$tip\"". + ""; + + } + + $toolbar.="
"; + return $toolbar; + + } } include_once( "SkinStandard.php" ); diff --git a/languages/Language.php b/languages/Language.php index 328e867c27..37b6f4ebf0 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -61,6 +61,7 @@ if($wgMetaNamespace === FALSE) "skin" => 0, "math" => 1, "rcdays" => 7, "rclimit" => 50, "highlightbroken" => 1, "stubthreshold" => 0, "previewontop" => 1, "editsection"=>1,"editsectiononrightclick"=>0, "showtoc"=>1, + "showtoolbar"=>1, "date" => 0 ); @@ -97,6 +98,7 @@ this (alternative: like this?).", "hideminor" => "Hide minor edits in recent changes", "usenewrc" => "Enhanced recent changes (not for all browsers)", "numberheadings" => "Auto-number headings", + "showtoolbar"=>"Show edit box toolbar", "editondblclick" => "Edit pages on double click (JavaScript)", "editsection"=>"Enable section editing via [edit] links", "editsectiononrightclick"=>"Enable section editing by right clicking
on section titles (JavaScript)", @@ -289,7 +291,7 @@ this (alternative: like this?).", MAG_START => array( 0, "__START__" ), MAG_CURRENTMONTH => array( 1, "{{CURRENTMONTH}}" ), MAG_CURRENTMONTHNAME => array( 1, "{{CURRENTMONTHNAME}}" ), - MAG_CURRENTDAY => array( 1, "{{CURRENTDAY}}" ), + MAG_CURRENTDAY => array( 1, "{{CURRENTDAY}}" ), MAG_CURRENTDAYNAME => array( 1, "{{CURRENTDAYNAME}}" ), MAG_CURRENTYEAR => array( 1, "{{CURRENTYEAR}}" ), MAG_CURRENTTIME => array( 1, "{{CURRENTTIME}}" ), @@ -300,7 +302,7 @@ this (alternative: like this?).", MAG_MSGNW => array( 0, "{{MSGNW:$1}}" ), MAG_END => array( 0, "__END__" ) ); - + # All special pages have to be listed here: a description of "" # will make them not show up on the "Special Pages" page, which # is the right thing for some of them (such as the "targeted" ones). @@ -357,7 +359,7 @@ this (alternative: like this?).", #------------------------------------------------------------------- # Default messages #------------------------------------------------------------------- -# Allowed characters in keys are: A-Z, a-z, 0-9, underscore (_) and +# Allowed characters in keys are: A-Z, a-z, 0-9, underscore (_) and # hyphen (-). If you need more characters, you may be able to change # the regex in MagicWord::initRegex @@ -582,6 +584,26 @@ You should log in and change your password now.", registered for \"$1\". Please log in again after you receive it.", +# Edit page toolbar +"bold_sample"=>"Bold text", +"bold_tip"=>"Bold text", +"italic_sample"=>"Italic text", +"italic_tip"=>"Italic text", +"link_sample"=>"Link title", +"link_tip"=>"Internal link", +"extlink_sample"=>"http://www.example.com link title", +"extlink_tip"=>"External link (remember http:// prefix)", +"headline_sample"=>"Headline text", +"headline_tip"=>"Level 2 headline", +"math_sample"=>"Insert formula here", +"math_tip"=>"Mathematical formula (LaTeX)", +"image_sample"=>"Example.jpg", +"image_tip"=>"Embedded image", +"media_sample"=>"Example.mp3", +"media_tip"=>"Media file link", +"sig_tip"=>"Your signature with timestamp", +"hr_tip"=>"Horizontal line (use sparingly)", + # Edit pages # "summary" => "Summary", @@ -594,14 +616,14 @@ Please log in again after you receive it.", "blockedtitle" => "User is blocked", "blockedtext" => "Your user name or IP address has been blocked by $1. The reason given is this:
''$2''

You may contact $1 or one of the other -[[$wgMetaNamespace:Administrators|administrators]] to discuss the block. +[[$wgMetaNamespace:Administrators|administrators]] to discuss the block. -Note that you may not use the \"email this user\" feature unless you have a valid email address registered in your [[Special:Preferences|user preferences]]. +Note that you may not use the \"email this user\" feature unless you have a valid email address registered in your [[Special:Preferences|user preferences]]. Your IP address is $3. Please include this address in any queries you make. ==Note to AOL users== -Due to continuing acts of vandalism by one particular AOL user, Wikipedia often blocks AOL proxies. Unfortunately, a single proxy server may be used by a large number of AOL users, and hence innocent AOL users are often inadvertently blocked. We apologise for any inconvenience caused. +Due to continuing acts of vandalism by one particular AOL user, Wikipedia often blocks AOL proxies. Unfortunately, a single proxy server may be used by a large number of AOL users, and hence innocent AOL users are often inadvertently blocked. We apologise for any inconvenience caused. If this happens to you, please email an administrator, using an AOL email address. Be sure to include the IP address given above. ", diff --git a/stylesheets/wikibits.js b/stylesheets/wikibits.js index ba8ce1d8d3..21c679ab10 100644 --- a/stylesheets/wikibits.js +++ b/stylesheets/wikibits.js @@ -1,5 +1,15 @@ // Wikipedia JavaScript support functions +var clientVer = parseInt(navigator.appVersion); // Get browser version +var clientPC = navigator.userAgent.toLowerCase(); // Get client info +var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1)); +var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1) + && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1) + && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1)); +var is_moz = 0; +var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1)); +var is_mac = (clientPC.indexOf("mac")!=-1); + // for enhanced RecentChanges function toggleVisibility( _levelId, _otherId, _linkId) { var thisLevel = document.getElementById( _levelId ); @@ -51,7 +61,7 @@ function showTocToggle(show,hide) { if(document.getElementById) { document.writeln('[' + '' + - '' + hide + '' + '' + hide + '' + ']'); } } @@ -61,7 +71,7 @@ function toggleToc() { var showlink=document.getElementById('showlink'); var hidelink=document.getElementById('hidelink'); if(toc.style.display == 'none') { - toc.style.display = tocWas; + toc.style.display = tocWas; hidelink.style.display=''; showlink.style.display='none'; @@ -74,3 +84,55 @@ function toggleToc() { } } +// apply tagOpen/tagClose to selection in textarea, +// use sampleText instead of selection if there is none +// copied and adapted from phpBB +function insertTags(tagOpen, tagClose, sampleText) { + + var txtarea = document.editform.wpTextbox1; + if ((clientVer >= 4) && is_ie && is_win) { + theSelection = document.selection.createRange().text; + if (!theSelection) { + txtarea.value += tagOpen + sampleText + tagClose; + txtarea.focus(); + return; + } + document.selection.createRange().text = tagOpen + theSelection + tagClose; + txtarea.focus(); + return; + } + else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) + { + mozWrap(txtarea, tagOpen, tagClose, sampleText); + return; + } + else + { + txtarea.value += tagOpen + sampleText + tagClose; + txtarea.focus(); + } + storeCaret(txtarea); +} + +// From http://www.massless.org/mozedit/ +function mozWrap(txtarea, open, close) +{ + var txtarea = document.editform.wpTextbox1; + var selLength = txtarea.textLength; + var selStart = txtarea.selectionStart; + var selEnd = txtarea.selectionEnd; + if (selEnd == 1 || selEnd == 2) + selEnd = selLength; + + var s1 = (txtarea.value).substring(0,selStart); + var s2 = (txtarea.value).substring(selStart, selEnd) + var s3 = (txtarea.value).substring(selEnd, selLength); + txtarea.value = s1 + open + s2 + close + s3; + return; +} + +// Insert at Claret position. Code from +// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130 +function storeCaret(textEl) { + if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); +} diff --git a/stylesheets/wikistandard.css b/stylesheets/wikistandard.css index 1f33328fed..d4e20a7130 100644 --- a/stylesheets/wikistandard.css +++ b/stylesheets/wikistandard.css @@ -8,6 +8,7 @@ #quickbar { width: 140px; padding: 4px; visibility: visible; z-index:99;font-size:95%;} #topbar { padding: 4px;font-size:95%; } #toc { border:1px solid #8888aa; background-color:#f7f8ff;padding:5px;font-size:95%; } +#toolbar { border-width:2px;border-style:groove;border-color:black;padding:0px;width:230px;} .bodytext { } a.interwiki, a.external { color: #3366BB; } a.printable { text-decoration: underline; }