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