本文整理汇总了PHP中singular函数的典型用法代码示例。如果您正苦于以下问题:PHP singular函数的具体用法?PHP singular怎么用?PHP singular使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了singular函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_singular
public function test_singular()
{
$strs = array('tellies' => 'telly', 'smellies' => 'smelly', 'abjectnesses' => 'abjectness', 'smells' => 'smell', 'equipment' => 'equipment');
foreach ($strs as $str => $expect) {
$this->assertEquals($expect, singular($str));
}
}
开发者ID:saiful1105020,项目名称:Under-Construction-Bracathon-Project-,代码行数:7,代码来源:inflector_helper_test.php
示例2: _remap
/**
* Remap routes
*
* Codeigniter controller routes RESTful remap
*
* @return mixed
*/
public function _remap()
{
$http_method = $this->input->method();
$route = $this->router->method;
$params = array_slice($this->router->uri->rsegments, 2);
// We are use PUT, PATCH, DELETE methods
if (!is_null($this->input->post('_method'))) {
$http_method = strtolower($this->input->post('_method'));
$route = isset($this->router->uri->rsegments[2]) ? $this->router->uri->rsegments[2] : $this->router->uri->rsegments[1];
}
// Second segment is numeric
if (is_numeric($route)) {
$route = singular($this->router->uri->rsegments[1]);
if (end($this->router->uri->segments) === 'edit') {
$http_method = 'edit';
}
$params = array_slice($this->router->uri->rsegments, 1, 1);
// Third uri segment is resource $id
$params = $params[0];
}
if ($route === 'create') {
$http_method = 'create';
$route = singular($this->router->class);
}
$action = "{$http_method}_{$route}";
if (method_exists($this, $action)) {
return $this->{$action}($params);
}
if (method_exists($this, $route)) {
return $this->{$route}($params);
}
redirect(404);
}
示例3: generate_crud
protected function generate_crud($table, $subject = '')
{
// create CRUD object
$this->load->library('Grocery_CRUD');
$crud = new grocery_CRUD();
$crud->set_table($table);
// auto-generate subject
if (empty($subject)) {
$crud->set_subject(humanize(singular($table)));
}
// load settings from: application/config/grocery_crud.php
$this->load->config('grocery_crud');
$this->mCrudUnsetFields = $this->config->item('grocery_crud_unset_fields');
if ($this->config->item('grocery_crud_unset_jquery')) {
$crud->unset_jquery();
}
if ($this->config->item('grocery_crud_unset_jquery_ui')) {
$crud->unset_jquery_ui();
}
if ($this->config->item('grocery_crud_unset_print')) {
$crud->unset_print();
}
if ($this->config->item('grocery_crud_unset_export')) {
$crud->unset_export();
}
if ($this->config->item('grocery_crud_unset_read')) {
$crud->unset_read();
}
foreach ($this->config->item('grocery_crud_display_as') as $key => $value) {
$crud->display_as($key, $value);
}
// other custom logic to be done outside
$this->mCrud = $crud;
return $crud;
}
示例4: __construct
/**
* Create a controller, set up its name, autoload models if possible
*/
public function __construct()
{
$this->name = trim(get_class($this), 'Controller');
if (class_exists(singular($this->name))) {
$this->loadModel(singular($this->name));
}
$this->data = array();
$this->d('Created a controller');
}
示例5: get_common_key
protected function get_common_key()
{
$this_class = strtolower(get_class($this));
// this is to ensure that singular is only called once per model
if (isset(DataMapper::$common[DMZ_CLASSNAMES_KEY][$this_class])) {
return DataMapper::$common[DMZ_CLASSNAMES_KEY][$this_class];
} else {
return singular($this_class);
}
}
示例6: up
public function up()
{
$this->dbforge->modify_column('blog', array('comments_enabled' => array('type' => 'set', 'constraint' => array('no', '1 day', '1 week', '2 weeks', '1 month', '3 months', 'always'), 'null' => false, 'default' => 'always')));
$this->db->update('blog', array('comments_enabled' => '3 months'));
// Lets update the comments table with these new awesome fields
$this->dbforge->modify_column('comments', array('module_id' => array('name' => 'entry_id', 'type' => 'varchar', 'constraint' => 255, 'null' => true), 'name' => array('name' => 'user_name', 'type' => 'varchar', 'constraint' => 255), 'email' => array('name' => 'user_email', 'type' => 'varchar', 'constraint' => 255), 'website' => array('name' => 'user_website', 'type' => 'varchar', 'constraint' => 255, 'null' => true)));
$this->dbforge->add_column('comments', array('entry_title' => array('type' => 'char', 'constraint' => 255, 'null' => false), 'entry_key' => array('type' => 'varchar', 'constraint' => 100, 'null' => false), 'entry_plural' => array('type' => 'varchar', 'constraint' => 100, 'null' => false), 'uri' => array('type' => 'varchar', 'constraint' => 255, 'null' => true), 'cp_uri' => array('type' => 'varchar', 'constraint' => 255, 'null' => true)));
$comments = $this->db->get('comments')->result();
foreach ($comments as &$comment) {
// What did they comment on
switch ($comment->module) {
case 'gallery':
$comment->module = plural($comment->module);
break;
case 'gallery-image':
$comment->module = 'galleries';
$ci->load->model('galleries/gallery_image_m');
if ($item = $ci->gallery_image_m->get($comment->module_id)) {
continue 2;
}
break;
}
$this->load->model('addons/module_m');
// Use the old comment logic to grab title names, then we can never have to use this junk again
if (in_array($comment->module, array('blog', 'pages'))) {
// Grab an item
switch ($comment->module) {
case 'blog':
// Get this one article out of the db
$item = $this->db->get_where('blog', array('id' => $comment->entry_id))->row();
$comment->entry_title = $item->title;
$comment->uri = 'blog/' . date('Y/m', $item->created_on) . '/' . $item->slug;
$comment->entry_key = 'blog:post';
$comment->entry_plural = 'blog:posts';
$comment->cp_uri = 'admin/' . $comment->module . '/preview/' . $item->id;
break;
case 'pages':
// Get this one page out of the db
$item = $this->db->get_where('pages', array('id' => $comment->entry_id))->row();
$comment->entry_title = $item->title;
$comment->uri = $item->uri;
$comment->entry_key = 'pages:page';
$comment->entry_plural = 'pages:pages';
$comment->cp_uri = 'admin/' . $comment->module . '/preview/' . $item->id;
break;
}
} else {
$comment->entry_title = $comment->module . ' #' . $comment->entry_id;
$comment->entry_key = humanize(singular($comment->module));
$comment->entry_plural = humanize(plural($comment->module));
}
// Save this comment again
$this->db->where('id', $comment->id)->update('comments', $comment);
}
}
示例7: build_db_select_with_aliases
function build_db_select_with_aliases($array)
{
$temp_alias_string = '';
foreach ($array as $table => $fields) {
$table_sigular = singular($table);
foreach ($fields as $field) {
$temp_alias_string .= $table . '.' . $field . ' AS ' . $table_sigular . '_' . $field . ', ';
}
}
return $temp_alias_string;
}
示例8: prepareData
/**
* Prepares the data before generation.
*
* @param array &$data
* @return void
*/
public function prepareData(array &$data)
{
$data['camel'] = [];
$data['columns'] = [];
$data['dropdowns'] = [];
$data['foreignKeys'] = [];
$data['models'] = [$data['name']];
$data['plural'] = plural($data['name']);
$data['singular'] = singular($data['name']);
$data['underscore'] = [];
}
示例9: __construct
function __construct()
{
parent::__construct();
if (empty($this->element)) {
$singular = ucfirst(singular($this->ctrlr_name));
$this->element = new $singular();
}
// if ($this->authentication->is_signed_in()) {
// $this->_add_menu_item('edit', lang('manage'), array($this->ctrlr_name . '/edit', lang('edit_profile')));
// }
// $this->_add_menu_item('view', '', array($this->ctrlr_name . '/view', lang('home')));
}
示例10: __construct
public function __construct()
{
parent::__construct();
$this->load->helper('inflector');
$model = strtolower(singular(get_class($this)));
if (file_exists(APPPATH . 'models/' . $model . '_model.php')) {
$this->models[] = $model;
}
foreach ($this->models as $model) {
$this->load->model($model . '_model', $model);
}
}
示例11: makeModel
public function makeModel($name)
{
$this->load->helper('inflector');
$name = singular($name);
$this->model_name = $name;
// If a table exists, we can build it from that
if ($this->table_exists) {
$this->generate("model {$name}", "-table {$name} -primary_key id", TRUE);
} else {
$this->generate("model {$name}", "-fields '{$this->fields}'", TRUE);
}
}
示例12: __construct
function __construct()
{
parent::__construct();
$this->redirect_url = "admin/" . $this->ctrlr_name;
if (empty($this->element)) {
$this->ctrlr_singular_name = singular($this->ctrlr_name);
$this->load->model(array('admin/' . $this->ctrlr_singular_name));
}
// if ($this->authentication->is_signed_in()) {
// $this->_add_menu_item('edit', lang('manage'), array($this->ctrlr_name . '/edit', lang('edit_profile')));
// }
// $this->_add_menu_item('view', '', array($this->ctrlr_name . '/view', lang('home')));
}
示例13: get_index
public function get_index($per_page = 0, $page = 0, $category_id = NULL, $order = NULL, $desc = NULL, $enable = TRUE)
{
if (isset($category_id)) {
$this->pdo->where(array($this->table . '.' . singular($this->table) . '_category_id' => $category_id));
if ($this->input->get('search_type')) {
$result = $this->get_search($this->input->get('search_type'), $this->input->get('search_word'));
}
$result['total'] = $this->pdo->count_all_results($this->table);
} else {
if ($this->input->get('search_type')) {
$result = $this->get_search($this->input->get('search_type'), $this->input->get('search_word'));
}
$result['total'] = $this->pdo->count_all_results($this->table);
}
if (empty($order)) {
if (empty($this->order)) {
$order = $this->order;
} else {
$order = 'id';
}
}
if (empty($desc)) {
if (empty($this->desc)) {
$desc = $this->desc;
} else {
$desc = TRUE;
}
}
if (!is_bool($desc)) {
throw new Exception("Error Processing Request", 1);
}
if ($desc) {
$desc = 'desc';
} else {
$desc = 'asc';
}
if (!$result['total']) {
return $result;
}
$this->pdo->select($this->table . '.*');
if (isset($category_id)) {
$this->pdo->where(array($this->table . '.' . singular($this->table) . '_category_id' => $category_id));
}
if ($this->input->get('search_type')) {
$this->get_search($this->input->get('search_type'), $this->input->get('search_word'));
}
$this->pdo->order_by($order, $desc);
$query = $this->pdo->get($this->table, $per_page, $page);
$result['list'] = $query->result_array();
return $result;
}
示例14: __construct
public function __construct()
{
parent::__construct();
// Configure limits on our controller methods
// Ensure you have created the 'limits' table and enabled 'limits' within application/config/rest.php
$this->methods['user_get']['limit'] = 500;
// 500 requests per hour per user/key
$this->methods['user_post']['limit'] = 100;
// 100 requests per hour per user/key
$this->methods['user_delete']['limit'] = 50;
// 50 requests per hour per user/key
$this->load->helper('inflector');
$this->load->model(singular($this->router->fetch_method()));
}
示例15: packageCliAction
public function packageCliAction($path = null)
{
$this->load->helper('inflector');
if (!$path) {
show_error('Please provide path');
}
$path = implode('/', func_get_args());
$path = '/' . strtolower(trim($path, '/'));
$dir = dirname($path);
$filename = basename($path);
$root = ROOTPATH . '/packages/' . $filename;
mkdir($root);
touch($root . '/composer.json');
mkdir($root . '/public');
mkdir($root . '/support');
mkdir($root . '/support/migrations');
touch($root . '/support/onload.php');
touch($root . '/support/migrations/v1.0.0-' . $filename . '.php');
mkdir($root . '/controllers');
mkdir($root . '/controllers/' . $dir, 0777, true);
touch($root . '/controllers/' . $dir . '/' . ucfirst($filename) . 'Controller.php');
mkdir($root . '/helpers');
mkdir($root . '/language');
mkdir($root . '/libraries');
mkdir($root . '/models');
touch($root . '/models/' . ucfirst($filename) . '_model.php');
mkdir($root . '/views');
mkdir($root . '/views/' . $path, 0777, true);
touch($root . '/views/' . $path . '/index.php');
touch($root . '/views/' . $path . '/form.php');
$data = [];
$this->model($filename, $data);
$this->view($filename, $data);
$data['controller'] = ucfirst(strtolower(str_replace('-', '_', $filename)));
$data['uname'] = ucfirst(strtolower($filename));
$data['lname'] = strtolower($filename);
$data['path'] = trim($path, '/');
$data['model'] = $filename . '_model';
$data['single'] = singular($filename);
$data['plural'] = plural($filename);
$data['name'] = strtolower($filename);
//var_dump($data);
file_put_contents($root . '/views/' . $path . '/index.php', $this->merge('index', $data));
file_put_contents($root . '/views/' . $path . '/form.php', $this->merge('form', $data));
file_put_contents($root . '/controllers/' . $dir . '/' . ucfirst($filename) . 'Controller.php', $this->merge('controller', $data));
file_put_contents($root . '/models/' . ucfirst($filename) . '_model.php', $this->merge('model', $data));
file_put_contents($root . '/support/migrations/v1.0.0-' . $filename . '.php', $this->merge('migration', $data));
file_put_contents($root . '/composer.json', $this->merge('composer', $data));
}