return $this->mMethod;
}
+ /**
+ * Wraps the given $section into an user-visible fieldset.
+ *
+ * @param string $legend Legend text for the fieldset
+ * @param string $section The section content in plain Html
+ * @param array $attributes Additional attributes for the fieldset
+ * @return string The fieldset's Html
+ */
+ protected function wrapFieldSetSection( $legend, $section, $attributes ) {
+ return Xml::fieldset( $legend, $section, $attributes ) . "\n";
+ }
+
/**
* @todo Document
*
if ( $fieldsetIDPrefix ) {
$attributes['id'] = Sanitizer::escapeId( "$fieldsetIDPrefix$key" );
}
- $subsectionHtml .= Xml::fieldset( $legend, $section, $attributes ) . "\n";
+ $subsectionHtml .= $this->wrapFieldSetSection( $legend, $section, $attributes );
} else {
// Just return the inputs, nothing fancy.
$subsectionHtml .= $section;
return $html;
}
+ protected function wrapFieldSetSection( $legend, $section, $attributes ) {
+ // to get a user visible effect, wrap the fieldset into a framed panel layout
+ $layout = new OOUI\PanelLayout( array(
+ 'expanded' => false,
+ 'padded' => true,
+ 'framed' => true,
+ 'infusable' => false,
+ ) );
+
+ $layout->appendContent(
+ new OOUI\FieldsetLayout( array(
+ 'label' => $legend,
+ 'infusable' => false,
+ 'items' => array(
+ new OOUI\Widget( array(
+ 'content' => new OOUI\HtmlSnippet( $section )
+ ) ),
+ ),
+ ) + $attributes )
+ );
+ return $layout;
+ }
+
/**
* Put a form section together from the individual fields' HTML, merging it and wrapping.
* @param OOUI\\FieldLayout[] $fieldsHtml
* @return mixed
*/
private function getCachedConfigVar( $name ) {
- global $wgConf;
-
+ // @TODO: cleanup this whole method with a proper config system
if ( $this->wiki === wfWikiID() ) {
return $GLOBALS[$name]; // common case
} else {
- $cache = ObjectCache::getLocalClusterInstance();
- list( $db, $prefix ) = wfSplitWikiID( $this->wiki );
- $key = wfForeignMemcKey( $db, $prefix, 'configvalue', $name );
- $value = $cache->get( $key ); // ('v' => ...) or false
- if ( is_array( $value ) ) {
- return $value['v'];
- } else {
- $value = $wgConf->getConfig( $this->wiki, $name );
- $cache->set(
- $key,
- array( 'v' => $value ),
- $cache::TTL_DAY + mt_rand( 0, $cache::TTL_DAY )
- );
-
- return $value;
- }
+ $wiki = $this->wiki;
+ $cache = ObjectCache::getMainWANInstance();
+ $value = $cache->getWithSetCallback(
+ $cache->makeGlobalKey( 'jobqueue', 'configvalue', $wiki, $name ),
+ $cache::TTL_DAY + mt_rand( 0, $cache::TTL_DAY ),
+ function () use ( $wiki, $name ) {
+ global $wgConf;
+
+ return array( 'v' => $wgConf->getConfig( $wiki, $name ) );
+ },
+ array( 'pcTTL' => 30 )
+ );
+
+ return $value['v'];
}
}
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';
}