--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+// Own namespace
+namespace CoreFramework\Tests\Controller;
+
+// Import framework stuff
+use CoreFramework\Controller\BaseController;
+
+/**
+ * The default controller with news for e.g. home or news page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class TestsConsoleDefaultNewsController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ /*
+ foreach (array('bootstrap', 'activation','shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ */
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public static final function createTestsConsoleDefaultNewsController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new TestsConsoleDefaultNewsController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // Add news filters to this controller
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter'));
+
+ // Return the prepared instance
+ return $controllerInstance;
+ }
+
+ /**
+ * Handles the given request and response
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the command instance from the resolver by sending a request instance to the resolver
+ $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+ // Add more filters by the command
+ $commandInstance->addExtraFilters($this, $requestInstance);
+
+ // Run the pre filters
+ $this->executePreFilters($requestInstance, $responseInstance);
+
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
+
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
+
+ // Run the pre filters
+ $this->executePostFilters($requestInstance, $responseInstance);
+
+ // Flush the response out
+ $responseInstance->flushBuffer();
+ }
+
+ /**
+ * Add a bootstrap filter
+ *
+ * @param $filterInstance A Filterable class
+ * @return void
+ */
+ public function addBootstrapFilter (Filterable $filterInstance) {
+ $this->addFilter('bootstrap', $filterInstance);
+ }
+
+ /**
+ * Executes all bootstrap filters
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
+ }
+
+ /**
+ * Add a hub activation filter
+ *
+ * @param $filterInstance A Filterable class
+ * @return void
+ */
+ public function addActivationFilter (Filterable $filterInstance) {
+ $this->addFilter('activation', $filterInstance);
+ }
+
+ /**
+ * Executes all hub activation filters
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->executeFilters('activation', $requestInstance, $responseInstance);
+ }
+}
+
+// [EOF]
+?>
<?php
// Own namespace
-namespace CoreFramework\Resolver\Controller;
+namespace CoreFramework\Tests\Resolver\Controller;
+
+// Import framework stuff
+use CoreFramework\Controller\BaseController;
+use CoreFramework\Manager\ManageableApplication;
/**
* A resolver for resolving controllers locally
if (empty($controllerName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
+ } elseif ($resolverInstance->isControllerValid(__NAMESPACE__, $controllerName) === FALSE) {
// Invalid command found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
}
namespace CoreFramework\Controller\Default;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Default;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Confirm;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Default;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\News;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Login;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Failed;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Logout;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Logout;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Request\Requestable;
/**
namespace CoreFramework\Controller\Problem;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Register;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Response\Responseable;
/**
namespace CoreFramework\Controller\Status;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Form;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Login;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Image\Captcha;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
namespace CoreFramework\Controller\Default;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Request\Requestable;
use CoreFramework\Response\Responseable;
if ($stripTags === TRUE) {
// Prepare the output without HTML tags
$output = trim(html_entity_decode(strip_tags(stripslashes($output))));
- } else {
- // Prepare the output with HTML tags
- $output = trim(stripslashes($output));
- }
+ } // END - if
// Are debug times enabled?
if ($this->getConfigInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_output_timings') == 'Y') {
* controller was not found one of the default controllers will be used
* depending on whether news shall be displayed.
*
+ * @param $namespace Namespace to look in
* @param $controllerName A controller name we shall look for
* @return $controllerInstance A loaded controller instance
* @throws InvalidControllerException Thrown if even the requested
* controller class is missing (bad!)
*/
- protected function loadController ($controllerName) {
+ protected function loadController ($namespace, $controllerName) {
// Cache default controller
$defaultController = $this->getConfigInstance()->getConfigEntry('default_' . strtolower($this->getClassPrefix()) . '_controller');
// Init controller instance
$controllerInstance = NULL;
+ // Create full class name
+ $className = sprintf(
+ '%s\%sDefaultNewsController',
+ $namespace,
+ $this->getCapitalizedClassPrefix()
+ );
+
// Default controller
- $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController');
+ $this->setClassName($className);
// Generate the class name
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BEFORE: controller=' . $controllerName);
$this->setClassName($className);
} else {
// No news at main controller or non-news controller
- $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController');
+ $this->setClassName($className);
}
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('AFTER: controller=' . $this->getClassName());
/**
* Checks whether the given controller is valid
*
+ * @param $namespace Namespace to look in, no trailing backslash
* @param $controllerName The default controller we shall execute
* @return $isValid Whether the given controller is valid
* @throws EmptyVariableException Thrown if given controller is not set
* @throws DefaultControllerException Thrown if default controller was not found
*/
- public function isControllerValid ($controllerName) {
+ public function isControllerValid ($namespace, $controllerName) {
// By default nothing shall be valid
$isValid = FALSE;
- // Is a controller set?
- if (empty($controllerName)) {
+ // Is namespace and controller name set?
+ if (empty($namespace)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($this, 'namespace'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif (empty($controllerName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($this, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
} // END - if
// Create class name
- $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($controllerName) . 'Controller';
+ $className = sprintf(
+ '%s\%sController',
+ $namespace,
+ $this->getCapitalizedClassPrefix() . self::convertToClassName($controllerName)
+ );
+ $newsControllerName = sprintf(
+ '%s\%sDefaultNewsController',
+ $namespace,
+ $this->getCapitalizedClassPrefix()
+ );
+
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('className=%s', $className));
// Now, let us create the full name of the controller class
$this->setClassName($className);
if (class_exists($this->getClassName())) {
// This class does exist. :-)
$isValid = TRUE;
- } elseif ($this->getClassName() != $this->getCapitalizedClassPrefix() . 'DefaultNewsController') {
+ } elseif ($this->getClassName() != $newsControllerName) {
// Set default controller
- $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController');
+ $this->setClassName($newsControllerName);
} else {
// All is tried, give it up here
throw new DefaultControllerException($this, self::EXCEPTION_DEFAULT_CONTROLLER_GONE);
$controllerName = '';
$controllerInstance = NULL;
- // Get the controller name
+ // Get namespace and controller name
+ $namespace = $this->getNamespace();
$controllerName = $this->getControllerName();
// Get the controller
- $controllerInstance = $this->loadController($controllerName);
+ $controllerInstance = $this->loadController($namspace, $controllerName);
// And validate it
if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
namespace CoreFramework\Resolver\Controller;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Manager\ManageableApplication;
/**
/**
* Creates an instance of a resolver class with a given controller
*
+ * @param $namespace Namespace to look in
* @param $controllerName The controller we shall resolve
* @param $applicationInstance An instance of a manageable application helper class
* @return $resolverInstance The prepared controller resolver instance
* @throws EmptyVariableException Thrown if default controller is not set
* @throws InvalidControllerException Thrown if default controller is invalid
*/
- public static final function createConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
+ public static final function createConsoleControllerResolver ($namespace, $controllerName, ManageableApplication $applicationInstance) {
// Create the new instance
$resolverInstance = new ConsoleControllerResolver();
if (empty($controllerName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
+ } elseif ($resolverInstance->isControllerValid($namespace, $controllerName) === FALSE) {
// Invalid controller found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
}
namespace CoreFramework\Resolver\Controller;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Manager\ManageableApplication;
/**
/**
* Creates an instance of a resolver class with a given controller
*
+ * @param $namespace Namespace to look in
* @param $controllerName The controller we shall resolve
* @param $applicationInstance An instance of a manageable application helper class
* @return $resolverInstance The prepared controller resolver instance
* @throws EmptyVariableException Thrown if default controller is not set
* @throws InvalidControllerException Thrown if default controller is invalid
*/
- public static final function createHtmlControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
+ public static final function createHtmlControllerResolver ($namespace, $controllerName, ManageableApplication $applicationInstance) {
// Create the new instance
$resolverInstance = new HtmlControllerResolver();
if (empty($controllerName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
+ } elseif ($resolverInstance->isControllerValid($namespace, $controllerName) === FALSE) {
// Invalid controller found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
}
namespace CoreFramework\Resolver\Controller;
// Import framework stuff
+use CoreFramework\Controller\BaseController;
use CoreFramework\Manager\ManageableApplication;
/**
/**
* Creates an instance of a resolver class with a given controller
*
+ * @param $namespace Namespace to look in
* @param $controllerName The controller we shall resolve
* @param $applicationInstance An instance of a manageable application helper class
* @return $resolverInstance The prepared controller resolver instance
* @throws EmptyVariableException Thrown if default controller is not set
* @throws InvalidControllerException Thrown if default controller is invalid
*/
- public static final function createImageControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
+ public static final function createImageControllerResolver ($namespace, $controllerName, ManageableApplication $applicationInstance) {
// Create the new instance
$resolverInstance = new ImageControllerResolver();
if (empty($controllerName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
+ } elseif ($resolverInstance->isControllerValid($namespace, $controllerName) === FALSE) {
// Invalid controller found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
}