ModuleFeedback   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 51
c 0
b 0
f 0
dl 0
loc 85
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 5 2
A __construct() 0 2 1
A getFormFeedback() 0 50 1
1
<?php
2
3
namespace XoopsModules\Modulebuilder\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
     * @param null
41
     */
42
    public function __construct()
43
    {
44
    }
45
46
    /**
47
     * @static function &getInstance
48
     *
49
     * @param null
50
     */
51
    public static function getInstance()
52
    {
53
        static $instance = false;
54
        if (!$instance) {
55
            $instance = new self();
56
        }
57
    }
58
59
    /**
60
     * @public function getFormFeedback:
61
     * provide form for sending a feedback to module author
62
     * @return \XoopsThemeForm
63
     */
64
    public function getFormFeedback()
65
    {
66
        $moduleDirName      = \basename(\dirname(__DIR__, 2));
67
        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
68
        // Get Theme Form
69
        \xoops_load('XoopsFormLoader');
70
        $form = new \XoopsThemeForm(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true);
71
        $form->setExtra('enctype="multipart/form-data"');
72
73
        $recipient = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail'));
74
        $recipient->setExtra('disabled="disabled"');
75
        $form->addElement($recipient);
76
        $your_name = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name);
77
        $your_name->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME_PLACEHOLER') . '"');
78
        $form->addElement($your_name);
79
        $your_site = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE'), 'your_site', 50, 255, $this->site);
80
        $your_site->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE_PLACEHOLER') . '"');
81
        $form->addElement($your_site);
82
        $your_mail = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL'), 'your_mail', 50, 255, $this->email);
83
        $your_mail->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL_PLACEHOLER') . '"');
84
        $form->addElement($your_mail);
85
86
        $fbtypeSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE'), 'fb_type', $this->type);
87
        $fbtypeSelect->addOption('', '');
88
        $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'));
89
        $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'));
90
        $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'));
91
        $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'));
92
        $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'));
93
        $form->addElement($fbtypeSelect, true);
94
95
        $editorConfigs           = [];
96
        $editorConfigs['name']   = 'fb_content';
97
        $editorConfigs['value']  = $this->content;
98
        $editorConfigs['rows']   = 5;
99
        $editorConfigs['cols']   = 40;
100
        $editorConfigs['width']  = '100%';
101
        $editorConfigs['height'] = '400px';
102
        $moduleHandler           = \xoops_getHandler('module');
103
        $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

103
        /** @scrutinizer ignore-call */ 
104
        $module                  = $moduleHandler->getByDirname('system');
Loading history...
104
        $configHandler           = \xoops_getHandler('config');
105
        $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

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