1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Marquee; |
4
|
|
|
|
5
|
|
|
use XoopsDatabase; |
6
|
|
|
use XoopsPersistableObjectHandler; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* **************************************************************************** |
10
|
|
|
* marquee - MODULE FOR XOOPS |
11
|
|
|
* Copyright (c) Hervé Thouzard (https://www.herve-thouzard.com) |
12
|
|
|
* |
13
|
|
|
* You may not change or alter any portion of this comment or credits |
14
|
|
|
* of supporting developers from this source code or any supporting source code |
15
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
16
|
|
|
* This program is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
19
|
|
|
* |
20
|
|
|
* @copyright Hervé Thouzard (https://www.herve-thouzard.com) |
21
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
22
|
|
|
* @author Hervé Thouzard (https://www.herve-thouzard.com) |
23
|
|
|
* **************************************************************************** |
24
|
|
|
*/ |
25
|
|
|
//require_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
26
|
|
|
//require_once XOOPS_ROOT_PATH . '/modules/marquee/class/Utility.php'; |
27
|
|
|
//if (!class_exists('MarqueePersistableObjectHandler')) { |
28
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/marquee/class/PersistableObjectHandler.php'; |
29
|
|
|
//} |
30
|
|
|
//class MarqueeHandler extends MarqueePersistableObjectHandler |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Class MarqueeHandler |
34
|
|
|
*/ |
35
|
|
|
class MarqueexHandler extends XoopsPersistableObjectHandler //MarqueePersistableObjectHandler |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* @param \XoopsDatabase|null $db |
39
|
|
|
*/ |
40
|
|
|
public function __construct(XoopsDatabase $db = null) |
41
|
|
|
{ |
42
|
|
|
parent::__construct($db, 'marquee', Marqueex::class, 'marquee_marqueeid'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param int $selectedmarquee |
47
|
|
|
* |
48
|
|
|
* @return string |
49
|
|
|
*/ |
50
|
|
|
public function getHtmlMarqueesList($selectedmarquee = 0) |
51
|
|
|
{ |
52
|
|
|
$ret = ''; |
53
|
|
|
$tbl_marquee = $this->getObjects(); |
54
|
|
|
foreach ($tbl_marquee as $oneMarquee) { |
55
|
|
|
$selected = ''; |
56
|
|
|
if ($oneMarquee->getVar('marquee_marqueeid') == $selectedmarquee) { |
57
|
|
|
$selected = ' selected'; |
58
|
|
|
} |
59
|
|
|
$content = '' !== \xoops_trim(\strip_tags($oneMarquee->getVar('marquee_content'))) ? \xoops_substr(\strip_tags($oneMarquee->getVar('marquee_content')), 0, 50) : $oneMarquee->getVar('marquee_source'); |
60
|
|
|
$ret .= '<option ' . $selected . " value='" . $oneMarquee->getVar('marquee_marqueeid') . "'>" . $content . '</option>'; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return $ret; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Quickly insert a record like this $myobjectHandler->quickInsert('field1' => field1value, 'field2' => $field2value) |
68
|
|
|
* |
69
|
|
|
* @param array $vars Array containing the fields name and value |
70
|
|
|
* @param bool $force whether to force the query execution despite security settings |
71
|
|
|
* |
72
|
|
|
* @return bool @link insert's value |
73
|
|
|
*/ |
74
|
|
|
public function quickInsert($vars = null, $force = false) |
75
|
|
|
{ |
76
|
|
|
$object = $this->create(true); |
77
|
|
|
$object->setVars($vars); |
78
|
|
|
$retval = $this->insert($object, $force); |
79
|
|
|
unset($object); |
80
|
|
|
|
81
|
|
|
return $retval; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|