-
Notifications
You must be signed in to change notification settings - Fork 0
Library: Ajudante
Para quem trabalha no Brasil, agora pode ter um ajudante que retorna valores comuns como os meses do ano ou mesmo os estados.
[code] <?php <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Ajudante { function estados () { return array ( array ('Acre','AC'), array ('Alagoas','AL'), array ('Amapá','AP'), array ('Amazonas','AM'), array ('Bahia','BA'), array ('Ceará','CE'), array ('Distrito Federal','DF'), array ('Goiás','GO'), array ('Espírito Santo','ES'), array ('Maranhão','MA'), array ('Mato Grosso','MT'), array ('Mato Grosso do Sul','MS'), array ('Minas Gerais','MG'), array ('Pará','PA'), array ('Paraiba','PB'), array ('Paraná','PR'), array ('Pernambuco','PE'), array ('Piauí','PI'), array ('Rio de Janeiro','RJ'), array ('Rio Grande do Norte','RN'), array ('Rio Grande do Sul','RS'), array ('Rondônia','RO'), array ('Rorâima','RR'), array ('São Paulo','SP'), array ('Santa Catarina','SC'), array ('Sergipe','SE'), array ('Tocantins','TO') ); } function ufs ($empty=false) { $estados = self::estados (); $return = array (); foreach ($estados as $value) { $return[$value[1]] = $value[1]; } if ($empty) { array_unshift ($return, 'Estado'); } return $return; } function aviso ($titulo='',$string,$element='div',$extraClass='') { $titulo=($titulo?"
\n":''); return "<$element class="aviso $extraClass">".$titulo."$string\n</$element>"; } function randChr($totalContador,$numeros=false) { $caracteres = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; if ($numeros) $caracteres.='0123456789'; $totalCaracteres = strlen($caracteres); $contador = 0; $return = ''; while ($contador < $totalContador) { $numeroRandomico = mt_rand(0,$totalCaracteres - 1); $return .= $caracteres[$numeroRandomico]; $contador++; } return $return; } function meses ($assoc = false) { $meses = array ( 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' ); return $this->_assoc ($meses, $assoc); } function _assoc ($return, $assoc = false) { if (!$assoc) { return $return; } $assoc = array (); foreach ($return as $item) { $assoc[$item] = $item; } return $assoc; } ?> [/code]- Original author: Derek Jones
- How to extend helpers: See User Guide
- Modified by: Thomas Stapleton (id, classes, selected country option and all option)
- Modified by: Bradley De-Lar (construct, setLayout example)