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


PHP FOFInflector::isPlural方法代码示例

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


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

示例1: renderSubmenu

 /**
  * Renders the submenu (toolbar links) for all detected views of this component
  *
  * @return  void
  */
 public function renderSubmenu()
 {
     $views = $this->getMyViews();
     if (empty($views)) {
         return;
     }
     $activeView = $this->input->getCmd('view', 'cpanel');
     foreach ($views as $view) {
         // Get the view name
         $key = strtoupper($this->component) . '_TITLE_' . strtoupper($view);
         if (strtoupper(JText::_($key)) == $key) {
             $altview = FOFInflector::isPlural($view) ? FOFInflector::singularize($view) : FOFInflector::pluralize($view);
             $key2 = strtoupper($this->component) . '_TITLE_' . strtoupper($altview);
             if (strtoupper(JText::_($key2)) == $key2) {
                 $name = ucfirst($view);
             } else {
                 $name = JText::_($key2);
             }
         } else {
             $name = JText::_($key);
         }
         $link = 'index.php?option=' . $this->component . '&view=' . $view;
         $active = $view == $activeView;
         $this->appendLink($name, $link, $active);
     }
 }
开发者ID:Tommar,项目名称:vino2,代码行数:31,代码来源:toolbar.php

示例2: getTask

 /**
  * Tries to guess the controller task to execute based on the view name and
  * the HTTP request method.
  *
  * @param   string  $view  The name of the view
  *
  * @return  string  The best guess of the task to execute
  */
 protected function getTask($view)
 {
     // Get a default task based on plural/singular view
     $request_task = $this->input->getCmd('task', null);
     $task = FOFInflector::isPlural($view) ? 'browse' : 'edit';
     // Get a potential ID, we might need it later
     $id = $this->input->get('id', null, 'int');
     if ($id == 0) {
         $ids = $this->input->get('ids', array(), 'array');
         if (!empty($ids)) {
             $id = array_shift($ids);
         }
     }
     // Check the request method
     if (!isset($_SERVER['REQUEST_METHOD'])) {
         $_SERVER['REQUEST_METHOD'] = 'GET';
     }
     $requestMethod = strtoupper($_SERVER['REQUEST_METHOD']);
     switch ($requestMethod) {
         case 'POST':
         case 'PUT':
             if (!is_null($id)) {
                 $task = 'save';
             }
             break;
         case 'DELETE':
             if ($id != 0) {
                 $task = 'delete';
             }
             break;
         case 'GET':
         default:
             // If it's an edit without an ID or ID=0, it's really an add
             if ($task == 'edit' && $id == 0) {
                 $task = 'add';
             } elseif ($task == 'edit' && FOFPlatform::getInstance()->isFrontend()) {
                 $task = 'read';
             }
             break;
     }
     return $task;
 }
开发者ID:01J,项目名称:skazkipronebo,代码行数:50,代码来源:dispatcher.php

示例3: createView

 /**
  * Creates a View object instance and returns it
  *
  * @param   string  $name    The name of the view, e.g. Items
  * @param   string  $prefix  The prefix of the view, e.g. FoobarView
  * @param   string  $type    The type of the view, usually one of Html, Raw, Json or Csv
  * @param   array   $config  The configuration variables to use for creating the view
  *
  * @return  FOFView
  */
 protected function createView($name, $prefix = '', $type = '', $config = array())
 {
     // Make sure $config is an array
     if (is_object($config)) {
         $config = (array) $config;
     } elseif (!is_array($config)) {
         $config = array();
     }
     $result = null;
     // Clean the view name
     $viewName = preg_replace('/[^A-Z0-9_]/i', '', $name);
     $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
     $viewType = preg_replace('/[^A-Z0-9_]/i', '', $type);
     if (!isset($config['input'])) {
         $config['input'] = $this->input;
     }
     if ($config['input'] instanceof FOFInput) {
         $tmpInput = $config['input'];
     } else {
         $tmpInput = new FOFInput($config['input']);
     }
     // Guess the component name and view
     if (!empty($prefix)) {
         preg_match('/(.*)View$/', $prefix, $m);
         $component = 'com_' . strtolower($m[1]);
     } else {
         $component = '';
     }
     if (empty($component) && array_key_exists('input', $config)) {
         $component = $tmpInput->get('option', $component, 'cmd');
     }
     if (array_key_exists('option', $config)) {
         if ($config['option']) {
             $component = $config['option'];
         }
     }
     $config['option'] = $component;
     $view = strtolower($viewName);
     if (empty($view) && array_key_exists('input', $config)) {
         $view = $tmpInput->get('view', $view, 'cmd');
     }
     if (array_key_exists('view', $config)) {
         if ($config['view']) {
             $view = $config['view'];
         }
     }
     $config['view'] = $view;
     if (array_key_exists('input', $config)) {
         $tmpInput->set('option', $config['option']);
         $tmpInput->set('view', $config['view']);
         $config['input'] = $tmpInput;
     }
     // Get the component directories
     $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']);
     // Get the base paths where the view class files are expected to live
     $basePaths = array($componentPaths['main'], $componentPaths['alt']);
     $basePaths = array_merge($this->paths['view']);
     // Get the alternate (singular/plural) view name
     $altViewName = FOFInflector::isPlural($viewName) ? FOFInflector::singularize($viewName) : FOFInflector::pluralize($viewName);
     $suffixes = array($viewName, $altViewName, 'default');
     $filesystem = FOFPlatform::getInstance()->getFilesystem();
     foreach ($suffixes as $suffix) {
         // Build the view class name
         $viewClass = $classPrefix . ucfirst($suffix);
         if (class_exists($viewClass)) {
             // The class is already loaded
             break;
         }
         // The class is not loaded. Let's load it!
         $viewPath = $this->createFileName('view', array('name' => $suffix, 'type' => $viewType));
         $path = $filesystem->pathFind($basePaths, $viewPath);
         if ($path) {
             require_once $path;
         }
         if (class_exists($viewClass)) {
             // The class was loaded successfully
             break;
         }
     }
     if (!class_exists($viewClass)) {
         $viewClass = 'FOFView' . ucfirst($type);
     }
     $templateOverridePath = FOFPlatform::getInstance()->getTemplateOverridePath($config['option']);
     // Setup View configuration options
     if (!array_key_exists('template_path', $config)) {
         $config['template_path'][] = $componentPaths['main'] . '/views/' . FOFInflector::pluralize($config['view']) . '/tmpl';
         if ($templateOverridePath) {
             $config['template_path'][] = $templateOverridePath . '/' . FOFInflector::pluralize($config['view']);
         }
         $config['template_path'][] = $componentPaths['main'] . '/views/' . FOFInflector::singularize($config['view']) . '/tmpl';
//.........这里部分代码省略.........
开发者ID:alvarovladimir,项目名称:messermeister_ab_rackservers,代码行数:101,代码来源:controller.php

示例4: createView

 /**
  * Creates a View object instance and returns it
  *
  * @param   string  $name    The name of the view, e.g. Items
  * @param   string  $prefix  The prefix of the view, e.g. FoobarView
  * @param   string  $type    The type of the view, usually one of Html, Raw, Json or Csv
  * @param   array   $config  The configuration variables to use for creating the view
  *
  * @return  FOFView
  */
 protected function createView($name, $prefix = '', $type = '', $config = array())
 {
     // Make sure $config is an array
     if (is_object($config)) {
         $config = (array) $config;
     } elseif (!is_array($config)) {
         $config = array();
     }
     $result = null;
     // Clean the view name
     $viewName = preg_replace('/[^A-Z0-9_]/i', '', $name);
     $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
     $viewType = preg_replace('/[^A-Z0-9_]/i', '', $type);
     if (!isset($config['input'])) {
         $config['input'] = $this->input;
     }
     if ($config['input'] instanceof FOFInput) {
         $tmpInput = $config['input'];
     } else {
         $tmpInput = new FOFInput($config['input']);
     }
     // Guess the component name and view
     if (!empty($prefix)) {
         preg_match('/(.*)View$/', $prefix, $m);
         $component = 'com_' . strtolower($m[1]);
     } else {
         $component = '';
     }
     if (empty($component) && array_key_exists('input', $config)) {
         $component = $tmpInput->get('option', $component, 'cmd');
     }
     if (array_key_exists('option', $config)) {
         if ($config['option']) {
             $component = $config['option'];
         }
     }
     $config['option'] = $component;
     $view = strtolower($viewName);
     if (empty($view) && array_key_exists('input', $config)) {
         $view = $tmpInput->get('view', $view, 'cmd');
     }
     if (array_key_exists('view', $config)) {
         if ($config['view']) {
             $view = $config['view'];
         }
     }
     $config['view'] = $view;
     if (array_key_exists('input', $config)) {
         $tmpInput->set('option', $config['option']);
         $tmpInput->set('view', $config['view']);
         $config['input'] = $tmpInput;
     }
     // Get the component directories
     $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']);
     // Get the base paths where the view class files are expected to live
     $basePaths = array($componentPaths['main'], $componentPaths['alt']);
     $basePaths = array_merge($this->paths['view']);
     // Get the alternate (singular/plural) view name
     $altViewName = FOFInflector::isPlural($viewName) ? FOFInflector::singularize($viewName) : FOFInflector::pluralize($viewName);
     $suffixes = array($viewName, $altViewName, 'default');
     $filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
     foreach ($suffixes as $suffix) {
         // Build the view class name
         $viewClass = $classPrefix . ucfirst($suffix);
         if (class_exists($viewClass)) {
             // The class is already loaded
             break;
         }
         // The class is not loaded. Let's load it!
         $viewPath = $this->createFileName('view', array('name' => $suffix, 'type' => $viewType));
         $path = $filesystem->pathFind($basePaths, $viewPath);
         if ($path) {
             require_once $path;
         }
         if (class_exists($viewClass)) {
             // The class was loaded successfully
             break;
         }
     }
     if (!class_exists($viewClass)) {
         $viewClass = 'FOFView' . ucfirst($type);
     }
     $templateOverridePath = FOFPlatform::getInstance()->getTemplateOverridePath($config['option']);
     // Setup View configuration options
     if (!array_key_exists('template_path', $config)) {
         $config['template_path'][] = $componentPaths['main'] . '/views/' . FOFInflector::pluralize($config['view']) . '/tmpl';
         if ($templateOverridePath) {
             $config['template_path'][] = $templateOverridePath . '/' . FOFInflector::pluralize($config['view']);
         }
         $config['template_path'][] = $componentPaths['main'] . '/views/' . FOFInflector::singularize($config['view']) . '/tmpl';
//.........这里部分代码省略.........
开发者ID:educakanchay,项目名称:kanchay,代码行数:101,代码来源:controller.php

示例5: getPluralization

 public static function getPluralization($name, $form = 'singular')
 {
     static $cache = array();
     if (!empty($cache[$name . '.' . $form])) {
         return $cache[$name . '.' . $form];
     }
     //Pluralization
     if (JFile::exists(JPATH_LIBRARIES . '/fof/include.php')) {
         if (!defined('FOF_INCLUDED')) {
             require_once JPATH_LIBRARIES . '/fof/include.php';
         }
     } else {
         if (JFile::exists(JPATH_LIBRARIES . '/fof/inflector/inflector.php')) {
             require_once JPATH_LIBRARIES . '/fof/inflector/inflector.php';
         } else {
             require_once JPATH_COMPONENT . '/helpers/fofinflector.php';
         }
     }
     $plural = null;
     //$inflector = new FOFInflector();
     //see if name is singular, if so get a plural
     if (FOFInflector::isSingular($name)) {
         $plural = FOFInflector::pluralize($name);
     }
     //if still no plural check if name is plural
     if (empty($plural)) {
         if (FOFInflector::isPlural($name)) {
             //if its a plural switch them
             $plural = $name;
             //and get a singular
             $name = FOFInflector::singularize($name);
         }
     }
     //if still no plural just make one anyway
     if (empty($plural)) {
         $plural = $name . 's';
     }
     $cache[$name . '.plural'] = $plural;
     $cache[$name . '.singular'] = $name;
     return $cache[$name . '.' . $form];
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:41,代码来源:jacc.php

示例6: createView

 /**
  * Creates a View object instance and returns it
  *
  * @param   string  $name    The name of the view, e.g. Items
  * @param   string  $prefix  The prefix of the view, e.g. FoobarView
  * @param   string  $type    The type of the view, usually one of Html, Raw, Json or Csv
  * @param   array   $config  The configuration variables to use for creating the view
  *
  * @return  FOFView
  */
 protected function createView($name, $prefix = '', $type = '', $config = array())
 {
     // Make sure $config is an array
     if (is_object($config)) {
         $config = (array) $config;
     } elseif (!is_array($config)) {
         $config = array();
     }
     $result = null;
     // Clean the view name
     $viewName = preg_replace('/[^A-Z0-9_]/i', '', $name);
     $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
     $viewType = preg_replace('/[^A-Z0-9_]/i', '', $type);
     if (!isset($config['input'])) {
         $config['input'] = $this->input;
     }
     if ($config['input'] instanceof FOFInput) {
         $tmpInput = $config['input'];
     } else {
         $tmpInput = new FOFInput($config['input']);
     }
     // Guess the component name and view
     if (!empty($prefix)) {
         preg_match('/(.*)View$/', $prefix, $m);
         $component = 'com_' . strtolower($m[1]);
     } else {
         $component = '';
     }
     if (empty($component) && array_key_exists('input', $config)) {
         $component = $tmpInput->get('option', $component, 'cmd');
     }
     if (array_key_exists('option', $config)) {
         if ($config['option']) {
             $component = $config['option'];
         }
     }
     $config['option'] = $component;
     $view = strtolower($viewName);
     if (empty($view) && array_key_exists('input', $config)) {
         $view = $tmpInput->get('view', $view, 'cmd');
     }
     if (array_key_exists('view', $config)) {
         if ($config['view']) {
             $view = $config['view'];
         }
     }
     $config['view'] = $view;
     if (array_key_exists('input', $config)) {
         $tmpInput->set('option', $config['option']);
         $tmpInput->set('view', $config['view']);
         $config['input'] = $tmpInput;
     }
     // Get the base paths where the view class files are expected to live
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     $basePaths = array(JPATH_SITE . '/components/' . $config['option'] . '/views', JPATH_ADMINISTRATOR . '/components/' . $config['option'] . '/views');
     if ($isAdmin || $isCli) {
         $basePaths = array_reverse($basePaths);
         $basePaths = array_merge($basePaths, $this->paths['view'], $basePaths);
     } else {
         $basePaths = array_merge($this->paths['view']);
     }
     // Get the alternate (singular/plural) view name
     $altViewName = FOFInflector::isPlural($viewName) ? FOFInflector::singularize($viewName) : FOFInflector::pluralize($viewName);
     $suffixes = array($viewName, $altViewName, 'default');
     JLoader::import('joomla.filesystem.path');
     foreach ($suffixes as $suffix) {
         // Build the view class name
         $viewClass = $classPrefix . ucfirst($suffix);
         if (class_exists($viewClass)) {
             // The class is already loaded
             break;
         }
         // The class is not loaded. Let's load it!
         $viewPath = $this->createFileName('view', array('name' => $suffix, 'type' => $viewType));
         $path = JPath::find($basePaths, $viewPath);
         if ($path) {
             require_once $path;
         }
         if (class_exists($viewClass)) {
             // The class was loaded successfully
             break;
         }
     }
     if (!class_exists($viewClass)) {
         $viewClass = 'FOFView' . ucfirst($type);
     }
     // Setup View configuration options
     if ($isAdmin) {
         $basePath = JPATH_ADMINISTRATOR;
     } elseif ($isCli) {
//.........这里部分代码省略.........
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:101,代码来源:controller.php


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