* Compact the titles, only serialize the text form.
*/
function __sleep() {
- foreach ( $this->internals as $ns => &$nsLinks ) {
- foreach ( $nsLinks as $key => &$entry ) {
+ foreach ( $this->internals as &$nsLinks ) {
+ foreach ( $nsLinks as &$entry ) {
unset( $entry['title'] );
}
}
unset( $nsLinks );
unset( $entry );
- foreach ( $this->interwikis as $key => &$entry ) {
+ foreach ( $this->interwikis as &$entry ) {
unset( $entry['title'] );
}
unset( $entry );
* Recreate the Title objects
*/
function __wakeup() {
- foreach ( $this->internals as $ns => &$nsLinks ) {
- foreach ( $nsLinks as $key => &$entry ) {
+ foreach ( $this->internals as &$nsLinks ) {
+ foreach ( $nsLinks as &$entry ) {
$entry['title'] = Title::newFromText( $entry['pdbk'] );
}
}
unset( $nsLinks );
unset( $entry );
- foreach ( $this->interwikis as $key => &$entry ) {
+ foreach ( $this->interwikis as &$entry ) {
$entry['title'] = Title::newFromText( $entry['pdbk'] );
}
unset( $entry );
* strings will be returned.
*
* @param $other LinkHolderArray
- * @param $text Array of strings
+ * @param $texts Array of strings
* @return Array
*/
function mergeForeign( $other, $texts ) {
*
* @param $nt Title
*/
- function makeHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
+ function makeHolder( $nt, $text = '', $query = array(), $trail = '', $prefix = '' ) {
wfProfileIn( __METHOD__ );
if ( ! is_object($nt) ) {
# Fail gracefully
'text' => $prefix.$text.$inside,
'pdbk' => $nt->getPrefixedDBkey(),
);
- if ( $query !== '' ) {
+ if ( $query !== array() ) {
$entry['query'] = $query;
}
}
/**
- * FIXME: update documentation. makeLinkObj() is deprecated.
+ * @todo FIXME: Update documentation. makeLinkObj() is deprecated.
* Replace <!--LINK--> link placeholders with actual links, in the buffer
* Placeholders created in Skin::makeLinkObj()
* Returns an array of link CSS classes, indexed by PDBK.
global $wgContLang;
$colours = array();
- $sk = $this->parent->getOptions()->getSkin( $this->parent->mTitle );
$linkCache = LinkCache::singleton();
$output = $this->parent->getOutput();
wfProfileIn( __METHOD__.'-check' );
$dbr = wfGetDB( DB_SLAVE );
- $page = $dbr->tableName( 'page' );
$threshold = $this->parent->getOptions()->getStubThreshold();
# Sort by namespace
$linkcolour_ids = array();
# Generate query
- $query = false;
- $current = null;
+ $queries = array();
foreach ( $this->internals as $ns => $entries ) {
foreach ( $entries as $entry ) {
$title = $entry['title'];
} elseif ( $ns == NS_SPECIAL ) {
$colours[$pdbk] = 'new';
} elseif ( ( $id = $linkCache->getGoodLinkID( $pdbk ) ) != 0 ) {
- $colours[$pdbk] = $sk->getLinkColour( $title, $threshold );
+ $colours[$pdbk] = Linker::getLinkColour( $title, $threshold );
$output->addLink( $title, $id );
$linkcolour_ids[$id] = $pdbk;
} elseif ( $linkCache->isBadLink( $pdbk ) ) {
$colours[$pdbk] = 'new';
} else {
# Not in the link cache, add it to the query
- if ( !isset( $current ) ) {
- $current = $ns;
- $query = "SELECT page_id, page_namespace, page_title, page_is_redirect, page_len, page_latest";
- $query .= " FROM $page WHERE (page_namespace=$ns AND page_title IN(";
- } elseif ( $current != $ns ) {
- $current = $ns;
- $query .= ")) OR (page_namespace=$ns AND page_title IN(";
- } else {
- $query .= ', ';
- }
-
- $query .= $dbr->addQuotes( $title->getDBkey() );
+ $queries[$ns][] = $title->getDBkey();
}
}
}
- if ( $query ) {
- $query .= '))';
+ if ( $queries ) {
+ $where = array();
+ foreach( $queries as $ns => $pages ){
+ $where[] = $dbr->makeList(
+ array(
+ 'page_namespace' => $ns,
+ 'page_title' => $pages,
+ ),
+ LIST_AND
+ );
+ }
- $res = $dbr->query( $query, __METHOD__ );
+ $res = $dbr->select(
+ 'page',
+ array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ),
+ $dbr->makeList( $where, LIST_OR ),
+ __METHOD__
+ );
# Fetch data and form into an associative array
# non-existent = broken
$pdbk = $title->getPrefixedDBkey();
$linkCache->addGoodLinkObj( $s->page_id, $title, $s->page_len, $s->page_is_redirect, $s->page_latest );
$output->addLink( $title, $s->page_id );
- # FIXME: convoluted data flow
+ # @todo FIXME: Convoluted data flow
# The redirect status and length is passed to getLinkColour via the LinkCache
# Use formal parameters instead
- $colours[$pdbk] = $sk->getLinkColour( $title, $threshold );
+ $colours[$pdbk] = Linker::getLinkColour( $title, $threshold );
//add id to the extension todolist
$linkcolour_ids[$s->page_id] = $pdbk;
}
foreach ( $entries as $index => $entry ) {
$pdbk = $entry['pdbk'];
$title = $entry['title'];
- $query = isset( $entry['query'] ) ? $entry['query'] : '';
+ $query = isset( $entry['query'] ) ? $entry['query'] : array();
$key = "$ns:$index";
$searchkey = "<!--LINK $key-->";
- if ( !isset( $colours[$pdbk] ) || $colours[$pdbk] == 'new' ) {
- $linkCache->addBadLinkObj( $title );
+ $displayText = $entry['text'];
+ if ( $displayText === '' ) {
+ $displayText = null;
+ }
+ if ( !isset( $colours[$pdbk] ) ) {
$colours[$pdbk] = 'new';
+ }
+ $attribs = array();
+ if ( $colours[$pdbk] == 'new' ) {
+ $linkCache->addBadLinkObj( $title );
$output->addLink( $title, 0 );
- // FIXME: replace deprecated makeBrokenLinkObj() by link()
- $replacePairs[$searchkey] = $sk->makeBrokenLinkObj( $title,
- $entry['text'],
- $query );
+ $type = array( 'broken' );
} else {
- // FIXME: replace deprecated makeColouredLinkObj() by link()
- $replacePairs[$searchkey] = $sk->makeColouredLinkObj( $title, $colours[$pdbk],
- $entry['text'],
- $query );
+ if ( $colours[$pdbk] != '' ) {
+ $attribs['class'] = $colours[$pdbk];
+ }
+ $type = array( 'known', 'noclasses' );
}
+ $replacePairs[$searchkey] = Linker::link( $title, $displayText,
+ $attribs, $query, $type );
}
}
$replacer = new HashtableReplacer( $replacePairs, 1 );
wfProfileIn( __METHOD__ );
# Make interwiki link HTML
- $sk = $this->parent->getOptions()->getSkin( $this->parent->mTitle );
$output = $this->parent->getOutput();
$replacePairs = array();
foreach( $this->interwikis as $key => $link ) {
- $replacePairs[$key] = $sk->link( $link['title'], $link['text'] );
+ $replacePairs[$key] = Linker::link( $link['title'], $link['text'] );
$output->addInterwikiLink( $link['title'] );
}
$replacer = new HashtableReplacer( $replacePairs, 1 );
$variantMap = array(); // maps $pdbkey_Variant => $keys (of link holders)
$output = $this->parent->getOutput();
$linkCache = LinkCache::singleton();
- $sk = $this->parent->getOptions()->getSkin( $this->parent->mTitle );
$threshold = $this->parent->getOptions()->getStubThreshold();
$titlesToBeConverted = '';
$titlesAttrs = array();
for ( $i = 0; $i < $l; $i ++ ) {
foreach ( $allVariantsName as $variantName ) {
$textVariant = $titlesAllVariants[$variantName][$i];
- extract( $titlesAttrs[$i] );
- if($textVariant != $titleText){
- $variantTitle = Title::makeTitle( $ns, $textVariant );
+ if ( $textVariant != $titlesAttrs[$i]['titleText'] ) {
+ $variantTitle = Title::makeTitle( $titlesAttrs[$i]['ns'], $textVariant );
if( is_null( $variantTitle ) ) {
continue;
}
$linkBatch->addObj( $variantTitle );
- $variantMap[$variantTitle->getPrefixedDBkey()][] = $key;
+ $variantMap[$variantTitle->getPrefixedDBkey()][] = $titlesAttrs[$i]['key'];
}
}
}
$entry['pdbk'] = $varPdbk;
// set pdbk and colour
- # FIXME: convoluted data flow
+ # @todo FIXME: Convoluted data flow
# The redirect status and length is passed to getLinkColour via the LinkCache
# Use formal parameters instead
- $colours[$varPdbk] = $sk->getLinkColour( $variantTitle, $threshold );
+ $colours[$varPdbk] = Linker::getLinkColour( $variantTitle, $threshold );
$linkcolour_ids[$s->page_id] = $pdbk;
}
}