Index: trunk/extensions/uniwiki/GenericEditPage/GenericEditPage.php |
— | — | @@ -439,8 +439,7 @@ |
440 | 440 | |
441 | 441 | /* special case: if the first (un-named) section has text in the layout, |
442 | 442 | * but not in the page, copy it. otherwise, use the page text (even if empty) */ |
443 | | - // FIXME: Undefined offset: 0 in scenario without layout |
444 | | - $result[] = ( $layout[0]['text'] && !$page[0]['text'] ) ? $layout[0] : $page[0]; |
| 443 | + $result[] = ( !empty($layout[0]) && $layout[0]['text'] && !$page[0]['text'] ) ? $layout[0] : $page[0]; |
445 | 444 | |
446 | 445 | /* only show the un-named section if it is being used. as |
447 | 446 | * default, do not encourage people to use it by showing it */ |
— | — | @@ -589,8 +588,7 @@ |
590 | 589 | |
591 | 590 | |
592 | 591 | // if this section has a title, show it |
593 | | - // FIXME: Undefined index: title in scenario without layout |
594 | | - if ( $result[$i]['title'] ) { |
| 592 | + if ( !empty($result[$i]['title']) ) { |
595 | 593 | $title = $result[$i]['title']; |
596 | 594 | if ( $result[$i]['lock-header'] ) { |
597 | 595 | $out->addHTML ( "<h2>$title</h2>" ); |
— | — | @@ -607,8 +605,7 @@ |
608 | 606 | /* always add a textarea, whether or |
609 | 607 | * not it is currently in use. titles |
610 | 608 | * without text are kind of useless */ |
611 | | - // FIXME: Undefined index: lock-text in scenario without layout |
612 | | - if ( $result[$i]['lock-text'] ) { |
| 609 | + if ( !empty($result[$i]['lock-text']) ) { |
613 | 610 | |
614 | 611 | /* render the wiki markup into HTML, the old-school |
615 | 612 | * way which actually works, unlike recursiveTagParse() */ |
— | — | @@ -617,7 +614,8 @@ |
618 | 615 | $out->addHTML ( "<div class='locked-text' id='locked-text-$i'>" . $text . "</div>" ); |
619 | 616 | } else { |
620 | 617 | // add the editable text for this section |
621 | | - $text = htmlspecialchars ( $result[$i]['text'], ENT_QUOTES ); |
| 618 | + $text = (empty($result[$i]['text'])) ? "" : $result[$i]['text']; |
| 619 | + $text = htmlspecialchars ($text , ENT_QUOTES ); |
622 | 620 | $out->addHTML ( "<textarea name='section-$i' class='editor'>$text</textarea>" ); |
623 | 621 | } |
624 | 622 | |
— | — | @@ -654,8 +652,8 @@ |
655 | 653 | |
656 | 654 | |
657 | 655 | // pass the layout name back, to be re-appended |
658 | | - // FIXME: Undefined offset: 0 in scenario without layout |
659 | | - $out->addHTML ( "<input type='hidden' name='layout-name' value='{$layout[0]['name']}' />" ); |
| 656 | + if(!empty($layout)) |
| 657 | + $out->addHTML ( "<input type='hidden' name='layout-name' value='{$layout[0]['name']}' />" ); |
660 | 658 | |
661 | 659 | |
662 | 660 | // build the sidebar (cats, sections) in its entirety |
Index: trunk/extensions/uniwiki/FormatChanges/FormatChanges.body.php |
— | — | @@ -0,0 +1,65 @@ |
| 2 | +<?php |
| 3 | +class UniwikiFormatChanges { |
| 4 | + public function UW_FormatChanges( $user, $skin, $list ) { |
| 5 | + $list = new UniwikiChangesList( $skin ); |
| 6 | + return false; |
| 7 | + } |
| 8 | +} |
| 9 | + |
| 10 | +class UniwikiChangesList extends ChangesList { |
| 11 | + |
| 12 | + public function recentChangesLine( &$rc, $watched = false ) { |
| 13 | + global $wgLang; |
| 14 | + |
| 15 | + // set local vars (this apparently does that) |
| 16 | + extract( $rc->mAttribs ); |
| 17 | + |
| 18 | + $this->insertDateHeader( $line, $rc_timestamp ); |
| 19 | + |
| 20 | + /* NOTE: the following logic is reproduced from |
| 21 | + * the old version of the recent changes |
| 22 | + * page in case we want to produce a |
| 23 | + * similar result (though much is not |
| 24 | + * implemented yet)... |
| 25 | + */ |
| 26 | + |
| 27 | + // moved pages |
| 28 | + if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { |
| 29 | + // handle these? |
| 30 | + } |
| 31 | + // log entries(old) and special pages |
| 32 | + else if ( $rc_namespace == NS_SPECIAL ) { |
| 33 | + // handle these? |
| 34 | + } |
| 35 | + // new unpatrolled pages |
| 36 | + else if ( isset( $rc->unpatrolled ) && $rc_type == RC_NEW ) { |
| 37 | + // handle these? |
| 38 | + } |
| 39 | + // log entries |
| 40 | + else if ( $rc_type == RC_LOG ) { |
| 41 | + // handle these? |
| 42 | + } |
| 43 | + // edits and new pages |
| 44 | + else { |
| 45 | + wfLoadExtensionMessages( 'FormatChanges' ); |
| 46 | + |
| 47 | + $line .= "<li>"; |
| 48 | + $page_link = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' ); |
| 49 | + if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) { |
| 50 | + $user_link = '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>'; |
| 51 | + } else { |
| 52 | + $user_link = ( $rc_user > 0 ) ? $this->skin->userLink( $rc_user, $rc_user_text ) : wfMsg( 'formatchanges-anonymous' ); |
| 53 | + } |
| 54 | + $timestamp = $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ); |
| 55 | + |
| 56 | + if ( $rc_type == RC_NEW ) { |
| 57 | + $line .= wfMsgHtml( 'formatchanges-createdby', $page_link, $user_link, $timestamp ); |
| 58 | + } else { |
| 59 | + $line .= wfMsgHtml( 'formatchanges-editedby', $page_link, $user_link, $timestamp ); |
| 60 | + } |
| 61 | + $line .= "</li>"; |
| 62 | + } |
| 63 | + |
| 64 | + return $line; |
| 65 | + } |
| 66 | +} |
Property changes on: trunk/extensions/uniwiki/FormatChanges/FormatChanges.body.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 67 | + native |
Index: trunk/extensions/uniwiki/FormatChanges/FormatChanges.php |
— | — | @@ -16,70 +16,9 @@ |
17 | 17 | ); |
18 | 18 | |
19 | 19 | $wgExtensionMessagesFiles['FormatChanges'] = dirname( __FILE__ ) . '/FormatChanges.i18n.php'; |
| 20 | +$wgAutoloadClasses['UniwikiFormatChanges'] = dirname(__FILE__) . '/FormatChanges.body.php'; |
20 | 21 | |
21 | | -/* ---- HOOKS ---- */ |
22 | | -$wgHooks['FetchChangesList'][] = "UW_FormatChanges"; |
| 22 | +$wgUniwikiFormatChangesObject = new UniwikiFormatChanges(); |
23 | 23 | |
24 | | -// FIXME: split off into a class file. See ChangesList.php for example. |
25 | | -function UW_FormatChanges( $user, $skin, $list ) { |
26 | | - $list = new UniwikiChangesList( $skin ); |
27 | | - return false; |
28 | | -} |
29 | | - |
30 | | -class UniwikiChangesList extends ChangesList { |
31 | | - |
32 | | - public function recentChangesLine( &$rc, $watched = false ) { |
33 | | - global $wgLang; |
34 | | - |
35 | | - // set local vars (this apparently does that) |
36 | | - extract( $rc->mAttribs ); |
37 | | - |
38 | | - $this->insertDateHeader( $line, $rc_timestamp ); |
39 | | - |
40 | | - /* NOTE: the following logic is reproduced from |
41 | | - * the old version of the recent changes |
42 | | - * page in case we want to produce a |
43 | | - * similar result (though much is not |
44 | | - * implemented yet)... |
45 | | - */ |
46 | | - |
47 | | - // moved pages |
48 | | - if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { |
49 | | - // handle these? |
50 | | - } |
51 | | - // log entries(old) and special pages |
52 | | - else if ( $rc_namespace == NS_SPECIAL ) { |
53 | | - // handle these? |
54 | | - } |
55 | | - // new unpatrolled pages |
56 | | - else if ( isset( $rc->unpatrolled ) && $rc_type == RC_NEW ) { |
57 | | - // handle these? |
58 | | - } |
59 | | - // log entries |
60 | | - else if ( $rc_type == RC_LOG ) { |
61 | | - // handle these? |
62 | | - } |
63 | | - // edits and new pages |
64 | | - else { |
65 | | - wfLoadExtensionMessages( 'FormatChanges' ); |
66 | | - |
67 | | - $line .= "<li>"; |
68 | | - $page_link = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' ); |
69 | | - if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) { |
70 | | - $user_link = '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>'; |
71 | | - } else { |
72 | | - $user_link = ( $rc_user > 0 ) ? $this->skin->userLink( $rc_user, $rc_user_text ) : wfMsg( 'formatchanges-anonymous' ); |
73 | | - } |
74 | | - $timestamp = $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ); |
75 | | - |
76 | | - if ( $rc_type == RC_NEW ) { |
77 | | - $line .= wfMsgHtml( 'formatchanges-createdby', $page_link, $user_link, $timestamp ); |
78 | | - } else { |
79 | | - $line .= wfMsgHtml( 'formatchanges-editedby', $page_link, $user_link, $timestamp ); |
80 | | - } |
81 | | - $line .= "</li>"; |
82 | | - } |
83 | | - |
84 | | - return $line; |
85 | | - } |
86 | | -} |
| 24 | +/* ---- HOOKS ---- */ |
| 25 | +$wgHooks['FetchChangesList'][] = array($wgUniwikiFormatChangesObject,"UW_FormatChanges"); |
Index: trunk/extensions/uniwiki/AutoCreateCategoryPages/AutoCreateCategoryPages.php |
— | — | @@ -18,77 +18,10 @@ |
19 | 19 | ); |
20 | 20 | |
21 | 21 | $wgExtensionMessagesFiles['AutoCreateCategoryPages'] = dirname( __FILE__ ) . '/AutoCreateCategoryPages.i18n.php'; |
| 22 | +$wgAutoloadClasses['UniwikiAutoCreateCategoryPages'] = dirname(__FILE__) . '/AutoCreateCategoryPages.body.php'; |
22 | 23 | |
23 | | -/* ---- HOOKS ---- */ |
24 | | -$wgHooks['ArticleSaveComplete'][] = "UW_AutoCreateCategoryPages_Save"; |
25 | | -$wgHooks['UserGetReservedNames'][] = 'UW_OnUserGetReservedNames'; |
| 24 | +$wgAutoCreateCategoryPagesObject = new UniwikiAutoCreateCategoryPages(); |
26 | 25 | |
27 | | -// FIXME: put methods in a class and their own file. |
28 | | -function UW_AutoCreateCategoryPages_Save ( &$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor, &$flags, $revision ) { |
29 | | - global $wgDBprefix; |
30 | | - |
31 | | - /* after the page is saved, get all the categories |
32 | | - * and see if they exists as "proper" pages; if not |
33 | | - * then create a simple page for them automatically */ |
34 | | - |
35 | | - // Extract the categories on this page |
36 | | - // |
37 | | - // FIXME: this obviously only works for the English namespaces |
38 | | - // |
39 | | - $regex = "/\[\[category:(.+?)(?:\|.*)?\]\]/i"; |
40 | | - preg_match_all ( $regex, $text, $matches ); |
41 | | - |
42 | | - // array of the categories on the page (in db form) |
43 | | - $on_page = array(); |
44 | | - foreach ( $matches[1] as $cat ) |
45 | | - $on_page[] = Title::newFromText ( $cat )->getDBkey(); |
46 | | - |
47 | | - // array of the categories in the db |
48 | | - $db = wfGetDB ( DB_MASTER ); |
49 | | - $results = $db->resultObject ( $db->query( |
50 | | - "select distinct page_title from {$wgDBprefix}page " . |
51 | | - "where page_namespace = '" . NS_CATEGORY . "'" ) |
52 | | - ); |
53 | | - |
54 | | - $in_db = array(); |
55 | | - while ( $r = $results->next() ) |
56 | | - $in_db[] = $r->page_title; |
57 | | - |
58 | | - /* loop through the categories in the page and |
59 | | - * see if they already exist as a category page */ |
60 | | - foreach ( $on_page as $db_key ) { |
61 | | - if ( !in_array( $db_key, $in_db ) ) { |
62 | | - |
63 | | - wfLoadExtensionMessages( 'AutoCreateCategoryPages' ); |
64 | | - |
65 | | - // Create a user object for the editing user and add it to the database |
66 | | - // if it is not there already |
67 | | - $editor = User::newFromName( wfMsgForContent( 'autocreatecategorypages-editor' ) ); |
68 | | - if ( !$editor->isLoggedIn() ) { |
69 | | - $editor->addToDatabase(); |
70 | | - } |
71 | | - |
72 | | - // if it does not exist, then create it here |
73 | | - $page_title = Title::newFromDBkey ( $db_key )->getText(); |
74 | | - $stub = wfMsgForContent ( 'autocreatecategorypages-stub', $page_title ); |
75 | | - $summary = wfMsgForContent ( 'autocreatecategorypages-createdby' ); |
76 | | - $article = new Article ( Title::newFromDBkey( "Category:$db_key" ) ); |
77 | | - |
78 | | - try { |
79 | | - $article->doEdit ( $stub, $summary, EDIT_NEW & EDIT_SUPPRESS_RC, false, $editor ); |
80 | | - |
81 | | - } catch ( MWException $e ) { |
82 | | - /* fail silently... |
83 | | - * todo: what can go wrong here? */ |
84 | | - } |
85 | | - } |
86 | | - } |
87 | | - |
88 | | - return true; |
89 | | -} |
90 | | - |
91 | | -function UW_OnUserGetReservedNames( &$names ) { |
92 | | - wfLoadExtensionMessages( 'AutoCreateCategoryPages' ); |
93 | | - $names[] = 'msg:autocreatecategorypages-editor'; |
94 | | - return true; |
95 | | -} |
| 26 | +/* ---- HOOKS ---- */ |
| 27 | +$wgHooks['ArticleSaveComplete'][] = array($wgAutoCreateCategoryPagesObject,"UW_AutoCreateCategoryPages_Save"); |
| 28 | +$wgHooks['UserGetReservedNames'][] = array($wgAutoCreateCategoryPagesObject,'UW_OnUserGetReservedNames'); |
Index: trunk/extensions/uniwiki/AutoCreateCategoryPages/AutoCreateCategoryPages.body.php |
— | — | @@ -0,0 +1,79 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class UniwikiAutoCreateCategoryPages { |
| 5 | + public function UW_AutoCreateCategoryPages_Save ( &$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor, &$flags, $revision ) { |
| 6 | + global $wgDBprefix; |
| 7 | + |
| 8 | + /* after the page is saved, get all the categories |
| 9 | + * and see if they exists as "proper" pages; if not |
| 10 | + * then create a simple page for them automatically */ |
| 11 | + |
| 12 | + // Extract the categories on this page |
| 13 | + // |
| 14 | + // FIXME: this obviously only works for the English namespaces |
| 15 | + // |
| 16 | + $category = wfMsg("nstab-category"); |
| 17 | + $regex = "/\[\[{$category}:(.+?)(?:\|.*)?\]\]/i"; |
| 18 | + preg_match_all ( $regex, $text, $matches ); |
| 19 | + |
| 20 | + // array of the categories on the page (in db form) |
| 21 | + $on_page = array(); |
| 22 | + foreach ( $matches[1] as $cat ) |
| 23 | + $on_page[] = Title::newFromText ( $cat )->getDBkey(); |
| 24 | + |
| 25 | + $regex = "/\[\[category:(.+?)(?:\|.*)?\]\]/i"; |
| 26 | + preg_match_all ( $regex, $text, $matches ); |
| 27 | + |
| 28 | + foreach ( $matches[1] as $cat ) |
| 29 | + $on_page[] = Title::newFromText ( $cat )->getDBkey(); |
| 30 | + |
| 31 | + // array of the categories in the db |
| 32 | + $db = wfGetDB ( DB_MASTER ); |
| 33 | + $results = $db->resultObject ( $db->query( |
| 34 | + "select distinct page_title from {$wgDBprefix}page " . |
| 35 | + "where page_namespace = '" . NS_CATEGORY . "'" ) |
| 36 | + ); |
| 37 | + |
| 38 | + $in_db = array(); |
| 39 | + while ( $r = $results->next() ) |
| 40 | + $in_db[] = $r->page_title; |
| 41 | + |
| 42 | + /* loop through the categories in the page and |
| 43 | + * see if they already exist as a category page */ |
| 44 | + foreach ( $on_page as $db_key ) { |
| 45 | + if ( !in_array( $db_key, $in_db ) ) { |
| 46 | + |
| 47 | + wfLoadExtensionMessages( 'AutoCreateCategoryPages' ); |
| 48 | + |
| 49 | + // Create a user object for the editing user and add it to the database |
| 50 | + // if it is not there already |
| 51 | + $editor = User::newFromName( wfMsgForContent( 'autocreatecategorypages-editor' ) ); |
| 52 | + if ( !$editor->isLoggedIn() ) { |
| 53 | + $editor->addToDatabase(); |
| 54 | + } |
| 55 | + |
| 56 | + // if it does not exist, then create it here |
| 57 | + $page_title = Title::newFromDBkey ( $db_key )->getText(); |
| 58 | + $stub = wfMsgForContent ( 'autocreatecategorypages-stub', $page_title ); |
| 59 | + $summary = wfMsgForContent ( 'autocreatecategorypages-createdby' ); |
| 60 | + $article = new Article ( Title::newFromDBkey( "Category:$db_key" ) ); |
| 61 | + |
| 62 | + try { |
| 63 | + $article->doEdit ( $stub, $summary, EDIT_NEW & EDIT_SUPPRESS_RC, false, $editor ); |
| 64 | + |
| 65 | + } catch ( MWException $e ) { |
| 66 | + /* fail silently... |
| 67 | + * todo: what can go wrong here? */ |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + return true; |
| 73 | + } |
| 74 | + |
| 75 | + public function UW_OnUserGetReservedNames( &$names ) { |
| 76 | + wfLoadExtensionMessages( 'AutoCreateCategoryPages' ); |
| 77 | + $names[] = 'msg:autocreatecategorypages-editor'; |
| 78 | + return true; |
| 79 | + } |
| 80 | +} |
Property changes on: trunk/extensions/uniwiki/AutoCreateCategoryPages/AutoCreateCategoryPages.body.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 81 | + native |