Exemple #1
0
 public function setUrl($mode = null, $defaultUrl = null)
 {
     if (!$this->url && !$defaultUrl) {
         $this->url = $this->data['url'] = trim($this->O->route()->getRoute(), '/') . '?' . $this->var_module . '=' . trim(preg_replace('#\\\\#', '.', get_called_class()), '\\');
     } else {
         if ($defaultUrl) {
             $this->is_routed = true;
             $this->url = $this->data['url'] = $defaultUrl;
         }
     }
     $m = 0;
     $mode = $mode ? $mode : $this->mode;
     $sp = preg_match("#\\?#", $this->url) ? '&' : '?';
     if ($mode) {
         // si le mode est présent dans l'url on le remplace
         // @TODO l'utilisation des variables-value est déprécié
         if (preg_match("#/(?:{$this->var_mode}-)?{$mode}#", $this->url)) {
             $m = 1;
         }
         if (preg_match("#/(?:{$this->var_mode}=)?{$mode}#", $this->url, $match)) {
             $m = 1;
         }
     }
     foreach ($this->render_mode as $v) {
         if ($m) {
             $this->data["url_" . $v] = $this->{"url_" . $v} = str_replace($mode, $v, $this->url);
         } else {
             if ($v != $mode) {
                 $this->data["url_" . $v] = $this->{"url_" . $v} = $this->url . $sp . $this->var_mode . '=' . $v;
             } else {
                 $this->data["url_" . $v] = $this->{"url_" . $v} = $this->url;
             }
         }
     }
     $this->data['url_static'] = $this->url_static;
     return $this;
 }
Exemple #2
0
 public static function getWebPath(\Fp\Core\Init $O, $dir)
 {
     return $O->route()->getWebPath($dir);
 }
 /**
  * @param unknown $t
  * @param unknown $url
  * @return unknown
  * @deprecated
  */
 public static function urlRelativ($t, \Fp\Core\Init $O, $url)
 {
     $c = clone $t;
     $r = $o->glob('url') . '/' . $O->route()->getRoute();
     $c->vars = preg_replace("#{$r}#", '.', $c->vars);
     return $c;
 }