r26515 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26514‎ | r26515 | r26516 >
Date:21:58, 8 October 2007
Author:david
Status:old
Tags:
Comment:
Removed known-link hacks from Title. Replaced with hook from Linker::makeLinkObj. Empty talk pages now have red links. Hopefully this is not too expensive.
Modified paths:
  • /branches/liquidthreads/extensions/LqtBaseView.php (modified) (history)
  • /branches/liquidthreads/includes/Linker.php (modified) (history)
  • /branches/liquidthreads/includes/Title.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtBaseView.php
@@ -46,6 +46,7 @@
4747
4848 $wgHooks['MediaWikiPerformAction'][] = array('LqtDispatch::tryPage');
4949 $wgHooks['SpecialMovepageAfterMove'][] = array('LqtDispatch::onPageMove');
 50+$wgHooks['LinkerMakeLinkObj'][] = array('LqtDispatch::makeLinkObj');
5051
5152 class LqtDispatch {
5253 public static $views = array(
@@ -144,6 +145,36 @@
145146
146147 return true;
147148 }
 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+ }
148179 }
149180
150181
Index: branches/liquidthreads/includes/Linker.php
@@ -234,6 +234,13 @@
235235 wfProfileOut( __METHOD__ );
236236 return $retVal;
237237 }
 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+ }
238245
239246 # Work out link colour immediately
240247 $aid = $nt->getArticleID() ;
Index: branches/liquidthreads/includes/Title.php
@@ -1611,7 +1611,6 @@
16121612 * @return array the array of groups allowed to edit this article
16131613 */
16141614 public function getRestrictions( $action ) {
1615 - // LQT HACK.
16161615 $result = array();
16171616 if( !wfRunHooks('TitleGetRestrictions', array($this, $action, &$result)) )
16181617 return $result;
@@ -2592,11 +2591,11 @@
25932592 }
25942593
25952594 /**
2596 - * Check if page exists LQT HACK
 2595+ * Check if page exists
25972596 * @return bool
25982597 */
25992598 public function exists() {
2600 - return $this->getArticleId() != 0 || $this->isTalkPage();
 2599+ return $this->getArticleId() != 0;
26012600 }
26022601
26032602 /**
@@ -2604,13 +2603,9 @@
26052604 * consider that it exists?
26062605 *
26072606 * @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?
26122607 */
26132608 public function isAlwaysKnown() {
2614 - return $this->isExternal() || $this->isTalkPage()
 2609+ return $this->isExternal()
26152610 || ( $this->mNamespace == NS_MAIN && $this->mDbkeyform == '' )
26162611 || ( $this->mNamespace == NS_MEDIAWIKI && wfMsgWeirdKey( $this->mDbkeyform ) );
26172612 }

Status & tagging log