Beispiel #1
0
 /** 
  * Get the uri to an asset
  *
  *     // /assets/images/something.jpg
  *     CCAsset::uri( 'images/something.jpg' );
  *     
  *     // /assets/MyTheme/images/something.jpg
  *     CCAsset::uri( 'images/logo.png', 'theme' );
  *     
  *     // will not modify the given url
  *     CCAsset::uri( 'http://example.com/images/logo.jpg' );
  * 
  * @param string		$uri
  * @param string		$name 
  * @return string
  */
 public static function uri($uri, $name = null)
 {
     // when the uri conains a protocol we just return
     // the given uri.
     if (strpos($uri, '://') === false) {
         // If the path is relative and not absolute
         // we prefix the holder path.
         if (substr($uri, 0, 1) != '/') {
             $uri = CCUrl::to(static::holder($name)->path . $uri);
         } else {
             $uri = CCUrl::to(substr($uri, 1));
         }
     }
     return $uri;
 }
Beispiel #2
0
 /**
  * Create an URL based on an router alias
  *
  * @param string		$alias
  * @param array  	$params
  * @param bool		$retain		Should we keep the get parameters?
  * @return string 
  */
 public static function alias($alias, $params = array(), $retain = false)
 {
     $route_params = array();
     // to handle the suffix after a slash in an alias define
     $suffix = '';
     if (strpos($alias, '/') !== false && $alias !== '/') {
         // slashes in aliases get appended as suffix
         list($alias, $suffix) = explode('/', $alias);
         $suffix = '/' . $suffix;
     }
     // get the parameters with the numeric keys so we can
     // pass them as route parameters like [any]-[num]-[num]/[any]/
     foreach ($params as $key => $value) {
         if (is_int($key)) {
             $route_params[] = $value;
             unset($params[$key]);
         }
     }
     return CCUrl::to(CCRouter::alias($alias, $route_params) . $suffix, $params, $retain);
 }
Beispiel #3
0
 /**
  * Get the public url to a file if available
  *
  * @param string		$file
  * @param string		$key
  * @return string
  */
 public static function url($file = null, $key = null)
 {
     // get the storage key
     if (is_null($key)) {
         $key = static::$default;
     }
     // check if path exists
     if (!isset(static::$urls[$key])) {
         throw new CCException('CCStorage - use of undefined public url ' . $key . '.');
     }
     return CCUrl::to(static::$urls[$key] . $file);
 }
Beispiel #4
0
 /**
  * CCUrl::active tests
  */
 public function test_dimensions()
 {
     $url = CCUrl::to('/', array("test" => array("a" => array("b" => "z", "c" => "z"))));
     $this->assertEquals('/?test[a][b]=z&test[a][c]=z', urldecode($url));
 }
Beispiel #5
0
		<form class="form" method="post">
			<div class="form-group">
				<input class="form-control" name="key" type="text" placeholder="key">
			</div>
			<div class="form-group">
				<input class="form-control" name="value" type="text" placeholder="value">
			</div>
			<div class="form-group">
				<input class="btn btn-default" type="submit" value="Save">
			</div>
		</form>
		<hr>
		
		<h4>Switch manager</h4>
		<form class="form" method="post" action="<?php 
echo CCUrl::action('manager');
?>
">
			<div class="form-group">
				<input class="form-control" name="name" type="text" placeholder="Session manager name">
			</div>
			<div class="form-group">
				<input class="btn btn-default" type="submit" value="Switch">
			</div>
		</form>
		
	</div>
	<div class="col-md-8">
		<h4>Data</h4>
		<pre style="overflow: auto; overflow-x:scroll;white-space: nowrap;"><?php 
echo nl2br(str_replace(array(" ", "\t"), array('&nbsp;', '&nbsp;&nbsp;'), $data_dump));