1
|
<?php
|
2
|
/* --------------------------------------------------------------
|
3
|
PopupContentContentView.inc.php 2015-02-18 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
|
(c) 2003 XT-Commerce - community made shopping http://www.xt-commerce.com
|
12
|
-----------------------------------------------------------------------------------------
|
13
|
based on:
|
14
|
(c) 2000-2001 The Exchange Project (earlier name of osCommerce)
|
15
|
(c) 2002-2003 osCommerce www.oscommerce.com
|
16
|
(c) 2003 nextcommerce www.nextcommerce.org
|
17
|
|
18
|
XTC-NEWSLETTER_RECIPIENTS RC1 - Contribution for XT-Commerce http://www.xt-commerce.com
|
19
|
by Matthias Hinsche http://www.gamesempire.de
|
20
|
|
21
|
Released under the GNU General Public License
|
22
|
--------------------------------------------------------------------------------------- */
|
23
|
|
24
|
class PopupContentContentView extends ContentView
|
25
|
{
|
26
|
protected $content_group_id;
|
27
|
protected $customer_status_id;
|
28
|
protected $lightbox_mode = 0;
|
29
|
protected $language_id = 2;
|
30
|
protected $content_data_array;
|
31
|
|
32
|
public function __construct()
|
33
|
{
|
34
|
parent::__construct();
|
35
|
$this->set_content_template('module/popup_content.html');
|
36
|
$this->set_flat_assigns(true);
|
37
|
}
|
38
|
|
39
|
protected function set_validation_rules()
|
40
|
{
|
41
|
// SET VALIDATION RULES
|
42
|
$this->validation_rules_array['content_group_id'] = array('type' => 'int');
|
43
|
$this->validation_rules_array['customer_status_id'] = array('type' => 'int');
|
44
|
$this->validation_rules_array['lightbox_mode'] = array('type' => 'int');
|
45
|
$this->validation_rules_array['language_id'] = array('type' => 'int');
|
46
|
$this->validation_rules_array['content_data_array'] = array('type' => 'array');
|
47
|
}
|
48
|
|
49
|
public function prepare_data()
|
50
|
{
|
51
|
$t_uninitialized_array = $this->get_uninitialized_variables(array('content_group_id'));
|
52
|
if(empty($t_uninitialized_array))
|
53
|
{
|
54
|
$this->get_data();
|
55
|
$this->set_data();
|
56
|
}
|
57
|
else
|
58
|
{
|
59
|
trigger_error("Variable(s) " . implode(', ', $t_uninitialized_array) . " do(es) not exist in class " . get_class($this) . " or is/are null", E_USER_ERROR);
|
60
|
}
|
61
|
}
|
62
|
|
63
|
protected function get_data()
|
64
|
{
|
65
|
$t_query = 'SELECT
|
66
|
*
|
67
|
FROM
|
68
|
' . TABLE_CONTENT_MANAGER . '
|
69
|
WHERE
|
70
|
content_group = "' . $this->content_group_id . '"
|
71
|
AND languages_id = "' . $this->language_id . '"';
|
72
|
|
73
|
$t_result = xtc_db_query($t_query);
|
74
|
$this->content_data_array = xtc_db_fetch_array($t_result, true);
|
75
|
|
76
|
if($this->lightbox_mode == 1 && $this->content_data_array['content_text'] != '')
|
77
|
{
|
78
|
$this->content_data_array['content_text'] = $this->add_target_to_links($this->content_data_array['content_text']);
|
79
|
}
|
80
|
|
81
|
// CHECK IF CONTENT FILE IS SET
|
82
|
if($this->content_data_array['content_file'] != '')
|
83
|
{
|
84
|
$this->content_data_array['content_text'] = $this->load_content_file($this->content_data_array['content_file']);
|
85
|
}
|
86
|
elseif($this->content_group_id == 3889891)
|
87
|
{
|
88
|
$coo_shipping_and_payment_matrix_content_view = MainFactory::create_object('ShippingAndPaymentMatrixContentView');
|
89
|
$t_matrix_content = $coo_shipping_and_payment_matrix_content_view->get_html();
|
90
|
|
91
|
$this->content_data_array['content_text'] = str_replace('{$shipping_and_payment_matrix}', $t_matrix_content, $this->content_data_array['content_text']);
|
92
|
}
|
93
|
elseif($this->content_data_array['content_group'] == gm_get_conf('GM_WITHDRAWAL_CONTENT_ID'))
|
94
|
{
|
95
|
$t_group_check_condition = $this->get_group_check_sql_condition();
|
96
|
$t_shop_content_query = xtc_db_query("SELECT
|
97
|
content_file,
|
98
|
content_heading,
|
99
|
content_text
|
100
|
FROM " . TABLE_CONTENT_MANAGER . " as cm
|
101
|
LEFT JOIN cm_file_flags AS ff USING (file_flag)
|
102
|
WHERE file_flag_name = 'withdrawal'
|
103
|
AND content_status = 1
|
104
|
" . $t_group_check_condition . "
|
105
|
AND languages_id='" . $this->language_id . "'");
|
106
|
|
107
|
while($t_row = xtc_db_fetch_array($t_shop_content_query))
|
108
|
{
|
109
|
if($t_row['content_file'] != '')
|
110
|
{
|
111
|
$t_content_array[] = $this->load_content_file($t_row['content_file']);
|
112
|
}
|
113
|
else
|
114
|
{
|
115
|
$t_content_array[] = '<strong>' . $t_row['content_heading'] . '</strong><br /><br />' . $t_row['content_text'];
|
116
|
}
|
117
|
}
|
118
|
|
119
|
if(is_array($t_content_array) && count($t_content_array) > 0)
|
120
|
{
|
121
|
$t_withdrawal_content = implode("<br /><br /><br />", $t_content_array);
|
122
|
}
|
123
|
|
124
|
$this->content_data_array['content_text'] = $t_withdrawal_content;
|
125
|
}
|
126
|
}
|
127
|
|
128
|
protected function load_content_file($p_content_file)
|
129
|
{
|
130
|
// GET FILE CONTENT
|
131
|
ob_start();
|
132
|
|
133
|
if(strpos($p_content_file, '.txt'))
|
134
|
{
|
135
|
echo '<pre>';
|
136
|
}
|
137
|
|
138
|
include (DIR_FS_CATALOG . 'media/content/' . basename($p_content_file));
|
139
|
|
140
|
if(strpos($p_content_file, '.txt'))
|
141
|
{
|
142
|
echo '</pre>';
|
143
|
}
|
144
|
|
145
|
$t_content_output = ob_get_contents();
|
146
|
ob_end_clean();
|
147
|
|
148
|
return $t_content_output;
|
149
|
}
|
150
|
|
151
|
protected function get_group_check_sql_condition()
|
152
|
{
|
153
|
$t_group_check = '';
|
154
|
|
155
|
if(GROUP_CHECK == 'true')
|
156
|
{
|
157
|
$t_group_check = "and group_ids LIKE '%c_" . $this->customer_status_id . "_group%'";
|
158
|
}
|
159
|
|
160
|
return $t_group_check;
|
161
|
}
|
162
|
|
163
|
protected function set_data()
|
164
|
{
|
165
|
if($this->content_group_id == 3889895)
|
166
|
{
|
167
|
$coo_text_manager = MainFactory::create_object('LanguageTextManager', array('checkout_payment', $this->language_id));
|
168
|
$this->content_array['CONTENT_HEADING'] = $coo_text_manager->get_text('title_withdrawal');
|
169
|
}
|
170
|
else
|
171
|
{
|
172
|
$this->content_array['CONTENT_HEADING'] = $this->content_data_array['content_heading'];
|
173
|
}
|
174
|
|
175
|
$this->content_array['LIGHTBOX_MODE'] = $this->lightbox_mode;
|
176
|
$this->content_array['TEXT_CLOSE_WINDOW'] = TEXT_CLOSE_WINDOW;
|
177
|
$this->content_array['TEXT_CLOSE_WINDOW_NO_JS'] = TEXT_CLOSE_WINDOW_NO_JS;
|
178
|
$this->content_array['STYLESHEET'] = 'templates/' . CURRENT_TEMPLATE . '/stylesheet.css';
|
179
|
$this->content_array['DYNAMIC_CSS'] = 'templates/' . CURRENT_TEMPLATE . '/gm_dynamic.css.php';
|
180
|
$this->content_array['HTML'] = $this->content_data_array['content_text'];
|
181
|
}
|
182
|
|
183
|
|
184
|
protected function add_target_to_links($p_content)
|
185
|
{
|
186
|
libxml_use_internal_errors(true);
|
187
|
$t_dom_document = new DOMDocument('1.0', 'UTF-8');
|
188
|
$t_dom_document->substituteEntities = true;
|
189
|
$t_options_allowed = version_compare(PHP_VERSION, '5.4.0', '>=')
|
190
|
&& defined('LIBXML_HTML_NOIMPLIED')
|
191
|
&& defined('LIBXML_HTML_NODEFDTD');
|
192
|
|
193
|
if($t_options_allowed)
|
194
|
{
|
195
|
$t_dom_document->loadHTML($p_content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
196
|
}
|
197
|
else
|
198
|
{
|
199
|
$t_dom_document->loadHTML($p_content);
|
200
|
}
|
201
|
|
202
|
$t_links = $t_dom_document->getElementsByTagName('a');
|
203
|
|
204
|
foreach ($t_links as $t_link)
|
205
|
{
|
206
|
$t_link->setAttribute('target', '_parent');
|
207
|
}
|
208
|
|
209
|
$t_content = $t_dom_document->saveHTML();
|
210
|
|
211
|
if($t_options_allowed === false)
|
212
|
{
|
213
|
$t_content = preg_replace('~<(?:!DOCTYPE|/?(?:html|head|body))[^>]*>\s*~i', '', $t_content);
|
214
|
}
|
215
|
|
216
|
return $t_content;
|
217
|
}
|
218
|
}
|