当前位置: 首页>>代码示例>>PHP>>正文


PHP humanize函数代码示例

本文整理汇总了PHP中humanize函数的典型用法代码示例。如果您正苦于以下问题:PHP humanize函数的具体用法?PHP humanize怎么用?PHP humanize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了humanize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = '&raquo;', $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


注:本文中的humanize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。