3 * Contain the EditPage class
9 * Splitting edit page/HTML interface from Article...
10 * The actual database and text munging is still in Article,
11 * but it should get easier to call those from alternate
22 var $save = false, $preview = false;
23 var $minoredit = false, $watchthis = false;
24 var $textbox1 = '', $textbox2 = '', $summary = '';
25 var $edittime = '', $section = '';
32 function EditPage( $article ) {
33 $this->mArticle
=& $article;
35 $this->mTitle
=& $wgTitle;
39 * This is the function that gets called for "action=edit".
42 global $wgOut, $wgUser, $wgWhitelistEdit, $wgRequest;
43 // this is not an article
44 $wgOut->setArticleFlag(false);
46 $this->importFormData( $wgRequest );
48 if ( ! $this->mTitle
->userCanEdit() ) {
49 $wgOut->readOnlyPage( $this->mArticle
->getContent( true ), true );
52 if ( $wgUser->isBlocked() ) {
53 $this->blockedIPpage();
56 if ( !$wgUser->getID() && $wgWhitelistEdit ) {
57 $this->userNotLoggedInPage();
61 if( $this->save ||
$this->preview
) {
62 $this->editForm( 'preview' );
64 $wgOut->readOnlyPage( $this->mArticle
->getContent( true ) );
69 $this->editForm( 'save' );
70 } else if ( $this->preview
or $wgUser->getOption('previewonfirst')) {
71 $this->editForm( 'preview' );
72 } else { # First time through
73 $this->editForm( 'initial' );
80 function importFormData( &$request ) {
81 # These fields need to be checked for encoding.
82 # Also remove trailing whitespace, but don't remove _initial_
83 # whitespace from the text boxes. This may be significant formatting.
84 $this->textbox1
= rtrim( $request->getText( 'wpTextbox1' ) );
85 $this->textbox2
= rtrim( $request->getText( 'wpTextbox2' ) );
86 $this->summary
= trim( $request->getText( 'wpSummary' ) );
88 $this->edittime
= $request->getVal( 'wpEdittime' );
89 if( !preg_match( '/^\d{14}$/', $this->edittime
)) $this->edittime
= '';
91 $this->preview
= $request->getCheck( 'wpPreview' );
92 $this->save
= $request->wasPosted() && !$this->preview
;
93 $this->minoredit
= $request->getCheck( 'wpMinoredit' );
94 $this->watchthis
= $request->getCheck( 'wpWatchthis' );
96 $this->oldid
= $request->getInt( 'oldid' );
98 # Section edit can come from either the form or a link
99 $this->section
= $request->getVal( 'wpSection', $request->getVal( 'section' ) );
103 * Since there is only one text field on the edit form,
104 * pressing <enter> will cause the form to be submitted, but
105 * the submit button value won't appear in the query, so we
106 * Fake it here before going back to edit(). This is kind of
107 * ugly, but it helps some old URLs to still work.
110 if( !$this->preview
) $this->save
= true;
116 * The edit form is self-submitting, so that when things like
117 * preview and edit conflicts occur, we get the same form back
118 * with the extra stuff added. Only when the final submission
119 * is made and all is well do we actually save and redirect to
120 * the newly-edited page.
122 * @param string $formtype Type of form either : save, initial or preview
124 function editForm( $formtype ) {
125 global $wgOut, $wgUser;
126 global $wgLang, $wgContLang, $wgParser, $wgTitle;
127 global $wgAllowAnonymousMinor;
128 global $wgWhitelistEdit;
129 global $wgSpamRegex, $wgFilterCallback;
132 $sk = $wgUser->getSkin();
134 // css / js subpages of user pages get a special treatment
135 $isCssJsSubpage = (Namespace::getUser() == $wgTitle->getNamespace() and preg_match("/\\.(css|js)$/", $wgTitle->getText() ));
137 if(!$this->mTitle
->getArticleID()) { # new article
138 $wgOut->addWikiText(wfmsg('newarticletext'));
141 if( Namespace::isTalk( $this->mTitle
->getNamespace() ) ) {
142 $wgOut->addWikiText(wfmsg('talkpagetext'));
145 # Attempt submission here. This will check for edit conflicts,
146 # and redundantly check for locked database, blocked IPs, etc.
147 # that edit() already checked just in case someone tries to sneak
148 # in the back door with a hand-edited submission URL.
150 if ( 'save' == $formtype ) {
152 if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1
, $matches ) ) {
153 $this->spamPage ( $matches );
156 if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle
, $this->textbox1
, $this->section
) ) {
157 # Error messages or other handling should be performed by the filter function
160 if ( $wgUser->isBlocked() ) {
161 $this->blockedIPpage();
164 if ( !$wgUser->getID() && $wgWhitelistEdit ) {
165 $this->userNotLoggedInPage();
168 if ( wfReadOnly() ) {
169 $wgOut->readOnlyPage();
173 # If article is new, insert it.
174 $aid = $this->mTitle
->getArticleID( GAID_FOR_UPDATE
);
176 # Don't save a new article if it's blank.
177 if ( ( '' == $this->textbox1
) ||
178 ( wfMsg( 'newarticletext' ) == $this->textbox1
) ) {
179 $wgOut->redirect( $this->mTitle
->getFullURL() );
182 if (wfRunHooks('ArticleSave', $this->mArticle
, $wgUser, $this->textbox1
,
183 $this->summary
, $this->minoredit
, $this->watchthis
, NULL))
185 $this->mArticle
->insertNewArticle( $this->textbox1
, $this->summary
,
186 $this->minoredit
, $this->watchthis
);
187 wfRunHooks('ArticleSaveComplete', $this->mArticle
, $wgUser, $this->textbox1
,
188 $this->summary
, $this->minoredit
, $this->watchthis
, NULL);
193 # Article exists. Check for edit conflict.
195 $this->mArticle
->clear(); # Force reload of dates, etc.
196 $this->mArticle
->forUpdate( true ); # Lock the article
198 if( ( $this->section
!= 'new' ) &&
199 ($this->mArticle
->getTimestamp() != $this->edittime
) ) {
202 $userid = $wgUser->getID();
205 $text = $this->mArticle
->getTextOfLastEditWithSectionReplacedOrAdded(
206 $this->section
, $this->textbox1
, $this->summary
, $this->edittime
);
209 $text = $this->mArticle
->getTextOfLastEditWithSectionReplacedOrAdded(
210 $this->section
, $this->textbox1
, $this->summary
);
212 # Suppress edit conflict with self
214 if ( ( 0 != $userid ) && ( $this->mArticle
->getUser() == $userid ) ) {
217 # switch from section editing to normal editing in edit conflict
220 if( $this->mergeChangesInto( $text ) ){
221 // Successful merge! Maybe we should tell the user the good news?
225 $this->textbox1
= $text;
229 if ( ! $isConflict ) {
232 if( $this->section
== 'new' ) {
233 if( $this->summary
!= '' ) {
234 $sectionanchor = $this->sectionAnchor( $this->summary
);
236 } elseif( $this->section
!= '' ) {
237 # Try to get a section anchor from the section source, redirect to edited section if header found
238 # XXX: might be better to integrate this into Article::getTextOfLastEditWithSectionReplacedOrAdded
239 # for duplicate heading checking and maybe parsing
240 $hasmatch = preg_match( "/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1
, $matches );
241 # we can't deal with anchors, includes, html etc in the header for now,
242 # headline would need to be parsed to improve this
243 #if($hasmatch and strlen($matches[2]) > 0 and !preg_match( "/[\\['{<>]/", $matches[2])) {
244 if($hasmatch and strlen($matches[2]) > 0) {
245 $sectionanchor = $this->sectionAnchor( $matches[2] );
249 if (wfRunHooks('ArticleSave', $this, $wgUser, $text, $this->summary
,
250 $this->minoredit
, $this->watchthis
, $sectionanchor))
252 # update the article here
253 if($this->mArticle
->updateArticle( $text, $this->summary
, $this->minoredit
,
254 $this->watchthis
, '', $sectionanchor ))
256 wfRunHooks('ArticleSaveComplete', $this, $wgUser, $text, $this->summary
,
257 $this->minoredit
, $this->watchthis
, $sectionanchor);
265 # First time through: get contents, set time for conflict
268 if ( 'initial' == $formtype ) {
269 $this->edittime
= $this->mArticle
->getTimestamp();
270 $this->textbox1
= $this->mArticle
->getContent( true );
274 $wgOut->setRobotpolicy( 'noindex,nofollow' );
276 # Enabled article-related sidebar, toplinks, etc.
277 $wgOut->setArticleRelated( true );
280 $s = wfMsg( 'editconflict', $this->mTitle
->getPrefixedText() );
281 $wgOut->setPageTitle( $s );
282 $wgOut->addHTML( wfMsg( 'explainconflict' ) );
284 $this->textbox2
= $this->textbox1
;
285 $this->textbox1
= $this->mArticle
->getContent( true );
286 $this->edittime
= $this->mArticle
->getTimestamp();
289 if( $this->section
!= '' ) {
290 if( $this->section
== 'new' ) {
291 $s = wfMsg('editingcomment', $this->mTitle
->getPrefixedText() );
293 $s = wfMsg('editingsection', $this->mTitle
->getPrefixedText() );
295 if(!$this->preview
) {
296 $sectitle=preg_match("/^=+(.*?)=+/mi",
299 if( !empty( $matches[1] ) ) {
300 $this->summary
= "/* ". trim($matches[1])." */ ";
304 $s = wfMsg( 'editing', $this->mTitle
->getPrefixedText() );
306 $wgOut->setPageTitle( $s );
307 if ( !$wgUseLatin1 && !$this->checkUnicodeCompliantBrowser() ) {
308 $this->mArticle
->setOldSubtitle();
309 $wgOut->addWikiText( wfMsg( 'nonunicodebrowser') );
311 if ( $this->oldid
) {
312 $this->mArticle
->setOldSubtitle();
313 $wgOut->addHTML( wfMsg( 'editingold' ) );
318 $wgOut->addHTML( '<strong>' .
319 wfMsg( 'readonlywarning' ) .
321 } else if ( $isCssJsSubpage and 'preview' != $formtype) {
322 $wgOut->addHTML( wfMsg( 'usercssjsyoucanpreview' ));
324 if( $this->mTitle
->isProtected('edit') ) {
325 $wgOut->addHTML( '<strong>' . wfMsg( 'protectedpagewarning' ) .
326 "</strong><br />\n" );
329 $kblength = (int)(strlen( $this->textbox1
) / 1024);
330 if( $kblength > 29 ) {
331 $wgOut->addHTML( '<strong>' .
332 wfMsg( 'longpagewarning', $wgLang->formatNum( $kblength ) )
336 $rows = $wgUser->getOption( 'rows' );
337 $cols = $wgUser->getOption( 'cols' );
339 $ew = $wgUser->getOption( 'editwidth' );
340 if ( $ew ) $ew = " style=\"width:100%\"";
343 $q = 'action=submit';
344 #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
345 $action = $this->mTitle
->escapeLocalURL( $q );
347 $summary = wfMsg('summary');
348 $subject = wfMsg('subject');
349 $minor = wfMsg('minoredit');
350 $watchthis = wfMsg ('watchthis');
351 $save = wfMsg('savearticle');
352 $prev = wfMsg('showpreview');
354 $cancel = $sk->makeKnownLink( $this->mTitle
->getPrefixedText(),
356 $edithelpurl = $sk->makeUrl( wfMsg( 'edithelppage' ));
357 $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
358 htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
359 htmlspecialchars( wfMsg( 'newwindow' ) );
361 global $wgRightsText;
362 $copywarn = "<div id=\"editpage-copywarn\">\n" .
363 wfMsg( $wgRightsText ?
'copyrightwarning' : 'copyrightwarning2',
364 '[[' . wfMsg( 'copyrightpage' ) . ']]',
365 $wgRightsText ) . "\n</div>";
367 if( $wgUser->getOption('showtoolbar') and !$isCssJsSubpage ) {
368 # prepare toolbar for edit buttons
369 $toolbar = $this->getEditToolbar();
374 // activate checkboxes if user wants them to be always active
375 if( !$this->preview
) {
376 if( $wgUser->getOption( 'watchdefault' ) ) $this->watchthis
= true;
377 if( $wgUser->getOption( 'minordefault' ) ) $this->minoredit
= true;
379 // activate checkbox also if user is already watching the page,
380 // require wpWatchthis to be unset so that second condition is not
381 // checked unnecessarily
382 if( !$this->watchthis
&& $this->mTitle
->userIsWatching() ) $this->watchthis
= true;
387 if ( 0 != $wgUser->getID() ||
$wgAllowAnonymousMinor ) {
389 "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'".($this->minoredit?
" checked='checked'":"").
390 " accesskey='".wfMsg('accesskey-minoredit')."' id='wpMinoredit' />".
391 "<label for='wpMinoredit' title='".wfMsg('tooltip-minoredit')."'>{$minor}</label>";
396 if ( 0 != $wgUser->getID() ) {
397 $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'".($this->watchthis?
" checked='checked'":"").
398 " accesskey='".wfMsg('accesskey-watch')."' id='wpWatchthis' />".
399 "<label for='wpWatchthis' title='".wfMsg('tooltip-watch')."'>{$watchthis}</label>";
402 $checkboxhtml = $minoredithtml . $watchhtml . '<br />';
404 if ( 'preview' == $formtype) {
405 $previewhead='<h2>' . wfMsg( 'preview' ) . "</h2>\n<p><center><font color=\"#cc0000\">" .
406 wfMsg( 'note' ) . wfMsg( 'previewnote' ) . "</font></center></p>\n";
408 $previewhead.='<h2>' . wfMsg( 'previewconflict' ) .
412 $parserOptions = ParserOptions
::newFromUser( $wgUser );
413 $parserOptions->setEditSection( false );
414 $parserOptions->setEditSectionOnRightClick( false );
416 # don't parse user css/js, show message about preview
417 # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here
419 if ( $isCssJsSubpage ) {
420 if(preg_match("/\\.css$/", $wgTitle->getText() ) ) {
421 $previewtext = wfMsg('usercsspreview');
422 } else if(preg_match("/\\.js$/", $wgTitle->getText() ) ) {
423 $previewtext = wfMsg('userjspreview');
425 $parserOutput = $wgParser->parse( $previewtext , $wgTitle, $parserOptions );
426 $wgOut->addHTML( $parserOutput->mText
);
428 # if user want to see preview when he edit an article
429 if( $wgUser->getOption('previewonfirst') and ($this->textbox1
== '')) {
430 $this->textbox1
= $this->mArticle
->getContent(true);
433 $parserOutput = $wgParser->parse( $this->mArticle
->preSaveTransform( $this->textbox1
) ."\n\n",
434 $wgTitle, $parserOptions );
436 $previewHTML = $parserOutput->mText
;
438 if($wgUser->getOption('previewontop')) {
439 $wgOut->addHTML($previewhead);
440 $wgOut->addHTML($previewHTML);
442 $wgOut->addCategoryLinks($parserOutput->getCategoryLinks());
443 $wgOut->addLanguageLinks($parserOutput->getLanguageLinks());
444 $wgOut->addHTML( "<br style=\"clear:both;\" />\n" );
448 # if this is a comment, show a subject line at the top, which is also the edit summary.
449 # Otherwise, show a summary field at the bottom
450 $summarytext = htmlspecialchars( $wgContLang->recodeForEdit( $this->summary
) ); # FIXME
451 if( $this->section
== 'new' ) {
452 $commentsubject="{$subject}: <input tabindex='1' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
455 $commentsubject = '';
456 $editsummary="{$summary}: <input tabindex='3' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
459 if( !$this->preview
) {
460 # Don't select the edit box on preview; this interferes with seeing what's going on.
461 $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' );
463 # Prepare a list of templates used by this page
464 $db =& wfGetDB( DB_SLAVE
);
465 $cur = $db->tableName( 'cur' );
466 $links = $db->tableName( 'links' );
467 $id = $this->mTitle
->getArticleID();
468 $sql = "SELECT cur_namespace,cur_title,cur_id ".
469 "FROM $cur,$links WHERE l_to=cur_id AND l_from={$id} and cur_namespace=".NS_TEMPLATE
;
470 $res = $db->query( $sql, "EditPage::editform" );
472 if ( $db->numRows( $res ) ) {
473 $templates = '<br />'. wfMsg( 'templatesused' ) . '<ul>';
474 while ( $row = $db->fetchObject( $res ) ) {
475 if ( $titleObj = Title
::makeTitle( $row->cur_namespace
, $row->cur_title
) ) {
476 $templates .= '<li>' . $sk->makeLinkObj( $titleObj ) . '</li>';
479 $templates .= '</ul>';
485 <form id=\"editform\" name=\"editform\" method=\"post\" action=\"$action\"
486 enctype=\"multipart/form-data\">
488 <textarea tabindex='1' accesskey=\",\" name=\"wpTextbox1\" rows='{$rows}'
489 cols='{$cols}'{$ew}>" .
490 htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1
) ) .
495 <input tabindex='5' id='wpSave' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"".wfMsg('accesskey-save')."\"".
496 " title=\"".wfMsg('tooltip-save')."\"/>
497 <input tabindex='6' id='wpPreview' type='submit' value=\"{$prev}\" name=\"wpPreview\" accesskey=\"".wfMsg('accesskey-preview')."\"".
498 " title=\"".wfMsg('tooltip-preview')."\"/>
499 <em>{$cancel}</em> | <em>{$edithelp}</em>{$templates}" );
500 $wgOut->addWikiText( $copywarn );
502 <input type='hidden' value=\"" . htmlspecialchars( $this->section
) . "\" name=\"wpSection\" />
503 <input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n" );
506 require_once( "DifferenceEngine.php" );
507 $wgOut->addHTML( "<h2>" . wfMsg( "yourdiff" ) . "</h2>\n" );
508 DifferenceEngine
::showDiff( $this->textbox2
, $this->textbox1
,
509 wfMsg( "yourtext" ), wfMsg( "storedversion" ) );
511 $wgOut->addHTML( "<h2>" . wfMsg( "yourtext" ) . "</h2>
512 <textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>"
513 . htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox2
) ) .
517 $wgOut->addHTML( "</form>\n" );
518 if($formtype =="preview" && !$wgUser->getOption("previewontop")) {
519 $wgOut->addHTML($previewhead);
520 $wgOut->addHTML($previewHTML);
527 function blockedIPpage() {
528 global $wgOut, $wgUser, $wgContLang, $wgIP;
530 $wgOut->setPageTitle( wfMsg( 'blockedtitle' ) );
531 $wgOut->setRobotpolicy( 'noindex,nofollow' );
532 $wgOut->setArticleRelated( false );
534 $id = $wgUser->blockedBy();
535 $reason = $wgUser->blockedFor();
538 if ( is_numeric( $id ) ) {
539 $name = User
::whoIs( $id );
543 $link = '[[' . $wgContLang->getNsText( Namespace::getUser() ) .
544 ":{$name}|{$name}]]";
546 $wgOut->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name ) );
547 $wgOut->returnToMain( false );
553 function userNotLoggedInPage() {
554 global $wgOut, $wgUser;
556 $wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) );
557 $wgOut->setRobotpolicy( 'noindex,nofollow' );
558 $wgOut->setArticleRelated( false );
560 $wgOut->addWikiText( wfMsg( 'whitelistedittext' ) );
561 $wgOut->returnToMain( false );
567 function spamPage ( $matches = array() )
570 $wgOut->setPageTitle( wfMsg( 'spamprotectiontitle' ) );
571 $wgOut->setRobotpolicy( 'noindex,nofollow' );
572 $wgOut->setArticleRelated( false );
574 $wgOut->addWikiText( wfMsg( 'spamprotectiontext' ) );
575 if ( isset ( $matches[0] ) ) {
576 $wgOut->addWikiText( wfMsg( 'spamprotectionmatch', "<nowiki>{$matches[0]}</nowiki>" ) );
578 $wgOut->returnToMain( false );
582 * Forks processes to scan the originating IP for an open proxy server
583 * MemCached can be used to skip IPs that have already been scanned
585 function proxyCheck() {
586 global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
587 global $wgIP, $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry;
589 if ( !$wgBlockOpenProxies ) {
595 if ( $wgUseMemCached ) {
596 $mcKey = $wgDBname.':proxy:ip:'.$wgIP;
597 $mcValue = $wgMemc->get( $mcKey );
605 $title = Title
::makeTitle( NS_SPECIAL
, 'Blockme' );
606 $iphash = md5( $wgIP . $wgProxyKey );
607 $url = $title->getFullURL( 'ip='.$iphash );
609 foreach ( $wgProxyPorts as $port ) {
610 $params = implode( ' ', array(
611 escapeshellarg( $wgProxyScriptPath ),
612 escapeshellarg( $wgIP ),
613 escapeshellarg( $port ),
614 escapeshellarg( $url )
616 exec( "php $params &>/dev/null &" );
619 if ( $wgUseMemCached ) {
620 $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
629 function mergeChangesInto( &$text ){
630 $fname = 'EditPage::mergeChangesInto';
631 $oldDate = $this->edittime
;
632 $dbw =& wfGetDB( DB_MASTER
);
633 $obj = $dbw->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mTitle
->getArticleID() ),
634 $fname, 'FOR UPDATE' );
636 $yourtext = $obj->cur_text
;
637 $ns = $this->mTitle
->getNamespace();
638 $title = $this->mTitle
->getDBkey();
639 $obj = $dbw->selectRow( 'old',
640 array( 'old_text','old_flags'),
641 array( 'old_namespace' => $ns, 'old_title' => $title,
642 'old_timestamp' => $dbw->timestamp($oldDate)),
644 $oldText = Article
::getRevisionText( $obj );
646 if(wfMerge($oldText, $text, $yourtext, $result)){
655 function checkUnicodeCompliantBrowser() {
656 global $wgBrowserBlackList;
657 $currentbrowser = $_SERVER["HTTP_USER_AGENT"];
658 foreach ( $wgBrowserBlackList as $browser ) {
659 if ( preg_match($browser, $currentbrowser) ) {
667 * Format an anchor fragment as it would appear for a given section name
668 * @param string $text
672 function sectionAnchor( $text ) {
673 global $wgInputEncoding;
674 $headline = do_html_entity_decode( $text, ENT_COMPAT
, $wgInputEncoding );
676 $headline = preg_replace( '/<.*?' . '>/', '', $headline );
677 $headline = trim( $headline );
678 $sectionanchor = '#' . urlencode( str_replace( ' ', '_', $headline ) );
679 $replacearray = array(
684 array_keys( $replacearray ),
685 array_values( $replacearray ),
690 * Shows a bulletin board style toolbar for common editing functions.
691 * It can be disabled in the user preferences.
692 * The necessary JavaScript code can be found in style/wikibits.js.
694 function getEditToolbar() {
695 global $wgStylePath, $wgLang, $wgMimeType;
698 * toolarray an array of arrays which each include the filename of
699 * the button image (without path), the opening tag, the closing tag,
700 * and optionally a sample text that is inserted between the two when no
701 * selection is highlighted.
702 * The tip text is shown when the user moves the mouse over the button.
704 * Already here are accesskeys (key), which are not used yet until someone
705 * can figure out a way to make them work in IE. However, we should make
706 * sure these keys are not defined on the edit page.
709 array( 'image'=>'button_bold.png',
712 'sample'=> wfMsg('bold_sample'),
713 'tip' => wfMsg('bold_tip'),
716 array( 'image'=>'button_italic.png',
719 'sample'=> wfMsg('italic_sample'),
720 'tip' => wfMsg('italic_tip'),
723 array( 'image'=>'button_link.png',
726 'sample'=> wfMsg('link_sample'),
727 'tip' => wfMsg('link_tip'),
730 array( 'image'=>'button_extlink.png',
733 'sample'=> wfMsg('extlink_sample'),
734 'tip' => wfMsg('extlink_tip'),
737 array( 'image'=>'button_headline.png',
740 'sample'=> wfMsg('headline_sample'),
741 'tip' => wfMsg('headline_tip'),
744 array( 'image'=>'button_image.png',
745 'open' => '[['.$wgLang->getNsText(NS_IMAGE
).":",
747 'sample'=> wfMsg('image_sample'),
748 'tip' => wfMsg('image_tip'),
751 array( 'image' => 'button_media.png',
752 'open' => '[['.$wgLang->getNsText(NS_MEDIA
).':',
754 'sample'=> wfMsg('media_sample'),
755 'tip' => wfMsg('media_tip'),
758 array( 'image' => 'button_math.png',
759 'open' => "\\<math\\>",
760 'close' => "\\</math\\>",
761 'sample'=> wfMsg('math_sample'),
762 'tip' => wfMsg('math_tip'),
765 array( 'image' => 'button_nowiki.png',
766 'open' => "\\<nowiki\\>",
767 'close' => "\\</nowiki\\>",
768 'sample'=> wfMsg('nowiki_sample'),
769 'tip' => wfMsg('nowiki_tip'),
772 array( 'image' => 'button_sig.png',
776 'tip' => wfMsg('sig_tip'),
779 array( 'image' => 'button_hr.png',
780 'open' => "\\n----\\n",
783 'tip' => wfMsg('hr_tip'),
787 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
789 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
790 foreach($toolarray as $tool) {
792 $image=$wgStylePath.'/common/images/'.$tool['image'];
794 $close=$tool['close'];
795 $sample = addslashes( $tool['sample'] );
797 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
798 // Older browsers show a "speedtip" type message only for ALT.
799 // Ideally these should be different, realistically they
800 // probably don't need to be.
801 $tip = addslashes( $tool['tip'] );
803 #$key = $tool["key"];
805 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
808 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
809 $toolbar.="document.writeln(\"</div>\");\n";
811 $toolbar.="/*]]>*/\n</script>";