Continued:
[core.git] / inc / main / classes / response / console / class_ConsoleResponse.php
1 <?php
2 // Own namespace
3 namespace CoreFramework\Response;
4
5 // Import framework stuff
6 use CoreFramework\Manager\ManageableApplication;
7
8 /**
9  * A class for a console response aka output to console
10  *
11  * @author              Roland Haeder <webmaster@shipsimu.org>
12  * @version             0.0.0
13  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
14  * @license             GNU GPL 3.0 or any newer version
15  * @link                http://www.shipsimu.org
16  *
17  * This program is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program. If not, see <http://www.gnu.org/licenses/>.
29  *
30  * The extended headers are taken from phpMyAdmin setup tool, written by
31  * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
32  */
33 class ConsoleResponse extends BaseResponse implements Responseable {
34         /**
35          * Protected constructor
36          *
37          * @return      void
38          */
39         protected function __construct () {
40                 // Call parent constructor
41                 parent::__construct(__CLASS__);
42
43                 // Set response type
44                 $this->setResponseType('console');
45         }
46
47         /**
48          * Creates an object of this class
49          *
50          * @param       $applicationInstance    An instance of a manageable application
51          * @return      $responseInstance               A prepared instance of this class
52          */
53         public static final function createConsoleResponse (ManageableApplication $applicationInstance) {
54                 // Get a new instance
55                 $responseInstance = new ConsoleResponse();
56
57                 // Set the application instance
58                 $responseInstance->setApplicationInstance($applicationInstance);
59
60                 // Initialize the template engine here
61                 $responseInstance->initTemplateEngine($applicationInstance);
62
63                 // Init web output instance
64                 $responseInstance->initWebOutputInstance();
65
66                 // Return the prepared instance
67                 return $responseInstance;
68         }
69
70         /**
71          * Initializes the template engine instance
72          *
73          * @param       $applicationInstance    An instance of a manageable application
74          * @return      void
75          */
76         public final function initTemplateEngine (ManageableApplication $applicationInstance) {
77                 $this->setTemplateInstance($this->prepareTemplateInstance($applicationInstance));
78         }
79
80         /**
81          * Adds a cookie to the response
82          *
83          * @param       $cookieName             Cookie's name
84          * @param       $cookieValue    Value to store in the cookie
85          * @param       $encrypted              Do some extra encryption on the value
86          * @param       $expires                Timestamp of expiration (default: configured)
87          * @return      void
88          * @throws      ResponseHeadersAlreadySentException             If headers are already sent
89          */
90         public function addCookie ($cookieName, $cookieValue, $encrypted = FALSE, $expires = NULL) {
91                 //* DEBUG: */ echo $cookieName.'='.$cookieValue."<br />\n";
92                 $this->partialStub('Naturally unimplemented in console response.');
93         }
94
95         /**
96          * Redirect to a configured URL. The URL can be absolute or relative. In
97          * case of relative URL it will be extended automatically.
98          *
99          * @param       $configEntry    The configuration entry which holds our URL
100          * @return      void
101          * @throws      ResponseHeadersAlreadySentException             If headers are already sent
102          */
103         public function redirectToConfiguredUrl ($configEntry) {
104                 $this->partialStub('Naturally unimplemented in console response.');
105         }
106
107         /**
108          * Expires the given cookie if it is set
109          *
110          * @param       $cookieName             Cookie to expire
111          * @return      void
112          */
113         public function expireCookie ($cookieName) {
114                 $this->partialStub('Naturally unimplemented in console response.');
115         }
116
117         /**
118          * Refreshs a given cookie. This will make the cookie live longer
119          *
120          * @param       $cookieName             Cookie to refresh
121          * @return      void
122          */
123         public function refreshCookie ($cookieName) {
124                 $this->partialStub('Naturally unimplemented in console response.');
125         }
126
127         /**
128          * Flushs the cached console response to the console
129          *
130          * @param       $force  Whether we shall force the output or abort if headers are
131          *                                      already sent with an exception
132          * @return      void
133          * @throws      ResponseHeadersAlreadySentException             Thrown if headers are already sent
134          */
135         public function flushBuffer ($force = FALSE) {
136                 $this->partialStub('Please implement this class.');
137         }
138
139 }