3 * Contain the EditPage class
8 * Splitting edit page/HTML interface from Article...
9 * The actual database and text munging is still in Article,
10 * but it should get easier to call those from alternate
21 var $save = false, $preview = false;
22 var $minoredit = false, $watchthis = false;
23 var $textbox1 = '', $textbox2 = '', $summary = '';
24 var $edittime = '', $section = '';
31 function EditPage( $article ) {
32 $this->mArticle
=& $article;
34 $this->mTitle
=& $wgTitle;
38 * This is the function that gets called for "action=edit".
41 global $wgOut, $wgUser, $wgWhitelistEdit, $wgRequest;
42 // this is not an article
43 $wgOut->setArticleFlag(false);
45 $this->importFormData( $wgRequest );
47 if ( ! $this->mTitle
->userCanEdit() ) {
48 $wgOut->readOnlyPage( $this->mArticle
->getContent( true ), true );
51 if ( $wgUser->isBlocked() ) {
52 $this->blockedIPpage();
55 if ( !$wgUser->getID() && $wgWhitelistEdit ) {
56 $this->userNotLoggedInPage();
60 if( $this->save ||
$this->preview
) {
61 $this->editForm( 'preview' );
63 $wgOut->readOnlyPage( $this->mArticle
->getContent( true ) );
68 $this->editForm( 'save' );
69 } else if ( $this->preview
or $wgUser->getOption('previewonfirst')) {
70 $this->editForm( 'preview' );
71 } else { # First time through
72 $this->editForm( 'initial' );
79 function importFormData( &$request ) {
80 # These fields need to be checked for encoding.
81 # Also remove trailing whitespace, but don't remove _initial_
82 # whitespace from the text boxes. This may be significant formatting.
83 $this->textbox1
= rtrim( $request->getText( 'wpTextbox1' ) );
84 $this->textbox2
= rtrim( $request->getText( 'wpTextbox2' ) );
85 $this->summary
= trim( $request->getText( 'wpSummary' ) );
87 $this->edittime
= $request->getVal( 'wpEdittime' );
88 if( !preg_match( '/^\d{14}$/', $this->edittime
)) $this->edittime
= '';
90 $this->preview
= $request->getCheck( 'wpPreview' );
91 $this->save
= $request->wasPosted() && !$this->preview
;
92 $this->minoredit
= $request->getCheck( 'wpMinoredit' );
93 $this->watchthis
= $request->getCheck( 'wpWatchthis' );
95 $this->oldid
= $request->getInt( 'oldid' );
97 # Section edit can come from either the form or a link
98 $this->section
= $request->getVal( 'wpSection', $request->getVal( 'section' ) );
102 * Since there is only one text field on the edit form,
103 * pressing <enter> will cause the form to be submitted, but
104 * the submit button value won't appear in the query, so we
105 * Fake it here before going back to edit(). This is kind of
106 * ugly, but it helps some old URLs to still work.
109 if( !$this->preview
) $this->save
= true;
115 * The edit form is self-submitting, so that when things like
116 * preview and edit conflicts occur, we get the same form back
117 * with the extra stuff added. Only when the final submission
118 * is made and all is well do we actually save and redirect to
119 * the newly-edited page.
121 * @param string $formtype Type of form either : save, initial or preview
123 function editForm( $formtype ) {
124 global $wgOut, $wgUser;
125 global $wgLang, $wgContLang, $wgParser, $wgTitle;
126 global $wgAllowAnonymousMinor;
127 global $wgWhitelistEdit;
128 global $wgSpamRegex, $wgFilterCallback;
131 $sk = $wgUser->getSkin();
133 // css / js subpages of user pages get a special treatment
134 $isCssJsSubpage = (Namespace::getUser() == $wgTitle->getNamespace() and preg_match("/\\.(css|js)$/", $wgTitle->getText() ));
136 if(!$this->mTitle
->getArticleID()) { # new article
137 $wgOut->addWikiText(wfmsg('newarticletext'));
140 if( Namespace::isTalk( $this->mTitle
->getNamespace() ) ) {
141 $wgOut->addWikiText(wfmsg('talkpagetext'));
144 # Attempt submission here. This will check for edit conflicts,
145 # and redundantly check for locked database, blocked IPs, etc.
146 # that edit() already checked just in case someone tries to sneak
147 # in the back door with a hand-edited submission URL.
149 if ( 'save' == $formtype ) {
151 if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1
, $matches ) ) {
152 $this->spamPage ( $matches );
155 if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle
, $this->textbox1
, $this->section
) ) {
156 # Error messages or other handling should be performed by the filter function
159 if ( $wgUser->isBlocked() ) {
160 $this->blockedIPpage();
163 if ( !$wgUser->getID() && $wgWhitelistEdit ) {
164 $this->userNotLoggedInPage();
167 if ( wfReadOnly() ) {
168 $wgOut->readOnlyPage();
172 # If article is new, insert it.
173 $aid = $this->mTitle
->getArticleID( GAID_FOR_UPDATE
);
175 # Don't save a new article if it's blank.
176 if ( ( '' == $this->textbox1
) ||
177 ( wfMsg( 'newarticletext' ) == $this->textbox1
) ) {
178 $wgOut->redirect( $this->mTitle
->getFullURL() );
181 if (wfRunHooks('ArticleSave', $this->mArticle
, $wgUser, $this->textbox1
,
182 $this->summary
, $this->minoredit
, $this->watchthis
, NULL))
184 $this->mArticle
->insertNewArticle( $this->textbox1
, $this->summary
,
185 $this->minoredit
, $this->watchthis
);
186 wfRunHooks('ArticleSaveComplete', $this->mArticle
, $wgUser, $this->textbox1
,
187 $this->summary
, $this->minoredit
, $this->watchthis
, NULL);
192 # Article exists. Check for edit conflict.
194 $this->mArticle
->clear(); # Force reload of dates, etc.
195 $this->mArticle
->forUpdate( true ); # Lock the article
197 if( ( $this->section
!= 'new' ) &&
198 ($this->mArticle
->getTimestamp() != $this->edittime
) ) {
201 $userid = $wgUser->getID();
204 $text = $this->mArticle
->getTextOfLastEditWithSectionReplacedOrAdded(
205 $this->section
, $this->textbox1
, $this->summary
, $this->edittime
);
208 $text = $this->mArticle
->getTextOfLastEditWithSectionReplacedOrAdded(
209 $this->section
, $this->textbox1
, $this->summary
);
211 # Suppress edit conflict with self
213 if ( ( 0 != $userid ) && ( $this->mArticle
->getUser() == $userid ) ) {
216 # switch from section editing to normal editing in edit conflict
219 if( $this->mergeChangesInto( $text ) ){
220 // Successful merge! Maybe we should tell the user the good news?
224 $this->textbox1
= $text;
228 if ( ! $isConflict ) {
231 if( $this->section
== 'new' ) {
232 if( $this->summary
!= '' ) {
233 $sectionanchor = $this->sectionAnchor( $this->summary
);
235 } elseif( $this->section
!= '' ) {
236 # Try to get a section anchor from the section source, redirect to edited section if header found
237 # XXX: might be better to integrate this into Article::getTextOfLastEditWithSectionReplacedOrAdded
238 # for duplicate heading checking and maybe parsing
239 $hasmatch = preg_match( "/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1
, $matches );
240 # we can't deal with anchors, includes, html etc in the header for now,
241 # headline would need to be parsed to improve this
242 #if($hasmatch and strlen($matches[2]) > 0 and !preg_match( "/[\\['{<>]/", $matches[2])) {
243 if($hasmatch and strlen($matches[2]) > 0) {
244 $sectionanchor = $this->sectionAnchor( $matches[2] );
248 if (wfRunHooks('ArticleSave', $this, $wgUser, $text, $this->summary
,
249 $this->minoredit
, $this->watchthis
, $sectionanchor))
251 # update the article here
252 if($this->mArticle
->updateArticle( $text, $this->summary
, $this->minoredit
,
253 $this->watchthis
, '', $sectionanchor ))
255 wfRunHooks('ArticleSaveComplete', $this, $wgUser, $text, $this->summary
,
256 $this->minoredit
, $this->watchthis
, $sectionanchor);
264 # First time through: get contents, set time for conflict
267 if ( 'initial' == $formtype ) {
268 $this->edittime
= $this->mArticle
->getTimestamp();
269 $this->textbox1
= $this->mArticle
->getContent( true );
273 $wgOut->setRobotpolicy( 'noindex,nofollow' );
275 # Enabled article-related sidebar, toplinks, etc.
276 $wgOut->setArticleRelated( true );
279 $s = wfMsg( 'editconflict', $this->mTitle
->getPrefixedText() );
280 $wgOut->setPageTitle( $s );
281 $wgOut->addHTML( wfMsg( 'explainconflict' ) );
283 $this->textbox2
= $this->textbox1
;
284 $this->textbox1
= $this->mArticle
->getContent( true );
285 $this->edittime
= $this->mArticle
->getTimestamp();
288 if( $this->section
!= '' ) {
289 if( $this->section
== 'new' ) {
290 $s = wfMsg('editingcomment', $this->mTitle
->getPrefixedText() );
292 $s = wfMsg('editingsection', $this->mTitle
->getPrefixedText() );
294 if(!$this->preview
) {
295 preg_match( "/^(=+)(.+)\\1/mi",
298 if( !empty( $matches[2] ) ) {
299 $this->summary
= "/* ". trim($matches[2])." */ ";
303 $s = wfMsg( 'editing', $this->mTitle
->getPrefixedText() );
305 $wgOut->setPageTitle( $s );
306 if ( !$wgUseLatin1 && !$this->checkUnicodeCompliantBrowser() ) {
307 $this->mArticle
->setOldSubtitle();
308 $wgOut->addWikiText( wfMsg( 'nonunicodebrowser') );
310 if ( $this->oldid
) {
311 $this->mArticle
->setOldSubtitle();
312 $wgOut->addHTML( wfMsg( 'editingold' ) );
317 $wgOut->addHTML( '<strong>' .
318 wfMsg( 'readonlywarning' ) .
320 } else if ( $isCssJsSubpage and 'preview' != $formtype) {
321 $wgOut->addHTML( wfMsg( 'usercssjsyoucanpreview' ));
323 if( $this->mTitle
->isProtected('edit') ) {
324 $wgOut->addHTML( '<strong>' . wfMsg( 'protectedpagewarning' ) .
325 "</strong><br />\n" );
328 $kblength = (int)(strlen( $this->textbox1
) / 1024);
329 if( $kblength > 29 ) {
330 $wgOut->addHTML( '<strong>' .
331 wfMsg( 'longpagewarning', $wgLang->formatNum( $kblength ) )
335 $rows = $wgUser->getOption( 'rows' );
336 $cols = $wgUser->getOption( 'cols' );
338 $ew = $wgUser->getOption( 'editwidth' );
339 if ( $ew ) $ew = " style=\"width:100%\"";
342 $q = 'action=submit';
343 #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
344 $action = $this->mTitle
->escapeLocalURL( $q );
346 $summary = wfMsg('summary');
347 $subject = wfMsg('subject');
348 $minor = wfMsg('minoredit');
349 $watchthis = wfMsg ('watchthis');
350 $save = wfMsg('savearticle');
351 $prev = wfMsg('showpreview');
353 $cancel = $sk->makeKnownLink( $this->mTitle
->getPrefixedText(),
355 $edithelpurl = $sk->makeUrl( wfMsg( 'edithelppage' ));
356 $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
357 htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
358 htmlspecialchars( wfMsg( 'newwindow' ) );
360 global $wgRightsText;
361 $copywarn = "<div id=\"editpage-copywarn\">\n" .
362 wfMsg( $wgRightsText ?
'copyrightwarning' : 'copyrightwarning2',
363 '[[' . wfMsg( 'copyrightpage' ) . ']]',
364 $wgRightsText ) . "\n</div>";
366 if( $wgUser->getOption('showtoolbar') and !$isCssJsSubpage ) {
367 # prepare toolbar for edit buttons
368 $toolbar = $this->getEditToolbar();
373 // activate checkboxes if user wants them to be always active
374 if( !$this->preview
) {
375 if( $wgUser->getOption( 'watchdefault' ) ) $this->watchthis
= true;
376 if( $wgUser->getOption( 'minordefault' ) ) $this->minoredit
= true;
378 // activate checkbox also if user is already watching the page,
379 // require wpWatchthis to be unset so that second condition is not
380 // checked unnecessarily
381 if( !$this->watchthis
&& $this->mTitle
->userIsWatching() ) $this->watchthis
= true;
386 if ( 0 != $wgUser->getID() ||
$wgAllowAnonymousMinor ) {
388 "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'".($this->minoredit?
" checked='checked'":"").
389 " accesskey='".wfMsg('accesskey-minoredit')."' id='wpMinoredit' />".
390 "<label for='wpMinoredit' title='".wfMsg('tooltip-minoredit')."'>{$minor}</label>";
395 if ( 0 != $wgUser->getID() ) {
396 $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'".($this->watchthis?
" checked='checked'":"").
397 " accesskey='".wfMsg('accesskey-watch')."' id='wpWatchthis' />".
398 "<label for='wpWatchthis' title='".wfMsg('tooltip-watch')."'>{$watchthis}</label>";
401 $checkboxhtml = $minoredithtml . $watchhtml . '<br />';
403 if ( 'preview' == $formtype) {
404 $previewhead='<h2>' . wfMsg( 'preview' ) . "</h2>\n<p><center><font color=\"#cc0000\">" .
405 wfMsg( 'note' ) . wfMsg( 'previewnote' ) . "</font></center></p>\n";
407 $previewhead.='<h2>' . wfMsg( 'previewconflict' ) .
411 $parserOptions = ParserOptions
::newFromUser( $wgUser );
412 $parserOptions->setEditSection( false );
413 $parserOptions->setEditSectionOnRightClick( false );
415 # don't parse user css/js, show message about preview
416 # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here
418 if ( $isCssJsSubpage ) {
419 if(preg_match("/\\.css$/", $wgTitle->getText() ) ) {
420 $previewtext = wfMsg('usercsspreview');
421 } else if(preg_match("/\\.js$/", $wgTitle->getText() ) ) {
422 $previewtext = wfMsg('userjspreview');
424 $parserOutput = $wgParser->parse( $previewtext , $wgTitle, $parserOptions );
425 $wgOut->addHTML( $parserOutput->mText
);
427 # if user want to see preview when he edit an article
428 if( $wgUser->getOption('previewonfirst') and ($this->textbox1
== '')) {
429 $this->textbox1
= $this->mArticle
->getContent(true);
432 $parserOutput = $wgParser->parse( $this->mArticle
->preSaveTransform( $this->textbox1
) ."\n\n",
433 $wgTitle, $parserOptions );
435 $previewHTML = $parserOutput->mText
;
437 if($wgUser->getOption('previewontop')) {
438 $wgOut->addHTML($previewhead);
439 $wgOut->addHTML($previewHTML);
441 $wgOut->addCategoryLinks($parserOutput->getCategoryLinks());
442 $wgOut->addLanguageLinks($parserOutput->getLanguageLinks());
443 $wgOut->addHTML( "<br style=\"clear:both;\" />\n" );
447 # if this is a comment, show a subject line at the top, which is also the edit summary.
448 # Otherwise, show a summary field at the bottom
449 $summarytext = htmlspecialchars( $wgContLang->recodeForEdit( $this->summary
) ); # FIXME
450 if( $this->section
== 'new' ) {
451 $commentsubject="{$subject}: <input tabindex='1' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
454 $commentsubject = '';
455 $editsummary="{$summary}: <input tabindex='3' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
458 if( !$this->preview
) {
459 # Don't select the edit box on preview; this interferes with seeing what's going on.
460 $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' );
462 # Prepare a list of templates used by this page
463 $db =& wfGetDB( DB_SLAVE
);
464 $cur = $db->tableName( 'cur' );
465 $links = $db->tableName( 'links' );
466 $id = $this->mTitle
->getArticleID();
467 $sql = "SELECT cur_namespace,cur_title,cur_id ".
468 "FROM $cur,$links WHERE l_to=cur_id AND l_from={$id} and cur_namespace=".NS_TEMPLATE
;
469 $res = $db->query( $sql, "EditPage::editform" );
471 if ( $db->numRows( $res ) ) {
472 $templates = '<br />'. wfMsg( 'templatesused' ) . '<ul>';
473 while ( $row = $db->fetchObject( $res ) ) {
474 if ( $titleObj = Title
::makeTitle( $row->cur_namespace
, $row->cur_title
) ) {
475 $templates .= '<li>' . $sk->makeLinkObj( $titleObj ) . '</li>';
478 $templates .= '</ul>';
484 <form id=\"editform\" name=\"editform\" method=\"post\" action=\"$action\"
485 enctype=\"multipart/form-data\">
487 <textarea tabindex='1' accesskey=\",\" name=\"wpTextbox1\" rows='{$rows}'
488 cols='{$cols}'{$ew}>" .
489 htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1
) ) .
494 <input tabindex='5' id='wpSave' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"".wfMsg('accesskey-save')."\"".
495 " title=\"".wfMsg('tooltip-save')."\"/>
496 <input tabindex='6' id='wpPreview' type='submit' value=\"{$prev}\" name=\"wpPreview\" accesskey=\"".wfMsg('accesskey-preview')."\"".
497 " title=\"".wfMsg('tooltip-preview')."\"/>
498 <em>{$cancel}</em> | <em>{$edithelp}</em>{$templates}" );
499 $wgOut->addWikiText( $copywarn );
501 <input type='hidden' value=\"" . htmlspecialchars( $this->section
) . "\" name=\"wpSection\" />
502 <input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n" );
505 require_once( "DifferenceEngine.php" );
506 $wgOut->addHTML( "<h2>" . wfMsg( "yourdiff" ) . "</h2>\n" );
507 DifferenceEngine
::showDiff( $this->textbox2
, $this->textbox1
,
508 wfMsg( "yourtext" ), wfMsg( "storedversion" ) );
510 $wgOut->addHTML( "<h2>" . wfMsg( "yourtext" ) . "</h2>
511 <textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>"
512 . htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox2
) ) .
516 $wgOut->addHTML( "</form>\n" );
517 if($formtype =="preview" && !$wgUser->getOption("previewontop")) {
518 $wgOut->addHTML($previewhead);
519 $wgOut->addHTML($previewHTML);
526 function blockedIPpage() {
527 global $wgOut, $wgUser, $wgContLang, $wgIP;
529 $wgOut->setPageTitle( wfMsg( 'blockedtitle' ) );
530 $wgOut->setRobotpolicy( 'noindex,nofollow' );
531 $wgOut->setArticleRelated( false );
533 $id = $wgUser->blockedBy();
534 $reason = $wgUser->blockedFor();
537 if ( is_numeric( $id ) ) {
538 $name = User
::whoIs( $id );
542 $link = '[[' . $wgContLang->getNsText( Namespace::getUser() ) .
543 ":{$name}|{$name}]]";
545 $wgOut->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name ) );
546 $wgOut->returnToMain( false );
552 function userNotLoggedInPage() {
553 global $wgOut, $wgUser;
555 $wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) );
556 $wgOut->setRobotpolicy( 'noindex,nofollow' );
557 $wgOut->setArticleRelated( false );
559 $wgOut->addWikiText( wfMsg( 'whitelistedittext' ) );
560 $wgOut->returnToMain( false );
566 function spamPage ( $matches = array() )
569 $wgOut->setPageTitle( wfMsg( 'spamprotectiontitle' ) );
570 $wgOut->setRobotpolicy( 'noindex,nofollow' );
571 $wgOut->setArticleRelated( false );
573 $wgOut->addWikiText( wfMsg( 'spamprotectiontext' ) );
574 if ( isset ( $matches[0] ) ) {
575 $wgOut->addWikiText( wfMsg( 'spamprotectionmatch', "<nowiki>{$matches[0]}</nowiki>" ) );
577 $wgOut->returnToMain( false );
581 * Forks processes to scan the originating IP for an open proxy server
582 * MemCached can be used to skip IPs that have already been scanned
584 function proxyCheck() {
585 global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
586 global $wgIP, $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry;
588 if ( !$wgBlockOpenProxies ) {
594 if ( $wgUseMemCached ) {
595 $mcKey = $wgDBname.':proxy:ip:'.$wgIP;
596 $mcValue = $wgMemc->get( $mcKey );
604 $title = Title
::makeTitle( NS_SPECIAL
, 'Blockme' );
605 $iphash = md5( $wgIP . $wgProxyKey );
606 $url = $title->getFullURL( 'ip='.$iphash );
608 foreach ( $wgProxyPorts as $port ) {
609 $params = implode( ' ', array(
610 escapeshellarg( $wgProxyScriptPath ),
611 escapeshellarg( $wgIP ),
612 escapeshellarg( $port ),
613 escapeshellarg( $url )
615 exec( "php $params &>/dev/null &" );
618 if ( $wgUseMemCached ) {
619 $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
628 function mergeChangesInto( &$text ){
629 $fname = 'EditPage::mergeChangesInto';
630 $oldDate = $this->edittime
;
631 $dbw =& wfGetDB( DB_MASTER
);
632 $obj = $dbw->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mTitle
->getArticleID() ),
633 $fname, 'FOR UPDATE' );
635 $yourtext = $obj->cur_text
;
636 $ns = $this->mTitle
->getNamespace();
637 $title = $this->mTitle
->getDBkey();
638 $obj = $dbw->selectRow( 'old',
639 array( 'old_text','old_flags'),
640 array( 'old_namespace' => $ns, 'old_title' => $title,
641 'old_timestamp' => $dbw->timestamp($oldDate)),
643 $oldText = Article
::getRevisionText( $obj );
645 if(wfMerge($oldText, $text, $yourtext, $result)){
654 function checkUnicodeCompliantBrowser() {
655 global $wgBrowserBlackList;
656 $currentbrowser = $_SERVER["HTTP_USER_AGENT"];
657 foreach ( $wgBrowserBlackList as $browser ) {
658 if ( preg_match($browser, $currentbrowser) ) {
666 * Format an anchor fragment as it would appear for a given section name
667 * @param string $text
671 function sectionAnchor( $text ) {
672 global $wgInputEncoding;
673 $headline = do_html_entity_decode( $text, ENT_COMPAT
, $wgInputEncoding );
675 $headline = preg_replace( '/<.*?' . '>/', '', $headline );
676 $headline = trim( $headline );
677 $sectionanchor = '#' . urlencode( str_replace( ' ', '_', $headline ) );
678 $replacearray = array(
683 array_keys( $replacearray ),
684 array_values( $replacearray ),
689 * Shows a bulletin board style toolbar for common editing functions.
690 * It can be disabled in the user preferences.
691 * The necessary JavaScript code can be found in style/wikibits.js.
693 function getEditToolbar() {
694 global $wgStylePath, $wgLang, $wgMimeType;
697 * toolarray an array of arrays which each include the filename of
698 * the button image (without path), the opening tag, the closing tag,
699 * and optionally a sample text that is inserted between the two when no
700 * selection is highlighted.
701 * The tip text is shown when the user moves the mouse over the button.
703 * Already here are accesskeys (key), which are not used yet until someone
704 * can figure out a way to make them work in IE. However, we should make
705 * sure these keys are not defined on the edit page.
708 array( 'image'=>'button_bold.png',
711 'sample'=> wfMsg('bold_sample'),
712 'tip' => wfMsg('bold_tip'),
715 array( 'image'=>'button_italic.png',
718 'sample'=> wfMsg('italic_sample'),
719 'tip' => wfMsg('italic_tip'),
722 array( 'image'=>'button_link.png',
725 'sample'=> wfMsg('link_sample'),
726 'tip' => wfMsg('link_tip'),
729 array( 'image'=>'button_extlink.png',
732 'sample'=> wfMsg('extlink_sample'),
733 'tip' => wfMsg('extlink_tip'),
736 array( 'image'=>'button_headline.png',
739 'sample'=> wfMsg('headline_sample'),
740 'tip' => wfMsg('headline_tip'),
743 array( 'image'=>'button_image.png',
744 'open' => '[['.$wgLang->getNsText(NS_IMAGE
).":",
746 'sample'=> wfMsg('image_sample'),
747 'tip' => wfMsg('image_tip'),
750 array( 'image' => 'button_media.png',
751 'open' => '[['.$wgLang->getNsText(NS_MEDIA
).':',
753 'sample'=> wfMsg('media_sample'),
754 'tip' => wfMsg('media_tip'),
757 array( 'image' => 'button_math.png',
758 'open' => "\\<math\\>",
759 'close' => "\\</math\\>",
760 'sample'=> wfMsg('math_sample'),
761 'tip' => wfMsg('math_tip'),
764 array( 'image' => 'button_nowiki.png',
765 'open' => "\\<nowiki\\>",
766 'close' => "\\</nowiki\\>",
767 'sample'=> wfMsg('nowiki_sample'),
768 'tip' => wfMsg('nowiki_tip'),
771 array( 'image' => 'button_sig.png',
775 'tip' => wfMsg('sig_tip'),
778 array( 'image' => 'button_hr.png',
779 'open' => "\\n----\\n",
782 'tip' => wfMsg('hr_tip'),
786 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
788 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
789 foreach($toolarray as $tool) {
791 $image=$wgStylePath.'/common/images/'.$tool['image'];
793 $close=$tool['close'];
794 $sample = addslashes( $tool['sample'] );
796 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
797 // Older browsers show a "speedtip" type message only for ALT.
798 // Ideally these should be different, realistically they
799 // probably don't need to be.
800 $tip = addslashes( $tool['tip'] );
802 #$key = $tool["key"];
804 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
807 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
808 $toolbar.="document.writeln(\"</div>\");\n";
810 $toolbar.="/*]]>*/\n</script>";