ModuleFeedback::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace XoopsModules\Wgevents\Common;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
/**
16
 * Feedback plugin for xoops modules
17
 *
18
 * @copyright      XOOPS Project  (https://xoops.org)
19
 * @license        GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
20
 * @author         Michael Beck <[email protected]>
21
 * @author         Wedega - Email:<[email protected]>
22
 * @author         Fernando Santos (topet05) <[email protected]>
23
 */
24
\defined('XOOPS_ROOT_PATH') || die('Restricted access');
25
26
/**
27
 * Class Object ModuleFeedback
28
 */
29
class ModuleFeedback extends \XoopsObject
30
{
31
    public $name    = '';
32
    public $email   = '';
33
    public $site    = '';
34
    public $type    = '';
35
    public $content = '';
36
37
    /**
38
     * Constructor
39
     *
40
     */
41
    public function __construct()
42
    {
43
    }
44
45
    /**
46
     * @static function &getInstance
47
     *
48
     */
49
    public static function getInstance()
50
    {
51
        static $instance = false;
52
        if (!$instance) {
53
            $instance = new self();
54
        }
55
    }
56
57
    /**
58
     * @public function getFormFeedback:
59
     * provide form for sending a feedback to module author
60
     * @return \XoopsThemeForm
61
     */
62
    public function getFormFeedback()
63
    {
64
        $moduleDirName      = \basename(\dirname(__DIR__, 2));
65
        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
66
        // Get Theme Form
67
        \xoops_load('XoopsFormLoader');
68
        $form = new \XoopsThemeForm(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true);
69
        $form->setExtra('enctype="multipart/form-data"');
70
71
        $recipient = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail'));
72
        $recipient->setExtra('disabled="disabled"');
73
        $form->addElement($recipient);
74
        $your_name = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name);
75
        $your_name->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME_PLACEHOLER') . '"');
76
        $form->addElement($your_name);
77
        $your_site = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE'), 'your_site', 50, 255, $this->site);
78
        $your_site->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE_PLACEHOLER') . '"');
79
        $form->addElement($your_site);
80
        $your_mail = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL'), 'your_mail', 50, 255, $this->email);
81
        $your_mail->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL_PLACEHOLER') . '"');
82
        $form->addElement($your_mail);
83
84
        $fbtypeSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE'), 'fb_type', $this->type);
85
        $fbtypeSelect->addOption('');
86
        $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'));
87
        $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'));
88
        $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'));
89
        $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'));
90
        $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'));
91
        $form->addElement($fbtypeSelect, true);
92
93
        $editorConfigs           = [];
94
        $editorConfigs['name']   = 'fb_content';
95
        $editorConfigs['value']  = $this->content;
96
        $editorConfigs['rows']   = 5;
97
        $editorConfigs['cols']   = 40;
98
        $editorConfigs['width']  = '100%';
99
        $editorConfigs['height'] = '400px';
100
        $moduleHandler           = \xoops_getHandler('module');
101
        $module                  = $moduleHandler->getByDirname('system');
0 ignored issues
show
Bug introduced by
The method getByDirname() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

101
        /** @scrutinizer ignore-call */ 
102
        $module                  = $moduleHandler->getByDirname('system');
Loading history...
102
        $configHandler           = \xoops_getHandler('config');
103
        $config                  = &$configHandler->getConfigsByCat(0, $module->getVar('mid'));
0 ignored issues
show
Bug introduced by
The method getConfigsByCat() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

103
        $config                  = &$configHandler->/** @scrutinizer ignore-call */ getConfigsByCat(0, $module->getVar('mid'));
Loading history...
104
        $editorConfigs['editor'] = $config['general_editor'];
105
        $editor                  = new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs);
106
        $form->addElement($editor, true);
107
108
        $form->addElement(new \XoopsFormHidden('op', 'send'));
109
        $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false));
110
111
        return $form;
112
    }
113
}
114