Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
abc1fad6
Commit
abc1fad6
authored
Sep 08, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more refactoring and changes.
parent
03654fc5
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
871 additions
and
470 deletions
+871
-470
composers.php
application/composers.php
+2
-2
aliases.php
application/config/aliases.php
+4
-4
arr.php
laravel/arr.php
+1
-1
asset.php
laravel/asset.php
+20
-18
benchmark.php
laravel/benchmark.php
+13
-3
blade.php
laravel/blade.php
+67
-0
bootstrap.php
laravel/bootstrap.php
+2
-5
driver.php
laravel/cache/driver.php
+4
-2
config.php
laravel/config.php
+25
-4
container.php
laravel/config/container.php
+7
-5
container.php
laravel/container.php
+43
-22
controller.php
laravel/controller.php
+14
-10
cookie.php
laravel/cookie.php
+16
-5
download.php
laravel/download.php
+0
-51
facades.php
laravel/facades.php
+24
-21
file.php
laravel/file.php
+36
-8
form.php
laravel/form.php
+101
-9
html.php
laravel/html.php
+92
-4
inflector.php
laravel/inflector.php
+19
-10
input.php
laravel/input.php
+43
-15
lang.php
laravel/lang.php
+31
-35
laravel.php
laravel/laravel.php
+22
-34
loader.php
laravel/loader.php
+11
-47
package.php
laravel/package.php
+0
-45
redirect.php
laravel/redirect.php
+23
-16
request.php
laravel/request.php
+3
-3
response.php
laravel/response.php
+39
-12
caller.php
laravel/routing/caller.php
+1
-1
delegator.php
laravel/routing/delegator.php
+1
-1
driver.php
laravel/session/driver.php
+16
-8
str.php
laravel/str.php
+28
-31
url.php
laravel/url.php
+81
-5
view.php
laravel/view.php
+71
-31
index.php
public/index.php
+11
-2
No files found.
application/composers.php
View file @
abc1fad6
...
...
@@ -39,12 +39,12 @@ return array(
|
*/
'shared'
=>
function
(
$view
,
$laravel
)
'shared'
=>
function
(
$view
)
{
//
},
'home.index'
=>
array
(
'name'
=>
'home'
,
function
(
$view
,
$laravel
)
'home.index'
=>
array
(
'name'
=>
'home'
,
function
(
$view
)
{
//
}),
...
...
application/config/aliases.php
View file @
abc1fad6
...
...
@@ -19,7 +19,7 @@ return array(
*/
'Arr'
=>
'Laravel\\Arr'
,
'Asset'
=>
'Laravel\\Asset'
,
'Asset'
=>
'Laravel\\
Facades\\
Asset'
,
'Auth'
=>
'Laravel\\Facades\\Auth'
,
'Benchmark'
=>
'Laravel\\Benchmark'
,
'Cache'
=>
'Laravel\\Facades\\Cache'
,
...
...
@@ -37,16 +37,16 @@ return array(
'Inflector'
=>
'Laravel\\Inflector'
,
'Input'
=>
'Laravel\\Facades\\Input'
,
'IoC'
=>
'Laravel\\IoC'
,
'Lang'
=>
'Laravel\\Lang'
,
'Lang'
=>
'Laravel\\
Facades\\
Lang'
,
'Loader'
=>
'Laravel\\Facades\\Loader'
,
'Package'
=>
'Laravel\\Facades\\Package'
,
'URL'
=>
'Laravel\\Facades\\URL'
,
'Redirect'
=>
'Laravel\\Facades\\Redirect'
,
'Request'
=>
'Laravel\\Facades\\Request'
,
'Response'
=>
'Laravel\\Response'
,
'Response'
=>
'Laravel\\
Facades\\
Response'
,
'Session'
=>
'Laravel\\Facades\\Session'
,
'Str'
=>
'Laravel\\Str'
,
'Validator'
=>
'Laravel\\Facades\\Validator'
,
'View'
=>
'Laravel\\View'
,
'View'
=>
'Laravel\\
Facades\\
View'
,
);
\ No newline at end of file
laravel/arr.php
View file @
abc1fad6
...
...
@@ -47,7 +47,7 @@ class Arr {
* method, JavaScript "dot" syntax is supported.
*
* <code>
* // Set
the "name" item to "Fred" in the array
* // Set
an array's "name" item to "Fred"
* Arr::set($array, 'name', 'Fred');
* </code>
*
...
...
laravel/asset.php
View file @
abc1fad6
...
...
@@ -58,8 +58,8 @@ class Asset {
/**
* Magic Method for calling methods on the default Asset container.
*
* This provides a convenient API, allowing the develop
to skip the "container"
* method when using the default container.
* This provides a convenient API, allowing the develop
er to skip the
*
"container"
method when using the default container.
*
* <code>
* // Add a JavaScript file to the default container
...
...
@@ -81,8 +81,6 @@ class Asset_Container {
/**
* The asset container name.
*
* This name may be used to access the container instance via the Asset::container method.
*
* @var string
*/
public
$name
;
...
...
@@ -127,10 +125,10 @@ class Asset_Container {
*
* <code>
* // Add an asset to the container
* Asset::
container()->
add('jquery', 'js/jquery.js');
* Asset::add('jquery', 'js/jquery.js');
*
* // Add an asset that has dependencies
* Asset::
container()->
add('jquery', 'js/jquery.js', array('jquery-ui'));
* Asset::add('jquery', 'js/jquery.js', array('jquery-ui'));
* </code>
*
* @param string $name
...
...
@@ -147,13 +145,13 @@ class Asset_Container {
}
/**
* Add
CSS
to the registered assets.
* Add
a CSS file
to the registered assets.
*
* @param string $name
* @param string $source
* @param array $dependencies
* @param array $attributes
* @return
void
* @param string
$name
* @param string
$source
* @param array
$dependencies
* @param array
$attributes
* @return
Asset_Container
*/
public
function
style
(
$name
,
$source
,
$dependencies
=
array
(),
$attributes
=
array
())
{
...
...
@@ -163,20 +161,24 @@ class Asset_Container {
}
$this
->
register
(
'style'
,
$name
,
$source
,
$dependencies
,
$attributes
);
return
$this
;
}
/**
* Add
JavaScript
to the registered assets.
* Add
a JavaScript file
to the registered assets.
*
* @param string $name
* @param string $source
* @param array $dependencies
* @param array $attributes
* @return
void
* @param string
$name
* @param string
$source
* @param array
$dependencies
* @param array
$attributes
* @return
Asset_Container
*/
public
function
script
(
$name
,
$source
,
$dependencies
=
array
(),
$attributes
=
array
())
{
$this
->
register
(
'script'
,
$name
,
$source
,
$dependencies
,
$attributes
);
return
$this
;
}
/**
...
...
laravel/benchmark.php
View file @
abc1fad6
...
...
@@ -10,9 +10,14 @@ class Benchmark {
protected
static
$marks
=
array
();
/**
* Start a benchmark.
* Start a benchmark
starting time
.
*
* After starting a benchmark, the elapsed time in milliseconds may be retrieved via the "check" method.
* The elapsed time since setting a benchmark may checked via the "check" method.
*
* <code>
* // Set a benchmark starting time
* Benchmark::start('database');
* </code>
*
* @param string $name
* @return void
...
...
@@ -25,6 +30,11 @@ class Benchmark {
/**
* Get the elapsed time in milliseconds since starting a benchmark.
*
* <code>
* // Get the elapsed time since starting a benchmark
* $time = Benchmark::check('database');
* </code>
*
* @param string $name
* @return float
*/
...
...
@@ -45,7 +55,7 @@ class Benchmark {
*/
public
static
function
memory
()
{
return
number_format
(
memory_get_usage
()
/
1024
/
1024
,
2
);
return
(
float
)
number_format
(
memory_get_usage
()
/
1024
/
1024
,
2
);
}
}
\ No newline at end of file
laravel/blade.php
0 → 100644
View file @
abc1fad6
<?php
namespace
Laravel
;
class
Blade
{
/**
* Rewrites the specified file containing Blade pseudo-code into valid PHP.
*
* @param string $path
* @return string
*/
public
static
function
parse
(
$path
)
{
return
static
::
parse_string
(
file_get_contents
(
$path
));
}
/**
* Rewrites the specified string containing Blade pseudo-code into valid PHP.
*
* @param string $value
* @return string
*/
public
static
function
parse_string
(
$value
)
{
$value
=
static
::
rewrite_echos
(
$value
);
$value
=
static
::
rewrite_openings
(
$value
);
$value
=
static
::
rewrite_closings
(
$value
);
return
$value
;
}
/**
* Rewrites Blade echo statements into PHP echo statements.
*
* @param string $value
* @return string
*/
protected
static
function
rewrite_echos
(
$value
)
{
return
preg_replace
(
'/\{\{(.+)\}\}/'
,
'<?php echo $1; ?>'
,
$value
);
}
/**
* Rewrites Blade structure openings into PHP structure openings.
*
* @param string $value
* @return string
*/
protected
static
function
rewrite_openings
(
$value
)
{
return
preg_replace
(
'/@(if|elseif|foreach|for|while)(\s*\(.*?\))\:/'
,
'<?php $1$2: ?>'
,
$value
);
}
/**
* Rewrites Blade structure closings into PHP structure closings.
*
* @param string $value
* @return string
*/
protected
static
function
rewrite_closings
(
$value
)
{
$value
=
preg_replace
(
'/(\s*)@(else)(.*?)\:/'
,
'$1<?php $2$3: ?>'
,
$value
);
$value
=
preg_replace
(
'/(\s*)@(endif|endforeach|endfor|endwhile)(\s*)/'
,
'$1<?php $2; ?> $3'
,
$value
);
return
$value
;
}
}
\ No newline at end of file
laravel/bootstrap.php
View file @
abc1fad6
...
...
@@ -25,9 +25,7 @@ define('CONFIG_PATH', APP_PATH.'config/');
define
(
'CONTROLLER_PATH'
,
APP_PATH
.
'controllers/'
);
define
(
'DATABASE_PATH'
,
STORAGE_PATH
.
'database/'
);
define
(
'LANG_PATH'
,
APP_PATH
.
'language/'
);
define
(
'SCRIPT_PATH'
,
PUBLIC_PATH
.
'js/'
);
define
(
'SESSION_PATH'
,
STORAGE_PATH
.
'sessions/'
);
define
(
'STYLE_PATH'
,
PUBLIC_PATH
.
'css/'
);
define
(
'SYS_CONFIG_PATH'
,
SYS_PATH
.
'config/'
);
define
(
'SYS_LANG_PATH'
,
SYS_PATH
.
'language/'
);
define
(
'VIEW_PATH'
,
APP_PATH
.
'views/'
);
...
...
@@ -36,7 +34,6 @@ define('VIEW_PATH', APP_PATH.'views/');
// Load the configuration manager and its dependencies.
// --------------------------------------------------------------
require
SYS_PATH
.
'facades'
.
EXT
;
require
SYS_PATH
.
'loader'
.
EXT
;
require
SYS_PATH
.
'config'
.
EXT
;
require
SYS_PATH
.
'arr'
.
EXT
;
...
...
@@ -62,6 +59,6 @@ $container = new Container($dependencies);
IoC
::
$container
=
$container
;
// --------------------------------------------------------------
// Register the auto-loader on the stack.
// Register the auto-loader on the
auto-loader
stack.
// --------------------------------------------------------------
spl_autoload_register
(
array
(
$container
->
loader
,
'load'
));
\ No newline at end of file
spl_autoload_register
(
array
(
$container
->
resolve
(
'laravel.loader'
),
'load'
));
\ No newline at end of file
laravel/cache/driver.php
View file @
abc1fad6
<?php
namespace
Laravel\Cache
;
use
Closure
;
abstract
class
Driver
{
/**
...
...
@@ -25,7 +27,7 @@ abstract class Driver {
{
if
(
!
is_null
(
$item
=
$this
->
retrieve
(
$key
)))
return
$item
;
return
(
$default
instanceof
\
Closure
)
?
call_user_func
(
$default
)
:
$default
;
return
(
$default
instanceof
Closure
)
?
call_user_func
(
$default
)
:
$default
;
}
/**
...
...
@@ -59,7 +61,7 @@ abstract class Driver {
{
if
(
!
is_null
(
$item
=
$this
->
get
(
$key
,
null
)))
return
$item
;
$default
=
(
$default
instanceof
\
Closure
)
?
call_user_func
(
$default
)
:
$default
;
$default
=
(
$default
instanceof
Closure
)
?
call_user_func
(
$default
)
:
$default
;
$this
->
put
(
$key
,
$default
,
$minutes
);
...
...
laravel/config.php
View file @
abc1fad6
...
...
@@ -5,14 +5,14 @@ class Config {
/**
* All of the loaded configuration items.
*
* The configuration arrays are keyed by
file names
.
* The configuration arrays are keyed by
their owning file name
.
*
* @var array
*/
protected
$items
=
array
();
/**
* The paths
containing
the configuration files.
* The paths
to
the configuration files.
*
* @var array
*/
...
...
@@ -46,6 +46,17 @@ class Config {
* If the name of a configuration file is passed without specifying an item, the
* entire configuration array will be returned.
*
* <code>
* // Get the "timezone" option from the "application" file
* $timezone = Config::get('application.timezone');
*
* // Get the SQLite connection configuration from the "database" file
* $sqlite = Config::get('database.connections.sqlite');
*
* // Get a configuration option and return "Fred" if it doesn't exist
* $option = Config::get('config.option', 'Fred');
* </code>
*
* @param string $key
* @param string $default
* @return array
...
...
@@ -70,6 +81,14 @@ class Config {
* If a specific configuration item is not specified, the entire configuration
* array will be replaced with the given value.
*
* <code>
* // Set the "timezone" option in the "application" file
* Config::set('application.timezone', 'America/Chicago');
*
* // Set the entire "session" array to an empty array
* Config::set('session', array());
* </code>
*
* @param string $key
* @param mixed $value
* @return void
...
...
@@ -91,11 +110,13 @@ class Config {
* @param string $key
* @return array
*/
pr
ivate
function
parse
(
$key
)
pr
otected
function
parse
(
$key
)
{
$segments
=
explode
(
'.'
,
$key
);
return
array
(
$segments
[
0
],
(
count
(
$segments
)
>
1
)
?
implode
(
'.'
,
array_slice
(
$segments
,
1
))
:
null
);
$key
=
(
count
(
$segments
)
>
1
)
?
implode
(
'.'
,
array_slice
(
$segments
,
1
))
:
null
;
return
array
(
$segments
[
0
],
$key
);
}
/**
...
...
laravel/config/container.php
View file @
abc1fad6
...
...
@@ -110,7 +110,7 @@ return array(
(
$request
->
spoofed
())
?
$input
=
$_POST
:
parse_str
(
file_get_contents
(
'php://input'
),
$input
);
}
return
new
Input
(
$
input
,
$_FILES
,
$container
->
resolve
(
'laravel.cookie'
)
);
return
new
Input
(
$
container
->
resolve
(
'laravel.file'
),
$container
->
resolve
(
'laravel.cookie'
),
$input
,
$_FILES
);
}),
...
...
@@ -124,9 +124,11 @@ return array(
'laravel.loader'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
{
$paths
=
array
(
BASE_PATH
,
APP_PATH
.
'models/'
,
APP_PATH
.
'libraries/'
)
;
require_once
SYS_PATH
.
'loader'
.
EXT
;
return
new
Loader
(
$container
->
resolve
(
'laravel.config'
)
->
get
(
'aliases'
),
$paths
);
$aliases
=
$container
->
resolve
(
'laravel.config'
)
->
get
(
'aliases'
);
return
new
Loader
(
array
(
BASE_PATH
,
APP_PATH
.
'models/'
,
APP_PATH
.
'libraries/'
),
$aliases
);
}),
...
...
@@ -152,7 +154,7 @@ return array(
{
require_once
SYS_PATH
.
'response'
.
EXT
;
return
new
Response_Factory
(
$container
->
resolve
(
'laravel.view'
));
return
new
Response_Factory
(
$container
->
resolve
(
'laravel.view'
)
,
$container
->
resolve
(
'laravel.file'
)
);
}),
...
...
@@ -220,7 +222,7 @@ return array(
'laravel.view.composer'
=>
array
(
'resolver'
=>
function
(
$container
)
{
return
new
View_Composer
(
$container
,
require
APP_PATH
.
'composers'
.
EXT
);
return
new
View_Composer
(
require
APP_PATH
.
'composers'
.
EXT
);
}),
/*
...
...
laravel/container.php
View file @
abc1fad6
...
...
@@ -46,26 +46,31 @@ class Container {
*
* @var array
*/
protected
$re
solvers
=
array
();
protected
$re
gistry
=
array
();
/**
* Create a new IoC container instance.
*
* @param array $
dependencies
* @param array $
registry
* @return void
*/
public
function
__construct
(
$
dependencies
=
array
())
public
function
__construct
(
$
registry
=
array
())
{
foreach
(
$dependencies
as
$key
=>
$value
)
{
$this
->
register
(
$key
,
$value
[
'resolver'
],
(
isset
(
$value
[
'singleton'
]))
?
$value
[
'singleton'
]
:
false
);
}
$this
->
registry
=
$registry
;
}
/**
* Register a dependency and its resolver.
*
* The resolver function when the registered dependency is requested.
* The resolver function is called when the registered dependency is requested.
*
* <code>
* // Register a dependency in the container
* IoC::register('something', function($container) {return new Something;});
*
* // Register a dependency in the container as a singleton
* IoC::register('something', function($container) {return new Something;}, true);
* </code>
*
* @param string $name
* @param Closure $resolver
...
...
@@ -73,7 +78,7 @@ class Container {
*/
public
function
register
(
$name
,
$resolver
,
$singleton
=
false
)
{
$this
->
re
solvers
[
$name
]
=
array
(
'resolver'
=>
$resolver
,
'singleton'
=>
$singleton
);
$this
->
re
gistry
[
$name
]
=
array
(
'resolver'
=>
$resolver
,
'singleton'
=>
$singleton
);
}
/**
...
...
@@ -84,7 +89,7 @@ class Container {
*/
public
function
registered
(
$name
)
{
return
array_key_exists
(
$name
,
$this
->
re
solvers
);
return
array_key_exists
(
$name
,
$this
->
re
gistry
);
}
/**
...
...
@@ -93,6 +98,11 @@ class Container {
* Singletons will only be instantiated the first time they are resolved. On subsequent
* requests for the object, the original instance will be returned.
*
* <code>
* // Register a dependency in the container as a singleton
* IoC::singleton('something', function($container) {return new Something;});
* </code>
*
* @param string $name
* @param Closure $resolver
* @return void
...
...
@@ -108,6 +118,13 @@ class Container {
* This method allows you to register an already existing object instance with the
* container as a singleton instance.
*
* <code>
* // Register an instance with the IoC container
* $something = new Something;
*
* IoC::instance('something', $something);
* </code>
*
* @param string $name
* @param mixed $instance
* @return void
...
...
@@ -122,6 +139,11 @@ class Container {
*
* The dependency's resolver will be called and its result will be returned.
*
* <code>
* // Get the "something" dependency out of the IoC container
* $something = IoC::resolve('something');
* </code>
*
* @param string $name
* @return mixed
*/
...
...
@@ -134,26 +156,25 @@ class Container {
throw
new
\Exception
(
"Error resolving [
$name
]. No resolver has been registered in the container."
);
}
$object
=
call_user_func
(
$this
->
re
solvers
[
$name
][
'resolver'
],
$this
);
$object
=
call_user_func
(
$this
->
re
gistry
[
$name
][
'resolver'
],
$this
);
if
(
$this
->
resolvers
[
$name
][
'singleton'
])
$this
->
singletons
[
$name
]
=
$object
;
return
$object
;
return
(
isset
(
$this
->
registry
[
$name
][
'singleton'
]))
?
$this
->
singletons
[
$name
]
=
$object
:
$object
;
}
/**
* Magic Method for resolving classes out of the IoC container.
*
* <code>
* // Get the "something" instance out of the IoC container
* $something = IoC::container()->something;
*
* // Equivalent method of retrieving the instance using the resolve method
* $something = IoC::container()->resolve('something');
* </code>
*/
public
function
__get
(
$key
)
{
if
(
$this
->
registered
(
'laravel.'
.
$key
))
{
return
$this
->
resolve
(
'laravel.'
.
$key
);
}
elseif
(
$this
->
registered
(
$key
))
{
return
$this
->
resolve
(
$key
);
}
if
(
$this
->
registered
(
$key
))
return
$this
->
resolve
(
$key
);
throw
new
\Exception
(
"Attempting to resolve undefined class [
$key
]."
);
}
...
...
laravel/controller.php
View file @
abc1fad6
...
...
@@ -2,13 +2,6 @@
abstract
class
Controller
{
/**
* The IoC container instance.
*
* @var Container
*/
public
$container
;
/**
* A stub method that will be called before every request to the controller.
*
...
...
@@ -28,15 +21,26 @@ abstract class Controller {
*/
public
function
__call
(
$method
,
$parameters
)
{
return
$this
->
container
->
resolve
(
'laravel.response'
)
->
error
(
'404'
);
return
IoC
::
container
()
->
resolve
(
'laravel.response'
)
->
error
(
'404'
);
}
/**
*
Magic Method for retrieving items out of the
IoC container.
*
Dynamically resolve items from the application
IoC container.
*/
public
function
__get
(
$key
)
{
return
$this
->
container
->
$key
;
$container
=
IoC
::
container
();
if
(
$container
->
registered
(
'laravel.'
.
$key
))
{
return
$container
->
resolve
(
'laravel.'
.
$key
);
}
elseif
(
$container
->
registered
(
$key
))
{
return
$container
->
resolve
(
$key
);
}
throw
new
\Exception
(
"Attempting to access undefined property [
$key
] on controller."
);
}
}
\ No newline at end of file
laravel/cookie.php
View file @
abc1fad6
...
...
@@ -7,7 +7,7 @@ class Cookie {
*
* @var array
*/
pr
ivate
$cookies
;
pr
otected
$cookies
;
/**
* Create a new cookie manager instance.
...
...
@@ -34,6 +34,14 @@ class Cookie {
/**
* Get the value of a cookie.
*
* <code>
* // Get the value of a cookie
* $value = Cookie::get('color');
*
* // Get the value of a cookie and return "blue" if the cookie doesn't exist
* $value = Cookie::get('color', 'blue');
* </code>
*
* @param string $name
* @param mixed $default
* @return string
...
...
@@ -60,8 +68,9 @@ class Cookie {
}
/**
* Set the value of a cookie. If a negative number of minutes is
* specified, the cookie will be deleted.
* Set the value of a cookie.
*
* If a negative number of minutes is specified, the cookie will be deleted.
*
* @param string $name
* @param string $value
...
...
@@ -74,9 +83,11 @@ class Cookie {
*/
public
function
put
(
$name
,
$value
,
$minutes
=
0
,
$path
=
'/'
,
$domain
=
null
,
$secure
=
false
,
$http_only
=
false
)
{
if
(
$minutes
<
0
)
unset
(
$_COOKIE
[
$name
]);
if
(
$minutes
<
0
)
unset
(
$this
->
cookies
[
$name
]);
$time
=
(
$minutes
!=
0
)
?
time
()
+
(
$minutes
*
60
)
:
0
;
return
setcookie
(
$name
,
$value
,
(
$minutes
!=
0
)
?
time
()
+
(
$minutes
*
60
)
:
0
,
$path
,
$domain
,
$secure
,
$http_only
);
return
setcookie
(
$name
,
$value
,
$time
,
$path
,
$domain
,
$secure
,
$http_only
);
}
/**
...
...
laravel/download.php
deleted
100644 → 0
View file @
03654fc5
<?php
namespace
Laravel
;
class
Download
extends
Response
{
/**
* The file engine instance.
*
* @var File
*/
protected
$file
;
/**
* Create a new download engine instance.
*
* @param File $file
* @return void
*/
public
function
__construct
(
File
$file
)
{
$this
->
file
=
$file
;
}
/**
* Create a new download response instance.
*
* @param string $path
* @param string $name
* @param array $headers
* @return Response
*/
public
function
of
(
$path
,
$name
=
null
,
$headers
=
array
())
{
if
(
is_null
(
$name
))
$name
=
basename
(
$path
);
$headers
=
array_merge
(
array
(
'Content-Description'
=>
'File Transfer'
,
'Content-Type'
=>
$this
->
mime
(
$this
->
file
->
extension
(
$path
)),
'Content-Disposition'
=>
'attachment; filename="'
.
$name
.
'"'
,
'Content-Transfer-Encoding'
=>
'binary'
,
'Expires'
=>
0
,
'Cache-Control'
=>
'must-revalidate, post-check=0, pre-check=0'
,
'Pragma'
=>
'public'
,
'Content-Length'
=>
$this
->
file
-
size
(
$path
),
),
$headers
);
$response
=
parent
::
__construct
(
$this
->
file
->
get
(
$path
),
200
,
$headers
);
return
$response
;
}
}
\ No newline at end of file
laravel/facades.php
View file @
abc1fad6
...
...
@@ -15,28 +15,31 @@ abstract class Facade {
*/
public
static
function
__callStatic
(
$method
,
$parameters
)
{
return
call_user_func_array
(
array
(
IoC
::
container
()
->
resolve
(
'laravel.'
.
static
::
$resolve
),
$method
),
$parameters
);
return
call_user_func_array
(
array
(
IoC
::
container
()
->
resolve
(
static
::
$resolve
),
$method
),
$parameters
);
}
}
class
Asset
extends
Facade
{
public
static
$resolve
=
'asset'
;
}
class
Auth
extends
Facade
{
public
static
$resolve
=
'auth'
;
}
class
Cache
extends
Facade
{
public
static
$resolve
=
'cache'
;
}
class
Config
extends
Facade
{
public
static
$resolve
=
'config'
;
}
class
Cookie
extends
Facade
{
public
static
$resolve
=
'cookie'
;
}
class
Crypter
extends
Facade
{
public
static
$resolve
=
'crypter'
;
}
class
DB
extends
Facade
{
public
static
$resolve
=
'database'
;
}
class
Download
extends
Facade
{
public
static
$resolve
=
'download'
;
}
class
File
extends
Facade
{
public
static
$resolve
=
'file'
;
}
class
Form
extends
Facade
{
public
static
$resolve
=
'form'
;
}
class
Hasher
extends
Facade
{
public
static
$resolve
=
'hasher'
;
}
class
HTML
extends
Facade
{
public
static
$resolve
=
'html'
;
}
class
Input
extends
Facade
{
public
static
$resolve
=
'input'
;
}
class
Loader
extends
Facade
{
public
static
$resolve
=
'loader'
;
}
class
Package
extends
Facade
{
public
static
$resolve
=
'package'
;
}
class
Redirect
extends
Facade
{
public
static
$resolve
=
'redirect'
;
}
class
Request
extends
Facade
{
public
static
$resolve
=
'request'
;
}
class
Session
extends
Facade
{
public
static
$resolve
=
'session'
;
}
class
URL
extends
Facade
{
public
static
$resolve
=
'url'
;
}
class
Validator
extends
Facade
{
public
static
$resolve
=
'validator'
;
}
\ No newline at end of file
class
Asset
extends
Facade
{
public
static
$resolve
=
'laravel.asset'
;
}
class
Auth
extends
Facade
{
public
static
$resolve
=
'laravel.auth'
;
}
class
Cache
extends
Facade
{
public
static
$resolve
=
'laravel.cache'
;
}
class
Config
extends
Facade
{
public
static
$resolve
=
'laravel.config'
;
}
class
Cookie
extends
Facade
{
public
static
$resolve
=
'laravel.cookie'
;
}
class
Crypter
extends
Facade
{
public
static
$resolve
=
'laravel.crypter'
;
}
class
DB
extends
Facade
{
public
static
$resolve
=
'laravel.database'
;
}
class
Download
extends
Facade
{
public
static
$resolve
=
'laravel.download'
;
}
class
File
extends
Facade
{
public
static
$resolve
=
'laravel.file'
;
}
class
Form
extends
Facade
{
public
static
$resolve
=
'laravel.form'
;
}
class
Hasher
extends
Facade
{
public
static
$resolve
=
'laravel.hasher'
;
}
class
HTML
extends
Facade
{
public
static
$resolve
=
'laravel.html'
;
}
class
Input
extends
Facade
{
public
static
$resolve
=
'laravel.input'
;
}
class
Lang
extends
Facade
{
public
static
$resolve
=
'laravel.lang'
;
}
class
Loader
extends
Facade
{
public
static
$resolve
=
'laravel.loader'
;
}
class
Package
extends
Facade
{
public
static
$resolve
=
'laravel.package'
;
}
class
Redirect
extends
Facade
{
public
static
$resolve
=
'laravel.redirect'
;
}
class
Request
extends
Facade
{
public
static
$resolve
=
'laravel.request'
;
}
class
Response
extends
Facade
{
public
static
$resolve
=
'laravel.response'
;
}
class
Session
extends
Facade
{
public
static
$resolve
=
'laravel.session'
;
}
class
URL
extends
Facade
{
public
static
$resolve
=
'laravel.url'
;
}
class
Validator
extends
Facade
{
public
static
$resolve
=
'laravel.validator'
;
}
class
View
extends
Facade
{
public
static
$resolve
=
'laravel.view'
;
}
\ No newline at end of file
laravel/file.php
View file @
abc1fad6
...
...
@@ -121,9 +121,29 @@ class File {
return
filemtime
(
$path
);
}
/**
* Move an uploaded file to permanenet storage.
*
* @param string $key
* @param string $path
* @param array $files
* @return bool
*/
public
function
upload
(
$key
,
$path
,
$files
)
{
return
move_uploaded_file
(
$files
[
$key
][
'tmp_name'
],
$path
);
}
/**
* Get a file MIME type by extension.
*
* If the MIME type can't be determined, "application/octet-stream" will be returned.
*
* <code>
* // Returns 'application/x-tar'
* $mime = File::mime('path/to/file.tar');
* </code>
*
* @param string $extension
* @param string $default
* @return string
...
...
@@ -140,20 +160,28 @@ class File {
*
* The Fileinfo PHP extension will be used to determine the MIME type of the file.
*
* @param string $extension
* @param string $path
* <code>
* // Determine if a file is a JPG image
* $image = File::is('jpg', 'path/to/image.jpg');
*
* // Determine if a file is any one of an array of types
* $image = File::is(array('jpg', 'png', 'gif'), 'path/to/image.jpg');
* </code>
*
* @param array|string $extension
* @param string $path
* @return bool
*/
public
function
is
(
$extension
,
$path
)
public
function
is
(
$extension
s
,
$path
)
{
if
(
!
array_key_exists
(
$extension
,
$this
->
mimes
)
)
foreach
((
array
)
$extensions
as
$extension
)
{
throw
new
\Exception
(
"File extension [
$extension
] is unknown. Cannot determine file type."
);
}
$mime
=
finfo_file
(
finfo_open
(
FILEINFO_MIME_TYPE
),
$path
);
$mime
=
finfo_file
(
finfo_open
(
FILEINFO_MIME_TYPE
),
$path
);
if
(
isset
(
$this
->
mimes
[
$extension
])
and
in_array
((
array
)
$this
->
mimes
[
$extension
]))
return
true
;
}
return
(
is_array
(
$this
->
mimes
[
$extension
]))
?
in_array
(
$mime
,
$this
->
mimes
[
$extension
])
:
$mime
===
$this
->
mimes
[
$extension
]
;
return
false
;
}
}
\ No newline at end of file
laravel/form.php
View file @
abc1fad6
...
...
@@ -7,21 +7,21 @@ class Form {
*
* @var Request
*/
pr
ivate
$request
;
pr
otected
$request
;
/**
* The HTML writer instance.
*
* @var HTML
*/
pr
ivate
$html
;
pr
otected
$html
;
/**
* The URL generator instance.
*
* @var URL
*/
pr
ivate
$url
;
pr
otected
$url
;
/**
* All of the label names that have been created.
...
...
@@ -31,7 +31,7 @@ class Form {
*
* @var array
*/
pr
ivate
$labels
=
array
();
pr
otected
$labels
=
array
();
/**
* Create a new form writer instance.
...
...
@@ -55,6 +55,17 @@ class Form {
* containing the request method. PUT and DELETE are not supported by HTML forms, so the
* hidden field will allow us to "spoof" PUT and DELETE requests.
*
* <code>
* // Open a POST form to the current URI
* echo Form::open();
*
* // Open a POST form to a given URI
* echo Form::open('user/profile');
*
* // Open a PUT form to a given URI and add form attributes
* echo Form::open('user/profile', 'put', array('class' => 'profile'));
* </code>
*
* @param string $action
* @param string $method
* @param array $attributes
...
...
@@ -84,7 +95,7 @@ class Form {
* @param string $method
* @return string
*/
pr
ivate
function
method
(
$method
)
pr
otected
function
method
(
$method
)
{
return
strtoupper
((
$method
==
'PUT'
or
$method
==
'DELETE'
)
?
'POST'
:
$method
);
}
...
...
@@ -98,7 +109,7 @@ class Form {
* @param bool $https
* @return string
*/
pr
ivate
function
action
(
$action
,
$https
)
pr
otected
function
action
(
$action
,
$https
)
{
return
$this
->
html
->
entities
(
$this
->
url
->
to
(((
is_null
(
$action
))
?
$this
->
request
->
uri
()
:
$action
),
$https
));
}
...
...
@@ -172,12 +183,25 @@ class Form {
*/
public
function
raw_token
()
{
if
(
IoC
::
container
()
->
resolve
(
'laravel.config'
)
->
get
(
'session.driver'
)
==
''
)
{
throw
new
\Exception
(
"A session driver must be specified before using CSRF tokens."
);
}
return
IoC
::
container
()
->
resolve
(
'laravel.session'
)
->
get
(
'csrf_token'
);
}
/**
* Create a HTML label element.
*
* <code>
* // Create a form label
* echo Form::label('email', 'E-Mail Address');
*
* // Create a form label with attributes
* echo Form::label('email', 'E-Mail Address', array('class' => 'login'));
* </code>
*
* @param string $name
* @param string $value
* @param array $attributes
...
...
@@ -196,6 +220,17 @@ class Form {
* If an ID attribute is not specified and a label has been generated matching the input
* element name, the label name will be used as the element ID.
*
* <code>
* // Create a "text" type input element
* echo Form::input('text', 'email');
*
* // Create an input element with a specified value
* echo Form::input('text', 'email', 'example@gmail.com');
*
* // Create an input element with attributes
* echo Form::input('text', 'email', 'example@gmail.com', array('class' => 'login'));
* </code>
*
* @param string $name
* @param mixed $value
* @param array $attributes
...
...
@@ -203,6 +238,8 @@ class Form {
*/
public
function
input
(
$type
,
$name
,
$value
=
null
,
$attributes
=
array
())
{
$name
=
(
isset
(
$attributes
[
'name'
]))
?
$attributes
[
'name'
]
:
$name
;
$id
=
$this
->
id
(
$name
,
$attributes
);
return
'<input'
.
$this
->
html
->
attributes
(
array_merge
(
$attributes
,
compact
(
'type'
,
'name'
,
'value'
,
'id'
)))
.
'>'
.
PHP_EOL
;
...
...
@@ -326,6 +363,14 @@ class Form {
/**
* Create a HTML textarea element.
*
* <code>
* // Create a textarea element
* echo Form::textarea('comment');
*
* // Create a textarea with specified rows and columns
* echo Form::textarea('comment', '', array('rows' => 10, 'columns' => 50));
* </code>
*
* @param string $name
* @param string $value
* @param array $attributes
...
...
@@ -345,6 +390,14 @@ class Form {
/**
* Create a HTML select element.
*
* <code>
* // Create a selection element
* echo Form::select('sizes', array('S' => 'Small', 'L' => 'Large'));
*
* // Create a selection element with a given option pre-selected
* echo Form::select('sizes', array('S' => 'Small', 'L' => 'Large'), 'L');
* </code>
*
* @param string $name
* @param array $options
* @param string $selected
...
...
@@ -370,13 +423,21 @@ class Form {
/**
* Create a HTML checkbox input element.
*
* <code>
* // Create a checkbox element
* echo Form::checkbox('terms');
*
* // Create a checkbox element that is checked by default
* echo Form::checkbox('terms', 'yes', true);
* </code>
*
* @param string $name
* @param string $value
* @param bool $checked
* @param array $attributes
* @return string
*/
public
function
checkbox
(
$name
,
$value
=
null
,
$checked
=
false
,
$attributes
=
array
())
public
function
checkbox
(
$name
,
$value
=
1
,
$checked
=
false
,
$attributes
=
array
())
{
return
$this
->
checkable
(
'checkbox'
,
$name
,
$value
,
$checked
,
$attributes
);
}
...
...
@@ -384,6 +445,14 @@ class Form {
/**
* Create a HTML radio button input element.
*
* <code>
* // Create a radio button element
* echo Form::radio('apple');
*
* // Create a radio button element that is selected by default
* echo Form::radio('microsoft', 'pc', true);
* </code>
*
* @param string $name
* @param string $value
* @param bool $checked
...
...
@@ -392,6 +461,8 @@ class Form {
*/
public
function
radio
(
$name
,
$value
=
null
,
$checked
=
false
,
$attributes
=
array
())
{
if
(
is_null
(
$value
))
$value
=
$name
;
return
$this
->
checkable
(
'radio'
,
$name
,
$value
,
$checked
,
$attributes
);
}
...
...
@@ -405,7 +476,7 @@ class Form {
* @param array $attributes
* @return string
*/
pr
ivate
function
checkable
(
$type
,
$name
,
$value
,
$checked
,
$attributes
)
pr
otected
function
checkable
(
$type
,
$name
,
$value
,
$checked
,
$attributes
)
{
$attributes
=
array_merge
(
$attributes
,
array
(
'id'
=>
$this
->
id
(
$name
,
$attributes
),
'checked'
=>
(
$checked
)
?
'checked'
:
null
));
...
...
@@ -415,6 +486,14 @@ class Form {
/**
* Create a HTML submit input element.
*
* <code>
* // Create a submit input element
* echo Form::submit('Login!');
*
* // Create a submit input element with attributes
* echo Form::submit('Login!', array('class' => 'login'));
* </code>
*
* @param string $value
* @param array $attributes
* @return string
...
...
@@ -439,6 +518,11 @@ class Form {
/**
* Create a HTML image input element.
*
* <code>
* // Create an image input element
* echo Form::image('img/login.jpg');
* </code>
*
* @param string $url
* @param array $attributes
* @return string
...
...
@@ -453,6 +537,14 @@ class Form {
/**
* Create a HTML button element.
*
* <code>
* // Create a button input element
* echo Form::button('Login!');
*
* // Create a button input element with attributes
* echo Form::button('Login!', array('class' => 'login'));
* </code>
*
* @param string $name
* @param string $value
* @param array $attributes
...
...
@@ -473,7 +565,7 @@ class Form {
* @param array $attributes
* @return mixed
*/
pr
ivate
function
id
(
$name
,
$attributes
)
pr
otected
function
id
(
$name
,
$attributes
)
{
if
(
array_key_exists
(
'id'
,
$attributes
))
return
$attributes
[
'id'
];
...
...
laravel/html.php
View file @
abc1fad6
...
...
@@ -44,6 +44,14 @@ class HTML {
/**
* Generate a JavaScript reference.
*
* <code>
* // Generate a link to a JavaScript file
* echo HTML::script('js/jquery.js');
*
* // Generate a link to a JavaScript file with attributes
* echo HTML::script('js/jquery.js', array('defer'));
* </code>
*
* @param string $url
* @param array $attributes
* @return string
...
...
@@ -58,6 +66,16 @@ class HTML {
/**
* Generate a CSS reference.
*
* If no media type is selected, "all" will be used.
*
* <code>
* // Generate a link to a CSS file
* echo HTML::style('css/common.css');
*
* // Generate a link to a CSS file with attributes
* echo HTML::style('css/common.css', array('media' => 'print'));
* </code>
*
* @param string $url
* @param array $attributes
* @return string
...
...
@@ -74,6 +92,14 @@ class HTML {
/**
* Generate a HTML span.
*
* <code>
* // Generate a HTML span element
* echo HTML::span('This is inside a span element.');
*
* // Generate a HTML span element with attributes
* echo HTML::span('This is inside a span.', array('class' => 'text'));
* </code>
*
* @param string $value
* @param array $attributes
* @return string
...
...
@@ -86,6 +112,14 @@ class HTML {
/**
* Generate a HTML link.
*
* <code>
* // Generate a HTML link element
* echo HTML::link('user/profile', 'User Profile');
*
* // Generate a HTML link element with attributes
* echo HTML::link('user/profile', 'User Profile', array('class' => 'profile'));
* </code>
*
* @param string $url
* @param string $title
* @param array $attributes
...
...
@@ -116,6 +150,8 @@ class HTML {
/**
* Generate an HTML link to an asset.
*
* The application index page will not be added to asset links.
*
* @param string $url
* @param string $title
* @param array $attributes
...
...
@@ -144,6 +180,15 @@ class HTML {
*
* An array of parameters may be specified to fill in URI segment wildcards.
*
* <code>
* // Generate a link to the "profile" route
* echo HTML::link_to_route('profile', 'User Profile');
*
* // Generate a link to a route that has wildcard segments
* // Example: /user/profile/(:any)
* echo HTML::link_to_route('profile', 'User Profile', array($username));
* </code>
*
* @param string $name
* @param string $title
* @param array $parameters
...
...
@@ -174,6 +219,17 @@ class HTML {
*
* The E-Mail address will be obfuscated to protect it from spam bots.
*
* <code>
* // Generate a HTML mailto link
* echo HTML::mailto('example@gmail.com');
*
* // Generate a HTML mailto link with a title
* echo HTML::mailto('example@gmail.com', 'E-Mail Me!');
*
* // Generate a HTML mailto link with attributes
* echo HTML::mailto('example@gmail.com', 'E-Mail Me', array('class' => 'email'));
* </code>
*
* @param string $email
* @param string $title
* @param array $attributes
...
...
@@ -202,7 +258,18 @@ class HTML {
}
/**
* Generate an HTML image.
* Generate an HTML image element.
*
* <code>
* // Generate a HTML image element
* echo HTML::image('img/profile.jpg');
*
* // Generate a HTML image element with Alt text
* echo HTML::image('img/profile.jpg', 'Profile Photo');
*
* // Generate a HTML image element with attributes
* echo HTML::image('img/profile.jpg', 'Profile Photo', array('class' => 'profile'));
* </code>
*
* @param string $url
* @param string $alt
...
...
@@ -217,7 +284,15 @@ class HTML {
}
/**
* Generate an ordered list.
* Generate an ordered list of items.
*
* <code>
* // Generate an ordered list of items
* echo HTML::ol(array('Small', 'Medium', 'Large'));
*
* // Generate an ordered list of items with attributes
* echo HTML::ol(array('Small', 'Medium', 'Large'), array('class' => 'sizes'));
* </code>
*
* @param array $list
* @param array $attributes
...
...
@@ -229,7 +304,15 @@ class HTML {
}
/**
* Generate an un-ordered list.
* Generate an un-ordered list of items.
*
* <code>
* // Generate an un-ordered list of items
* echo HTML::ul(array('Small', 'Medium', 'Large'));
*
* // Generate an un-ordered list of items with attributes
* echo HTML::ul(array('Small', 'Medium', 'Large'), array('class' => 'sizes'));
* </code>
*
* @param array $list
* @param array $attributes
...
...
@@ -261,7 +344,12 @@ class HTML {
}
/**
* Build a list of HTML attributes.
* Build a list of HTML attributes from an array.
*
* <code>
* // Returns: class="profile" id="picture"
* echo HTML::attributes(array('class' => 'profile', 'id' => 'picture'));
* </code>
*
* @param array $attributes
* @return string
...
...
laravel/inflector.php
View file @
abc1fad6
...
...
@@ -86,14 +86,14 @@ class Inflector {
* @var array
*/
private
static
$irregular
=
array
(
'
move'
=>
'moves
'
,
'
child'
=>
'children
'
,
'foot'
=>
'feet'
,
'goose'
=>
'geese'
,
'sex'
=>
'sexes'
,
'child'
=>
'children'
,
'man'
=>
'men'
,
'
tooth'
=>
'teeth
'
,
'
move'
=>
'moves
'
,
'person'
=>
'people'
,
'sex'
=>
'sexes'
,
'tooth'
=>
'teeth'
,
);
/**
...
...
@@ -102,20 +102,29 @@ class Inflector {
* @var array
*/
private
static
$uncountable
=
array
(
'
sheep
'
,
'
fish
'
,
'
equipment
'
,
'
data
'
,
'deer'
,
'
series
'
,
'
species
'
,
'
fish
'
,
'
information
'
,
'money'
,
'rice'
,
'information'
,
'equipment'
,
'series'
,
'sheep'
,
'species'
,
);
/**
* Get the plural form of a word if the specified count is greater than one.
*
* <code>
* // Returns "friend"
* echo Inflector::plural_if('friend', 1);
*
* // Returns "friends"
* echo Inflector::plural_if('friend', 2);
* </code>
*
* @param string $value
* @param int $count
* @return string
...
...
laravel/input.php
View file @
abc1fad6
...
...
@@ -10,18 +10,18 @@ class Input {
protected
$input
;
/**
* The $_
GET
array for the request.
* The $_
FILES
array for the request.
*
* @var array
*/
p
ublic
$get
;
p
rotected
$files
;
/**
* The
$_POST array for the request
.
* The
file manager instance
.
*
* @var
array
* @var
File
*/
p
ublic
$post
;
p
rotected
$file
;
/**
* The cookie engine instance.
...
...
@@ -30,23 +30,17 @@ class Input {
*/
public
$cookies
;
/**
* The $_FILES array for the request.
*
* @var array
*/
public
$files
;
/**
* Create a new Input instance.
*
* @param Cookie $cookies
* @param array $input
* @param array $files
* @param Cookie $cookies
* @return void
*/
public
function
__construct
(
$input
,
$files
,
Cookie
$cooki
es
)
public
function
__construct
(
File
$file
,
Cookie
$cookies
,
$input
,
$fil
es
)
{
$this
->
file
=
$file
;
$this
->
input
=
$input
;
$this
->
files
=
$files
;
$this
->
cookies
=
$cookies
;
...
...
@@ -80,6 +74,14 @@ class Input {
*
* This method should be used for all request methods (GET, POST, PUT, and DELETE).
*
* <code>
* // Get an item from the input to the application
* $value = Input::get('name');
*
* // Get an item from the input and return "Fred" if the item doesn't exist
* $value = Input::get('name', 'Fred');
* </code>
*
* @param string $key
* @param mixed $default
* @return mixed
...
...
@@ -103,12 +105,25 @@ class Input {
/**
* Get input data from the previous request.
*
* <code>
* // Get an item from the previous request's input
* $value = Input::old('name');
*
* // Get an item from the previous request's input and return "Fred" if it doesn't exist.
* $value = Input::old('name', 'Fred');
* </code>
*
* @param string $key
* @param mixed $default
* @return string
*/
public
function
old
(
$key
=
null
,
$default
=
null
)
{
if
(
IoC
::
container
()
->
resolve
(
'laravel.config'
)
->
get
(
'session.driver'
)
==
''
)
{
throw
new
\Exception
(
'A session driver must be specified in order to access old input.'
);
}
$driver
=
IoC
::
container
()
->
resolve
(
'laravel.session'
);
return
Arr
::
get
(
$driver
->
get
(
'laravel_old_input'
,
array
()),
$key
,
$default
);
...
...
@@ -119,6 +134,14 @@ class Input {
*
* "Dot" syntax may be used to get a specific item from the file array.
*
* <code>
* // Get the array of information regarding an uploaded file
* $file = Input::file('picture');
*
* // Get an element from the array of information regarding an uploaded file
* $size = Input::file('picture.size');
* </code>
*
* @param string $key
* @param mixed $default
* @return array
...
...
@@ -133,13 +156,18 @@ class Input {
*
* This method is simply a convenient wrapper around move_uploaded_file.
*
* <code>
* // Move the "picture" file to a permament location on disk
* Input::upload('picture', PUBLIC_PATH.'img/picture.jpg');
* </code>
*
* @param string $key
* @param string $path
* @return bool
*/
public
function
upload
(
$key
,
$path
)
{
return
array_key_exists
(
$key
,
$this
->
files
)
?
move_uploaded_file
(
$this
->
files
[
$key
][
'tmp_name'
],
$path
)
:
false
;
return
array_key_exists
(
$key
,
$this
->
files
)
?
$this
->
file
->
upload
(
$key
,
$path
,
$this
->
files
)
:
false
;
}
/**
...
...
laravel/lang.php
View file @
abc1fad6
...
...
@@ -35,6 +35,14 @@ class Lang_Factory {
/**
* Begin retrieving a language line.
*
* <code>
* // Begin retrieving a language line
* $lang = Lang::line('messages.welcome');
*
* // Begin retrieving a language line with replacements
* $lang = Lang::line('validation.required', array('attribute' => 'email'));
* </code>
*
* @param string $key
* @param array $replacements
* @return Lang
...
...
@@ -55,35 +63,35 @@ class Lang {
*
* @var array
*/
pr
ivate
static
$lines
=
array
();
pr
otected
static
$lines
=
array
();
/**
* The key of the language line being retrieved.
*
* @var string
*/
pr
ivate
$key
;
pr
otected
$key
;
/**
* The replacements that should be made on the language line.
*
* @var array
*/
pr
ivate
$replacements
;
pr
otected
$replacements
;
/**
* The
default language being used by the application
.
* The
language in which the line should be retrieved
.
*
* @var string
*/
pr
ivate
$language
;
pr
otected
$language
;
/**
* The paths containing the language files.
*
* @var array
*/
pr
ivate
$paths
;
pr
otected
$paths
;
/**
* Create a new Lang instance.
...
...
@@ -102,28 +110,30 @@ class Lang {
$this
->
replacements
=
$replacements
;
}
/**
* Create a new Lang instance.
*
* @param string $key
* @param array $replacements
* @return Lang
*/
public
static
function
line
(
$key
,
$replacements
=
array
())
{
return
IoC
::
container
()
->
resolve
(
'laravel.lang'
)
->
line
(
$key
,
$replacements
);
}
/**
* Get the language line.
*
* A default value may also be specified, which will be returned in the language line doesn't exist.
*
* <code>
* // Retrieve a language line in the default language
* echo Lang::line('validation.required')->get();
*
* // Retrieve a language line for a given language
* echo Lang::line('validation.required')->get('sp');
*
* // Retrieve a language line and return "Fred" if it doesn't exist
* echo Lang::line('validation.required')->get('en', 'Fred');
* </code>
*
* @param string $language
* @param string $default
* @return string
*/
public
function
get
(
$default
=
null
)
public
function
get
(
$
language
=
null
,
$
default
=
null
)
{
if
(
!
is_null
(
$language
))
$this
->
language
=
$language
;
list
(
$file
,
$line
)
=
$this
->
parse
(
$this
->
key
);
if
(
!
$this
->
load
(
$file
))
...
...
@@ -151,7 +161,7 @@ class Lang {
* @param string $key
* @return array
*/
pr
ivate
function
parse
(
$key
)
pr
otected
function
parse
(
$key
)
{
if
(
count
(
$segments
=
explode
(
'.'
,
$key
))
>
1
)
{
...
...
@@ -169,7 +179,7 @@ class Lang {
* @param string $file
* @return bool
*/
pr
ivate
function
load
(
$file
)
pr
otected
function
load
(
$file
)
{
if
(
isset
(
static
::
$lines
[
$this
->
language
.
$file
]))
return
;
...
...
@@ -188,20 +198,6 @@ class Lang {
return
isset
(
static
::
$lines
[
$this
->
language
.
$file
]);
}
/**
* Set the language the line should be returned in.
*
* The language specified in this method should correspond to a language directory in your application.
*
* @param string $language
* @return Lang
*/
public
function
in
(
$language
)
{
$this
->
language
=
$language
;
return
$this
;
}
/**
* Get the string content of the language line.
*/
...
...
laravel/laravel.php
View file @
abc1fad6
...
...
@@ -6,63 +6,53 @@
require
'bootstrap.php'
;
// --------------------------------------------------------------
//
Set the error reporting and display levels
.
//
Get an instance of the configuration manager
.
// --------------------------------------------------------------
error_reporting
(
-
1
);
ini_set
(
'display_errors'
,
'Off'
);
$config
=
$container
->
resolve
(
'laravel.config'
);
// --------------------------------------------------------------
// Register the error / exception handlers.
// --------------------------------------------------------------
set_exception_handler
(
function
(
$e
)
use
(
$container
)
set_exception_handler
(
function
(
$e
)
use
(
$config
)
{
call_user_func
(
$con
tainer
->
con
fig
->
get
(
'error.handler'
),
$e
);
call_user_func
(
$config
->
get
(
'error.handler'
),
$e
);
});
set_error_handler
(
function
(
$number
,
$error
,
$file
,
$line
)
use
(
$con
tainer
)
set_error_handler
(
function
(
$number
,
$error
,
$file
,
$line
)
use
(
$con
fig
)
{
$exception
=
new
\ErrorException
(
$error
,
$number
,
0
,
$file
,
$line
);
call_user_func
(
$con
tainer
->
con
fig
->
get
(
'error.handler'
),
$exception
);
call_user_func
(
$config
->
get
(
'error.handler'
),
$exception
);
});
register_shutdown_function
(
function
()
use
(
$con
tainer
)
register_shutdown_function
(
function
()
use
(
$con
fig
)
{
if
(
!
is_null
(
$error
=
error_get_last
()))
{
$exception
=
new
\ErrorException
(
$error
[
'message'
],
$error
[
'type'
],
0
,
$error
[
'file'
],
$error
[
'line'
]);
call_user_func
(
$con
tainer
->
con
fig
->
get
(
'error.handler'
),
$exception
);
call_user_func
(
$config
->
get
(
'error.handler'
),
$exception
);
}
});
// --------------------------------------------------------------
// Set the
default timezone
.
// Set the
error reporting and display levels
.
// --------------------------------------------------------------
date_default_timezone_set
(
$container
->
config
->
get
(
'application.timezone'
));
error_reporting
(
-
1
);
ini_set
(
'display_errors'
,
'Off'
);
// --------------------------------------------------------------
//
Load the session and session manager
.
//
Set the default timezone
.
// --------------------------------------------------------------
if
(
$container
->
config
->
get
(
'session.driver'
)
!==
''
)
{
$cookie
=
$container
->
input
->
cookies
->
get
(
'laravel_session'
);
$container
->
session
->
start
(
$cookie
,
$container
->
config
->
get
(
'session.lifetime'
));
}
date_default_timezone_set
(
$config
->
get
(
'application.timezone'
));
// --------------------------------------------------------------
// Load the
packages that are in the auto-loaded packages array
.
// Load the
session and session manager
.
// --------------------------------------------------------------
$packages
=
$container
->
config
->
get
(
'application.packages'
);
if
(
count
(
$packages
)
>
0
)
if
(
$config
->
get
(
'session.driver'
)
!==
''
)
{
$container
->
package
->
load
(
$packages
);
}
$cookie
=
$container
->
resolve
(
'laravel.input'
)
->
cookies
->
get
(
'laravel_session'
);
unset
(
$packages
);
$container
->
resolve
(
'laravel.session'
)
->
start
(
$cookie
,
$config
->
get
(
'session'
));
}
// --------------------------------------------------------------
// Route the request and get the response from the route.
...
...
@@ -71,13 +61,11 @@ $route = $container->resolve('laravel.routing.router')->route();
if
(
!
is_null
(
$route
))
{
$route
->
filters
=
require
APP_PATH
.
'filters'
.
EXT
;
$response
=
$container
->
resolve
(
'laravel.routing.caller'
)
->
call
(
$route
);
}
else
{
$response
=
$container
->
res
ponse
->
error
(
'404'
);
$response
=
$container
->
res
olve
(
'laravel.response'
)
->
error
(
'404'
);
}
// --------------------------------------------------------------
...
...
@@ -88,9 +76,9 @@ $response->content = $response->render();
// --------------------------------------------------------------
// Close the session.
// --------------------------------------------------------------
if
(
$con
tainer
->
con
fig
->
get
(
'session.driver'
)
!==
''
)
if
(
$config
->
get
(
'session.driver'
)
!==
''
)
{
$container
->
session
->
close
(
$container
->
input
,
$container
->
config
->
get
(
'session
'
));
$container
->
resolve
(
'laravel.session'
)
->
close
(
$container
->
resolve
(
'laravel.input
'
));
}
// --------------------------------------------------------------
...
...
laravel/loader.php
View file @
abc1fad6
...
...
@@ -3,35 +3,34 @@
class
Loader
{
/**
* The paths t
o
be searched by the loader.
* The paths t
hat will
be searched by the loader.
*
* @var array
*/
p
rotected
$paths
;
p
ublic
$paths
;
/**
*
All of the class aliases
.
*
The class aliases defined for the application
.
*
* @var array
*/
p
rotected
$aliases
;
p
ublic
$aliases
;
/**
*
Bootstrap the auto-loader
.
*
Create a new class loader instance
.
*
* @param array $paths
* @param array $aliases
* @return void
*/
public
function
__construct
(
$
aliases
,
$path
s
)
public
function
__construct
(
$
paths
,
$aliase
s
)
{
$this
->
paths
=
$paths
;
$this
->
aliases
=
$aliases
;
}
/**
* Load a class file for a given class name.
*
* This function is registered on the SPL auto-loader stack by the front controller during each request.
* All Laravel class names follow a namespace to directory convention.
* Load the file for a given class.
*
* @param string $class
* @return void
...
...
@@ -45,9 +44,9 @@ class Loader {
return
class_alias
(
$this
->
aliases
[
$class
],
$class
);
}
foreach
(
$this
->
paths
as
$
directory
)
foreach
(
$this
->
paths
as
$
path
)
{
if
(
file_exists
(
$path
=
$
directory
.
$file
.
EXT
))
if
(
file_exists
(
$path
=
$
path
.
$file
.
EXT
))
{
require_once
$path
;
...
...
@@ -56,39 +55,4 @@ class Loader {
}
}
/**
* Register a path with the auto-loader.
*
* After registering the path, it will be checked similarly to the models and libraries directories.
*
* @param string $path
* @return void
*/
public
function
register_path
(
$path
)
{
$this
->
paths
[]
=
rtrim
(
$path
,
'/'
)
.
'/'
;
}
/**
* Register an alias with the auto-loader.
*
* @param array $alias
* @return void
*/
public
function
register_alias
(
$alias
)
{
$this
->
aliases
=
array_merge
(
$this
->
aliases
,
$alias
);
}
/**
* Remove an alias from the auto-loader's list of aliases.
*
* @param string $alias
* @return void
*/
public
function
forget_alias
(
$alias
)
{
unset
(
$this
->
aliases
[
$alias
]);
}
}
\ No newline at end of file
laravel/package.php
deleted
100644 → 0
View file @
03654fc5
<?php
namespace
Laravel
;
class
Package
{
/**
* All of the loaded packages.
*
* @var array
*/
private
$loaded
=
array
();
/**
* Load a package or set of packages.
*
* The package name should correspond to a package directory for your application.
*
* @param string|array $packages
* @param string $path
* @return void
*/
public
function
load
(
$packages
,
$path
)
{
foreach
((
array
)
$packages
as
$package
)
{
if
(
!
$this
->
loaded
(
$package
)
and
file_exists
(
$bootstrap
=
$path
.
$package
.
'/bootstrap'
.
EXT
))
{
require
$bootstrap
;
}
$this
->
loaded
[]
=
$package
;
}
}
/**
* Determine if a given package has been loaded.
*
* @param string $package
* @return bool
*/
public
function
loaded
(
$package
)
{
return
array_key_exists
(
$package
,
$this
->
loaded
);
}
}
\ No newline at end of file
laravel/redirect.php
View file @
abc1fad6
...
...
@@ -12,7 +12,7 @@ class Redirect extends Response {
/**
* Create a new redirect generator instance.
*
* @param URL
$url
* @param URL $url
* @return void
*/
public
function
__construct
(
URL
$url
)
...
...
@@ -23,39 +23,41 @@ class Redirect extends Response {
/**
* Create a redirect response.
*
* <code>
* // Create a redirect response to a given URL
* return Redirect::to('user/profile');
*
* // Create a redirect with a given status code
* return Redirect::to('user/profile', 301);
* </code>
*
* @param string $url
* @param int $status
* @param string $method
* @param bool $https
* @return Redirect
*/
public
function
to
(
$url
,
$status
=
302
,
$
method
=
'location'
,
$
https
=
false
)
public
function
to
(
$url
,
$status
=
302
,
$https
=
false
)
{
$url
=
$this
->
url
->
to
(
$url
,
$https
);
parent
::
__construct
(
''
,
$status
);
if
(
$method
==
'location'
)
{
return
$this
->
header
(
'Refresh'
,
'0;url='
.
$url
);
}
else
{
return
$this
->
header
(
'Location'
,
$url
);
}
return
$this
->
header
(
'Location'
,
$this
->
url
->
to
(
$url
,
$https
));
}
/**
* Create a redirect response to a HTTPS URL.
*
* <code>
* // Create a redirect response to a HTTPS URL
* return Redirect::to_secure('user/profile');
* </code>
*
* @param string $url
* @param int $status
* @param string $method
* @return Response
*/
public
function
to_secure
(
$url
,
$status
=
302
,
$method
=
'location'
)
public
function
to_secure
(
$url
,
$status
=
302
)
{
return
$this
->
to
(
$url
,
$status
,
$method
,
true
);
return
$this
->
to
(
$url
,
$status
,
true
);
}
/**
...
...
@@ -69,6 +71,11 @@ class Redirect extends Response {
*/
public
function
with
(
$key
,
$value
)
{
if
(
IoC
::
container
()
->
resolve
(
'laravel.config'
)
->
get
(
'session.driver'
)
==
''
)
{
throw
new
\Exception
(
'A session driver must be set before setting flash data.'
);
}
IoC
::
container
()
->
resolve
(
'laravel.session'
)
->
flash
(
$key
,
$value
);
return
$this
;
...
...
laravel/request.php
View file @
abc1fad6
...
...
@@ -21,14 +21,14 @@ class Request {
*
* @var array
*/
pr
ivate
$post
;
pr
otected
$post
;
/**
* The base URL of the application.
*
* @var string
*/
pr
ivate
$url
;
pr
otected
$url
;
/**
* The request URI.
...
...
@@ -38,7 +38,7 @@ class Request {
*
* @var string
*/
pr
ivate
$uri
;
pr
otected
$uri
;
/**
* Create a new request instance.
...
...
laravel/response.php
View file @
abc1fad6
...
...
@@ -7,17 +7,26 @@ class Response_Factory {
*
* @var View_Factory
*/
private
$view
;
protected
$view
;
/**
* The file manager instance.
*
* @var File
*/
protected
$file
;
/**
* Create a new response factory instance.
*
* @param File $file
* @param View_Factory $view
* @param File $file
* @return void
*/
public
function
__construct
(
View_Factory
$view
)
public
function
__construct
(
View_Factory
$view
,
File
$file
)
{
$this
->
view
=
$view
;
$this
->
file
=
$file
;
}
/**
...
...
@@ -54,13 +63,39 @@ class Response_Factory {
*
* @param int $code
* @param array $data
* @return
void
* @return
Response
*/
public
function
error
(
$code
,
$data
=
array
())
{
return
new
Response
(
$this
->
view
->
make
(
'error/'
.
$code
,
$data
),
$code
);
}
/**
* Create a new download response instance.
*
* @param string $path
* @param string $name
* @param array $headers
* @return Response
*/
public
function
download
(
$path
,
$name
=
null
,
$headers
=
array
())
{
if
(
is_null
(
$name
))
$name
=
basename
(
$path
);
$headers
=
array_merge
(
array
(
'Content-Description'
=>
'File Transfer'
,
'Content-Type'
=>
$this
->
file
->
mime
(
$this
->
file
->
extension
(
$path
)),
'Content-Disposition'
=>
'attachment; filename="'
.
$name
.
'"'
,
'Content-Transfer-Encoding'
=>
'binary'
,
'Expires'
=>
0
,
'Cache-Control'
=>
'must-revalidate, post-check=0, pre-check=0'
,
'Pragma'
=>
'public'
,
'Content-Length'
=>
$this
->
file
-
size
(
$path
),
),
$headers
);
return
new
Response
(
$this
->
file
->
get
(
$path
),
200
,
$headers
);
}
}
class
Response
{
...
...
@@ -224,12 +259,4 @@ class Response {
return
$this
;
}
/**
* Magic Method for calling methods on the response factory instance.
*/
public
static
function
__callStatic
(
$method
,
$parameters
)
{
return
call_user_func_array
(
array
(
IoC
::
container
()
->
resolve
(
'laravel.response'
),
$method
),
$parameters
);
}
}
\ No newline at end of file
laravel/routing/caller.php
View file @
abc1fad6
...
...
@@ -67,7 +67,7 @@ class Caller {
return
$this
->
finish
(
$route
,
$response
);
}
return
$this
->
finish
(
$route
,
$this
->
container
->
res
ponse
->
error
(
'404'
));
return
$this
->
finish
(
$route
,
$this
->
container
->
res
olve
(
'laravel.response'
)
->
error
(
'404'
));
}
/**
...
...
laravel/routing/delegator.php
View file @
abc1fad6
...
...
@@ -49,7 +49,7 @@ class Delegator {
// an underscore are not publicly available.
if
(
is_null
(
$controller
)
or
(
$method
==
'before'
or
strncmp
(
$method
,
'_'
,
1
)
===
0
))
{
return
$this
->
container
->
res
ponse
->
error
(
'404'
);
return
$this
->
container
->
res
olve
(
'laravel.response'
)
->
error
(
'404'
);
}
$controller
->
container
=
$this
->
container
;
...
...
laravel/session/driver.php
View file @
abc1fad6
...
...
@@ -13,6 +13,13 @@ abstract class Driver {
*/
public
$session
=
array
();
/**
* The application session configuration.
*
* @var array
*/
public
$config
=
array
();
/**
* Load the session for a given session ID.
*
...
...
@@ -22,14 +29,16 @@ abstract class Driver {
* If the session has expired, a new, empty session will be generated.
*
* @param string $id
* @param
int $lifetime
* @param
array $config
* @return void
*/
public
function
start
(
$id
,
$
lifetime
)
public
function
start
(
$id
,
$
config
)
{
$this
->
config
=
$config
;
$this
->
session
=
(
!
is_null
(
$id
))
?
$this
->
load
(
$id
)
:
null
;
if
(
is_null
(
$this
->
session
)
or
(
time
()
-
$this
->
session
[
'last_activity'
])
>
(
$
lifetime
*
60
))
if
(
is_null
(
$this
->
session
)
or
(
time
()
-
$this
->
session
[
'last_activity'
])
>
(
$
this
->
config
[
'lifetime'
]
*
60
))
{
$this
->
session
=
array
(
'id'
=>
Str
::
random
(
40
),
'data'
=>
array
());
}
...
...
@@ -169,20 +178,19 @@ abstract class Driver {
* available for the next request via the "old" method on the input class.
*
* @param Laravel\Input $input
* @param array $config
* @return void
*/
public
function
close
(
Input
$input
,
$config
)
public
function
close
(
Input
$input
)
{
$this
->
flash
(
'laravel_old_input'
,
$input
->
get
())
->
age
();
$this
->
save
();
$this
->
write_cookie
(
$input
->
cookies
,
$config
);
$this
->
write_cookie
(
$input
->
cookies
,
$
this
->
config
);
if
(
$this
instanceof
Sweeper
and
mt_rand
(
1
,
100
)
<=
2
)
{
$this
->
sweep
(
time
()
-
(
$config
[
'lifetime'
]
*
60
));
$this
->
sweep
(
time
()
-
(
$
this
->
config
[
'lifetime'
]
*
60
));
}
}
...
...
@@ -214,7 +222,7 @@ abstract class Driver {
* already been sent to the browser.
*
* @param Laravel\Cookie $cookie
* @param array
$config
* @param array $config
* @return void
*/
protected
function
write_cookie
(
Cookie
$cookies
,
$config
)
...
...
laravel/str.php
View file @
abc1fad6
...
...
@@ -10,7 +10,12 @@ class Str {
*/
public
static
function
lower
(
$value
)
{
return
function_exists
(
'mb_strtolower'
)
?
mb_strtolower
(
$value
,
static
::
encoding
())
:
strtolower
(
$value
);
if
(
function_exists
(
'mb_strtolower'
))
{
return
mb_strtolower
(
$value
,
static
::
encoding
());
}
return
strtolower
(
$value
);
}
/**
...
...
@@ -21,7 +26,12 @@ class Str {
*/
public
static
function
upper
(
$value
)
{
return
function_exists
(
'mb_strtoupper'
)
?
mb_strtoupper
(
$value
,
static
::
encoding
())
:
strtoupper
(
$value
);
if
(
function_exists
(
'mb_strtoupper'
))
{
return
mb_strtoupper
(
$value
,
static
::
encoding
());
}
return
strtoupper
(
$value
);
}
/**
...
...
@@ -32,7 +42,12 @@ class Str {
*/
public
static
function
title
(
$value
)
{
return
(
function_exists
(
'mb_convert_case'
))
?
mb_convert_case
(
$value
,
MB_CASE_TITLE
,
static
::
encoding
())
:
ucwords
(
strtolower
(
$value
));
if
(
function_exists
(
'mb_convert_case'
))
{
return
mb_convert_case
(
$value
,
MB_CASE_TITLE
,
static
::
encoding
());
}
return
ucwords
(
strtolower
(
$value
));
}
/**
...
...
@@ -43,7 +58,12 @@ class Str {
*/
public
static
function
length
(
$value
)
{
return
function_exists
(
'mb_strlen'
)
?
mb_strlen
(
$value
,
static
::
encoding
())
:
strlen
(
$value
);
if
(
function_exists
(
'mb_strlen'
))
{
return
mb_strlen
(
$value
,
static
::
encoding
());
}
return
strlen
(
$value
);
}
/**
...
...
@@ -72,34 +92,11 @@ class Str {
*/
public
static
function
random
(
$length
=
16
,
$type
=
'alpha_num'
)
{
$
value
=
'
'
;
$
alpha
=
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
'
;
$pool
_length
=
strlen
(
$pool
=
static
::
pool
(
$type
))
-
1
;
$pool
=
(
$type
==
'alpha_num'
)
?
'0123456789'
.
$alpha
:
$alpha
;
for
(
$i
=
0
;
$i
<
$length
;
$i
++
)
{
$value
.=
$pool
[
mt_rand
(
0
,
$pool_length
)];
}
return
$value
;
}
/**
* Get a chracter pool.
*
* @param string $type
* @return string
*/
private
static
function
pool
(
$type
=
'alpha_num'
)
{
switch
(
$type
)
{
case
'alpha_num'
:
return
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
default
:
return
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
}
return
implode
(
''
,
array_map
(
function
()
use
(
$pool
)
{
return
$pool
[
mt_rand
(
0
,
strlen
(
$pool
)
-
1
)];
},
range
(
0
,
$length
)));
}
/**
...
...
@@ -107,7 +104,7 @@ class Str {
*
* @return string
*/
p
ublic
static
function
encoding
()
p
rotected
static
function
encoding
()
{
return
IoC
::
container
()
->
resolve
(
'laravel.config'
)
->
get
(
'application.encoding'
);
}
...
...
laravel/url.php
View file @
abc1fad6
...
...
@@ -2,13 +2,41 @@
class
URL
{
/**
* The application router instance.
*
* @var Routing\Router
*/
protected
$router
;
/**
* The base URL of the application.
*
* @var string
*/
protected
$base
;
/**
* The application index file.
*
* @var string
*/
protected
$index
;
/**
* Indicates if the current request is using HTTPS.
*
* @var bool
*/
protected
$https
;
/**
* Create a new URL writer instance.
*
* @param Router $router
* @param string $base
* @param string $index
* @param bool $https
* @param Rout
ing\Rout
er $router
* @param string
$base
* @param string
$index
* @param bool
$https
* @return void
*/
public
function
__construct
(
Routing\Router
$router
,
$base
,
$index
,
$https
)
...
...
@@ -24,6 +52,14 @@ class URL {
*
* If the given URL is already well-formed, it will be returned unchanged.
*
* <code>
* // Generate an application URL from a given URI
* echo URL::to('user/profile');
*
* // Generate an application URL with HTTPS
* echo URL::to('user/profile', true);
* </code>
*
* @param string $url
* @param bool $https
* @return string
...
...
@@ -36,12 +72,17 @@ class URL {
if
(
$https
)
$base
=
preg_replace
(
'~http://~'
,
'https://'
,
$base
,
1
);
return
rtrim
(
$base
,
'/'
)
.
'/'
.
trim
(
$url
,
'/'
);
return
rtrim
(
$base
,
'/'
)
.
'/'
.
l
trim
(
$url
,
'/'
);
}
/**
* Generate an application URL with HTTPS.
*
* <code>
* // Generate an application URL with HTTPS
* echo URL::to_secure('user/profile');
* </code>
*
* @param string $url
* @return string
*/
...
...
@@ -56,6 +97,14 @@ class URL {
* The index file will not be added to asset URLs. If the HTTPS option is not
* specified, HTTPS will be used when the active request is also using HTTPS.
*
* <code>
* // Generate a URL to an asset
* echo URL::to_asset('img/picture.jpg');
*
* // Generate a URL to a an asset with HTTPS
* echo URL::to_asset('img/picture.jpg', true);
* </code>
*
* @param string $url
* @param bool $https
* @return string
...
...
@@ -76,6 +125,14 @@ class URL {
*
* Optional parameters will be convereted to spaces if no parameter values are specified.
*
* <code>
* // Generate the URL for a given route
* echo URL::to_route('profile');
*
* // Generate the URL for a given route with wildcard segments
* echo URL::to_route('profile', array($username));
* </code>
*
* @param string $name
* @param array $parameters
* @param bool $https
...
...
@@ -103,6 +160,14 @@ class URL {
/**
* Generate a HTTPS URL from a route name.
*
* <code>
* // Generate the URL for a route with HTTPS
* echo URL::to_secure_route('profile');
*
* // Generate the URL for a route with HTTPS and wildcard segments
* echo URL::to_secure_route('profile', array($username));
* </code>
*
* @param string $name
* @param array $parameters
* @return string
...
...
@@ -134,6 +199,17 @@ class URL {
/**
* Magic Method for dynamically creating URLs to named routes.
*
* <code>
* // Generate the URL for the "profile" named route
* echo URL::to_profile();
*
* // Generate the URL for the "profile" named route with wildcard segments
* echo URL::to_profile(array($username));
*
* // Generate the URL for the "profile" named route with HTTPS
* echo URL::to_secure_profile();
* </code>
*/
public
function
__call
(
$method
,
$parameters
)
{
...
...
laravel/view.php
View file @
abc1fad6
...
...
@@ -37,6 +37,18 @@ class View_Factory {
/**
* Create a new view instance.
*
* The name of the view given to this method should correspond to a view
* within your application views directory. Dots or slashes may used to
* reference views within sub-directories.
*
* <code>
* // Create a new view instance
* $view = View::make('home.index');
*
* // Create a new view instance with bound data
* $view = View::make('home.index', array('name' => 'Fred'));
* </code>
*
* @param string $view
* @param array $data
* @return View
...
...
@@ -49,6 +61,16 @@ class View_Factory {
/**
* Create a new view instance from a view name.
*
* View names are defined in the application composers file.
*
* <code>
* // Create a new named view instance
* $view = View::of('layout');
*
* // Create a new named view instance with bound data
* $view = View::of('layout', array('name' => 'Fred'));
* </code>
*
* @param string $name
* @param array $data
* @return View
...
...
@@ -71,11 +93,30 @@ class View_Factory {
*/
protected
function
path
(
$view
)
{
return
$this
->
path
.
str_replace
(
'.'
,
'/'
,
$view
)
.
EXT
;
$view
=
str_replace
(
'.'
,
'/'
,
$view
);
if
(
file_exists
(
$path
=
$this
->
path
.
$view
.
'.blade'
.
EXT
))
{
return
$path
;
}
elseif
(
file_exists
(
$path
=
$this
->
path
.
$view
.
EXT
))
{
return
$path
;
}
throw
new
\Exception
(
'View ['
.
$view
.
'] does not exist.'
);
}
/**
* Magic Method for handling the dynamic creation of named views.
*
* <code>
* // Create an instance of the "layout" named view
* $view = View::of_layout();
*
* // Create an instance of the "layout" named view with bound data
* $view = View::of_layout(array('name' => 'Fred'));
* </code>
*/
public
function
__call
(
$method
,
$parameters
)
{
...
...
@@ -95,13 +136,6 @@ class View_Factory {
*/
class
View_Composer
{
/**
* The IoC container instance.
*
* @var Container
*/
protected
$container
;
/**
* The view composers.
*
...
...
@@ -112,13 +146,11 @@ class View_Composer {
/**
* Create a new view composer instance.
*
* @param Container $container
* @param array $composers
* @return void
*/
public
function
__construct
(
Container
$container
,
$composers
)
public
function
__construct
(
$composers
)
{
$this
->
container
=
$container
;
$this
->
composers
=
$composers
;
}
...
...
@@ -144,13 +176,13 @@ class View_Composer {
*/
public
function
compose
(
View
$view
)
{
if
(
isset
(
$this
->
composers
[
'shared'
]))
call_user_func
(
$this
->
composers
[
'shared'
],
$view
,
$this
->
container
);
if
(
isset
(
$this
->
composers
[
'shared'
]))
call_user_func
(
$this
->
composers
[
'shared'
],
$view
);
if
(
isset
(
$this
->
composers
[
$view
->
view
]))
{
foreach
((
array
)
$this
->
composers
[
$view
->
view
]
as
$key
=>
$value
)
{
if
(
$value
instanceof
\Closure
)
return
call_user_func
(
$value
,
$view
,
$this
->
container
);
if
(
$value
instanceof
\Closure
)
return
call_user_func
(
$value
,
$view
);
}
}
}
...
...
@@ -216,23 +248,6 @@ class View {
$this
->
path
=
$path
;
$this
->
factory
=
$factory
;
$this
->
composer
=
$composer
;
if
(
!
file_exists
(
$this
->
path
))
{
throw
new
\Exception
(
'View ['
.
$this
->
path
.
'] does not exist.'
);
}
}
/**
* Create a new view instance.
*
* @param string $view
* @param array $data
* @return View
*/
public
static
function
make
(
$view
,
$data
=
array
())
{
return
IoC
::
container
()
->
resolve
(
'laravel.view'
)
->
make
(
$view
,
$data
);
}
/**
...
...
@@ -254,14 +269,34 @@ class View {
ob_start
()
and
extract
(
$this
->
data
,
EXTR_SKIP
);
try
{
include
$this
->
path
;
}
catch
(
\Exception
$e
)
{
ob_get_clean
();
throw
$e
;
}
$content
=
(
$this
->
bladed
())
?
Blade
::
parse
(
$this
->
path
)
:
file_get_contents
(
$this
->
path
);
eval
(
'?>'
.
$content
);
return
ob_get_clean
();
}
/**
* Determine if the view is using the blade view engine.
*
* @return bool
*/
protected
function
bladed
()
{
return
(
strpos
(
$this
->
path
,
'.blade'
.
EXT
)
!==
false
);
}
/**
* Add a view instance to the view data.
*
* <code>
* // Bind a partial view to the view data
* $view->partial('footer', 'partials/footer');
*
* // Bind a partial view to the view data with it's own bound data
* $view->partial('footer', 'partials/footer', array('name' => 'Fred'));
* </code>
*
* @param string $key
* @param string $view
* @param array $data
...
...
@@ -277,6 +312,11 @@ class View {
*
* Bound data will be available to the view as variables.
*
* <code>
* // Bind a piece of data to a view instance
* $view->with('name', 'Fred');
* </code>
*
* @param string $key
* @param mixed $value
* @return View
...
...
public/index.php
View file @
abc1fad6
...
...
@@ -10,7 +10,14 @@
/*
|--------------------------------------------------------------------------
| Installation Paths
| Tick... Tock... Tick... Tock
|--------------------------------------------------------------------------
*/
define
(
'START_TIME'
,
microtime
(
true
));
/*
|--------------------------------------------------------------------------
| Where Am I?
|--------------------------------------------------------------------------
|
| Here you may specify the location of the various Laravel framework
...
...
@@ -36,4 +43,6 @@ $public = __DIR__;
| 3... 2... 1... Lift-off!
|--------------------------------------------------------------------------
*/
require
$laravel
.
'/laravel.php'
;
\ No newline at end of file
require
$laravel
.
'/laravel.php'
;
echo
(
microtime
(
true
)
-
START_TIME
)
*
1000
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment