/** * Smarty {hiddenurl} function plugin. * Writes an input Hidden field for every parameter in the URL. * Useful when using GET forms because we need to print the current parameters * in hidden input so they are to the next URL after the form is submitted. * * * Examples: * <pre> * {hiddenurl module="API"} with a URL 'index.php?action=test&module=CoreHome' will output * <input type=hidden name=action value=test> * <input type=hidden name=module value=API> * </pre> * * Set a value to null if you want this value not to be passed in the submitted form. * * @param array * @param Smarty * @return string */ function smarty_function_hiddenurl($params, &$smarty) { $queryStringModified = Core_Url::getCurrentQueryStringWithParametersModified($params); $urlValues = Core_Common::getArrayFromQueryString($queryStringModified); $out = ''; foreach ($urlValues as $name => $value) { $out .= '<input type="hidden" name="' . $name . '" value="' . $value . '" />'; } return $out; }
/** * If current URL is "http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2" * will return * array * 'param1' => string 'value1' * 'param2' => string 'value2' * * @return array */ static function getArrayFromCurrentQueryString() { $queryString = self::getCurrentQueryString(); $urlValues = Core_Common::getArrayFromQueryString($queryString); return $urlValues; }