/**
 * 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;
}
Example #2
0
 function __construct($id, $method = 'post', $attributes = null, $trackSubmit = false)
 {
     if (!isset($attributes['action'])) {
         $attributes['action'] = Core_Url::getCurrentQueryString();
     }
     if (!isset($attributes['name'])) {
         $attributes['name'] = $id;
     }
     parent::__construct($id, $method, $attributes, $trackSubmit);
     $this->init();
 }
/**
 * 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);
}
Example #4
0
 /**
  * Returns true if this appears to be a secure HTTPS connection
  *
  * @return bool
  */
 public static function isHttps()
 {
     return Core_Url::getCurrentScheme() === 'https' || Zend_Registry::get('config')->General->assume_secure_protocol;
 }
Example #5
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;
 }
Example #6
0
 public function render()
 {
     try {
         $this->currentModule = Core_Helper::getModule();
         //$this->userLogin = Core_Helper::getCurrentUserLogin();
         $this->url = Core_Url::getCurrentUrl();
         //$this->token_auth = Core_Core::getCurrentUserTokenAuth();
         //$this->userHasSomeAdminAccess = Core_Core::isUserHasSomeAdminAccess();
         //$this->userIsSuperUser = Core_Core::isUserIsSuperUser();
         //$this->Core_version = Core_Version::VERSION;
         //$this->latest_version_available = UpdateCheck::isNewestVersionAvailable();
         //$this->loginModule = Zend_Registry::get('auth')->getName();
         // global value accessible to all templates: the
         // Core base URL for the current request
         $this->Core_Url = Core_Url::getCurrentUrlWithoutFileName();
         /* The navigation menu */
         $this->Core_NavigationMenu = Core_Navigator::getInstance()->getMenu();
         $this->InternetIsConnected = Zend_Registry::get('config')->General->internet_is_connected == 1;
         $this->MapData = Zend_Registry::get('config')->General->map_data;
     } catch (Exception $e) {
         // can fail, for example at installation (no plugin loaded yet)
     }
     //$this->totalTimeGeneration = Zend_Registry::get('timer')->getTime();
     /*
     		try {
     			$this->totalNumberOfQueries = Core_Common::getQueryCount();
     		}
     		catch(Exception $e){
     			$this->totalNumberOfQueries = 0;
     		}*/
     @header('Content-Type: text/html; charset=utf-8');
     @header("Pragma: ");
     @header("Cache-Control: no-store, must-revalidate");
     return $this->smarty->fetch($this->template);
 }
/**
 * 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);
}
Example #8
0
 /**
  * Check force_ssl_login and redirect if connection isn't secure and not    using a reverse proxy
  *
  * @param none
  * @return void
  */
 protected function checkForceSslLogin()
 {
     $forceSslLogin = Zend_Registry::get('config')->General->force_ssl_login;
     if ($forceSslLogin) {
         $reverseProxy = Zend_Registry::get('config')->General->reverse_proxy;
         if (!(Core_Url::getCurrentScheme() == 'https' || $reverseProxy)) {
             $url = 'https://' . Core_Url::getCurrentHost() . Core_Url::getCurrentScriptName() . Core_Url::getCurrentQueryString();
             Core_Url::redirectToUrl($url);
         }
     }
 }
Example #9
0
/**
 * @param       $address
 * @param null  $code
 * @param array $options
 * @return mixed
 */
function r($address, $code = null, array $options = array())
{
    return Core_Url::getInstance()->redirect($address, $code, $options);
}
Example #10
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));
}