[ Index ]

PHP Cross Reference of Akelos Framework

title

Body

[close]

/ -> AkInflector.php (summary)

(no description)

Author: Bermi Ferrer
Copyright: Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
License: GNU Lesser General Public License
File Size: 480 lines (16 kb)
Included or required: 11 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

AkInflector:: (23 methods):
  _loadConfig()
  _inflect()
  pluralize()
  singularize()
  conditionalPlural()
  titleize()
  camelize()
  underscore()
  humanize()
  variablize()
  tableize()
  classify()
  ordinalize()
  demodulize()
  unaccent()
  urlize()
  foreignKey()
  toControllerFilename()
  toModelFilename()
  toHelperFilename()
  toFullName()
  is_singular()
  is_plural()


Class: AkInflector  - X-Ref

AkInflector for pluralize and singularize English nouns.

This AkInflector is a port of Ruby on Rails AkInflector.

It can be really helpful for developers that want to
create frameworks based on naming conventions rather than
configurations.

You can find the inflector rules in config/inflector.yml
To add your own inflector rules, please do so in config/inflector/mydictionary.yml

Using it:

AkInflector::pluralize('inglés',null,'es'); // ingleses, see config/inflector/es.yml

_loadConfig($dictionary)   X-Ref
No description

_inflect($word, $new_value, $type, $dictionary = null)   X-Ref
No description

pluralize($word, $new_plural = null, $dictionary = null)   X-Ref
Pluralizes English nouns.

param: string    $word    English noun to pluralize
return: string Plural noun

singularize($word, $new_singular = null, $dictionary = null)   X-Ref
Singularizes English nouns.

param: string    $word    English noun to singularize
return: string Singular noun.

conditionalPlural($numer_of_records, $word)   X-Ref
Get the plural form of a word if first parameter is greater than 1

param: integer $numer_of_records
param: string $word
return: string Pluralized string when number of items is greater than 1

titleize($word, $uppercase = '')   X-Ref
Converts an underscored or CamelCase word into a English
sentence.

The titleize function converts text like "WelcomePage",
"welcome_page" or  "welcome page" to this "Welcome
Page".
If second parameter is set to 'first' it will only
capitalize the first character of the title.

param: string    $word    Word to format as tile
param: string    $uppercase    If set to 'first' it will only uppercase the
return: string Text formatted as title

camelize($word)   X-Ref
Returns given word as CamelCased

Converts a word like "send_email" to "SendEmail". It
will remove non alphanumeric character from the word, so
"who's online" will be converted to "WhoSOnline"

param: string    $word    Word to convert to camel case
return: string UpperCamelCasedWord

underscore($word)   X-Ref
Converts a word "into_it_s_underscored_version"

Convert any "CamelCased" or "ordinary Word" into an
"underscored_word".

This can be really useful for creating friendly URLs.

param: string    $word    Word to underscore
return: string Underscored word

humanize($word, $uppercase = '')   X-Ref
Returns a human-readable string from $word

Returns a human-readable string from $word, by replacing
underscores with a space, and by upper-casing the initial
character by default.

If you need to uppercase all the words you just have to
pass 'all' as a second parameter.

param: string    $word    String to "humanize"
param: string    $uppercase    If set to 'all' it will uppercase all the words
return: string Human-readable word

variablize($word)   X-Ref
Same as camelize but first char is lowercased

Converts a word like "send_email" to "sendEmail". It
will remove non alphanumeric character from the word, so
"who's online" will be converted to "whoSOnline"

param: string    $word    Word to lowerCamelCase
return: string Returns a lowerCamelCasedWord

tableize($class_name)   X-Ref
Converts a class name to its table name according to rails
naming conventions.

Converts "Person" to "people"

param: string    $class_name    Class name for getting related table_name.
return: string plural_table_name

classify($table_name)   X-Ref
Converts a table name to its class name according to Akelos
naming conventions.

Converts "people" to "Person"

param: string    $table_name    Table name for getting related ClassName.
return: string SingularClassName

ordinalize($number)   X-Ref
Converts number to its ordinal English form.

This method converts 13 to 13th, 2 to 2nd ...

param: integer    $number    Number to get its ordinal value
return: string Ordinal representation of given string.

demodulize($module_name)   X-Ref
Removes the module name from a module/path, Module::name or Module_ControllerClassName.

Example:    AkInflector::demodulize('admin/dashboard_controller');  //=> dashboard_controller
AkInflector::demodulize('Admin_DashboardController');  //=> DashboardController
AkInflector::demodulize('Admin::Dashboard');  //=> Dashboard

unaccent($text)   X-Ref
Transforms a string to its unaccented version.
This might be useful for generating "friendly" URLs


urlize($text)   X-Ref
No description

foreignKey($class_name, $separate_class_name_and_id_with_underscore = true)   X-Ref
Returns $class_name in underscored form, with "_id" tacked on at the end.
This is for use in dealing with the database.

param: string $class_name
return: string

toControllerFilename($name)   X-Ref
No description

toModelFilename($name)   X-Ref
No description

toHelperFilename($name)   X-Ref
No description

toFullName($name, $correct)   X-Ref
No description

is_singular($singular)   X-Ref
No description

is_plural($plural)   X-Ref
No description



Generated: Mon Oct 27 12:43:49 2008 Cross-referenced by PHPXref 0.6