Refactor printActionUrl as getActionUrl
authorJehan-Guillaume (ioguix) de Rorthais <ioguix@free.fr>
Mon, 5 Dec 2011 21:46:48 +0000 (22:46 +0100)
committerJehan-Guillaume (ioguix) de Rorthais <ioguix@free.fr>
Wed, 22 Aug 2012 10:23:50 +0000 (12:23 +0200)
remove useless parameters and make it simpler. Takes part in the pavement
for WIP plugin architecture.

classes/Misc.php

index d8e947908e13ff12f5267db532c8d94ec11adc56..46e0b88d59e0666593745f806046ab99a58c787c 100644 (file)
 
                                if (!isset($tab['hide']) || $tab['hide'] !== true) {
 
-                                       $tablink = "<a" . $this->printActionUrl($tab, $_REQUEST, 'href') . ">";
+                                       $tablink = '<a href="' . htmlentities($this->getActionUrl($tab, $_REQUEST)) . '">';
 
                                        if (isset($tab['icon']) && $icon = $this->icon($tab['icon']))
                                                $tablink .= "<span class=\"icon\"><img src=\"{$icon}\" alt=\"{$tab['title']}\" /></span>";
                }
 
                /**
-                * Display a URL given an action associative array.
+                * Returns URL given an action associative array.
+                * NOTE: this function does not html-escape, only url-escape
                 * @param $action An associative array of the follow properties:
                 *                      'url'  => The first part of the URL (before the ?)
                 *                      'urlvars' => Associative array of (URL variable => field name)
                 *                                              these are appended to the URL
-                *                      'urlfn' => Function to apply to URL before display
                 * @param $fields Field data from which 'urlfield' and 'vars' are obtained.
-                * @param $attr If supplied then the URL will be quoted and prefixed with
-                *                              '$attr='.
                 */
-               function printActionUrl(&$action, &$fields, $attr = null) {
+               function getActionUrl(&$action, &$fields) {
                        $url = value($action['url'], $fields);
 
                        if ($url === false) return '';
                                $sep = '&';
                        }
 
-                       $url = htmlentities($url, ENT_QUOTES, 'UTF-8');
-
-                       if ($attr !== null && $url != '')
-                               return ' '.$attr.'="'.$url.'"';
-                       else
-                               return $url;
+                       return $url;
                }
 
                function getRequestVars($subject = '') {