Yii 1.1: cihelpers

CodeIgniter Helpers
3 followers

Some helper methods that I copy from CodeIgniter framework.

Usage ΒΆ

Just extract the folder to ext.helpers, them import it to your app.

Some useful helper function:

ArrayHelper::element($item, $array, $default = FALSE)
ArrayHelper::random_element($array)
ArrayHelper::elements($items, $array, $default = FALSE)
DirectoryHelper::directory_map($source_dir, $directory_depth = 0, $hidden = FALSE)
DirectoryHelper::safe_directory($path) {
EmailHelper::valid_email($address)
EmailHelper::send_email($recipient, $subject = 'Test email', $message = 'Hello World')
FileHelper::read_file($file)
FileHelper::write_file($path, $data, $mode = FOPEN_WRITE_CREATE_DESTRUCTIVE)
FileHelper::delete_files($path, $del_dir = FALSE, $level = 0)
FileHelper::get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE)
FileHelper::get_dir_file_info($source_dir, $top_level_only = TRUE, $_recursion = FALSE)
FileHelper::get_file_info($file, $returned_values = array('name', 'server_path', 'size', 'date'))
FileHelper::get_mime_by_extension($file)
FileHelper::symbolic_permissions($perms)
FileHelper::octal_permissions($perms)
InflectorHelper::singular($str)
InflectorHelper::plural($str, $force = FALSE)
InflectorHelper::camelize($str)
InflectorHelper::underscore($str)
InflectorHelper::humanize($str)
NumberHelper::byte_format($num, $precision = 1)
PathHelper::set_realpath($path, $check_existance = FALSE)
StringHelper::trim_slashes($str)
StringHelper::strip_slashes($str)
StringHelper::strip_quotes($str)
StringHelper::quotes_to_entities($str)
StringHelper::reduce_double_slashes($str)
StringHelper::reduce_multiples($str, $character = ',', $trim = FALSE)
StringHelper::random_string($type = 'alnum', $len = 8)
StringHelper::alternator()
StringHelper::repeater($data, $num = 1)
TextHelper::word_limiter($str, $limit = 100, $end_char = '…')
TextHelper::character_limiter($str, $n = 500, $end_char = '…')
TextHelper::ascii_to_entities($str)
TextHelper::entities_to_ascii($str, $all = TRUE)
TextHelper::word_censor($str, $censored, $replacement = '')
TextHelper::highlight_code($str)
TextHelper::// The highlight string encodes and highlights
TextHelper::// The highlight_string requires that the text be surrounded
TextHelper::// Prior to PHP 5, the highligh used icky <font> tags
TextHelper::highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
TextHelper::word_wrap($str, $charlim = '76')
TextHelper::// Use PHP's native to do the initial wordwrap.
TextHelper:: * This will strip tags from a string, split it at its max_length and ellipsize
TextHelper::ellipsize($str, $max_length, $position = 1, $ellipsis = '&hellip;')
TextHelper::utf2ascii($str, $replacespace = false, $by = ''){
XmlHelper::xml_convert($str, $protect_all = FALSE)

Be the first person to leave a comment

Please to leave your comment.

Create extension