Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Chris Berthe 2012-06-25 13:11:54 -04:00
commit f3d756476b
23 changed files with 320 additions and 21 deletions

View File

@ -0,0 +1,19 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Pagination Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used by the paginator library to build
| the pagination links. You're free to change them to anything you want.
| If you come up with something more exciting, let us know.
|
*/
'previous' => '→ السابق',
'next' => 'التالي ←',
);

View File

@ -0,0 +1,99 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used
| by the validator class. Some of the rules contain multiple versions,
| such as the size (max, min, between) rules. These versions are used
| for different input types such as strings and files.
|
| These language lines may be easily changed to provide custom error
| messages in your application. Error messages for custom validation
| rules may also be added to this file.
|
*/
"accepted" => "القيمة :attribute يجب أن تكون مقبولة.",
"active_url" => "القيمة :attribute تمثل عنوان موقع إنترنت غير صحيح.",
"after" => "القيمة :attribute يجب أن تكون بعد تاريخ :date.",
"alpha" => "القيمة :attribute يمكنها أن تحتوي على أحرف فقط.",
"alpha_dash" => "القيمة :attribute يمكنها أن تحتوي على أحرف و أرقام و إشارة الناقص فقط.",
"alpha_num" => "القيمة :attribute يمكنها أن تحتوي على أحرف و أرقام فقط.",
"before" => "القيمة :attribute يجب أن تكون قبل تاريخ :date.",
"between" => array(
"numeric" => "القيمة :attribute يجب أن تكون بين :min و :max.",
"file" => "الملف :attribute يجب أن يكون بحجم من :min إلى :max كيلوبايت.",
"string" => "النص :attribute يجب أن يكون بطول من :min إلى :max حرف.",
),
"confirmed" => "القيمة :attribute التأكيدية غير مطابقة.",
"different" => "القيمتان :attribute و :other يجب أن تختلفان.",
"email" => "القيمة :attribute تمثل بريد إلكتروني غير صحيح.",
"exists" => "القيمة المختارة :attribute غير موجودة.",
"image" => "القيمة :attribute يجب أن تكون صورة.",
"in" => "القيمة المختارة :attribute غير موجودة.",
"integer" => "القيمة :attribute يجب أن تكون رقماً.",
"ip" => "القيمة :attribute يجب أن تمثل عنوان بروتوكول إنترنت صحيح.",
"match" => "القيمة :attribute هي بتنسيق غير صحيح.",
"max" => array(
"numeric" => "القيمة :attribute يجب أن تكون أقل من :max.",
"file" => "الملف :attribute يجب أن يكون بحجم أقل من :max كيلوبايت.",
"string" => "النص :attribute يجب أن يكون بطول أقل من :max حرف.",
),
"mimes" => "القيمة :attribute يجب أن تكون ملف من نوع: :values.",
"min" => array(
"numeric" => "القيمة :attribute يجب أن تساوي :min على الأقل.",
"file" => "الملف :attribute يجب أن يكون بحجم :min كيلوبايت على الأقل.",
"string" => "النص :attribute يجب أن يكون بطول :min حرف على الأقل.",
),
"not_in" => "القيمة :attribute المختارة غير صحيحة.",
"numeric" => "القيمة :attribute يجب أن تكون رقماً.",
"required" => "القيمة :attribute مطلوبة.",
"same" => "القيمتان :attribute و :other يجب أن تتطابقان.",
"size" => array(
"numeric" => "القيمة :attribute يجب أن تكون بحجم :size.",
"file" => "الملف :attribute يجب أن يكون بحجم :size كيلوبايت.",
"string" => "النص :attribute يجب أن يكون بطول :size حرف.",
),
"unique" => "القيمة :attribute تم استخدامها من قبل.",
"url" => "التنسيق :attribute غير صحيح.",
/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
|--------------------------------------------------------------------------
|
| Here you may specify custom validation messages for attributes using the
| convention "attribute_rule" to name the lines. This helps keep your
| custom validation clean and tidy.
|
| So, say you want to use a custom validation message when validating that
| the "email" attribute is unique. Just add "email_unique" to this array
| with your custom message. The Validator will handle the rest!
|
*/
'custom' => array(),
/*
|--------------------------------------------------------------------------
| Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as "E-Mail Address" instead
| of "email". Your users will thank you.
|
| The Validator class will automatically search this array of lines it
| is attempting to replace the :attribute place-holder in messages.
| It's pretty slick. We think you'll like it.
|
*/
'attributes' => array(),
);

View File

@ -0,0 +1,19 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Pagination Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used by the paginator library to build
| the pagination links. You're free to change them to anything you want.
| If you come up with something more exciting, let us know.
|
*/
'previous' => '&laquo; Zur&uuml;ck',
'next' => 'Weiter &raquo;',
);

View File

@ -0,0 +1,99 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used
| by the validator class. Some of the rules contain multiple versions,
| such as the size (max, min, between) rules. These versions are used
| for different input types such as strings and files.
|
| These language lines may be easily changed to provide custom error
| messages in your application. Error messages for custom validation
| rules may also be added to this file.
|
*/
"accepted" => ":attribute muss akzeptiert werden.",
"active_url" => ":attribute ist keine g&uuml;ltige URL.",
"after" => ":attribute muss ein Datum nach dem :date sein.",
"alpha" => ":attribute darf nur Buchstaben beinhalten.",
"alpha_dash" => ":attribute sollte nur aus Buchstaben, Nummern und Bindestrichen bestehen.",
"alpha_num" => ":attribute sollte nur aus Buchstaben und Nummern bestehen.",
"before" => ":attribute muss ein Datum vor dem :date sein.",
"between" => array(
"numeric" => ":attribute muss zwischen :min und :max liegen.",
"file" => ":attribute muss zwischen :min und :max Kilobytes gro&szlig; sein.",
"string" => ":attribute muss zwischen :min und :max Zeichen lang sein.",
),
"confirmed" => ":attribute stimmt nicht mit der Best&auml;tigung &uuml;berein.",
"different" => ":attribute und :other m&uuml;ssen verschieden sein.",
"email" => ":attribute ist keine g&uuml;ltige Email-Adresse.",
"exists" => "Der gew&auml;hlte Wert f&uuml;r :attribute ist ung&uuml;ltig.",
"image" => ":attribute muss ein Bild sein.",
"in" => "Der gew&auml;hlte Wert f&uuml;r :attribute ist ung&uuml;ltig.",
"integer" => ":attribute muss eine ganze Zahl sein.",
"ip" => ":attribute muss eine g&uuml;ltige IP-Adresse sein.",
"match" => ":attribute hat ein ung&uuml;ltiges Format.",
"max" => array(
"numeric" => ":attribute muss kleiner als :max sein.",
"file" => ":attribute muss kleiner als :max Kilobytes gro&szlig; sein.",
"string" => ":attribute muss k&uuml;rzer als :max Zeichen sein.",
),
"mimes" => ":attribute muss den Dateityp :values haben.",
"min" => array(
"numeric" => ":attribute muss gr&ouml;&szlig;er als :min sein.",
"file" => ":attribute muss gr&ouml;&szlig;er als :min Kilobytes gro&szlig; sein.",
"string" => ":attribute muss l&auml;nger als :min Zeichen sein.",
),
"not_in" => "Der gew&auml;hlte Wert f&uuml;r :attribute ist ung&uuml;ltig.",
"numeric" => ":attribute muss eine Zahl sein.",
"required" => ":attribute muss aufgef&uuml;llt sein.",
"same" => ":attribute und :other m&uuml;ssen &uuml;bereinstimmen.",
"size" => array(
"numeric" => ":attribute muss gleich :size sein.",
"file" => ":attribute muss :size Kilobyte gro&szlig; sein.",
"string" => ":attribute muss :size Zeichen lang sein.",
),
"unique" => ":attribute ist schon vergeben.",
"url" => "Das Format von :attribute ist ung&uuml;ltig.",
/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
|--------------------------------------------------------------------------
|
| Here you may specify custom validation messages for attributes using the
| convention "attribute_rule" to name the lines. This helps keep your
| custom validation clean and tidy.
|
| So, say you want to use a custom validation message when validating that
| the "email" attribute is unique. Just add "email_unique" to this array
| with your custom message. The Validator will handle the rest!
|
*/
'custom' => array(),
/*
|--------------------------------------------------------------------------
| Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as "E-Mail Address" instead
| of "email". Your users will thank you.
|
| The Validator class will automatically search this array of lines it
| is attempting to replace the :attribute place-holder in messages.
| It's pretty slick. We think you'll like it.
|
*/
'attributes' => array(),
);

View File

@ -278,7 +278,7 @@ protected static function compile_structure_openings($value)
*/ */
protected static function compile_structure_closings($value) protected static function compile_structure_closings($value)
{ {
$pattern = '/(\s*)@(endif|endforeach|endfor|endwhile)(\s*)/'; $pattern = '/(\s*)@(endif|endforeach|endfor|endwhile|break)(\s*)/';
return preg_replace($pattern, '$1<?php $2; ?>$3', $value); return preg_replace($pattern, '$1<?php $2; ?>$3', $value);
} }

View File

@ -194,7 +194,7 @@ public function query($sql, $bindings = array())
return $statement->rowCount(); return $statement->rowCount();
} }
// For insert statements that use the "returning" clause, which is allowed // For insert statements that use the "returning" clause, which is allowed
// by databsae systems such as Postgres, we need to actually return the // by database systems such as Postgres, we need to actually return the
// real query result so the consumer can get the ID. // real query result so the consumer can get the ID.
elseif (stripos($sql, 'insert') === 0 and stripos($sql, 'returning') !== false) elseif (stripos($sql, 'insert') === 0 and stripos($sql, 'returning') !== false)
{ {

View File

@ -253,7 +253,27 @@ public static function all()
*/ */
public function _with($includes) public function _with($includes)
{ {
$this->includes = (array) $includes; $includes = (array) $includes;
$all_includes = array();
foreach($includes as $include)
{
$nested = explode('.', $include);
$inc = array();
foreach($nested as $relation)
{
$inc[] = $relation;
$all_includes[] = implode('.', $inc);
}
}
//remove duplicates and reset the array keys.
$this->includes = array_values(array_unique($all_includes));
return $this; return $this;
} }

View File

@ -21,7 +21,7 @@ public function foreign(Table $table, Fluent $command)
// command is being executed and the referenced table are wrapped. // command is being executed and the referenced table are wrapped.
$table = $this->wrap($table); $table = $this->wrap($table);
$on = $this->wrap($command->on); $on = $this->wrap_table($command->on);
// Next we need to columnize both the command table's columns as well as // Next we need to columnize both the command table's columns as well as
// the columns referenced by the foreign key. We'll cast the referenced // the columns referenced by the foreign key. We'll cast the referenced

View File

@ -393,9 +393,7 @@ protected function command($type, $parameters = array())
{ {
$parameters = array_merge(compact('type'), $parameters); $parameters = array_merge(compact('type'), $parameters);
$this->commands[] = new Fluent($parameters); return $this->commands[] = new Fluent($parameters);
return end($this->commands);
} }
/** /**
@ -409,9 +407,7 @@ protected function column($type, $parameters = array())
{ {
$parameters = array_merge(compact('type'), $parameters); $parameters = array_merge(compact('type'), $parameters);
$this->columns[] = new Fluent($parameters); return $this->columns[] = new Fluent($parameters);
return end($this->columns);
} }
} }

View File

@ -63,7 +63,7 @@ ## Protecting Routes
To protect a route, simply attach the **auth** filter: To protect a route, simply attach the **auth** filter:
Route::get('admin', array('before' => 'auth', function() {}); Route::get('admin', array('before' => 'auth', function() {}));
> **Note:** You are free to edit the **auth** filter however you like. A default implementation is located in **application/routes.php**. > **Note:** You are free to edit the **auth** filter however you like. A default implementation is located in **application/routes.php**.

View File

@ -4,6 +4,7 @@ ### General
- [Installation & Setup](/docs/install) - [Installation & Setup](/docs/install)
- [Requirements](/docs/install#requirements) - [Requirements](/docs/install#requirements)
- [Installation](/docs/install#installation) - [Installation](/docs/install#installation)
- [Server Configuration: Why Public?](/docs/install#server-configuration)
- [Basic Configuration](/docs/install#basic-configuration) - [Basic Configuration](/docs/install#basic-configuration)
- [Environments](/docs/install#environments) - [Environments](/docs/install#environments)
- [Cleaner URLs](/docs/install#cleaner-urls) - [Cleaner URLs](/docs/install#cleaner-urls)

View File

@ -65,7 +65,7 @@ ## Retrieving Models
echo $user->email; echo $user->email;
} }
Of course, retrieving an entire table isn't very helpful. Thankfully, **every method that is available through the fluent query builder is available in Eloquent**. Just begin querying your model with a static call to one of the [query builder](/docs/database/query) methods, and execute the query using the **get** or **first** method. The get method will return an array of models, while the first method will return a single model: Of course, retrieving an entire table isn't very helpful. Thankfully, **every method that is available through the fluent query builder is available in Eloquent**. Just begin querying your model with a static call to one of the [query builder](/docs/database/fluent) methods, and execute the query using the **get** or **first** method. The get method will return an array of models, while the first method will return a single model:
$user = User::where('email', '=', $email)->first(); $user = User::where('email', '=', $email)->first();

View File

@ -146,3 +146,9 @@ #### Merging new data into the current input:
#### Replacing the entire input array with new data: #### Replacing the entire input array with new data:
Input::merge(array('doctor' => 'Bones', 'captain' => 'Kirk')); Input::merge(array('doctor' => 'Bones', 'captain' => 'Kirk'));
## Clearing Input
To clear all input data for the current request, using the `clear()` method, for example:
Input::clear();

View File

@ -4,6 +4,7 @@ ## Contents
- [Requirements](#requirements) - [Requirements](#requirements)
- [Installation](#installation) - [Installation](#installation)
- [Server Configuration: Why Public?](#server-configuration)
- [Basic Configuration](#basic-configuration) - [Basic Configuration](#basic-configuration)
- [Environments](#environments) - [Environments](#environments)
- [Cleaner URLs](#cleaner-urls) - [Cleaner URLs](#cleaner-urls)
@ -37,8 +38,30 @@ ### Problems?
If you are having problems installing, try the following: If you are having problems installing, try the following:
- Make sure the **public** directory is the document root of your web server. - Make sure the **public** directory is the document root of your web server. (see: Server Configuration below)
- If you are using mod_rewrite, set the **index** option in **application/config/application.php** to an empty string. - If you are using mod_rewrite, set the **index** option in **application/config/application.php** to an empty string.
- Verify that your storage folder and the folders within in are writable by your web server.
<a name="server-configuration"></a>
## Server Configuration: Why Public?
Like most web-development frameworks, Laravel is designed to protect your application code, bundles, and local storage by placing only files that are necessarily public in the web server's DocumentRoot. This prevents some types of server misconfiguration from making your code (including database passwords and other configuration data) accessible through the web server. It's best to be safe.
In this example let's imagine that we installed Laravel to the directory **/Users/JonSnow/Sites/MySite**.
A very basic example of an Apache VirtualHost configuration for MySite might look like this.
<VirtualHost *:80>
DocumentRoot /Users/JonSnow/Sites/MySite/public
ServerName mysite.local
</VirtualHost>
Notice that while we installed to **/Users/JonSnow/Sites/MySite** our DocumentRoot points to **/Users/JonSnow/Sites/MySite/public**.
Pointing the DocumentRoot to the public folder is a commonly used best-practice. However, you may need to use Laravel on a host that does not allow you to update your DocumentRoot. This is possible, but before resigning to this option it's best to contact your host and verify that you are unable to change your DocumentRoot to increase the security of your application.
More information about how to use the public folder can be found on the [Laravel Forums](http://forums.laravel.com/viewtopic.php?pid=10023#p10023).
<a name="basic-configuration"></a> <a name="basic-configuration"></a>
## Basic Configuration ## Basic Configuration

View File

@ -12,7 +12,7 @@ ## Contents
<a name="the-basics"></a> <a name="the-basics"></a>
## The Basics ## The Basics
Almost every interactive web application needs to validate data. For instance, a registration form probably requires the password to be confirmed. Maybe the e-mail address must be unique. Validating data can be a cumbersome process. Thankfully, it isn't in Laravel. The Validator class provides as awesome array of validation helpers to make validating your data a breeze. Let's walk through an example: Almost every interactive web application needs to validate data. For instance, a registration form probably requires the password to be confirmed. Maybe the e-mail address must be unique. Validating data can be a cumbersome process. Thankfully, it isn't in Laravel. The Validator class provides an awesome array of validation helpers to make validating your data a breeze. Let's walk through an example:
#### Get an array of data you want to validate: #### Get an array of data you want to validate:

View File

@ -164,6 +164,8 @@ ## Blade Layouts
The profile view will automatically use the "master" template thanks to Blade's **@layout** expression. The profile view will automatically use the "master" template thanks to Blade's **@layout** expression.
**Important:** The **@layout** call must always be on the very first line of the file, with no leading whitespaces or newline breaks.
Sometimes you may want to only append to a section of a layout rather than overwrite it. For example, consider the navigation list in our "master" layout. Let's assume we just want to append a new list item. Here's how to do it: Sometimes you may want to only append to a section of a layout rather than overwrite it. For example, consider the navigation list in our "master" layout. Let's assume we just want to append a new list item. Here's how to do it:
@layout('master') @layout('master')

View File

@ -427,7 +427,7 @@ protected static function optgroup($options, $label, $selected)
$html[] = static::option($value, $display, $selected); $html[] = static::option($value, $display, $selected);
} }
return '<optgroup label="'.HTML::entities($label).'">'.implode('', $html).'</option>'; return '<optgroup label="'.HTML::entities($label).'">'.implode('', $html).'</optgroup>';
} }
/** /**

View File

@ -287,4 +287,13 @@ public static function replace(array $input)
Request::foundation()->request->replace($input); Request::foundation()->request->replace($input);
} }
/**
* Clear the input for the current request.
* @return void
*/
public static function clear()
{
Request::foundation()->request->replace(array());
}
} }

View File

@ -102,7 +102,8 @@ public static function spoofed()
*/ */
public static function ip($default = '0.0.0.0') public static function ip($default = '0.0.0.0')
{ {
return value(static::foundation()->getClientIp(), $default); $client_ip = static::foundation()->getClientIp();
return $client_ip === NULL ? $default : $client_ip;
} }
/** /**

View File

@ -1,4 +1,4 @@
<?php namespace Laravel; <?php namespace Laravel; use Closure;
class Session { class Session {

View File

@ -118,6 +118,11 @@ public function __construct($view, $data = array())
*/ */
public static function exists($view, $return_path = false) public static function exists($view, $return_path = false)
{ {
if (starts_with($view, 'name: ') and array_key_exists($name = substr($view, 6), static::$names))
{
$view = static::$names[$name];
}
list($bundle, $view) = Bundle::parse($view); list($bundle, $view) = Bundle::parse($view);
$view = str_replace('.', '/', $view); $view = str_replace('.', '/', $view);

View File

@ -10,7 +10,7 @@
/* /*
|---------------------------------------------------------------- |----------------------------------------------------------------
| Application Environemtns | Application Environments
|---------------------------------------------------------------- |----------------------------------------------------------------
| |
| Laravel takes a dead simple approach to environments, and we | Laravel takes a dead simple approach to environments, and we