Passed
Pull Request — master (#14)
by Michael
04:13
created

include/common.php (1 issue)

Labels
Severity
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * oledrion
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 */
19
20
use XoopsModules\Oledrion;
21
use XoopsModules\Oledrion\Plugins\Models;
22
23
require_once dirname(__DIR__) . '/preloads/autoloader.php';
24
//require_once  dirname(__DIR__) . '/config.php';
25
26
$moduleDirName      = basename(dirname(__DIR__));
27
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
28
29
/** @var \XoopsDatabase $db */
30
/** @var Oledrion\Helper $helper */
31
/** @var Oledrion\Utility $utility */
32
$db      = \XoopsDatabaseFactory::getDatabaseConnection();
33
$helper  = Oledrion\Helper::getInstance();
34
$utility = new Oledrion\Utility();
35
//$configurator = new Oledrion\Common\Configurator();
36
37
$helper->loadLanguage('common');
38
$helper->loadLanguage('main');
39
40
$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
41
$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32);
42
43
if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) {
44
    define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__)));
45
    define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
46
    define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
47
    define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/');
48
    define($moduleDirNameUpper . '_IMAGES_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/');
49
    define($moduleDirNameUpper . '_IMAGES_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images/');
50
    define($moduleDirNameUpper . '_CLASS_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/class/');
51
    define($moduleDirNameUpper . '_PLUGINS_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/plugins/');
52
    define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/');
53
    define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/');
54
    //    define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($moduleDirNameUpper . '_DIRNAME'));
55
    define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php');
56
    //    define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png');
57
    define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
58
    define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
59
    define($moduleDirNameUpper . '_CACHE_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/' . 'cache/');
60
    define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', $pathIcon32 . '/xoopsmicrobutton.gif');
61
    define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1);
62
63
    // Define oledrion URL and PATH
64
    //    define('OLEDRION_URL', XOOPS_URL . '/modules/' . OLEDRION_DIRNAME . '/');
65
    //    define('OLEDRION_PATH', XOOPS_ROOT_PATH . '/modules/' . OLEDRION_DIRNAME . '/');
66
67
    // Set class path
68
    //    define('OLEDRION_CLASS_PATH', OLEDRION_PATH . 'class/');
69
70
    // Set image , js and css url
71
    //    define('OLEDRION_IMAGES_URL', OLEDRION_URL . 'assets/images/');
72
    define('OLEDRION_JS_URL', OLEDRION_URL . 'assets/js/');
73
    define('OLEDRION_CSS_URL', OLEDRION_URL . 'assets/css/');
74
75
    // Set admin URL and PATH
76
    //    define('OLEDRION_ADMIN_URL', OLEDRION_URL . 'admin/');
77
    //    define('OLEDRION_ADMIN_PATH', OLEDRION_PATH . 'admin' . '/');
78
79
    // Set gateways path
80
    define('OLEDRION_GATEWAY_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/class/Gateways' . '/');
81
82
    // Set plugin URL and PATH
83
    //    define('OLEDRION_PLUGINS_PATH', OLEDRION_PATH . 'plugins/');
84
    define('OLEDRION_PLUGINS_URL', OLEDRION_URL . 'plugins/');
85
86
    // Set text path
87
    define('OLEDRION_TEXT_PATH', XOOPS_UPLOAD_PATH . '/' . OLEDRION_DIRNAME . '/' . 'text/');
88
89
    // Set cache path
90
    //    define('OLEDRION_CACHE_PATH', XOOPS_UPLOAD_PATH . '/' . OLEDRION_DIRNAME . '/' . 'cache/');
91
92
    // Define here the place where main upload path
93
    //    define('OLEDRION_UPLOAD_URL', XOOPS_UPLOAD_URL . '/oledrion'); // WITHOUT Trailing slash
94
    //    define('OLEDRION_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/oledrion'); // WITHOUT Trailing slash
95
96
    // Define here the place where files attached to products are saved
97
    define('OLEDRION_ATTACHED_FILES_URL', XOOPS_UPLOAD_URL . '/oledrion/attached'); // WITHOUT Trailing slash
98
    define('OLEDRION_ATTACHED_FILES_PATH', XOOPS_UPLOAD_PATH . '/oledrion/attached'); // WITHOUT Trailing slash
99
100
    // Define here where pictures are saved
101
    define('OLEDRION_PICTURES_URL', XOOPS_UPLOAD_URL . '/oledrion/images'); // WITHOUT Trailing slash
102
    define('OLEDRION_PICTURES_PATH', XOOPS_UPLOAD_PATH . '/oledrion/images'); // WITHOUT Trailing slash
103
104
    // Maximum length of product's summary for pages (in characters)
105
    define('OLEDRION_SUMMARY_MAXLENGTH', 150);
106
107
    // Used in checkout to select a default country
108
    define('OLEDRION_DEFAULT_COUNTRY', 'US');
109
110
    // RSS Feed cache duration (in minutes)
111
    define('OLEDRION_RSS_CACHE', 3600);
112
113
    // Dimensions of the popup used to select product(s) when there are a lot of products
114
    define('OLEDRION_MAX_PRODUCTS_POPUP_WIDTH', 800);
115
    define('OLEDRION_MAX_PRODUCTS_POPUP_HEIGHT', 600);
116
117
    // Newsletter URL and PATH (the folder must be writable)
118
    define('OLEDRION_NEWSLETTER_URL', XOOPS_URL . '/uploads/oledrion/oledrion_newsletter.txt');
119
    define('OLEDRION_NEWSLETTER_PATH', XOOPS_ROOT_PATH . '/uploads/oledrion/oledrion_newsletter.txt');
120
121
    // CSV URL and path (the folder must be writable) and Separator
122
    define('OLEDRION_CSV_PATH', XOOPS_UPLOAD_PATH . '/oledrion/cvs');
123
    define('OLEDRION_CSV_URL', XOOPS_UPLOAD_URL . '/oledrion/cvs');
124
    define('OLEDRION_CSV_SEP', ';');
125
126
    // Gateway log's path (must be writable)
127
    // B.R. define('OLEDRION_GATEWAY_LOG_PATH', XOOPS_UPLOAD_PATH . '/oledrion/loggateway_oledrion.php');
128
    define('OLEDRION_GATEWAY_LOG_PATH', XOOPS_UPLOAD_PATH . '/oledrion/gateway_log.php');
129
    // B.R New: Filename of serialized confirmation email parameters
130
    define('OLEDRION_CONFIRMATION_EMAIL_FILENAME_SUFFIX', '_conf_email.parms');
131
132
    // B.R. New: Absolute path and filename of optional database update script
133
    // Must be located outside DOCUMENT_ROOT and change permissions to 'rwxr-x--x'
134
    define('OLEDRION_DB_UPDATE_SCRIPT', '/home/e-smith/files/ibays/rossco/license_server/update_licenseDB.php');
135
136
    // Do you want to show the list of main categories on the category page when user is on category.php (without specifying a category to see)
137
    define('OLEDRION_SHOW_MAIN_CATEGORIES', true);
138
    // Do you want to sho the list of sub categories of the current category on the category page (when viewing a specific category)
139
    define('OLEDRION_SHOW_SUB_CATEGORIES', true);
140
141
    // String to use to join the list of manufacturers of each product
142
    define('OLEDRION_STRING_TO_JOIN_MANUFACTURERS', ', ');
143
144
    // Thumbs prefix (when thumbs are automatically created)
145
    define('OLEDRION_THUMBS_PREFIX', 'thumb_');
146
147
    // Popup width and height (used in the product.php page to show the media.php page)
148
    define('OLEDRION_POPUP_MEDIA_WIDTH', 640);
149
    define('OLEDRION_POPUP_MEDIA_HEIGHT', 480);
150
151
    // Maximum attached files count to display on the product page
152
    define('OLEDRION_MAX_ATTACHMENTS', 20);
153
154
    // Define the MP3 player's dimensions (dewplayer)
155
    define('OLEDRION_DEWPLAYER_WIDTH', 240); // I do not recommend to go lower than 240 pixels !!!!
156
    define('OLEDRION_DEWPLAYER_HEIGHT', 20);
157
158
    // Place for the "duplicated" text inside the product's title
159
    define('OLEDRION_DUPLICATED_PLACE', 'right'); // or 'left'
160
161
    // Define the excluded tabs in the module's administration
162
    // '' = don't remove anything
163
    // To remove the first, third and fourth tabs only, type : '0,2,4'
164
    define('OLEDRION_EXCLUDED_TABS', '');
165
166
    // When this option is set to false, if Product A has Product B as a related product but Product A is not noted as related to Product B then the display of product A will display Product B as a related product.
167
    // But Product B will not show Product A as a related product.
168
    // When this option is set to true, Product A and Product B display each other as two related products even if Product A was not set as a related product to Product A.
169
    define('OLEDRION_RELATED_BOTH', true);
170
171
    // Do we resize pictures when they are smaller than defined dimensions  ?
172
    define('OLEDRION_DONT_RESIZE_IF_SMALLER', true);
173
174
    // Do you want to automatically fill the manual date when you create a new product ?
175
    define('OLEDRION_AUTO_FILL_MANUAL_DATE', true);
176
177
    // Set this option to true if you can't see the products when you add them to your cart
178
    define('OLEDRION_CART_BUG', false);
179
180
    // Set this option to true if your theme uses jQuery, else, set it to false
181
    define('OLEDRION_MY_THEME_USES_JQUERY', true);
182
183
    // Set Text file names
184
    define('OLEDRION_TEXTFILE1', 'oledrion_index.txt');
185
    define('OLEDRION_TEXTFILE2', 'oledrion_cgv.txt');
186
    define('OLEDRION_TEXTFILE3', 'oledrion_recomm.txt');
187
    define('OLEDRION_TEXTFILE4', 'oledrion_offlinepayment.txt');
188
    define('OLEDRION_TEXTFILE5', 'oledrion_restrictorders.txt');
189
    define('OLEDRION_TEXTFILE6', 'oledrion_checkout1.txt');
190
    define('OLEDRION_TEXTFILE7', 'oledrion_checkout2.txt');
191
192
    // Set SMS gateway
193
    define('OLEDRION_SMS_GATEWAY', 'example');
194
}
195
196
//_CACHE_PATH  XOOPS_UPLOAD_PATH . '/' . OLEDRION_DIRNAME . '/' . 'cache/'
197
//OLEDRION_PICTURES_URL
198
//OLEDRION_SUMMARY_MAXLENGTH
199
//OLEDRION_STRING_TO_JOIN_MANUFACTURERS
200
201
// Classes for plugins
202
//require_once OLEDRION_CLASS_PATH . 'Plugin.php'; // Main class
203
//require_once OLEDRION_PLUGINS_PATH . 'models/Action.php'; // model
204
//require_once OLEDRION_PLUGINS_PATH . 'models/Filter.php'; // model
205
206
// Les classes métier ou utilitaires (non ORM)
207
//require_once OLEDRION_CLASS_PATH . 'Utility.php';
208
//require_once OLEDRION_CLASS_PATH . 'HandlerManager.php';
209
//require_once OLEDRION_CLASS_PATH . 'Parameters.php';
210
//require_once OLEDRION_CLASS_PATH . 'Currency.php';
211
//require_once OLEDRION_CLASS_PATH . 'Shelf.php';
212
//require_once OLEDRION_CLASS_PATH . 'ShelfParameters.php';
213
//require_once OLEDRION_CLASS_PATH . 'oledrion_reductions.php';
214
//require_once OLEDRION_CLASS_PATH . 'Gateways.php';
215
//require_once OLEDRION_ADMIN_PATH . 'gateways/gateway.php'; // Abstract class
216
//require_once OLEDRION_CLASS_PATH . 'Lists.php';
217
//require_once OLEDRION_CLASS_PATH . 'Sms.php';
218
219
$oledrionHandlers = Oledrion\HandlerManager::getInstance();
220
221
$myts = \MyTextSanitizer::getInstance();
222
223
// Loading handlers
224
$caddyHandler           = new Oledrion\CaddyHandler($db);
225
$categoryHandler        = new Oledrion\CategoryHandler($db);
226
$commandsHandler        = new Oledrion\CommandsHandler($db);
227
$discountsHandler       = new Oledrion\DiscountsHandler($db);
228
$filesHandler           = new Oledrion\FilesHandler($db);
229
$gatewaysOptionsHandler = new Oledrion\GatewaysOptionsHandler($db);
230
$manufacturerHandler    = new Oledrion\ManufacturerHandler($db);
231
$persistentCartHandler  = new Oledrion\PersistentCartHandler($db);
232
$productsHandler        = new Oledrion\ProductsHandler($db);
233
$productsmanuHandler    = new Oledrion\ProductsmanuHandler($db);
234
$relatedHandler         = new Oledrion\RelatedHandler($db);
235
$vatHandler             = new Oledrion\VatHandler($db);
236
$vendorsHandler         = new Oledrion\VendorsHandler($db);
237
$votedataHandler        = new Oledrion\VotedataHandler($db);
238
// Added by voltan
239
$attributesHandler       = new Oledrion\AttributesHandler($db);
240
$caddyAttributesHandler  = new Oledrion\CaddyAttributesHandler($db);
241
$deliveryHandler         = new Oledrion\DeliveryHandler($db);
242
$deliveryPaymentHandler  = new Oledrion\DeliveryPaymentHandler($db);
243
$listsHandler            = new Oledrion\ListsHandler($db);
244
$locationDeliveryHandler = new Oledrion\LocationDeliveryHandler($db);
245
$locationHandler         = new Oledrion\LocationHandler($db);
246
$packingHandler          = new Oledrion\PackingHandler($db);
247
$paymentHandler          = new Oledrion\PaymentHandler($db);
248
$paymentLogHandler       = new Oledrion\PaymentLogHandler($db);
249
$productsListHandler     = new Oledrion\ProductsListHandler($db);
250
251
$shelf           = new Oledrion\Shelf(); // Facade
252
$shelfParameters = new Oledrion\ShelfParameters(); // Parameters of the facade
253
254
// Definition of Images
255
if (!defined('_OLEDRION_EDIT')) {
256
    //    global $xoopsConfig;
257
    //    if (file_exists(OLEDRION_PATH . 'language/' . $xoopsConfig['language'] . '/main.php')) {
258
    //        include OLEDRION_PATH . 'language/' . $xoopsConfig['language'] . '/main.php';
259
    //    } else {
260
    //        include OLEDRION_PATH . 'language/english/main.php';
261
    //    }
262
    //    $helper->loadLanguage('main');
263
}
264
265
$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
266
267
$icons = [
268
    'edit'     => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _OLEDRION_EDIT . "' align='middle'>",
269
    'delete'   => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _OLEDRION_DELETE . "' align='middle'>",
270
    'online'   => "<img src='" . OLEDRION_IMAGES_URL . "online.gif' alt='" . _OLEDRION_ONLINE . "' align='middle'>",
271
    'offline'  => "<img src='" . OLEDRION_IMAGES_URL . "offline.gif' alt='" . _OLEDRION_OFFLINE . "' align='middle'>",
272
    'ok'       => "<img src='" . OLEDRION_IMAGES_URL . "ok.png' alt='" . _OLEDRION_VALIDATE_COMMAND . "' align='middle'>",
273
    'copy'     => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _OLEDRION_DUPLICATE_PRODUCT . "' align='middle'>",
274
    'details'  => "<img src='" . OLEDRION_IMAGES_URL . "details.png' alt='" . _OLEDRION_DETAILS . "' align='middle'>",
275
    'print'    => "<img src='" . OLEDRION_IMAGES_URL . "print.png' alt='" . _OLEDRION_PRINT_VERSION . "' align='middle'>",
276
    'delivery' => "<img src='" . OLEDRION_IMAGES_URL . "delivery.png' alt='" . _OLEDRION_DELIVERY . "' align='middle'>",
277
    'package'  => "<img src='" . OLEDRION_IMAGES_URL . "package.png' alt='" . _OLEDRION_PACK . "' align='middle'>",
278
    'submit'   => "<img src='" . OLEDRION_IMAGES_URL . "submit.png' alt='" . _OLEDRION_SUBMIT . "' align='middle'>",
279
    'track'    => "<img src='" . OLEDRION_IMAGES_URL . "track.png' alt='" . _OLEDRION_TRACK . "' align='middle'>",
280
];
281
282
// Loading some preferences
283
$mod_pref = [
284
    //        'money_short'     => Oledrion\Utility::getModuleOption('money_short'),
285
    //        'money_full'      => Oledrion\Utility::getModuleOption('money_full'),
286
    //        'url_rewriting'   => Oledrion\Utility::getModuleOption('urlrewriting'),
287
    //        'tooltip'         => Oledrion\Utility::getModuleOption('infotips'),
288
    //        'advertisement'   => Oledrion\Utility::getModuleOption('advertisement'),
289
    //        'rss'             => Oledrion\Utility::getModuleOption('use_rss'),
290
    //        'nostock_msg'     => Oledrion\Utility::getModuleOption('nostock_msg'),
291
    //        'use_price'       => Oledrion\Utility::getModuleOption('use_price'),
292
    //        'restrict_orders' => Oledrion\Utility::getModuleOption('restrict_orders'),
293
    //        'isAdmin'         => Oledrion\Utility::isAdmin()
294
295
    'money_short'     => $helper->getConfig('money_short'),
296
    'money_full'      => $helper->getConfig('money_full'),
297
    'url_rewriting'   => $helper->getConfig('urlrewriting'),
298
    'tooltip'         => $helper->getConfig('infotips'),
299
    'advertisement'   => $helper->getConfig('advertisement'),
300
    'rss'             => $helper->getConfig('use_rss'),
301
    'nostock_msg'     => $helper->getConfig('nostock_msg'),
302
    'use_price'       => $helper->getConfig('use_price'),
303
    'restrict_orders' => $helper->getConfig('restrict_orders'),
304
    'isAdmin'         => $helper->isUserAdmin(),
305
];
306
307
//$pathModIcon16 = $helper->getModule()->getInfo('modicons16');
308
//$pathModIcon32 = $helper->getModule()->getInfo('modicons32');
309
310
$icons2 = [
311
    'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
312
    'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
313
    'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
314
    'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
315
    'print'   => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>",
316
    'pdf'     => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>",
317
    'add'     => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>",
318
    '0'       => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>",
319
    '1'       => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>",
320
];
321
$debug  = false;
322
323
// MyTextSanitizer object
324
$myts = \MyTextSanitizer::getInstance();
325
326
if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) {
327
    require_once $GLOBALS['xoops']->path('class/template.php');
328
    $GLOBALS['xoopsTpl'] = new \XoopsTpl();
329
}
330
331
$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName);
332
// Local icons path
333
if (is_object($helper->getModule())) {
334
    $pathModIcon16 = $helper->getModule()->getInfo('modicons16');
335
    $pathModIcon32 = $helper->getModule()->getInfo('modicons32');
336
337
    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
0 ignored issues
show
Are you sure $pathModIcon16 of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

337
    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . /** @scrutinizer ignore-type */ $pathModIcon16);
Loading history...
338
    $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
339
}
340