1 <?php
2 /* --------------------------------------------------------------
3 AdminPageHttpControllerResponse.inc.php 2015-03-12 gm
4 Gambio GmbH
5 http://www.gambio.de
6 Copyright (c) 2015 Gambio GmbH
7 Released under the GNU General Public License (Version 2)
8 [http://www.gnu.org/licenses/gpl-2.0.html]
9 --------------------------------------------------------------
10 */
11
12 MainFactory::load_class('HttpControllerResponse');
13
14 /**
15 * Class AdminPageHttpControllerResponse
16 *
17 * Important:
18 * This class will load the admin section of the shop, something that cannot be
19 * integrated into unit tests. That is why it is not unit tested.
20 *
21 * @category System
22 * @package Http
23 * @subpackage ValueObjects
24 * @extends HttpControllerResponse
25 */
26 class AdminPageHttpControllerResponse extends HttpControllerResponse
27 {
28 /**
29 * Initializes the admin page http controller response.
30 *
31 * @param string $title Page title of admin page.
32 * @param array|null $mainContent Rendered response body.
33 * @param AssetCollectionInterface $assets (Optional) Assets collection to add new assets to the markup.
34 * @param array $jsLanguageSections (Optional) Language section for the js engine modules for the
35 * rendered admin page.
36 */
37 public function __construct($title,
38 $mainContent,
39 AssetCollectionInterface $assets = null,
40 array $jsLanguageSections = array())
41 {
42 $this->httpBody = $this->_getAdminPageBody(array(
43 'title' => $title,
44 'main_content' => $mainContent
45 ),
46 $assets,
47 $jsLanguageSections);
48 }
49
50
51 /**
52 * Returns a predefined markup for gambio admin pages.
53 *
54 * @param array $contentArray Associative array with 'title' and 'main_content' keys.
55 * @param AssetCollectionInterface $assets (Optional) Collection with assets for the markup.
56 * @param array $jsLanguageSections (Optional) Array with language sections to access them in
57 * modules of the gx javascript engine.
58 *
59 * @return string Rendered markup for the admin page.
60 */
61 protected function _getAdminPageBody(array $contentArray,
62 AssetCollectionInterface $assets = null,
63 array $jsLanguageSections = array())
64 {
65 $varTitle = '';
66 $varMainContent = '';
67
68 if(isset($contentArray['title']))
69 {
70 $varTitle = $contentArray['title'];
71 }
72 if(isset($contentArray['main_content']))
73 {
74 $varMainContent = $contentArray['main_content'];
75 }
76
77 // Load language translations for JavaScript module engine.
78 $jsEngineLanguage = array(); // this variable is used in the "header.php" in the EngineConfiguration object
79 foreach($jsLanguageSections as $section)
80 {
81 $languageTextManager = MainFactory::create_object('LanguageTextManager',
82 array($section, $_SESSION['languages_id']));
83 $jsEngineLanguage[$section] = $languageTextManager->get_section_array($section);
84 }
85
86 ob_start();
87 ?>
88 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
89 <html <?php echo HTML_PARAMS; ?>>
90 <head>
91 <meta http-equiv="Content-Type"
92 content="text/html; charset=<?php echo $_SESSION['language_charset']; ?>">
93 <title><?php echo $varTitle ?></title>
94 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
95 <link rel="stylesheet" type="text/css" href="gm/css/lightbox.css">
96 <link rel="stylesheet" type="text/css" href="gm/css/buttons.css">
97 <link rel="stylesheet" type="text/css" href="includes/export_schemes.css">
98 <link rel="stylesheet" type="text/css" href="gm/css/tooltip_plugin.css">
99 <script type="text/javascript" src="includes/general.js"></script>
100 </head>
101
102 <body marginwidth="0"
103 marginheight="0"
104 topmargin="0"
105 bottommargin="0"
106 leftmargin="0"
107 rightmargin="0"
108 bgcolor="#FFFFFF">
109
110 <!-- header //-->
111 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
112 <script type="text/javascript" src="gm/javascript/lightbox_plugin.js"></script>
113 <script type="text/javascript" src="gm/javascript/tooltip_plugin.js"></script>
114 <!-- header_eof //-->
115
116 <!-- assets //-->
117 <?php
118 if($assets)
119 {
120 echo $assets->getHtml();
121 }
122 ?>
123 <!-- assets_eof //-->
124
125 <!-- body //-->
126 <table border="0" width="100%">
127 <tr>
128 <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
129 <table border="0"
130 width="<?php echo BOX_WIDTH; ?>"
131 class="columnLeft">
132 <!-- left_navigation //-->
133 <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
134 <!-- left_navigation_eof //-->
135 </table>
136 </td>
137 <!-- body_text //-->
138 <td class="boxCenter" width="100%" valign="top">
139 <table border="0" width="100%" cellspacing="0" cellpadding="0">
140 <tr>
141 <td>
142 <!-- gm_module //-->
143 <div class="pageHeading"
144 style="background-image:url(images/gm_icons/hilfsprogr1.png)">
145 <?php echo $varTitle ?>
146 </div>
147
148 <div id="container">
149 <?php echo $varMainContent ?>
150 </div>
151 </td>
152 </tr>
153 </table>
154 </td>
155 </tr>
156 </table>
157 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
158 </body>
159 </html>
160 <?php
161 $output = ob_get_contents();
162 ob_end_clean();
163
164 return $output;
165 }
166 }