fixing bugs and refactoring.
This commit is contained in:
parent
b40e69c47a
commit
a7e98e8e9a
|
@ -2,13 +2,6 @@
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
|
|
||||||
/**
|
|
||||||
* The paths to the configuration files.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public static $paths = array(SYS_CONFIG_PATH, CONFIG_PATH);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All of the loaded configuration items.
|
* All of the loaded configuration items.
|
||||||
*
|
*
|
||||||
|
@ -18,6 +11,13 @@ class Config {
|
||||||
*/
|
*/
|
||||||
public static $items = array();
|
public static $items = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The paths to the configuration files.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $paths = array(SYS_CONFIG_PATH, CONFIG_PATH);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a configuration item or file exists.
|
* Determine if a configuration item or file exists.
|
||||||
*
|
*
|
||||||
|
@ -114,9 +114,14 @@ protected static function parse($key)
|
||||||
{
|
{
|
||||||
$segments = explode('.', $key);
|
$segments = explode('.', $key);
|
||||||
|
|
||||||
$key = (count($segments) > 1) ? implode('.', array_slice($segments, 1)) : null;
|
if (count($segments) >= 2)
|
||||||
|
{
|
||||||
return array($segments[0], $key);
|
return array($segments[0], implode('.', array_slice($segments, 1)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return array($segments[0], null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,7 +71,7 @@ public static function forever($name, $value, $path = '/', $domain = null, $secu
|
||||||
*
|
*
|
||||||
* If a negative number of minutes is specified, the cookie will be deleted.
|
* If a negative number of minutes is specified, the cookie will be deleted.
|
||||||
*
|
*
|
||||||
* Note: This method's signature is very similar to the PHP setcookie method.
|
* This method's signature is very similar to the PHP setcookie method.
|
||||||
* However, you simply need to pass the number of minutes for which you
|
* However, you simply need to pass the number of minutes for which you
|
||||||
* wish the cookie to be valid. No funky time calculation is required.
|
* wish the cookie to be valid. No funky time calculation is required.
|
||||||
*
|
*
|
||||||
|
|
|
@ -43,7 +43,9 @@ class Form {
|
||||||
*/
|
*/
|
||||||
public static function open($action = null, $method = 'POST', $attributes = array(), $https = false)
|
public static function open($action = null, $method = 'POST', $attributes = array(), $https = false)
|
||||||
{
|
{
|
||||||
list($attributes['action'], $attributes['method']) = array(static::action($action, $https), static::method($method));
|
$attributes['action'] = static::action($action, $https);
|
||||||
|
|
||||||
|
$attributes['method'] = static::method($method);
|
||||||
|
|
||||||
if ( ! array_key_exists('accept-charset', $attributes))
|
if ( ! array_key_exists('accept-charset', $attributes))
|
||||||
{
|
{
|
||||||
|
@ -433,7 +435,9 @@ public static function radio($name, $value = null, $checked = false, $attributes
|
||||||
*/
|
*/
|
||||||
protected static function checkable($type, $name, $value, $checked, $attributes)
|
protected static function checkable($type, $name, $value, $checked, $attributes)
|
||||||
{
|
{
|
||||||
$attributes = array_merge($attributes, array('id' => static::id($name, $attributes), 'checked' => ($checked) ? 'checked' : null));
|
if ($checked) $attributes['checked'] = 'checked';
|
||||||
|
|
||||||
|
$attributes['id'] = static::id($name, $attributes);
|
||||||
|
|
||||||
return static::input($type, $name, $value, $attributes);
|
return static::input($type, $name, $value, $attributes);
|
||||||
}
|
}
|
||||||
|
@ -508,9 +512,15 @@ public static function button($value, $attributes = array())
|
||||||
*/
|
*/
|
||||||
protected static function id($name, $attributes)
|
protected static function id($name, $attributes)
|
||||||
{
|
{
|
||||||
if (array_key_exists('id', $attributes)) return $attributes['id'];
|
if (array_key_exists('id', $attributes))
|
||||||
|
{
|
||||||
|
return $attributes['id'];
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array($name, static::$labels)) return $name;
|
if (in_array($name, static::$labels))
|
||||||
|
{
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ class Input {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $input;
|
public static $input;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key used to store old input in the session.
|
* The key used to store old input in the session.
|
||||||
|
@ -16,17 +16,6 @@ class Input {
|
||||||
*/
|
*/
|
||||||
const old_input = 'laravel_old_input';
|
const old_input = 'laravel_old_input';
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the input for the current request.
|
|
||||||
*
|
|
||||||
* @param array $input
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function set($input)
|
|
||||||
{
|
|
||||||
static::$input = $input;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all of the input data for the request.
|
* Get all of the input data for the request.
|
||||||
*
|
*
|
||||||
|
|
|
@ -72,7 +72,7 @@ protected function __construct($key, $replacements = array(), $language = null)
|
||||||
*/
|
*/
|
||||||
public static function line($key, $replacements = array(), $language = null)
|
public static function line($key, $replacements = array(), $language = null)
|
||||||
{
|
{
|
||||||
if (is_null($language)) $language = Config::get('application.language');
|
if (is_null($language)) $language = Config::$items['application']['language'];
|
||||||
|
|
||||||
return new static($key, $replacements, $language);
|
return new static($key, $replacements, $language);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
*/
|
*/
|
||||||
unset($input[Request::spoofer]);
|
unset($input[Request::spoofer]);
|
||||||
|
|
||||||
Input::set($input);
|
Input::$input = $input;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route the request to the proper route in the application. If a
|
* Route the request to the proper route in the application. If a
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
*/
|
*/
|
||||||
Routing\Filter::register(require APP_PATH.'filters'.EXT);
|
Routing\Filter::register(require APP_PATH.'filters'.EXT);
|
||||||
|
|
||||||
list($method, $uri) = array(Request::method(), Request::uri());
|
list($uri, $method) = array(Request::uri(), Request::method());
|
||||||
|
|
||||||
$route = IoC::container()->core('routing.router')->route($method, $uri);
|
$route = IoC::container()->core('routing.router')->route($method, $uri);
|
||||||
|
|
||||||
|
|
|
@ -188,9 +188,28 @@ public static function ascii($value)
|
||||||
*/
|
*/
|
||||||
public static function random($length, $type = 'alnum')
|
public static function random($length, $type = 'alnum')
|
||||||
{
|
{
|
||||||
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
return substr(str_shuffle(str_repeat(static::pool($type), 5)), 0, $length);
|
||||||
|
}
|
||||||
|
|
||||||
return substr(str_shuffle(str_repeat(($type == 'alnum') ? $pool.'0123456789' : $pool, 5)), 0, $length);
|
/**
|
||||||
|
* Get the character pool for a given type of random string.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected static function pool($type)
|
||||||
|
{
|
||||||
|
switch ($type)
|
||||||
|
{
|
||||||
|
case 'alpha':
|
||||||
|
return 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
|
||||||
|
case 'alnum':
|
||||||
|
return '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new \Exception("Invalid random string type [$type].");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue