本文整理汇总了PHP中humanize函数的典型用法代码示例。如果您正苦于以下问题:PHP humanize函数的具体用法?PHP humanize怎么用?PHP humanize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了humanize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: displayData
function displayData($data = null, $type = 'string', $row = array(), $wrap_tag_open = '', $wrap_tag_close = '')
{
$CI =& get_instance();
if (is_null($data) || is_array($data) || strcmp($data, '') === 0 && !count($row)) {
return $data;
}
switch ($type) {
case 'string':
break;
case 'humanize':
$CI->load->helper("inflector");
$data = humanize($data);
break;
case 'date':
str2USDate($data);
break;
case 'datetime':
$data = str2USDate($data);
break;
case 'money':
$data = '$' . number_format((double) $data, 2);
break;
}
return $wrap_tag_open . $data . $wrap_tag_close;
}
开发者ID:ram-1501,项目名称:rs,代码行数:25,代码来源:common_helper.php
示例2: get_drivers
/**
* Returns a List of Drivers
*/
public static function get_drivers()
{
$drivers = array();
/*
* Humanize the Driver Name
*/
function humanize($segs)
{
$prepped = array();
foreach ($segs as $v) {
$prepped[] = ucfirst($v);
}
return trim(ucfirst(str_replace('Driver', '', implode(' ', $prepped))));
}
/*
* Driverize the Driver Name
*/
function driverize($segs)
{
foreach ($segs as &$v) {
ucfirst($v);
}
return str_replace('_driver', '', implode('_', $segs));
}
foreach (scandir(__DIR__ . '/payment_drivers') as $driver) {
if ($driver[0] != '.') {
$ex = explode('_', str_replace('.php', '', $driver));
$drivers[driverize($ex)] = humanize($ex);
}
}
return $drivers;
}
开发者ID:poseidonjm,项目名称:invoice-ninja,代码行数:35,代码来源:payment_driver.php
示例3: foundation_form_input
function foundation_form_input($name, $args = array())
{
$isValid = form_error($name) ? false : true;
if (!empty($args['default_value'])) {
$default_value = $args['default_value'];
} else {
$default_value = null;
}
$class = !empty($args['class']) ? $args['class'] : '';
$node = "<label>" . humanize($name);
if (!empty($args['as'])) {
switch ($args['as']) {
case 'collection':
if (!empty($args['collection'])) {
if ($args['allow_blank']) {
$args['collection'] = array_merge(array(" " => " "), $args['collection']);
}
$node .= form_dropdown($name, $args['collection'], set_value($name));
}
break;
case 'text':
$node .= form_textarea($name, set_value($name, $default_value));
break;
default:
# ...
break;
}
} else {
$node .= form_input($name, set_value($name, $default_value));
}
$node .= form_error($name, '<div class="error">', '</div>');
$node .= "</label>";
return $node;
}
开发者ID:chloereimer,项目名称:sleepy-me-hotel,代码行数:34,代码来源:foundation_form_helper.php
示例4: add_viewdata
function add_viewdata()
{
$CI =& get_instance();
$ctrler = $CI->router->fetch_class();
// only for pages after login
if ($ctrler != 'login') {
// fallback when mTitle is not set / empty
if (empty($CI->mTitle)) {
// take controller or action name as title
if ($CI->mAction == 'index') {
$CI->mTitle = humanize($CI->mCtrler);
} else {
$CI->mTitle = humanize($CI->mAction);
}
}
// fallback when mViewFile is not set
if (empty($CI->mViewFile)) {
if ($CI->mAction == 'index') {
$CI->mViewFile = $CI->mCtrler;
} else {
$CI->mViewFile = $CI->mCtrler . '/' . $CI->mAction;
}
}
if ($ctrler != 'home') {
// add an "active" entry at the end of breadcrumb (based on mTitle)
$CI->mBreadcrumb[] = array('name' => $CI->mTitle);
}
// push to mViewData before rendering
$CI->mViewData['breadcrumb'] = $CI->mBreadcrumb;
}
// render output
$view_data = empty($CI->mViewData) ? NULL : $CI->mViewData;
$CI->load->view($CI->mViewFile, $view_data);
}
开发者ID:msd1310,项目名称:ci_bootstrap,代码行数:34,代码来源:controller.php
示例5: test_humanize
public function test_humanize()
{
$strs = array('this_is_the_string' => 'This Is The String', 'this_is_another_one' => 'This Is Another One', 'i-am-playing-a-trick' => 'I-am-playing-a-trick', 'what_do_you_think-yo?' => 'What Do You Think-yo?');
foreach ($strs as $str => $expect) {
$this->assertEquals($expect, humanize($str));
}
}
开发者ID:saiful1105020,项目名称:Under-Construction-Bracathon-Project-,代码行数:7,代码来源:inflector_helper_test.php
示例6: info
/**
* Retrieve the info for a module
*
* @access public
* @param string module name
* @return array
*/
public function info($module)
{
if (!empty($this->_cached[$module])) {
return $this->_cached[$module];
}
//if (!$this->is_allowed($module)) return FALSE;
if (!isset($this->_modules[$module])) {
return FALSE;
}
$CI =& get_instance();
$CI->load->helper('inflector');
$CI->load->helper('string');
$defaults = array('module_name' => humanize($module), 'module_uri' => $module, 'model_name' => $module . '_model', 'model_location' => '', 'view_location' => '', 'display_field' => '', 'preview_path' => '', 'views' => array('list' => '_layouts/module_list', 'create_edit' => '_layouts/module_create_edit', 'delete' => '_layouts/module_delete'), 'permission' => $module, 'js_controller' => 'BaseFuelController', 'js_controller_params' => array(), 'js' => '', 'edit_method' => 'find_one_array', 'instructions' => lang('module_instructions_default', $module), 'filters' => array(), 'archivable' => TRUE, 'table_actions' => array('EDIT', 'VIEW', 'DELETE'), 'item_actions' => array('save', 'view', 'publish', 'activate', 'delete', 'duplicate', 'create'), 'list_actions' => array(), 'rows_selectable' => TRUE, 'clear_cache_on_save' => TRUE, 'create_action_name' => 'Create', 'configuration' => '', 'nav_selected' => NULL, 'default_col' => NULL, 'default_order' => NULL, 'sanitize_input' => TRUE, 'sanitize_images' => TRUE, 'displayonly' => FALSE, 'language' => '');
$return = array();
$params = $this->_modules[$module];
foreach ($defaults as $key => $val) {
if (isset($params[$key])) {
$return[$key] = $params[$key];
} else {
$return[$key] = $val;
}
}
$this->_cached[$module] = $return;
return $return;
}
开发者ID:kieranklaassen,项目名称:FUEL-CMS,代码行数:32,代码来源:Fuel_modules.php
示例7: __construct
function __construct()
{
parent::__construct();
if ($this->router->is_module) {
$this->load->add_package_path(MODPATH . $this->router->module_name);
}
$this->CI = $this;
$this->config->load('app');
$this->output->enable_profiler($this->config->item('enable_profiler'));
if (!$this->input->is_cli_request()) {
if ($this->config->config['cookie_path'] == '') {
$x = explode($_SERVER['HTTP_HOST'], $this->config->item('base_url'));
$cookie_path = rtrim($x[1], '/');
$this->CI->config->set_item('cookie_path', $cookie_path == '' ? '/' : $cookie_path);
}
}
$this->load->helper(array('url', 'form', 'x', 'text', 'inflector', 'xform'));
$this->_name = $this->uri->rsegments[1];
$this->_page_title = $this->config->item('page_title') . ' - ' . (empty($this->uri->rsegments[1]) ? '' : humanize($this->uri->rsegments[1])) . (empty($this->uri->rsegments[2]) ? ' ' : ' ' . humanize($this->uri->rsegments[2]));
if ($this->CI->config->item('lang_use_gettext')) {
$this->lang->load_gettext();
}
$this->load->library('session');
$this->load->library('xparam');
if (!isset($this->auth)) {
$this->load->library('xauth', null, 'auth');
}
// if ($this->config->item('debug')) {
// $this->load->driver('cache', array('adapter' => 'dummy'));
// } else {
// reekoheek: cache should always be run
$this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file'));
// }
}
开发者ID:rip-projects,项目名称:judge,代码行数:34,代码来源:base_controller.php
示例8: get_menu_item
private function get_menu_item($menu_id)
{
$this->load->library('table');
$this->load->model('menu_item');
$content_vars = array();
// Template da tabela
$this->table->set_template(array('table_open' => '<table class="table table-striped table-bordered">'));
$this->table->set_heading('Label', 'Ordem', 'Tipo', 'Link', 'Ações');
$query = $this->menu_item->get_by_field('menu_id', $menu_id, array('field' => 'ordem', 'order' => 'asc'));
foreach ($query->result() as $row) {
switch ($row->tipo) {
case 'post':
$link = $this->get_titulo_postagem($row->href);
break;
case 'posts':
$link = $this->get_titulo_categoria($row->href);
break;
case 'link':
$link = $row->href;
break;
case 'funcional':
$link = humanize($row->href);
break;
case 'submenu':
$link = $this->get_titulo_menu($row->href);
break;
}
$this->table->add_row($row->label, $row->ordem, humanize($row->tipo), $link, div(array('class' => 'btn-group btn-group-sm')) . anchor('admin/menuitens/edit/' . $row->id, glyphicon('edit'), array('class' => 'btn btn-default')) . '<button class="btn btn-default" onClick="return confirmar(\'' . site_url('admin/menuitens/delete/' . $row->id) . '\');">' . glyphicon('trash') . '</button>' . div(null, true));
}
$content_vars['menu_id'] = $menu_id;
$content_vars['listagem'] = $this->table->generate();
return $this->load->view('menuitens/index', $content_vars, TRUE);
}
开发者ID:GFhillip,项目名称:wpanel,代码行数:33,代码来源:menus.php
示例9: generate_crud
protected function generate_crud($table, $subject = '')
{
// create CRUD object
$this->load->library('Grocery_CRUD');
$crud = new grocery_CRUD();
$crud->set_table($table);
// auto-generate subject
if (empty($subject)) {
$crud->set_subject(humanize(singular($table)));
}
// load settings from: application/config/grocery_crud.php
$this->load->config('grocery_crud');
$this->mCrudUnsetFields = $this->config->item('grocery_crud_unset_fields');
if ($this->config->item('grocery_crud_unset_jquery')) {
$crud->unset_jquery();
}
if ($this->config->item('grocery_crud_unset_jquery_ui')) {
$crud->unset_jquery_ui();
}
if ($this->config->item('grocery_crud_unset_print')) {
$crud->unset_print();
}
if ($this->config->item('grocery_crud_unset_export')) {
$crud->unset_export();
}
if ($this->config->item('grocery_crud_unset_read')) {
$crud->unset_read();
}
foreach ($this->config->item('grocery_crud_display_as') as $key => $value) {
$crud->display_as($key, $value);
}
// other custom logic to be done outside
$this->mCrud = $crud;
return $crud;
}
开发者ID:TowerX,项目名称:ci_bootstrap_3,代码行数:35,代码来源:Admin_Controller.php
示例10: tabs
function tabs($tabs, $position = 'left', $active = FALSE, $id_prefix = '')
{
if (!$tabs) {
return '';
}
if (!is_array($tabs)) {
return $tabs;
}
$menu = '<ul class="nav nav-tabs">';
$content = '<div class="tab-content">';
foreach ($tabs as $name => $tab) {
if ($tab) {
$name = strtolower(underscore($name));
$menu .= '<li';
$content .= '<div id="' . $id_prefix . $name . '" class="tab-pane';
if ($active === FALSE || $active === $name) {
$menu .= ' class="active"';
$content .= ' active';
$active = TRUE;
}
$menu .= '><a href="#' . $id_prefix . $name . '" data-toggle="tab" class="no-ajax">' . humanize(preg_replace('/tab(\\d)+_/i', '', $name)) . '</a></li>';
$content .= '">' . $tab . '</div>';
}
}
$menu .= '</ul>';
$content .= '</div>';
return '<div class="tabbable tabs-' . $position . '">' . ($position != 'below' ? $menu . $content : $content . $menu) . '</div>';
}
开发者ID:jayalfredprufrock,项目名称:winx,代码行数:28,代码来源:bootstrap_helper.php
示例11: vasp_breadcrumbs
function vasp_breadcrumbs($trail_delimeter = '»', $open_tag = '<p>', $close_tag = '</p>')
{
$CI =& get_instance();
$CI->load->helper('inflector');
$breadcrumbs = array();
if (count($breadcrumbs) == 0) {
$url_parts = array();
$segment = $CI->uri->segment_array();
$last_segment = array_pop($segment);
foreach ($segment as $url_ref) {
// Skip if we already have this breadcrumb and its not admin
//if(in_array($url_ref, $url_parts) or $url_ref == 'admin') continue;
$url_parts[] = $url_ref;
$breadcrumbs[] = array('name' => humanize(str_replace('-', ' ', $url_ref)), 'url' => implode('/', $url_parts), 'current_page' => FALSE);
}
$url_parts[] = $last_segment;
$breadcrumbs[] = array('name' => humanize(str_replace('-', ' ', $last_segment)), 'url' => implode('/', $url_parts), 'current_page' => TRUE);
}
// Build HTML to output
$html = $open_tag . '<a href="' . site_url('home') . '">Home</a> ';
foreach ($breadcrumbs as $breadcrumb) {
if (!$breadcrumb['current_page']) {
$html .= $trail_delimeter . ' ' . '<a href="' . site_url($breadcrumb['url']) . '">' . $breadcrumb['name'] . '</a> ';
} elseif (current_url() === site_url('home') || uri_string() === '') {
$html .= '';
} else {
$html .= $trail_delimeter . ' ' . $breadcrumb['name'];
}
}
$html .= $close_tag;
echo $html;
}
开发者ID:silentworks,项目名称:vaspasian,代码行数:32,代码来源:page_helper.php
示例12: settings
function settings($module)
{
$this->load->helper('form');
$this->load->add_package_path(APPPATH . 'packages/shipping/' . $module . '/');
$this->load->library($module);
//ok, in order for the most flexibility, and in case someone wants to use javascript or something
//the form gets pulled directly from the library.
if (count($_POST) > 0) {
$check = $this->{$module}->check();
if (!$check) {
$this->session->set_flashdata('message', sprintf(lang('settings_updated'), $module));
redirect($this->config->item('admin_folder') . '/shipping');
} else {
//set the error data and form data in the flashdata
$this->session->set_flashdata('message', $check);
$this->session->set_flashdata('post', $_POST);
redirect($this->config->item('admin_folder') . '/shipping/settings/' . $module);
}
} elseif ($this->session->flashdata('post')) {
$data['form'] = $this->{$module}->form($this->session->flashdata('post'));
} else {
$data['form'] = $this->{$module}->form();
}
$data['module'] = $module;
$data['page_title'] = sprintf(lang('shipping_settings'), humanize($module));
$this->view($this->config->item('admin_folder') . '/shipping_module_settings', $data);
}
开发者ID:nagsamayam,项目名称:jcom,代码行数:27,代码来源:shipping.php
示例13: student_name
function student_name($regno, $details)
{
foreach ($details as $std) {
if ($std["regno"] == $regno) {
return humanize($std["name"]);
}
}
}
开发者ID:jithurjacob,项目名称:Placement-Portal-College-of-Engineering-Poonjar--CodeIgniter,代码行数:8,代码来源:performance.php
示例14: is_date_before_date
function is_date_before_date($date, $bdate)
{
if (!$this->is_date($date) || strtotime($date) > strtotime($this->CI->input->post($bdate))) {
$this->set_message('is_date_before_date', "The %s date must come before <strong>" . humanize($bdate) . '</strong>.');
return FALSE;
}
return TRUE;
}
开发者ID:jayalfredprufrock,项目名称:winx,代码行数:8,代码来源:MY_Form_validation.php
示例15: make_label
protected function make_label($id, $label_name = "", $options = array())
{
$option = array_merge($options, array("for" => $id));
if (!is_string($label_name) || strlen($label_name) < 2) {
$label_name = $id;
}
return $this->content_tag("label", humanize($label_name), $option);
}
开发者ID:phpwax,项目名称:phpwax,代码行数:8,代码来源:FormTagHelper.php
示例16: ajax_update
public function ajax_update()
{
$this->_validate();
$bday = $this->input->post('bday');
$data = array('name' => humanize($this->input->post('name')), 'mname' => humanize($this->input->post('mname')), 'lname' => humanize($this->input->post('lname')), 'gender' => humanize($this->input->post('gender')), 'age' => humanize($this->input->post('age')), 'bday' => date('Y-m-d', strtotime($bday)), 'citizenship' => humanize($this->input->post('citizenship')), 'occupation' => humanize($this->input->post('occupation')), 'status' => humanize($this->input->post('status')), 'purok' => humanize($this->input->post('purok')), 'resAddress' => humanize($this->input->post('resAddress')), 'perAddress' => humanize($this->input->post('perAddress')), 'email' => $this->input->post('email'), 'telNum' => $this->input->post('telNum'), 'cpNum' => $this->input->post('cpNum'), 'latlong' => $this->input->post('latlong'));
$this->InfoTable_model->update(array('resident_id' => $this->input->post('resident_id')), $data);
echo json_encode(array("status" => TRUE));
}
开发者ID:emonoel10,项目名称:System,代码行数:8,代码来源:InfoTable2.php
示例17: getHierarchy
function getHierarchy ($titleSort=false) {
$this->CI->load->helper(array('url', 'glib_directory', 'inflector'));
$pathBase = realpath(APPPATH.'controllers');
$pathThis = __FILE__;
foreach (rscandir($pathBase) as $pathController) {
if (
($pathController != $pathThis)
&& (!strpos($pathController, 'index.html'))
) {
// Make Path Relative to Web Root
$controller = rtrim(substr($pathController, strlen($pathBase) + 1 , -4 ), '/');
// Clean The Default Controllers From The List
$defaultController = $GLOBALS["CI"]->router->routes["default_controller"];
if (strpos($controller,$defaultController)) $controller =
preg_replace("/\/$defaultController/i", "", $controller);
elseif ($controller == $defaultController) $controller = '/';
// Send As Output If Not a Private Controller
if (substr($controller, 0, 1) != '_') {
// Set The Title
if ($controller == '/') {
$title = 'Home';
} else {
$title = humanize(ltrim(substr($controller, strrpos($controller, '/')), '/'));
}
// Add The Directory
$data["$controller"] = $title;
// Get The Methods When Necessary
if (!strpos($pathController, $defaultController.'.php')) {
require_once $pathController;
if (!strpos($controller, '/')) $className = $controller;
else $className = substr($controller, strripos($controller, '/') + 1);
$methods = $this->getMethods(ucfirst($className));
foreach ($methods as $method) if ($method != 'index') {
$data["$controller"] = $title;
}
}
}
}
}
if ($titleSort) asort($data);
else ksort($data);
return $data;
}
开发者ID:G-LAB,项目名称:g-lib,代码行数:58,代码来源:Sitemap.php
示例18: index
function index()
{
$this->load->helper('file');
$this->load->helper('inflector');
$data->page_name = 'Options';
$theme_folder = get_dir_file_info(BASEPATH . 'application/views/themes', FALSE, TRUE);
foreach ($theme_folder as $key => $value) {
if (is_dir(BASEPATH . 'application/views/themes/' . $key)) {
$themes[$key]->folder = $key;
$themes[$key]->name = humanize($key);
}
}
$data->themes = $themes;
if ($_POST) {
$this->load->library('validation');
$fields['lifestream_title'] = 'Lifestream Title';
$fields['admin_email'] = 'Admin Email';
$fields['new_password'] = 'New Password';
$fields['new_password_confirm'] = 'New Password Confirm';
$fields['per_page'] = 'Items Per Page';
$this->validation->set_fields($fields);
$rules['lifestream_title'] = "trim|required";
$rules['admin_email'] = "trim|required|valid_email";
$rules['new_password'] = "trim|matches[new_password_confirm]";
$rules['new_password_confirm'] = "trim";
$rules['per_page'] = "numeric";
$this->validation->set_rules($rules);
if ($this->validation->run() == FALSE) {
$data->errors = $this->validation->error_string;
$this->load->view('admin/_header', $data);
$this->load->view('admin/options', $data);
$this->load->view('admin/_footer');
} else {
//set new password if required
if ($this->validation->new_password && $this->validation->new_password != '') {
$password = md5($this->validation->new_password);
$this->db->update('users', array('user_pass' => $password), array('ID' => $this->data->user->ID));
}
//set admin email
$this->db->update('users', array('user_email' => $this->validation->admin_email), array('ID' => $this->data->user->ID));
unset($_POST['new_password']);
unset($_POST['new_password_confirm']);
//save options
foreach ($_POST as $key => $value) {
$option_array[$key]->option_name = $key;
$option_array[$key]->option_value = $value;
}
foreach ($option_array as $option) {
$this->option_model->add_option($option);
}
header('Location: ' . $this->config->item('base_url') . 'admin/options');
}
} else {
$this->load->view('admin/_header', $data);
$this->load->view('admin/options', $data);
$this->load->view('admin/_footer');
}
}
开发者ID:vu-nguyen,项目名称:sweetcron,代码行数:58,代码来源:options.php
示例19: __construct
public function __construct()
{
parent::__construct();
$this->load->helper('inflector');
$this->load->model('user_model', 'users');
$this->mTitle = humanize($this->mAction);
$this->_push_breadcrumb('Account');
$this->_push_breadcrumb($this->mTitle);
}
开发者ID:wisutsak,项目名称:ci_bootstrap_3,代码行数:9,代码来源:Account.php
示例20: __construct
public function __construct()
{
parent::__construct();
$this->load->helper('inflector');
$this->load->library('form_builder');
$this->mTitle = humanize($this->mAction);
$this->_push_breadcrumb('Example');
$this->_push_breadcrumb($this->mTitle);
}
开发者ID:wisutsak,项目名称:ci_bootstrap_3,代码行数:9,代码来源:Example.php
注:本文中的humanize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论