From 6881bdaf027fdfd8b90db4fe1bd61c1c606c43f0 Mon Sep 17 00:00:00 2001 From: Jason Walton Date: Mon, 11 Jun 2012 09:18:42 -0700 Subject: [PATCH 01/37] Added required_with validation rule to conditionally require an attribute based on the presence of another attribute Signed-off-by: Jason Walton --- laravel/documentation/validation.md | 3 +++ laravel/validator.php | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/laravel/documentation/validation.md b/laravel/documentation/validation.md index 49401439..528cea75 100644 --- a/laravel/documentation/validation.md +++ b/laravel/documentation/validation.md @@ -63,6 +63,9 @@ #### Validate that an attribute is present and is not an empty string: 'name' => 'required' +#### Validate that an attribute is present, when another attribute is present: + 'last_name' => 'required_with:first_name' + ### Alpha, Alpha Numeric, & Alpha Dash diff --git a/laravel/validator.php b/laravel/validator.php index 3290bc17..968e94b7 100644 --- a/laravel/validator.php +++ b/laravel/validator.php @@ -214,7 +214,7 @@ protected function validatable($rule, $attribute, $value) */ protected function implicit($rule) { - return $rule == 'required' or $rule == 'accepted'; + return $rule == 'required' or $rule == 'accepted' or $rule == 'required_with'; } /** @@ -257,6 +257,27 @@ protected function validate_required($attribute, $value) return true; } + /** + * Validate that an attribute exists in the attributes array, if another + * attribute exists in the attributes array. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validate_required_with($attribute, $value, $parameters) + { + $other = $parameters[0]; + + if ($this->validate_required($other, $this->attributes[$other])) + { + return $this->validate_required($attribute, $value); + } + + return true; + } + /** * Validate that an attribute has a matching confirmation attribute. * From 0b9b102dc78aec01c8f307583f413e9bcf099eb1 Mon Sep 17 00:00:00 2001 From: Tobsn Date: Fri, 22 Jun 2012 08:50:09 -0700 Subject: [PATCH 02/37] NOT NULL order issue fixed! thanks @crynobone !!! --- laravel/database/schema/grammars/mysql.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/database/schema/grammars/mysql.php b/laravel/database/schema/grammars/mysql.php index d0ba45ad..31c6b411 100644 --- a/laravel/database/schema/grammars/mysql.php +++ b/laravel/database/schema/grammars/mysql.php @@ -99,7 +99,7 @@ protected function columns(Table $table) */ protected function unsigned(Table $table, Fluent $column) { - if ($column->type == 'integer' && $column->unsigned) + if ($column->type == 'integer' && ($column->unsigned || $column->increment)) { return ' UNSIGNED'; } @@ -143,7 +143,7 @@ protected function incrementer(Table $table, Fluent $column) { if ($column->type == 'integer' and $column->increment) { - return ' UNSIGNED AUTO_INCREMENT PRIMARY KEY'; + return ' AUTO_INCREMENT PRIMARY KEY'; } } From 31abcd599ba7c7f80a4073ec1f785bdfabd21706 Mon Sep 17 00:00:00 2001 From: Tobsn Date: Fri, 22 Jun 2012 08:54:10 -0700 Subject: [PATCH 03/37] unique typo --- laravel/database/schema/grammars/mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/database/schema/grammars/mysql.php b/laravel/database/schema/grammars/mysql.php index 31c6b411..c0c607fe 100644 --- a/laravel/database/schema/grammars/mysql.php +++ b/laravel/database/schema/grammars/mysql.php @@ -260,7 +260,7 @@ public function drop_primary(Table $table, Fluent $command) } /** - * Generate the SQL statement for a drop unqique key command. + * Generate the SQL statement for a drop unique key command. * * @param Table $table * @param Fluent $command From ac810f8597d20f7215605afd4c0337c34f8e38ec Mon Sep 17 00:00:00 2001 From: Jason Lewis Date: Sun, 24 Jun 2012 19:28:53 +0930 Subject: [PATCH 04/37] Allow filter patterns to supply a name and callback as an easier alternative. Signed-off-by: Jason Lewis --- laravel/routing/route.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/laravel/routing/route.php b/laravel/routing/route.php index 73b79521..b63bdc32 100644 --- a/laravel/routing/route.php +++ b/laravel/routing/route.php @@ -213,6 +213,15 @@ protected function patterns() { if (Str::is($pattern, $this->uri)) { + // If the filter provided is an array then we need to register + // the filter before we can assign it to the route. + if (is_array($filter)) + { + list($filter, $callback) = array_values($filter); + + Filter::register($filter, $callback); + } + $filters[] = $filter; } } From cea48d4fe5e379c907ccb7cd9b2580e3a227445a Mon Sep 17 00:00:00 2001 From: Jason Lewis Date: Sun, 24 Jun 2012 19:37:08 +0930 Subject: [PATCH 05/37] Updated the documentation. Signed-off-by: Jason Lewis --- laravel/documentation/routing.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/laravel/documentation/routing.md b/laravel/documentation/routing.md index 18c90671..d10be6b1 100644 --- a/laravel/documentation/routing.md +++ b/laravel/documentation/routing.md @@ -152,6 +152,15 @@ #### Defining a URI pattern based filter: Route::filter('pattern: admin/*', 'auth'); +Optionally you can register filters directly when attaching filters to a given URI by supplying an array with the name of the filter and a callback. + +#### Defining a filter and URI pattern based filter in one: + + Route::filter('pattern: admin/*', array('name' => 'auth', function() + { + // + })); + ## Global Filters From 5e2373817d882e9873f3ba21da56c117f890599d Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Mon, 25 Jun 2012 21:31:54 +0300 Subject: [PATCH 06/37] Allow for passing variables to views with more expressive method calls. Example: with_foo($bar) instead of with('foo', $bar) Signed-off-by: Franz Liedke --- laravel/view.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/laravel/view.php b/laravel/view.php index 9a375073..2754d495 100644 --- a/laravel/view.php +++ b/laravel/view.php @@ -551,4 +551,20 @@ public function __toString() return $this->render(); } + /** + * Magic Method for handling dynamic functions. + * + * This method handles calls to dynamic with helpers. + */ + public function __call($method, $parameters) + { + if (strpos($method, 'with_') === 0) + { + $key = substr($method, 5); + return $this->with($key, $parameters[0]); + } + + throw new \Exception("Method [$method] is not defined on the View class."); + } + } \ No newline at end of file From ad2540c979bc20a9a4a52fbea7efd58da5baf7bd Mon Sep 17 00:00:00 2001 From: Luca Degasperi Date: Wed, 27 Jun 2012 15:20:28 +0200 Subject: [PATCH 07/37] Fixed the spaced directory when calling php unit via the command line Signed-off-by: Luca Degasperi --- laravel/cli/tasks/test/runner.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/laravel/cli/tasks/test/runner.php b/laravel/cli/tasks/test/runner.php index 85787896..e13a42d9 100644 --- a/laravel/cli/tasks/test/runner.php +++ b/laravel/cli/tasks/test/runner.php @@ -80,6 +80,9 @@ protected function test() // pointing to our temporary configuration file. This allows // us to flexibly run tests for any setup. $path = path('base').'phpunit.xml'; + + // fix the spaced directories problem when using the command line + $path = str_replace(" ", "\\ ", $path); passthru('phpunit --configuration '.$path); From 79a5dc19313c31ec0e109730a0b20389d3bfcd63 Mon Sep 17 00:00:00 2001 From: Luca Degasperi Date: Wed, 27 Jun 2012 17:31:38 +0200 Subject: [PATCH 08/37] Using escapeshellarg instead of putting backshlashes in front of spaces Signed-off-by: Luca Degasperi --- laravel/cli/tasks/test/runner.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/laravel/cli/tasks/test/runner.php b/laravel/cli/tasks/test/runner.php index e13a42d9..953c9857 100644 --- a/laravel/cli/tasks/test/runner.php +++ b/laravel/cli/tasks/test/runner.php @@ -82,7 +82,8 @@ protected function test() $path = path('base').'phpunit.xml'; // fix the spaced directories problem when using the command line - $path = str_replace(" ", "\\ ", $path); + // strings with spaces inside should be wrapped in quotes. + $path = escapeshellarg($path) passthru('phpunit --configuration '.$path); From 39df69fdc1a4c00fea078d11d2421fbb18661da3 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 28 Jun 2012 18:33:45 +0300 Subject: [PATCH 09/37] Allow more than just WHERE clauses on eager load constraints. --- laravel/database/query.php | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/laravel/database/query.php b/laravel/database/query.php index 83c92b83..915f7c80 100644 --- a/laravel/database/query.php +++ b/laravel/database/query.php @@ -395,7 +395,7 @@ public function or_where_not_null($column) } /** - * Add a nested where condition to the query. + * Add nested constraints to the query. * * @param Closure $callback * @param string $connector @@ -403,24 +403,7 @@ public function or_where_not_null($column) */ public function where_nested($callback, $connector = 'AND') { - $type = 'where_nested'; - - // To handle a nested where statement, we will actually instantiate a new - // Query instance and run the callback over that instance, which will - // allow the developer to have a fresh query instance - $query = new Query($this->connection, $this->grammar, $this->from); - - call_user_func($callback, $query); - - // Once the callback has been run on the query, we will store the nested - // query instance on the where clause array so that it's passed to the - // query's query grammar instance when building. - if ($query->wheres !== null) - { - $this->wheres[] = compact('type', 'query', 'connector'); - } - - $this->bindings = array_merge($this->bindings, $query->bindings); + call_user_func($callback, $this); return $this; } From a87bb869992d6050855b8c4d47f73b98567f4c56 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 29 Jun 2012 20:56:32 +0300 Subject: [PATCH 10/37] Fix a bug with Eloquent model classes and isset() when eager loading a relationship returns an empty result set. --- laravel/database/eloquent/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index 2ad1c72b..7e9b0ba3 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -725,7 +725,7 @@ public function __isset($key) { foreach (array('attributes', 'relationships') as $source) { - if (array_key_exists($key, $this->$source)) return true; + if (array_key_exists($key, $this->$source)) return !is_null($this->$source[$key]); } if (method_exists($this, $key)) return true; From 97dfaee88fbe33b54fcf197b5232c57517984307 Mon Sep 17 00:00:00 2001 From: Tomasz Tomczyk Date: Fri, 29 Jun 2012 19:43:00 +0100 Subject: [PATCH 11/37] Added Polish translation Signed-off-by: Tomasz Tomczyk --- application/language/pl/pagination.php | 19 +++++ application/language/pl/validation.php | 99 ++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 application/language/pl/pagination.php create mode 100644 application/language/pl/validation.php diff --git a/application/language/pl/pagination.php b/application/language/pl/pagination.php new file mode 100644 index 00000000..90536b95 --- /dev/null +++ b/application/language/pl/pagination.php @@ -0,0 +1,19 @@ + '« Poprzednia', + 'next' => 'Następna »', + +); \ No newline at end of file diff --git a/application/language/pl/validation.php b/application/language/pl/validation.php new file mode 100644 index 00000000..ead856b1 --- /dev/null +++ b/application/language/pl/validation.php @@ -0,0 +1,99 @@ + ":attribute musi zostać zaakceptowane.", + "active_url" => ":attribute nie jest prawidłowym adresem URL.", + "after" => ":attribute musi zawierać datę, która jest po :date.", + "alpha" => ":attribute może zawierać jedynie litery.", + "alpha_dash" => ":attribute może zawierać jedynie litery, cyfry i myślniki.", + "alpha_num" => ":attribute może zawierać jedynie litery i cyfry.", + "before" => ":attribute musi zawierać datę, która jest przed :date.", + "between" => array( + "numeric" => ":ttribute musi mieścić się w granicach :min - :max.", + "file" => ":attribute musi mieć :min - :max kilobajtów.", + "string" => ":attribute musi mieć :min - :max znaków.", + ), + "confirmed" => "Potwierdzenie :attribute się nie zgadza.", + "different" => ":attribute i :other muszą się od siebie różnić.", + "email" => "The :attribute format is invalid.", + "exists" => "Zaznaczona opcja :attribute jest nieprawidłowa.", + "image" => ":attribute musi być obrazkiem.", + "in" => "Zaznaczona opcja :attribute jest nieprawidłowa.", + "integer" => ":attribute musi być liczbą całkowitą.", + "ip" => ":attribute musi być prawidłowym adresem IP.", + "match" => "Format :attribute jest nieprawidłowy.", + "max" => array( + "numeric" => ":attribute musi być poniżej :max.", + "file" => ":attribute musi mieć poniżej :max kilobajtów.", + "string" => ":attribute musi mieć poniżej :max znaków.", + ), + "mimes" => ":attribute musi być plikiem rodzaju :values.", + "min" => array( + "numeric" => ":attribute musi być co najmniej :min.", + "file" => "Plik :attribute musi mieć co najmniej :min kilobajtów.", + "string" => ":attribute musi mieć co najmniej :min znaków.", + ), + "not_in" => "Zaznaczona opcja :attribute jest nieprawidłowa.", + "numeric" => ":attribute musi być numeryczne.", + "required" => "Pole :attribute jest wymagane.", + "same" => ":attribute i :other muszą być takie same.", + "size" => array( + "numeric" => ":attribute musi mieć rozmiary :size.", + "file" => ":attribute musi mieć :size kilobajtów.", + "string" => ":attribute musi mieć :size znaków.", + ), + "unique" => ":attribute zostało już użyte.", + "url" => "Format pola :attribute jest nieprawidłowy.", + + /* + |-------------------------------------------------------------------------- + | 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(), + +); \ No newline at end of file From f77b22eb45af6fbdd37078feda09776c96b9ca41 Mon Sep 17 00:00:00 2001 From: TommyC81 Date: Sat, 30 Jun 2012 18:11:31 +0300 Subject: [PATCH 12/37] Add documentation on how to attach pivot table fields to attach command. --- laravel/documentation/database/eloquent.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/laravel/documentation/database/eloquent.md b/laravel/documentation/database/eloquent.md index c2afc7a2..5858224b 100644 --- a/laravel/documentation/database/eloquent.md +++ b/laravel/documentation/database/eloquent.md @@ -318,6 +318,10 @@ ### Inserting Related Models (Many-To-Many) $user->roles()->attach($role_id); +It's also possible to attach data for fields in the intermediate table (pivot table), to do this add a second array variable to the attach command containing the data you want to attach: + + $user->roles()->attach($role_id, array('expires' => $expires)); + Alternatively, you can use the `sync` method, which accepts an array of IDs to "sync" with the intermediate table. After this operation is complete, only the IDs in the array will be on the intermediate table. From 34923cff1e3b4ec677adba7be0ef4d6d13b339fc Mon Sep 17 00:00:00 2001 From: Nir Lahad Date: Sun, 1 Jul 2012 00:38:43 +0300 Subject: [PATCH 13/37] Hebrew Translation Hebrew language files. --- application/language/he/pagination.php | 19 +++++ application/language/he/validation.php | 102 +++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 application/language/he/pagination.php create mode 100644 application/language/he/validation.php diff --git a/application/language/he/pagination.php b/application/language/he/pagination.php new file mode 100644 index 00000000..6d2684cd --- /dev/null +++ b/application/language/he/pagination.php @@ -0,0 +1,19 @@ + '→ אחורה', + 'next' => 'קדימה ←', + +); \ No newline at end of file diff --git a/application/language/he/validation.php b/application/language/he/validation.php new file mode 100644 index 00000000..6a108d09 --- /dev/null +++ b/application/language/he/validation.php @@ -0,0 +1,102 @@ + "חובה להסכים ל-: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 חייבת להיות כתובת IP תקינה.", + "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(), + +); \ No newline at end of file From 52f76b9d662c17bb12bf872e964c8881fc41dd80 Mon Sep 17 00:00:00 2001 From: Jason Lewis Date: Sun, 1 Jul 2012 22:51:42 +0930 Subject: [PATCH 14/37] Fixes #818, wraps in an array instead of type casting. Signed-off-by: Jason Lewis --- laravel/database/query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/database/query.php b/laravel/database/query.php index 83c92b83..3dc7604f 100644 --- a/laravel/database/query.php +++ b/laravel/database/query.php @@ -140,7 +140,7 @@ public function distinct() */ public function select($columns = array('*')) { - $this->selects = (array) $columns; + $this->selects = is_array($columns) ? $columns : array($columns); return $this; } From b28c5eb19f2ec7941522b6289f02e543c0ed7d1b Mon Sep 17 00:00:00 2001 From: Steven Lischer Date: Mon, 2 Jul 2012 12:32:14 -0500 Subject: [PATCH 15/37] docs edit: eager loading using $includes in model --- laravel/documentation/database/eloquent.md | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/laravel/documentation/database/eloquent.md b/laravel/documentation/database/eloquent.md index c2afc7a2..93f4896f 100644 --- a/laravel/documentation/database/eloquent.md +++ b/laravel/documentation/database/eloquent.md @@ -406,6 +406,28 @@ ## Eager Loading $books = Book::with(array('author', 'author.contacts'))->get(); +If you find yourself eager loading the same models often, you may want to use **$includes** in the model. + + class Book extends Eloquent { + + public $includes = array('author'); + + public function author() + { + return $this->belongs_to('Author'); + } + + } + +**$includes** takes the same arguments that **with** takes. The following is now eagerly loaded. + + foreach (Book::all() as $book) + { + echo $book->author->name; + } + +> **Note:** Using **with** will override a models **$includes**. + ## Constraining Eager Loads @@ -419,6 +441,7 @@ ## Constraining Eager Loads In this example, we're eager loading the posts for the users, but only if the post's "title" column contains the word "first". + ## Getter & Setter Methods From 72558bda3b4c1b7a5848d43a466d7e3475a408d1 Mon Sep 17 00:00:00 2001 From: Steven Lischer Date: Mon, 2 Jul 2012 12:50:26 -0500 Subject: [PATCH 16/37] removed extra newline --- laravel/documentation/database/eloquent.md | 1 - 1 file changed, 1 deletion(-) diff --git a/laravel/documentation/database/eloquent.md b/laravel/documentation/database/eloquent.md index 93f4896f..17156c36 100644 --- a/laravel/documentation/database/eloquent.md +++ b/laravel/documentation/database/eloquent.md @@ -441,7 +441,6 @@ ## Constraining Eager Loads In this example, we're eager loading the posts for the users, but only if the post's "title" column contains the word "first". - ## Getter & Setter Methods From 7bdddfe2faa6d094441944ff22135d8a43bd743b Mon Sep 17 00:00:00 2001 From: Nir Lahad Date: Wed, 4 Jul 2012 08:19:36 +0300 Subject: [PATCH 17/37] Fixed Hebrew Fixed and unified hebrew translation. --- application/language/he/validation.php | 68 +++++++++++++------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/application/language/he/validation.php b/application/language/he/validation.php index 6a108d09..f0059b6a 100644 --- a/application/language/he/validation.php +++ b/application/language/he/validation.php @@ -22,48 +22,48 @@ */ "accepted" => "חובה להסכים ל-:attribute.", - "active_url" => ":attribute אינה כתובת אינטרנט פעילה.", - "after" => ":attribute חייב להיות תאריך אחרי :date.", - "alpha" => ":attribute יכול להכיל רק אותיות.", - "alpha_dash" => ":attribute יכול להיות רק אותיות, מספרים ומקפים.", - "alpha_num" => ":attribute יכול להכיל רק אותיות ומספרים.", - "before" => ":attribute חייב להיות תאריך אחרי :date.", + "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 תווים.", + "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 חייבת להיות כתובת IP תקינה.", - "match" => "התבנית של :attribute אינה תקינה.", + "confirmed" => "הערכים של :attribute חייבים להיות זהים.", + "different" => "הערכים של :attribute ו-:other חייבים להיות שונים.", + "email" => "הערך :attribute חייב להכיל כתובת אימייל תקינה.", + "exists" => "הערך :attribute לא קיים.", + "image" => "הערך :attribute חייב להיות תמונה.", + "in" => "הערך :attribute חייב להיות ברשימה המאשרת.", + "integer" => "הערך :attribute חייב להיות מספר שלם.", + "ip" => "הערך :attribute חייב להיות כתובת IP תקינה.", + "match" => "התבנית של הערך :attribute אינה תקינה.", "max" => array( - "numeric" => ":attribute חייב להיות פחות מ-:max.", - "file" => ":attribute חייב לשקול פחות מ-:max ק"ב.", - "string" => ":attribute חייב להכיל פחות מ-:max תווים.", + "numeric" => "הערך :attribute חייב להיות פחות מ-:max.", + "file" => "הערך :attribute חייב לשקול פחות מ-:max ק"ב.", + "string" => "הערך :attribute חייב להכיל פחות מ-:max תווים.", ), - "mimes" => ":attribute חייב להיות קובץ מסוג: :values.", + "mimes" => "הערך :attribute חייב להיות קובץ מסוג: :values.", "min" => array( - "numeric" => ":attribute חייב להיות לפחות :min.", - "file" => ":attribute חייב לשקול לפחות :min ק"ב.", - "string" => ":attribute חייב להכיל לפחות :min תווים.", + "numeric" => "הערך :attribute חייב להיות לפחות :min.", + "file" => "הערך :attribute חייב לשקול לפחות :min ק"ב.", + "string" => "הערך :attribute חייב להכיל לפחות :min תווים.", ), - "not_in" => ":attribute נמצא ברשימה השחורה.", - "numeric" => ":attribute חייב להיות מספר.", - "required" => "חובה למלא :attribute.", - "same" => ":attribute ו-:other חייבים להתאים.", + "not_in" => "הערך :attribute נמצא ברשימה השחורה.", + "numeric" => "הערך :attribute חייב להיות מספר.", + "required" => "חובה למלא את הערך :attribute.", + "same" => "הערכים :attribute ו-:other חייבים להיות זהים.", "size" => array( - "numeric" => ":attribute חייב להיות :size.", - "file" => ":attribute חייב לשקול :size ק"ב.", - "string" => ":attribute חייב להכיל :size תווים.", + "numeric" => "הערך :attribute חייב להיות :size.", + "file" => "הערך :attribute חייב לשקול :size ק"ב.", + "string" => "הערך :attribute חייב להכיל :size תווים.", ), - "unique" => ":attribute כבר קיים.", - "url" => ":attribute אינה כתובת אינטרנט תקנית.", + "unique" => "הערך :attribute כבר קיים.", + "url" => "הערך :attribute חייב להכיל כתובת אינטרנט תקינה.", /* |-------------------------------------------------------------------------- From 0440b86bd9764e7e3926b9a4e5de4fdca5e703f1 Mon Sep 17 00:00:00 2001 From: Roumen Damianoff Date: Wed, 4 Jul 2012 13:16:44 +0300 Subject: [PATCH 18/37] Added Bulgarian language files Signed-off-by: Roumen Damianoff --- application/language/bg/pagination.php | 19 +++++ application/language/bg/validation.php | 99 ++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 application/language/bg/pagination.php create mode 100644 application/language/bg/validation.php diff --git a/application/language/bg/pagination.php b/application/language/bg/pagination.php new file mode 100644 index 00000000..2f4b150c --- /dev/null +++ b/application/language/bg/pagination.php @@ -0,0 +1,19 @@ + '« Назад', + 'next' => 'Напред »', + +); \ No newline at end of file diff --git a/application/language/bg/validation.php b/application/language/bg/validation.php new file mode 100644 index 00000000..c76a6e92 --- /dev/null +++ b/application/language/bg/validation.php @@ -0,0 +1,99 @@ + "Трябва да приемете :attribute.", + "active_url" => "Полето :attribute не е валиден URL адрес.", + "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 трябва да бъде IP адрес.", + "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(), + +); \ No newline at end of file From f2ccc688fe0623211391d627309458af5d06ab76 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 4 Jul 2012 21:44:11 +0300 Subject: [PATCH 19/37] Ignore NULL values when determining whether a model object is dirty. --- laravel/database/eloquent/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index 2ad1c72b..9d35b47d 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -536,7 +536,7 @@ public function get_dirty() foreach ($this->attributes as $key => $value) { - if ( ! isset($this->original[$key]) or $value !== $this->original[$key]) + if ( ! array_key_exists($key, $this->original) or $value !== $this->original[$key]) { $dirty[$key] = $value; } From 1be274caa68d8773680834295772e7c409ac80de Mon Sep 17 00:00:00 2001 From: Jesse O'Brien Date: Wed, 4 Jul 2012 15:46:12 -0400 Subject: [PATCH 20/37] Change update function so it uses timestamp like save Calling update() on an eloquent model has no way of overriding the timestamp that should be set if $timestamps is set on the model. This changes that so it uses the timestamp() function which is an easy way to over ride the type of timestamps used. --- laravel/database/eloquent/model.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index 2ad1c72b..0f7b6a91 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -218,9 +218,11 @@ public static function update($id, $attributes) { $model = new static(array(), true); - if (static::$timestamps) $attributes['updated_at'] = new \DateTime; + $model->fill($attributes); - return $model->query()->where($model->key(), '=', $id)->update($attributes); + if (static::$timestamps) $model->timestamp(); + + return $model->query()->where($model->key(), '=', $id)->update($model->attributes); } /** From f05148503e95a77feff5e7ff7f3a1b5e82dfc97f Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 4 Jul 2012 22:56:58 +0300 Subject: [PATCH 21/37] Input::has_file was not working properly. This one should work perfect :) --- laravel/input.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/input.php b/laravel/input.php index 6a28b17f..0de7b759 100644 --- a/laravel/input.php +++ b/laravel/input.php @@ -205,7 +205,7 @@ public static function file($key = null, $default = null) */ public static function has_file($key) { - return ! is_null(static::file("{$key}.tmp_name")); + return strlen(static::file("{$key}.tmp_name", "")) > 0; } /** From d7bbdd97358bc5a2a3b837f366c5fc01e749836b Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 5 Jul 2012 01:52:30 +0300 Subject: [PATCH 22/37] Fix anchor name for "Retrieving a language line" section on localization page. --- laravel/documentation/localization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/documentation/localization.md b/laravel/documentation/localization.md index e1941633..c928a49c 100644 --- a/laravel/documentation/localization.md +++ b/laravel/documentation/localization.md @@ -33,7 +33,7 @@ #### Creating a language file: Nice! Now you know how to get started setting up your language files and directories. Let's keep localizing! - + ## Retrieving A Language Line #### Retrieving a language line: From db9f220f57f963a33d6f7e4405c2ef971787727a Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 7 Jul 2012 02:17:12 +0300 Subject: [PATCH 23/37] Force UTF-8 charset on JSON responses. --- laravel/response.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/response.php b/laravel/response.php index b6fa4d84..d86ee93e 100644 --- a/laravel/response.php +++ b/laravel/response.php @@ -93,7 +93,7 @@ public static function view($view, $data = array()) */ public static function json($data, $status = 200, $headers = array()) { - $headers['Content-Type'] = 'application/json'; + $headers['Content-Type'] = 'application/json; charset=utf-8'; return new static(json_encode($data), $status, $headers); } @@ -113,7 +113,7 @@ public static function json($data, $status = 200, $headers = array()) */ public static function eloquent($data, $status = 200, $headers = array()) { - $headers['Content-Type'] = 'application/json'; + $headers['Content-Type'] = 'application/json; charset=utf-8'; return new static(eloquent_to_json($data), $status, $headers); } From ebcbbbb8430643988a6395ffeeab0f650c206144 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 9 Jul 2012 09:54:03 -0500 Subject: [PATCH 24/37] WIP. --- application/language/bg/validation.php | 196 ++++++++++++------------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/application/language/bg/validation.php b/application/language/bg/validation.php index c76a6e92..4e46f6ff 100644 --- a/application/language/bg/validation.php +++ b/application/language/bg/validation.php @@ -1,99 +1,99 @@ - "Трябва да приемете :attribute.", - "active_url" => "Полето :attribute не е валиден URL адрес.", - "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 трябва да бъде IP адрес.", - "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(), - + "Трябва да приемете :attribute.", + "active_url" => "Полето :attribute не е валиден URL адрес.", + "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 трябва да бъде IP адрес.", + "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(), + ); \ No newline at end of file From 82ababb4cb8e123c6b2e5e767119390364c867cd Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 9 Jul 2012 09:54:56 -0500 Subject: [PATCH 25/37] Add note about making view directory writable. --- laravel/documentation/install.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/laravel/documentation/install.md b/laravel/documentation/install.md index b3312366..941699ee 100644 --- a/laravel/documentation/install.md +++ b/laravel/documentation/install.md @@ -23,7 +23,8 @@ ## Installation 1. [Download Laravel](http://laravel.com/download) 2. Extract the Laravel archive and upload the contents to your web server. 3. Set the value of the **key** option in the **config/application.php** file to a random, 32 character string. -4. Navigate to your application in a web browser. +4. Verify that the `storage/views` directory is writable. +5. Navigate to your application in a web browser. If all is well, you should see a pretty Laravel splash page. Get ready, there is lots more to learn! From 1879e6575aaad4851a273349b8eede194e2d2ee2 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 10 Jul 2012 08:02:08 -0500 Subject: [PATCH 26/37] tweak eloquent model change method to not check types. --- laravel/database/eloquent/model.php | 2 +- laravel/documentation/changes.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index 8703f4c4..ccdd42d5 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -502,7 +502,7 @@ final public function sync() */ public function changed($attribute) { - return array_get($this->attributes, $attribute) !== array_get($this->original, $attribute); + return array_get($this->attributes, $attribute) != array_get($this->original, $attribute); } /** diff --git a/laravel/documentation/changes.md b/laravel/documentation/changes.md index e5c68b89..7fb72d41 100644 --- a/laravel/documentation/changes.md +++ b/laravel/documentation/changes.md @@ -37,6 +37,7 @@ ## Contents ## Laravel 3.2.4 - Speed up many to many eager loading mapping. +- Tweak the Eloquent::changed() method. ## Upgrading From 3.2.3 From c8718a32eccee418baec7be18d51f53cd34e91d7 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Jul 2012 10:18:48 -0500 Subject: [PATCH 27/37] added option for URI languages. --- application/config/application.php | 15 ++++++++++- laravel/laravel.php | 42 ++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/application/config/application.php b/application/config/application.php index 9f597954..abfcf072 100755 --- a/application/config/application.php +++ b/application/config/application.php @@ -84,7 +84,7 @@ /* |-------------------------------------------------------------------------- - | Application Language + | Default Application Language |-------------------------------------------------------------------------- | | The default language of your application. This language will be used by @@ -94,6 +94,19 @@ 'language' => 'en', + /* + |-------------------------------------------------------------------------- + | Supported Languages + |-------------------------------------------------------------------------- + | + | These languages may also be supported by your application. If a request + | enters your application with a URI beginning with one of these values + | the default language will automatically be set to that language. + | + */ + + 'languages' => array('fr', 'sp'), + /* |-------------------------------------------------------------------------- | SSL Link Generation diff --git a/laravel/laravel.php b/laravel/laravel.php index a1ca2061..2544c617 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -107,6 +107,46 @@ return Event::first('404'); }); +/* +|-------------------------------------------------------------------------- +| Gather The URI And Locales +|-------------------------------------------------------------------------- +| +| When routing, we'll need to grab the URI and the supported locales for +| the route so we can properly set the language and route the request +| to the proper end-point in the application. +| +*/ + +$uri = URI::current(); + +$locales = Config::get('application.languages', array()); + +$locales[] = Config::get('application.language'); + +/* +|-------------------------------------------------------------------------- +| Set The Locale Based On Route +|-------------------------------------------------------------------------- +| +| If the URI starts with one of the supported languages, we will set +| the default language to match that URI segment and shorten the +| URI we'll pass to the router to not include the lang segment. +| +*/ + +foreach ($locales as $locale) +{ + if (starts_with($uri, $locale)) + { + Config::set('application.language', $locale); + + $uri = trim(substr($uri, strlen($locale)), '/'); break; + } +} + +if ($uri === '') $uri = '/'; + /* |-------------------------------------------------------------------------- | Route The Incoming Request @@ -118,8 +158,6 @@ | */ -$uri = URI::current(); - Request::$route = Routing\Router::route(Request::method(), $uri); $response = Request::$route->call(); From 5f919d76a5f9bb86c2a5c8d74f62ee91eebf8e8c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Jul 2012 10:20:12 -0500 Subject: [PATCH 28/37] updated change log. --- laravel/documentation/changes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/laravel/documentation/changes.md b/laravel/documentation/changes.md index 7fb72d41..d969d5a2 100644 --- a/laravel/documentation/changes.md +++ b/laravel/documentation/changes.md @@ -38,6 +38,7 @@ ## Laravel 3.2.4 - Speed up many to many eager loading mapping. - Tweak the Eloquent::changed() method. +- Added support for locales in the URI. ## Upgrading From 3.2.3 From 10e5918e237f354c9f8a650a5be51ec919ff6bb4 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Jul 2012 10:24:08 -0500 Subject: [PATCH 29/37] clear out langauges option. --- application/config/application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/config/application.php b/application/config/application.php index abfcf072..07bb2157 100755 --- a/application/config/application.php +++ b/application/config/application.php @@ -105,7 +105,7 @@ | */ - 'languages' => array('fr', 'sp'), + 'languages' => array(), /* |-------------------------------------------------------------------------- From e19e4ebd2490efcc5c5463c1ac11b8a5beca625a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Jul 2012 10:30:44 -0500 Subject: [PATCH 30/37] tweak url for languages. --- laravel/url.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/laravel/url.php b/laravel/url.php index 44b89428..443ddb2a 100644 --- a/laravel/url.php +++ b/laravel/url.php @@ -107,6 +107,14 @@ public static function to($url = '', $https = null) $root = static::base().'/'.Config::get('application.index'); + // If multiple languages are being supported via URIs, we will append current + // language to the URI so all redirects and URLs generated include the + // current language so it is not lost on further requests. + if (count(Config::get('application.languages')) > 0) + { + $root .= '/'.Config::get('application.language'); + } + // Since SSL is not often used while developing the application, we allow the // developer to disable SSL on all framework generated links to make it more // convenient to work with the site while developing locally. @@ -242,6 +250,11 @@ public static function to_asset($url, $https = null) $url = str_replace($index.'/', '', $url); } + if (count(Config::get('application.languages')) > 0) + { + $url = str_replace(Config::get('application.language').'/', '', $url); + } + return $url; } From 49928b397ab6447be4103e231fc5e55235f9fbd0 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Wed, 11 Jul 2012 22:22:57 +0200 Subject: [PATCH 31/37] added server configuration to the documentation --- laravel/documentation/install.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/laravel/documentation/install.md b/laravel/documentation/install.md index 12f12951..73137df8 100644 --- a/laravel/documentation/install.md +++ b/laravel/documentation/install.md @@ -4,6 +4,7 @@ ## Contents - [Requirements](#requirements) - [Installation](#installation) +- [Server Configuration](#server-configuration) - [Basic Configuration](#basic-configuration) - [Environments](#environments) - [Cleaner URLs](#cleaner-urls) @@ -37,8 +38,27 @@ ### Problems? 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. +- Verify that your storage folder and the folders within in are writable by your web server. + + +## Server Configuration + +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. + + + DocumentRoot /Users/JonSnow/Sites/MySite/public + ServerName mysite.dev + + +Notice that while we installed to **/Users/JonSnow/Sites/MySite** our DocumentRoot points to /Users/JonSnow/Sites/MySite/public**. + +While pointing the DocumentRoot to the public folder is a commonly used best-practice, it's possible that you may need to use Laravel on a host that does not allow you to update your DocumentRoot. A collection of algorithms to circumvent this need can be found [http://forums.laravel.com/viewtopic.php?id=1258](on the Laravel forums.) ## Basic Configuration From a66eb44809c76c3cae3934a81c6c51ff73035e8f Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Wed, 11 Jul 2012 22:28:44 +0200 Subject: [PATCH 32/37] fixed typo --- laravel/documentation/install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/documentation/install.md b/laravel/documentation/install.md index 7a1f68dc..a3e9bd8e 100644 --- a/laravel/documentation/install.md +++ b/laravel/documentation/install.md @@ -45,7 +45,7 @@ ### Problems? - 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. -- Verify that your storage folder and the folders within in are writable by your web server. +- Verify that your storage folder and the folders within are writable by your web server. ## Server Configuration From ee6adc26d9e651297833fa9a22a678793105de33 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Wed, 11 Jul 2012 22:30:38 +0200 Subject: [PATCH 33/37] fix merge --- laravel/documentation/install.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/laravel/documentation/install.md b/laravel/documentation/install.md index a3e9bd8e..ae3984dd 100644 --- a/laravel/documentation/install.md +++ b/laravel/documentation/install.md @@ -4,11 +4,7 @@ ## Contents - [Requirements](#requirements) - [Installation](#installation) -<<<<<<< HEAD -- [Server Configuration: Why Public?](#server-configuration) -======= - [Server Configuration](#server-configuration) ->>>>>>> feature/docs-install - [Basic Configuration](#basic-configuration) - [Environments](#environments) - [Cleaner URLs](#cleaner-urls) From 85ec19367d034622f74683049db365fcf5d7113f Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Wed, 11 Jul 2012 22:31:46 +0200 Subject: [PATCH 34/37] fix merge --- laravel/documentation/install.md | 1 - 1 file changed, 1 deletion(-) diff --git a/laravel/documentation/install.md b/laravel/documentation/install.md index ae3984dd..07cfbb4f 100644 --- a/laravel/documentation/install.md +++ b/laravel/documentation/install.md @@ -60,7 +60,6 @@ ## Server Configuration Notice that while we installed to **/Users/JonSnow/Sites/MySite** our DocumentRoot points to /Users/JonSnow/Sites/MySite/public**. While pointing the DocumentRoot to the public folder is a commonly used best-practice, it's possible that you may need to use Laravel on a host that does not allow you to update your DocumentRoot. A collection of algorithms to circumvent this need can be found [http://forums.laravel.com/viewtopic.php?id=1258](on the Laravel forums.) ->>>>>>> feature/docs-install ## Basic Configuration From a6c28050e68f0b824db608aa490c89652032ae15 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Wed, 11 Jul 2012 22:34:38 +0200 Subject: [PATCH 35/37] style updates --- laravel/documentation/install.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/documentation/install.md b/laravel/documentation/install.md index 07cfbb4f..1e051e06 100644 --- a/laravel/documentation/install.md +++ b/laravel/documentation/install.md @@ -57,9 +57,9 @@ ## Server Configuration ServerName mysite.dev -Notice that while we installed to **/Users/JonSnow/Sites/MySite** our DocumentRoot points to /Users/JonSnow/Sites/MySite/public**. +Notice that while we installed to **/Users/JonSnow/Sites/MySite** our DocumentRoot points to **/Users/JonSnow/Sites/MySite/public**. -While pointing the DocumentRoot to the public folder is a commonly used best-practice, it's possible that you may need to use Laravel on a host that does not allow you to update your DocumentRoot. A collection of algorithms to circumvent this need can be found [http://forums.laravel.com/viewtopic.php?id=1258](on the Laravel forums.) +While pointing the DocumentRoot to the public folder is a commonly used best-practice, it's possible that you may need to use Laravel on a host that does not allow you to update your DocumentRoot. A collection of algorithms to circumvent this need can be found [on the Laravel forums.](http://forums.laravel.com/viewtopic.php?id=1258) ## Basic Configuration From 05ada38d8f6d3642a5d52a668c7b895a1e599a66 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Wed, 11 Jul 2012 22:36:20 +0200 Subject: [PATCH 36/37] style update --- laravel/documentation/install.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/laravel/documentation/install.md b/laravel/documentation/install.md index cb3f9dc6..1e051e06 100644 --- a/laravel/documentation/install.md +++ b/laravel/documentation/install.md @@ -41,10 +41,6 @@ ### Problems? - 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. -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> hotfix/fix_markdown - Verify that your storage folder and the folders within are writable by your web server. From 3acc64051f830097c06a593bebbca36e64fc5cce Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Wed, 11 Jul 2012 22:42:36 +0200 Subject: [PATCH 37/37] simplify navigation copy --- laravel/documentation/contents.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/documentation/contents.md b/laravel/documentation/contents.md index 5a512ad1..63a2b86f 100644 --- a/laravel/documentation/contents.md +++ b/laravel/documentation/contents.md @@ -4,7 +4,7 @@ ### General - [Installation & Setup](/docs/install) - [Requirements](/docs/install#requirements) - [Installation](/docs/install#installation) - - [Server Configuration: Why Public?](/docs/install#server-configuration) + - [Server Configuration](/docs/install#server-configuration) - [Basic Configuration](/docs/install#basic-configuration) - [Environments](/docs/install#environments) - [Cleaner URLs](/docs/install#cleaner-urls)