Completed
Push — master ( a1059e...55b12e )
by Michael
01:29
created

MarqueexHandler::quickInsert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php namespace XoopsModules\Marquee;
2
3
/**
4
 * ****************************************************************************
5
 * marquee - MODULE FOR XOOPS
6
 * Copyright (c) Hervé Thouzard (http://www.herve-thouzard.com)
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          Hervé Thouzard (http://www.herve-thouzard.com)
16
 * @license            http://www.fsf.org/copyleft/gpl.html GNU public license
17
 * @package            marquee
18
 * @author             Hervé Thouzard (http://www.herve-thouzard.com)
19
 * ****************************************************************************
20
 */
21
22
// defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
23
24
//require_once XOOPS_ROOT_PATH . '/kernel/object.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
44% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
25
//require_once XOOPS_ROOT_PATH . '/modules/marquee/class/Utility.php';
26
//if (!class_exists('MarqueePersistableObjectHandler')) {
27
//    require_once XOOPS_ROOT_PATH . '/modules/marquee/class/PersistableObjectHandler.php';
28
//}
29
30
31
32
//class MarqueeHandler extends MarqueePersistableObjectHandler
33
34
/**
35
 * Class MarqueeHandler
36
 */
37
class MarqueexHandler extends \XoopsPersistableObjectHandler //MarqueePersistableObjectHandler
38
{
39
    /**
40
     * @param $db
41
     */
42
    public function __construct(\XoopsDatabase $db)
43
    {
44
        parent::__construct($db, 'marquee', Marqueex::class, 'marquee_marqueeid');
45
    }
46
47
    /**
48
     * @param int $selectedmarquee
49
     *
50
     * @return string
51
     */
52
    public function getHtmlMarqueesList($selectedmarquee = 0)
53
    {
54
        $ret         = '';
55
        $tbl_marquee =& $this->getObjects();
56
        foreach ($tbl_marquee as $oneMarquee) {
57
            $selected = '';
58
            if ($oneMarquee->getVar('marquee_marqueeid') == $selectedmarquee) {
59
                $selected = ' selected';
60
            }
61
            $content = '' !== xoops_trim(strip_tags($oneMarquee->getVar('marquee_content'))) ? xoops_substr(strip_tags($oneMarquee->getVar('marquee_content')), 0, 50) : $oneMarquee->getVar('marquee_source');
62
            $ret     .= '<option ' . $selected . " value='" . $oneMarquee->getVar('marquee_marqueeid') . "'>" . $content . '</option>';
63
        }
64
65
        return $ret;
66
    }
67
68
    /**
69
     * Quickly insert a record like this $myobjectHandler->quickInsert('field1' => field1value, 'field2' => $field2value)
70
     *
71
     * @param array $vars  Array containing the fields name and value
0 ignored issues
show
Documentation introduced by
Should the type for parameter $vars not be array|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
72
     * @param bool  $force whether to force the query execution despite security settings
73
     *
74
     * @return bool @link insert's value
75
     */
76
    public function quickInsert($vars = null, $force = false)
77
    {
78
        $object = $this->create(true);
79
        $object->setVars($vars);
80
        $retval = $this->insert($object, $force);
81
        unset($object);
82
83
        return $retval;
84
    }
85
}
86