X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderWikiModule.php;h=7b0d93a6c5481d6340a3f71503f933d63c212c54;hb=a85d1b9d0cd7f02111d3a647d5b91e3b1f334563;hp=52eb2d81be4ff61111e7627c2238aa3a944e9acb;hpb=cb2896f90ebef77c02c9da4067b0e56e37471092;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderWikiModule.php b/includes/resourceloader/ResourceLoaderWikiModule.php index 52eb2d81be..7b0d93a6c5 100644 --- a/includes/resourceloader/ResourceLoaderWikiModule.php +++ b/includes/resourceloader/ResourceLoaderWikiModule.php @@ -50,13 +50,13 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { protected $origin = self::ORIGIN_USER_SITEWIDE; // In-process cache for title info - protected $titleInfo = array(); + protected $titleInfo = []; // List of page names that contain CSS - protected $styles = array(); + protected $styles = []; // List of page names that contain JavaScript - protected $scripts = array(); + protected $scripts = []; // Group of module protected $group; @@ -99,18 +99,18 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { */ protected function getPages( ResourceLoaderContext $context ) { $config = $this->getConfig(); - $pages = array(); + $pages = []; // Filter out pages from origins not allowed by the current wiki configuration. if ( $config->get( 'UseSiteJs' ) ) { foreach ( $this->scripts as $script ) { - $pages[$script] = array( 'type' => 'script' ); + $pages[$script] = [ 'type' => 'script' ]; } } if ( $config->get( 'UseSiteCss' ) ) { foreach ( $this->styles as $style ) { - $pages[$style] = array( 'type' => 'style' ); + $pages[$style] = [ 'type' => 'style' ]; } } @@ -199,7 +199,7 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { * @return array */ public function getStyles( ResourceLoaderContext $context ) { - $styles = array(); + $styles = []; foreach ( $this->getPages( $context ) as $titleText => $options ) { if ( $options['type'] !== 'style' ) { continue; @@ -213,9 +213,9 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { $style = CSSJanus::transform( $style, true, false ); } $style = MemoizedCallable::call( 'CSSMin::remap', - array( $style, false, $this->getConfig()->get( 'ScriptPath' ), true ) ); + [ $style, false, $this->getConfig()->get( 'ScriptPath' ), true ] ); if ( !isset( $styles[$media] ) ) { - $styles[$media] = array(); + $styles[$media] = []; } $style = ResourceLoader::makeComment( $titleText ) . $style; $styles[$media][] = $style; @@ -243,11 +243,11 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { */ public function getDefinitionSummary( ResourceLoaderContext $context ) { $summary = parent::getDefinitionSummary( $context ); - $summary[] = array( + $summary[] = [ 'pages' => $this->getPages( $context ), // Includes SHA1 of content 'titleInfo' => $this->getTitleInfo( $context ), - ); + ]; return $summary; } @@ -284,34 +284,34 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { $dbr = $this->getDB(); if ( !$dbr ) { // We're dealing with a subclass that doesn't have a DB - return array(); + return []; } $pages = $this->getPages( $context ); $key = implode( '|', array_keys( $pages ) ); if ( !isset( $this->titleInfo[$key] ) ) { - $this->titleInfo[$key] = array(); + $this->titleInfo[$key] = []; $batch = new LinkBatch; foreach ( $pages as $titleText => $options ) { $batch->addObj( Title::newFromText( $titleText ) ); } if ( !$batch->isEmpty() ) { - $res = $dbr->select( array( 'page', 'revision' ), - array( 'page_namespace', 'page_title', 'rev_len', 'rev_sha1' ), + $res = $dbr->select( [ 'page', 'revision' ], + [ 'page_namespace', 'page_title', 'rev_len', 'rev_sha1' ], $batch->constructSet( 'page', $dbr ), __METHOD__, - array(), - array( 'revision' => array( 'INNER JOIN', array( 'page_latest=rev_id' ) ) ) + [], + [ 'revision' => [ 'INNER JOIN', [ 'page_latest=rev_id' ] ] ] ); foreach ( $res as $row ) { // Avoid including ids or timestamps of revision/page tables so // that versions are not wasted $title = Title::makeTitle( $row->page_namespace, $row->page_title ); - $this->titleInfo[$key][$title->getPrefixedText()] = array( + $this->titleInfo[$key][$title->getPrefixedText()] = [ 'rev_len' => $row->rev_len, 'rev_sha1' => $row->rev_sha1, - ); + ]; } } }