Completed
Push — master ( 819fc9...f42eea )
by Goffy
18s queued 11s
created

ModuleFeedback::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Xnewsletter\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 (http://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
25
defined('XOOPS_ROOT_PATH') || die('Restricted access');
26
27
/**
28
 * Class Object ModuleFeedback
29
 */
30
class ModuleFeedback extends \XoopsObject
31
{
32
    public $name    = '';
33
    public $email   = '';
34
    public $site    = '';
35
    public $type    = '';
36
    public $content = '';
37
38
    /**
39
     * Constructor
40
     *
41
     * @param null
42
     */
43
    public function __construct()
44
    {
45
    }
46
47
    /**
48
     * @static function &getInstance
49
     *
50
     * @param null
51
     */
52
    public static function getInstance()
53
    {
54
        static $instance = false;
55
        if (!$instance) {
56
            $instance = new self();
57
        }
58
    }
59
60
    /**
61
     * @public function getFormFeedback:
62
     * provide form for sending a feedback to module author
63
     * @param bool $action
64
     * @return \XoopsThemeForm
65
     */
66
    public function getFormFeedback($action = false)
67
    {
68
        if (false === $action) {
69
            $action = $_SERVER['REQUEST_URI'];
0 ignored issues
show
Unused Code introduced by
$action is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
70
        }
71
        $moduleDirName      = basename(dirname(dirname(__DIR__)));
72
        $moduleDirNameUpper = mb_strtoupper($moduleDirName);
73
        // Get Theme Form
74
        xoops_load('XoopsFormLoader');
75
        $form = new \XoopsThemeForm(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true);
76
        $form->setExtra('enctype="multipart/form-data"');
77
78
        $recipient = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail'));
79
        $recipient->setExtra('disabled="disabled"');
80
        $form->addElement($recipient);
81
        $your_name = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name);
82
        $your_name->setExtra('placeholder="' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME_PLACEHOLER') . '"');
83
        $form->addElement($your_name);
84
        $your_site = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE'), 'your_site', 50, 255, $this->site);
85
        $your_site->setExtra('placeholder="' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE_PLACEHOLER') . '"');
86
        $form->addElement($your_site);
87
        $your_mail = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL'), 'your_mail', 50, 255, $this->email);
88
        $your_mail->setExtra('placeholder="' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL_PLACEHOLER') . '"');
89
        $form->addElement($your_mail);
90
91
        $fbtypeSelect = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE'), 'fb_type', $this->type);
92
        $fbtypeSelect->addOption('', '');
93
        $fbtypeSelect->addOption(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'), constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'));
94
        $fbtypeSelect->addOption(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'), constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'));
95
        $fbtypeSelect->addOption(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'), constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'));
96
        $fbtypeSelect->addOption(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'), constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'));
97
        $fbtypeSelect->addOption(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'), constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'));
98
        $form->addElement($fbtypeSelect, true);
99
100
        $editorConfigs           = [];
101
        $editorConfigs['name']   = 'fb_content';
102
        $editorConfigs['value']  = $this->content;
103
        $editorConfigs['rows']   = 5;
104
        $editorConfigs['cols']   = 40;
105
        $editorConfigs['width']  = '100%';
106
        $editorConfigs['height'] = '400px';
107
        /** @var \XoopsModuleHandler $moduleHandler */
108
        $moduleHandler           = xoops_getHandler('module');
109
        $module                  = $moduleHandler->getByDirname('system');
110
        /** @var \XoopsConfigHandler $configHandler */
111
        $configHandler           = xoops_getHandler('config');
112
        $config                  = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
113
        $editorConfigs['editor'] = $config['general_editor'];
114
        $editor                  = new \XoopsFormEditor(constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs);
115
        $form->addElement($editor, true);
116
117
        $form->addElement(new \XoopsFormHidden('op', 'send'));
118
        $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false));
119
120
        return $form;
121
    }
122
}
123