예제 #1
0
<?php
/**
 * RoxPHP
 *
 * Copyright (C) 2008 - 2011 Ramon Torres
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright Copyright (c) 2008 - 2011 Ramon Torres
 * @package App
 * @license The MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

// include the bootstrap file
require dirname(__DIR__) . '/config/bootstrap.php';

if (empty($_GET['route']) ) {
	if (isset($_SERVER['REQUEST_URI'])
		&& strlen(trim($_SERVER['REQUEST_URI'])) > 0
		&& $_SERVER['REQUEST_URI'] != \rox\Router::url('/')) {
		$_GET['route'] = $_SERVER['REQUEST_URI'];
	} else {
		$_GET['route'] = '/';
	}
}

$dispatcher = new \rox\http\Dispatcher;
$dispatcher->dispatch(new \rox\http\Request);
예제 #2
0
 public function testUrl()
 {
     $_SERVER['PHP_SELF'] = '/folder/app/webroot/index.php';
     $_SERVER['HTTP_HOST'] = 'example.org';
     $result = Router::url('/articles');
     $this->assertSame('/folder/articles', $result);
     $result = Router::url('/articles', true);
     $this->assertSame('http://example.org/folder/articles', $result);
 }
예제 #3
0
 /**
  * Sends redirect headers and exit
  *
  * @param string $url
  */
 protected function redirect($url, $options = array())
 {
     $defaults = array('status' => 301);
     $options += $defaults;
     $location = preg_match('/^([a-z0-9]+):\\/\\//', $url) === 1 ? $url : Router::url($url);
     $this->response->status = $options['status'];
     $this->response->header('Location', $location);
     $this->response->render();
     exit;
 }
예제 #4
0
파일: Html.php 프로젝트: radius/roxphp
	/**
	 * Returns the URL for deleting a record.
	 *
	 * If a record of class Account is passed
	 * the returned url is: [...]/accounts/delete/[Record ID]
	 *
	 * @param ActiveModel $object 
	 * @param string $absolute 
	 * @return string
	 */
	public function deleteUrl(ActiveModel $object, $absolute = false) {
		return Router::url($this->deletePath($object), $absolute);
	}
예제 #5
0
 /**
  * Creates a form opening tag
  *
  * @param string $model
  * @param string $action
  * @param array $attributes
  * @return string
  */
 public function create($action, $attributes = array())
 {
     $attributes['action'] = Router::url($action);
     $attributes = array_merge(array('method' => 'post'), $attributes);
     return sprintf('<form%s>', $this->_attributes($attributes));
 }
예제 #6
0
 protected function _src($folder, $filename)
 {
     $path = "/{$folder}/{$filename}";
     if (self::$_config['timestamp']) {
         $timestamp = @filemtime(ROX_APP_PATH . "/webroot/{$folder}/{$filename}");
         $path .= "?{$timestamp}";
     }
     if (self::$_config['host'] !== false) {
         return self::$_config['host'] . $path;
     }
     return Router::url($path);
 }