コード例 #1
0
ファイル: home.php プロジェクト: kosmosby/medicine-prof
	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
0
ファイル: kunena.php プロジェクト: Ruud68/Kunena-Forum
// 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
0
ファイル: home.php プロジェクト: GoremanX/Kunena-2.0
	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());
		}
	}