ModuleFeedback   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 53
dl 0
loc 89
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFormFeedback() 0 53 2
A getInstance() 0 5 2
A __construct() 0 2 1
1
<?php
2
3
namespace XoopsModules\Soapbox\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      module for xoops
19
 * @license        GPL 2.0 or later
20
 * @package        general
21
 * @since          1.0
22
 * @min_xoops      2.5.9
23
 * @author         XOOPS - Website:<https://xoops.org>
24
 */
25
26
defined('XOOPS_ROOT_PATH') || die('Restricted access');
27
28
/**
29
 * Class Object ModuleFeedback
30
 */
31
class ModuleFeedback extends \XoopsObject
32
{
33
    public $name    = '';
34
    public $email   = '';
35
    public $site    = '';
36
    public $type    = '';
37
    public $content = '';
38
39
    /**
40
     * Constructor
41
     *
42
     * @param null
43
     */
44
    public function __construct()
45
    {
46
    }
47
48
    /**
49
     * @static function &getInstance
50
     *
51
     * @param null
52
     */
53
    public static function getInstance()
54
    {
55
        static $instance = false;
56
        if (!$instance) {
57
            $instance = new self();
58
        }
59
    }
60
61
    /**
62
     * @public function getFormFeedback:
63
     * provide form for sending a feedback to module author
64
     * @param bool $action
65
     * @return \XoopsThemeForm
66
     */
67
    public function getFormFeedback($action = false)
68
    {
69
        if (!$action) {
70
            $action = $_SERVER['REQUEST_URI'];
0 ignored issues
show
Unused Code introduced by
The assignment to $action is dead and can be removed.
Loading history...
71
        }
72
        $moduleDirName      = basename(dirname(dirname(__DIR__)));
73
        $moduleDirNameUpper = mb_strtoupper($moduleDirName);
74
        // Get Theme Form
75
        xoops_load('XoopsFormLoader');
76
        $form = new \XoopsThemeForm(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true);
77
        $form->setExtra('enctype="multipart/form-data"');
78
79
        $recipient = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail'));
80
        $recipient->setExtra('disabled="disabled"');
81
        $form->addElement($recipient);
82
        $your_name = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name);
83
        $your_name->setExtra('placeholder="' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME_PLACEHOLER') . '"');
84
        $form->addElement($your_name);
85
        $your_site = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE'), 'your_site', 50, 255, $this->site);
86
        $your_site->setExtra('placeholder="' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE_PLACEHOLER') . '"');
87
        $form->addElement($your_site);
88
        $your_mail = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL'), 'your_mail', 50, 255, $this->email);
89
        $your_mail->setExtra('placeholder="' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL_PLACEHOLER') . '"');
90
        $form->addElement($your_mail);
91
92
        $fbtypeSelect = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE'), 'fb_type', $this->type);
93
        $fbtypeSelect->addOption('', '');
94
        $fbtypeSelect->addOption(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'), constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'));
95
        $fbtypeSelect->addOption(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'), constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'));
96
        $fbtypeSelect->addOption(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'), constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'));
97
        $fbtypeSelect->addOption(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'), constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'));
98
        $fbtypeSelect->addOption(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'), constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'));
99
        $form->addElement($fbtypeSelect, true);
100
101
        $editorConfigs           = [];
102
        $editorConfigs['name']   = 'fb_content';
103
        $editorConfigs['value']  = $this->content;
104
        $editorConfigs['rows']   = 5;
105
        $editorConfigs['cols']   = 40;
106
        $editorConfigs['width']  = '100%';
107
        $editorConfigs['height'] = '400px';
108
        $moduleHandler           = xoops_getHandler('module');
109
        $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

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

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