Commit a7e98e8e authored by Taylor Otwell's avatar Taylor Otwell

fixing bugs and refactoring.

parent b40e69c4
......@@ -3,20 +3,20 @@
class Config {
/**
* The paths to the configuration files.
* All of the loaded configuration items.
*
* The configuration arrays are keyed by their owning file name.
*
* @var array
*/
public static $paths = array(SYS_CONFIG_PATH, CONFIG_PATH);
public static $items = array();
/**
* All of the loaded configuration items.
*
* The configuration arrays are keyed by their owning file name.
* The paths to the configuration files.
*
* @var array
*/
public static $items = array();
public static $paths = array(SYS_CONFIG_PATH, CONFIG_PATH);
/**
* Determine if a configuration item or file exists.
......@@ -114,9 +114,14 @@ class Config {
{
$segments = explode('.', $key);
$key = (count($segments) > 1) ? implode('.', array_slice($segments, 1)) : null;
return array($segments[0], $key);
if (count($segments) >= 2)
{
return array($segments[0], implode('.', array_slice($segments, 1)));
}
else
{
return array($segments[0], null);
}
}
/**
......
......@@ -71,9 +71,9 @@ class Cookie {
*
* 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.
* 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.
* 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
* wish the cookie to be valid. No funky time calculation is required.
*
* @param string $name
* @param string $value
......
......@@ -43,7 +43,9 @@ class Form {
*/
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))
{
......@@ -433,7 +435,9 @@ class Form {
*/
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);
}
......@@ -508,9 +512,15 @@ class Form {
*/
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;
}
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ class Input {
*
* @var array
*/
protected static $input;
public static $input;
/**
* The key used to store old input in the session.
......@@ -16,17 +16,6 @@ class 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.
*
......
......@@ -72,7 +72,7 @@ class Lang {
*/
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);
}
......
......@@ -78,7 +78,7 @@ switch (Request::method())
*/
unset($input[Request::spoofer]);
Input::set($input);
Input::$input = $input;
/**
* Route the request to the proper route in the application. If a
......@@ -88,7 +88,7 @@ Input::set($input);
*/
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);
......
......@@ -188,9 +188,28 @@ class Str {
*/
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].");
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment