We're really sorry, but we couldn't find the resource you requested.
- -Perhaps you would like to go to our instead?
-diff --git a/application/composers.php b/application/composers.php index 5acd4d6c..6e61babb 100644 --- a/application/composers.php +++ b/application/composers.php @@ -37,16 +37,8 @@ return array( | // | }) | - | The "shared" composer is called for every view. This allows the - | convenient binding of global data or assets. - | */ - 'shared' => function($view) - { - // This composer is called for every view. - }, - 'home.index' => array('name' => 'home', function($view) { // This composer is called for the "home.index" view. diff --git a/application/config/error.php b/application/config/error.php index 6cb77488..8d30867a 100644 --- a/application/config/error.php +++ b/application/config/error.php @@ -49,18 +49,11 @@ return array( 'handler' => function($exception, $severity, $message, $config) { - if ($config['detail']) - { - $data = compact('exception', 'severity', 'message'); + $data = compact('exception', 'severity', 'message'); - $response = Response::view('error.exception', $data)->status(500); - } - else - { - $response = Response::error('500'); - } + $data['detailed'] = $config['detail']; - $response->send(); + Response::error('500', $data)->send(); }, /* diff --git a/application/views/error/404.php b/application/views/error/404.php deleted file mode 100644 index 4513dbe0..00000000 --- a/application/views/error/404.php +++ /dev/null @@ -1,64 +0,0 @@ - - -
- - -We're really sorry, but we couldn't find the resource you requested.
- -Perhaps you would like to go to our instead?
-We're really sorry, but something went wrong while we were processing your request.
- -Perhaps you would like to go to our instead?
-getTraceAsString(); ?>-
+
+
You have successfully installed the Laravel framework. Laravel is a simple framework
diff --git a/laravel/bootstrap/core.php b/laravel/bootstrap/core.php
index 2a3a2403..4d2dfcd1 100644
--- a/laravel/bootstrap/core.php
+++ b/laravel/bootstrap/core.php
@@ -20,6 +20,7 @@ define('ROUTE_PATH', APP_PATH.'routes/');
define('SESSION_PATH', STORAGE_PATH.'sessions/');
define('SYS_CONFIG_PATH', SYS_PATH.'config/');
define('SYS_LANG_PATH', SYS_PATH.'language/');
+define('SYS_VIEW_PATH', SYS_PATH.'views/');
define('VIEW_PATH', APP_PATH.'views/');
define('EXT', '.php');
diff --git a/laravel/database/connection.php b/laravel/database/connection.php
index 2790b8a9..ebd695b6 100644
--- a/laravel/database/connection.php
+++ b/laravel/database/connection.php
@@ -109,11 +109,45 @@ class Connection {
*/
public function query($sql, $bindings = array())
{
+ $sql = $this->transform($sql, $bindings);
+
$this->queries[] = compact('sql', 'bindings');
return $this->execute($this->pdo->prepare(trim($sql)), $bindings);
}
+ /**
+ * Transform an SQL query into an executable query.
+ *
+ * Laravel provides a convenient short-cut when writing raw queries for
+ * handling cumbersome "where in" statements. This method will transform
+ * those segments into their full SQL counterparts.
+ *
+ * @param string $sql
+ * @param array $bindings
+ * @return string
+ */
+ protected function transform($sql, $bindings)
+ {
+ if (strpos($sql, '(...)') === false) return $sql;
+
+ for ($i = 0; $i < count($bindings); $i++)
+ {
+ // If the binding is an array, we can assume it is being used to fill
+ // a "where in" condition, so we will replace the next place-holder
+ // in the query with the correct number of parameters based on the
+ // number of elements in this binding.
+ if (is_array($bindings[$i]))
+ {
+ $parameters = implode(', ', array_fill(0, count($bindings[$i]), '?'));
+
+ $sql = preg_replace('~\(\.\.\.\)~', "({$parameters})", $sql, 1);
+ }
+ }
+
+ return $sql;
+ }
+
/**
* Execute a prepared PDO statement and return the appropriate results.
*
diff --git a/laravel/database/grammars/grammar.php b/laravel/database/grammars/grammar.php
index 257f71f3..acb1e1df 100644
--- a/laravel/database/grammars/grammar.php
+++ b/laravel/database/grammars/grammar.php
@@ -19,9 +19,9 @@ class Grammar {
/**
* Compile a SQL SELECT statement from a Query instance.
*
- * The query will be compiled according to the order of the elements specified
- * in the "components" property. The entire query is pased into each component
- * compiler for convenience.
+ * The query will be compiled according to the order of the elements
+ * specified in the "components" property. The entire query is passed
+ * into each component compiler for convenience.
*
* @param Query $query
* @return string
@@ -30,11 +30,15 @@ class Grammar {
{
$sql = array();
- // Iterate through each query component, calling the compiler for that
- // component, and passing the query instance into the compiler.
+ // Iterate through each query component, calling the compiler
+ // for that component, and passing the query instance into
+ // the compiler.
foreach ($this->components as $component)
{
- if ( ! is_null($query->$component)) $sql[] = call_user_func(array($this, $component), $query);
+ if ( ! is_null($query->$component))
+ {
+ $sql[] = call_user_func(array($this, $component), $query);
+ }
}
return implode(' ', Arr::without($sql, array(null, '')));
@@ -59,9 +63,7 @@ class Grammar {
*/
protected function aggregate(Query $query)
{
- list($aggregator, $column) = array($query->aggregate['aggregator'], $query->aggregate['column']);
-
- return 'SELECT '.$aggregator.'('.$this->wrap($column).')';
+ return 'SELECT '.$query->aggregate['aggregator'].'('.$this->wrap($query->aggregate['column']).')';
}
/**
@@ -83,15 +85,18 @@ class Grammar {
*/
protected function joins(Query $query)
{
- // Since creating a JOIN clause using string concatenation is a little cumbersome,
- // we will create a format we can pass to "sprintf" to make things cleaner.
+ // Since creating a JOIN clause using string concatenation is a
+ // little cumbersome, we will create a format we can pass to
+ // "sprintf" to make things cleaner.
$format = '%s JOIN %s ON %s %s %s';
foreach ($query->joins as $join)
{
extract($join, EXTR_SKIP);
- list($column1, $column2) = array($this->wrap($column1), $this->wrap($column2));
+ $column1 = $this->wrap($column1);
+
+ $column2 = $this->wrap($column2);
$sql[] = sprintf($format, $type, $this->wrap($table), $column1, $operator, $column2);
}
@@ -107,15 +112,16 @@ class Grammar {
*/
final protected function wheres(Query $query)
{
- // Each WHERE clause array has a "type" that is assigned by the query builder, and
- // each type has its own compiler function. For example, "where in" queries are
- // compiled by the "where_in" function.
- //
- // The only exception to this rule are "raw" where clauses, which are simply
- // appended to the query as-is, without any further compiling.
+ // Each WHERE clause array has a "type" that is assigned by the
+ // query builder, and each type has its own compiler function.
+ // The only exception to this rule are "raw" where clauses,
+ // which are simply appended to the query as-is, without
+ // any further compiling.
foreach ($query->wheres as $where)
{
- $sql[] = ($where['type'] == 'raw') ? $where['sql'] : $where['connector'].' '.$this->{$where['type']}($where);
+ $sql[] = ($where['type'] !== 'raw')
+ ? $where['connector'].' '.$this->{$where['type']}($where)
+ : $where['sql'];
}
if (isset($sql)) return implode(' ', array_merge(array('WHERE 1 = 1'), $sql));
@@ -207,20 +213,20 @@ class Grammar {
*/
public function insert(Query $query, $values)
{
- // Force every insert to be treated like a batch insert. This simply makes creating
- // the SQL syntax a little easier on us since we can always treat the values as if
- // is an array containing multiple inserts.
+ // Force every insert to be treated like a batch insert.
+ // This simply makes creating the SQL syntax a little
+ // easier on us since we can always treat the values
+ // as if is an array containing multiple inserts.
if ( ! is_array(reset($values))) $values = array($values);
- // Since we only care about the column names, we can pass any of the insert arrays
- // into the "columnize" method. The names should be the same for every insert.
+ // Since we only care about the column names, we can pass
+ // any of the insert arrays into the "columnize" method.
+ // The names should be the same for every insert.
$columns = $this->columnize(array_keys(reset($values)));
- // We need to create a string of comma-delimited insert segments. Each segment contains
- // PDO place-holders for each value being inserted into the table. So, if we are inserting
- // into three columns, the string should look like this:
- //
- // (?, ?, ?), (?, ?, ?), (?, ?, ?)
+ // We need to create a string of comma-delimited insert
+ // segments. Each segment contains PDO place-holders for
+ // each value being inserted into the table.
$parameters = implode(', ', array_fill(0, count($values), '('.$this->parameterize(reset($values)).')'));
return 'INSERT INTO '.$this->wrap($query->from).' ('.$columns.') VALUES '.$parameters;
@@ -229,8 +235,9 @@ class Grammar {
/**
* Compile a SQL UPDATE statment from a Query instance.
*
- * Note: Since UPDATE statements can be limited by a WHERE clause, this method will
- * use the same WHERE clause compilation functions as the "select" method.
+ * Note: Since UPDATE statements can be limited by a WHERE clause,
+ * this method will use the same WHERE clause compilation
+ * functions as the "select" method.
*
* @param Query $query
* @param array $values
@@ -255,17 +262,16 @@ class Grammar {
}
/**
- * The following functions primarily serve as utility functions for the grammar.
- * They perform tasks such as wrapping values in keyword identifiers or creating
- * variable lists of bindings. Most likely, they will not need to change across
- * various database systems.
+ * The following functions primarily serve as utility functions
+ * for the grammar. They perform tasks such as wrapping values
+ * in keyword identifiers or creating variable lists of bindings.
*/
/**
* Create a comma-delimited list of wrapped column names.
*
- * Optionally, an "append" value may be passed to the method. This value will be
- * appended to every wrapped column name.
+ * Optionally, an "append" value may be passed to the method.
+ * This value will be appended to every wrapped column name.
*
* @param array $columns
* @param string $append
@@ -284,9 +290,9 @@ class Grammar {
/**
* Wrap a value in keyword identifiers.
*
- * They keyword identifier used by the method is specified as a property on
- * the grammar class so it can be conveniently overriden without changing
- * the wrapping logic itself.
+ * They keyword identifier used by the method is specified as
+ * a property on the grammar class so it can be conveniently
+ * overriden without changing the wrapping logic itself.
*
* @param string $value
* @return string
diff --git a/laravel/str.php b/laravel/str.php
index 10066696..b01d397b 100644
--- a/laravel/str.php
+++ b/laravel/str.php
@@ -98,6 +98,55 @@ class Str {
return strlen($value);
}
+ /**
+ * Limit the number of chars in a string
+ *
+ *
+ * // Limit the characters
+ * echo Str::limit_chars('taylor otwell', 3);
+ * results in 'tay...'
+ *
+ *
+ * @param string $value
+ * @param int $length
+ * @param string $end
+ * @return string
+ */
+ public static function limit($value, $length = 100, $end = '...')
+ {
+ if (static::length($value) <= $length) return $value;
+
+ if (function_exists('mb_substr'))
+ {
+ return mb_substr($value, 0, $length).$end;
+ }
+
+ return substr($value, 0, $length).$end;
+ }
+
+ /**
+ * Limit the number of words in a string
+ *
+ *
+ * // Limit the words
+ * echo Str::limit_chars('This is a sentence.', 3);
+ * results in 'This is a...'
+ *
+ *
+ * @param string $value
+ * @param int $length
+ * @param string $end
+ * @return string
+ */
+ public static function limit_words($value, $length = 100, $end = '...')
+ {
+ $count = str_word_count($value,1);
+
+ if ($count <= $length) return $value;
+
+ return implode(' ',array_slice($count,0,$length)).$end;
+ }
+
/**
* Convert a string to 7-bit ASCII.
*
diff --git a/laravel/view.php b/laravel/view.php
index cd54d553..1739265a 100644
--- a/laravel/view.php
+++ b/laravel/view.php
@@ -59,7 +59,14 @@ class View {
foreach (array(EXT, BLADE_EXT) as $extension)
{
- if (file_exists($path = VIEW_PATH.$view.$extension)) return $path;
+ if (file_exists($path = VIEW_PATH.$view.$extension))
+ {
+ return $path;
+ }
+ elseif (file_exists($path = SYS_VIEW_PATH.$view.$extension))
+ {
+ return $path;
+ }
}
throw new \Exception("View [$view] does not exist.");
@@ -145,10 +152,6 @@ class View {
{
if (is_null(static::$composers)) static::$composers = require APP_PATH.'composers'.EXT;
- // The shared composer is called for every view instance. This allows the
- // convenient binding of global view data or partials within a single method.
- if (isset(static::$composers['shared'])) call_user_func(static::$composers['shared'], $view);
-
if (isset(static::$composers[$view->view]))
{
foreach ((array) static::$composers[$view->view] as $key => $value)
diff --git a/laravel/views/error/404.php b/laravel/views/error/404.php
new file mode 100644
index 00000000..8f7b48a0
--- /dev/null
+++ b/laravel/views/error/404.php
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+ + We couldn't find the page you requested on our servers. We're really sorry about that. + It's our fault, not yours. We'll work hard to get this page back online as soon as possible. +
+ ++ Perhaps you would like to go to our ? +
+
+
+
+
+
+
+ + Something went wrong on our servers while we were processing your request. + We're really sorry about this, and will work hard to get this resolved as + soon as possible. +
+ ++ Perhaps you would like to go to our ? +
+ + +