r67955 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67954‎ | r67955 | r67956 >
Date:16:14, 13 June 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.6.3 - changes to allow issue fix in SM
Modified paths:
  • /trunk/extensions/Maps/Services/Maps_MappingService.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/Services/Maps_MappingService.php
@@ -45,6 +45,8 @@
4646 */
4747 private $mAddedDependencies = array();
4848
 49+ private $mDependencies = array();
 50+
4951 /**
5052 * Constructor. Creates a new instance of MapsMappingService.
5153 *
@@ -95,7 +97,26 @@
9698 * @param mixed $parserOrOut
9799 */
98100 public final function addDependencies( &$parserOrOut ) {
99 - $allDependencies = $this->getDependencies();
 101+ $dependencies = $this->getDependencyHtml();
 102+
 103+ // Only aff a head item when there are dependencies.
 104+ if ( $dependencies ) {
 105+ if ( $parserOrOut instanceof Parser ) {
 106+ $parserOrOut->getOutput()->addHeadItem( $dependencies );
 107+ }
 108+ else if ( $parserOrOut instanceof OutputPage ) {
 109+ $parserOrOut->addHeadItem( md5( $dependencies ), $dependencies );
 110+ }
 111+ }
 112+ }
 113+
 114+ /**
 115+ * Returns the html for the needed dependencies or false.
 116+ *
 117+ * @return mixed Steing or false
 118+ */
 119+ public final function getDependencyHtml() {
 120+ $allDependencies = array_merge( $this->getDependencies(), $this->mDependencies );
100121 $dependencies = array();
101122
102123 // Only add dependnecies that have not yet been added.
@@ -106,20 +127,21 @@
107128 }
108129 }
109130
110 - // If there are dependencies, put them all together in a string and add them to the header.
111 - if ( count( $dependencies ) > 0 ) {
112 - $dependencies = implode( '', $dependencies );
113 -
114 - if ( $parserOrOut instanceof Parser ) {
115 - $parserOrOut->getOutput()->addHeadItem( $dependencies );
116 - }
117 - else if ( $parserOrOut instanceof OutputPage ) {
118 - $parserOrOut->addHeadItem( md5($dependencies), $dependencies );
119 - }
120 - }
 131+ // If there are dependencies, put them all together in a string, otherwise return false.
 132+ return count( $dependencies ) > 0 ? implode( '', $dependencies ) : false;
121133 }
122134
123135 /**
 136+ * Adds a dependency that is needed for this service. It will be passed along with the next
 137+ * call to getDependencyHtml or addDependencies.
 138+ *
 139+ * @param string $dependencyHtml
 140+ */
 141+ public final function addDependency( $dependencyHtml ) {
 142+ $this->mDependencies[] = $dependencyHtml;
 143+ }
 144+
 145+ /**
124146 * Returns a list of html fragments, such as script includes, the current service depends on.
125147 *
126148 * @return array

Status & tagging log