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


PHP inflector::humanizeModelName方法代码示例

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


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

示例1: createView

 protected function createView($baseModel = NULL, $forceDelete = NULL)
 {
     // Overload the update view
     if ($forceDelete or strcasecmp(Router::$method, 'delete') == 0 and $forceDelete !== FALSE) {
         $this->template->content = new View('generic/delete');
     } else {
         if (strcasecmp(Router::$method, 'create') == 0) {
             $this->template->content = new View(Router::$controller . '/add');
         } else {
             $this->template->content = new View(Router::$controller . '/edit');
         }
     }
     if (is_null($baseModel)) {
         $baseModel = ucfirst($this->baseModel);
     }
     $this->view->title = ucfirst(Router::$method) . ' ' . inflector::humanizeModelName($baseModel);
     Event::run('bluebox.create_view', $this->view);
 }
开发者ID:swk,项目名称:bluebox,代码行数:18,代码来源:powerdns.php

示例2: prepareUpdateView

 protected function prepareUpdateView()
 {
     $numberingOptions = array('number_pools' => array(array('value' => 0, 'text' => 'Select')), 'destinations' => array(array('value' => 0, 'text' => 'Select')));
     $numberTypes = Doctrine::getTable('NumberType')->findAll(Doctrine::HYDRATE_ARRAY);
     foreach ($numberTypes as $numberType) {
         $numbers = Doctrine_Query::create()->select('n.number_id, n.number, d.name')->from('Number n, n.' . str_replace('Number', '', $numberType['class']) . ' d')->where('(n.foreign_id <> ? AND n.foreign_id IS NOT NULL)', array(0))->andWhereIn('n.class_type', array($numberType['class']))->orderBy('number')->execute(array(), Doctrine::HYDRATE_SCALAR);
         if (empty($numbers)) {
             continue;
         }
         $displayName = str_replace('Number', '', $numberType['class']);
         $displayName = inflector::humanizeModelName($displayName);
         $numberingOptions['number_pools'][] = array('value' => $numberType['class'], 'text' => $displayName);
         foreach ($numbers as $number) {
             $numberingOptions['destinations'][] = array('value' => $number['n_number_id'], 'text' => $number['d_name'] . ' (' . $number['n_number'] . ')', 'class' => $numberType['class']);
         }
     }
     $this->view->numberingJson = json_encode($numberingOptions);
     $this->view->keys = json_encode($this->autoattendant['keys']);
     parent::prepareUpdateView();
 }
开发者ID:swk,项目名称:bluebox,代码行数:20,代码来源:autoattendant.php

示例3: foreach

        Check the boxes below to specify what types of features can be assigned to this number.');
?>
    </p>

    <ul>

        <?php 
foreach ($numberTypes['numberTypes'] as $numberType) {
    ?>

            <li>

                <div class="field">

                    <?php 
    echo form::label('numberType_' . $numberType['number_type_id'], inflector::humanizeModelName(str_replace('Number', '', $numberType['class'])));
    ?>

                    <?php 
    echo form::checkbox(array('name' => 'number[NumberPool][][number_type_id]', 'id' => 'numberType_' . $numberType['number_type_id']), $numberType['number_type_id']);
    ?>

                </div>

            </li>

        <?php 
}
?>

    </ul>
开发者ID:swk,项目名称:bluebox,代码行数:31,代码来源:numberPools.php

示例4: poolsDropdown

 public static function poolsDropdown($data, $selected = NULL, $extra = '')
 {
     // standardize the $data as an array, strings default to the class_type
     if (!is_array($data)) {
         $data = array('name' => $data);
     }
     // add in all the defaults if they are not provided
     $data += array('nullOption' => 'Select', 'classType' => FALSE, 'assigned' => TRUE, 'forDependent' => FALSE);
     // if types was just a string then make it an array
     if (!empty($data['classType']) && !is_array($data['classType'])) {
         $data['classType'] = array($data['classType']);
     }
     // append or insert the class
     $data = arr::update($data, 'class', ' pools_dropdown');
     // render a null option if its been set in data
     if (!empty($data['nullOption'])) {
         $options = array(0 => __($data['nullOption']));
     } else {
         $options = array();
     }
     unset($data['nullOption']);
     // check if we should attempt to fill the selected
     $selected = self::_attemptRePopulate($data['name'], $selected);
     // foreach of the number pools make an option
     $pools = self::getPoolTypes();
     foreach ($pools as $pool_id => $pool) {
         // skip this we have a list of number types to include and not this
         if (is_array($data['classType']) && !in_array($pool, $data['classType'])) {
             continue;
         }
         $numbers = Doctrine::getTable('Number')->findByClassType($pool);
         if ($numbers->count() == 0 and $data['assigned']) {
             continue;
         }
         // get the vars out of the class ex: 'DeviceNumber' model
         $classVars = get_class_vars($pool);
         // see if that model has a var called description
         if (empty($classVars['description'])) {
             // if not then clean up the number pool name and use that
             $classVars['description'] = str_replace('Number', '', $pool);
         }
         $classVars['description'] = inflector::humanizeModelName($classVars['description']);
         if ($data['forDependent']) {
             // set a select option with the description or our cleaned up name
             $options[$pool_id . '" title="' . $pool] = $classVars['description'];
             // we are hacking the dropdown helper a bit so we need the selected var
             // to match up with our perceived option value
             if ($selected == $pool_id or $selected == $pool) {
                 $selected = $pool_id . '" title="' . $pool;
             }
         } else {
             // set a select option with the description or our cleaned up name
             $options[$pool_id] = $classVars['description'];
         }
     }
     unset($data['classType'], $data['forDependent'], $data['assigned']);
     return form::dropdown($data, $options, $selected, $extra);
 }
开发者ID:Jaybee-,项目名称:bluebox,代码行数:58,代码来源:numbering.php

示例5: createView

 protected function createView($baseModel = NULL, $forceDelete = NULL)
 {
     // Overload the update view
     if ($forceDelete || strcasecmp(Router::$method, 'delete') == 0 && $forceDelete !== FALSE) {
         $this->template->content = new View('generic/delete');
     } else {
         try {
             $this->template->content = new View(Router::$controller . '/update_' . strtolower($this->baseModel) . '.mus');
         } catch (Exception $e) {
             try {
                 $this->template->content = new View(Router::$controller . '/update_' . strtolower($this->baseModel));
             } catch (Exception $e) {
                 $this->template->content = new View(Router::$controller . '/update');
             }
         }
     }
     if (is_null($baseModel)) {
         $baseModel = ucfirst($baseModel);
     }
     $this->view->title = ucfirst(Router::$method) . ' ' . inflector::humanizeModelName($baseModel);
     Event::run('bluebox.create_view', $this->view);
 }
开发者ID:swk,项目名称:bluebox,代码行数:22,代码来源:bluebox.php

示例6: migrate

 /**
  * Perform a migration of this module.
  *
  * Make sure you rollback any changes if your migration fails!
  *
  * By default, the migrate routine just runs the migrations in Doctrine for your models, based on the version of
  * this module and the version registered in the database.
  * If that's all you need for your migrations, you don't need to override this function.
  * All models in the directory of your module will be migrated.
  *
  * You do not need to override this class if you are not adding additional functionality to it.
  *
  * @return array | NULL Array of failures, or NULL if everything is OK
  */
 public function migrate($identifier)
 {
     $package = Package_Catalog::getPackageByIdentifier($identifier);
     if (!empty($package['models'])) {
         $loadedModels = Doctrine::loadModels($package['directory'] . '/models', Doctrine::MODEL_LOADING_CONSERVATIVE);
     }
     if (empty($loadedModels)) {
         return;
     }
     $installed = Package_Catalog::getInstalledPackage($package['packageName']);
     if (Package_Dependency::compareVersion($package['version'], $installed['version'])) {
         kohana::log('debug', 'Attempting to upgrade package ' . $installed['packageName'] . ' version ' . $installed['version'] . ' to ' . $package['version']);
         foreach ($loadedModels as $modelName) {
             if (get_parent_class($modelName) != 'Bluebox_Record' and get_parent_class($modelName) != 'Doctrine_Record') {
                 continue;
             }
             $migrationDirectory = $package['directory'] . '/migrations/' . $modelName;
             kohana::log('debug', 'Looking for migrations in `' . $migrationDirectory . '`');
             if (is_dir($migrationDirectory)) {
                 try {
                     $migration = new Bluebox_Migration($migrationDirectory, NULL, strtolower($modelName));
                     kohana::log('debug', 'Running migration on ' . $modelName . ' from model version ' . $migration->getCurrentVersion() . ' to ' . $migration->getLatestVersion());
                     $migration->migrate();
                     $msg = inflector::humanizeModelName($modelName);
                     $msg .= ' database table upgraded to model version # ' . $migration->getCurrentVersion();
                     Package_Message::set($msg, 'info', $identifier);
                 } catch (Exception $e) {
                     kohana::log('alert', 'Alerts during migration, this can USUALLY be ignored: ' . $e->getMessage());
                     // TODO: This isnt a great idea, but migrations are so noisy with needless failures... PITA
                     $migration->setCurrentVersion($migration->getLatestVersion());
                     foreach ($migration->getErrors() as $error) {
                         if (strstr($error->getMessage(), 'Already at version')) {
                             $msg = inflector::humanizeModelName($modelName);
                             $msg .= ' database table ' . inflector::lcfirst($error->getMessage());
                             Package_Message::set($msg, 'info', $identifier);
                         } else {
                             Package_Message::set($error->getMessage(), 'alert', $identifier);
                         }
                     }
                 }
             } else {
                 $migration = new Bluebox_Migration(NULL, NULL, strtolower($modelName));
                 $migration->setCurrentVersion(0);
             }
         }
     } else {
         kohana::log('debug', 'Attempting to downgrade package ' . $installed['packageName'] . ' version ' . $installed['version'] . ' to ' . $package['version']);
         foreach ($loadedModels as $modelName) {
             if (get_parent_class($modelName) != 'Bluebox_Record' and get_parent_class($modelName) != 'Doctrine_Record') {
                 continue;
             }
             $migrationDirectory = $installed['directory'] . '/migrations/' . $modelName;
             kohana::log('debug', 'Looking for migrations in `' . $migrationDirectory . '`');
             if (is_dir($migrationDirectory)) {
                 try {
                     $modelVersion = 0;
                     if (is_dir($package['directory'] . '/migrations/' . $modelName)) {
                         $previousMigration = new Doctrine_Migration($package['directory'] . '/migrations/' . $modelName);
                         $modelVersion = $previousMigration->getLatestVersion();
                     }
                     kohana::log('debug', 'Determined that ' . $package['packageName'] . ' version ' . $package['version'] . ' works against ' . $modelName . ' version ' . $modelVersion);
                     $migration = new Bluebox_Migration($migrationDirectory, NULL, strtolower($modelName));
                     kohana::log('debug', 'Running migration on ' . $modelName . ' from model version ' . $migration->getCurrentVersion() . ' to ' . $modelVersion);
                     $migration->migrate($modelVersion);
                     $msg = inflector::humanizeModelName($modelName);
                     $msg .= ' database table downgraded to model version # ' . $migration->getCurrentVersion();
                     Package_Message::set($msg, 'info', $identifier);
                 } catch (Exception $e) {
                     kohana::log('alert', 'Alerts during migration, this can USUALLY be ignored: ' . $e->getMessage());
                     // TODO: This isnt a great idea, but migrations are so noisy with needless failures... PITA
                     $migration->setCurrentVersion($migration->getLatestVersion());
                     foreach ($migration->getErrors() as $error) {
                         if (strstr($error->getMessage(), 'Already at version')) {
                             $msg = inflector::humanizeModelName($modelName);
                             $msg .= ' database table ' . inflector::lcfirst($error->getMessage());
                             Package_Message::set($msg, 'info', $identifier);
                         } else {
                             Package_Message::set($error->getMessage(), 'alert', $identifier);
                         }
                     }
                 }
             } else {
                 $migration = new Bluebox_Migration(NULL, NULL, strtolower($modelName));
                 $migration->setCurrentVersion(0);
             }
         }
//.........这里部分代码省略.........
开发者ID:swk,项目名称:bluebox,代码行数:101,代码来源:Bluebox_Configure.php


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