summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kohana/core/Bootstrap.php4
-rw-r--r--kohana/core/Kohana.php52
-rw-r--r--kohana/helpers/form.php10
-rw-r--r--kohana/helpers/valid.php3
-rw-r--r--kohana/libraries/Image.php62
-rw-r--r--kohana/libraries/Input.php4
-rw-r--r--kohana/libraries/ORM.php31
-rw-r--r--kohana/libraries/View.php54
8 files changed, 128 insertions, 92 deletions
diff --git a/kohana/core/Bootstrap.php b/kohana/core/Bootstrap.php
index 6b2aefaa..57db1648 100644
--- a/kohana/core/Bootstrap.php
+++ b/kohana/core/Bootstrap.php
@@ -10,8 +10,8 @@
* @license http://kohanaphp.com/license.html
*/
-define('KOHANA_VERSION', '2.2');
-define('KOHANA_CODENAME', 'efĂ­mera');
+define('KOHANA_VERSION', '2.3');
+define('KOHANA_CODENAME', 'accipiter');
// Test of Kohana is running in Windows
define('KOHANA_IS_WIN', DIRECTORY_SEPARATOR === '\\');
diff --git a/kohana/core/Kohana.php b/kohana/core/Kohana.php
index e6bfb3f1..c4812e63 100644
--- a/kohana/core/Kohana.php
+++ b/kohana/core/Kohana.php
@@ -975,37 +975,39 @@ final class Kohana {
$file = $class;
}
- if (($filepath = self::find_file($type, $file)) === FALSE)
+ if ($filename = self::find_file($type, $file))
+ {
+ // Load the class
+ require $filename;
+ }
+ else
+ {
+ // The class could not be found
return FALSE;
+ }
- // Load the file
- require $filepath;
-
- if ($type === 'libraries' OR $type === 'helpers')
+ if ($filename = self::find_file($type, self::$configuration['core']['extension_prefix'].$class))
{
- if ($extension = self::find_file($type, self::$configuration['core']['extension_prefix'].$class))
- {
- // Load the extension
- require $extension;
- }
- elseif ($suffix !== 'Core' AND class_exists($class.'_Core', FALSE))
- {
- // Class extension to be evaluated
- $extension = 'class '.$class.' extends '.$class.'_Core { }';
-
- // Start class analysis
- $core = new ReflectionClass($class.'_Core');
+ // Load the class extension
+ require $filename;
+ }
+ elseif ($suffix !== 'Core' AND class_exists($class.'_Core', FALSE))
+ {
+ // Class extension to be evaluated
+ $extension = 'class '.$class.' extends '.$class.'_Core { }';
- if ($core->isAbstract())
- {
- // Make the extension abstract
- $extension = 'abstract '.$extension;
- }
+ // Start class analysis
+ $core = new ReflectionClass($class.'_Core');
- // Transparent class extensions are handled using eval. This is
- // a disgusting hack, but it gets the job done.
- eval($extension);
+ if ($core->isAbstract())
+ {
+ // Make the extension abstract
+ $extension = 'abstract '.$extension;
}
+
+ // Transparent class extensions are handled using eval. This is
+ // a disgusting hack, but it gets the job done.
+ eval($extension);
}
return TRUE;
diff --git a/kohana/helpers/form.php b/kohana/helpers/form.php
index 5162a1ad..bd656604 100644
--- a/kohana/helpers/form.php
+++ b/kohana/helpers/form.php
@@ -144,9 +144,10 @@ class form_Core {
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param string a string to be attached to the end of the attributes
+ * @param boolean encode existing entities
* @return string
*/
- public static function input($data, $value = '', $extra = '')
+ public static function input($data, $value = '', $extra = '', $double_encode = TRUE )
{
if ( ! is_array($data))
{
@@ -161,7 +162,7 @@ class form_Core {
);
// For safe form data
- $data['value'] = html::specialchars($data['value']);
+ $data['value'] = html::specialchars($data['value'], $double_encode);
return '<input'.form::attributes($data).' '.$extra.' />';
}
@@ -212,9 +213,10 @@ class form_Core {
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param string a string to be attached to the end of the attributes
+ * @param boolean encode existing entities
* @return string
*/
- public static function textarea($data, $value = '', $extra = '')
+ public static function textarea($data, $value = '', $extra = '', $double_encode = TRUE )
{
if ( ! is_array($data))
{
@@ -227,7 +229,7 @@ class form_Core {
// Value is not part of the attributes
unset($data['value']);
- return '<textarea'.form::attributes($data, 'textarea').' '.$extra.'>'.html::specialchars($value).'</textarea>';
+ return '<textarea'.form::attributes($data, 'textarea').' '.$extra.'>'.html::specialchars($value, $double_encode).'</textarea>';
}
/**
diff --git a/kohana/helpers/valid.php b/kohana/helpers/valid.php
index 3d3206c8..c2cefb5d 100644
--- a/kohana/helpers/valid.php
+++ b/kohana/helpers/valid.php
@@ -85,9 +85,10 @@ class valid_Core {
*
* @param string IP address
* @param boolean allow IPv6 addresses
+ * @param boolean allow private IP networks
* @return boolean
*/
- public static function ip($ip, $ipv6 = FALSE, $allow_private = FALSE)
+ public static function ip($ip, $ipv6 = FALSE, $allow_private = TRUE)
{
// By default do not allow private and reserved range IPs
$flags = FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
diff --git a/kohana/libraries/Image.php b/kohana/libraries/Image.php
index 3db810e8..bd723a27 100644
--- a/kohana/libraries/Image.php
+++ b/kohana/libraries/Image.php
@@ -303,9 +303,10 @@ class Image_Core {
* @throws Kohana_Exception
* @param string new image filename
* @param integer permissions for new image
+ * @param boolean keep or discard image process actions
* @return object
*/
- public function save($new_image = FALSE, $chmod = 0644)
+ public function save($new_image = FALSE, $chmod = 0644, $keep_actions = FALSE)
{
// If no new image is defined, use the current image
empty($new_image) and $new_image = $this->image['file'];
@@ -328,37 +329,40 @@ class Image_Core {
chmod($new_image, $chmod);
}
}
-
- // Reset the actions
- $this->actions = array();
-
+
+ // Reset actions. Subsequent save() or render() will not apply previous actions.
+ if ($keep_actions === FALSE)
+ $this->actions = array();
+
return $status;
}
- /**
- * Output the image to the browser.
- *
- * @return object
- */
- public function render()
- {
- $new_image = $this->image['file'];
-
- // Separate the directory and filename
- $dir = pathinfo($new_image, PATHINFO_DIRNAME);
- $file = pathinfo($new_image, PATHINFO_BASENAME);
-
- // Normalize the path
- $dir = str_replace('\\', '/', realpath($dir)).'/';
-
- // Process the image with the driver
- $status = $this->driver->process($this->image, $this->actions, $dir, $file, $render = TRUE);
-
- // Reset the actions
- $this->actions = array();
-
- return $status;
- }
+ /**
+ * Output the image to the browser.
+ *
+ * @param boolean keep or discard image process actions
+ * @return object
+ */
+ public function render($keep_actions = FALSE)
+ {
+ $new_image = $this->image['file'];
+
+ // Separate the directory and filename
+ $dir = pathinfo($new_image, PATHINFO_DIRNAME);
+ $file = pathinfo($new_image, PATHINFO_BASENAME);
+
+ // Normalize the path
+ $dir = str_replace('\\', '/', realpath($dir)).'/';
+
+ // Process the image with the driver
+ $status = $this->driver->process($this->image, $this->actions, $dir, $file, $render = TRUE);
+
+ // Reset actions. Subsequent save() or render() will not apply previous actions.
+ if ($keep_actions === FALSE)
+ $this->actions = array();
+
+ return $status;
+ }
/**
* Sanitize a given value type.
diff --git a/kohana/libraries/Input.php b/kohana/libraries/Input.php
index c5289840..a0004621 100644
--- a/kohana/libraries/Input.php
+++ b/kohana/libraries/Input.php
@@ -130,9 +130,9 @@ class Input_Core {
foreach ($_COOKIE as $key => $val)
{
// Ignore special attributes in RFC2109 compliant cookies
- if ($key == '$Version' || $key == '$Path' || $key == '$Domain') {
+ if ($key == '$Version' OR $key == '$Path' OR $key == '$Domain')
continue;
- }
+
// Sanitize $_COOKIE
$_COOKIE[$this->clean_input_keys($key)] = $this->clean_input_data($val);
}
diff --git a/kohana/libraries/ORM.php b/kohana/libraries/ORM.php
index 4a76701b..7fe126c9 100644
--- a/kohana/libraries/ORM.php
+++ b/kohana/libraries/ORM.php
@@ -32,7 +32,7 @@ class ORM_Core {
protected $related = array();
protected $loaded = FALSE;
protected $saved = FALSE;
- protected $sorting = array('id' => 'asc');
+ protected $sorting;
// Related objects
protected $object_relations = array();
@@ -91,6 +91,12 @@ class ORM_Core {
$this->object_name = strtolower(substr(get_class($this), 0, -6));
$this->object_plural = inflector::plural($this->object_name);
+ if (!isset($this->sorting))
+ {
+ // Default sorting
+ $this->sorting = array($this->primary_key => 'asc');
+ }
+
// Initialize database
$this->__initialize();
@@ -1181,29 +1187,6 @@ class ORM_Core {
return $table;
}
-
- /**
- * Outputs ORM iterator joined with given model
- * @param $related_model ORM Model the model related to this ORM
- * @return ORM iterator
- * @author credits to Josh Domagala
- */
- public function join_model($related_model)
- {
- if( !in_array( $related_model->table_name, $this->has_and_belongs_to_many ) )
- {
- return FALSE;
- }
-
- // Get the join table name
- $join_table = $this->join_table($related_model->table_name);
-
- // Return ORM iterator of model
- return $this
- ->join($join_table, $this->foreign_key(NULL, $join_table), $this->foreign_key(TRUE))
- ->where($related_model->foreign_key(NULL, $join_table), $related_model->id)
- ->find_all();
- }
/**
* Returns an ORM model for the given object name;
diff --git a/kohana/libraries/View.php b/kohana/libraries/View.php
index 067ace9c..7a49fd84 100644
--- a/kohana/libraries/View.php
+++ b/kohana/libraries/View.php
@@ -56,6 +56,17 @@ class View_Core {
$this->kohana_local_data = array_merge($this->kohana_local_data, $data);
}
}
+
+ /**
+ * Magic method access to test for view property
+ *
+ * @param string View property to test for
+ * @return boolean
+ */
+ public function __isset($key = NULL)
+ {
+ return $this->is_set($key);
+ }
/**
* Sets the view filename.
@@ -118,6 +129,43 @@ class View_Core {
}
/**
+ * Checks for a property existence in the view locally or globally. Unlike the built in __isset(),
+ * this method can take an array of properties to test simultaneously.
+ *
+ * @param string $key property name to test for
+ * @param array $key array of property names to test for
+ * @return boolean property test result
+ * @return array associative array of keys and boolean test result
+ */
+ public function is_set( $key = FALSE )
+ {
+ // Setup result;
+ $result = FALSE;
+
+ // If key is an array
+ if (is_array($key))
+ {
+ // Set the result to an array
+ $result = array();
+
+ // Foreach key
+ foreach ($key as $property)
+ {
+ // Set the result to an associative array
+ $result[$property] = (array_key_exists($property, $this->kohana_local_data) OR array_key_exists($property, self::$kohana_global_data)) ? TRUE : FALSE;
+ }
+ }
+ else
+ {
+ // Otherwise just check one property
+ $result = (array_key_exists($key, $this->kohana_local_data) OR array_key_exists($key, self::$kohana_global_data)) ? TRUE : FALSE;
+ }
+
+ // Return the result
+ return $result;
+ }
+
+ /**
* Sets a bound variable by reference.
*
* @param string name of variable
@@ -164,10 +212,7 @@ class View_Core {
*/
public function __set($key, $value)
{
- if ( ! isset($this->$key))
- {
- $this->kohana_local_data[$key] = $value;
- }
+ $this->kohana_local_data[$key] = $value;
}
/**
@@ -255,5 +300,4 @@ class View_Core {
return $output;
}
-
} // End View \ No newline at end of file