Passed
Push — master ( 93b609...1da0d9 )
by Michael
37s
created

Rating   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 38
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getForm() 0 39 3
1
<?php
2
3
namespace XoopsModules\Tdmdownloads;
4
5
/**
6
 * TDMDownload
7
 *
8
 * You may not change or alter any portion of this comment or credits
9
 * of supporting developers from this source code or any supporting source code
10
 * which is considered copyrighted (c) material of the original comment or credit authors.
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 *
15
 * @copyright   Gregory Mage (Aka Mage)
16
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 * @author      Gregory Mage (Aka Mage)
18
 */
19
defined('XOOPS_ROOT_PATH') || die('Restricted access');
20
21
/**
22
 * Class Rating
23
 * @package XoopsModules\Tdmdownloads
24
 */
25
class Rating extends \XoopsObject
26
{
27
    // constructor
28
    public function __construct()
29
    {
30
        $this->initVar('ratingid', XOBJ_DTYPE_INT, null, false, 11);
31
        $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 11);
32
        $this->initVar('ratinguser', XOBJ_DTYPE_INT, null, false, 11);
33
        $this->initVar('rating', XOBJ_DTYPE_OTHER, null, false, 3);
34
        $this->initVar('ratinghostname', XOBJ_DTYPE_TXTBOX, null, false);
35
        $this->initVar('ratingtimestamp', XOBJ_DTYPE_INT, null, false, 10);
36
    }
37
38
    /**
39
     * @param      $lid
40
     * @param bool $action
41
     *
42
     * @return \XoopsThemeForm
43
     */
44
    public function getForm($lid, $action = false)
45
    {
46
        //        global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
47
        if (false === $action) {
48
            $action = $_SERVER['REQUEST_URI'];
0 ignored issues
show
Unused Code introduced by
The assignment to $action is dead and can be removed.
Loading history...
49
        }
50
        if (!$this->isNew()) {
51
            $rating = 11;
52
        } else {
53
            $rating = $this->getVar('rating');
54
        }
55
        $form = new \XoopsThemeForm(_MD_TDMDOWNLOADS_SINGLEFILE_RATHFILE, 'rateform', 'ratefile.php', 'post');
56
        $form->setExtra('enctype="multipart/form-data"');
57
        $rating  = new \XoopsFormSelect(_MD_TDMDOWNLOADS_RATEFILE_VOTE, 'rating', $rating);
58
        $options = [
59
            '11' => '--',
60
            '10' => '10',
61
            '9'  => '9',
62
            '8'  => '8',
63
            '7'  => '7',
64
            '6'  => '6',
65
            '5'  => '5',
66
            '4'  => '4',
67
            '3'  => '3',
68
            '2'  => '2',
69
            '1'  => '1',
70
            '0'  => '0',
71
        ];
72
        $rating->addOptionArray($options);
73
        $form->addElement($rating, true);
74
        $form->addElement(new \XoopsFormCaptcha(), true);
75
        $form->addElement(new \XoopsFormHidden('op', 'save'));
76
        $form->addElement(new \XoopsFormHidden('lid', $lid));
77
        // Submit button
78
        $button_tray = new \XoopsFormElementTray('', '');
79
        $button_tray->addElement(new \XoopsFormButton('', 'post', _MD_TDMDOWNLOADS_RATEFILE_RATE, 'submit'));
80
        $form->addElement($button_tray);
81
82
        return $form;
83
    }
84
}
85