Index: trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_EditPageAjax.php |
— | — | @@ -4,28 +4,28 @@ |
5 | 5 | * |
6 | 6 | * All Metavid Wiki code is Released Under the GPL2 |
7 | 7 | * for more info visit http://metavid.org/wiki/Code |
8 | | - * |
9 | | - * |
| 8 | + * |
| 9 | + * |
10 | 10 | * The metavid interface class |
11 | 11 | * provides the metavid interface for Metavid: requests |
12 | 12 | * provides the base metadata |
13 | | - * |
| 13 | + * |
14 | 14 | */ |
15 | 15 | if ( !defined( 'MEDIAWIKI' ) ) die( 1 ); |
16 | 16 | /* very similar to showEditForm in EditPage |
17 | 17 | * differences include: |
18 | | - * ajax type display request and processing |
19 | | - * display type based on mvTitle info |
| 18 | + * ajax type display request and processing |
| 19 | + * display type based on mvTitle info |
20 | 20 | */ |
21 | | - |
| 21 | + |
22 | 22 | class MV_EditPageAjax extends EditPage { |
23 | 23 | var $adj_html = ''; |
24 | 24 | var $basic_html = ''; |
25 | | - |
| 25 | + |
26 | 26 | function __construct( $article ) { |
27 | 27 | $this->mArticle =& $article; |
28 | 28 | $this->mTitle =& $article->mTitle; |
29 | | - |
| 29 | + |
30 | 30 | // print "article content: " . $this->mArticle->getContent(); |
31 | 31 | # Placeholders for text injection by hooks (empty per default) |
32 | 32 | $this->editFormPageTop = |
— | — | @@ -35,22 +35,22 @@ |
36 | 36 | $this->editFormTextBottom = ""; |
37 | 37 | } |
38 | 38 | function do_pre_annoEdit() { |
39 | | - |
| 39 | + |
40 | 40 | } |
41 | 41 | function getAjaxForm() { |
42 | 42 | global $wgUser; |
43 | | - return '<form id="mvd_form_' . $this->mvd_id . '" name="mvd_form_' . $this->mvd_id . '" method="GET" action="" |
| 43 | + return '<form id="mvd_form_' . $this->mvd_id . '" name="mvd_form_' . $this->mvd_id . '" method="GET" action="" |
44 | 44 | onSubmit="mv_do_ajax_form_submit(\'' . $this->mvd_id . '\', \'save\'); return false;" ' . |
45 | 45 | 'enctype="multipart/form-data" >' . |
46 | 46 | '<input type="hidden" name="fname" value="mv_edit_submit">' . |
47 | | - // do the normal edit hidden fields: |
| 47 | + // do the normal edit hidden fields: |
48 | 48 | "\n" . '<input type="hidden" value="' . htmlspecialchars( $wgUser->editToken() ) . |
49 | 49 | '" name="wpEditToken" />' . "\n" . |
50 | 50 | '<input type="hidden" name="title" value="' . $this->mTitle->getDBkey() . '">' . "\n" . |
51 | 51 | '<input type="hidden" name="mvd_id" value="' . $this->mvd_id . '">' . "\n"; |
52 | 52 | } |
53 | 53 | function loadEditText() { |
54 | | - // get the article text if it exists |
| 54 | + // get the article text if it exists |
55 | 55 | if ( $this->mArticle->mTitle->exists() ) { |
56 | 56 | $this->stripped_edit_text = $this->mArticle->getContent(); |
57 | 57 | } else { |
— | — | @@ -61,31 +61,31 @@ |
62 | 62 | function do_pre_htEdit() { |
63 | 63 | global $wgOut, $wgUser; |
64 | 64 | $this->loadEditText(); |
65 | | - |
| 65 | + |
66 | 66 | $MvOverlay = new MV_Overlay(); |
67 | 67 | // strip semantic tags which are managed by the interface: |
68 | 68 | $semantic_data = $MvOverlay->get_and_strip_semantic_tags( $this->stripped_edit_text ); |
69 | 69 | $out = $js_eval = ''; |
70 | | - // add a div for previews: |
| 70 | + // add a div for previews: |
71 | 71 | $wgOut->addHTML( '<div id="wikiPreview_' . $this->mvd_id . '"></div>' ); |
72 | | - |
73 | | - // set the default action so save page: |
| 72 | + |
| 73 | + // set the default action so save page: |
74 | 74 | $wgOut->addHTML( $this->getAjaxForm() ); |
75 | | - |
76 | | - // add in adjust html if present: |
| 75 | + |
| 76 | + // add in adjust html if present: |
77 | 77 | $wgOut->addHTML( $this->adj_html ); |
78 | | - |
79 | | - // structure layout via tables (@@todo switch to class based css layout) |
| 78 | + |
| 79 | + // structure layout via tables (@@todo switch to class based css layout) |
80 | 80 | $wgOut->addHTML( '<table style="background: transparent;" width="100%"><tr><td valign="top" width="90">' ); |
81 | 81 | // output the person selector: |
82 | 82 | if ( !isset ( $semantic_data['spoken_by'] ) )$semantic_data['spoken_by'] = ''; |
83 | 83 | $img = mv_get_person_img( $semantic_data['spoken_by'] ); |
84 | 84 | $wgOut->addHTML( '<img id="mv_edit_im_' . htmlspecialchars( $this->mvd_id ) . '" style="display: block;margin-left: auto;margin-right: auto;" src="' . htmlspecialchars( $img->getURL() ) . '" width="44">' ); |
85 | | - $wgOut->addHTML( '<input style="font-size:x-small" |
86 | | - value="' . htmlspecialchars( $semantic_data['spoken_by'] ) . '" |
| 85 | + $wgOut->addHTML( '<input style="font-size:x-small" |
| 86 | + value="' . htmlspecialchars( $semantic_data['spoken_by'] ) . '" |
87 | 87 | name="smw_Spoken_By" |
88 | | - onClick="this.value=\'\';" |
89 | | - type="text" id="auto_comp_' . htmlspecialchars( $this->mvd_id ) . '" size="12" |
| 88 | + onClick="this.value=\'\';" |
| 89 | + type="text" id="auto_comp_' . htmlspecialchars( $this->mvd_id ) . '" size="12" |
90 | 90 | maxlength="125" autocomplete="off"/>' ); |
91 | 91 | // only add one auto_comp_choices_ per object/request pass |
92 | 92 | if ( !isset( $this->auto_comp_choices ) ) { |
— | — | @@ -149,19 +149,19 @@ |
150 | 150 | // limt rows for ajax: |
151 | 151 | $non_ajax_rows = $wgUser->getIntOption( 'rows' ); |
152 | 152 | $wgUser->setOption( 'rows', 5 ); |
153 | | - |
| 153 | + |
154 | 154 | $sk = $wgUser->getSkin(); |
155 | 155 | $cancel = '<a href="javascript:mv_disp_mvd(\'' . $this->mTitle->getDBkey() . '\',\'' . |
156 | 156 | $this->mvd_id . '\');">' . wfMsgExt( 'cancel', array( 'parseinline' ) ) . '</a>'; |
157 | | - |
| 157 | + |
158 | 158 | // get the stream parent: |
159 | 159 | $mvd = MV_Index::getMVDbyId( $this->mvd_id ); |
160 | 160 | $stream_name = MV_Stream::getStreamNameFromId( $mvd->stream_id ); |
161 | | - |
| 161 | + |
162 | 162 | $lTitle = Title::makeTitle( NS_SPECIAL, 'Userlogin' ); |
163 | | - $loginLink = $lTitle->getFullURL('returnto=' . MWNamespace::getCanonicalName( MV_NS_STREAM ) . ':' . $stream_name ); |
164 | | - |
165 | | - $wgOut->addHTML( wfMsg( 'mv_user_cant_edit', $loginLink, $cancel ) ); |
| 163 | + $loginLink = $lTitle->getFullURL('returnto=' . MWNamespace::getCanonicalName( MV_NS_STREAM ) . ':' . $stream_name ); |
| 164 | + |
| 165 | + $wgOut->addWikiText( wfMsg( 'mv_user_cant_edit', $loginLink, $cancel ) ); |
166 | 166 | $wgOut->readOnlyPage( $this->mArticle->getContent(), true, $permErrors ); |
167 | 167 | $wgUser->setOption( 'rows', $non_ajax_rows ); |
168 | 168 | wfProfileOut( $fname ); |
— | — | @@ -215,7 +215,7 @@ |
216 | 216 | # Show applicable editing introductions |
217 | 217 | if ( $this->formtype == 'initial' || $this->firsttime ) |
218 | 218 | $this->showIntro(); |
219 | | - |
| 219 | + |
220 | 220 | if ( $this->mTitle->isTalkPage() ) { |
221 | 221 | $wgOut->addWikiText( wfMsg( 'talkpagetext' ) ); |
222 | 222 | } |
— | — | @@ -225,9 +225,9 @@ |
226 | 226 | # that edit() already checked just in case someone tries to sneak |
227 | 227 | # in the back door with a hand-edited submission URL. |
228 | 228 | |
229 | | - // set up commit transaction |
| 229 | + // set up commit transaction |
230 | 230 | // $dbw = wfGetDB( DB_MASTER ); |
231 | | - // $dbw->begin(); |
| 231 | + // $dbw->begin(); |
232 | 232 | |
233 | 233 | if ( 'save' == $this->formtype ) { |
234 | 234 | if ( !$this->attemptSave() ) { |
— | — | @@ -236,7 +236,7 @@ |
237 | 237 | return; |
238 | 238 | } |
239 | 239 | } |
240 | | - |
| 240 | + |
241 | 241 | // $dbw->immediateCommit(); |
242 | 242 | |
243 | 243 | # First time through: get contents, set time for conflict |
— | — | @@ -256,7 +256,7 @@ |
257 | 257 | wfProfileOut( "$fname-business-end" ); |
258 | 258 | wfProfileOut( $fname ); |
259 | 259 | } |
260 | | - /********would not have to override if they where not "private" functions |
| 260 | + /********would not have to override if they where not "private" functions |
261 | 261 | /** |
262 | 262 | * Should we show a preview when the edit form is first shown? |
263 | 263 | * |
— | — | @@ -323,7 +323,7 @@ |
324 | 324 | } |
325 | 325 | function do_post_HtEdit() { |
326 | 326 | global $wgOut; |
327 | | - /*"<textarea name=\"wpTextbox{$mvd_id}\" |
| 327 | + /*"<textarea name=\"wpTextbox{$mvd_id}\" |
328 | 328 | id=\"wpTextbox{$this->mvd_id}\" rows='3' |
329 | 329 | cols=\"50\" >$text |
330 | 330 | </textarea>"*/ |
— | — | @@ -348,7 +348,7 @@ |
349 | 349 | } |
350 | 350 | function internalAttemptSave( &$result, $bot = false ) { |
351 | 351 | global $wgHooks; |
352 | | - // clear confirmEdit for ajax edits: |
| 352 | + // clear confirmEdit for ajax edits: |
353 | 353 | if ( isset( $wgHooks['EditFilter'] ) ) { |
354 | 354 | foreach ( $wgHooks['EditFilter'] as $k => $hook ) { |
355 | 355 | unset( $wgHooks['EditFilter'][$k] ); |
— | — | @@ -358,13 +358,13 @@ |
359 | 359 | } |
360 | 360 | function showEditForm( $formCallback = null ) { |
361 | 361 | global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize; |
362 | | - |
| 362 | + |
363 | 363 | // print "call SHOW EDIT FORM"; |
364 | 364 | if ( !isset( $this->stripped_edit_text ) )$this->stripped_edit_text = ''; |
365 | | - |
| 365 | + |
366 | 366 | $fname = 'EditPageAjax::showEditForm'; |
367 | 367 | wfProfileIn( $fname ); |
368 | | - |
| 368 | + |
369 | 369 | $closeFormHtml = ''; |
370 | 370 | // check if we are in the MVD namespace (and need to use templates for edits:) |
371 | 371 | if ( $this->mTitle->getNamespace() == MV_NS_MVD ) { |
— | — | @@ -374,7 +374,7 @@ |
375 | 375 | } |
376 | 376 | $editFormType = strtolower( $this->mvTitle->getMvdTypeKey() ); |
377 | 377 | } else { |
378 | | - // check if its seq type: |
| 378 | + // check if its seq type: |
379 | 379 | if ( $this->mvd_id == 'seq' ) { |
380 | 380 | $editFormType = 'seq'; |
381 | 381 | } else { |
— | — | @@ -388,9 +388,9 @@ |
389 | 389 | break; |
390 | 390 | case 'anno_en': |
391 | 391 | $this->loadEditText(); |
392 | | - // set the default action so save page: |
| 392 | + // set the default action so save page: |
393 | 393 | $wgOut->addHTML( $this->getAjaxForm() ); |
394 | | - // add in adjust html if present: |
| 394 | + // add in adjust html if present: |
395 | 395 | $wgOut->addHTML( $this->adj_html ); |
396 | 396 | break; |
397 | 397 | case 'seq': |
— | — | @@ -404,7 +404,7 @@ |
405 | 405 | break; |
406 | 406 | default: |
407 | 407 | $this->loadEditText(); |
408 | | - // set the default action so save page: |
| 408 | + // set the default action so save page: |
409 | 409 | $wgOut->addHTML( $this->getAjaxForm() ); |
410 | 410 | break; |
411 | 411 | } |
— | — | @@ -535,7 +535,7 @@ |
536 | 536 | if ( $this->formtype == 'preview' ) { |
537 | 537 | $previewOutput = $this->getPreviewText(); |
538 | 538 | } |
539 | | - |
| 539 | + |
540 | 540 | if ( $wgUser->getOption( 'previewontop' ) ) { |
541 | 541 | |
542 | 542 | if ( 'preview' == $this->formtype ) { |
— | — | @@ -550,7 +550,7 @@ |
551 | 551 | } |
552 | 552 | $wgOut->addHTML( $this->basic_html ); |
553 | 553 | $wgOut->addHTML( '<div style="display:inline" class="mv_advanced_edit"><br>' ); |
554 | | - |
| 554 | + |
555 | 555 | // $rows = $wgUser->getIntOption( 'rows' ); |
556 | 556 | // $cols = $wgUser->getIntOption( 'cols' ); |
557 | 557 | // for ajax short edit area: |
— | — | @@ -560,7 +560,7 @@ |
561 | 561 | $ew = $wgUser->getOption( 'editwidth' ); |
562 | 562 | if ( $ew ) $ew = " style=\"width:100%\""; |
563 | 563 | else $ew = ''; |
564 | | - |
| 564 | + |
565 | 565 | // do ajax action: |
566 | 566 | // $q = 'action=ajax'; |
567 | 567 | # if ( "no" == $redirect ) { $q .= "&redirect=no"; } |
— | — | @@ -582,7 +582,7 @@ |
583 | 583 | $this->mvd_id . '\');">' . wfMsgExt( 'cancel', array( 'parseinline' ) ) . '</a>'; |
584 | 584 | $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' ) ); |
585 | 585 | } |
586 | | - |
| 586 | + |
587 | 587 | $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . |
588 | 588 | htmlspecialchars( wfMsg( 'edithelp' ) ) . '</a> ' . |
589 | 589 | htmlspecialchars( wfMsg( 'newwindow' ) ); |
— | — | @@ -594,7 +594,7 @@ |
595 | 595 | '[[' . wfMsgForContent( 'copyrightpage' ) . ']]', |
596 | 596 | $wgRightsText ) . "\n</div>"; |
597 | 597 | */ |
598 | | - |
| 598 | + |
599 | 599 | if ( $wgUser->getOption( 'showtoolbar' ) and !$this->isCssJsSubpage ) { |
600 | 600 | # prepare toolbar for edit buttons |
601 | 601 | $toolbar = EditPage::getEditToolbar(); |
— | — | @@ -641,7 +641,7 @@ |
642 | 642 | /*if( !$this->preview && !$this->diff ) { |
643 | 643 | $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' ); |
644 | 644 | }*/ |
645 | | - |
| 645 | + |
646 | 646 | $templates = ( $this->preview || $this->section != '' ) ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates(); |
647 | 647 | $formattedtemplates = $sk->formatTemplates( $templates, $this->preview, $this->section != '' ); |
648 | 648 | |
— | — | @@ -677,9 +677,9 @@ |
678 | 678 | array( 'minor' => $this->minoredit, 'watch' => $this->watchthis ) ); |
679 | 679 | |
680 | 680 | $checkboxhtml = implode( $checkboxes, "\n" ); |
681 | | - |
| 681 | + |
682 | 682 | $button_action = 'mv_do_ajax_form_submit(\'' . $this->mvd_id . '\', \'%s\');'; |
683 | | - |
| 683 | + |
684 | 684 | $buttons = $this->getEditButtons( $tabindex , $button_action ); |
685 | 685 | $buttonshtml = implode( $buttons, "\n" ); |
686 | 686 | |
— | — | @@ -717,7 +717,7 @@ |
718 | 718 | " |
719 | 719 | </textarea> |
720 | 720 | " ); |
721 | | - |
| 721 | + |
722 | 722 | // close advanced display_edit div |
723 | 723 | $wgOut->addHTML( "</div>" ); |
724 | 724 | |
— | — | @@ -836,10 +836,10 @@ |
837 | 837 | ); |
838 | 838 | if ( $this->mvd_id == 'seq' ) |
839 | 839 | $temp['value'] = wfMsg( 'mv_save_sequence' ); |
840 | | - |
| 840 | + |
841 | 841 | if ( $button_action != '' ) |
842 | 842 | $temp['onMouseUp'] = sprintf( $button_action, 'save' ); |
843 | | - |
| 843 | + |
844 | 844 | $buttons['save'] = Xml::element( 'input', $temp, '' ); |
845 | 845 | |
846 | 846 | ++$tabindex; // use the same for preview and live preview |
— | — | @@ -883,7 +883,7 @@ |
884 | 884 | ); |
885 | 885 | if ( $button_action != '' ) |
886 | 886 | $temp['onMouseUp'] = sprintf( $button_action, 'preview' ); |
887 | | - |
| 887 | + |
888 | 888 | $buttons['preview'] = Xml::element( 'input', $temp, '' ); |
889 | 889 | $buttons['live'] = ''; |
890 | 890 | } |