3 namespace Org\Mxchange\CoreFramework\Command\Guest;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Command\BaseCommand;
7 use Org\Mxchange\CoreFramework\Command\Commandable;
8 use Org\Mxchange\CoreFramework\Controller\Controller;
9 use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
10 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
11 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
12 use Org\Mxchange\CoreFramework\Registry\Registry;
13 use Org\Mxchange\CoreFramework\Request\Requestable;
14 use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
15 use Org\Mxchange\CoreFramework\Response\Responseable;
18 * A command for the confirmation link handling
20 * @author Roland Haeder <webmaster@shipsimu.org>
22 <<<<<<< HEAD:framework/main/classes/commands/html/class_HtmlConfirmCommand.php
23 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
25 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
26 >>>>>>> Some updates::inc/main/classes/commands/html/class_HtmlConfirmCommand.php
27 * @license GNU GPL 3.0 or any newer version
28 * @link http://www.shipsimu.org
30 * This program is free software: you can redistribute it and/or modify
31 * it under the terms of the GNU General Public License as published by
32 * the Free Software Foundation, either version 3 of the License, or
33 * (at your option) any later version.
35 * This program is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 * GNU General Public License for more details.
40 * You should have received a copy of the GNU General Public License
41 * along with this program. If not, see <http://www.gnu.org/licenses/>.
43 class HtmlConfirmCommand extends BaseCommand implements Commandable {
45 * Protected constructor
49 protected function __construct () {
50 // Call parent constructor
51 parent::__construct(__CLASS__);
55 * Creates an instance of this class
57 * @param $resolverInstance An instance of a command resolver class
58 * @return $commandInstance An instance a prepared command class
60 public static final function createHtmlConfirmCommand (CommandResolver $resolverInstance) {
62 $commandInstance = new HtmlConfirmCommand();
64 // Set the application instance
65 $commandInstance->setResolverInstance($resolverInstance);
67 // Return the prepared instance
68 return $commandInstance;
72 * Executes the given command with given request and response objects
74 * @param $requestInstance An instance of a class with an Requestable interface
75 * @param $responseInstance An instance of a class with an Responseable interface
78 public function execute (Requestable $requestInstance, Responseable $responseInstance) {
79 // Get the application instance
80 $applicationInstance = Registry::getRegistry()->getInstance('app');
82 // Prepare a template instance
83 $templateInstance = $this->prepareTemplateInstance($applicationInstance);
85 // Assign application data with template engine
86 $templateInstance->assignApplicationData($applicationInstance);
89 $templateInstance->assignConfigVariable('base_url');
91 // Load the master template
92 $masterTemplate = $applicationInstance->buildMasterTemplateName();
94 // Load header template
95 $templateInstance->loadCodeTemplate('header');
97 // Compile and assign it with a variable
98 $templateInstance->compileTemplate();
99 $templateInstance->assignTemplateWithVariable('header', 'header');
101 // Load footer template
102 $templateInstance->loadCodeTemplate('footer');
104 // Compile and assign it with a variable
105 $templateInstance->compileTemplate();
106 $templateInstance->assignTemplateWithVariable('footer', 'footer');
108 // Load the home template
109 $templateInstance->loadCodeTemplate('confirm_link');
111 // Assign the home template with the master template as a content ... ;)
112 $templateInstance->assignTemplateWithVariable('confirm_link', 'main_content');
114 // Load the master template
115 $templateInstance->loadCodeTemplate($masterTemplate);
118 $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_confirm_link_title'));
122 $userInstance = Registry::getRegistry()->getInstance('user');
123 } catch (NullPointerException $e) {
124 // Not found user, e.g. when the user is somehow invalid
125 $responseInstance->redirectToConfiguredUrl('html_cmd_user_is_null');
129 $templateInstance->assignVariable('username', $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USERNAME));
131 // Construct the menu in every command. We could do this in BaseCommand class. But this means
132 // *every* command has a navigation system and that is want we don't want.
133 $menuInstance = ObjectFactory::createObjectByConfiguredName('confirm_menu_class', array($applicationInstance));
136 $menuInstance->renderMenu();
138 // Transfer it to the template engine instance
139 $menuInstance->transferContentToTemplateEngine($templateInstance);
142 * ... and all variables. This should be merged together in a pattern
143 * to make things easier. A cache mechanism should be added between
144 * these two calls to cache compiled templates.
146 $templateInstance->compileVariables();
148 // Get the content back from the template engine and put it in response class
149 $templateInstance->transferToResponse($responseInstance);
153 * Adds extra filters to the given controller instance
155 * @param $controllerInstance A controller instance
156 * @param $requestInstance An instance of a class with an Requestable interface
159 public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {