arr
methods
is_assoc

Kohana_Arr::is_assoc(array $array)

Tests if an array is associative or or not.

path

Kohana_Arr::path(array $array, string $path, mixed $default = NULL)

Gets a value from an array using a dot separated path.

// Get the value of $array['foo']['bar']
$value = Arr::path($array, 'foo.bar');
range

Kohana_Arr::range(integer $step = 10, integer $max = 100)

Fill an array with a range of numbers.

get

Kohana_Arr::get(array $array, string $key, mixed $default = NULL)

Retreive a single key from an array. If the key does not exist in the array, the default value will be returned instead.

extract

Kohana_Arr::extract(array $array, array $keys, mixed $default = NULL)

Retrieves multiple keys from an array. If the key does not exist in the array, the default value will be added instead.

binary_search

Kohana_Arr::binary_search(mixed $needle, array $haystack, boolean $sort = false)

Binary search algorithm.

unshift

Kohana_Arr::unshift(array $array, string $key, mixed $val)

Adds a value to the beginning of an associative array.

merge

Kohana_Arr::merge(array $a1)

Merges one or more arrays recursively and preserves all keys. Note that this does not work the same the PHP function array_merge_recursive()!

overwrite

Kohana_Arr::overwrite(array $array1, array $array2)

Overwrites an array with values from input array(s). Non-existing keys will not be appended!

callback

Kohana_Arr::callback(string $str)

Creates a callable function and parameter list from a string representation. Note that this function does not validate the callback string.

// Get the callback function and parameters
list($func, $params) = Arr::callback('Foo::bar(apple,orange)');

// Get the result of the callback
$result = call_user_func_array($func, $params);
controller
properties
request

Kohana_Controller::request

Request that created the controller
methods
before

Kohana_Controller::before()

Automatically executed before the controller action.

after

Kohana_Controller::after()

Automatically executed after the controller action.

cookie
properties
salt

Kohana_Cookie::salt

Magic salt to add to the cookie
expiration

Kohana_Cookie::expiration

Number of seconds before the cookie expires
path

Kohana_Cookie::path

Restrict the path that the cookie is available to
domain

Kohana_Cookie::domain

Restrict the domain that the cookie is available to
secure

Kohana_Cookie::secure

Only transmit cookies over secure connections
httponly

Kohana_Cookie::httponly

Only transmit cookies over HTTP, disabling Javascript access
methods
get

Kohana_Cookie::get(string $key, mixed $default = NULL)

Gets the value of a signed cookie. Cookies without signatures will not be returned. If the cookie signature is present, but invalid, the cookie will be deleted.

set

Kohana_Cookie::set(string $name, string $value, integer $expiration = NULL)

Sets a signed cookie. Note that all cookie values must be strings and no automatic serialization will be performed!

delete

Kohana_Cookie::delete(string $name)

Deletes a cookie by making the value NULL and expiring it.

salt

Kohana_Cookie::salt(string $name, string $value)

Generates a salt string for a cookie based on the name and value.

date
methods
offset

Kohana_Date::offset(string $remote, string $local = NULL)

Returns the offset (in seconds) between two time zones.

seconds

Kohana_Date::seconds(integer $step = 1, integer $start = 0, integer $end = 60)

Number of seconds in a minute, incrementing by a step.

minutes

Kohana_Date::minutes(integer $step = 5)

Number of minutes in an hour, incrementing by a step.

hours

Kohana_Date::hours(integer $step = 1, boolean $long = false, integer $start = NULL)

Number of hours in a day.

ampm

Kohana_Date::ampm(integer $hour)

Returns AM or PM, based on a given hour.

adjust

Kohana_Date::adjust(integer $hour, string $ampm)

Adjusts a non-24-hour number into a 24-hour number.

days

Kohana_Date::days(integer $month, integer $year = false)

Number of days in month.

months

Kohana_Date::months()

Number of months in a year

years

Kohana_Date::years(integer $start = false, integer $end = false)

Returns an array of years between a starting and ending year. Uses the current year +/- 5 as the max/min.

span

Kohana_Date::span(integer $time1, integer $time2 = NULL, string $output = 'years,months,weeks,days,hours,minutes,seconds')

Returns time difference between two timestamps, in human readable format.

fuzzy_span

Kohana_Date::fuzzy_span(integer $timestamp)

Returns the difference between a time and now in a "fuzzy" way.

unix2dos

Kohana_Date::unix2dos(integer $timestamp = false)

Converts a UNIX timestamp to DOS format.

dos2unix

Kohana_Date::dos2unix(integer $timestamp = false)

Converts a DOS timestamp to UNIX format.

encrypt
properties
instances

Kohana_Encrypt::instances

Encrypt class instances
methods
instance

Kohana_Encrypt::instance(string $name = 'default')

Returns a singleton instance of Encrypt. An encryption key must be provided, but default configuration settings will be applied:

"nofb" mode, produces short output with high entropy and supports IV "rijndael-128" (128-bit AES) cipher, the industry standard

encode

Kohana_Encrypt::encode(string $data)

Encrypts a string and returns an encrypted string that can be decoded.

decode

Kohana_Encrypt::decode(string $data)

Decrypts an encoded string back to its original value.

feed
methods
parse

Kohana_Feed::parse(string $feed, integer $limit = 0)

Parses a remote feed into an array.

create

Kohana_Feed::create(array $info, array $items, string $format = 'rss2', string $encoding = 'UTF-8')

Creates a feed from the given parameters.

file
methods
mime

Kohana_File::mime(string $filename)

Attempt to get the mime type from a file. This method is horribly unreliable, due to PHP being horribly unreliable when it comes to determining the mime type of a file.

mime_by_ext

Kohana_File::mime_by_ext(string $extension)

Return the mime type of an extension.

split

Kohana_File::split(string $filename, string $piece_size = 10)

Split a file into pieces matching a specific size.

join

Kohana_File::join(string $filename)

Join a split file into a whole file.

form
methods
open

Kohana_Form::open(string $action = NULL, array $attributes = NULL)

Generates an opening HTML form tag.

close

Kohana_Form::close()

Creates the closing form tag.

input

Kohana_Form::input(string $name, string $value = NULL, array $attributes = NULL)

Creates a form input. If no type is specified, a "text" type input will be returned.

hidden

Kohana_Form::hidden(string $name, string $value = NULL, array $attributes = NULL)

Creates a hidden form input.

password

Kohana_Form::password(string $name, string $value = NULL, array $attributes = NULL)

Creates a password form input.

file

Kohana_Form::file(string $name, string $attributes = NULL)

Creates a file upload form input.

checkbox

Kohana_Form::checkbox(string $name, string $value = NULL, boolean $checked = false, array $attributes = NULL)

Creates a checkbox form input.

radio

Kohana_Form::radio(string $name, string $value = NULL, boolean $checked = false, array $attributes = NULL)

Creates a radio form input.

textarea

Kohana_Form::textarea(string $name, string $body = '', array $attributes = NULL, boolean $double_encode = true)

Creates a textarea form input.

select

Kohana_Form::select(string $name, array $options = NULL, string $selected = NULL, array $attributes = NULL)

Creates a select form input.

submit

Kohana_Form::submit(string $name, string $value, array $attributes = NULL)

Creates a submit form input.

button

Kohana_Form::button(string $name, string $body, array $attributes = NULL)

Creates a button form input. Note that the body of a button is NOT escaped, to allow images and other HTML to be used.

label

Kohana_Form::label(string $input, string $text = NULL, array $attributes = NULL)

Creates a form label.

fragment
properties
lifetime

Kohana_Fragment::lifetime

default number of seconds to cache for
methods
load

Kohana_Fragment::load(string $name, integer $lifetime = NULL)

Load a fragment from cache and display it. Multiple fragments can be nested.

save

Kohana_Fragment::save()

Saves a fragment in the cache.

delete

Kohana_Fragment::delete(string $name)

Delete a cached fragment.

html
properties
attribute_order

Kohana_HTML::attribute_order

preferred order of attributes
windowed_urls

Kohana_HTML::windowed_urls

automatically target external URLs to a new window
methods
chars

Kohana_HTML::chars(string $value, boolean $double_encode = true)

Convert special characters to HTML entities.

anchor

Kohana_HTML::anchor(string $uri, string $title = NULL, array $attributes = NULL, string $protocol = NULL)

Create HTML link anchors. Note that the title is not escaped, to allow HTML elements within links (images, etc).

file_anchor

Kohana_HTML::file_anchor(string $file, string $title = NULL, array $attributes = NULL, string $protocol = NULL)

Creates an HTML anchor to a file. Note that the title is not escaped, to allow HTML elements within links (images, etc).

email

Kohana_HTML::email(string $email)

Generates an obfuscated version of an email address.

mailto

Kohana_HTML::mailto(string $email, string $title = NULL, array $attributes = NULL)

Creates an email anchor. Note that the title is not escaped, to allow HTML elements within links (images, etc).

style

Kohana_HTML::style(string $file, array $attributes = NULL, boolean $index = false)

Creates a style sheet link.

script

Kohana_HTML::script(string $file, array $attributes = NULL, boolean $index = false)

Creates a script link.

image

Kohana_HTML::image(string $file, array $attributes = NULL)

Creates a image link.

attributes

Kohana_HTML::attributes(array $attributes = NULL)

Compiles an array of HTML attributes into an attribute string.

i18n
properties
lang

Kohana_I18n::lang

target language: en-us, es-es, zh-cn, etc
methods
lang

Kohana_I18n::lang(string $lang = NULL)

Get and set the target language.

get

Kohana_I18n::get(string $string)

Returns translation of a string. If no translation exists, the original string will be returned.

load

Kohana_I18n::load(string $lang)

Returns the translation table for a given language.

inflector
methods
uncountable

Kohana_Inflector::uncountable(string $str)

Checks if a word is defined as uncountable.

singular

Kohana_Inflector::singular(string $str, integer $count = NULL)

Makes a plural word singular.

plural

Kohana_Inflector::plural(string $str)

Makes a singular word plural.

camelize

Kohana_Inflector::camelize(string $str)

Makes a phrase camel case.

underscore

Kohana_Inflector::underscore(string $str)

Makes a phrase underscored instead of spaced.

humanize

Kohana_Inflector::humanize(string $str)

Makes an underscored or dashed phrase human-readable.

kohana_config
methods
instance

Kohana_Config::instance()

Get the singleton instance of Kohana_Config.

attach

Kohana_Config::attach(object $reader, boolean $first = true)

Attach a configuration reader.

detach

Kohana_Config::detach(object $reader)

Detaches a configuration reader.

load

Kohana_Config::load(string $group)

Load a configuration group. Searches the readers in order until the group is found. If the group does not exist, an empty configuration array will be loaded using the first reader.

copy

Kohana_Config::copy(string $group)

Copy one configuration group to all of the other readers.

kohana_log
properties
timestamp

Kohana_Log::timestamp

timestamp format
methods
instance

Kohana_Log::instance()

Get the singleton instance of this class and enable writing at shutdown.

attach

Kohana_Log::attach(object $writer, array $types = NULL)

Attaches a log writer.

detach

Kohana_Log::detach(object $writer)

Detaches a log writer.

add

Kohana_Log::add(string $type, string $message)

Adds a message to the log.

write

Kohana_Log::write()

Write and clear all of the messages.

kohana
properties
php_errors

Kohana_Core::php_errors

PHP error code => human readable name
environment

Kohana_Core::environment

current environment name
is_cli

Kohana_Core::is_cli

command line environment?
is_windows

Kohana_Core::is_windows

Windows environment?
magic_quotes

Kohana_Core::magic_quotes

magic quotes enabled?
log_errors

Kohana_Core::log_errors

log errors and exceptions?
charset

Kohana_Core::charset

character set of input and output
base_url

Kohana_Core::base_url

base URL to the application
index_file

Kohana_Core::index_file

application index file
cache_dir

Kohana_Core::cache_dir

cache directory
caching

Kohana_Core::caching

enabling internal caching?
profiling

Kohana_Core::profiling

enable core profiling?
errors

Kohana_Core::errors

enable error handling?
log

Kohana_Core::log

logging object
config

Kohana_Core::config

config object
methods
init

Kohana_Core::init(array $settings = NULL)

Initializes the environment:

  • Disables register_globals and magic_quotes_gpc
  • Determines the current environment
  • Set global settings
  • Sanitizes GET, POST, and COOKIE variables
  • Converts GET, POST, and COOKIE variables to the global character set

Any of the global settings can be set here:

Type Setting Description Default Value
boolean errors use internal error and exception handling? TRUE
boolean profile do internal benchmarking? TRUE
boolean caching cache the location of files between requests? FALSE
string charset character set used for all input and output "utf-8"
string base_url set the base URL for the application "/"
string index_file set the index.php file name "index.php"
string cache_dir set the cache directory path APPPATH."cache"
deinit

Kohana_Core::deinit()

Cleans up the environment:

  • Restore the previous error and exception handlers
  • Destroy the Kohana::$log and Kohana::$config objects
sanitize

Kohana_Core::sanitize(mixed $value)

Recursively sanitizes an input variable:

  • Strips slashes if magic quotes are enabled
  • Normalizes all newlines to LF
auto_load

Kohana_Core::auto_load(string $class)

Provides auto-loading support of Kohana classes, as well as transparent extension of classes that have a _Core suffix.

Class names are converted to file names by making the class name lowercase and converting underscores to slashes:

// Loads classes/my/class/name.php
Kohana::auto_load('My_Class_Name');
modules

Kohana_Core::modules(array $modules = NULL)

Changes the currently enabled modules. Module paths may be relative or absolute, but must point to a directory:

Kohana::modules(array('modules/foo', MODPATH.'bar'));
include_paths

Kohana_Core::include_paths()

Returns the the currently active include paths, including the application and system paths.

find_file

Kohana_Core::find_file(string $dir, string $file, string $ext = NULL)

Finds the path of a file by directory, filename, and extension. If no extension is given, the default EXT extension will be used.

When searching the "config" or "i18n" directory, an array of files will be returned. These files will return arrays which must be merged together.

// Returns an absolute path to views/template.php
Kohana::find_file('views', 'template');

// Returns an absolute path to media/css/style.css
Kohana::find_file('media', 'css/style', 'css');

// Returns an array of all the "mimes" configuration file
Kohana::find_file('config', 'mimes');
list_files

Kohana_Core::list_files(string $directory = NULL, array $paths = NULL)

Recursively finds all of the files in the specified directory.

$views = Kohana::list_files('views');
load

Kohana_Core::load(string $file)

Loads a file within a totally empty scope and returns the output:

$foo = Kohana::load('foo.php');
config

Kohana_Core::config(string $group)

Creates a new configuration object for the requested group.

cache

Kohana_Core::cache(string $name, mixed $data = NULL, integer $lifetime = 60)

Provides simple file-based caching for strings and arrays:

// Set the "foo" cache
Kohana::cache('foo', 'hello, world');

// Get the "foo" cache
$foo = Kohana::cache('foo');

All caches are stored as PHP code, generated with var_export. Caching objects may not work as expected. Storing references or an object or array that has recursion will cause an E_FATAL.

message

Kohana_Core::message(string $file, string $path = NULL, mixed $default = NULL)

Get a message from a file. Messages are arbitary strings that are stored in the messages/ directory and reference by a key. Translation is not performed on the returned values.

// Get "username" from messages/text.php
$username = Kohana::message('text', 'username');
error_handler

Kohana_Core::error_handler()

PHP error handler, converts all errors into ErrorExceptions. This handler respects error_reporting settings.

exception_handler

Kohana_Core::exception_handler(object $e)

Inline exception handler, displays the error message, source of the exception, and the stack trace of the error.

shutdown_handler

Kohana_Core::shutdown_handler()

Catches errors that are not caught by the error handler, such as E_PARSE.

exception_text

Kohana_Core::exception_text(object $e)

Get a single line of text representing the exception:

Error [ Code ]: Message ~ File [ Line ]

debug

Kohana_Core::debug()

Returns an HTML string of debugging information about any number of variables, each wrapped in a "pre" tag:

// Displays the type and value of each variable
echo Kohana::debug($foo, $bar, $baz);
dump

Kohana_Core::dump(mixed $value, integer $length = 128)

Returns an HTML string of information about a single variable.

Borrows heavily on concepts from the Debug class of Nette.

# _dump

Kohana_Core::_dump(mixed $var, integer $length = 128, integer $level = 0)

Helper for Kohana::dump(), handles recursion in arrays and objects.

debug_path

Kohana_Core::debug_path(string $file)

Removes application, system, modpath, or docroot from a filename, replacing them with the plain text equivalents. Useful for debugging when you want to display a shorter path.

// Displays SYSPATH/classes/kohana.php
echo Kohana::debug_path(Kohana::find_file('classes', 'kohana'));
debug_source

Kohana_Core::debug_source(string $file, integer $line_number, integer $padding = 5)

Returns an HTML string, highlighting a specific line of a file, with some number of lines padded above and below.

// Highlights the current line of the current file
echo Kohana::debug_source(__FILE__, __LINE__);
trace

Kohana_Core::trace(string $trace = NULL)

Returns an array of HTML strings that represent each step in the backtrace.

// Displays the entire current backtrace
echo implode('<br/>', Kohana::trace());
model
methods
factory

Kohana_Model::factory(string $name, mixed $db = NULL)

Create a new model instance.

num
methods
ordinal

Kohana_Num::ordinal(integer $number)

Returns the English ordinal suffix (th, st, nd, etc) of a number.

format

Kohana_Num::format(float $number, integer $places, boolean $monetary = false)

Locale-aware number formatting.

profiler
properties
rollover

Kohana_Profiler::rollover

maximium number of application stats to keep
methods
start

Kohana_Profiler::start(string $group, string $name)

Starts a new benchmark and returns a unique token.

stop

Kohana_Profiler::stop(string $token)

Stops a benchmark.

delete

Kohana_Profiler::delete(string $token)

Deletes a benchmark.

groups

Kohana_Profiler::groups()

Returns all the benchmark tokens by group and name as an array.

stats

Kohana_Profiler::stats(array $tokens)

Gets the min, max, average and total of a set of tokens as an array.

total

Kohana_Profiler::total(string $token)

Gets the total execution time and memory usage of a benchmark as a list.

application

Kohana_Profiler::application()

Gets the total application run time and memory usage.

remote
methods
get

Kohana_Remote::get(string $url, array $options = NULL)

Returns the output of a remote URL.

status

Kohana_Remote::status(string $url)

Returns the status code for a URL.

request
properties
messages

Kohana_Request::messages

method

Kohana_Request::method

method: GET, POST, PUT, DELETE, etc
protocol

Kohana_Request::protocol

protocol: http, https, ftp, cli, etc
referrer

Kohana_Request::referrer

referring URL
user_agent

Kohana_Request::user_agent

client user agent
client_ip

Kohana_Request::client_ip

client IP address
is_ajax

Kohana_Request::is_ajax

AJAX-generated request
route

Kohana_Request::route

route matched for this request
status

Kohana_Request::status

HTTP response code: 200, 404, 500, etc
response

Kohana_Request::response

response body
headers

Kohana_Request::headers

headers to send with the response body
directory

Kohana_Request::directory

controller directory
controller

Kohana_Request::controller

controller to be executed
action

Kohana_Request::action

action to be executed in the controller
uri

Kohana_Request::uri

the URI of the request
methods
instance

Kohana_Request::instance(string $uri = true)

Main request singleton instance. If no URI is provided, the URI will be automatically detected using PATH_INFO, REQUEST_URI, or PHP_SELF.

factory

Kohana_Request::factory(string $uri)

Creates a new request object for the given URI.

user_agent

Kohana_Request::user_agent(string $value)

Returns information about the client user agent.

accept_type

Kohana_Request::accept_type(string $type = NULL)

Returns the accepted content types. If a specific type is defined, the quality of that type will be returned.

accept_lang

Kohana_Request::accept_lang(string $lang = NULL)

Returns the accepted languages. If a specific language is defined, the quality of that language will be returned. If the language is not accepted, FALSE will be returned.

accept_encoding

Kohana_Request::accept_encoding(string $type = NULL)

Returns the accepted encodings. If a specific encoding is defined, the quality of that encoding will be returned. If the encoding is not accepted, FALSE will be returned.

# _parse_accept

Kohana_Request::_parse_accept(string $header, array $accepts = NULL)

Parses an accept header and returns an array (type => quality) of the accepted types, ordered by quality.

uri

Kohana_Request::uri(array $params = NULL)

Generates a relative URI for the current route.

param

Kohana_Request::param(string $key = NULL, mixed $default = NULL)

Retrieves a value from the route parameters.

send_headers

Kohana_Request::send_headers()

Sends the response status and all set headers.

redirect

Kohana_Request::redirect(string $url, integer $code = 302)

Redirects as the request response.

send_file

Kohana_Request::send_file(string $filename, string $download = NULL, array $options = NULL)

Send file download as the response. All execution will be halted when this method is called! Use TRUE for the filename to send the current response as the file content. The third parameter allows the following options to be set:

Type Option Description Default Value
boolean inline Display inline instead of download FALSE
string mime_type Manual mime type Automatic
execute

Kohana_Request::execute()

Processes the request, executing the controller. Before the routed action is run, the before() method will be called, which allows the controller to overload the action based on the request parameters. After the action is run, the after() method will be called, for post-processing.

By default, the output from the controller is captured and returned, and no headers are sent.

generate_etag

Kohana_Request::generate_etag()

Generate ETag Generates an ETag from the response ready to be returned

check_cache

Kohana_Request::check_cache(String $etag = NULL)

Check Cache Checks the browser cache to see the response needs to be returned

security
methods
xss_clean

Kohana_Security::xss_clean(string $str)

Remove XSS from user input.

strip_image_tags

Kohana_Security::strip_image_tags(string $str)

Remove image tags from a string.

encode_php_tags

Kohana_Security::encode_php_tags(string $str)

Remove PHP tags from a string.

route
properties
default_action

Kohana_Route::default_action

default action for all routes
methods
set

Kohana_Route::set(string $name, string $uri, array $regex = NULL)

Stores a named route and returns it.

get

Kohana_Route::get(string $name)

Retrieves a named route.

all

Kohana_Route::all()

Retrieves all named routes.

name

Kohana_Route::name()

Get the name of a route.

cache

Kohana_Route::cache(boolean $save = false)

Saves or loads the route cache.

defaults

Kohana_Route::defaults(array $defaults = NULL)

Provides default values for keys when they are not present. The default action will always be "index" unless it is overloaded here.

$route->defaults(array('controller' => 'welcome', 'action' => 'index'));
matches

Kohana_Route::matches(string $uri)

Tests if the route matches a given URI. A successful match will return all of the routed parameters as an array. A failed match will return boolean FALSE.

// This route will only match if the <controller>, <action>, and <id> exist
$params = Route::factory('<controller>/<action>/<id>', array('id' => '\d+'))
    ->matches('users/edit/10');
// The parameters are now: controller = users, action = edit, id = 10

This method should almost always be used within an if/else block:

if ($params = $route->matches($uri))
{
    // Parse the parameters
}
uri

Kohana_Route::uri(array $params = NULL)

Generates a URI for the current route based on the parameters given.

# _compile

Kohana_Route::_compile()

Returns the compiled regular expression for the route. This translates keys and optional groups to a proper PCRE regular expression.

session
methods
instance

Kohana_Session::instance(string $type = 'native', string $id = NULL)

Creates a singleton session of the given type. Some session types (native, database) also support restarting a session by passing a session id as the second parameter.

as_array

Kohana_Session::as_array()

Returns the current session array.

get

Kohana_Session::get(string $key, mixed $default = NULL)

Get a variable from the session array.

set

Kohana_Session::set(string $key, mixed $value)

Set a variable in the session array.

delete

Kohana_Session::delete(string $key)

Removes a variable in the session array.

read

Kohana_Session::read(string $id = NULL)

Loads the session data.

regenerate

Kohana_Session::regenerate()

Generates a new session id and returns it.

write

Kohana_Session::write()

Sets the last_active timestamp and saves the session.

destroy

Kohana_Session::destroy()

Destroy the current session.

# _read

Kohana_Session::_read(string $id = NULL)

Loads the raw session data string and returns it.

# _regenerate

Kohana_Session::_regenerate()

Generate a new session id and return it.

# _write

Kohana_Session::_write()

Writes the current session.

# _destroy

Kohana_Session::_destroy()

Destroys the current session.

text
methods
limit_words

Kohana_Text::limit_words(string $str, integer $limit = 100, string $end_char = NULL)

Limits a phrase to a given number of words.

limit_chars

Kohana_Text::limit_chars(string $str, integer $limit = 100, string $end_char = NULL, boolean $preserve_words = false)

Limits a phrase to a given number of characters.

alternate

Kohana_Text::alternate()

Alternates between two or more strings.

random

Kohana_Text::random(string $type = 'alnum', integer $length = 8)

Generates a random string of a given type and length.

reduce_slashes

Kohana_Text::reduce_slashes(string $str)

Reduces multiple slashes in a string to single slashes.

censor

Kohana_Text::censor(string $str, array $badwords, string $replacement = '#', boolean $replace_partial_words = true)

Replaces the given words with a string.

similar

Kohana_Text::similar(array $words)

Finds the text that is similar between a set of words.

auto_link

Kohana_Text::auto_link(string $text)

Converts text email addresses and anchors into links.

auto_link_urls

Kohana_Text::auto_link_urls(string $text)

Converts text anchors into links.

auto_link_emails

Kohana_Text::auto_link_emails(string $text)

Converts text email addresses into links.

auto_p

Kohana_Text::auto_p(string $str, boolean $br = true)

Automatically applies

<

p> and
markup to text. Basically nl2br() on steroids.

bytes

Kohana_Text::bytes(integer $bytes, string $force_unit = NULL, string $format = NULL, boolean $si = true)

Returns human readable sizes.

widont

Kohana_Text::widont(string $str)

Prevents widow words by inserting a non-breaking space between the last two words.

upload
properties
remove_spaces

Kohana_Upload::remove_spaces

remove spaces in uploaded files
default_directory

Kohana_Upload::default_directory

default upload directory
methods
save

Kohana_Upload::save(array $file, string $filename = NULL, string $directory = NULL, integer $chmod = 420)

Save an uploaded file to a new location. If no filename is provided, the original filename will be used, with a unique prefix added.

This method should be used after validating the $_FILES array:

if ($validate->check())
{
    // Upload is valid, save it
    Upload::save($_FILES['file']);
}
valid

Kohana_Upload::valid(array $file)

Tests if upload data is valid, even if no file was uploaded.

$validate->add_rule('file', 'Upload::valid')
not_empty

Kohana_Upload::not_empty(array $file)

Tests if a successful upload has been made.

$validate->add_rule('file', 'Upload::not_empty');
type

Kohana_Upload::type(array $file, array $allowed)

Test if an uploaded file is an allowed file type, by extension.

$validate->add_rule('file', 'Upload::type', array(array('jpg', 'png', 'gif')));
size

Kohana_Upload::size(array $file, string $size)

Validation rule to test if an uploaded file is allowed by file size. File sizes are defined as: SB, where S is the size (1, 15, 300, etc) and B is the byte modifier: (B)ytes, (K)ilobytes, (M)egabytes, (G)igabytes.

// Uploaded file must be 1MB or less
$validate->add_rule('file', 'Upload::size', array('1M'))
url
methods
base

Kohana_URL::base(boolean $index = false, boolean|string $protocol = false)

Gets the base URL to the application. To include the current protocol, use TRUE. To specify a protocol, provide the protocol as a string.

site

Kohana_URL::site(string $uri = '', string $protocol = false)

Fetches an absolute site URL based on a URI segment.

query

Kohana_URL::query(array $params = NULL)

Merges the current GET parameters with an array of new or overloaded parameters and returns the resulting query string.

title

Kohana_URL::title(string $title, string $separator = '-')

Convert a phrase to a URL-safe title. Note that non-ASCII characters should be transliterated before using this function.

utf8
properties
server_utf8

UTF8::server_utf8

called

UTF8::called

methods
clean

UTF8::clean(mixed $var, string $charset = 'UTF-8')

Recursively cleans arrays, objects, and strings. Removes ASCII control codes and converts to the requested charset while silently discarding incompatible characters.

is_ascii

UTF8::is_ascii(string $str)

Tests whether a string contains only 7-bit ASCII bytes. This is used to determine when to use native functions or UTF-8 functions.

strip_ascii_ctrl

UTF8::strip_ascii_ctrl(string $str)

Strips out device control codes in the ASCII range.

strip_non_ascii

UTF8::strip_non_ascii(string $str)

Strips out all non-7bit ASCII bytes.

transliterate_to_ascii

UTF8::transliterate_to_ascii(string $str, integer $case = 0)

Replaces special/accented UTF-8 characters by ASCII-7 'equivalents'.

strlen

UTF8::strlen(string $str)

Returns the length of the given string.

strpos

UTF8::strpos(string $str, string $search, integer $offset = 0)

Finds position of first occurrence of a UTF-8 string.

strrpos

UTF8::strrpos(string $str, string $search, integer $offset = 0)

Finds position of last occurrence of a char in a UTF-8 string.

substr

UTF8::substr(string $str, integer $offset, integer $length = NULL)

Returns part of a UTF-8 string.

substr_replace

UTF8::substr_replace(string $str, string $replacement, integer $offset)

Replaces text within a portion of a UTF-8 string.

strtolower

UTF8::strtolower(string $str)

Makes a UTF-8 string lowercase.

strtoupper

UTF8::strtoupper(string $str)

Makes a UTF-8 string uppercase.

ucfirst

UTF8::ucfirst(string $str)

Makes a UTF-8 string's first character uppercase.

ucwords

UTF8::ucwords(string $str)

Makes the first character of every word in a UTF-8 string uppercase.

strcasecmp

UTF8::strcasecmp(string $str1, string $str2)

Case-insensitive UTF-8 string comparison.

str_ireplace

UTF8::str_ireplace(string|array $search, string|array $replace, string|array $str, integer $count = NULL)

Returns a string or an array with all occurrences of search in subject (ignoring case) and replaced with the given replace value.

Note: This function is very slow compared to the native version.

stristr

UTF8::stristr(string $str, string $search)

Case-insenstive UTF-8 version of strstr. Returns all of input string from the first occurrence of needle to the end.

strspn

UTF8::strspn(string $str, string $mask, integer $offset = NULL, integer $length = NULL)

Finds the length of the initial segment matching mask.

strcspn

UTF8::strcspn(string $str, string $mask, integer $offset = NULL, integer $length = NULL)

Finds the length of the initial segment not matching mask.

str_pad

UTF8::str_pad(string $str, integer $final_str_length, string $pad_str = ' ', string $pad_type = 1)

Pads a UTF-8 string to a certain length with another string.

str_split

UTF8::str_split(string $str, integer $split_length = 1)

Converts a UTF-8 string to an array.

strrev

UTF8::strrev(string $str)

Reverses a UTF-8 string.

trim

UTF8::trim(string $str, string $charlist = NULL)

Strips whitespace (or other UTF-8 characters) from the beginning and end of a string.

ltrim

UTF8::ltrim(string $str, string $charlist = NULL)

Strips whitespace (or other UTF-8 characters) from the beginning of a string.

rtrim

UTF8::rtrim(string $str, string $charlist = NULL)

Strips whitespace (or other UTF-8 characters) from the end of a string.

ord

UTF8::ord(string $chr)

Returns the unicode ordinal for a character.

to_unicode

UTF8::to_unicode(string $str)

Takes an UTF-8 string and returns an array of ints representing the Unicode characters. Astral planes are supported i.e. the ints in the output can be > 0xFFFF. Occurrances of the BOM are ignored. Surrogates are not allowed.

The Original Code is Mozilla Communicator client code. The Initial Developer of the Original Code is Netscape Communications Corporation. Portions created by the Initial Developer are Copyright (C) 1998 the Initial Developer. Ported to PHP by Henri Sivonen hsivonen@iki.fi, see http://hsivonen.iki.fi/php-utf8/ Slight modifications to fit with phputf8 library by Harry Fuecks hfuecks@gmail.com

from_unicode

UTF8::from_unicode(array $arr)

Takes an array of ints representing the Unicode characters and returns a UTF-8 string. Astral planes are supported i.e. the ints in the input can be > 0xFFFF. Occurrances of the BOM are ignored. Surrogates are not allowed.

The Original Code is Mozilla Communicator client code. The Initial Developer of the Original Code is Netscape Communications Corporation. Portions created by the Initial Developer are Copyright (C) 1998 the Initial Developer. Ported to PHP by Henri Sivonen hsivonen@iki.fi, see http://hsivonen.iki.fi/php-utf8/ Slight modifications to fit with phputf8 library by Harry Fuecks hfuecks@gmail.com.

view
methods
factory

Kohana_View::factory(string $file = NULL, array $data = NULL)

Returns a new View object.

# capture

Kohana_View::capture(string $kohana_view_filename, array $kohana_view_data)

Captures the output that is generated when a view is included. The view data will be extracted to make local variables. This method is static to prevent object scope resolution.

set_global

Kohana_View::set_global(string $key, mixed $value = NULL)

Sets a global variable, similar to the set() method.

bind_global

Kohana_View::bind_global(string $key, mixed $value)

Assigns a global variable by reference, similar to the bind() method.

set_filename

Kohana_View::set_filename(string $file)

Sets the view filename.

set

Kohana_View::set(string $key, mixed $value = NULL)

Assigns a variable by name. Assigned values will be available as a variable within the view file:

// This value can be accessed as $foo within the view
$view->set('foo', 'my value');

You can also use an array to set several values at once:

// Create the values $food and $beverage in the view
$view->set(array('food' => 'bread', 'beverage' => 'water'));
bind

Kohana_View::bind(string $key, mixed $value)

Assigns a value by reference. The benefit of binding is that values can be altered without re-setting them. It is also possible to bind variables before they have values. Assigned values will be available as a variable within the view file:

// This reference can be accessed as $ref within the view
$view->bind('ref', $bar);
render

Kohana_View::render(view $file = NULL)

Renders the view object to a string. Global and local data are merged and extracted to create local variables within the view file.

Note: Global variables with the same key name as local variables will be overwritten by the local variable.

Kohana 3.0.3
sher.pl
Adam Stankiewicz
validate
methods
factory

Kohana_Validate::factory(array $array)

Creates a new Validation instance.

not_empty

Kohana_Validate::not_empty()

Checks if a field is not empty.

regex

Kohana_Validate::regex(string $value, string $expression)

Checks a field against a regular expression.

min_length

Kohana_Validate::min_length(string $value, integer $length)

Checks that a field is long enough.

max_length

Kohana_Validate::max_length(string $value, integer $length)

Checks that a field is short enough.

exact_length

Kohana_Validate::exact_length(string $value, integer $length)

Checks that a field is exactly the right length.

email

Kohana_Validate::email(string $email, boolean $strict = false)

Check an email address for correct format.

email_domain

Kohana_Validate::email_domain(string $email)

Validate the domain of an email address by checking if the domain has a valid MX record.

url

Kohana_Validate::url(string $url)

Validate a URL.

ip

Kohana_Validate::ip(string $ip, boolean $allow_private = true)

Validate an IP.

credit_card

Kohana_Validate::credit_card(integer $number, string|array $type = NULL)

Validates a credit card number using the Luhn (mod10) formula.

phone

Kohana_Validate::phone(string $number)

Checks if a phone number is valid.

date

Kohana_Validate::date(string $str)

Tests if a string is a valid date string.

alpha

Kohana_Validate::alpha(string $str, boolean $utf8 = false)

Checks whether a string consists of alphabetical characters only.

alpha_numeric

Kohana_Validate::alpha_numeric(string $str, boolean $utf8 = false)

Checks whether a string consists of alphabetical characters and numbers only.

alpha_dash

Kohana_Validate::alpha_dash(string $str, boolean $utf8 = false)

Checks whether a string consists of alphabetical characters, numbers, underscores and dashes only.

digit

Kohana_Validate::digit(string $str, boolean $utf8 = false)

Checks whether a string consists of digits only (no dots or dashes).

numeric

Kohana_Validate::numeric(string $str)

Checks whether a string is a valid number (negative and decimal numbers allowed).

Uses {@link http://www.php.net/manual/en/function.localeconv.php locale conversion} to allow decimal point to be locale specific.

range

Kohana_Validate::range(string $number, integer $min, integer $max)

Tests if a number is within a range.

decimal

Kohana_Validate::decimal(string $str, integer $places = 2, integer $digits = NULL)

Checks if a string is a proper decimal format. Optionally, a specific number of digits can be checked too.

color

Kohana_Validate::color(string $str)

Checks if a string is a proper hexadecimal HTML color value. The validation is quite flexible as it does not require an initial "#" and also allows for the short notation using only three instead of six hexadecimal characters.

as_array

Kohana_Validate::as_array()

Returns the array representation of the current object.

label

Kohana_Validate::label(string $field, string $label)

Sets or overwrites the label name for a field.

labels

Kohana_Validate::labels(array $labels)

Sets labels using an array.

filter

Kohana_Validate::filter(string $field, mixed $filter, array $params = NULL)

Overwrites or appends filters to a field. Each filter will be executed once. All rules must be valid callbacks.

// Run trim() on all fields
$validation->filter(TRUE, 'trim');
filters

Kohana_Validate::filters(string $field, array $filters)

Add filters using an array.

rule

Kohana_Validate::rule(string $field, string $rule, array $params = NULL)

Overwrites or appends rules to a field. Each rule will be executed once. All rules must be string names of functions method names.

// The "username" must not be empty and have a minimum length of 4
$validation->rule('username', 'not_empty')
           ->rule('username', 'min_length', array(4));
rules

Kohana_Validate::rules(string $field, array $rules)

Add rules using an array.

callback

Kohana_Validate::callback(string $field, mixed $callback)

Adds a callback to a field. Each callback will be executed only once. No extra parameters can be passed as the format for callbacks is predefined as (Validate $array, $field, array $errors).

// The "username" must be checked with a custom method
$validation->callback('username', array($this, 'check_username'));

To add a callback to every field already set, use TRUE for the field name.

callbacks

Kohana_Validate::callbacks(string $field, array $callbacks)

Add callbacks using an array.

check

Kohana_Validate::check()

Executes all validation filters, rules, and callbacks. This should typically be called within an in/else block.

if ($validation->check())
{
     // The data is valid, do something here
}
error

Kohana_Validate::error(string $field, string $error)

Add an error to a field.

errors

Kohana_Validate::errors(string $file = NULL, mixed $translate = true)

Returns the error messages. If no file is specified, the error message will be the name of the rule that failed. When a file is specified, the message will be loaded from "field/rule", or if no rule-specific message exists, "field/default" will be used. If neither is set, the returned message will be "file/field/rule".

By default all messages are translated using the default language. A string can be used as the second parameter to specified the language that the message was written in.

// Get errors from messages/forms/login.php
$errors = $validate->errors('forms/login');
# matches

Kohana_Validate::matches(string $value, string $match)

Checks if a field matches the value of another field.

offsetExists

ArrayObject::offsetExists()

offsetGet

ArrayObject::offsetGet()

offsetSet

ArrayObject::offsetSet()

offsetUnset

ArrayObject::offsetUnset()

append

ArrayObject::append()

getArrayCopy

ArrayObject::getArrayCopy()

count

ArrayObject::count()

getFlags

ArrayObject::getFlags()

setFlags

ArrayObject::setFlags()

asort

ArrayObject::asort()

ksort

ArrayObject::ksort()

uasort

ArrayObject::uasort()

uksort

ArrayObject::uksort()

natsort

ArrayObject::natsort()

natcasesort

ArrayObject::natcasesort()

unserialize

ArrayObject::unserialize()

serialize

ArrayObject::serialize()

getIterator

ArrayObject::getIterator()

exchangeArray

ArrayObject::exchangeArray()

setIteratorClass

ArrayObject::setIteratorClass()

getIteratorClass

ArrayObject::getIteratorClass()