Index: branches/liquidthreads/extensions/LqtBaseView.php |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | |
48 | 48 | $wgHooks['MediaWikiPerformAction'][] = array('LqtDispatch::tryPage'); |
49 | 49 | $wgHooks['SpecialMovepageAfterMove'][] = array('LqtDispatch::onPageMove'); |
| 50 | +$wgHooks['LinkerMakeLinkObj'][] = array('LqtDispatch::makeLinkObj'); |
50 | 51 | |
51 | 52 | class LqtDispatch { |
52 | 53 | public static $views = array( |
— | — | @@ -144,6 +145,36 @@ |
145 | 146 | |
146 | 147 | return true; |
147 | 148 | } |
| 149 | + |
| 150 | + static function makeLinkObj( &$returnValue, &$linker, $nt, $text, $query, $trail, $prefix ) { |
| 151 | +// var_dump(array($nt, $text,$query,$trail, $prefix)); |
| 152 | + |
| 153 | + if( ! $nt->isTalkPage() ) |
| 154 | + return true; |
| 155 | + |
| 156 | + // Talkpages with headers. |
| 157 | + if( $nt->getArticleID() != 0 ) |
| 158 | + return true; |
| 159 | + |
| 160 | + // Talkpages without headers -- check existance of threads. |
| 161 | + $article = new Article($nt->getSubjectPage()); |
| 162 | + $threads = Threads::where(Threads::articleClause($article), "LIMIT 1"); |
| 163 | + if( count($threads) == 0 ) {
|
| 164 | + // We want it to look like a broken link, but not have action=edit, since that |
| 165 | + // will edit the header, so we can't use makeBrokenLinkObj. This code is copied |
| 166 | + // from the body of that method. |
| 167 | + $url = $nt->escapeLocalURL( $query ); |
| 168 | + if ( '' == $text ) |
| 169 | + $text = htmlspecialchars( $nt->getPrefixedText() ); |
| 170 | + $style = $linker->getInternalLinkAttributesObj( $nt, $text, "yes" ); |
| 171 | + list( $inside, $trail ) = Linker::splitTrail( $trail ); |
| 172 | + $returnValue = "<a href=\"{$url}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}"; |
| 173 | + } |
| 174 | + else { |
| 175 | + $returnValue = $linker->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); |
| 176 | + } |
| 177 | + return false; |
| 178 | + } |
148 | 179 | } |
149 | 180 | |
150 | 181 | |
Index: branches/liquidthreads/includes/Linker.php |
— | — | @@ -234,6 +234,13 @@ |
235 | 235 | wfProfileOut( __METHOD__ ); |
236 | 236 | return $retVal; |
237 | 237 | } |
| 238 | + |
| 239 | + $hookRetVal = ""; |
| 240 | + if( ! wfRunHooks('LinkerMakeLinkObj', array(&$hookRetVal, &$this, $nt, $text, $query, $trail, $prefix)) ) { |
| 241 | + wfProfileOut( __METHOD__.'-immediate' ); |
| 242 | + wfProfileOut( __METHOD__ ); |
| 243 | + return $hookRetVal; |
| 244 | + } |
238 | 245 | |
239 | 246 | # Work out link colour immediately |
240 | 247 | $aid = $nt->getArticleID() ; |
Index: branches/liquidthreads/includes/Title.php |
— | — | @@ -1611,7 +1611,6 @@ |
1612 | 1612 | * @return array the array of groups allowed to edit this article |
1613 | 1613 | */ |
1614 | 1614 | public function getRestrictions( $action ) { |
1615 | | - // LQT HACK. |
1616 | 1615 | $result = array(); |
1617 | 1616 | if( !wfRunHooks('TitleGetRestrictions', array($this, $action, &$result)) ) |
1618 | 1617 | return $result; |
— | — | @@ -2592,11 +2591,11 @@ |
2593 | 2592 | } |
2594 | 2593 | |
2595 | 2594 | /** |
2596 | | - * Check if page exists LQT HACK |
| 2595 | + * Check if page exists |
2597 | 2596 | * @return bool |
2598 | 2597 | */ |
2599 | 2598 | public function exists() { |
2600 | | - return $this->getArticleId() != 0 || $this->isTalkPage(); |
| 2599 | + return $this->getArticleId() != 0; |
2601 | 2600 | } |
2602 | 2601 | |
2603 | 2602 | /** |
— | — | @@ -2604,13 +2603,9 @@ |
2605 | 2604 | * consider that it exists? |
2606 | 2605 | * |
2607 | 2606 | * @return bool |
2608 | | - * |
2609 | | - * LQT HACK: Talk pages are also always known. |
2610 | | - * Should talk pages for non-existant articles be known? |
2611 | | - * Talk pages with no threads? With only archived threads? |
2612 | 2607 | */ |
2613 | 2608 | public function isAlwaysKnown() { |
2614 | | - return $this->isExternal() || $this->isTalkPage() |
| 2609 | + return $this->isExternal() |
2615 | 2610 | || ( $this->mNamespace == NS_MAIN && $this->mDbkeyform == '' ) |
2616 | 2611 | || ( $this->mNamespace == NS_MEDIAWIKI && wfMsgWeirdKey( $this->mDbkeyform ) ); |
2617 | 2612 | } |