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


PHP AkInflector::humanize方法代码示例

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


在下文中一共展示了AkInflector::humanize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cast

    function cast()
    {
        $this->model_name = AkInflector::camelize($this->model_name);
        $this->model_file_path = AkInflector::toModelFilename($this->model_name);
        $this->controller_name = empty($this->controller_name) ? $this->model_name : (AkInflector::camelize($this->controller_name));
        $this->controller_file_path = AkInflector::toControllerFilename($this->controller_name);
        $this->controller_class_name = $this->controller_name.'Controller';
        $this->controller_human_name = AkInflector::humanize($this->controller_name);
        $this->helper_var_name = '$'.AkInflector::underscore($this->controller_name).'_helper';

        $this->singular_name = AkInflector::underscore($this->model_name);
        $this->plural_name = AkInflector::pluralize($this->singular_name);
        $this->singular_controller_name = AkInflector::underscore($this->controller_name);

        $this->files = array(
        'controller.php' => $this->controller_file_path,
        /**
         * @todo Implement generic functional tests
         */
        // 'functional_test.php' => AK_TEST_DIR.DS.'functional'.DS.'test_'.$this->controller_class_name.'.php',
        'helper.php' => AK_HELPERS_DIR.DS.trim($this->helper_var_name,'$').'.php',
        'layout' => AK_VIEWS_DIR.DS.'layouts'.DS.$this->singular_controller_name.'.tpl',
        'view_add' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'add.tpl',
        'view_destroy' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'destroy.tpl',
        'view_edit' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'edit.tpl',
        'view_listing' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'listing.tpl',
        'view_show' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'show.tpl',
        'form' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'_form.tpl',
        );

        $this->user_actions = array();
        foreach ((array)@$this->actions as $action){
            $this->user_actions[$action] = AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.$action.'.tpl';
        }
    }
开发者ID:joeymetal,项目名称:v1,代码行数:35,代码来源:scaffold_generator.php

示例2: menu_for_controllers

 function menu_for_controllers($menu_options = array())
 {
     $menu_options = empty($menu_options) ? $this->_get_default_full_menu() : $menu_options;
     $menu = '';
     foreach ($menu_options as $controller => $actions) {
         $controller_name = AkInflector::classify($controller);
         $current_controller_name = $this->_controller->getControllerName();
         $current_action_name = $this->_controller->Request->getAction();
         $controller_class_name = $controller_name . 'Controller';
         $controller_human_name = AkInflector::humanize($controller);
         $controller_file_name = AkInflector::toControllerFilename($controller);
         if (file_exists($controller_file_name)) {
             include_once $controller_file_name;
             if (class_exists($controller_class_name)) {
                 $menu_header = TagHelper::content_tag('h2', TagHelper::content_tag('a', $controller_human_name, array('href' => $this->_controller->urlFor(array('controller' => $controller)))), array('class' => $current_controller_name == $controller_name ? 'current' : ''));
                 $submenu = '';
                 foreach ((array) $actions as $action) {
                     if ($action[0] == '_') {
                         continue;
                     }
                     $submenu .= TagHelper::content_tag('li', TagHelper::content_tag('a', AkInflector::humanize($action), array('href' => $this->_controller->urlFor(array('controller' => $controller, 'action' => $action)))), array('class' => $current_controller_name == $controller_name && $current_action_name == $action ? 'current' : ''));
                 }
                 $menu .= !empty($submenu) ? TagHelper::content_tag('ul', TagHelper::content_tag('li', $menu_header . TagHelper::content_tag('ul', $submenu))) : '';
             }
         }
     }
     return TagHelper::content_tag('div', $menu, array('id' => 'menu'));
 }
开发者ID:joeymetal,项目名称:v1,代码行数:28,代码来源:menu_helper.php

示例3: cast

 function cast()
 {
     $this->model_name = AkInflector::camelize($this->model_name);
     $this->model_file_path = AkInflector::toModelFilename($this->model_name);
     if (empty($this->actions) && !empty($this->controller_name) && strstr($this->controller_name, ',')) {
         $this->controller_name = '';
     }
     $this->controller_name = empty($this->controller_name) ? AkInflector::pluralize($this->model_name) : AkInflector::camelize($this->controller_name);
     $this->controller_file_path = AkInflector::toControllerFilename($this->controller_name);
     $this->controller_class_name = str_replace(array('/', '::'), '_', $this->controller_name . 'Controller');
     $this->controller_name = AkInflector::demodulize($this->controller_name);
     $this->controller_human_name = AkInflector::humanize($this->controller_name);
     $this->helper_name = (AkInflector::is_plural($this->controller_name) ? AkInflector::singularize($this->controller_name) : $this->controller_name) . 'Helper';
     $this->helper_var_name = '$' . AkInflector::underscore($this->helper_name);
     $this->singular_name = AkInflector::underscore($this->model_name);
     $this->plural_name = AkInflector::pluralize($this->singular_name);
     $this->singular_controller_name = AkInflector::underscore($this->controller_name);
     $this->module_preffix = AkInflector::underscore(substr($this->controller_class_name, 0, strrpos($this->controller_class_name, '_')));
     $this->module_preffix = empty($this->module_preffix) ? '' : DS . $this->module_preffix;
     $this->files = array('controller.php' => $this->controller_file_path, 'helper.php' => AK_HELPERS_DIR . $this->module_preffix . DS . trim($this->helper_var_name, '$') . '.php', 'layout' => AK_VIEWS_DIR . DS . 'layouts' . DS . $this->singular_controller_name . '.tpl', 'view_add' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'add.tpl', 'view_destroy' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'destroy.tpl', 'view_edit' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'edit.tpl', 'view_listing' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'listing.tpl', 'view_show' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'show.tpl', 'form' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . '_form.tpl');
     $this->user_actions = array();
     foreach ((array) @$this->actions as $action) {
         $this->user_actions[$action] = AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . $action . '.tpl';
     }
 }
开发者ID:bermi,项目名称:akelos,代码行数:25,代码来源:scaffold_generator.php

示例4: toString

 /**
  * Displays a tring representation of the model for debugging.
  */
 public function toString($print = false)
 {
     $result = '';
     if (!AK_CLI || AK_ENVIRONMENT == 'testing' && !AK_CLI) {
         $result = "<h2>Details for " . AkInflector::humanize(AkInflector::underscore($this->_Model->getModelName())) . " with " . $this->_Model->getPrimaryKey() . " " . $this->_Model->getId() . "</h2>\n<dl>\n";
         foreach ($this->_Model->getColumnNames() as $column => $caption) {
             $result .= "<dt>{$caption}</dt>\n<dd>" . $this->_Model->getAttribute($column) . "</dd>\n";
         }
         $result .= "</dl>\n<hr />";
         if ($print) {
             echo $result;
         }
     } elseif (AK_DEV_MODE) {
         $result = "\n" . str_replace("\n", " ", var_export($this->_Model->getAttributes(), true));
         $result .= "\n";
         echo $result;
         return '';
     } elseif (AK_CLI) {
         $result = "\n-------\n Details for " . AkInflector::humanize(AkInflector::underscore($this->_Model->getModelName())) . " with " . $this->_Model->getPrimaryKey() . " " . $this->_Model->getId() . " ==\n\n/==\n";
         foreach ($this->_Model->getColumnNames() as $column => $caption) {
             $result .= "\t * {$caption}: " . $this->_Model->getAttribute($column) . "\n";
         }
         $result .= "\n\n-------\n";
         if ($print) {
             echo $result;
         }
     }
     return $result;
 }
开发者ID:bermi,项目名称:akelos,代码行数:32,代码来源:debug.php

示例5: typeCondition

 public function typeCondition($table_alias = null)
 {
     $inheritance_column = $this->_ActiveRecord->getInheritanceColumn();
     $type_condition = array();
     $table_name = $this->_ActiveRecord->getTableName();
     $available_types = array_merge(array($this->_ActiveRecord->getModelName()), $this->getSubclasses());
     foreach ($available_types as $subclass) {
         $type_condition[] = ' ' . ($table_alias != null ? $table_alias : $table_name) . '.' . $inheritance_column . ' = \'' . AkInflector::humanize(AkInflector::underscore($subclass)) . '\' ';
     }
     return empty($type_condition) ? '' : '(' . join('OR', $type_condition) . ') ';
 }
开发者ID:bermi,项目名称:akelos,代码行数:11,代码来源:table_inheritance.php

示例6: sortable_link

 function sortable_link($column, $url_options = array(), $link_options = array())
 {
     $default_url_options = array('sort' => $column, 'direction' => empty($this->_controller->params['sort']) ? 'desc' : ($this->_controller->params['sort'] == $column ? empty($this->_controller->params['direction']) ? 'desc' : ($this->_controller->params['direction'] == 'desc' ? 'asc' : 'desc') : 'desc'));
     $page_var_on_url = empty($url_options['page_var_on_url']) ? 'page' : $url_options['page_var_on_url'];
     unset($url_options['page_var_on_url']);
     $url_options = array_merge($default_url_options, $url_options);
     $link_options['href'] = html_entity_decode($this->_controller->url_helper->modify_current_url($url_options, array($page_var_on_url)));
     if (empty($link_options['title'])) {
         $link_options['title'] = $this->_controller->t("Sort by {$column} ({$url_options['direction']})");
     }
     return TagHelper::content_tag('a', $this->_controller->t(AkInflector::humanize($column)), $link_options);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:12,代码来源:pagination_helper.php

示例7: _setupCloner

 function _setupCloner()
 {
     $this->clone_setup_done = true;
     $this->class_to_clone = AkInflector::underscore($this->class_to_clone);
     $this->class_name = AkInflector::underscore($this->class_name);
     $this->clone_replacements = array(AkInflector::camelize($this->class_to_clone) . 'Controller' => AkInflector::camelize($this->class_name) . 'Controller', AkInflector::humanize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::humanize(AkInflector::pluralize($this->class_name)), AkInflector::titleize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::titleize(AkInflector::pluralize($this->class_name)), AkInflector::humanize($this->class_to_clone) => AkInflector::humanize($this->class_name), AkInflector::titleize($this->class_to_clone) => AkInflector::titleize($this->class_name), AkInflector::camelize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::camelize(AkInflector::pluralize($this->class_name)), AkInflector::pluralize($this->class_to_clone) => AkInflector::pluralize($this->class_name), AkInflector::camelize($this->class_to_clone) => AkInflector::camelize($this->class_name), $this->class_to_clone => $this->class_name);
     //AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name).DS.$action.'.tpl'
     $this->files_to_clone = array(AkInflector::toModelFilename($this->class_to_clone) => AkInflector::toModelFilename($this->class_name), AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_to_clone . '.php' => AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_name . '.php', AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_to_clone) . '.yml' => AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_name) . '.yml', AkInflector::toControllerFilename($this->class_to_clone) => AkInflector::toControllerFilename($this->class_name), AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_to_clone . '_controller') . '.php' => AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_name . '_controller') . '.php', AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_to_clone}_helper") . '.php' => AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_name}_helper") . '.php');
     foreach ($this->_getControllerViews() as $view_file) {
         $this->files_to_clone[AK_VIEWS_DIR . DS . $this->class_to_clone . DS . $view_file . '.tpl'] = AK_VIEWS_DIR . DS . $this->class_name . DS . $view_file . '.tpl';
     }
     $this->files_to_clone[AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_to_clone . '.tpl'] = AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_name . '.tpl';
     foreach (Ak::dir(AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone, array('dirs' => false)) as $locale_file) {
         $this->files_to_clone[AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone . DS . $locale_file] = AK_APP_DIR . DS . 'locales' . DS . $this->class_name . DS . $locale_file;
     }
 }
开发者ID:joeymetal,项目名称:v1,代码行数:16,代码来源:clone_generator.php

示例8: menu_for_controllers

 /**
  * Returns a menu for all or several actions in all or several controllers.
  *
  * Let +menu_options+ defaults and this will generate a menu with all actions in all controllers.
  * Set +menu_options+ to an array with keys as controller name and values as actions names.
  *
  * <?php echo $menu_helper->menu_for_controllers(array('advertiser' => array('buy', 'partial_in_template'))); ?>
  * will generate something like :
  * <div id="menu">
  *  <ul>
  *   <li>
  *    <h2><a href="/advertiser">Advertiser</a></h2>
  *    <ul>
  *     <li><a href="/advertiser/buy">Buy</a></li>
  *     <li><a href="/advertiser/partial_in_template">Partial in template</a></li>
  *    </ul>
  *   </li>
  *  </ul>
  * </div>
  *
  * +div_menu_id+: the id of the main div (default is "menu")
  * +current_class+: the class name of the current controller or the current action (default is "current")
  * +title_tag+: the tag that will contain the controller name link (default is "h2"). If it's empty, it won't be present
  */
 public function menu_for_controllers($menu_options = array(), $div_menu_id = 'menu', $current_class = 'current', $title_tag = 'h2')
 {
     $menu_options = empty($menu_options) ? $this->_get_default_full_menu() : $menu_options;
     $menu = '';
     foreach ($menu_options as $controller => $actions) {
         $controller_name = AkInflector::classify($controller);
         $current_controller_name = $this->_controller->getControllerName();
         $current_action_name = $this->_controller->Request->getAction();
         $controller_class_name = $controller_name . 'Controller';
         $controller_human_name = AkInflector::humanize($controller);
         $controller_file_name = AkInflector::toControllerFilename($controller);
         if (file_exists($controller_file_name)) {
             include_once $controller_file_name;
             if (class_exists($controller_class_name)) {
                 $class = $current_controller_name == $controller_name ? array('class' => $current_class) : array();
                 $href = array('href' => $this->_controller->urlFor(array('controller' => $controller)));
                 if (empty($title_tag)) {
                     $_title_tag = 'a';
                     $content = $controller_human_name;
                     $options = array_merge($class, $href);
                 } else {
                     $content = AkTagHelper::content_tag('a', $controller_human_name, $href);
                     $options = $class;
                     $_title_tag = $title_tag;
                 }
                 $menu_header = AkTagHelper::content_tag($_title_tag, $content, $options);
                 $submenu = '';
                 foreach ((array) $actions as $action) {
                     if ($action[0] == '_') {
                         continue;
                     }
                     $submenu .= AkTagHelper::content_tag('li', AkTagHelper::content_tag('a', AkInflector::humanize($action), array('href' => $this->_controller->urlFor(array('controller' => $controller, 'action' => $action)))), $current_controller_name == $controller_name && $current_action_name == $action ? array('class' => $current_class) : array());
                 }
                 $menu .= !empty($submenu) ? AkTagHelper::content_tag('ul', AkTagHelper::content_tag('li', $menu_header . AkTagHelper::content_tag('ul', $submenu))) : '';
             }
         }
     }
     return AkTagHelper::content_tag('div', $menu, array('id' => $div_menu_id));
 }
开发者ID:bermi,项目名称:akelos,代码行数:63,代码来源:ak_menu_helper.php

示例9: humanize

 function humanize($text)
 {
     return AkInflector::humanize($text);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:4,代码来源:text_helper.php

示例10: array

echo "Admin_" . AkInflector::camelize($controller_name) . "Controller";
?>
 extends AdminController
{

    var $controller_information = '<?php 
echo AkInflector::titleize($singular_name);
?>
 management area.';
    
<?php 
echo "    var \$models = '{$CamelCaseSingular}';\n";
echo "    var \$admin_menu_options = array('" . AkInflector::titleize($controller_name) . "'=>array('id'=>'" . AkInflector::underscore($controller_name) . "','url'=>array('controller'=>'" . AkInflector::underscore($controller_name) . "','action'=>'listing')));\n";
echo "    var \$controller_menu_options = array(";
foreach (array('listing', 'add') as $k) {
    echo "'" . AkInflector::humanize($k) . "'=> array('id'=>'{$k}','url'=>array('controller'=>'" . AkInflector::underscore($controller_name) . "','action'=>'{$k}')),";
}
echo ");\n\n";
?>
   
    function index()
    {
        $this->redirectToAction('listing');
    }

<?php 
foreach ((array) @$actions as $action) {
    ?>
    function <?php 
    echo $action;
    ?>
开发者ID:joeymetal,项目名称:v1,代码行数:31,代码来源:controller.php

示例11: error_messages_for

 /**
  * Returns a string with a div containing all the error messages for the object located as an instance variable by the name
  * of <tt>object_name</tt>. This div can be tailored by the following options:
  *
  * * <tt>header_tag</tt> - Used for the header of the error div (default: h2)
  * * <tt>id</tt> - The id of the error div (default: errorExplanation)
  * * <tt>class</tt> - The class of the error div (default: errorExplanation)
  *
  * NOTE: This is a pre-packaged presentation of the errors with embedded strings and a certain HTML structure. If what
  * you need is significantly different from the default presentation, it makes plenty of sense to access the $object->getErrors()
  * instance yourself and set it up. View the source of this method to see how easy it is.
  */
 public function error_messages_for($object_name, $options = array())
 {
     $object = $this->_controller->{$object_name};
     if ($object->hasErrors()) {
         $error_list = '<ul>';
         foreach ($object->getFullErrorMessages() as $field => $errors) {
             foreach ($errors as $error) {
                 $error_list .= AkTagHelper::content_tag('li', $error);
             }
         }
         $error_list .= '</ul>';
         return AkTagHelper::content_tag('div', AkTagHelper::content_tag(!empty($options['header_tag']) ? $options['header_tag'] : 'h2', $this->t('%number_of_errors %errors prohibited this %object_name from being saved', array('%number_of_errors' => $object->countErrors(), '%errors' => $this->t(AkInflector::conditionalPlural($object->countErrors(), 'error')), '%object_name' => $this->t(AkInflector::humanize($object->getModelName()))))) . AkTagHelper::content_tag('p', $this->t('There were problems with the following fields:')) . $error_list, array('id' => !empty($options['id']) ? $options['id'] : 'errorExplanation', 'class' => !empty($options['class']) ? $options['class'] : 'errorExplanation'));
     }
 }
开发者ID:bermi,项目名称:akelos,代码行数:26,代码来源:ak_active_record_helper.php

示例12: getAttributeCaption

 public function getAttributeCaption($attribute)
 {
     return $this->t(AkInflector::humanize($attribute));
 }
开发者ID:codegooglecom,项目名称:bnpanel,代码行数:4,代码来源:model.php

示例13: label_tag

 /**
  * Creates a label field
  *
  * ==== Options  
  * * Creates standard HTML attributes for the tag.
  *
  * ==== Examples
  *   label_tag 'name'
  *   # => <label for="name">Name</label>
  *
  *   label_tag 'name', 'Your name'
  *   # => <label for="name">Your Name</label>
  *
  *   label_tag 'name', nil, :class => 'small_label'
  *   # => <label for="name" class="small_label">Name</label>
  */
 static function label_tag($name, $text = null, $options = array())
 {
     return AkTagHelper::content_tag('label', empty($text) ? AkInflector::humanize($name) : $text, array_merge($options, array('for' => self::sanitize_to_id($name))));
 }
开发者ID:bermi,项目名称:akelos,代码行数:20,代码来源:ak_form_tag_helper.php

示例14: array

            if($this-><?php 
echo $CamelCaseSingular;
?>
 =& $this-><?php 
echo $CamelCaseSingular;
?>
->find($this->params['id'])){
                if($this->Request->isPost()){
                    $this-><?php 
echo $CamelCaseSingular;
?>
->destroy();
                    $this->flash_options = array('seconds_to_close' => 10);
                    $this->flash['notice'] = $this->t('<?php 
echo AkInflector::humanize($singular_name);
?>
 was successfully deleted.');
                    $this->redirectToAction('listing');
                }
            }else {
                $this->flash['error'] = $this->t('<?php 
echo AkInflector::humanize($singular_name);
?>
 not found.');
                $this->redirectToAction('listing');
            }
        }
    }
}

?>
开发者ID:joeymetal,项目名称:v1,代码行数:31,代码来源:controller.php

示例15: getFullErrorMessages

 /**
  * Returns all the full error messages in an array.
  */
 function getFullErrorMessages()
 {
     $full_messages = array();
     foreach ($this->_errors as $attribute => $errors) {
         $full_messages[$attribute] = array();
         foreach ($errors as $error) {
             $full_messages[$attribute][] = $this->t(AkInflector::humanize($attribute)) . ' ' . $error;
         }
     }
     return $full_messages;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:14,代码来源:AkActiveRecord.php


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