Index: trunk/extensions/Collection/Collection.php |
— | — | @@ -87,7 +87,9 @@ |
88 | 88 | $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'Collection::createNavURLs'; |
89 | 89 | $wgHooks['MonoBookTemplateToolboxEnd'][] = 'Collection::insertMonoBookToolboxLink'; |
90 | 90 | |
| 91 | +$wgHooks['SkinBuildSidebar'][] = 'Collection::buildSidebar'; |
91 | 92 | |
| 93 | + |
92 | 94 | function collectionLocalizedPageName(&$specialPageArray, $code) { |
93 | 95 | wfLoadExtensionMessages( 'Collection' ); |
94 | 96 | $text = wfMsg( 'coll-collection' ); |
Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | } else { |
71 | 71 | $redirectURL = $title->getFullURL( 'oldid=' . $oldid ); |
72 | 72 | } |
73 | | - $title->invalidateCache(); |
| 73 | + $wgUser->invalidateCache(); |
74 | 74 | $wgOut->redirect( $redirectURL ); |
75 | 75 | return; |
76 | 76 | } else if ( $par == 'remove_article/' ) { |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | } else { |
84 | 84 | $redirectURL = $title->getFullURL( 'oldid=' . $oldid ); |
85 | 85 | } |
86 | | - $title->invalidateCache(); |
| 86 | + $wgUser->invalidateCache(); |
87 | 87 | $wgOut->redirect( $redirectURL ); |
88 | 88 | return; |
89 | 89 | } else if ( $par == 'add_category/' ) { |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | } else { |
95 | 95 | $wgOut->redirect( $title->getFullURL() ); |
96 | 96 | } |
97 | | - $title->invalidateCache(); |
| 97 | + $wgUser->invalidateCache(); |
98 | 98 | return; |
99 | 99 | } else if ( $par == 'load_collection/' ) { |
100 | 100 | $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) ); |
— | — | @@ -1045,6 +1045,24 @@ |
1046 | 1046 | return true; |
1047 | 1047 | } |
1048 | 1048 | |
| 1049 | + |
| 1050 | + static function buildSidebar( $skin, &$bar ) { |
| 1051 | + global $wgArticle, $wgUser; |
| 1052 | + if( $wgUser->isLoggedIn() ) { |
| 1053 | + // We don't want this sidebar gadget polluting the HTTP caches. |
| 1054 | + // To stay on the safe side for now, we'll show this only for |
| 1055 | + // logged-in users. |
| 1056 | + // |
| 1057 | + // In theory this could be managed properly for open sessions, |
| 1058 | + // but you'd have to inject something for non-open sessions or |
| 1059 | + // it would be very confusing. |
| 1060 | + if( $wgArticle && $wgArticle->exists() ) { |
| 1061 | + $bar['COLLECTION'] = self::printPortlet(); |
| 1062 | + } |
| 1063 | + } |
| 1064 | + return true; |
| 1065 | + } |
| 1066 | + |
1049 | 1067 | /** |
1050 | 1068 | * Return HTML-code to be inserted as portlet |
1051 | 1069 | */ |
— | — | @@ -1067,13 +1085,7 @@ |
1068 | 1086 | $loadCollection = wfMsgHtml( 'coll-load_collection' ); |
1069 | 1087 | $tooBigCat = wfMsgHtml( 'coll-too_big_cat' ); |
1070 | 1088 | |
1071 | | - print <<<EOS |
1072 | | - <div id="p-collection" class="portlet"> |
1073 | | - <h5>$portletTitle</h5> |
1074 | | - <div class="pBody"> |
1075 | | - <ul> |
1076 | | -EOS |
1077 | | - ; |
| 1089 | + $out = "<ul>"; |
1078 | 1090 | if ( is_null( $wgArticle ) || !$wgArticle->exists() ) { |
1079 | 1091 | // no op |
1080 | 1092 | } else if ( self::isCollectionPage( $wgTitle, $wgArticle) ) { |
— | — | @@ -1082,7 +1094,7 @@ |
1083 | 1095 | 'Collection', |
1084 | 1096 | 'load_collection/' |
1085 | 1097 | ), $params ) ); |
1086 | | - print "<li><a href=\"$href\">$loadCollection</a></li>"; |
| 1098 | + $out .= "<li><a href=\"$href\">$loadCollection</a></li>"; |
1087 | 1099 | } else if ( $wgTitle->getNamespace() == NS_MAIN ) { // TODO: only NS_MAIN? |
1088 | 1100 | $params = "arttitle=" . $wgTitle->getPrefixedUrl() . "&oldid=" . $wgArticle->getOldID(); |
1089 | 1101 | |
— | — | @@ -1091,13 +1103,13 @@ |
1092 | 1104 | 'Collection', |
1093 | 1105 | 'add_article/' |
1094 | 1106 | ), $params ) ); |
1095 | | - print "<li><a href=\"$href\">$addArticle</a></li>"; |
| 1107 | + $out .= "<li><a href=\"$href\">$addArticle</a></li>"; |
1096 | 1108 | } else { |
1097 | 1109 | $href = htmlspecialchars( wfAppendQuery( SkinTemplate::makeSpecialUrlSubpage( |
1098 | 1110 | 'Collection', |
1099 | 1111 | 'remove_article/' |
1100 | 1112 | ), $params ) ); |
1101 | | - print "<li><a href=\"$href\">$removeArticle</a></li>"; |
| 1113 | + $out .= "<li><a href=\"$href\">$removeArticle</a></li>"; |
1102 | 1114 | } |
1103 | 1115 | } else if ( $wgTitle->getNamespace() == NS_CATEGORY ) { |
1104 | 1116 | $params = "cattitle=" . $wgTitle->getPartialURL(); |
— | — | @@ -1105,7 +1117,7 @@ |
1106 | 1118 | 'Collection', |
1107 | 1119 | 'add_category/' |
1108 | 1120 | ), $params ) ); |
1109 | | - print "<li><a href=\"$href\">$addCategory</a></li>"; |
| 1121 | + $out .= "<li><a href=\"$href\">$addCategory</a></li>"; |
1110 | 1122 | } |
1111 | 1123 | |
1112 | 1124 | $numArticles = self::countArticles(); |
— | — | @@ -1121,21 +1133,20 @@ |
1122 | 1134 | } |
1123 | 1135 | $showCollection = wfMsgHtml( 'coll-show_collection' ); |
1124 | 1136 | $showURL = htmlspecialchars( SkinTemplate::makeSpecialUrl( 'Collection') ); |
1125 | | - print <<<EOS |
| 1137 | + $out .= <<<EOS |
1126 | 1138 | <li><a href="$showURL">$showCollection<br /> |
1127 | 1139 | ($articles)</a></li> |
1128 | 1140 | EOS |
1129 | 1141 | ; |
1130 | 1142 | $helpCollections = wfMsgHtml( 'coll-help_collections' ); |
1131 | 1143 | $helpURL = htmlspecialchars( Title::makeTitle( NS_HELP, wfMsgForContent( 'coll-collections' ) )->getFullURL() ); |
1132 | | - print <<<EOS |
| 1144 | + $out .= <<<EOS |
1133 | 1145 | <li><a href="$helpURL">$helpCollections</a></li> |
1134 | 1146 | </ul> |
1135 | | - </div> |
1136 | | - </div> |
1137 | 1147 | <span id="tooBigCategoryText" style="display:none">$tooBigCat</span> |
1138 | 1148 | EOS |
1139 | 1149 | ; |
| 1150 | + return $out; |
1140 | 1151 | } |
1141 | 1152 | |
1142 | 1153 | static function pdfServerCommand( $command, $args, $timeout=true, $toFile=null ) { |