Esempio n. 1
0
 /**
  * Convenience method to generate an API Url
  *
  * @param string|array $url
  * @param bool $full
  * @return string
  */
 public function apiUrl($url = null, $full = false)
 {
     if (is_array($url)) {
         $url = Hash::merge(array('admin' => false, 'api' => Configure::read('Croogo.Api.path'), 'prefix' => 'v1.0', 'ext' => 'json'), $url);
     }
     return parent::url($url, $full);
 }
Esempio n. 2
0
 public function url($url = null, $full = false)
 {
     if (is_array($url) && !array_key_exists('lang', $url)) {
         $url['lang'] = Configure::read('Config.language');
     }
     return parent::url($url, $full);
 }
 /**
  * Url helper function
  *
  * @param string $url 
  * @param bool $full 
  * @return mixed
  * @access public
  */
 public function url($url = null, $full = false)
 {
     if (!isset($url['locale']) && isset($this->params['locale'])) {
         $url['locale'] = $this->params['locale'];
     }
     return parent::url($url, $full);
 }
Esempio n. 4
0
 function url($url = null, $full = false)
 {
     if (isset($this->params['admin']) && is_array($url) && !isset($url['admin'])) {
         $url['admin'] = false;
     }
     return parent::url($url, $full);
 }
Esempio n. 5
0
 public function url($url = null, $full = false)
 {
     if (empty($this->params['admin']) && is_array($url) && empty($url['admin']) && !array_key_exists('lang', $url)) {
         $url['lang'] = $this->request['lang'];
     }
     return parent::url($url, $full);
 }
Esempio n. 6
0
 public function url($url, $full = false)
 {
     if (is_string($url) && preg_match(sprintf('/^%s.+/', preg_quote('//', '/')), $url)) {
         return h($url);
     }
     return parent::url($url, $full);
 }
Esempio n. 7
0
 /**
  * Url helper function
  *
  * @param string $url
  * @param bool $full
  * @return mixed
  * @access public
  */
 public function url($url = null, $full = false)
 {
     if (isset($this->request->params['locale'])) {
         if ($url === null || is_array($url) && !isset($url['locale'])) {
             $url['locale'] = $this->request->params['locale'];
         }
     }
     return parent::url($url, $full);
 }
Esempio n. 8
0
 /**
  * Return link the pagination.
  * - Force return of the first page.
  *
  * @param array $options 	Opções da paginação
  * @param bool $asArray 	Retorna a url como array ou como string
  * @param string $model 	Model para paginação
  * @return mixed By default, returns a full pagination URL string for use in non-standard contexts (i.e. JavaScript)
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::url
  */
 public function url($options = array(), $asArray = false, $model = null)
 {
     if (is_array($options)) {
         if (!isset($options['page'])) {
             $options['page'] = 1;
         }
     }
     return parent::url($options, $asArray, $model);
 }
Esempio n. 9
0
 /**
  * Url helper function
  *
  *  - Localize URL.
  *
  * @param string $url
  * @param bool $full
  * @return mixed
  * @access public
  */
 public function url($url = null, $full = false)
 {
     if (CakePlugin::loaded('I18n')) {
         $url = Common::url($url);
         if (is_array($url) && !array_key_exists('lang', $url)) {
             $url['lang'] = Configure::read('Config.language');
         }
     }
     return parent::url($url, $full);
 }
 /** 
  * Overrides the default url method in order to clear any/all prefixes
  * that aren't explicitly requested. This will prevent a subsequent request
  * (e.g. redirect or link on a prefixed page) from inheriting the current
  * prefix.
  * 
  * @access  public
  * @see     Helper::url()
  */
 function url($url = null, $full = false)
 {
     if (isset($this->params['prefix'])) {
         $prefix = $this->params['prefix'];
         if ($this->params[$prefix] && (!isset($url[$prefix]) || empty($url[$prefix]))) {
             $url[$prefix] = false;
         }
     }
     return parent::url($url, $full);
 }
Esempio n. 11
0
 public function getDelete($id)
 {
     DB::beginTransaction();
     try {
         $model = $this->model->find($id);
         $model->delete();
         DB::commit();
         return redirect(\Helper::url('index'))->withMessage('Data has been deleted');
     } catch (\Exception $e) {
         DB::rollback();
         return redirect(\Helper::url('index'))->withMessage('Data cannot be deleted');
     }
 }
Esempio n. 12
0
 function url($url = null, $full = false)
 {
     $keyUrl = $url;
     if (is_array($keyUrl)) {
         $keyUrl += $this->_extras;
     }
     $key = md5(serialize($keyUrl));
     if (!empty($this->_cache[$key])) {
         return $this->_cache[$key];
     }
     $url = parent::url($url, $full);
     $this->_cache[$key] = $url;
     return $url;
 }
Esempio n. 13
0
 /**
  * url function
  *
  * @param mixed $url
  * @param bool $full
  * @access public
  * @return void
  */
 function url($url = null, $full = false)
 {
     if (!is_array($url)) {
         return parent::url($url, $full);
     }
     $defaults = array('controller' => $this->params['controller'], 'action' => $this->params['action'], 'admin' => !empty($this->params['admin']), 'lang' => $this->params['lang'], 'theme' => $this->params['theme']);
     $url = am($defaults, $url);
     if (isset($url[0])) {
         $id = Configure::read('Site.homeNode');
         if (empty($url['admin']) && $url['controller'] === 'nodes' && $url['action'] === 'view' && $url[0] == $id) {
             $url = array('action' => 'index', 'lang' => $this->params['lang'], 'theme' => $this->params['theme']);
         }
     }
     return parent::url($url, $full);
 }
 function url($url = null, $full = false)
 {
     $keyUrl = $url;
     if (is_array($keyUrl)) {
         $keyUrl += $this->_extras;
     }
     $key = md5(serialize($keyUrl) . $full);
     $key += md5_file(CONFIGS . DS . 'routes.php');
     if (!empty($this->_cache[$key])) {
         return $this->_cache[$key];
     }
     $url = parent::url($url, $full);
     $this->_cache[$key] = $url;
     return $url;
 }
 /**
  * Intercepts the parent URL function to first look if the cache was already generated for the same params
  *
  * @param mixed $url URL to generate using CakePHP array syntax
  * @param boolean $full whether to generate a full url or not (http scheme)
  * @return string
  * @see Helper::url()
  */
 public function url($url = null, $full = false)
 {
     if (Configure::read('UrlCache.runtime.afterLayout')) {
         return parent::url($url, $full);
     }
     if (Configure::read('UrlCache.active')) {
         if ($cachedUrl = UrlCacheManager::get($url, $full)) {
             return $cachedUrl;
         }
     }
     $routerUrl = parent::url($url, $full);
     if (Configure::read('UrlCache.active')) {
         UrlCacheManager::set($routerUrl);
     }
     return $routerUrl;
 }
Esempio n. 16
0
function getThemeForm($theme)
{
    global $options;
    $configFile = $options->themeFile($theme, 'functions.php');
    $haveCfg = false;
    if (file_exists($configFile)) {
        require_once $configFile;
        if (function_exists('themeConfig')) {
            $haveCfg = true;
        }
    }
    if (!$haveCfg) {
        throw new Typecho_Widget_Exception(_t('外观配置功能不存在'), 404);
    }
    $form = new Typecho_Widget_Helper_Form(Helper::url('ThemeShow/config.php') . "&cfgtheme=" . $theme, Typecho_Widget_Helper_Form::POST_METHOD);
    themeConfig($form);
    return $form;
}
Esempio n. 17
0
 function url($url = null, $full = false)
 {
     if (!isset($url['lang']) && isset($this->params['lang'])) {
         if ($this->params['lang'] != Configure::read('Languages.default')) {
             $url['lang'] = $this->params['lang'];
         }
     }
     $keyUrl = $url;
     if (is_array($keyUrl)) {
         $keyUrl += $this->_extras;
     }
     $key = md5(serialize($keyUrl));
     if (!empty($this->_cache[$key])) {
         return $this->_cache[$key];
     }
     $url = parent::url($url, $full);
     $this->_cache[$key] = $url;
     return $url;
 }
Esempio n. 18
0
 /**
  * The Html->url() function overridden to support local prefixes
  *
  * @param string $url 
  * @param string $full 
  * @return void
  * @author Dean Sofer
  */
 public function url($url = null, $full = false)
 {
     if (is_array($url)) {
         if (!isset($url['lang']) && isset($this->request->params['lang'])) {
             $url['lang'] = $this->request->params['lang'];
         } elseif (isset($url['lang']) && $url['lang'] == Configure::read('Languages.default')) {
             unset($url['lang']);
         }
         if (!isset($url['plugin'])) {
             $url['plugin'] = false;
         }
         if (!$this->maintainPrefix) {
             $routing = Configure::read('Routing');
             if (!empty($routing['prefixes'])) {
                 $prefixes = array_diff_key(array_flip($routing['prefixes']), $url);
                 $url = array_merge($url, array_fill_keys(array_keys($prefixes), false));
             }
         }
     }
     return parent::url($url, $full);
 }
Esempio n. 19
0
 /**
  * Finds URL for specified action.
  *
  * Returns an URL pointing to a combination of controller and action. Param
  * $url can be:
  * 	+ Empty - the method will find adress to actuall controller/action.
  * 	+ '/' - the method will find base URL of application.
  * 	+ A combination of controller/action - the method will find url for it.
  *
  * @param  mixed  $url    Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4"
  *                        or an array specifying any of the following: 'controller', 'action',
  *                        and/or 'plugin', in addition to named arguments (keyed array elements),
  *                        and standard URL arguments (indexed array elements)
  * @param boolean $full   If true, the full base URL will be prepended to the result
  * @return string  Full translated URL with base path.
  */
 public function url($url = null, $full = false, $sessionId = true)
 {
     if ($sessionId) {
         $url = addSessionId($url);
     }
     //======================================================================
     // FormHelper::createで id をキーとして使うので、ルーターでマッチしない場合がある。
     // id というキー名を除外する事で対応。
     //======================================================================
     if (is_array($url) && isset($url['id'])) {
         array_push($url, $url['id']);
         unset($url['id']);
     }
     if (is_array($url) && !isset($url['admin']) && !empty($this->request->params['admin'])) {
         $url = array_merge($url, array('admin' => true));
     }
     if (!is_array($url) && preg_match('/\\/(img|css|js|files)\\//', $url)) {
         return $this->webroot($url);
     } elseif (!is_array($url) && preg_match('/^javascript:/', $url)) {
         return $url;
     } else {
         return parent::url($url, $full);
     }
 }
Esempio n. 20
0
<?php

require_once 'header.php';
?>
      <div class="main row">
       <div class="span8 offset4"> <form action="<?php 
print Helper::url('user/login');
?>
" method="post" class="form-stacked">
       <fieldset>
	<legend>Login</legend>
	<div class="main row">
 <p class="alert-message"><?php 
print Session::getFlashMessage();
?>
</p>
</div>
	<div class="clearfix">
		<label>Username:</label>   
		<div class="input">
	<input type="text" name="username"></div>
              </div>
		<div class="clearfix">
		<label>Password</label>		
		<div class="input"><input type="password" name="password"></div>
</div>
         <div class="actions"> <input type="submit" name="login" value="Login" class="btn primary"></div>
      </form>
      </div>
</div>
<?php 
Esempio n. 21
0
 function testOfUrl()
 {
     $pool = array(array('ftp://ftp.domain.co.uk/', true), array('ftp://*****:*****@domain.co.uk/folder/', true), array('123', false));
     foreach ($pool as $sample) {
         $this->assertSame(Helper::url($sample[0]), $sample[1]);
     }
 }
Esempio n. 22
0
File: add.php Progetto: AmbreB/Senny
<?php

$this->layout('template', ['title' => 'Add user']);
?>
<h1>Nouvel utilisateur</h1>
<form action="<?php 
echo Helper::url('users/index', false, 'addUser');
?>
" class="ui form" method="post">
	<?php 
echo Helper::field('nom', null);
?>
	<?php 
echo Helper::field('prenom', null);
?>
	<?php 
echo Helper::field('tel', null, 'Téléphone');
?>
	<?php 
echo Helper::field('code_postal', null, 'Code Postal');
?>
	<?php 
echo Helper::field('ville', null);
?>
	<?php 
echo Helper::field('site', null);
?>
	<div>
		<button class="ui blue button">Ajouter</button>
	</div>
</form>
Esempio n. 23
0
 function selectURL()
 {
     $output = "function selectURL(url) {\n            if (url == '') return false;\n\n            url = '" . Helper::url('/uploads/') . "' + url;\n\n            field = window.top.opener.browserWin.document.forms[0].elements[window.top.opener.browserField];\n            field.value = url;\n            if (field.onchange != null) field.onchange();\n            window.top.close();\n            window.top.opener.browserWin.focus();\n        }";
     return $output;
 }
Esempio n. 24
0
 public function url($url = null, $full = false)
 {
     return parent::url(router_url_language($url), $full);
 }
Esempio n. 25
0
function url($page, $id = false, $action = false)
{
    return Helper::url($page, $id, $action);
}
Esempio n. 26
0
 /**
  * Intercepts the parent url function to first look if the cache was already generated for the same params
  *
  * @param mixed $url url to generate using cakephp array syntax
  * @param bool|array $full whether to generate a full url or not (http scheme). As array: full, escape.
  * @return string
  * @see Helper::url()
  */
 public function url($url = null, $full = false)
 {
     if (is_array($full)) {
         $escape = isset($full['ecape']) ? $full['escape'] : true;
         $full = isset($full['full']) ? $full['full'] : false;
     } else {
         $escape = true;
     }
     if (Configure::read('UrlCache.active')) {
         if ($cachedUrl = UrlCacheManager::get($url, $full)) {
             return $cachedUrl;
         }
     }
     if (!$escape) {
         $routerUrl = Router::url($url, $full);
     } else {
         $routerUrl = parent::url($url, $full);
     }
     if (Configure::read('UrlCache.active')) {
         UrlCacheManager::set($routerUrl);
     }
     return $routerUrl;
 }
Esempio n. 27
0
<?php

require_once 'header.php';
?>
      <div class="main row">
        <form action="<?php 
print Helper::url('user/' . $this->type);
?>
" method="post" class="form-stacked">
          <fieldset>
            <legend><?php 
print $this->type == 'add' ? 'Add a new user' : 'Edit user';
?>
</legend>
            <?php 
if ($this->type == 'add') {
    ?>
			<div class="clearfix">
            	<label>Username</label>
            	<div class="input"><input name="username"/></div>
            </div> <?php 
}
?>
			
			<?php 
if ($this->type == 'add') {
    ?>
			<div class="clearfix">
            	<label>Password</label>
            	<div class="input"><input name="password" type="password"/></div>
            </div> <?php 
Esempio n. 28
0
 /**
  * @brief cache urls so router does less work
  *
  * cache urls when the method is called saves using the router doing all
  * the additional calculations.
  *
  * @link http://api.cakephp.org/class/helper#method-Helperurl
  *
  * @param mixed $url the url to generate
  * @param bool $full full url returned or just relative
  * @access public
  *
  * @return string the generated url
  */
 public function url($url = null, $full = true)
 {
     if (CakeSession::read('Spam.bot') || $this->request->url == '/?spam=true') {
         return parent::url('/?spam=true', true);
     }
     $persistedNamedParameters = Configure::read('AppHelper.persistParameters');
     if (!empty($persistedNamedParameters) && is_array($url)) {
         foreach ($persistedNamedParameters as $parameter) {
             if (!array_key_exists($parameter, $url) && !empty($this->request->params['named'][$parameter])) {
                 $url[$parameter] = $this->request->params['named'][$parameter];
             }
             if (array_key_exists($parameter, $url) && $url[$parameter] === false) {
                 unset($url[$parameter]);
             }
         }
     }
     $keyUrl = $url;
     if (is_array($keyUrl)) {
         $keyUrl += $this->urlExtras;
     }
     $key = md5(serialize($keyUrl) . $full);
     if (defined('INFINITAS_ROUTE_HASH')) {
         $key .= INFINITAS_ROUTE_HASH;
     }
     if (!empty($this->urlCache[$key])) {
         return $this->urlCache[$key];
     }
     $url = parent::url($url, $full);
     $this->urlCache[$key] = $url;
     return $url;
 }
Esempio n. 29
0
 /**
  * Finds URL for specified action.
  *
  * Returns an URL pointing to a combination of controller and action. Param
  * $url can be:
  *	+ Empty - the method will find adress to actuall controller/action.
  *	+ '/' - the method will find base URL of application.
  *	+ A combination of controller/action - the method will find url for it.
  *
  * @param  mixed  $url    Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4"
  *                        or an array specifying any of the following: 'controller', 'action',
  *                        and/or 'plugin', in addition to named arguments (keyed array elements),
  *                        and standard URL arguments (indexed array elements)
  * @param boolean $full   If true, the full base URL will be prepended to the result
  * @return string  Full translated URL with base path.
  */
 function url($url = null, $full = false)
 {
     $url = addSessionId($url);
     //======================================================================
     // FormHelper::createで id をキーとして使うので、ルーターでマッチしない場合がある。
     // id というキー名を除外する事で対応。
     //======================================================================
     if (is_array($url) && isset($url['id'])) {
         array_push($url, $url['id']);
         unset($url['id']);
     }
     if (!isset($url['admin']) && !empty($this->params['admin'])) {
         $url['admin'] = true;
     } elseif (isset($url['admin']) && !$url['admin']) {
         unset($url['admin']);
     }
     return parent::url($url, $full);
 }
Esempio n. 30
0
<?php

require_once 'header.php';
?>
      <div class="main row">
        <form action="<?php 
print Helper::url('article/' . $this->type);
?>
" method="post" class="form-stacked">
          <fieldset>
            <legend><?php 
print $this->type == 'add' ? 'Add a new article' : 'Edit article';
?>
</legend>
            <div class="clearfix">
            	<label>Title</label>
            	<div class="input"><input name="title" value="<?php 
print $this->type == 'edit' ? $this->article_data->title : '';
?>
" /></div>
            </div>
            <div class="clearfix">
            	<label>Content</label>
            	<div class="input"><textarea name="content"><?php 
print $this->type == 'edit' ? $this->article_data->content : '';
?>
</textarea></div>
            </div>
            <div class="actions">
              <input type="hidden" name="filled" value=="true" />
              <?php