/** * Initialize object (for relations) * @param orm $object */ public function initialize(&$object) { $models[0] = Inflector::plural(strtolower(str_replace('Model_', '', get_class($object)))); $models[1] = $this->item['name']; sort($models); $object->create_relation('hasMany', $this->item['name'], array('model' => Inflector::singular($this->item['name']), 'through' => $models[0] . '_' . $models[1])); }
/** * Automatically sets foreign to sensible defaults. * * @param string $model * @param string $name * @return void */ public function initialize(Jam_Meta $meta, $name) { parent::initialize($meta, $name); if (!$this->foreign_key) { $this->foreign_key = $name . '_id'; } if ($this->foreign_key === $name) { throw new Kohana_Exception('In association ":name" for model ":model" - invalid foreign_key name. Field and Association cannot be the same name', array(':model' => $this->model, ':name' => $name)); } $meta->field($this->foreign_key, Jam::field('integer', array_merge($this->_default_field_options, $this->field_options))); if ($this->is_polymorphic()) { if (!is_string($this->polymorphic)) { $this->polymorphic = $name . '_model'; } $meta->field($this->polymorphic, Jam::field('string', array('convert_empty' => TRUE))); } elseif (!$this->foreign_model) { $this->foreign_model = $name; } if ($this->count_cache) { if ($this->is_polymorphic()) { throw new Kohana_Exception('Cannot use count cache on polymorphic associations'); } if ($this->count_cache === TRUE) { $this->count_cache = Inflector::plural($this->model) . '_count'; } } }
function __construct(Jam_Query_Builder_Collection $collection, $offset, array $columns = array()) { $this->collection($collection); $this->controller(Inflector::plural($collection->meta()->model())); $this->columns($columns); $this->_offset = $offset; }
protected function submit($task, $id, $type) { $item = Jelly::select($type, $id); $redirect = HTML::uri(array('action' => Inflector::plural($type))); switch ($task) { case 'apply': $item->set($_POST)->save(); $redirect = HTML::uri(array('action' => $type, 'task' => 'edit', 'id' => $item->id)); $this->request->redirect($redirect); break; case 'save': $item->set($_POST)->save(); $this->request->redirect($redirect); break; case 'cancel': $this->request->redirect($redirect); break; case 'delete': if ($ids = Arr::get($_POST, 'cid', NULL)) { $items = Jelly::delete($item)->where(':primary_key', 'IN', $ids)->execute(); } $this->request->redirect($redirect); break; case 'default': if (!$item->loaded()) { $this->request->redirect($redirect); } break; } return $item; }
public function action_calendar() { $view = View::factory('calendar/calendar')->bind('calendar', $calendar_markup); $month = Arr::get($_GET, 'month', date('m')); $year = Arr::get($_GET, 'year', date('Y')); $event_type = Arr::get($_GET, 'event_type'); $calendar = new Calendar($month, $year); $calendar->standard('prev-next'); $event = Model_Event::monthly_events($month, $year, $event_type); $day_events = array(); // loop though events and group events by day and event types foreach ($event as $e) { $day = date('j-m', $e->eventstart); if (!isset($day_events[$day][$e->eventtype])) { $day_events[$day][$e->eventtype] = array(); } $day_events[$day][$e->eventtype][] = array('id' => $e->id); } if ($day_events) { foreach ($day_events as $daymonth => $types) { list($day, $month) = explode("-", $daymonth); $timestamp = mktime(0, 0, 0, $month, (int) $day, $year); foreach ($types as $type => $events) { $count = count($events); $type = $count > 1 ? Inflector::plural($type) : $type; $calendar->attach($calendar->event()->condition('timestamp', (int) $timestamp)->output($count . ' ' . $type)); } } } $calendar->attach($calendar->event()->condition('timestamp', time())->add_class('today')); $calendar_markup = $calendar->render(); $this->content = $view; }
/** * Return the item's name prefixed with its amount * * @return string */ public function name() { if ($this->amount > 1) { return $this->amount . ' ' . Inflector::plural($this->item->name, $this->amount); } else { return $this->amount . ' ' . $this->item->name; } }
public function initialize(Jam_Meta $meta, $name) { parent::initialize($meta, $name); if (!$this->_branches_table) { $this->_branches_table = ($meta->table() ?: Inflector::plural($meta->model())) . '_branches'; } $meta->associations(array('parent' => Jam::association('closuretable_parent', array('foreign_model' => $this->_model, 'branches_table' => $this->_branches_table, 'ansestor_key' => $this->_ansestor_key, 'descendant_key' => $this->_descendant_key, 'depth_key' => $this->_depth_key, 'inverse_of' => 'children')), 'children' => Jam::association('closuretable_children', array('foreign_model' => $this->_model, 'branches_table' => $this->_branches_table, 'ansestor_key' => $this->_ansestor_key, 'descendant_key' => $this->_descendant_key, 'depth_key' => $this->_depth_key, 'inverse_of' => 'parent', 'children_dependent' => $this->_children_dependent)))); $meta->events()->bind('model.after_save', array($this, 'model_before_after_save'), Jam_Event::ATTRIBUTE_PRIORITY + 1); }
public function apply($collection) { if (!$this->controller()) { $this->controller(Inflector::plural($collection->meta()->model())); } foreach ($this->data() as $name => $value) { if ($value and $this->entries($name)) { $this->entries($name)->apply($collection, $value); } } return $this; }
/** * Add a validator item * * @access public * @param mixed $type * @param mixed $rule * @return object */ public function add_validator($type, $rule) { $type = Inflector::plural($rule->type); if (in_array($type, array('filters', 'display_filters'))) { return $this->add_filter(Inflector::singular($type), $rule); } $next = count($this->_validators[$type]); // Resolve the context $this->make_context($rule); $this->_validators[$type][$next] = $rule; return $this; }
public function build($model, array $values = NULL) { $column = Inflector::plural($model); $col = Arr::get($this->_has_many, $column); $foreign_key = Arr::get($col, 'foreign_key'); $polymorphic = Arr::get($col, 'polymorphic', FALSE); $object = ORM::factory($model); if ($polymorphic && $object instanceof ORM_Polymorph) { $foreign_key = $object->polymorph_id(); $foreign_type = $object->polymorph_type(); $values[$foreign_type] = $this->object_name(); } $values[$foreign_key] = $this->id; return $object->values($values); }
function render_menu($items, $parent = NULL) { $html = ''; $ignored = array(); foreach ($items as $item) { $controller_name = 'Controller_Manager_' . $item; if (class_exists($controller_name)) { $reflector = new ReflectionClass($controller_name); if ($reflector->isAbstract()) { continue; } } if (in_array($item, $ignored)) { continue; } $matches = preg_grep('/^' . $item . '_/i', $items); if ($matches and !$parent) { $html .= '<li><a href="#" class="dropdown-toggle" data-toggle="dropdown">'; $html .= __(Inflector::plural($item)) . ' <span class="caret"></span>'; $html .= '</a>'; $html .= '<ul class="dropdown-menu">'; if (Can::show($item, 'index')) { $html .= '<li><a href="./manager/' . strtolower($item) . '">' . __(Inflector::plural($item)) . '</a></li>'; } $html .= render_menu($matches, $item); $html .= '</ul></li>'; $ignored = array_merge($ignored, $matches); } else { if (!Can::show($item, 'index')) { continue; } $prepend = ''; if ($parent) { $underlines = count(explode('_', $item)); if ($underlines >= 3) { for ($i = $underlines; $i > 3; $i--) { $prepend .= '<i class="glyphicon glyphicon-option-horizontal"></i>'; } $prepend .= '<i class="glyphicon glyphicon-triangle-right"></i>'; } } $html .= '<li><a href="./manager/' . strtolower($item) . '">' . $prepend . __(Inflector::plural($item)) . '</a></li>'; } } return $html; }
public function add($alias, $driver = NULL, $value = NULL, array $options = NULL) { // If Formo object was passed, add it as a subform if ($driver instanceof Formo) { return $this->add_subform($driver); } if ($alias instanceof Formo) { return $this->add_subform($alias->alias($driver)); } if ($value instanceof Formo) { return $this->add_subform($value->alias($alias)->set('driver', $driver)); } $orig_options = $options; $options = func_get_args(); $options = self::args(__CLASS__, __FUNCTION__, $options); // If a driver is named but not an alias, make the driver text and the alias the driver if (empty($options['driver'])) { $options['driver'] = Arr::get($this->config, 'default_driver', 'text'); } // Allow loading rules, callbacks, filters upon adding a field $validate_options = array('rule', 'trigger', 'filter'); // Create the array $validate_settings = array(); foreach ($validate_options as $option) { $option_name = Inflector::plural($option); if (!empty($options[$option_name])) { $validate_settings[$option] = $options[$option_name]; unset($options[$option_name]); } } // Create the new field $field = Ffield::factory($options); $this->append($field); // Add the validation rules foreach ($validate_settings as $method => $array) { foreach ($array as $callback => $opts) { $args = array(NULL, $callback, $opts); call_user_func_array(array($field, $method), $args); } } return $this; }
/** * Returns the time since a particular time * * @static * * @param $i_datetime1 * @param null $i_datetime2 * * @return string * * @author Marcel Beck <*****@*****.**> */ public static function time_since($i_datetime1, $i_datetime2 = null) { $datetime1 = new \DateTime($i_datetime1); $datetime2 = $i_datetime2 === null ? new \DateTime('now') : new \DateTime($i_datetime2); $interval = $datetime1->diff($datetime2); $doPlural = function ($nb, $str) { return $nb > 1 ? Inflector::plural($str) : $str; }; // adds plurals $format = array(); if ($interval->y !== 0) { $format[] = '%y ' . $doPlural($interval->y, __('year')); } if ($interval->m !== 0) { $format[] = '%m ' . $doPlural($interval->m, _('month')); } if ($interval->d !== 0) { $format[] = '%d ' . $doPlural($interval->d, _('day')); } if ($interval->h !== 0) { $format[] = '%h ' . $doPlural($interval->h, __('hour')); } if ($interval->i !== 0) { $format[] = '%i ' . $doPlural($interval->i, __('minute')); } if ($interval->s !== 0) { if (!count($format)) { return __('less than a minute ago'); } else { $format[] = '%s ' . $doPlural($interval->s, __('second')); } } // We use the two biggest parts if (count($format) > 1) { $format = array_shift($format) . ' ' . __('and') . ' ' . array_shift($format); } else { $format = array_pop($format); } //echo $interval->format('%y years, %m months, %d days, %h hours and %i minutes ago'); return $interval->format($format); }
/** * This is called after initialization to * finalize any changes to the meta object. * * @param string $model * @return */ public function finalize($model) { if ($this->_initialized) { return; } // Set the name of a possible behavior class $behavior_class = Jam::behavior_prefix() . Jam::capitalize_class_name($model); // See if we have a special behavior class to use if (class_exists($behavior_class)) { // Load behavior $behavior = new $behavior_class(); if (!in_array($behavior, $this->_behaviors)) { // Add to behaviors $this->_behaviors[] = $behavior; } } foreach ($this->_behaviors as $name => $behavior) { if (!$behavior instanceof Jam_Behavior) { throw new Kohana_Exception('Behavior at index [ :key ] is not an instance of Jam_Behavior, :type found.', array(':type' => is_object($behavior) ? 'instance of ' . get_class($behavior) : gettype($behavior), ':key' => $name)); } // Initialize behavior $behavior->initialize($this, $name); } // Allow modification of this meta object by the behaviors $this->_events->trigger('meta.before_finalize', $this); // Ensure certain fields are not overridden $this->_model = $model; $this->_defaults = array(); if (!$this->_errors_filename) { // Default errors filename to the model's name $this->_errors_filename = 'validators/' . $this->_model; } // Table should be a sensible default if (empty($this->_table)) { $this->_table = Inflector::plural($model); } // Can we set a sensible foreign key? if (empty($this->_foreign_key)) { $this->_foreign_key = $model . '_id'; } if (empty($this->_unique_key) and method_exists(Jam::class_name($this->_model), 'unique_key')) { $this->_unique_key = Jam::class_name($this->_model) . '::unique_key'; } foreach ($this->_fields as $column => $field) { // Ensure a default primary key is set if ($field instanceof Jam_Field and $field->primary and empty($this->_primary_key)) { $this->_primary_key = $column; } // Ensure a default plymorphic key is set if ($field instanceof Jam_Field_Polymorphic and empty($this->_polymorphic_key)) { $this->_polymorphic_key = $column; } } foreach ($this->_associations as $column => &$association) { $association->initialize($this, $column); } foreach ($this->_fields as $column => &$field) { $field->initialize($this, $column); $this->_defaults[$column] = $field->default; } if (!$this->_collection and $class = Jam::collection_prefix() . Jam::capitalize_class_name($this->_model) and class_exists($class)) { $this->_collection = $class; } // Meta object is initialized and no longer writable $this->_initialized = TRUE; // Final meta callback $this->_events->trigger('meta.after_finalize', $this); }
/** * Prepares the model database connection, determines the table name, * and loads column information. * * @return void */ protected function _initialize() { if (!is_object($this->_db)) { // Get database instance $this->_db = Database::instance($this->_db); } if (empty($this->_table_name)) { // Table name is the same as the object name $this->_table_name = $this->_object_name; if ($this->_table_names_plural === TRUE) { // Make the table name plural $this->_table_name = Inflector::plural($this->_table_name); } } foreach ($this->_belongs_to as $alias => $details) { $defaults['model'] = $alias; $defaults['foreign_key'] = $alias . $this->_foreign_key_suffix; $this->_belongs_to[$alias] = array_merge($defaults, $details); } foreach ($this->_has_one as $alias => $details) { $defaults['model'] = $alias; $defaults['foreign_key'] = $this->_object_name . $this->_foreign_key_suffix; $this->_has_one[$alias] = array_merge($defaults, $details); } foreach ($this->_has_many as $alias => $details) { $defaults['model'] = Inflector::singular($alias); $defaults['foreign_key'] = $this->_object_name . $this->_foreign_key_suffix; $defaults['through'] = NULL; $defaults['far_key'] = Inflector::singular($alias) . $this->_foreign_key_suffix; $this->_has_many[$alias] = array_merge($defaults, $details); } // Load column information $this->reload_columns(); }
protected function show_list_page($item_type, $model_name, $extra_button_view = '') { // update any sort on fields... $fields = Jelly::meta($model_name)->fields(); $sort_on_field = FALSE; foreach ($fields as $field) { if ($field instanceof Field_SortOn) { $sort_on_field = $field; break; } } if ($sort_on_field && Arr::get($_POST, 'my-action') == 'sortItems') { $ids = explode(',', Arr::get($_POST, 'ids', '')); $index = 1; foreach ($ids as $id) { /* // Should work but is resetting the is_published field to 0??! Jelly::factory($model_name)->set( array( $sort_on_field => $index++, ) )->save($id); */ Jelly::select($model_name, $id)->set(array($sort_on_field->column => $index++))->save(); } $this->auto_render = false; echo '{complete:1}'; return; } $this->init_template('List ' . Inflector::plural($item_type)); $builder = Jelly::select($model_name); $this->modify_list_builder($builder); if ($sort_on_field) { if (isset($sort_on_field->category_key)) { if (is_array($sort_on_field->category_key)) { foreach ($sort_on_field->category_key as $o) { $builder->order_by($o); } } else { $builder->order_by($sort_on_field->category_key); } } $builder->order_by($sort_on_field->column); $rpp = 9999999999; } else { $rpp = Kohana::config('kadmium')->results_per_list_page; } $count_builder = Jelly::select($model_name); $this->modify_list_builder($count_builder); //$count = $count_builder->count(); // Nasty workaround because Jelly_Builder->count() doesn't support custom builders so if // your model has a custom builder which e.g. overrides ->execute() to add filtering to the // WHERE clause then Jelly_Builder->count() will ignore this. $count_builder->select(DB::expr('COUNT(*) AS num')); $count_loader = $count_builder->execute()->as_array(); $count = $count_loader[0]['num']; //echo Kohana::debug($count, Database::instance()->last_query); $pagination = Pagination::factory(array('total_items' => $count, 'items_per_page' => $rpp, 'page' => $this->request->param('page'))); if ($pagination->__get('current_page') != $this->request->param('page')) { throw new Kadmium_Exception_PageNotFound(); } $items = $builder->limit($rpp)->offset($pagination->__get('offset'))->execute(); $add_link = Route::get('kadmium')->uri(array('controller' => $this->request->controller, 'action' => 'new')); $this->template->content = View::factory('kadmium/list', array('page_title' => 'List ' . Inflector::plural($item_type), 'item_type' => $item_type, 'display_add_links' => !Jelly::factory($model_name)->disable_user_add, 'add_link' => $add_link, 'show_edit' => Jelly::factory($model_name)->disable_user_edit !== TRUE, 'items' => $items, 'pagination' => $pagination->render(), 'extra_button_view' => $extra_button_view)); }
/** * Tests Inflector::plural * * @test * @dataProvider provider_plural * @param boolean $input Input for File::mime * @param boolean $expected Output for File::mime */ public function test_plural($input, $count, $expected) { $this->assertSame($expected, Inflector::plural($input, $count)); }
/** * Generate modification column script * @param string $name * @param string $item * @return string */ private function modify_column($name, $item) { $buffer = '--' . "\n"; $buffer .= '-- alter table for model: ' . $this->model_name . ' - modify column: ' . $name . "\n"; $buffer .= '--' . "\n"; $buffer .= 'alter table `' . Inflector::plural($this->model_name) . '` modify '; $buffer .= '`' . $name . '` '; $buffer .= $item['type']; $buffer .= (isset($item['info']['var']) and $item['info']['var'] != null) ? '(' . $item['info']['var'] . ') ' : ' '; $buffer .= (isset($item['info']['attr']) and $item['info']['attr'] != null) ? $item['info']['attr'] . ' ' : null; $buffer .= (isset($item['info']['notnull']) and $item['info']['notnull']) ? 'NOT NULL ' : 'NULL '; $buffer .= (isset($item['info']['default']) and $item['info']['default'] != null) ? 'DEFAULT `' . $item['info']['default'] . '`' : null; $buffer .= ';' . "\n\n"; return $buffer; }
<div class="errors"> <?php if (isset($errors['paypal'])) { ?> We're sorry an error occoured while processing your purchase.</br></br> Details: <?php echo $errors['paypal']; ?> <?php } else { ?> We're sorry but your form has <?php echo count($errors); ?> <?php echo Inflector::plural('error', count($errors)); ?> .<br> Please check the information below and try again. <?php } ?> </div> <?php } ?> <h1>Purchase</h1> <?php echo Form::open('/payment/', array('method' => 'POST', 'id' => 'payment-form', 'name' => 'paymentForm')); ?>
/** * Find the join table based on the two model names pluralized, * sorted alphabetically and with an underscore separating them * * @param string $model1 * @param string $model2 * @return string */ public static function guess_through_table($model1, $model2) { $through = array(Inflector::plural($model1), Inflector::plural($model2)); sort($through); return implode('_', $through); }
?> </a></li> <?php } ?> <?php if ($model->id) { ?> <li><a href="<?php echo $url; ?> /index"><?php echo __(Inflector::plural($title)); ?> </a></li> <li class="active"><?php echo $model->id ? 'Editar' : 'Criar'; ?> </li> <?php } else { ?> <li><?php echo __(Inflector::plural($title)); ?> </li> <?php } ?> </ol>
public function before() { if (!Can::show()) { // Record only when invalid session, prevent ximite. if (!Auth::instance()->logged_in()) { Session::instance()->set('manager_login_reference', URL::current()); } return HTTP::redirect('manager/login'); } $success = Session::instance()->get_once('success'); View::set_global('success', $success); if (!$this->model_name and class_exists('Model_' . $this->request->controller())) { $this->model_name = $this->request->controller(); } if ($this->title === NULL) { $this->title = $this->model_name; } if (!$this->parents) { $this->parents = $this->request->param('parents'); $this->parents = explode('/', $this->parents); $parents = array(); if (count($this->parents) > 1) { foreach ($this->parents as $index => $value) { if ($index % 2) { continue; } $parents[] = array('model' => $value, 'table' => Inflector::plural($value), 'model_id' => $this->parents[$index + 1]); } } $this->parents = array_reverse($parents); } if (!$this->parent) { $this->parent = $this->request->param('parent'); } if (!$this->parent_id) { $this->parent_id = $this->request->param('parent_id'); } $boolean_fields = array(); $image_fields = array(); $upload_fields = array(); $text_fields = array(); $date_fields = array(); if ($this->model_name) { $this->model = ORM::factory(ORM::get_model_name($this->model_name), $this->request->param('id')); if ($this->parents) { $current_parent_table = strtolower($this->model_name); foreach ($this->parents as $index => $values) { $this->model->join(Arr::get($values, 'table')); $this->model->on(Arr::get($values, 'table') . '.id', '=', $current_parent_table . '.' . Arr::get($values, 'model') . '_id'); $this->model->where(Arr::get($values, 'table') . '.id', '=', Arr::get($values, 'model_id')); $current_parent_table = Arr::get($values, 'table'); } } if ($this->parent_id) { $this->foreign_key = strtolower($this->parent) . '_id'; $this->parent_model = ORM::factory(ORM::get_model_name($this->parent), $this->parent_id); $model_has_many = Inflector::plural(strtolower($this->model_name)); if (in_array($this->foreign_key, array_keys($this->model->as_array()))) { $this->model->where($this->foreign_key, '=', $this->parent_id); } else { if (in_array($model_has_many, array_keys($this->parent_model->as_array()))) { $this->model = $this->parent_model->{$model_has_many}; } } } $text_field_formats = Kohana::$config->load('huia/model.models'); if ($text_field_formats) { $this->text_field_formats = Arr::merge($this->text_field_formats, $text_field_formats); } $this->model->reload_columns(TRUE); foreach ($this->model->table_columns() as $column => $values) { if (Arr::get($values, 'data_type') === 'text') { $format = Arr::path($this->text_field_formats, $this->model->object_name() . '.' . $column, 'ckeditor'); $text_fields[$column] = array('format' => $format); } else { if (Arr::get($values, 'data_type') === 'tinyint' and Arr::get($values, 'display') == 1) { $boolean_fields[] = $column; } else { if (preg_match('/^(image|thumb)/', $column)) { $image_fields[] = $column; } else { if (preg_match('/^(file|upload)/', $column)) { $upload_fields[] = $column; } else { if (Arr::get($values, 'data_type') === 'date') { $date_fields[] = $column; } } } } } } View::set_global('date_fields', $date_fields); View::set_global('text_fields', $text_fields); $this->belongs_to = Arr::merge($this->belongs_to, $this->model->belongs_to()); $this->has_many = Arr::merge($this->has_many, $this->model->has_many()); $model_labels = $this->model->labels(); foreach ($model_labels as $key => $value) { // ignore through secundary $has_many_key = Arr::get($this->has_many, $key); if ($has_many_key) { $through = Arr::get($has_many_key, 'through'); $is_secundary = preg_match('/^' . $key . '_/', $through); $same_table = $through === $key . '_' . $key; if ($is_secundary and !$same_table) { unset($model_labels[$key]); } } // ignore composite if (preg_match('/^id_/', $key)) { unset($model_labels[$key]); } } $this->labels = Arr::merge($this->labels, $model_labels); } // auto upload if ($this->upload_fields === NULL) { $this->upload_fields = $upload_fields; } // auto booleans if ($this->boolean_fields === NULL) { $this->boolean_fields = $boolean_fields; } // auto images if ($this->image_fields === NULL) { $this->image_fields = $image_fields; } foreach ($this->boolean_fields as $field) { if (!isset($this->boolean_fields_labels[$field])) { $this->boolean_fields_labels[$field] = $this->boolean_fields_labels['default']; } } $model_classes = ORM_Autogen::get_models(); View::set_global('model_classes', $model_classes); parent::before(); // autogen controllers if (Kohana::$environment === Kohana::DEVELOPMENT) { self::generate_controllers($model_classes); } }
<h1><?php echo ucfirst(Text::number($total_jobs)), ' ', Inflector::plural('job', $total_jobs) ?> available</h1> <?php if (isset($term)) : ?> <h2><?php echo HTML::chars(__('You have searched for: :term', array(':term' => $term))) ?></h2> <?php endif ?> <table summary="<?php echo __('List of all Kohana jobs (most recent first)') ?>"> <thead> <tr> <th><?php echo __('Date') ?></th> <th><?php echo __('Job') ?></th> </tr> </thead> <tbody> <?php foreach ($jobs as $job) { ?> <tr> <td><?php echo date('d M', $job->created) ?></td> <td> <strong><?php echo HTML::anchor(Route::get('job')->uri(array('id' => $job->id)), HTML::chars($job->title)) ?></strong><br /> at <?php echo $job->company ?> </td> </tr> <?php } ?> </tbody> </table> <?php echo $pagination ?>
public static function generate_model($model, $force = FALSE) { $class_name = 'Model_' . $model; $file = str_replace('_', DIRECTORY_SEPARATOR, $model); $base_dir = 'Base'; $model_dir = APPPATH . 'classes' . DIRECTORY_SEPARATOR . 'Model' . DIRECTORY_SEPARATOR; $model_base = $model_dir . $base_dir . DIRECTORY_SEPARATOR; $file_name = Kohana::find_file('classes/model', $file); $file_base_name = Kohana::find_file('classes/model/base', $file); $table_name = strtolower(Inflector::plural($model)); $table_id = strtolower($model) . '_id'; $rules = array(); $labels = array(); $has_many = array(); $belongs_to = array(); $columns = Database::instance()->list_columns($table_name); foreach ($columns as $field) { $name = Arr::get($field, 'column_name'); $key = Arr::get($field, 'key'); $type = Arr::get($field, 'type'); $low_name = str_replace('_id', '', $name); $maximum_length = Arr::get($field, 'character_maximum_length', Arr::get($field, 'display')); $title = ucfirst($name); // ignore id and _at$ if ($name === 'id' or preg_match('@_at$@', $name)) { continue; } $field_rules = array(); // unique if ($key === 'UNI') { $field_rules[] = "array(array(\$this, 'unique'), array(':field', ':value')),"; } // unique if ($type === 'int') { $field_rules[] = "array('numeric'),"; } // not null if (Arr::get($field, 'is_nullable') === FALSE) { $field_rules[] = "array('not_empty'),"; } // max length if ($maximum_length) { $field_rules[] = "array('max_length', array(':value', {$maximum_length})),"; } // cpf if ($name === 'cpf') { $field_rules[] = "array('cpf', array(':value')),"; } // email if (preg_match('@email@', $name)) { $field_rules[] = "array('email', array(':value')),"; } // rules if (!empty($field_rules)) { $rules[$name] = $field_rules; } // labels if (!preg_match('@_id$@', $name)) { $labels[$name] = $title; } // belongs to if (preg_match('@_id$@', $name)) { $model_name = ORM::get_model_name($low_name); $belongs_to[$low_name] = "array(" . "'model' => '" . $model_name . "'" . "),"; $labels[$low_name] = ucfirst($low_name); } } foreach (Database::instance()->list_tables() as $name) { $_columns = array_keys(Database::instance()->list_columns($name)); // has many through if (preg_match('/(^' . $table_name . '_(.*)|(.*)_' . $table_name . '$)/', $name, $matchs)) { $related = $matchs[count($matchs) - 1]; $has_many[$related] = "array(" . "'model' => '" . ORM::get_model_name($related) . "', " . "'through' => '" . $name . "'" . "),"; $labels[$related] = ucfirst($related); } // has many if (in_array('id', $_columns) and in_array($table_id, $_columns)) { $related = Inflector::singular($name); $field_name = Inflector::singular($table_name); $model_name = ORM::get_model_name($related); $has_many[str_replace($field_name . '_', '', $name)] = "array(" . "'model' => '" . $model_name . "'" . "),"; } } $class_extends = 'Model_App'; $columns = self::format_columns($columns); $full_class_name = 'Model_' . $base_dir . '_' . $model; $view = View::factory('huia/orm/base'); $view->set('class_name', $full_class_name); $view->set('class_extends', $class_extends); $view->set('table_name', $class_name); $view->set('rules', $rules); $view->set('labels', $labels); $view->set('has_many', $has_many); $view->set('belongs_to', $belongs_to); $view->set('columns', $columns); $render_view = $view->render(); $hash_current = $file_base_name ? preg_replace("/[^A-Za-z0-9]/", "", @file_get_contents($file_base_name)) : NULL; $hash_new = preg_replace("/[^A-Za-z0-9]/", "", $render_view); if ($hash_current !== $hash_new) { $file_base_name = $model_base . $file . EXT; create_dir(dirname($file_base_name)); file_put_contents($file_base_name, $view->render()); } // Create if dont exists if (!$file_name) { $view = View::factory('huia/orm'); $view->set('class_name', $class_name); $view->set('class_extends', 'Model_' . $base_dir . '_' . $model); $file_name = $model_dir . $file . EXT; create_dir(dirname($file_name)); file_put_contents($file_name, $view->render()); } }
/** * Get the item's name based on an amount * * @param integer $amount * * @return string */ public function name($amount) { return $amount . ' ' . Inflector::plural($this->name, $amount); }
<h1><?php echo $total_jobs, ' ', Inflector::plural('job', $total_jobs); ?> available</h1> <table summary="<?php echo __('List of all Kohana jobs (most recent first)'); ?> "> <thead> <tr> <th><?php echo __('Date'); ?> </th> <th><?php echo __('Job'); ?> </th> </tr> </thead> <tbody> <?php foreach ($jobs as $job) { ?> <tr> <td><?php echo date('d M', $job->created); ?> </td> <td>
protected function _execute(array $options) { $module_name = $options['module']; $dir = Arr::get(Kohana::modules(), $module_name); $meta = Jam::meta($options['model']); $controller = $options['controller'] ?: Inflector::plural($meta->model()); $item_name = $meta->model(); $item_title = ucwords(Inflector::humanize($meta->model())); $plural_name = str_replace('_', ' ', $controller); $author = $options['author']; $controller_option = $options['controller'] ? '->controller(\'' . $controller . '\')' : NULL; $controller_title = Jam::capitalize_class_name($plural_name); $controller_path = str_replace('_', DIRECTORY_SEPARATOR, $controller_title); $controller_dir = $dir . 'classes' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . 'Tart'; $controller_file = $controller_dir . DIRECTORY_SEPARATOR . $controller_path . EXT; $controller_class = 'Controller_Tart_' . str_replace(' ', '_', $controller_title); $views_path = 'tart' . DIRECTORY_SEPARATOR . strtolower($controller_path); $views_dir = $dir . 'views' . DIRECTORY_SEPARATOR . $views_path . DIRECTORY_SEPARATOR; $extra_controller = $options['controller'] ? ", array('controller' => '{$controller}')" : ''; $extra_controller_delete = $options['controller'] ? "array('controller' => '{$controller}', 'action' => 'delete')" : "'delete'"; $batch_index = NULL; $batch_delete = NULL; $batch_modify = NULL; if (!is_dir($views_dir)) { mkdir($views_dir, 0777, TRUE); } if (!is_dir(dirname($controller_file))) { mkdir(dirname($controller_file), 0777, TRUE); } if ($options['batch_delete'] !== FALSE or $options['batch_modify'] !== FALSE) { $actions = ''; if ($options['batch_delete'] !== FALSE) { $actions .= "\n\t\t\t\t'delete' => 'Delete',"; $batch_delete = <<<BATCH_DELETE \tpublic function batch_delete(\$ids) \t{ \t\tif (\$this->request->method() == Request::POST) \t\t{ \t\t\t\$result = array(); \t\t\tforeach (Jam::all('{$meta->model()}')->where_key(\$ids) as \${$item_name}) \t\t\t{ \t\t\t\t\$result[] = \${$item_name}->delete(); \t\t\t} \t\t\t\$this->notify('success', count(\$result).' {$plural_name} deleted'); \t\t\t\$this->redirect(Tart::uri('{$controller}')); \t\t} \t\telse \t\t{ \t\t\t\$table = Tart::table(Jam::all('{$meta->model()}')->where_key(\$ids)) \t\t\t\t->selected(\$ids) \t\t\t\t->columns('{$meta->name_key()}', Tart::column()); \t\t\t\$this->template->content = View::factory('{$views_path}/batch_delete', array('table' => \$table)); \t\t} \t} BATCH_DELETE; } if ($options['batch_modify'] !== FALSE) { $actions .= "\n\t\t\t\t'modify' => 'Modify',"; $batch_modify = <<<BATCH_MODIFY \tpublic function batch_modify(\$ids) \t{ \t\t\$params = array('{$meta->name_key()}'); \t\tif (\$this->request->method() == Request::POST) \t\t{ \t\t\t\$modified = Tart_Request::modified_params(\$this->request->post(), \$params); \t\t\tforeach (Jam::all('{$meta->model()}')->where_key(\$ids) as \$item) \t\t\t{ \t\t\t\t\$item->set(\$modified)->save(); \t\t\t} \t\t\t\$this->notify('success', count(\$ids).' {$plural_name} modified: '.Tart_Request::to_modifications(\$modified)); \t\t\t\$this->redirect(Tart::uri('{$controller}')); \t\t} \t\telse \t\t{ \t\t\t\$table = Tart::table(Jam::all('{$meta->model()}')->where_key(\$ids)) \t\t\t\t->selected(\$ids) \t\t\t\t->columns('{$meta->name_key()}', Tart::column()); \t\t\t\$item = Jam::build('{$meta->model()}', Jam_Form::common_params(\$table->collection(), \$params)); \t\t\t\$this->template->content = View::factory('{$views_path}/batch_modify', array('table' => \$table, 'form' => Jam::form(\$item, 'tart_general')->validation(FALSE))); \t\t} \t} BATCH_MODIFY; } $batch_index = <<<BATCH_INDEX \t\t\t->batch_actions(array({$actions} \t\t\t)) BATCH_INDEX; } $controller_content = <<<CONTROLLER <?php defined('SYSPATH') OR die('No direct script access.'); /** * Tart Controller: {$controller_title} * * @package {$module_name} * @author {$author} * @copyright (c) 2011-2013 Despark Ltd. */ class {$controller_class} extends Controller_Tart_Layout { \tpublic function action_index() \t{ \t\t\$collection = Jam::all('{$meta->model()}'); \t\t\$filter = Tart::filter(\$this->request->query()) \t\t\t{$controller_option} \t\t\t->entries(array( \t\t\t\t'q' => Tart::entry('search'), \t\t\t)) \t\t\t->apply(\$collection); \t\t\$index = Tart::index(\$collection, \$this->request->query('offset')) \t\t\t{$controller_option} {$batch_index} \t\t\t->columns(array( \t\t\t\t'{$meta->name_key()}' => Tart::column(), \t\t\t\t'actions' => Tart::column('actions'), \t\t\t)); \t\t\$this->template->set(array( \t\t\t'content' => View::factory('{$views_path}/index', array('index' => \$index, 'filter' => \$filter)), \t\t\t'sidebar' => View::factory('{$views_path}/sidebar', array('filter' => \$filter)), \t\t)); \t} \tpublic function action_edit() \t{ \t\t\$item = Jam::find_insist('{$meta->model()}', \$this->request->param('id')); \t\tif (\$this->request->method() === Request::POST AND \$item->set(\$this->post())->check()) \t\t{ \t\t\t\$this->notify('success', '{$item_title} Updated'); \t\t\t\$item->save(); \t\t} \t\t\$this->template->content = View::factory('{$views_path}/edit', array('item' => \$item)); \t} \tpublic function action_new() \t{ \t\t\$item = Jam::build('{$meta->model()}'); \t\tif (\$this->request->method() === Request::POST AND \$item->set(\$this->post())->check()) \t\t{ \t\t\t\$item->save(); \t\t\t\$this->notify('success', '{$item_title} Created'); \t\t\t\$this->redirect(Tart::uri(\$item{$extra_controller})); \t\t} \t\t\$this->template->content = View::factory('{$views_path}/new', array('item' => \$item)); \t} \tpublic function action_delete() \t{ \t\t\$item = Jam::find_insist('{$meta->model()}', \$this->request->param('id')); \t\t\$item->delete(); \t\t\$this->notify('success', "{$item_title} \\{\$item->name()\\} deleted"); \t\t\$this->redirect(Tart::uri('{$controller}')); \t} {$batch_delete} {$batch_modify} } CONTROLLER; Minion_Jam_Generate::modify_file($controller_file, $controller_content, $options['force'] !== FALSE, $options['unlink'] !== FALSE); $index_file = $views_dir . 'index' . EXT; $index_content = <<<VIEW_INDEX <ul class="breadcrumb"> \t<li class="active"> \t\t{$controller_title} <?php echo \$filter->render_active(); ?> \t</li> \t<li class="pull-right"> \t\t<?php echo \$index->pagination()->pager(); ?> \t</li> </ul> <?php echo \$index->render(); ?> VIEW_INDEX; Minion_Jam_Generate::modify_file($index_file, $index_content, $options['force'] !== FALSE, $options['unlink'] !== FALSE); $sidebar_file = $views_dir . 'sidebar' . EXT; $sidebar_content = <<<VIEW_SIDEBAR <ul class="nav nav-tabs nav-stacked"> \t<li> \t\t<?php echo Tart_Html::anchor(Tart::uri(Jam::build('{$meta->model()}'){$extra_controller}), '<i class="icon-plus"></i> Add {$item_title}'); ?> \t</li> </ul> <?php echo \$filter->render() ?> VIEW_SIDEBAR; Minion_Jam_Generate::modify_file($sidebar_file, $sidebar_content, $options['force'] !== FALSE, $options['unlink'] !== FALSE); $new_file = $views_dir . 'new' . EXT; $new_content = <<<VIEW_NEW <ul class="breadcrumb"> \t<li> \t\t<?php echo Tart_Html::anchor(Tart::uri('{$controller}'), '{$controller_title}'); ?> \t\t<span class="divider">/</span> \t</li> \t<li class="active"> \t\tCreate New {$item_title} \t</li> </ul> <?php echo Form::open(Tart::uri(\$item{$extra_controller}), array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data')) ?> \t<?php echo View::factory('{$views_path}/form', array('item' => \$item)) ?> \t<div class="form-actions"> \t\t<?php echo Tart_Html::anchor(Tart::uri('{$controller}'), 'Cancel', array('class' => 'btn btn-link')); ?> \t\t<button type="submit" class="btn btn-primary">Create {$item_title}</button> \t</div> <?php echo Form::close() ?> VIEW_NEW; Minion_Jam_Generate::modify_file($new_file, $new_content, $options['force'] !== FALSE, $options['unlink'] !== FALSE); $edit_file = $views_dir . 'edit' . EXT; $edit_content = <<<VIEW_EDIT <ul class="breadcrumb"> \t<li> \t\t<a href="<?php echo Tart::uri('{$controller}') ?>">{$controller_title}</a> \t\t<span class="divider">/</span> \t</li> \t<li class="active"> \t\tEdit {$item_name} <strong><?php echo \$item->name() ?></strong> \t</li> </ul> <?php echo Form::open(Tart::uri(\$item{$extra_controller}), array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data')) ?> \t<?php echo View::factory('{$views_path}/form', array('item' => \$item)) ?> \t<div class="form-actions"> \t\t<?php echo Tart_Html::anchor(Tart::uri('{$controller}'), 'Cancel', array('class' => 'btn btn-link')); ?> \t\t<button type="submit" class="btn btn-primary">Save changes</button> \t\t<?php echo Tart_Html::anchor(Tart::uri(\$item, {$extra_controller_delete}), 'Delete {$item_title}', array('class' => 'btn btn-danger pull-right', 'data-confirm' => 'Are you sure you want to delete this {$item_title}?')); ?> \t</div> <?php echo Form::close() ?> VIEW_EDIT; Minion_Jam_Generate::modify_file($edit_file, $edit_content, $options['force'] !== FALSE, $options['unlink'] !== FALSE); $form_file = $views_dir . 'form' . EXT; $form_content = <<<VIEW_FORM <?php \$form = Jam::form(\$item, 'tart_general') ?> <fieldset> \t<legend>Information</legend> \t<?php echo \$form->row('input', '{$meta->name_key()}') ?> </fieldset> VIEW_FORM; Minion_Jam_Generate::modify_file($form_file, $form_content, $options['force'] !== FALSE, $options['unlink'] !== FALSE); if ($options['batch_delete'] !== FALSE) { $batch_delete_file = $views_dir . 'batch_delete' . EXT; $batch_delete_content = <<<VIEW_BATCH_DELETE <ul class="breadcrumb"> \t<li> \t\t<?php echo Tart_Html::anchor(Tart::uri('{$controller}'), '{$controller_title}'); ?> \t\t<span class="divider">/</span> \t</li> \t<li class="active"> \t\tBatch Delete \t</li> </ul> <?php echo Form::open(Tart::uri('{$controller}', 'batch'), array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data')) ?> \t<?php echo \$table->render() ?> \t<div class="form-actions"> \t\t<?php echo Tart_Html::anchor(Tart::uri('{$controller}'), 'Cancel', array('class' => 'btn btn-link')); ?> \t\t<button type="submit" class="btn btn-primary" name="action" value="delete">Delete Selected</button> \t</div> <?php echo Form::close() ?> VIEW_BATCH_DELETE; Minion_Jam_Generate::modify_file($batch_delete_file, $batch_delete_content, $options['force'] !== FALSE, $options['unlink'] !== FALSE); } if ($options['batch_modify'] !== FALSE) { $batch_modify_file = $views_dir . 'batch_modify' . EXT; $batch_modify_content = <<<VIEW_BATCH_MODIFY <ul class="breadcrumb"> \t<li> \t\t<?php echo Tart_Html::anchor(Tart::uri('{$controller}'), '{$controller_title}'); ?> \t\t<span class="divider">/</span> \t</li> \t<li class="active"> \t\tBatch Modify \t</li> </ul> <?php echo Form::open(Tart::uri('{$controller}', 'batch'), array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data')) ?> \t<?php echo \$table->render() ?> \t<fieldset> \t\t<legend>Modify Selected Items</legend> \t\t<?php echo \$form->row('input', '{$meta->name_key()}', array('clear' => TRUE)); ?> \t</fieldset> \t<div class="form-actions"> \t\t<?php echo Tart_Html::anchor(Tart::uri('{$controller}'), 'Cancel', array('class' => 'btn btn-link')); ?> \t\t<button type="submit" class="btn btn-primary" name="action" value="modify">Modify Selected Items</button> \t</div> <?php echo Form::close() ?> VIEW_BATCH_MODIFY; Minion_Jam_Generate::modify_file($batch_modify_file, $batch_modify_content, $options['force'] !== FALSE, $options['unlink'] !== FALSE); } }
/** * Shortcut to remove a model from a relation (HABTM or embedded has_many) * See Mango::remove_relation * * @param Mango Model to remove * @param string Alternative name of model (optional) * @return boolean Model was removed * @throws No such relation exists */ public function remove(Mango $model, $name = NULL) { if ($name === NULL) { $name = (string) $model; } return $this->remove_from_relation($model, Inflector::plural($name)); }
/** * Prepares the model database connection, determines the table name, * and loads column information. * * @return void */ protected function _initialize() { // Set the object name and plural name $this->_object_name = strtolower(substr(get_class($this), 6)); // Check if this model has already been initialized if (!($init = Arr::get(ORM::$_init_cache, $this->_object_name, FALSE))) { $init = array('_belongs_to' => array(), '_has_one' => array(), '_has_many' => array(), '_has_many_keys' => array()); // Set the object plural name if none predefined if (!isset($this->_object_plural)) { $init['_object_plural'] = Inflector::plural($this->_object_name); } if (!$this->_errors_filename) { $init['_errors_filename'] = $this->_object_name; } if (!is_object($this->_db)) { // Get database instance $init['_db'] = Database::instance($this->_db_group); } if (empty($this->_table_name)) { // Table name is the same as the object name $init['_table_name'] = $this->_object_name; if ($this->_table_names_plural === TRUE) { // Make the table name plural $init['_table_name'] = Arr::get($init, '_object_plural', $this->_object_plural); } } if (!empty($this->_ignored_columns)) { // Optimize for performance $init['_ignored_columns'] = array_combine($this->_ignored_columns, $this->_ignored_columns); } $defaults = array(); foreach ($this->_belongs_to as $alias => $details) { $defaults['model'] = $alias; $defaults['foreign_key'] = $alias . $this->_foreign_key_suffix; $init['_belongs_to'][$alias] = array_merge($defaults, $details); } foreach ($this->_has_one as $alias => $details) { $defaults['model'] = $alias; $defaults['foreign_key'] = $this->_object_name . $this->_foreign_key_suffix; $init['_has_one'][$alias] = array_merge($defaults, $details); } foreach ($this->_has_many as $alias => $details) { $defaults['model'] = Inflector::singular($alias); $defaults['foreign_key'] = $this->_object_name . $this->_foreign_key_suffix; $defaults['through'] = NULL; $defaults['far_key'] = Inflector::singular($alias) . $this->_foreign_key_suffix; $init['_has_many'][$alias] = array_merge($defaults, $details); } foreach ($this->_has_many_keys as $alias => $details) { $defaults['model'] = Inflector::singular($alias); $defaults['foreign_key'] = array($this->_object_name . $this->_foreign_key_suffix); $defaults['far_key'] = array(Inflector::singular($alias) . $this->_foreign_key_suffix); $init['_has_many_keys'][$alias] = array_merge($defaults, $details); } ORM::$_init_cache[$this->_object_name] = $init; } // Assign initialized properties to the current object foreach ($init as $property => $value) { $this->{$property} = $value; } // Load column information $this->reload_columns(); // Clear initial model state $this->clear(); }
/** * Clears all inflection rules. * * @param string|boolean $lang The language name to reset or `true` to reset all even defaults. */ public static function reset($lang = null) { if (is_string($lang)) { unset(static::$_singular[$lang]); unset(static::$_plural[$lang]); return; } static::$_singular = []; static::$_plural = []; if ($lang === true) { return; } /** * Initilalize the class with english inflector rules. */ Inflector::singular('/([^s])s$/i', '\\1', 'default'); Inflector::plural('/([^s])$/i', '\\1s', 'default'); Inflector::singular('/(x|z|s|ss|ch|sh)es$/i', '\\1', 'default'); Inflector::plural('/(x|z|ss|ch|sh)$/i', '\\1es', 'default'); Inflector::singular('/ies$/i', 'y', 'default'); Inflector::plural('/([^aeiouy]|qu)y$/i', '\\1ies', 'default'); Inflector::plural('/(meta|data)$/i', '\\1', 'default'); Inflector::irregular('child', 'children', 'default'); Inflector::irregular('equipment', 'equipment', 'default'); Inflector::irregular('information', 'information', 'default'); Inflector::irregular('man', 'men', 'default'); Inflector::irregular('news', 'news', 'default'); Inflector::irregular('person', 'people', 'default'); Inflector::irregular('woman', 'women', 'default'); /** * Warning, using an "exhastive" list of rules will slow * down all singularizations/pluralizations generations. * So it may be preferable to only add the ones you are actually needed. * * Anyhow bellow a list english exceptions which are not covered by the above rules. */ // Inflector::irregular('advice', 'advice', 'default'); // Inflector::irregular('aircraft', 'aircraft', 'default'); // Inflector::irregular('alias', 'aliases', 'default'); // Inflector::irregular('alga', 'algae', 'default'); // Inflector::irregular('alumna', 'alumnae', 'default'); // Inflector::irregular('alumnus', 'alumni', 'default'); // Inflector::irregular('analysis', 'analyses', 'default'); // Inflector::irregular('antenna', 'antennae', 'default'); // Inflector::irregular('automaton', 'automata', 'default'); // Inflector::irregular('axis', 'axes', 'default'); // Inflector::irregular('bacillus', 'bacilli', 'default'); // Inflector::irregular('bacterium', 'bacteria', 'default'); // Inflector::irregular('barracks', 'barracks', 'default'); // Inflector::irregular('basis', 'bases', 'default'); // Inflector::irregular('bellows', 'bellows', 'default'); // Inflector::irregular('buffalo', 'buffaloes', 'default'); // Inflector::irregular('bus', 'buses', 'default'); // Inflector::irregular('bison', 'bison', 'default'); // Inflector::irregular('cactus', 'cacti', 'default'); // Inflector::irregular('cafe', 'cafes', 'default'); // Inflector::irregular('calf', 'calves', 'default'); // Inflector::irregular('cargo', 'cargoes', 'default'); // Inflector::irregular('cattle', 'cattle', 'default'); // Inflector::irregular('child', 'children', 'default'); // Inflector::irregular('congratulations', 'congratulations', 'default'); // Inflector::irregular('corn', 'corn', 'default'); // Inflector::irregular('crisis', 'crises', 'default'); // Inflector::irregular('criteria', 'criterion', 'default'); // Inflector::irregular('curriculum', 'curricula', 'default'); // Inflector::irregular('datum', 'data', 'default'); // Inflector::irregular('deer', 'deer', 'default'); // Inflector::irregular('die', 'dice', 'default'); // Inflector::irregular('dregs', 'dregs', 'default'); // Inflector::irregular('duck', 'duck', 'default'); // Inflector::irregular('echo', 'echos', 'default'); // Inflector::irregular('elf', 'elves', 'default'); // Inflector::irregular('ellipsis', 'ellipses', 'default'); // Inflector::irregular('embargo', 'embargoes', 'default'); // Inflector::irregular('equipment', 'equipment', 'default'); // Inflector::irregular('erratum', 'errata', 'default'); // Inflector::irregular('evidence', 'evidence', 'default'); // Inflector::irregular('eyeglasses', 'eyeglasses', 'default'); // Inflector::irregular('fish', 'fish', 'default'); // Inflector::irregular('focus', 'foci', 'default'); // Inflector::irregular('foot', 'feet', 'default'); // Inflector::irregular('fungus', 'fungi', 'default'); // Inflector::irregular('gallows', 'gallows', 'default'); // Inflector::irregular('genus', 'genera', 'default'); // Inflector::irregular('goose', 'geese', 'default'); // Inflector::irregular('gold', 'gold', 'default'); // Inflector::irregular('grotto', 'grottoes', 'default'); // Inflector::irregular('gymnasium', 'gymnasia', 'default'); // Inflector::irregular('half', 'halves', 'default'); // Inflector::irregular('headquarters', 'headquarters', 'default'); // Inflector::irregular('hoof', 'hooves', 'default'); // Inflector::irregular('hypothesis', 'hypotheses', 'default'); // Inflector::irregular('information', 'information', 'default'); // Inflector::irregular('graffito', 'graffiti', 'default'); // Inflector::irregular('half', 'halves', 'default'); // Inflector::irregular('hero', 'heroes', 'default'); // Inflector::irregular('jewelry', 'jewelry', 'default'); // Inflector::irregular('kin', 'kin', 'default'); // Inflector::irregular('knife', 'knives', 'default'); // Inflector::irregular('larva', 'larvae', 'default'); // Inflector::irregular('leaf', 'leaves', 'default'); // Inflector::irregular('legislation', 'legislation', 'default'); // Inflector::irregular('life', 'lives', 'default'); // Inflector::irregular('loaf', 'loaves', 'default'); // Inflector::irregular('locus', 'loci', 'default'); // Inflector::irregular('louse', 'lice', 'default'); // Inflector::irregular('luck', 'luck', 'default'); // Inflector::irregular('luggage', 'luggage', 'default'); // Inflector::irregular('man', 'men', 'default'); // Inflector::irregular('mathematics', 'mathematics', 'default'); // Inflector::irregular('matrix', 'matrices', 'default'); // Inflector::irregular('means', 'means', 'default'); // Inflector::irregular('measles', 'measles', 'default'); // Inflector::irregular('medium', 'media', 'default'); // Inflector::irregular('memorandum', 'memoranda', 'default'); // Inflector::irregular('money', 'monies', 'default'); // Inflector::irregular('moose', 'moose', 'default'); // Inflector::irregular('mosquito', 'mosquitoes', 'default'); // Inflector::irregular('motto', 'mottoes', 'default'); // Inflector::irregular('mouse', 'mice', 'default'); // Inflector::irregular('mumps', 'mumps', 'default'); // Inflector::irregular('music', 'music', 'default'); // Inflector::irregular('mythos', 'mythoi', 'default'); // Inflector::irregular('nebula', 'nebulae', 'default'); // Inflector::irregular('neurosis', 'neuroses', 'default'); // Inflector::irregular('news', 'news', 'default'); // Inflector::irregular('nucleus', 'nuclei', 'default'); // Inflector::irregular('numen', 'numina', 'default'); // Inflector::irregular('oasis', 'oases', 'default'); // Inflector::irregular('oats', 'oats', 'default'); // Inflector::irregular('octopus', 'octopuses', 'default'); // Inflector::irregular('offspring', 'offspring', 'default'); // Inflector::irregular('ovum', 'ova', 'default'); // Inflector::irregular('ox', 'oxen', 'default'); // Inflector::irregular('pajamas', 'pajamas', 'default'); // Inflector::irregular('pants', 'pants', 'default'); // Inflector::irregular('paralysis', 'paralyses', 'default'); // Inflector::irregular('parenthesis', 'parentheses', 'default'); // Inflector::irregular('person', 'people', 'default'); // Inflector::irregular('phenomenon', 'phenomena', 'default'); // Inflector::irregular('pike', 'pike', 'default'); // Inflector::irregular('plankton', 'plankton', 'default'); // Inflector::irregular('pliers', 'pliers', 'default'); // Inflector::irregular('polyhedron', 'polyhedra', 'default'); // Inflector::irregular('potato', 'potatoes', 'default'); // Inflector::irregular('quiz', 'quizzes', 'default'); // Inflector::irregular('radius', 'radii', 'default'); // Inflector::irregular('roof', 'roofs', 'default'); // Inflector::irregular('salmon', 'salmon', 'default'); // Inflector::irregular('scarf', 'scarves', 'default'); // Inflector::irregular('scissors', 'scissors', 'default'); // Inflector::irregular('self', 'selves', 'default'); // Inflector::irregular('series', 'series', 'default'); // Inflector::irregular('shears', 'shears', 'default'); // Inflector::irregular('sheep', 'sheep', 'default'); // Inflector::irregular('shelf', 'shelves', 'default'); // Inflector::irregular('shorts', 'shorts', 'default'); // Inflector::irregular('silver', 'silver', 'default'); // Inflector::irregular('species', 'species', 'default'); // Inflector::irregular('squid', 'squid', 'default'); // Inflector::irregular('stimulus', 'stimuli', 'default'); // Inflector::irregular('stratum', 'strata', 'default'); // Inflector::irregular('swine', 'swine', 'default'); // Inflector::irregular('syllabus', 'syllabi', 'default'); // Inflector::irregular('synopsis', 'synopses', 'default'); // Inflector::irregular('synthesis', 'syntheses', 'default'); // Inflector::irregular('tax', 'taxes', 'default'); // Inflector::irregular('terminus', 'termini', 'default'); // Inflector::irregular('thesis', 'theses', 'default'); // Inflector::irregular('thief', 'thieves', 'default'); // Inflector::irregular('tomato', 'tomatoes', 'default'); // Inflector::irregular('tongs', 'tongs', 'default'); // Inflector::irregular('tooth', 'teeth', 'default'); // Inflector::irregular('torpedo', 'torpedoes', 'default'); // Inflector::irregular('torus', 'tori', 'default'); // Inflector::irregular('trousers', 'trousers', 'default'); // Inflector::irregular('trout', 'trout', 'default'); // Inflector::irregular('tweezers', 'tweezers', 'default'); // Inflector::irregular('vertebra', 'vertebrae', 'default'); // Inflector::irregular('vertex', 'vertices', 'default'); // Inflector::irregular('vespers', 'vespers', 'default'); // Inflector::irregular('veto', 'vetoes', 'default'); // Inflector::irregular('volcano', 'volcanoes', 'default'); // Inflector::irregular('vortex', 'vortices', 'default'); // Inflector::irregular('vita', 'vitae', 'default'); // Inflector::irregular('virus', 'viri', 'default'); // Inflector::irregular('wheat', 'wheat', 'default'); // Inflector::irregular('wife', 'wives', 'default'); // Inflector::irregular('wolf', 'wolves', 'default'); // Inflector::irregular('woman', 'women', 'default'); // Inflector::irregular('zero', 'zeros', 'default'); }