summaryrefslogtreecommitdiff
path: root/system/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/arr.php4
-rw-r--r--system/helpers/cookie.php4
-rw-r--r--system/helpers/date.php4
-rw-r--r--system/helpers/db.php4
-rw-r--r--system/helpers/download.php4
-rw-r--r--system/helpers/expires.php28
-rw-r--r--system/helpers/feed.php6
-rw-r--r--system/helpers/file.php4
-rw-r--r--system/helpers/form.php4
-rw-r--r--system/helpers/format.php4
-rw-r--r--system/helpers/html.php4
-rw-r--r--system/helpers/inflector.php4
-rw-r--r--system/helpers/num.php4
-rw-r--r--system/helpers/remote.php4
-rw-r--r--system/helpers/request.php4
-rw-r--r--system/helpers/security.php4
-rw-r--r--system/helpers/text.php4
-rw-r--r--system/helpers/upload.php4
-rw-r--r--system/helpers/url.php4
-rw-r--r--system/helpers/utf8.php4
-rw-r--r--system/helpers/valid.php119
21 files changed, 137 insertions, 88 deletions
diff --git a/system/helpers/arr.php b/system/helpers/arr.php
index a1bde230..19026fa9 100644
--- a/system/helpers/arr.php
+++ b/system/helpers/arr.php
@@ -2,9 +2,7 @@
/**
* Array helper class.
*
- * $Id: arr.php 4680 2009-11-10 01:57:00Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/cookie.php b/system/helpers/cookie.php
index 8a2e3659..3680ae34 100644
--- a/system/helpers/cookie.php
+++ b/system/helpers/cookie.php
@@ -2,9 +2,7 @@
/**
* Cookie helper class.
*
- * $Id: cookie.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/date.php b/system/helpers/date.php
index af7e85bd..0b29d28e 100644
--- a/system/helpers/date.php
+++ b/system/helpers/date.php
@@ -2,9 +2,7 @@
/**
* Date helper class.
*
- * $Id: date.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/db.php b/system/helpers/db.php
index ce7583b7..941bb2e6 100644
--- a/system/helpers/db.php
+++ b/system/helpers/db.php
@@ -2,9 +2,7 @@
/**
* Database helper class.
*
- * $Id: $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/download.php b/system/helpers/download.php
index 58a7ab94..0bdb04d9 100644
--- a/system/helpers/download.php
+++ b/system/helpers/download.php
@@ -2,9 +2,7 @@
/**
* Download helper class.
*
- * $Id: download.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/expires.php b/system/helpers/expires.php
index 5f599e13..81468ce3 100644
--- a/system/helpers/expires.php
+++ b/system/helpers/expires.php
@@ -2,9 +2,7 @@
/**
* Controls headers that effect client caching of pages
*
- * $Id: expires.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
@@ -15,18 +13,19 @@ class expires_Core {
* Sets the amount of time before content expires
*
* @param integer Seconds before the content expires
- * @return integer Timestamp when the content expires
+ * @param integer Last modified timestamp in seconds(optional)
+ * @return integer Timestamp when the content expires
*/
public static function set($seconds = 60, $last_modified=null)
{
$now = time();
$expires = $now + $seconds;
- if (empty($last_modified))
- {
- $last_modified = $now;
- }
+ if (empty($last_modified))
+ {
+ $last_modified = $now;
+ }
- header('Last-Modified: '.gmdate('D, d M Y H:i:s T', $last_modified));
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s T', $last_modified));
// HTTP 1.0
header('Expires: '.gmdate('D, d M Y H:i:s T', $expires));
@@ -70,7 +69,7 @@ class expires_Core {
* @uses expires::get()
*
* @param integer Maximum age of the content in seconds
- * @param integer Last modified timestamp in seconds
+ * @param integer Last modified timestamp in seconds(optional)
* @return integer|boolean Timestamp of the If-Modified-Since header or FALSE when header is lacking or malformed
*/
public static function check($seconds = 60, $modified=null)
@@ -79,10 +78,11 @@ class expires_Core {
{
$now = time();
- if (empty($modified))
- {
- $modified = $now;
- }
+ if (empty($last_modified))
+ {
+ $last_modified = $now;
+ }
+ $max_age = $expires - time();
if ($modified <= $last_modified)
{
diff --git a/system/helpers/feed.php b/system/helpers/feed.php
index 4aab1dcd..9831812c 100644
--- a/system/helpers/feed.php
+++ b/system/helpers/feed.php
@@ -2,9 +2,7 @@
/**
* Feed helper class.
*
- * $Id: feed.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
@@ -23,7 +21,7 @@ class feed_Core {
// Check if SimpleXML is installed
if( ! function_exists('simplexml_load_file'))
throw new Kohana_User_Exception('Feed Error', 'SimpleXML must be installed!');
-
+
// Make limit an integer
$limit = (int) $limit;
diff --git a/system/helpers/file.php b/system/helpers/file.php
index 0d4a7980..48fbfc14 100644
--- a/system/helpers/file.php
+++ b/system/helpers/file.php
@@ -2,9 +2,7 @@
/**
* File helper class.
*
- * $Id: file.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/form.php b/system/helpers/form.php
index b7c60c24..3d4f8ad7 100644
--- a/system/helpers/form.php
+++ b/system/helpers/form.php
@@ -2,9 +2,7 @@
/**
* Form helper class.
*
- * $Id: form.php 4699 2009-12-08 18:45:14Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/format.php b/system/helpers/format.php
index 9351afda..7494046a 100644
--- a/system/helpers/format.php
+++ b/system/helpers/format.php
@@ -2,9 +2,7 @@
/**
* Format helper class.
*
- * $Id: format.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/html.php b/system/helpers/html.php
index 2d759ac0..c16031d2 100644
--- a/system/helpers/html.php
+++ b/system/helpers/html.php
@@ -2,9 +2,7 @@
/**
* HTML helper class.
*
- * $Id: html.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/inflector.php b/system/helpers/inflector.php
index 5a2910c0..e7237079 100644
--- a/system/helpers/inflector.php
+++ b/system/helpers/inflector.php
@@ -2,9 +2,7 @@
/**
* Inflector helper class.
*
- * $Id: inflector.php 4722 2009-12-19 17:47:34Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/num.php b/system/helpers/num.php
index 42f13bec..c9e98431 100644
--- a/system/helpers/num.php
+++ b/system/helpers/num.php
@@ -2,9 +2,7 @@
/**
* Number helper class.
*
- * $Id: num.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/remote.php b/system/helpers/remote.php
index 37995cdb..d34899ec 100644
--- a/system/helpers/remote.php
+++ b/system/helpers/remote.php
@@ -2,9 +2,7 @@
/**
* Remote url/file helper.
*
- * $Id: remote.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/request.php b/system/helpers/request.php
index 31afee4e..2cc59b20 100644
--- a/system/helpers/request.php
+++ b/system/helpers/request.php
@@ -2,9 +2,7 @@
/**
* Request helper class.
*
- * $Id: request.php 4692 2009-12-04 15:59:44Z cbandy $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/security.php b/system/helpers/security.php
index 33e5118e..7103bd15 100644
--- a/system/helpers/security.php
+++ b/system/helpers/security.php
@@ -2,9 +2,7 @@
/**
* Security helper class.
*
- * $Id: security.php 4698 2009-12-08 18:39:33Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/text.php b/system/helpers/text.php
index ed7f9cbf..bf82f12a 100644
--- a/system/helpers/text.php
+++ b/system/helpers/text.php
@@ -2,9 +2,7 @@
/**
* Text helper class.
*
- * $Id: text.php 4689 2009-12-02 01:39:24Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/upload.php b/system/helpers/upload.php
index 3aec2ac4..62de674f 100644
--- a/system/helpers/upload.php
+++ b/system/helpers/upload.php
@@ -3,9 +3,7 @@
* Upload helper class for working with the global $_FILES
* array and Validation library.
*
- * $Id: upload.php 4679 2009-11-10 01:45:52Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/url.php b/system/helpers/url.php
index 4a94e894..1bc81230 100644
--- a/system/helpers/url.php
+++ b/system/helpers/url.php
@@ -2,9 +2,7 @@
/**
* URL helper class.
*
- * $Id: url.php 4685 2009-11-30 21:24:06Z isaiah $
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
diff --git a/system/helpers/utf8.php b/system/helpers/utf8.php
index 773f6331..0123cfb3 100644
--- a/system/helpers/utf8.php
+++ b/system/helpers/utf8.php
@@ -12,9 +12,7 @@
* string functions.
* @see http://php.net/mbstring
*
- * $Id$
- *
- * @package Core
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @copyright (c) 2005 Harry Fuecks
diff --git a/system/helpers/valid.php b/system/helpers/valid.php
index cffcd7c0..1f7be223 100644
--- a/system/helpers/valid.php
+++ b/system/helpers/valid.php
@@ -1,10 +1,36 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
- * Validation helper class.
+ * The Valid Helper provides functions to help validate data. They can be used as standalone static functions or
+ * as rules for the Validation Library.
*
- * $Id: valid.php 4679 2009-11-10 01:45:52Z isaiah $
+ * ###### Validation Library Example:
+ * $data = new Validation($_POST);
+ * $data->add_rules('phone', 'required', 'valid::phone[7, 10, 11, 14]')
*
- * @package Core
+ * if ($data->validate())
+ * {
+ * echo 'The phone number is valid';
+ * }
+ * else
+ * {
+ * echo Kohana::debug($data->errors());
+ * }
+ *
+ * [!!] The *valid::* part of the rule is optional, but is recommended to avoid conflicts with php functions.
+ *
+ * For more informaiton see the [Validation] Library.
+ *
+ * ###### Standalone Example:
+ * if (valid::phone($_POST['phone'], array(7, 10, 11, 14))
+ * {
+ * echo 'The phone number is valid';
+ * }
+ * else
+ * {
+ * echo 'Not valid';
+ * }
+ *
+ * @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
@@ -12,9 +38,20 @@
class valid_Core {
/**
- * Validate email, commonly used characters only
+ * Validate an email address. This method is more strict than valid::email_rfc();
*
- * @param string email address
+ * ###### Example:
+ * $email = 'bill@gates.com';
+ * if (valid::email($email))
+ * {
+ * echo "Valid email";
+ * }
+ * else
+ * {
+ * echo "Invalid email";
+ * }
+ *
+ * @param string A email address
* @return boolean
*/
public static function email($email)
@@ -26,6 +63,8 @@ class valid_Core {
* Validate the domain of an email address by checking if the domain has a
* valid MX record.
*
+ * [!!] This function will always return `TRUE` if the checkdnsrr() function isn't avaliable (All Windows platforms before php 5.3)
+ *
* @param string email address
* @return boolean
*/
@@ -41,8 +80,7 @@ class valid_Core {
}
/**
- * Validate email, RFC compliant version
- * Note: This function is LESS strict than valid_email. Choose carefully.
+ * RFC compliant email validation. This function is __LESS__ strict than [valid::email]. Choose carefully.
*
* @see Originally by Cal Henderson, modified to fit Kohana syntax standards:
* @see http://www.iamcal.com/publish/articles/php/parsing_email/
@@ -70,7 +108,18 @@ class valid_Core {
}
/**
- * Validate URL
+ * Basic URL validation.
+ *
+ * ###### Example:
+ * $url = 'http://www.kohanaphp.com';
+ * if (valid::url($url))
+ * {
+ * echo "Valid url";
+ * }
+ * else
+ * {
+ * echo "Invalid url";
+ * }
*
* @param string URL
* @return boolean
@@ -81,7 +130,9 @@ class valid_Core {
}
/**
- * Validate IP
+ * Validates an IP Address. This only tests to see if the ip address is valid,
+ * it doesn't check to see if the ip address is actually in use. Has optional support for
+ * IPv6, and private ip address ranges.
*
* @param string IP address
* @param boolean allow IPv6 addresses
@@ -102,8 +153,19 @@ class valid_Core {
}
/**
- * Validates a credit card number using the Luhn (mod10) formula.
- * @see http://en.wikipedia.org/wiki/Luhn_algorithm
+ * Validates a credit card number using the [Luhn (mod10)](http://en.wikipedia.org/wiki/Luhn_algorithm)
+ * formula.
+ *
+ * ###### Example:
+ * $cc_number = '4111111111111111';
+ * if (valid::credit_card($cc_number, array('visa', 'mastercard')))
+ * {
+ * echo "Valid number";
+ * }
+ * else
+ * {
+ * echo "Invalid number";
+ * }
*
* @param integer credit card number
* @param string|array card type, or an array of card types
@@ -178,7 +240,19 @@ class valid_Core {
}
/**
- * Checks if a phone number is valid.
+ * Checks if a phone number is valid. This function will strip all non-digit
+ * characters from the phone number for testing.
+ *
+ * ###### Example:
+ * $phone_number = '(201) 664-0274';
+ * if (valid::phone($phone_number))
+ * {
+ * echo "Valid phone number";
+ * }
+ * else
+ * {
+ * echo "Invalid phone number";
+ * }
*
* @param string phone number to check
* @return boolean
@@ -198,7 +272,8 @@ class valid_Core {
}
/**
- * Tests if a string is a valid date string.
+ * Tests if a string is a valid date using the php
+ * [strtotime()](http://php.net/strtotime) function
*
* @param string date to check
* @return boolean
@@ -266,9 +341,8 @@ class valid_Core {
/**
* Checks whether a string is a valid number (negative and decimal numbers allowed).
- *
- * @see Uses locale conversion to allow decimal point to be locale specific.
- * @see http://www.php.net/manual/en/function.localeconv.php
+ * This function uses [localeconv()](http://www.php.net/manual/en/function.localeconv.php)
+ * to support international number formats.
*
* @param string input string
* @return boolean
@@ -318,6 +392,19 @@ class valid_Core {
* array(2) would force the number to have 2 decimal places, array(4,2)
* would force the number to have 4 digits and 2 decimal places.
*
+ * ###### Example:
+ * $decimal = '4.5';
+ * if (valid::decimal($decimal, array(2,1)))
+ * {
+ * echo "Valid decimal";
+ * }
+ * else
+ * {
+ * echo "Invalid decimal";
+ * }
+ *
+ * Output: Invalid decimal
+ *
* @param string input string
* @param array decimal format: y or x,y
* @return boolean