1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* **************************************************************************** |
4
|
|
|
* marquee - MODULE FOR XOOPS |
5
|
|
|
* Copyright (c) Hervé Thouzard (http://www.herve-thouzard.com) |
6
|
|
|
* |
7
|
|
|
* You may not change or alter any portion of this comment or credits |
8
|
|
|
* of supporting developers from this source code or any supporting source code |
9
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
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
|
|
|
* @copyright Hervé Thouzard (http://www.herve-thouzard.com) |
15
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
16
|
|
|
* @package marquee |
17
|
|
|
* @author Hervé Thouzard (http://www.herve-thouzard.com) |
18
|
|
|
* |
19
|
|
|
* Version : |
20
|
|
|
* **************************************************************************** |
21
|
|
|
* |
22
|
|
|
* @param $options |
23
|
|
|
* |
24
|
|
|
* @return array |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
use XoopsModules\Marquee; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param $options |
31
|
|
|
* @return array |
32
|
|
|
*/ |
33
|
|
|
function b_marquee_show($options) |
34
|
|
|
{ |
35
|
|
|
global $xoopsTpl; |
|
|
|
|
36
|
|
|
$marquee = null; |
|
|
|
|
37
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/marquee/class/Utility.php'; |
38
|
|
|
$marqueeHandler = XoopsModules\Marquee\Helper::getInstance()->getHandler('Marqueex'); |
39
|
|
|
$block = []; |
40
|
|
|
$marqueeId = (int)$options[0]; |
41
|
|
|
if ($marqueeId > 0) { |
42
|
|
|
/** @var Marquee\Marqueex $marquee */ |
43
|
|
|
$marquee = $marqueeHandler->get($marqueeId); |
44
|
|
|
if (is_object($marquee)) { |
45
|
|
|
$uniqid = md5(uniqid(mt_rand(), true)); |
46
|
|
|
if ('DHTML' === Marquee\Utility::getModuleOption('methodtouse')) { |
|
|
|
|
47
|
|
|
$link = '<script type="text/javascript" src="' . XOOPS_URL . '/modules/marquee/assets/js/xbMarquee.js"></script>'; |
|
|
|
|
48
|
|
|
$link .= "\n<script type=\"text/javascript\">\n"; |
49
|
|
|
$link .= 'var marquee' . $uniqid . ";\n"; |
50
|
|
|
$link .= "var html$uniqid = '';\n"; |
51
|
|
|
$link .= "function init_$uniqid()\n"; |
52
|
|
|
$link .= "{\n"; |
53
|
|
|
$link .= "\tmarquee$uniqid.start();\n"; |
54
|
|
|
$link .= "}\n"; |
55
|
|
|
$link .= "</script>\n"; |
56
|
|
|
$xoopsTpl->assign('xoops_module_header', $link); |
57
|
|
|
} |
58
|
|
|
$block['marqueecode'] = $marquee->constructMarquee($uniqid); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $block; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param $options |
67
|
|
|
* |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
function b_marquee_edit($options) |
71
|
|
|
{ |
72
|
|
|
/** @var Marquee\MarqueexHandler $marqueeHandler */ |
73
|
|
|
$marqueeHandler = Marquee\Helper::getInstance()->getHandler('Marqueex'); |
74
|
|
|
$form = "<table border='0'>"; |
75
|
|
|
$form .= '<tr><td>' . _MB_MARQUEE_SELECT . "</td><td><select name='options[0]'>" . $marqueeHandler->getHtmlMarqueesList($options[0]) . '</select></td></tr>'; |
76
|
|
|
$form .= '</table>'; |
77
|
|
|
|
78
|
|
|
return $form; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/* |
82
|
|
|
* Block on the fly |
83
|
|
|
*/ |
84
|
|
|
/** |
85
|
|
|
* @param $options |
86
|
|
|
*/ |
87
|
|
|
function b_marquee_custom($options) |
88
|
|
|
{ |
89
|
|
|
$options = explode('|', $options); |
90
|
|
|
$block = b_marquee_show($options); |
91
|
|
|
|
92
|
|
|
$tpl = new \XoopsTpl(); |
|
|
|
|
93
|
|
|
$tpl->assign('block', $block); |
94
|
|
|
$tpl->display('db:marquee_block.tpl'); |
95
|
|
|
} |
96
|
|
|
|
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state