本文整理汇总了PHP中FOFInput::getCmd方法的典型用法代码示例。如果您正苦于以下问题:PHP FOFInput::getCmd方法的具体用法?PHP FOFInput::getCmd怎么用?PHP FOFInput::getCmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FOFInput
的用法示例。
在下文中一共展示了FOFInput::getCmd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setToolbarTitle
private function setToolbarTitle()
{
$subtitle_key = FOFInput::getCmd('option', 'com_overload', $this->input).
'_TITLE_'.strtoupper(FOFInput::getCmd('view', '', $this->input));
JToolBarHelper::title(
JText::_( FOFInput::getCmd('option', 'com_overload', $this->input)).
' – <small>'.JText::_($subtitle_key).'</small>',
'generic.png');
}
示例2: array
/**
*
* @staticvar array $instances
* @param type $option
* @param type $view
* @param type $config
* @return FOFToolbar
*/
public static function &getAnInstance($option = null, $config = array())
{
static $instances = array();
// Make sure $config is an array
if (is_object($config)) {
$config = (array) $config;
} elseif (!is_array($config)) {
$config = array();
}
$hash = $option;
if (!array_key_exists($hash, $instances)) {
if (array_key_exists('input', $config)) {
if ($config['input'] instanceof FOFInput) {
$input = $config['input'];
} else {
$input = new FOFInput($config['input']);
}
} else {
$input = new FOFInput();
}
$config['option'] = !is_null($option) ? $option : $input->getCmd('option', 'com_foobar');
$input->set('option', $config['option']);
$config['input'] = $input;
$className = ucfirst(str_replace('com_', '', $config['option'])) . 'Toolbar';
if (!class_exists($className)) {
list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
if ($isAdmin) {
$basePath = JPATH_ADMINISTRATOR;
} elseif ($isCli) {
$basePath = JPATH_ROOT;
} else {
$basePath = JPATH_SITE;
}
$searchPaths = array($basePath . '/components/' . $config['option'], $basePath . '/components/' . $config['option'] . '/toolbars', JPATH_ADMINISTRATOR . '/components/' . $config['option'], JPATH_ADMINISTRATOR . '/components/' . $config['option'] . '/toolbars');
if (array_key_exists('searchpath', $config)) {
array_unshift($searchPaths, $config['searchpath']);
}
JLoader::import('joomla.filesystem.path');
$path = JPath::find($searchPaths, 'toolbar.php');
if ($path) {
require_once $path;
}
}
if (!class_exists($className)) {
$className = 'FOFToolbar';
}
$instance = new $className($config);
$instances[$hash] = $instance;
}
return $instances[$hash];
}
示例3: preRender
/**
* Echoes any HTML to show before the view template
*
* @param string $view The current view
* @param string $task The current task
* @param FOFInput $input The input array (request parameters)
* @param array $config The view configuration array
*
* @return void
*/
public function preRender($view, $task, $input, $config = array())
{
$format = $input->getCmd('format', 'html');
if (empty($format)) {
$format = 'html';
}
if ($format != 'html') {
return;
}
// Render the submenu and toolbar
if ($input->getBool('render_toolbar', true)) {
$this->renderButtons($view, $task, $input, $config);
$this->renderLinkbar($view, $task, $input, $config);
}
}
示例4: postRender
/**
* Echoes any HTML to show after the view template
*
* @param string $view The current view
* @param string $task The current task
* @param FOFInput $input The input array (request parameters)
* @param array $config The view configuration array
*
* @return void
*/
public function postRender($view, $task, $input, $config = array())
{
$format = $input->getCmd('format', 'html');
if (empty($format)) {
$format = 'html';
}
if ($format != 'html') {
return;
}
// Closing tag only if we're not in CLI
if (FOFPlatform::getInstance()->isCli()) {
return;
}
echo "</div>\n";
// Closes akeeba-renderjoomla div
}
示例5: array
/**
* Gets an instance of a component's toolbar
*
* @param string $option The name of the component
* @param array $config The configuration array for the component
*
* @return FOFToolbar The toolbar instance for the component
*/
public static function &getAnInstance($option = null, $config = array())
{
static $instances = array();
// Make sure $config is an array
if (is_object($config)) {
$config = (array) $config;
} elseif (!is_array($config)) {
$config = array();
}
$hash = $option;
if (!array_key_exists($hash, $instances)) {
if (array_key_exists('input', $config)) {
if ($config['input'] instanceof FOFInput) {
$input = $config['input'];
} else {
$input = new FOFInput($config['input']);
}
} else {
$input = new FOFInput();
}
$config['option'] = !is_null($option) ? $option : $input->getCmd('option', 'com_foobar');
$input->set('option', $config['option']);
$config['input'] = $input;
$className = ucfirst(str_replace('com_', '', $config['option'])) . 'Toolbar';
if (!class_exists($className)) {
$componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']);
$searchPaths = array($componentPaths['main'], $componentPaths['main'] . '/toolbars', $componentPaths['alt'], $componentPaths['alt'] . '/toolbars');
if (array_key_exists('searchpath', $config)) {
array_unshift($searchPaths, $config['searchpath']);
}
JLoader::import('joomla.filesystem.path');
$path = JPath::find($searchPaths, 'toolbar.php');
if ($path) {
require_once $path;
}
}
if (!class_exists($className)) {
$className = 'FOFToolbar';
}
$instance = new $className($config);
$instances[$hash] = $instance;
}
return $instances[$hash];
}
示例6: 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())
{
// TODO Should we read from internal variables instead of the input? With a temp instance we have no input
$option = $this->input->getCmd('option', 'com_foobar');
$view = $this->name;
$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
// PLEASE NOTE: If you ever change this, please update Model Unit tests, too, since we have to
// copy these default folders (we have to add the protocol for the virtual filesystem)
$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');
}
$paths = array_unique($paths);
// 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
$result = false;
$filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
foreach ($paths as $path) {
foreach ($suffixes as $suffix) {
$filename = $path . '/' . $source . $suffix;
if ($filesystem->fileExists($filename)) {
$result = $filename;
break;
}
}
if ($result) {
break;
}
}
return $result;
}
示例7: getItemidURLSuffix
/**
* Gets a URL suffix with the Itemid parameter. If it's not the front-end of the site, or if
* there is no Itemid set it returns an empty string.
*
* @return string The &Itemid=123 URL suffix, or an empty string if Itemid is not applicable
*/
public function getItemidURLSuffix()
{
if (FOFPlatform::getInstance()->isFrontend() && $this->input->getCmd('Itemid', 0) != 0) {
return '&Itemid=' . $this->input->getInt('Itemid', 0);
} else {
return '';
}
}
示例8: array
/**
* Gets a temporary instance of a controller object. A temporary instance is
* not a Singleton and can be disposed off after use.
*
* @param string $option The component name, e.g. com_foobar
* @param string $view The view name, e.g. cpanel
* @param array $config Configuration parameters
*
* @return \className A disposable class instance
*/
public static function &getTmpInstance($option = null, $view = null, $config = array())
{
// Make sure $config is an array
if (is_object($config)) {
$config = (array) $config;
} elseif (!is_array($config)) {
$config = array();
}
// Get an input object
if (array_key_exists('input', $config)) {
$input = $config['input'];
} else {
$input = null;
}
if (array_key_exists('input_options', $config)) {
$input_options = $config['input_options'];
} else {
$input_options = array();
}
if (!$input instanceof FOFInput) {
$input = new FOFInput($input, $input_options);
}
// Determine the option (component name) and view
$config['option'] = !is_null($option) ? $option : $input->getCmd('option', 'com_foobar');
$config['view'] = !is_null($view) ? $view : $input->getCmd('view', 'cpanel');
// Get the class base name, e.g. FoobarController
$classBaseName = ucfirst(str_replace('com_', '', $config['option'])) . 'Controller';
// Get the class name suffixes, in the order to be searched for: plural, singular, 'default'
$classSuffixes = array(FOFInflector::pluralize($config['view']), FOFInflector::singularize($config['view']), 'default');
// Initialise the base path for performance reasons
list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
if ($isAdmin) {
$basePath = JPATH_ADMINISTRATOR;
} elseif ($isCli) {
$basePath = JPATH_ROOT;
} else {
$basePath = JPATH_SITE;
}
JLoader::import('joomla.filesystem.path');
// Look for the best classname match
foreach ($classSuffixes as $suffix) {
$className = $classBaseName . ucfirst($suffix);
if (class_exists($className)) {
// The class is already loaded. We have a match!
break;
}
// The class is not already loaded. Try to find and load it.
$searchPaths = array($basePath . '/components/' . $config['option'] . '/controllers', JPATH_ADMINISTRATOR . '/components/' . $config['option'] . '/controllers');
// If we have a searchpath in the configuration please search it first
if (array_key_exists('searchpath', $config)) {
array_unshift($searchPaths, $config['searchpath']);
} else {
$configProvider = new FOFConfigProvider();
$searchPath = $configProvider->get($config['option'] . '.views.' . FOFInflector::singularize($config['view']) . '.config.searchpath', null);
if ($searchPath) {
array_unshift($searchPaths, JPATH_ADMINISTRATOR . '/components/' . $config['option'] . '/' . $searchPath);
array_unshift($searchPaths, $basePath . '/components/' . $config['option'] . '/' . $searchPath);
}
}
// Try to find the path to this file. First try to find the
// format-specific controller file, e.g. foobar.json.php for
// format=json, then the regular one-size-fits-all controller
$format = $input->getCmd('format', 'html');
$path = null;
if (!empty($format)) {
$path = JPath::find($searchPaths, strtolower($suffix) . '.' . strtolower($format) . '.php');
}
if (!$path) {
$path = JPath::find($searchPaths, strtolower($suffix) . '.php');
}
// The path is found. Load the file and make sure the expected class name exists.
if ($path) {
require_once $path;
if (class_exists($className)) {
// The class was loaded successfully. We have a match!
break;
}
}
}
if (!class_exists($className)) {
// If no specialised class is found, instantiate the generic FOFController
$className = 'FOFController';
}
$instance = new $className($config);
return $instance;
}
示例9: renderFormEdit
/**
* Renders a FOFForm for an Edit view and returns the corresponding HTML
*
* @param FOFForm &$form The form to render
* @param FOFModel $model The model providing our data
* @param FOFInput $input The input object
*
* @return string The HTML rendering of the form
*/
protected function renderFormEdit(FOFForm &$form, FOFModel $model, FOFInput $input)
{
// Get the key for this model's table
$key = $model->getTable()->getKeyName();
$keyValue = $model->getId();
$html = '';
$validate = strtolower($form->getAttribute('validate'));
if (in_array($validate, array('true', 'yes', '1', 'on'))) {
JHTML::_('behavior.framework', true);
JHTML::_('behavior.formvalidation');
$class = ' form-validate';
$this->loadValidationScript($form);
} else {
$class = '';
}
// Check form enctype. Use enctype="multipart/form-data" to upload binary files in your form.
$template_form_enctype = $form->getAttribute('enctype');
if (!empty($template_form_enctype)) {
$enctype = ' enctype="' . $form->getAttribute('enctype') . '" ';
} else {
$enctype = '';
}
// Check form name. Use name="yourformname" to modify the name of your form.
$formname = $form->getAttribute('name');
if (empty($formname)) {
$formname = 'adminForm';
}
// Check form ID. Use id="yourformname" to modify the id of your form.
$formid = $form->getAttribute('name');
if (empty($formid)) {
$formid = 'adminForm';
}
$html .= '<form action="index.php" method="post" name="' . $formname . '" id="' . $formid . '"' . $enctype . ' class="form-horizontal' . $class . '">' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="option" value="' . $input->getCmd('option') . '" />' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="view" value="' . $input->getCmd('view', 'edit') . '" />' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="task" value="" />' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="' . $key . '" value="' . $keyValue . '" />' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="' . JFactory::getSession()->getFormToken() . '" value="1" />' . PHP_EOL;
$html .= $this->renderFormRaw($form, $model, $input, 'edit');
$html .= '</form>';
return $html;
}
示例10: renderButtons
/**
* Renders the toolbar buttons
*
* @param string $view The active view name
* @param string $task The current task
* @param FOFInput $input The input object
* @param array $config Extra configuration variables for the toolbar
*
* @return void
*/
protected function renderButtons($view, $task, $input, $config = array())
{
// On command line don't do anything
if (FOFPlatform::getInstance()->isCli()) {
return;
}
// Do not render buttons unless we are in the the frontend area and we are asked to do so
$toolbar = FOFToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config);
$renderFrontendButtons = $toolbar->getRenderFrontendButtons();
if (FOFPlatform::getInstance()->isBackend() || !$renderFrontendButtons) {
return;
}
// Load main backend language, in order to display toolbar strings
// (JTOOLBAR_BACK, JTOOLBAR_PUBLISH etc etc)
FOFPlatform::getInstance()->loadTranslations('joomla');
$title = JFactory::getApplication()->get('JComponentTitle');
$bar = JToolBar::getInstance('toolbar');
// Delete faux links, since if SEF is on, Joomla will follow the link instead of submitting the form
$bar_content = str_replace('href="#"', '', $bar->render());
echo '<div id="FOFHeaderHolder">', $bar_content, $title, '<div style="clear:both"></div>', '</div>';
}
示例11: canDelete
/**
* Generic check for whether dependencies exist for this object in the db schema
*
* @param integer $oid The primary key of the record to delete
* @param array $joins Any joins to foreign table, used to determine if dependent records exist
*
* @return boolean True if the record can be deleted
*/
public function canDelete($oid = null, $joins = null)
{
$k = $this->_tbl_key;
if ($oid) {
$this->{$k} = intval($oid);
}
if (is_array($joins)) {
$db = $this->_db;
$query = $db->getQuery(true)->select($db->qn('master') . '.' . $db->qn($k))->from($db->qn($this->_tbl) . ' AS ' . $db->qn('master'));
$tableNo = 0;
foreach ($joins as $table) {
$tableNo++;
$query->select(array('COUNT(DISTINCT ' . $db->qn('t' . $tableNo) . '.' . $db->qn($table['idfield']) . ') AS ' . $db->qn($table['idalias'])));
$query->join('LEFT', $db->qn($table['name']) . ' AS ' . $db->qn('t' . $tableNo) . ' ON ' . $db->qn('t' . $tableNo) . '.' . $db->qn($table['joinfield']) . ' = ' . $db->qn('master') . '.' . $db->qn($k));
}
$query->where($db->qn('master') . '.' . $db->qn($k) . ' = ' . $db->q($this->{$k}));
$query->group($db->qn('master') . '.' . $db->qn($k));
$this->_db->setQuery((string) $query);
if (version_compare(JVERSION, '3.0', 'ge')) {
try {
$obj = $this->_db->loadObject();
} catch (JDatabaseException $e) {
$this->setError($e->getMessage());
}
} else {
if (!($obj = $this->_db->loadObject())) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
$msg = array();
$i = 0;
foreach ($joins as $table) {
$k = $table['idalias'];
if ($obj->{$k} > 0) {
$msg[] = JText::_($table['label']);
}
$i++;
}
if (count($msg)) {
$option = $this->input->getCmd('option', 'com_foobar');
$comName = str_replace('com_', '', $option);
$tview = str_replace('#__' . $comName . '_', '', $this->_tbl);
$prefix = $option . '_' . $tview . '_NODELETE_';
foreach ($msg as $key) {
$this->setError(JText::_($prefix . $key));
}
return false;
} else {
return true;
}
}
return true;
}
示例12: getThisView
/**
* Returns current view object
*
* @param array $config Configuration variables for the model
*
* @return FOFView The global instance of the view object (singleton)
*/
public final function getThisView($config = array())
{
if (!is_object($this->_viewObject)) {
// Make sure $config is an array
if (is_object($config)) {
$config = (array) $config;
} elseif (!is_array($config)) {
$config = array();
}
$prefix = null;
$viewName = null;
$viewType = null;
if (!empty($this->viewName)) {
$parts = FOFInflector::explode($this->viewName);
$viewName = ucfirst(array_pop($parts));
$prefix = FOFInflector::implode($parts);
} else {
$prefix = ucfirst($this->bareComponent) . 'View';
$viewName = ucfirst($this->view);
}
$document = FOFPlatform::getInstance()->getDocument();
if ($document instanceof JDocument) {
$viewType = $document->getType();
} else {
$viewType = $this->input->getCmd('format', 'html');
}
if ($viewType == 'html' && $this->hasForm) {
$viewType = 'form';
}
if (!array_key_exists('input', $config) || !$config['input'] instanceof FOFInput) {
$config['input'] = $this->input;
}
$config['input']->set('base_path', $this->basePath);
$this->_viewObject = $this->getView($viewName, $viewType, $prefix, $config);
}
return $this->_viewObject;
}
示例13: array
/**
* Gets a temporary instance of a Dispatcher
*
* @param string $option The component name
* @param string $view The View name
* @param array $config Configuration data
*
* @return FOFDispatcher
*/
public static function &getTmpInstance($option = null, $view = null, $config = array())
{
if (array_key_exists('input', $config)) {
if ($config['input'] instanceof FOFInput) {
$input = $config['input'];
} else {
if (!is_array($config['input'])) {
$config['input'] = (array) $config['input'];
}
$config['input'] = array_merge($_REQUEST, $config['input']);
$input = new FOFInput($config['input']);
}
} else {
$input = new FOFInput();
}
$config['option'] = !is_null($option) ? $option : $input->getCmd('option', 'com_foobar');
$config['view'] = !is_null($view) ? $view : $input->getCmd('view', '');
$input->set('option', $config['option']);
$input->set('view', $config['view']);
$config['input'] = $input;
$className = ucfirst(str_replace('com_', '', $config['option'])) . 'Dispatcher';
if (!class_exists($className)) {
$componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']);
$searchPaths = array($componentPaths['main'], $componentPaths['main'] . '/dispatchers', $componentPaths['admin'], $componentPaths['admin'] . '/dispatchers');
if (array_key_exists('searchpath', $config)) {
array_unshift($searchPaths, $config['searchpath']);
}
$filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
$path = $filesystem->pathFind($searchPaths, 'dispatcher.php');
if ($path) {
require_once $path;
}
}
if (!class_exists($className)) {
$className = 'FOFDispatcher';
}
$instance = new $className($config);
return $instance;
}
示例14: _setPath
/**
* Sets an entire array of search paths for templates or resources.
*
* @param string $type The type of path to set, typically 'template'.
* @param mixed $path The new search path, or an array of search paths. If null or false, resets to the current directory only.
*
* @return void
*
*/
protected function _setPath($type, $path)
{
list($isCli, ) = FOFDispatcher::isCliAdmin();
// Clear out the prior search dirs
$this->_path[$type] = array();
// Actually add the user-specified directories
$this->_addPath($type, $path);
// Always add the fallback directories as last resort
switch (strtolower($type)) {
case 'template':
// Set the alternative template search dir
if (!$isCli) {
$app = JFactory::getApplication();
$component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $this->input->getCmd('option'));
$fallback = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $this->getName();
$this->_addPath('template', $fallback);
}
break;
}
}
示例15: _setPath
/**
* Sets an entire array of search paths for templates or resources.
*
* @param string $type The type of path to set, typically 'template'.
* @param mixed $path The new search path, or an array of search paths. If null or false, resets to the current directory only.
*
* @return void
*/
protected function _setPath($type, $path)
{
// Clear out the prior search dirs
$this->_path[$type] = array();
// Actually add the user-specified directories
$this->_addPath($type, $path);
// Always add the fallback directories as last resort
switch (strtolower($type)) {
case 'template':
// Set the alternative template search dir
if (!FOFPlatform::getInstance()->isCli()) {
$fallback = FOFPlatform::getInstance()->getTemplateOverridePath($this->input->getCmd('option', '')) . '/' . $this->getName();
$this->_addPath('template', $fallback);
}
break;
}
}