本文整理汇总了PHP中F0FInflector::isPlural方法的典型用法代码示例。如果您正苦于以下问题:PHP F0FInflector::isPlural方法的具体用法?PHP F0FInflector::isPlural怎么用?PHP F0FInflector::isPlural使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类F0FInflector
的用法示例。
在下文中一共展示了F0FInflector::isPlural方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: accessAllowed
/**
* Checks if the user should be granted access to the current view,
* based on his Master Password setting.
*
* @param string view Optional. The string to check. Leave null to use the current view.
*
* @return bool
*/
public function accessAllowed($view = null)
{
if (interface_exists('JModel')) {
$params = JModelLegacy::getInstance('Storage', 'AdmintoolsModel');
} else {
$params = JModel::getInstance('Storage', 'AdmintoolsModel');
}
if (empty($view)) {
$view = $this->input->get('view', 'cpanel');
}
$altView = F0FInflector::isPlural($view) ? F0FInflector::singularize($view) : F0FInflector::pluralize($view);
if (!in_array($view, $this->views) && !in_array($altView, $this->views)) {
return true;
}
$masterHash = $params->getValue('masterpassword', '');
if (!empty($masterHash)) {
$masterHash = md5($masterHash);
// Compare the master pw with the one the user entered
$session = JFactory::getSession();
$userHash = $session->get('userpwhash', '', 'admintools');
if ($userHash != $masterHash) {
// The login is invalid. If the view is locked I'll have to kick the user out.
$lockedviews_raw = $params->getValue('lockedviews', '');
if (!empty($lockedviews_raw)) {
$lockedViews = explode(",", $lockedviews_raw);
if (in_array($view, $lockedViews) || in_array($altView, $lockedViews)) {
return false;
}
}
}
}
return true;
}
示例2: addSubmenuLink
private function addSubmenuLink($view, $parent = null, $icon = null)
{
static $activeView = null;
if (empty($activeView)) {
$activeView = $this->input->getCmd('view', 'cpanel');
}
if ($activeView == 'cpanels') {
$activeView = 'cpanel';
}
$key = strtoupper($this->component) . '_TITLE_' . strtoupper($view);
if (strtoupper(JText::_($key)) == $key) {
$altview = F0FInflector::isPlural($view) ? F0FInflector::singularize($view) : F0FInflector::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, $icon, $parent);
}
示例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 F0FView
*/
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 F0FInput) {
$tmpInput = $config['input'];
} else {
$tmpInput = new F0FInput($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 = F0FPlatform::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 = F0FInflector::isPlural($viewName) ? F0FInflector::singularize($viewName) : F0FInflector::pluralize($viewName);
$suffixes = array($viewName, $altViewName, 'default');
$filesystem = F0FPlatform::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 = 'F0FView' . ucfirst($type);
}
$templateOverridePath = F0FPlatform::getInstance()->getTemplateOverridePath($config['option']);
// Setup View configuration options
if (!array_key_exists('template_path', $config)) {
$config['template_path'][] = $componentPaths['main'] . '/views/' . F0FInflector::pluralize($config['view']) . '/tmpl';
if ($templateOverridePath) {
$config['template_path'][] = $templateOverridePath . '/' . F0FInflector::pluralize($config['view']);
}
$config['template_path'][] = $componentPaths['main'] . '/views/' . F0FInflector::singularize($config['view']) . '/tmpl';
//.........这里部分代码省略.........
示例4: 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);
//Do we have a translation for this key?
if (strtoupper(JText::_($key)) == $key) {
$altview = F0FInflector::isPlural($view) ? F0FInflector::singularize($view) : F0FInflector::pluralize($view);
$key2 = strtoupper($this->component) . '_TITLE_' . strtoupper($altview);
// Maybe we have for the alternative view?
if (strtoupper(JText::_($key2)) == $key2) {
// Nope, let's use the raw name
$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);
}
}
示例5: 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 = F0FInflector::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' && F0FPlatform::getInstance()->isFrontend()) {
$task = 'read';
}
break;
}
return $task;
}
示例6: addSubmenuLink
/**
* addSubmenuLink
*
* @param object $view Param
* @param object $parent Param
*
* @return void
*/
private function addSubmenuLink($view, $parent = null)
{
static $activeView = null;
if (empty($activeView)) {
$activeView = $this->input->getCmd('view', 'cpanel');
}
if ($activeView == 'cpanels') {
$activeView = 'cpanel';
}
$icon_key = strtoupper($this->component) . '_ICON_' . strtoupper($view);
$icon = JText::_($icon_key);
$key = strtoupper($this->component) . '_TITLE_' . strtoupper($view);
if (strtoupper(JText::_($key)) == $key) {
$altview = F0FInflector::isPlural($view) ? F0FInflector::singularize($view) : F0FInflector::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);
}
if ($view == 'usermanual') {
$link = 'http://documentation.extly.com/';
} elseif ($view == 'options') {
$component = urlencode($this->component);
$uri = (string) JUri::getInstance();
$return = urlencode(base64_encode($uri));
$link = 'index.php?option=com_config&view=component&component=' . $component . '&path=&return=' . $return;
} else {
$link = 'index.php?option=' . $this->component . '&view=' . $view;
}
$active = $view == $activeView;
$this->appendLink($icon . ' ' . $name, $link, $active, null, $parent);
}