예제 #1
0
 static function recognise(URL $url)
 {
     if (self::$match === null) {
         self::$match = array();
         static::generate_matches();
     }
     $path = $url->getPath()->getPath(true);
     $matches = null;
     foreach (self::$match as $data) {
         if ($data->matches($path, $matches)) {
             return $data->call($matches);
         }
     }
 }
예제 #2
0
 function Authenticate()
 {
     if (\Radical\Utility\Net\URL::fromRequest() == $this->redirectUrl) {
         return parent::Authenticate();
     }
     //Redirect
     $page = new \Radical\Web\Page\Controller\Special\Redirect($this->redirectUrl);
     $page->Execute('GET');
     //Bye
     die('Redirecting');
 }
예제 #3
0
 static function recognise(URL $url)
 {
     $path = $url->getPath()->getPath(true);
     $match = null;
     foreach (static::$match as $expr => $class) {
         $matches = Format::consumeRegex($path, $expr, $match);
         if ($matches) {
             if (is_array($class) || is_string($class)) {
                 if (is_array($class)) {
                     $data = isset($class['data']) ? $class['data'] : $match;
                     $class = $class['class'];
                 } else {
                     $data = $match;
                     //matched but no data
                     if ($data === true) {
                         $data = array();
                     }
                 }
                 if (is_string($class)) {
                     if ($class[0] != '\\') {
                         $class_expr = '\\*\\Web\\Page\\Controller\\' . $class;
                         $class = null;
                         foreach (\Radical\Core\Libraries::get($class_expr) as $class) {
                             //$class set
                             break;
                         }
                         if ($class === null) {
                             return null;
                         }
                     }
                     return new $class($data);
                 }
             }
             return $class;
         }
     }
 }
예제 #4
0
 protected function event_redirect()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         return new Redirect((string) URL::fromRequest());
     }
     $url = URL::fromRequest();
     $qs = $url->getQuery();
     foreach ($qs as $k => $v) {
         if (substr($k, 0, 2) == '__') {
             unset($qs[$k]);
         }
     }
     $url->setQuery($qs);
     return new Redirect((string) $url);
 }
예제 #5
0
 function __construct($url = null, $query = 'page', $defaultPage = 1)
 {
     //Create URL object
     if ($url == null) {
         $url = URL::fromRequest();
     } else {
         $url = URL::fromURL($url);
     }
     //Reset Page
     $query_string = $url->getPath()->getQuery();
     if (isset($query_string[$query])) {
         $this->current = (int) $query_string[$query];
         unset($query_string[$query]);
         $url->getPath()->setQuery($query_string);
     } else {
         $this->current = $defaultPage;
     }
     $this->query = $query;
     $this->defaultPage = $defaultPage;
     parent::__construct($url);
 }
예제 #6
0
 function __clone()
 {
     $this->localPath = clone $this->localPath;
     parent::__clone();
 }
예제 #7
0
파일: URL.php 프로젝트: splitice/radical-db
 function getUrl()
 {
     return \Radical\Utility\Net\URL::fromURL($this->value);
 }