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