Completed
Push — master ( 2e7c79...ac9b98 )
by Gino
06:29 queued 03:01
created

TDMCreateModules::getDefinedLanguage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 34 and the first side effect is on line 25.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * modules class.
15
 *
16
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
17
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
18
 *
19
 * @since           2.5.7
20
 *
21
 * @author          Txmod Xoops <[email protected]> - <http://www.txmodxoops.org/>
22
 *
23
 * @version         $Id: 1.91 modules.php 13040 2015-04-25 15:12:12Z timgno $
24
 */
25
include __DIR__.'/autoload.php';
26
/*
27
*  @Class TDMCreateModules
28
*  @extends XoopsObject
29
*/
30
31
/**
32
 * Class TDMCreateModules.
33
 */
34
class TDMCreateModules extends XoopsObject
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
35
{    
0 ignored issues
show
Coding Style introduced by
The opening class brace should be on a newline by itself.
Loading history...
36
    /**
37
     * Options.
38
     */
39
    public $options = array(
40
        'admin',
41
        'user',
42
        'blocks',
43
        'search',
44
        'comments',
45
        'notifications',
46
        'permissions',
47
        'inroot_copy',
48
    );
49
50
    /*
51
    *  @public function constructor class
52
    *  @param null
53
    */
54
    /**
55
     *
56
     */
57
    public function __construct()
58
    {
59
        $tdmcreate = TDMCreateHelper::getInstance();
60
        $setId = XoopsRequest::getInt('set_id');
61
        $settings = $tdmcreate->getHandler('settings')->get($setId);
0 ignored issues
show
Bug introduced by
The method get cannot be called on $tdmcreate->getHandler('settings') (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
62
        //
63
        $this->initVar('mod_id', XOBJ_DTYPE_INT);
64
        $this->initVar('mod_name', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_name'));
65
        $this->initVar('mod_dirname', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_dirname'));
66
        $this->initVar('mod_version', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_version'));
67
        $this->initVar('mod_since', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_since'));
68
        $this->initVar('mod_min_php', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_min_php'));
69
        $this->initVar('mod_min_xoops', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_min_xoops'));
70
        $this->initVar('mod_min_admin', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_min_admin'));
71
        $this->initVar('mod_min_mysql', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_min_mysql'));
72
        $this->initVar('mod_description', XOBJ_DTYPE_TXTAREA, $settings->getVar('set_description'));
73
        $this->initVar('mod_author', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_author'));
74
        $this->initVar('mod_author_mail', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_author_mail'));
75
        $this->initVar('mod_author_website_url', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_author_website_url'));
76
        $this->initVar('mod_author_website_name', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_author_website_name'));
77
        $this->initVar('mod_credits', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_credits'));
78
        $this->initVar('mod_license', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_license'));
79
        $this->initVar('mod_release_info', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_release_info'));
80
        $this->initVar('mod_release_file', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_release_file'));
81
        $this->initVar('mod_manual', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_manual'));
82
        $this->initVar('mod_manual_file', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_manual_file'));
83
        $this->initVar('mod_image', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_image'));
84
        $this->initVar('mod_demo_site_url', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_demo_site_url'));
85
        $this->initVar('mod_demo_site_name', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_demo_site_name'));
86
        $this->initVar('mod_support_url', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_support_url'));
87
        $this->initVar('mod_support_name', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_support_name'));
88
        $this->initVar('mod_website_url', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_website_url'));
89
        $this->initVar('mod_website_name', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_website_name'));
90
        $this->initVar('mod_release', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_release'));
91
        $this->initVar('mod_status', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_status'));
92
        $this->initVar('mod_admin', XOBJ_DTYPE_INT, $settings->getVar('set_admin'));
93
        $this->initVar('mod_user', XOBJ_DTYPE_INT, $settings->getVar('set_user'));
94
        $this->initVar('mod_blocks', XOBJ_DTYPE_INT, $settings->getVar('set_blocks'));
95
        $this->initVar('mod_search', XOBJ_DTYPE_INT, $settings->getVar('set_search'));
96
        $this->initVar('mod_comments', XOBJ_DTYPE_INT, $settings->getVar('set_comments'));
97
        $this->initVar('mod_notifications', XOBJ_DTYPE_INT, $settings->getVar('set_notifications'));
98
        $this->initVar('mod_permissions', XOBJ_DTYPE_INT, $settings->getVar('set_permissions'));
99
        $this->initVar('mod_inroot_copy', XOBJ_DTYPE_INT, $settings->getVar('set_inroot_copy'));
100
        $this->initVar('mod_donations', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_donations'));
101
        $this->initVar('mod_subversion', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_subversion'));
102
    }
103
104
    /**
105
     * @param string $method
106
     * @param array  $args
107
     *
108
     * @return mixed
109
     */
110
    public function __call($method, $args)
111
    {
112
        $arg = isset($args[0]) ? $args[0] : null;
113
114
        return $this->getVar($method, $arg);
115
    }
116
117
    /*
118
    *  @static function &getInstance
119
    *  @param null
120
    */
121
    /**
122
     * @return TDMCreateModules
123
     */
124
    public static function &getInstance()
125
    {
126
        static $instance = false;
127
        if (!$instance) {
128
            $instance = new self();
129
        }
130
131
        return $instance;
132
    }
133
134
    /*
135
    *  @public function getFormModules
136
    *  @param mixed $action
137
    */
138
    /**
139
     * @param bool $action
140
     *
141
     * @return XoopsThemeForm
142
     */
143
    public function getFormModules($action = false)
144
    {
145
        $tdmcreate = TDMCreateHelper::getInstance();
146
        if ($action === false) {
147
            $action = $_SERVER['REQUEST_URI'];
148
        }
149
        $set = array();
150
        $settings = $tdmcreate->getHandler('settings')->getAllSettings(0, 0, 'set_type');
0 ignored issues
show
Bug introduced by
The method getAllSettings cannot be called on $tdmcreate->getHandler('settings') (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
151
        foreach ($settings as $setting) {
152
            $set['name'] = $setting->getVar('set_name');
153
            $set['dirname'] = $setting->getVar('set_dirname');
154
            $set['version'] = $setting->getVar('set_version');
155
            $set['since'] = $setting->getVar('set_since');
156
            $set['min_php'] = $setting->getVar('set_min_php');
157
            $set['min_xoops'] = $setting->getVar('set_min_xoops');
158
            $set['min_admin'] = $setting->getVar('set_min_admin');
159
            $set['min_mysql'] = $setting->getVar('set_min_mysql');
160
            $set['description'] = $setting->getVar('set_description');
161
            $set['author'] = $setting->getVar('set_author');
162
            $set['license'] = $setting->getVar('set_license');
163
            $set['admin'] = $setting->getVar('set_admin');
164
            $set['user'] = $setting->getVar('set_user');
165
            $set['blocks'] = $setting->getVar('set_blocks');
166
            $set['search'] = $setting->getVar('set_search');
167
            $set['comments'] = $setting->getVar('set_comments');
168
            $set['notifications'] = $setting->getVar('set_notifications');
169
            $set['permissions'] = $setting->getVar('set_permissions');
170
            $set['inroot'] = $setting->getVar('set_inroot_copy');
171
            $set['image'] = $setting->getVar('set_image');
172
            $set['author_mail'] = $setting->getVar('set_author_mail');
173
            $set['author_website_url'] = $setting->getVar('set_author_website_url');
174
            $set['author_website_name'] = $setting->getVar('set_author_website_name');
175
            $set['credits'] = $setting->getVar('set_credits');
176
            $set['release_info'] = $setting->getVar('set_release_info');
177
            $set['release_file'] = $setting->getVar('set_release_file');
178
            $set['manual'] = $setting->getVar('set_manual');
179
            $set['manual_file'] = $setting->getVar('set_manual_file');
180
            $set['demo_site_url'] = $setting->getVar('set_demo_site_url');
181
            $set['demo_site_name'] = $setting->getVar('set_demo_site_name');
182
            $set['support_url'] = $setting->getVar('set_support_url');
183
            $set['support_name'] = $setting->getVar('set_support_name');
184
            $set['website_url'] = $setting->getVar('set_website_url');
185
            $set['website_name'] = $setting->getVar('set_website_name');
186
            $set['release'] = $setting->getVar('set_release');
187
            $set['status'] = $setting->getVar('set_status');
188
            $set['donations'] = $setting->getVar('set_donations');
189
            $set['subversion'] = $setting->getVar('set_subversion');
190
        }
191
        //
192
        $isNew = $this->isNew();
193
        $title = $isNew ? sprintf(_AM_TDMCREATE_MODULE_NEW) : sprintf(_AM_TDMCREATE_MODULE_EDIT);
194
        //
195
        include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
196
        //
197
        $form = new XoopsThemeForm($title, 'moduleform', $action, 'post', true);
198
        $form->setExtra('enctype="multipart/form-data"');
199
        //
200
        $modName = $isNew ? $set['name'] : $this->getVar('mod_name');
201
        $modName = new XoopsFormText(_AM_TDMCREATE_MODULE_NAME, 'mod_name', 50, 255, $modName);
202
        $modName->setDescription(_AM_TDMCREATE_MODULE_NAME_DESC);
203
        $form->addElement($modName, true);
204
        //
205
        $modDirname = $isNew ? $set['dirname'] : $this->getVar('mod_dirname');
206
        $modDirname = new XoopsFormText(_AM_TDMCREATE_MODULE_DIRNAME, 'mod_dirname', 25, 255, $modDirname);
207
        $modDirname->setDescription(_AM_TDMCREATE_MODULE_DIRNAME_DESC);
208
        $form->addElement($modDirname, true);
209
        //
210
        $modVersion = $isNew ? $set['version'] : $this->getVar('mod_version');
211
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_VERSION, 'mod_version', 10, 25, $modVersion), true);
212
        //
213
        $modSince = $isNew ? $set['since'] : $this->getVar('mod_since');
214
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_SINCE, 'mod_since', 10, 25, $modSince), true);
215
        //
216
        $modMinPhp = $isNew ? $set['min_php'] : $this->getVar('mod_min_php');
217
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MIN_PHP, 'mod_min_php', 10, 25, $modMinPhp), true);
218
        //
219
        $modMinXoops = $isNew ? $set['min_xoops'] : $this->getVar('mod_min_xoops');
220
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MIN_XOOPS, 'mod_min_xoops', 10, 25, $modMinXoops), true);
221
        //
222
        $modMinAdmin = $isNew ? $set['min_admin'] : $this->getVar('mod_min_admin');
223
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MIN_ADMIN, 'mod_min_admin', 10, 25, $modMinAdmin), true);
224
        //
225
        $modMinMysql = $isNew ? $set['min_mysql'] : $this->getVar('mod_min_mysql');
226
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MIN_MYSQL, 'mod_min_mysql', 10, 25, $modMinMysql), true);
227
        // Name description
228
        $editorConfigs = array();
229
        $editorConfigs['name'] = 'mod_description';
230
        $editorConfigs['value'] = $isNew ? $set['description'] : $this->getVar('mod_description', 'e');
231
        $editorConfigs['rows'] = 5;
232
        $editorConfigs['cols'] = 100;
233
        $editorConfigs['width'] = '50%';
234
        $editorConfigs['height'] = '100px';
235
        $editorConfigs['editor'] = $tdmcreate->getConfig('tdmcreate_editor');
236
        $form->addElement(new XoopsFormEditor(_AM_TDMCREATE_MODULE_DESCRIPTION, 'mod_description', $editorConfigs), true);
237
        // Author
238
        $modAuthor = $isNew ? $set['author'] : $this->getVar('mod_author');
239
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR, 'mod_author', 50, 255, $modAuthor), true);
240
        $modLicense = $isNew ? $set['license'] : $this->getVar('mod_license');
241
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_LICENSE, 'mod_license', 50, 255, $modLicense), true);
242
        //
243
        $optionsTray = new XoopsFormElementTray(_OPTIONS, '<br />');
244
        $optionsTray->setDescription(_AM_TDMCREATE_OPTIONS_DESC);
245
        // Check All Modules Options
246
        $checkAllOptions = new XoopsFormCheckBox('', 'modulebox', 1);
247
        $checkAllOptions->addOption('allbox', _AM_TDMCREATE_MODULE_ALL);
248
        $checkAllOptions->setExtra(' onclick="xoopsCheckAll(\'moduleform\', \'modulebox\');" ');
249
        $checkAllOptions->setClass('xo-checkall');
250
        $optionsTray->addElement($checkAllOptions);
251
        // Options
252
        $checkbox = new XoopsFormCheckbox(' ', 'module_option', $this->getOptionsModules(), '<br />');
253
        foreach ($this->options as $option) {
254
            $checkbox->addOption($option, self::getDefinedLanguage('_AM_TDMCREATE_MODULE_'.strtoupper($option)));
255
        }
256
        $optionsTray->addElement($checkbox);
257
        //
258
        $form->addElement($optionsTray);
259
        //
260
        $modImage = $this->getVar('mod_image');
261
        $modImage = $modImage ? $modImage : $set['image'];
262
        //
263
        $uploadDirectory = 'uploads/'.$GLOBALS['xoopsModule']->dirname().'/images/modules';
264
        $imgtray = new XoopsFormElementTray(_AM_TDMCREATE_MODULE_IMAGE, '<br />');
265
        $imgpath = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, './'.strtolower($uploadDirectory).'/');
266
        $imageselect = new XoopsFormSelect($imgpath, 'mod_image', $modImage);
267
        $modImageArray = XoopsLists::getImgListAsArray(TDMC_UPLOAD_IMGMOD_PATH);
268
        foreach ($modImageArray as $image) {
269
            $imageselect->addOption("{$image}", $image);
270
        }
271
        $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"mod_image\", \"".$uploadDirectory.'", "", "'.XOOPS_URL."\")'");
272
        $imgtray->addElement($imageselect);
273
        $imgtray->addElement(new XoopsFormLabel('', "<br /><img src='".TDMC_UPLOAD_IMGMOD_URL.'/'.$modImage."' name='image3' id='image3' alt='' /><br />"));
274
        //
275
        $fileseltray = new XoopsFormElementTray('', '<br />');
276
        $fileseltray->addElement(new XoopsFormFile(_AM_TDMCREATE_FORMUPLOAD, 'attachedfile', $tdmcreate->getConfig('maxsize')));
277
        $fileseltray->addElement(new XoopsFormLabel(''));
278
        $imgtray->addElement($fileseltray);
279
        $form->addElement($imgtray);
280
        //---------- START LOGO GENERATOR -----------------
281
        $tables_img = $this->getVar('table_image') ?: 'about.png';
282
        $iconsdir = '/Frameworks/moduleclasses/icons/32';
283
        if (is_dir(XOOPS_ROOT_PATH.$iconsdir)) {
284
            $uploadDirectory = $iconsdir;
285
            $imgpath = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, ".{$iconsdir}/");
286
        } else {
287
            $uploadDirectory = '/uploads/'.$GLOBALS['xoopsModule']->dirname().'/images/tables';
288
            $imgpath = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, './uploads/'.$GLOBALS['xoopsModule']->dirname().'/images/tables');
289
        }
290
        $createLogoTray = new XoopsFormElementTray(_AM_TDMCREATE_MODULE_CREATENEWLOGO, '<br />');
291
        $iconSelect = new XoopsFormSelect($imgpath, 'tables_img', $tables_img, 8);
292
        $tablesImagesArray = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH.$uploadDirectory);
293
        foreach ($tablesImagesArray as $image) {
294
            $iconSelect->addOption("{$image}", $image);
295
        }
296
        $iconSelect->setExtra(" onchange='showImgSelected2(\"image4\", \"tables_img\", \"".$uploadDirectory.'", "", "'.XOOPS_URL."\")' ");
297
        $createLogoTray->addElement($iconSelect);
298
        $createLogoTray->addElement(new XoopsFormLabel('', "<br /><img src='".XOOPS_URL.'/'.$uploadDirectory.'/'.$tables_img."' name='image4' id='image4' alt='' />"));
299
        // Create preview and submit buttons
300
        $buttonLogoGenerator4 = new XoopsFormButton('', 'button4', _AM_TDMCREATE_MODULE_CREATENEWLOGO, 'button');
301
        $buttonLogoGenerator4->setExtra(" onclick='createNewModuleLogo(\"".TDMC_URL."\")' ");
302
        $createLogoTray->addElement($buttonLogoGenerator4);
303
        //
304
        $form->addElement($createLogoTray);
305
        //------------ END LOGO GENERATOR --------------------
306
        //
307
        $modAuthorMail = $isNew ? $set['author_mail'] : $this->getVar('mod_author_mail');
308
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR_MAIL, 'mod_author_mail', 50, 255, $modAuthorMail));
309
        //
310
        $modAuthorWebsiteUrl = $isNew ? $set['author_website_url'] : $this->getVar('mod_author_website_url');
311
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR_WEBSITE_URL, 'mod_author_website_url', 50, 255, $modAuthorWebsiteUrl));
312
        //
313
        $modAuthorWebsiteName = $isNew ? $set['author_website_name'] : $this->getVar('mod_author_website_name');
314
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR_WEBSITE_NAME, 'mod_author_website_name', 50, 255, $modAuthorWebsiteName));
315
        //
316
        $modCredits = $isNew ? $set['credits'] : $this->getVar('mod_credits');
317
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_CREDITS, 'mod_credits', 50, 255, $modCredits));
318
        //
319
        $modReleaseInfo = $isNew ? $set['release_info'] : $this->getVar('mod_release_info');
320
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_RELEASE_INFO, 'mod_release_info', 50, 255, $modReleaseInfo));
321
        //
322
        $modReleaseFile = $isNew ? $set['release_file'] : $this->getVar('mod_release_file');
323
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_RELEASE_FILE, 'mod_release_file', 50, 255, $modReleaseFile));
324
        //
325
        $modManual = $isNew ? $set['manual'] : $this->getVar('mod_manual');
326
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MANUAL, 'mod_manual', 50, 255, $modManual));
327
        //
328
        $modManualFile = $isNew ? $set['manual_file'] : $this->getVar('mod_manual_file');
329
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MANUAL_FILE, 'mod_manual_file', 50, 255, $modManualFile));
330
        //
331
        $modDemoSiteUrl = $isNew ? $set['demo_site_url'] : $this->getVar('mod_demo_site_url');
332
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_DEMO_SITE_URL, 'mod_demo_site_url', 50, 255, $modDemoSiteUrl));
333
        //
334
        $modDemoSiteName = $isNew ? $set['demo_site_name'] : $this->getVar('mod_demo_site_name');
335
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_DEMO_SITE_NAME, 'mod_demo_site_name', 50, 255, $modDemoSiteName));
336
        //
337
        $modSupportUrl = $isNew ? $set['support_url'] : $this->getVar('mod_support_url');
338
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_SUPPORT_URL, 'mod_support_url', 50, 255, $modSupportUrl));
339
        //
340
        $modSupportName = $isNew ? $set['support_name'] : $this->getVar('mod_support_name');
341
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_SUPPORT_NAME, 'mod_support_name', 50, 255, $modSupportName));
342
        //
343
        $modWebsiteUrl = $isNew ? $set['website_url'] : $this->getVar('mod_website_url');
344
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_WEBSITE_URL, 'mod_website_url', 50, 255, $modWebsiteUrl));
345
        //
346
        $modWebsiteName = $isNew ? $set['website_name'] : $this->getVar('mod_website_name');
347
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_WEBSITE_NAME, 'mod_website_name', 50, 255, $modWebsiteName));
348
        //
349
        $modRelease = $isNew ? $set['release'] : $this->getVar('mod_release');
350
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_RELEASE, 'mod_release', 50, 255, $modRelease));
351
        //
352
        $modStatus = $isNew ? $set['status'] : $this->getVar('mod_status');
353
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_STATUS, 'mod_status', 50, 255, $modStatus));
354
        //
355
        $modDonations = $isNew ? $set['donations'] : $this->getVar('mod_donations');
356
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_PAYPAL_BUTTON, 'mod_donations', 50, 255, $modDonations));
357
        //
358
        $modSubversion = $isNew ? $set['subversion'] : $this->getVar('mod_subversion');
359
        $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_SUBVERSION, 'mod_subversion', 50, 255, $modSubversion));
360
        //
361
        $buttonTray = new XoopsFormElementTray(_REQUIRED.' <sup class="red bold">*</sup>', '');
362
        $buttonTray->addElement(new XoopsFormHidden('op', 'save'));
363
        $buttonTray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
364
        $form->addElement($buttonTray);
365
366
        return $form;
367
    }
368
    
369
    /**
370
     * Get Values.
371
     */
372
    public function getValuesModules($keys = null, $format = null, $maxDepth = null)
373
    {
374
        $ret = $this->getValues($keys, $format, $maxDepth);
375
        // Values
376
        $ret['id'] = $this->getVar('mod_id');
377
        $ret['name'] = $this->getVar('mod_name');
378
        $ret['version'] = $this->getVar('mod_version');
379
        $ret['image'] = $this->getVar('mod_image');
380
        $ret['release'] = $this->getVar('mod_release');
381
        $ret['status'] = $this->getVar('mod_status');
382
        $ret['admin'] = $this->getVar('mod_admin');
383
        $ret['user'] = $this->getVar('mod_user');
384
        $ret['blocks'] = $this->getVar('mod_blocks');
385
        $ret['search'] = $this->getVar('mod_search');
386
        $ret['comments'] = $this->getVar('mod_comments');
387
        $ret['notifications'] = $this->getVar('mod_notifications');
388
        $ret['permissions'] = $this->getVar('mod_permissions');
389
390
        return $ret;
391
    }
392
393
    /**
394
     * Get Options.
395
     */
396
    /**
397
     * @param $key
398
     *
399
     * @return string
400
     */
401
    private function getOptionsModules()
402
    {
403
        $retModules = array();
404
        foreach ($this->options as $option) {
405
            if ($this->getVar('mod_'.$option) == 1) {
406
                array_push($retModules, $option);
407
            }
408
        }
409
410
        return $retModules;
411
    }
412
413
    /**
414
     * Get Defined Language.
415
     */
416
    /**
417
     * @param $lang
418
     *
419
     * @return string
420
     */
421
    private static function getDefinedLanguage($lang)
422
    {
423
        if (defined($lang)) {
424
            return constant($lang);
425
        }
426
427
        return $lang;
428
    }
429
}
430
431
/*
432
*  @Class TDMCreateModulesHandler
433
*  @extends XoopsPersistableObjectHandler
434
*/
435
436
/**
437
 * Class TDMCreateModulesHandler.
438
 */
439
class TDMCreateModulesHandler extends XoopsPersistableObjectHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
440
{
441
    /*
442
    *  @public function constructor class
443
    *  @param mixed $db
444
    */
445
    /**
446
     * @param null|object $db
447
     */
448
    public function __construct(&$db)
449
    {
450
        parent::__construct($db, 'tdmcreate_modules', 'tdmcreatemodules', 'mod_id', 'mod_name');
451
    }
452
453
    /**
454
     * @param bool $isNew
455
     *
456
     * @return object
457
     */
458
    public function &create($isNew = true)
459
    {
460
        return parent::create($isNew);
461
    }
462
463
    /**
464
     * retrieve a field.
465
     *
466
     * @param int  $i      field id
467
     * @param null $fields
468
     *
469
     * @return mixed reference to the <a href='psi_element://TDMCreateFields'>TDMCreateFields</a> object
470
     *               object
471
     */
472
    public function &get($i = null, $fields = null)
473
    {
474
        return parent::get($i, $fields);
475
    }
476
477
    /**
478
     * get inserted id.
479
     *
480
     * @param null
481
     *
482
     * @return int reference to the {@link TDMCreateTables} object
483
     */
484
    public function &getInsertId()
485
    {
486
        return $this->db->getInsertId();
487
    }
488
489
    /**
490
     * insert a new field in the database.
491
     *
492
     * @param object $field reference to the {@link TDMCreateFields} object
493
     * @param bool   $force
494
     *
495
     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
496
     */
497
    public function &insert(&$field, $force = false)
498
    {
499
        if (!parent::insert($field, $force)) {
500
            return false;
501
        }
502
503
        return true;
504
    }
505
506
    /**
507
     * Get Count Modules.
508
     */
509
    public function getCountModules($start = 0, $limit = 0, $sort = 'mod_id ASC, mod_name', $order = 'ASC')
510
    {
511
        $criteriaCountModules = new CriteriaCompo();
512
        $criteriaCountModules = $this->getModulesCriteria($criteriaCountModules, $start, $limit, $sort, $order);
513
514
        return $this->getCount($criteriaCountModules);
515
    }
516
517
    /**
518
     * Get All Modules.
519
     */
520
    public function getAllModules($start = 0, $limit = 0, $sort = 'mod_id ASC, mod_name', $order = 'ASC')
521
    {
522
        $criteriaAllModules = new CriteriaCompo();
523
        $criteriaAllModules = $this->getModulesCriteria($criteriaAllModules, $start, $limit, $sort, $order);
524
525
        return $this->getAll($criteriaAllModules);
526
    }
527
528
    /**
529
     * Get Modules Criteria.
530
     */
531
    private function getModulesCriteria($criteriaModules, $start, $limit, $sort, $order)
532
    {
533
        $criteriaModules->setStart($start);
534
        $criteriaModules->setLimit($limit);
535
        $criteriaModules->setSort($sort);
536
        $criteriaModules->setOrder($order);
537
538
        return $criteriaModules;
539
    }
540
}
541