本文整理汇总了PHP中KunenaController::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaController::getInstance方法的具体用法?PHP KunenaController::getInstance怎么用?PHP KunenaController::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaController
的用法示例。
在下文中一共展示了KunenaController::getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display($cachable = false, $urlparams = false) {
$menu = $this->app->getMenu ();
$home = $menu->getActive ();
if (!$home) {
JRequest::setVar ( 'view', 'category' );
JRequest::setVar ( 'layout', 'list' );
//JError::raiseError ( 500, JText::_ ( 'COM_KUNENA_NO_ACCESS' ) );
} else {
// Find default menu item
$default = $this->_getDefaultMenuItem($menu, $home);
if (!$default || $default->id == $home->id) {
// There is no default menu item, use category view instead
$default = $menu->getItem ( KunenaRoute::getItemID("index.php?option=com_kunena&view=category&layout=list") );
if ($default) {
$default = clone $default;
$defhome = KunenaRoute::getHome($default);
if (!$defhome || $defhome->id != $home->id) $default = clone $home;
$default->query['view'] = 'category';
$default->query['layout'] = 'list';
}
}
if (!$default) {
JError::raiseError ( 500, JText::_ ( 'COM_KUNENA_NO_ACCESS' ) );
}
// Add query variables from shown menu item
foreach ( $default->query as $var => $value ) {
JRequest::setVar ( $var, $value );
}
// Remove query variables coming from the home menu item
JRequest::setVar ( 'defaultmenu', null );
// Set active menu item to point the real page
$menu->setActive ( $default->id );
}
// Reset our router
KunenaRoute::initialize();
// Run display task from our new controller
$controller = KunenaController::getInstance();
$controller->execute ('display');
// Set redirect and message
$this->setRedirect ($controller->getRedirect(), $controller->getMessage(), $controller->getMessageType());
}
示例2: KunenaControllerInstall
// Safety check to prevent fatal error if 'System - Kunena Forum' plug-in has been disabled.
if ($app->input->getCmd('view') == 'install' || !class_exists('KunenaForum') || !KunenaForum::isCompatible('4.0')) {
// Run installer instead..
require_once __DIR__ . '/install/controller.php';
$controller = new KunenaControllerInstall();
// TODO: execute special task that checks what's wrong
$controller->execute($app->input->getCmd('task'));
$controller->redirect();
return;
}
if ($app->input->getCmd('view') == 'uninstall') {
$allowed = $app->getUserState('com_kunena.uninstall.allowed');
if ($allowed) {
require_once __DIR__ . '/install/controller.php';
$controller = new KunenaControllerInstall();
$controller->execute('uninstall');
$controller->redirect();
$app->setUserState('com_kunena.uninstall.allowed', null);
return;
}
}
// Initialize Kunena Framework.
KunenaForum::setup();
// Initialize custom error handlers.
KunenaError::initialize();
// Kunena has been successfully installed: Load our main controller.
$controller = KunenaController::getInstance();
$controller->execute($app->input->getCmd('task'));
$controller->redirect();
// Remove custom error handlers.
KunenaError::cleanup();
示例3: display
public function display() {
global $Itemid;
$menu = JFactory::getApplication ()->getMenu ();
$home = $menu->getActive ();
// TODO: maybe add error
if (!$home) return;
// Find default menu item
$default = $this->_getDefaultMenuItem($menu, $home);
if (!$default) {
// There is no default menu item, use category view instead
$default = clone $menu->getItem ( KunenaRoute::getItemID("index.php?option=com_kunena&view=category&layout=index") );
$default->query['view'] = 'category';
$default->query['layout'] = 'index';
}
if (!$default) {
JError::raiseError ( 500, JText::_ ( 'COM_KUNENA_NO_ACCESS' ) );
}
// Check if menu item was correctly routed
$active = $menu->getItem ( KunenaRoute::getItemID() );
if (!$active || ($active->id != $home->id && $active->id != $default->id)) {
// Routing has been changed, redirect or fail
if ($active) {
JRequest::setVar ( 'defaultmenu', null );
// FIXME: chack possible redirect loops!
$this->setRedirect (KunenaRoute::_(null, false));
}
return;
}
// Check if we are using default menu item
if (!isset($default->query['layout'])) $default->query['layout'] = 'default';
foreach ( $default->query as $var => $value ) {
$cmp = JRequest::getVar($var, null);
if ($var == 'defaultmenu') continue;
if ($var == 'view' && $cmp == 'home') continue;
if ($cmp !== null && $value != $cmp) {
$default = $home;
break;
}
}
// Add query variables from shown menu item
if ($default != $home) {
foreach ( $default->query as $var => $value ) {
JRequest::setVar ( $var, $value );
}
}
// Set active menu item to point the real page
$menu->setActive ( $default->id );
// Joomla 1.5 hack:
$Itemid = $default->id;
KunenaRoute::initialize();
if (JRequest::getVar ( 'view' ) != 'home') {
// Run display task from our new controller
$controller = KunenaController::getInstance(true);
$controller->execute ('display');
// Set redirect and message
$this->setRedirect ($controller->getRedirect(), $controller->getMessage(), $controller->getMessageType());
}
}