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


PHP FOFInflector::singularize方法代码示例

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


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

示例1: dispatch

 public function dispatch()
 {
     // Look for controllers in the plugins folder
     $option = $this->input->get('option', 'com_foobar', 'cmd');
     $view = $this->input->get('view', $this->defaultView, 'cmd');
     $c = FOFInflector::singularize($view);
     $alt_path = JPATH_SITE . '/components/' . $option . '/plugins/controllers/' . $c . '.php';
     JLoader::import('joomla.filesystem.file');
     if (JFile::exists($alt_path)) {
         // The requested controller exists and there you load it...
         require_once $alt_path;
     }
     $this->input->set('view', $this->view);
     parent::dispatch();
 }
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:15,代码来源:dispatcher.php

示例2: 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

示例3: getContentType

 /**
  * Get the content type for ucm
  *
  * @return string The content type alias
  */
 public function getContentType()
 {
     if ($this->contentType) {
         return $this->contentType;
     }
     /**
      * When tags was first introduced contentType variable didn't exist - so we guess one
      * This will fail if content history behvaiour is enabled. This code is deprecated
      * and will be removed in FOF 3.0 in favour of the content type class variable
      */
     $component = $this->input->get('option');
     $view = FOFInflector::singularize($this->input->get('view'));
     $alias = $component . '.' . $view;
     return $alias;
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:20,代码来源:table.php

示例4: dispatch

 /**
  * The main code of the Dispatcher. It spawns the necessary controller and
  * runs it.
  *
  * @throws Exception
  *
  * @return  null
  */
 public function dispatch()
 {
     $platform = FOFPlatform::getInstance();
     if (!$platform->authorizeAdmin($this->input->getCmd('option', 'com_foobar'))) {
         return $platform->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
     }
     $this->transparentAuthentication();
     // Merge English and local translations
     $platform->loadTranslations($this->component);
     $canDispatch = true;
     if ($platform->isCli()) {
         $canDispatch = $canDispatch && $this->onBeforeDispatchCLI();
     }
     $canDispatch = $canDispatch && $this->onBeforeDispatch();
     if (!$canDispatch) {
         $platform->setHeader('Status', '403 Forbidden', true);
         return $platform->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
     }
     // Get and execute the controller
     $option = $this->input->getCmd('option', 'com_foobar');
     $view = $this->input->getCmd('view', $this->defaultView);
     $task = $this->input->getCmd('task', null);
     if (empty($task)) {
         $task = $this->getTask($view);
     }
     // Pluralise/sungularise the view name for typical tasks
     if (in_array($task, array('edit', 'add', 'read'))) {
         $view = FOFInflector::singularize($view);
     } elseif (in_array($task, array('browse'))) {
         $view = FOFInflector::pluralize($view);
     }
     $this->input->set('view', $view);
     $this->input->set('task', $task);
     $config = $this->config;
     $config['input'] = $this->input;
     $controller = FOFController::getTmpInstance($option, $view, $config);
     $status = $controller->execute($task);
     if (!$this->onAfterDispatch()) {
         $platform->setHeader('Status', '403 Forbidden', true);
         return $platform->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
     }
     $format = $this->input->get('format', 'html', 'cmd');
     $format = empty($format) ? 'html' : $format;
     if ($format == 'html') {
         // In HTML views perform a redirection
         if ($controller->redirect()) {
             return;
         }
     } else {
         // In non-HTML views just exit the application with the proper HTTP headers
         if ($controller->hasRedirect()) {
             $headers = $platform->sendHeaders();
             jexit();
         }
     }
 }
开发者ID:01J,项目名称:skazkipronebo,代码行数:64,代码来源:dispatcher.php

示例5: dispatch

 public function dispatch()
 {
     if (!class_exists('AkeebaControllerDefault')) {
         require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/controllers/default.php';
     }
     // Merge the language overrides
     $paths = array(JPATH_ROOT, JPATH_ADMINISTRATOR);
     $jlang = JFactory::getLanguage();
     $jlang->load($this->component, $paths[0], 'en-GB', true);
     $jlang->load($this->component, $paths[0], null, true);
     $jlang->load($this->component, $paths[1], 'en-GB', true);
     $jlang->load($this->component, $paths[1], null, true);
     $jlang->load($this->component . '.override', $paths[0], 'en-GB', true);
     $jlang->load($this->component . '.override', $paths[0], null, true);
     $jlang->load($this->component . '.override', $paths[1], 'en-GB', true);
     $jlang->load($this->component . '.override', $paths[1], null, true);
     FOFInflector::addWord('alice', 'alices');
     // Timezone fix; avoids errors printed out by PHP 5.3.3+ (thanks Yannick!)
     if (function_exists('date_default_timezone_get') && function_exists('date_default_timezone_set')) {
         if (function_exists('error_reporting')) {
             $oldLevel = error_reporting(0);
         }
         $serverTimezone = @date_default_timezone_get();
         if (empty($serverTimezone) || !is_string($serverTimezone)) {
             $serverTimezone = 'UTC';
         }
         if (function_exists('error_reporting')) {
             error_reporting($oldLevel);
         }
         @date_default_timezone_set($serverTimezone);
     }
     // Necessary defines for Akeeba Engine
     if (!defined('AKEEBAENGINE')) {
         define('AKEEBAENGINE', 1);
         // Required for accessing Akeeba Engine's factory class
         define('AKEEBAROOT', dirname(__FILE__) . '/akeeba');
         define('ALICEROOT', dirname(__FILE__) . '/alice');
     }
     // Setup Akeeba's ACLs, honoring laxed permissions in component's parameters, if set
     // Access check, Joomla! 1.6 style.
     $user = JFactory::getUser();
     if (!$user->authorise('core.manage', 'com_akeeba')) {
         return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     // Make sure we have a profile set throughout the component's lifetime
     $session = JFactory::getSession();
     $profile_id = $session->get('profile', null, 'akeeba');
     if (is_null($profile_id)) {
         // No profile is set in the session; use default profile
         $session->set('profile', 1, 'akeeba');
     }
     // Load the factory
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/akeeba/factory.php';
     @(include_once JPATH_COMPONENT_ADMINISTRATOR . '/alice/factory.php');
     // Load the Akeeba Backup configuration and check user access permission
     $aeconfig = AEFactory::getConfiguration();
     AEPlatform::getInstance()->load_configuration();
     unset($aeconfig);
     // Preload helpers
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/includes.php';
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/escape.php';
     // Load the utils helper library
     AEPlatform::getInstance()->load_version_defines();
     // Create a versioning tag for our static files
     $staticFilesVersioningTag = md5(AKEEBA_VERSION . AKEEBA_DATE);
     define('AKEEBAMEDIATAG', $staticFilesVersioningTag);
     // If JSON functions don't exist, load our compatibility layer
     if (!function_exists('json_encode') || !function_exists('json_decode')) {
         require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/jsonlib.php';
     }
     // Look for controllers in the plugins folder
     $option = $this->input->get('option', 'com_foobar', 'cmd');
     $view = $this->input->get('view', $this->defaultView, 'cmd');
     $c = FOFInflector::singularize($view);
     $alt_path = JPATH_ADMINISTRATOR . '/components/' . $option . '/plugins/controllers/' . $c . '.php';
     JLoader::import('joomla.filesystem.file');
     if (JFile::exists($alt_path)) {
         // The requested controller exists and there you load it...
         require_once $alt_path;
     }
     $this->input->set('view', $this->view);
     parent::dispatch();
 }
开发者ID:sillysachin,项目名称:teamtogether,代码行数:83,代码来源:dispatcher.php

示例6: getViewTemplatePaths

 /**
  * Return a list of the view template paths for this component.
  *
  * @param   string   $component  The name of the component. For Joomla! this
  *                               is something like "com_example"
  * @param   string   $view       The name of the view you're looking a
  *                               template for
  * @param   string   $layout     The layout name to load, e.g. 'default'
  * @param   string   $tpl        The sub-template name to load (null by default)
  * @param   boolean  $strict     If true, only the specified layout will be searched for.
  *                               Otherwise we'll fall back to the 'default' layout if the
  *                               specified layout is not found.
  *
  * @see FOFPlatformInterface::getViewTemplateDirs()
  *
  * @return  array
  */
 public function getViewTemplatePaths($component, $view, $layout = 'default', $tpl = null, $strict = false)
 {
     $isAdmin = $this->isBackend();
     $basePath = $isAdmin ? 'admin:' : 'site:';
     $basePath .= $component . '/';
     $altBasePath = $basePath;
     $basePath .= $view . '/';
     $altBasePath .= (FOFInflector::isSingular($view) ? FOFInflector::pluralize($view) : FOFInflector::singularize($view)) . '/';
     if ($strict) {
         $paths = array($basePath . $layout . ($tpl ? "_{$tpl}" : ''), $altBasePath . $layout . ($tpl ? "_{$tpl}" : ''));
     } else {
         $paths = array($basePath . $layout . ($tpl ? "_{$tpl}" : ''), $basePath . $layout, $basePath . 'default' . ($tpl ? "_{$tpl}" : ''), $basePath . 'default', $altBasePath . $layout . ($tpl ? "_{$tpl}" : ''), $altBasePath . $layout, $altBasePath . 'default' . ($tpl ? "_{$tpl}" : ''), $altBasePath . 'default');
         $paths = array_unique($paths);
     }
     return $paths;
 }
开发者ID:alvarovladimir,项目名称:messermeister_ab_rackservers,代码行数:33,代码来源:platform.php

示例7: normaliseItemName

 /**
  * Normalises the format of a relation name
  *
  * @param   string   $itemName   The raw relation name
  * @param   boolean  $pluralise  Should I pluralise the name? If not, I will singularise it
  *
  * @return  string  The normalised relation key name
  */
 protected function normaliseItemName($itemName, $pluralise = false)
 {
     // Explode the item name
     $itemNameParts = explode('_', $itemName);
     // If we have multiple parts the first part is considered to be the component name
     if (count($itemNameParts) > 1) {
         $prefix = array_shift($itemNameParts);
     } else {
         $prefix = null;
     }
     // If we still have multiple parts we need to pluralise/singularise the last part and join everything in
     // CamelCase format
     if (count($itemNameParts) > 1) {
         $name = array_pop($itemNameParts);
         $name = $pluralise ? FOFInflector::pluralize($name) : FOFInflector::singularize($name);
         $itemNameParts[] = $name;
         $itemName = FOFInflector::implode($itemNameParts);
     } else {
         $name = array_pop($itemNameParts);
         $itemName = $pluralise ? FOFInflector::pluralize($name) : FOFInflector::singularize($name);
     }
     if (!empty($prefix)) {
         $itemName = $prefix . '_' . $itemName;
     }
     return $itemName;
 }
开发者ID:educakanchay,项目名称:kanchay,代码行数:34,代码来源:relations.php

示例8: loadTemplate

 /**
  * Overrides the built-in loadTemplate function with an FOF-specific one.
  * Our overriden function uses loadAnyTemplate to provide smarter view
  * template loading.
  *
  * @param   string   $tpl     The name of the template file to parse
  * @param   boolean  $strict  Should we use strict naming, i.e. force a non-empty $tpl?
  *
  * @return  mixed  A string if successful, otherwise a JError object
  */
 public function loadTemplate($tpl = null, $strict = false)
 {
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     $basePath = $isAdmin ? 'admin:' : 'site:';
     $basePath .= $this->config['option'] . '/';
     $altBasePath = $basePath;
     $basePath .= $this->config['view'] . '/';
     $altBasePath .= (FOFInflector::isSingular($this->config['view']) ? FOFInflector::pluralize($this->config['view']) : FOFInflector::singularize($this->config['view'])) . '/';
     if ($strict) {
         $paths = array($basePath . $this->getLayout() . ($tpl ? "_{$tpl}" : ''), $altBasePath . $this->getLayout() . ($tpl ? "_{$tpl}" : ''));
     } else {
         $paths = array($basePath . $this->getLayout() . ($tpl ? "_{$tpl}" : ''), $basePath . $this->getLayout(), $basePath . 'default' . ($tpl ? "_{$tpl}" : ''), $basePath . 'default', $altBasePath . $this->getLayout() . ($tpl ? "_{$tpl}" : ''), $altBasePath . $this->getLayout(), $altBasePath . 'default' . ($tpl ? "_{$tpl}" : ''), $altBasePath . 'default');
     }
     foreach ($paths as $path) {
         $result = $this->loadAnyTemplate($path);
         if (!$result instanceof Exception) {
             break;
         }
     }
     if (version_compare(JVERSION, '3.0', 'lt') && $result instanceof Exception) {
         JError::raiseError($result->getCode(), $result->getMessage());
     }
     return $result;
 }
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:34,代码来源:view.php

示例9: findFormFilename

 /**
  * Guesses the best candidate for the path to use for a particular form.
  *
  * @param   string  $source  The name of the form file to load, without the .xml extension.
  * @param   array   $paths   The paths to look into. You can declare this to override the default FOF paths.
  *
  * @return  mixed  A string if the path and filename of the form to load is found, false otherwise.
  *
  * @since   2.0
  */
 public function findFormFilename($source, $paths = array())
 {
     $option = $this->input->getCmd('option', 'com_foobar');
     $view = $this->input->getCmd('view', 'cpanels');
     $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($option);
     $file_root = $componentPaths['main'];
     $alt_file_root = $componentPaths['alt'];
     $template_root = FOFPlatform::getInstance()->getTemplateOverridePath($option);
     if (empty($paths)) {
         // Set up the paths to look into
         $paths = array($template_root . '/' . $view, $template_root . '/' . FOFInflector::singularize($view), $template_root . '/' . FOFInflector::pluralize($view), $file_root . '/views/' . $view . '/tmpl', $file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $alt_file_root . '/views/' . $view . '/tmpl', $alt_file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $alt_file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $file_root . '/models/forms', $alt_file_root . '/models/forms');
     }
     // Set up the suffixes to look into
     $suffixes = array();
     $temp_suffixes = FOFPlatform::getInstance()->getTemplateSuffixes();
     if (!empty($temp_suffixes)) {
         foreach ($temp_suffixes as $suffix) {
             $suffixes[] = $suffix . '.xml';
         }
     }
     $suffixes[] = '.xml';
     // Look for all suffixes in all paths
     JLoader::import('joomla.filesystem.file');
     $result = false;
     foreach ($paths as $path) {
         foreach ($suffixes as $suffix) {
             $filename = $path . '/' . $source . $suffix;
             if (JFile::exists($filename)) {
                 $result = $filename;
                 break;
             }
         }
         if ($result) {
             break;
         }
     }
     return $result;
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:48,代码来源:model.php

示例10: onBeforeUnpublish

 /**
  * ACL check before changing the publish status of a record; override to customise
  *
  * @return  boolean  True to allow the method to run
  */
 protected function onBeforeUnpublish()
 {
     $privilege = $this->configProvider->get($this->component . '.views.' . FOFInflector::singularize($this->view) . '.acl.unpublish', 'core.edit.state');
     return $this->checkACL($privilege);
 }
开发者ID:alvarovladimir,项目名称:messermeister_ab_rackservers,代码行数:10,代码来源:controller.php

示例11: getContentType

 /**
  * Get the content type for ucm
  *
  * @return string The content type alias
  */
 public function getContentType()
 {
     $component = $this->input->get('option');
     $view = FOFInflector::singularize($this->input->get('view'));
     $alias = $component . '.' . $view;
     return $alias;
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:12,代码来源:table.php

示例12: findFormFilename

 /**
  * Guesses the best candidate for the path to use for a particular form.
  *
  * @param   string  $source  The name of the form file to load, without the .xml extension
  *
  * @return  string  The path and filename of the form to load
  *
  * @since   2.0
  */
 public function findFormFilename($source)
 {
     // Get some useful variables
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     $option = $this->input->getCmd('option', 'com_foobar');
     $view = $this->input->getCmd('view', 'cpanels');
     if (!$isCli) {
         $template = JFactory::getApplication()->getTemplate();
     } else {
         $template = 'cli';
     }
     $file_root = $isAdmin ? JPATH_ADMINISTRATOR : JPATH_SITE;
     $file_root .= '/components/' . $option;
     $alt_file_root = $isAdmin ? JPATH_SITE : JPATH_ADMINISTRATOR;
     $alt_file_root .= '/components/' . $option;
     $template_root = $isAdmin ? JPATH_ADMINISTRATOR : JPATH_SITE;
     $template_root .= '/templates/' . $template . '/html/' . $option;
     // Set up the paths to look into
     $paths = array($template_root . '/' . $view, $template_root . '/' . FOFInflector::singularize($view), $template_root . '/' . FOFInflector::pluralize($view), $file_root . '/views/' . $view . '/tmpl', $file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $alt_file_root . '/views/' . $view . '/tmpl', $alt_file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $alt_file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $file_root . '/models/forms', $alt_file_root . '/models/forms');
     // Set up the suffixes to look into
     $jversion = new JVersion();
     $versionParts = explode('.', $jversion->RELEASE);
     $majorVersion = array_shift($versionParts);
     $suffixes = array('.j' . str_replace('.', '', $jversion->getHelpVersion()) . '.xml', '.j' . $majorVersion . '.xml', '.xml');
     unset($jversion, $versionParts, $majorVersion);
     // Look for all suffixes in all paths
     JLoader::import('joomla.filesystem.file');
     $result = false;
     foreach ($paths as $path) {
         foreach ($suffixes as $suffix) {
             $filename = $path . '/' . $source . $suffix;
             if (JFile::exists($filename)) {
                 $result = $filename;
                 break;
             }
         }
         if ($result) {
             break;
         }
     }
     return $result;
 }
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:51,代码来源:model.php

示例13: array

 /**
  * Returns a static object instance of a particular table type
  *
  * @param   string  $type    The table name
  * @param   string  $prefix  The prefix of the table class
  * @param   array   $config  Optional configuration variables
  *
  * @return FOFTable
  */
 public static function &getAnInstance($type = null, $prefix = 'JTable', $config = array())
 {
     static $instances = array();
     // Make sure $config is an array
     if (is_object($config)) {
         $config = (array) $config;
     } elseif (!is_array($config)) {
         $config = array();
     }
     // Guess the component name
     if (!array_key_exists('input', $config)) {
         $config['input'] = new FOFInput();
     }
     if ($config['input'] instanceof FOFInput) {
         $tmpInput = $config['input'];
     } else {
         $tmpInput = new FOFInput($config['input']);
     }
     $option = $tmpInput->getCmd('option', '');
     $tmpInput->set('option', $option);
     $config['input'] = $tmpInput;
     if (!in_array($prefix, array('Table', 'JTable'))) {
         preg_match('/(.*)Table$/', $prefix, $m);
         $option = 'com_' . strtolower($m[1]);
     }
     if (array_key_exists('option', $config)) {
         $option = $config['option'];
     }
     $config['option'] = $option;
     if (!array_key_exists('view', $config)) {
         $config['view'] = $config['input']->getCmd('view', 'cpanel');
     }
     if (is_null($type)) {
         if ($prefix == 'JTable') {
             $prefix = 'Table';
         }
         $type = $config['view'];
     }
     $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
     $tableClass = $prefix . ucfirst($type);
     $configProvider = new FOFConfigProvider();
     $configProviderKey = $option . '.views.' . FOFInflector::singularize($type) . '.config.';
     if (!array_key_exists($tableClass, $instances)) {
         if (!class_exists($tableClass)) {
             list($isCLI, $isAdmin) = FOFDispatcher::isCliAdmin();
             if (!$isAdmin) {
                 $basePath = JPATH_SITE;
             } else {
                 $basePath = JPATH_ADMINISTRATOR;
             }
             $searchPaths = array($basePath . '/components/' . $config['option'] . '/tables', JPATH_ADMINISTRATOR . '/components/' . $config['option'] . '/tables');
             if (array_key_exists('tablepath', $config)) {
                 array_unshift($searchPaths, $config['tablepath']);
             }
             $altPath = $configProvider->get($configProviderKey . 'table_path', null);
             if ($altPath) {
                 array_unshift($searchPaths, JPATH_ADMINISTRATOR . '/components/' . $option . '/' . $altPath);
             }
             JLoader::import('joomla.filesystem.path');
             $path = JPath::find($searchPaths, strtolower($type) . '.php');
             if ($path) {
                 require_once $path;
             }
         }
         if (!class_exists($tableClass)) {
             $tableClass = 'FOFTable';
         }
         $tbl_common = str_replace('com_', '', $config['option']) . '_';
         if (!array_key_exists('tbl', $config)) {
             $config['tbl'] = strtolower('#__' . $tbl_common . strtolower(FOFInflector::pluralize($type)));
         }
         $altTbl = $configProvider->get($configProviderKey . 'tbl', null);
         if ($altTbl) {
             $config['tbl'] = $altTbl;
         }
         if (!array_key_exists('tbl_key', $config)) {
             $keyName = FOFInflector::singularize($type);
             $config['tbl_key'] = strtolower($tbl_common . $keyName . '_id');
         }
         $altTblKey = $configProvider->get($configProviderKey . 'tbl_key', null);
         if ($altTblKey) {
             $config['tbl_key'] = $altTblKey;
         }
         if (!array_key_exists('db', $config)) {
             $config['db'] = JFactory::getDBO();
         }
         $instance = new $tableClass($config['tbl'], $config['tbl_key'], $config['db']);
         $instance->setInput($tmpInput);
         if (array_key_exists('trigger_events', $config)) {
             $instance->setTriggerEvents($config['trigger_events']);
         }
//.........这里部分代码省略.........
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:101,代码来源:table.php

示例14: 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

示例15: __construct

 /**
  * Public constructor. Instantiates a FOFView object.
  *
  * @param   array  $config  The configuration data array
  */
 public function __construct($config = array())
 {
     // Make sure $config is an array
     if (is_object($config)) {
         $config = (array) $config;
     } elseif (!is_array($config)) {
         $config = array();
     }
     // Get the input
     if (array_key_exists('input', $config)) {
         if ($config['input'] instanceof FOFInput) {
             $this->input = $config['input'];
         } else {
             $this->input = new FOFInput($config['input']);
         }
     } else {
         $this->input = new FOFInput();
     }
     parent::__construct($config);
     $component = 'com_foobar';
     // Get the component name
     if (array_key_exists('input', $config)) {
         if ($config['input'] instanceof FOFInput) {
             $tmpInput = $config['input'];
         } else {
             $tmpInput = new FOFInput($config['input']);
         }
         $component = $tmpInput->getCmd('option', '');
     } else {
         $tmpInput = $this->input;
     }
     if (array_key_exists('option', $config)) {
         if ($config['option']) {
             $component = $config['option'];
         }
     }
     $config['option'] = $component;
     // Get the view name
     $view = null;
     if (array_key_exists('input', $config)) {
         $view = $tmpInput->getCmd('view', '');
     }
     if (array_key_exists('view', $config)) {
         if ($config['view']) {
             $view = $config['view'];
         }
     }
     $config['view'] = $view;
     // Set the component and the view to the input array
     if (array_key_exists('input', $config)) {
         $tmpInput->set('option', $config['option']);
         $tmpInput->set('view', $config['view']);
     }
     // Set the view name
     if (array_key_exists('name', $config)) {
         $this->_name = $config['name'];
     } else {
         $this->_name = $config['view'];
     }
     $tmpInput->set('view', $this->_name);
     $config['input'] = $tmpInput;
     $config['name'] = $this->_name;
     $config['view'] = $this->_name;
     // Get the component directories
     $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']);
     // Set the charset (used by the variable escaping functions)
     if (array_key_exists('charset', $config)) {
         FOFPlatform::getInstance()->logDeprecated('Setting a custom charset for escaping in FOFView\'s constructor is deprecated. Override FOFView::escape() instead.');
         $this->_charset = $config['charset'];
     }
     // User-defined escaping callback
     if (array_key_exists('escape', $config)) {
         $this->setEscape($config['escape']);
     }
     // Set a base path for use by the view
     if (array_key_exists('base_path', $config)) {
         $this->_basePath = $config['base_path'];
     } else {
         $this->_basePath = $componentPaths['main'];
     }
     // Set the default template search path
     if (array_key_exists('template_path', $config)) {
         // User-defined dirs
         $this->_setPath('template', $config['template_path']);
     } else {
         $altView = FOFInflector::isSingular($this->getName()) ? FOFInflector::pluralize($this->getName()) : FOFInflector::singularize($this->getName());
         $this->_setPath('template', $this->_basePath . '/views/' . $altView . '/tmpl');
         $this->_addPath('template', $this->_basePath . '/views/' . $this->getName() . '/tmpl');
     }
     // Set the default helper search path
     if (array_key_exists('helper_path', $config)) {
         // User-defined dirs
         $this->_setPath('helper', $config['helper_path']);
     } else {
         $this->_setPath('helper', $this->_basePath . '/helpers');
//.........这里部分代码省略.........
开发者ID:naka211,项目名称:studiekorrektur,代码行数:101,代码来源:view.php


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