jenkins-bot has submitted this change and it was merged.

Change subject: Adding getter method for QuickTemplate
......................................................................


Adding getter method for QuickTemplate

Also updating a few functions to use it.

Change-Id: I466d36e48dec1f798f38152c829a25eb80f8b67b
---
M includes/SkinTemplate.php
1 file changed, 19 insertions(+), 4 deletions(-)

Approvals:
  MaxSem: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php
index 94978d4..a2ffb8e 100644
--- a/includes/SkinTemplate.php
+++ b/includes/SkinTemplate.php
@@ -1336,6 +1336,21 @@
        }
 
        /**
+        * Gets the template data requested
+        * @since 1.22
+        * @param string $name Key for the data
+        * @param mixed $default Optional default (or null)
+        * @return mixed The value of the data requested or the deafult
+        */
+       public function get( $name, $default = null ) {
+               if ( isset( $this->data[$name] ) ) {
+                       return $this->data[$name];
+               } else {
+                       return $default;
+               }
+       }
+
+       /**
         * @param $name
         * @param $value
         */
@@ -1537,7 +1552,7 @@
         */
        function getPersonalTools() {
                $personal_tools = array();
-               foreach ( $this->data['personal_urls'] as $key => $plink ) {
+               foreach ( $this->get( 'personal_urls' ) as $key => $plink ) {
                        # The class on a personal_urls item is meant to go on 
the <a> instead
                        # of the <li> so we have to use a single item "links" 
array instead
                        # of using most of the personal_url's keys directly.
@@ -1854,7 +1869,7 @@
                        'type' => 'search',
                        'name' => 'search',
                        'placeholder' => wfMessage( 'searchsuggest-search' 
)->text(),
-                       'value' => isset( $this->data['search'] ) ? 
$this->data['search'] : '',
+                       'value' => $this->get( 'search', '' ),
                );
                $realAttrs = array_merge( $realAttrs, 
Linker::tooltipAndAccesskeyAttribs( 'search' ), $attrs );
                return Html::element( 'input', $realAttrs );
@@ -1913,7 +1928,7 @@
         * @return array|mixed
         */
        function getFooterLinks( $option = null ) {
-               $footerlinks = $this->data['footerlinks'];
+               $footerlinks = $this->get( 'footerlinks' );
 
                // Reduce footer links down to only those which are being used
                $validFooterLinks = array();
@@ -1953,7 +1968,7 @@
         */
        function getFooterIcons( $option = null ) {
                // Generate additional footer icons
-               $footericons = $this->data['footericons'];
+               $footericons = $this->get( 'footericons' );
 
                if ( $option == 'icononly' ) {
                        // Unset any icons which don't have an image

-- 
To view, visit https://gerrit.wikimedia.org/r/73548
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I466d36e48dec1f798f38152c829a25eb80f8b67b
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Waldir <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to