array( 'redirect' => 'no' )
);
$links = array();
- $links[] = Linker::linkKnown(
- $fromObj,
- $this->msg( 'brokenredirects-edit' )->escaped(),
- array(),
- array( 'action' => 'edit' )
- );
+ // if the page is editable, add an edit link
+ if (
+ // check user permissions
+ $this->getUser()->isAllowed( 'edit' ) &&
+ // check, if the content model is editable through action=edit
+ ContentHandler::getForTitle( $fromObj )->supportsDirectEditing()
+ ) {
+ $links[] = Linker::linkKnown(
+ $fromObj,
+ $this->msg( 'brokenredirects-edit' )->escaped(),
+ array(),
+ array( 'action' => 'edit' )
+ );
+ }
$to = Linker::link(
$toObj,
null,
);
}
- $out .= $this->msg( 'parentheses' )->rawParams( $this->getLanguage()
- ->pipeList( $links ) )->escaped();
+ if ( $links ) {
+ $out .= $this->msg( 'parentheses' )->rawParams( $this->getLanguage()
+ ->pipeList( $links ) )->escaped();
+ }
$out .= " {$arr} {$to}";
return $out;
}
+
+ /**
+ * Cache page content model for performance
+ *
+ * @param IDatabase $db
+ * @param ResultWrapper $res
+ */
+ function preprocessResults( $db, $res ) {
+ if ( !$res->numRows() ) {
+ return;
+ }
+
+ $batch = new LinkBatch;
+ foreach ( $res as $row ) {
+ $batch->add( $row->namespace, $row->title );
+ }
+ $batch->execute();
+
+ // Back to start for display
+ $res->seek( 0 );
+ }
+
protected function getGroupName() {
return 'maintenance';
}
array( 'redirect' => 'no' )
);
- $edit = Linker::linkKnown(
- $titleA,
- $this->msg( 'parentheses', $this->msg( 'editlink' )->text() )->escaped(),
- array(),
- array(
- 'action' => 'edit'
- )
- );
+ // if the page is editable, add an edit link
+ if (
+ // check user permissions
+ $this->getUser()->isAllowed( 'edit' ) &&
+ // check, if the content model is editable through action=edit
+ ContentHandler::getForTitle( $titleA )->supportsDirectEditing()
+ ) {
+ $edit = Linker::linkKnown(
+ $titleA,
+ $this->msg( 'parentheses', $this->msg( 'editlink' )->text() )->escaped(),
+ array(),
+ array(
+ 'action' => 'edit'
+ )
+ );
+ } else {
+ $edit = '';
+ }
$linkB = Linker::linkKnown(
$titleB,
return ( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );
}
+ /**
+ * Cache page content model and gender distinction for performance
+ *
+ * @param IDatabase $db
+ * @param ResultWrapper $res
+ */
+ function preprocessResults( $db, $res ) {
+ if ( !$res->numRows() ) {
+ return;
+ }
+
+ $batch = new LinkBatch;
+ foreach ( $res as $row ) {
+ $batch->add( $row->namespace, $row->title );
+ if ( isset( $row->nsb ) ) {
+ // lazy loaded when using cached results
+ $batch->add( $row->nsb, $row->tb );
+ }
+ if ( isset( $row->iwc ) && !$row->iwc ) {
+ // lazy loaded when using cached result, not added when interwiki link
+ $batch->add( $row->nsc, $row->tc );
+ }
+ }
+ $batch->execute();
+
+ // Back to start for display
+ $res->seek( 0 );
+ }
+
protected function getGroupName() {
return 'maintenance';
}