Ejemplo n.º 1
0
/**
 * 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;
}
/**
 * Rewrites the given URL so that it looks like a URL that can be loaded directly.
 * Useful for users who don't handle javascript / ajax, they can still use piwik with these rewritten URLs.
 * 
 * @return string
 */
function smarty_modifier_urlRewriteBasicView($parameters)
{
    // replace module=X by moduleToLoad=X
    // replace action=Y by actionToLoad=Y
    /*
    	$parameters['moduleToLoad'] = $parameters['module'];
    	unset($parameters['module']);
    
    	if(isset( $parameters['action']))
    	{
    		$parameters['actionToLoad'] = $parameters['action'];
    		unset($parameters['action']);
    	}
    	else
    	{
    		$parameters['actionToLoad'] = null;
    	}
    */
    $url = Core_Url::getCurrentQueryStringWithParametersModified($parameters);
    // add module=CoreHome&action=showInContext
    //$url = $url . '&amp;module=CoreHome&amp;action=showInContext';
    return htmlspecialchars($url);
}
Ejemplo n.º 3
0
 /**
  * Redirect to module (and action)
  *
  * @param string $newModule
  * @param string $newAction
  * @return bool false if the URL to redirect to is already this URL
  */
 public static function redirectToModule($newModule, $newAction = '')
 {
     $currentModule = self::getModule();
     $currentAction = self::getAction();
     if ($currentModule != $newModule || $currentAction != $newAction) {
         $newUrl = 'index.php' . Core_Url::getCurrentQueryStringWithParametersModified(array('module' => $newModule, 'action' => $newAction));
         Core_Url::redirectToUrl($newUrl);
     }
     return false;
 }
/**
 * Rewrites the given URL and modify the given parameters.
 * @see Core_Url::getCurrentQueryStringWithParametersModified()
 * 
 * @return string
 */
function smarty_modifier_urlRewriteWithParameters($parameters)
{
    $url = Core_Url::getCurrentQueryStringWithParametersModified($parameters);
    return htmlspecialchars($url);
}
Ejemplo n.º 5
0
/**
 * Smarty {url} function plugin.
 * Generates a piwik URL with the specified parameters modified.
 *
 * Examples:
 * <pre>
 * {url module="API"} will rewrite the URL modifying the module GET parameter
 * {url module="API" method="getKeywords"} will rewrite the URL modifying the parameters module=API method=getKeywords
 * </pre>
 * 
 * @see Core_Url::getCurrentQueryStringWithParametersModified()
 * @param $name=$value of the parameters to modify in the generated URL
 * @return	string Something like index.php?module=X&action=Y 
 */
function smarty_function_url($params, &$smarty)
{
    return htmlspecialchars('index.php' . Core_Url::getCurrentQueryStringWithParametersModified($params));
}