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


PHP inflector类代码示例

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


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

示例1: index

 function index()
 {
     $module_id = Sanitize::getInt($this->params, 'module_id', Sanitize::getInt($this->data, 'module_id'));
     $this->viewSuffix = Sanitize::getString($this->params['module'], 'tmpl_suffix');
     $cache_file = 'modules_totals_' . $module_id . '_' . md5(serialize($this->params['module']));
     $page = $this->cached($cache_file);
     if ($page) {
         return $page;
     }
     // Initialize variables
     $extension = Sanitize::getString($this->params['module'], 'extension');
     // Automagically load and initialize Everywhere Model
     App::import('Model', 'everywhere_' . $extension, 'jreviews');
     $class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
     $conditions_reviews = array('Review.published = 1');
     $extension == 'com_content' and $conditions_listings = array('Listing.state = 1');
     $extension != '' and $conditions_reviews[] = "Review.mode = " . $this->quote($extension);
     if (class_exists($class_name)) {
         $this->Listing = new $class_name();
         $this->Listing->_user = $this->_user;
         $listings = $this->Listing->findCount(array('conditions' => $conditions_listings), 'DISTINCT Listing.' . $this->Listing->realKey);
         $reviews = $this->Review->findCount(array('conditions' => $conditions_reviews), 'DISTINCT Review.id');
     }
     # Send variables to view template
     $this->set(array('listing_count' => isset($listings) ? $listings : 0, 'review_count' => isset($reviews) ? $reviews : 0));
     $page = $this->render('modules', 'totals');
     # Save cached version
     $this->cacheView('modules', 'totals', $cache_file, $page);
     return $page;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:30,代码来源:module_totals_controller.php

示例2: __toString

 public function __toString()
 {
     if ($this->name) {
         return $this->name;
     }
     return inflector::humanize(current(explode('@', $this->email)));
 }
开发者ID:hdragomir,项目名称:ProjectsLounge,代码行数:7,代码来源:user.php

示例3: initialize

 /**
  * Sets up foreign and through properly.
  *
  * @param   string  $model
  * @param   string  $column
  * @return  void
  */
 public function initialize($model, $column)
 {
     // Default to the name of the column
     if (empty($this->foreign)) {
         $foreign_model = inflector::singular($column);
         $this->foreign = $foreign_model . '.' . $foreign_model . ':primary_key';
     } elseif (is_string($this->foreign) and FALSE === strpos($this->foreign, '.')) {
         $this->foreign = $this->foreign . '.' . $this->foreign . ':primary_key';
     }
     // Create an array from them for easier access
     if (!is_array($this->foreign)) {
         $this->foreign = array_combine(array('model', 'field'), explode('.', $this->foreign));
     }
     // Create the default through connection
     if (empty($this->through) or is_string($this->through)) {
         if (empty($this->through)) {
             // Find the join table based on the two model names pluralized,
             // sorted alphabetically and with an underscore separating them
             $through = array(inflector::plural($this->foreign['model']), inflector::plural($model));
             sort($through);
             $this->through = implode('_', $through);
         }
         $this->through = array('model' => $this->through, 'fields' => array(inflector::singular($model) . ':foreign_key', inflector::singular($this->foreign['model']) . ':foreign_key'));
     }
     parent::initialize($model, $column);
 }
开发者ID:piotrtheis,项目名称:jelly,代码行数:33,代码来源:manytomany.php

示例4: packageData

 public static function packageData(&$metadata, $filepath)
 {
     $metadata['directory'] = dirname($filepath);
     if (empty($metadata['packageName'])) {
         $metadata['packageName'] = dirname(str_replace(DOCROOT, '', $filepath));
     }
     if (empty($metadata['identifier'])) {
         //kohana::log('debug', 'Creating identifier from md5(\'' .$metadata['packageName'] .$metadata['version'] .'\');');
         $metadata['identifier'] = md5($metadata['packageName'] . $metadata['version']);
     }
     if (empty($metadata['displayName'])) {
         $metadata['displayName'] = ucfirst(inflector::humanize($metadata['packageName']));
     }
     if (!is_bool($metadata['default'])) {
         $metadata['default'] = FALSE;
     }
     if (!is_array($metadata['required'])) {
         $metadata['required'] = array();
         Package_Message::log('error', 'Package ' . $metadata['packageName'] . ' required parameter is poorly formated, ignoring');
     }
     if (is_numeric($metadata['version'])) {
         $versionParts = explode('.', $metadata['version']);
         $versionParts = array_pad($versionParts, 3, 0);
         $metadata['version'] = implode('.', $versionParts);
     }
     $metadata['version'] = (string) $metadata['version'];
     $metadata['upgrades'] = array();
     $metadata['downgrades'] = array();
     $metadata['basedir'] = dirname(str_replace(DOCROOT, '', $filepath));
     $metadata['status'] = Package_Manager::STATUS_UNINSTALLED;
     $metadata['datastore_id'] = NULL;
 }
开发者ID:swk,项目名称:bluebox,代码行数:32,代码来源:Standardize.php

示例5: beforeFilter

 function beforeFilter()
 {
     parent::beforeFilter();
     if (Sanitize::getInt($this->data, 'OwnerReply')) {
         $this->review_id = Sanitize::getInt($this->data['OwnerReply'], 'id');
     } else {
         $this->review_id = Sanitize::getInt($this->params, 'review_id');
     }
     if (!$this->Config->owner_replies || $this->review_id == 0 || $this->_user->id == 0) {
         $this->denyAccess = true;
         return;
     }
     // Get the listing id and extension
     $this->_db->setQuery("\n            SELECT \n                Review.pid AS listing_id, Review.`mode` AS extension\n            FROM \n                #__jreviews_comments AS Review\n            WHERE \n                Review.id = " . $this->review_id);
     // Get listing owner id and check if it matches the current user
     if ($listing = current($this->_db->loadAssocList())) {
         // Automagically load and initialize Everywhere Model to check if user is listing owner
         App::import('Model', 'everywhere_' . $listing['extension'], 'jreviews');
         $class_name = inflector::camelize('everywhere_' . $listing['extension']) . 'Model';
         if (class_exists($class_name)) {
             $this->Listing = new $class_name();
             $owner = $this->Listing->getListingOwner($listing['listing_id']);
             if ($this->_user->id != $owner['user_id']) {
                 $this->denyAccess = true;
                 return;
             }
             $this->data['Listing']['created_by'] = $owner['user_id'];
             // Used in the Activities component
             $this->data['Listing']['listing_id'] = $listing['listing_id'];
             // Used in the Activities component
             $this->data['Listing']['extension'] = $listing['extension'];
             // Used in the Activities component
         }
     }
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:35,代码来源:owner_replies_controller.php

示例6: index

 function index()
 {
     $reviews = array();
     $this->params = $this->data;
     $conditions = array("OwnerReply.owner_reply_approved = 0", "OwnerReply.owner_reply_text<>''");
     $replies = $this->OwnerReply->findAll(array('fields' => array('CASE WHEN CHAR_LENGTH(User.name) THEN User.name ELSE OwnerReply.name END AS `User.name`', 'OwnerReply.email AS `User.email`'), 'conditions' => $conditions, 'joins' => array('LEFT JOIN #__users AS User ON User.id = OwnerReply.userid'), 'offset' => $this->offset, 'limit' => $this->limit, 'order' => array('OwnerReply.owner_reply_created DESC')));
     $total = $this->OwnerReply->findCount(array('conditions' => $conditions));
     if (!empty($replies)) {
         $predefined_replies = $this->PredefinedReply->findAll(array('fields' => array('PredefinedReply.*'), 'conditions' => array('reply_type = "owner_reply"')));
         $this->Review->runProcessRatings = false;
         $this->EverywhereAfterFind = true;
         // Triggers the afterFind in the Observer Model
         // Complete the owner info for each reply
         // Get the review info for each reply
         $reviews = $this->Review->findAll(array('conditions' => 'Review.id IN (' . implode(',', array_keys($replies)) . ')'));
         # Pre-process all urls to sef
         $this->_getListingSefUrls($reviews);
         $this->_getReviewSefUrls($reviews);
         foreach ($replies as $key => $reply) {
             // Automagically load and initialize Everywhere Model to check if user is listing owner
             if (!isset($this->__loaded[$reply['Review']['extension']])) {
                 App::import('Model', 'everywhere_' . $reply['Review']['extension'], 'jreviews');
                 $class_name = inflector::camelize('everywhere_' . $reply['Review']['extension']) . 'Model';
                 if (class_exists($class_name)) {
                     ${$reply['Review']['extension']} = new $class_name();
                 }
             }
             $replies[$key]['Owner'] = ${$reply['Review']['extension']}->getListingOwner($reply['Review']['listing_id']);
             isset($reviews[$reply['Review']['review_id']]) and $replies[$key] = array_merge($replies[$key], $reviews[$reply['Review']['review_id']]);
         }
     }
     $this->set(array('total' => $total, 'owner_replies' => $replies, 'predefined_replies' => !empty($predefined_replies) ? $predefined_replies : array()));
     return $this->render('owner_replies', 'moderation');
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:34,代码来源:admin_owner_replies_controller.php

示例7: createExtension

 public static function createExtension()
 {
     Event::$data += array('sip_username' => html::token(Event::$data['owner_name']), 'sip_password' => inflector::generatePassword());
     extract(Event::$data);
     $plugin = array('sip' => array('username' => $sip_username, 'password' => $sip_password));
     $device['plugins'] = arr::merge($device['plugins'], $plugin);
 }
开发者ID:swk,项目名称:bluebox,代码行数:7,代码来源:SipLib.php

示例8: habtm

 public function habtm($model = NULL, $table = NULL, $id = NULL)
 {
     if (!$id and !$table) {
         $table = $model;
         $model = NULL;
     }
     if (!empty($this->form->model[$model])) {
         $model = $this->form->model[$model];
     } elseif ($id) {
         $model = ORM::factory($model, $id);
         $this->form->model[$model->object_name] = $model;
     } elseif (!is_object($model)) {
         // if no model is specified, use the last loaded model
         foreach ($this->form->model as $key => $_model) {
             $model = $this->form->model[$key];
             $table = $table;
             break;
         }
     }
     $model_name = $model->object_name;
     $keyname = "{$model_name}.{$table}";
     $this->habtm_name[$keyname] = ORM::factory($table)->primary_val;
     $this->habtm_plural[$keyname] = inflector::plural($table);
     $this->habtm_table[$keyname] = $table;
     $this->habtm_model[$keyname] = $model;
     $values = array();
     foreach (ORM::factory($this->habtm_table[$keyname])->find_all() as $option) {
         $values[$option->id] = $option->{$this->habtm_name[$keyname]};
         $this->elements[$keyname][] = $option->{$this->habtm_name[$keyname]};
     }
     $this->habtm_table[$keyname] = inflector::plural($this->habtm_table[$keyname]);
     $this->form->add_group($this->habtm_table[$keyname] . '[]', $values)->set($this->habtm_table[$keyname], 'required', FALSE);
     $this->fill_initial_values($keyname);
 }
开发者ID:ready4god2513,项目名称:scs,代码行数:34,代码来源:habtm.php

示例9: index

 public function index()
 {
     $dotfile = "digraph G {\n";
     foreach ($this->_get_models() as $model) {
         $dotfile .= $model->object_name . ' [shape="Mrecord", label=< <FONT POINT-SIZE="18.0">' . $model->object_name . '</FONT><BR ALIGN="CENTER"/>';
         foreach ($model->table_columns as $column => $meta) {
             if (substr($column, -3) == '_id' or $column == 'id') {
                 continue;
             }
             $dotfile .= '<FONT COLOR="darkgreen">' . $column . '</FONT> <FONT COLOR="grey">(' . $meta['type'] . ')' . '</FONT><BR ALIGN="LEFT"/>';
         }
         $dotfile .= '>];' . "\n";
         foreach ($model->has_one as $related) {
             $dotfile .= $model->object_name . ' -> ' . $related . ";\n";
             //" [arrowhead=\"tee\"];\n";
         }
         foreach ($model->has_many as $related) {
             $dotfile .= $model->object_name . ' -> ' . inflector::singular($related) . ";\n";
             //" [arrowhead=\"crow\"];\n";
         }
     }
     $dotfile .= '}';
     return $this->_render($dotfile);
     foreach ($this->_get_models() as $model) {
         echo $model->object_name . '<br />';
         foreach ($model->table_columns as $column => $meta) {
             echo ' : ' . $column . '<br />';
         }
         echo '<br />';
     }
 }
开发者ID:evansd-archive,项目名称:kohana-module--erd,代码行数:31,代码来源:erd.php

示例10: __get

 /**
  * Overload ORM::__get to support "parent" and "children" properties.
  *
  * @param   string  column name
  * @return  mixed
  */
 public function __get($column)
 {
     if ($column === 'parent') {
         if (empty($this->related[$column])) {
             // Load child model
             $model = ORM::factory(inflector::singular($this->children));
             if (array_key_exists($this->parent_key, $this->object)) {
                 // Find children of this parent
                 $model->where($model->primary_key, $this->object[$this->parent_key])->find();
             }
             $this->related[$column] = $model;
         }
         return $this->related[$column];
     } elseif ($column === 'children') {
         if (empty($this->related[$column])) {
             $model = ORM::factory(inflector::singular($this->children));
             if ($this->children === $this->table_name) {
                 // Load children within this table
                 $this->related[$column] = $model->where($this->parent_key, $this->object[$this->primary_key])->find_all();
             } else {
                 // Find first selection of children
                 $this->related[$column] = $model->where($this->foreign_key(), $this->object[$this->primary_key])->where($this->parent_key, NULL)->find_all();
             }
         }
         return $this->related[$column];
     }
     return parent::__get($column);
 }
开发者ID:kjgarza,项目名称:ushahidi,代码行数:34,代码来源:ORM_Tree.php

示例11: initialize

 /**
  * Overrides the initialize to automatically provide the column name
  *
  * @param   string  $model
  * @param   string  $column
  * @return  void
  */
 public function initialize($model, $column)
 {
     // Default to the name of the column
     if (empty($this->foreign)) {
         $foreign_model = inflector::singular($column);
         $this->foreign = $foreign_model . '.' . $foreign_model . ':primary_key';
     } elseif (FALSE === strpos($this->foreign, '.')) {
         $this->foreign = $this->foreign . '.' . $this->foreign . ':primary_key';
     }
     // Split them apart
     $foreign = explode('.', $this->foreign);
     // Create an array from them
     $this->foreign = array('model' => $foreign[0], 'column' => $foreign[1]);
     // We can work with nothing passed or just a model
     if (empty($this->through) or is_string($this->through)) {
         if (empty($this->through)) {
             // Find the join table based on the two model names pluralized,
             // sorted alphabetically and with an underscore separating them
             $through = array(inflector::plural($this->foreign['model']), inflector::plural($model));
             // Sort
             sort($through);
             // Bring them back together
             $this->through = implode('_', $through);
         }
         $this->through = array('model' => $this->through, 'columns' => array(inflector::singular($model) . ':foreign_key', inflector::singular($this->foreign['model']) . ':foreign_key'));
     }
     parent::initialize($model, $column);
 }
开发者ID:vitch,项目名称:kohana-jelly,代码行数:35,代码来源:manytomany.php

示例12: modelName

 private function modelName()
 {
     $source = get_class($this);
     if (preg_match("/([a-z])([A-Z])/", $source, $reg)) {
         $source = str_replace($reg[0], $reg[1] . "_" . strtolower($reg[2]), $source);
     }
     return strtolower(inflector::pluralize($source));
 }
开发者ID:ravenlp,项目名称:CodiceCMS,代码行数:8,代码来源:activeRecord.class.php

示例13: add_row

 /**
  * Add a row to the current data set
  *
  * @param  array $row
  */
 public function add_row($row)
 {
     $keyed_row = array();
     foreach ($row as $k => $v) {
         $keyed_row[inflector::camelize($this->columns[$k])] = $v;
     }
     $this->rows[] = $keyed_row;
 }
开发者ID:enormego,项目名称:EightPHP,代码行数:13,代码来源:xml.php

示例14: _tables

 protected function _tables()
 {
     // Prepare an array to hold tables
     $tables = array();
     // Create a new database table with name and database
     $table = new Database_Table($this->_model->table(), $this->_db);
     // Get the model's primary keys as an array
     $model_pks = is_array($this->_model->pk()) ? $this->_model->pk() : array($this->_model->pk());
     // Loop through each field within the model
     foreach ($this->_model->fields() as $field) {
         // Check if the field implaments the migratable field interface
         if ($field instanceof Sprig_Field_Migratable) {
             // Loop through each column in the field
             foreach ($field->columns() as $column) {
                 // Add the column to the table
                 $table->add_column($column);
             }
         } elseif ($field->in_db) {
             // If the field is unique
             if ($field->unique) {
                 // Add a unique constraint to the table
                 $table->add_constraint(new Database_Constraint_Unique($field->column));
             }
             // Loop through every column in the model
             foreach ($this->_columns($field, $table) as $column) {
                 // Add the column to the table
                 $table->add_column($column);
             }
         } elseif ($field instanceof Sprig_Field_ManyToMany) {
             // ManyToMany fields also contain a pivot table
             $pivot = new Database_Table($field->through, $this->_db);
             // Get the columns associated with the first half
             $columns = $this->_columns(new Sprig_Field_BelongsTo(array('model' => $field->model)), $pivot);
             // Foreach column in the first half
             foreach ($columns as $column) {
                 // Add it to the pivot table
                 $pivot->add_column($column);
             }
             // Get the columns associated with the second half
             $columns = $this->_columns(new Sprig_Field_BelongsTo(array('model' => inflector::singular($this->_model->table()))), $pivot);
             // Foreach column in the second half
             foreach ($columns as $column) {
                 // Add it to the pivot table
                 $pivot->add_column($column);
             }
             // Add a primary key constraint on all fields within the pivot table
             $pivot->add_constraint(new Database_Constraint_Primary(array_keys($pivot->columns()), $pivot->name));
             // Add the pivot table to the list of tables
             $tables[] = $pivot;
         }
     }
     // Add the primary key constraints to the table
     $table->add_constraint(new Database_Constraint_Primary($model_pks, $table->name));
     // Add the table to the list
     $tables[] = $table;
     // And return all tables.
     return $tables;
 }
开发者ID:kierangraham,项目名称:migration,代码行数:58,代码来源:sprig.php

示例15: getSynonomy

 /**
  * Retrieve the list of synonyms using a meaning id.
  * @param string $meaning_field Name of the meaning field, either taxon_meaning_id or meaning_id.
  * @param int $meaning_id Id value of the meaning to search for
  * @param boolean $within_list Search within the current list only (true=default) or
  * across all lists (false).
  * @return ORM_Iterator List of synonyms
  */
 public function getSynonomy($meaning_field, $meaning_id, $within_list = true)
 {
     $filters = array('preferred' => 'f', 'deleted' => 'f', $meaning_field => $meaning_id);
     if ($within_list) {
         $list_id_field = $this->list_id_field;
         $filters[$list_id_field] = $this->{$list_id_field};
     }
     return ORM::factory(inflector::singular($this->table_name))->where($filters)->find_all();
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:17,代码来源:base_name.php


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