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


PHP JString::ucWords方法代码示例

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


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

示例1: importFields

 /**
  * Method to get a unique code_name.
  *
  * @param   array   $data			The data where the original name is stored
  * @param   string  $field			Name of field which allows for handling both code_name and plural_code_name
  *
  * @return	string  $code_name		The modified code_name.
  */
 protected function importFields($data)
 {
     $db = JFactory::getDBO();
     $source_table = $data['source_table'];
     $component_id = $data['component_id'];
     $component_object_id = $data['id'];
     // Get the default fieldset
     $query = $db->getQuery(true);
     // Construct the query
     $query->select($db->quoteName('a.default_fieldset_id'));
     $query->from($db->quoteName('#__componentarchitect_componentobjects') . ' AS a ');
     $query->where($db->quoteName('a.id') . ' = ' . $component_object_id);
     // Setup the query
     $db->setQuery($query->__toString());
     // Return the result
     $default_fieldset_id = $db->loadResult();
     $query->clear();
     $db->setQuery('SHOW COLUMNS FROM ' . $source_table);
     if ($table_fields = $db->loadAssocList()) {
         $query->clear();
         // Construct the query
         $query->select($db->quoteName('a.code_name') . ' AS code_name');
         $query->from($db->quoteName('#__componentarchitect_fields') . ' AS a ');
         $query->where($db->quoteName('a.component_object_id') . ' = ' . $component_object_id);
         // Setup the query
         $db->setQuery($query->__toString());
         // Return the result
         $current_fields = $db->loadColumn();
         $field_type_lookup = array();
         // Get all field types to get the Field Type ID for the field
         $field_types_model = JModelLegacy::getInstance('fieldtypes', 'ComponentarchitectModel', array('ignore_request' => true));
         $field_types_model->setState('list.ordering', 'a.name');
         $field_types_model->setState('list.direction', 'ASC');
         $field_types_model->setState('list.select', 'a.*');
         $field_types = $field_types_model->getItems();
         foreach ($field_types as $field_type) {
             $field_type_lookup[] = $field_type->code_name;
         }
         foreach ($table_fields as $table_field) {
             $field = array();
             $table_field['Field'] = JString::strtolower(preg_replace('/[^a-zA-Z0-9_]/', '_', $table_field['Field']));
             $field['code_name'] = $table_field['Field'];
             // Only process fields if they do not already exist
             if (!in_array($field['code_name'], $current_fields)) {
                 $field['id'] = 0;
                 $field['name'] = JString::ucWords(str_replace('-', ' ', str_replace('_', ' ', $table_field['Field'])));
                 $type_array = explode('(', $table_field['Type']);
                 if (preg_match('/unsigned/i', $table_field['Type'])) {
                     $unsigned = true;
                 } else {
                     $unsigned = false;
                 }
                 $field['mysql_datatype'] = strtoupper(trim(preg_replace('/\\)|unsigned/i', '', $type_array[0])));
                 if (!is_null($table_field['Default']) and $table_field['Default'] != '') {
                     $field['mysql_default'] = "'" . $table_field['Default'] . "'";
                 } else {
                     if ($table_field['Null'] == 'YES' and is_null($table_field['Default'])) {
                         $field['mysql_default'] = "'NULL'";
                     } else {
                         $field['mysql_default'] = '';
                     }
                 }
                 // Set field maxlength
                 if (isset($type_array[1])) {
                     $field['mysql_size'] = trim(preg_replace('/\\)|unsigned/i', '', $type_array[1]));
                 } else {
                     $field['mysql_size'] = '';
                 }
                 switch ($field['mysql_datatype']) {
                     case 'VARCHAR':
                     case 'CHAR':
                         if ((int) $field['mysql_size'] <= 255) {
                             $type = 'text';
                         } else {
                             $type = 'textarea';
                         }
                         $field['maxlength'] = $field['mysql_size'];
                         $field['php_variable_type'] = 'string';
                         if ((int) $field['mysql_size'] <= 100) {
                             $field['size'] = $field['mysql_size'];
                         }
                         if ($field['mysql_default'] == '' and $field['mysql_datatype'] != 'TINYTEXT') {
                             $field['mysql_default'] = "''";
                         }
                         break;
                     case 'INT':
                     case 'BIGINT':
                     case 'SERIAL':
                         // Most likely a foreign key so check if we want to make it modal
                         if ((int) $field['mysql_size'] == 10 and $table_field['Key'] != '') {
                             // Get all the component object names if one matches the field code name (without '_id'_
                             $query->clear();
//.........这里部分代码省略.........
开发者ID:esorone,项目名称:efcpw,代码行数:101,代码来源:componentobject.php


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