Completed
Pull Request — master (#3)
by Michael
01:23
created

BlocksCall::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Tools;
4
5
/**
6
 * tools Module for XOOPS
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       XOOPS Project (https://xoops.org)
16
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
17
 * @package         tools
18
 * @since           2.00
19
 * @author          Susheng Yang <[email protected]>
20
 */
21
class BlocksCall extends \XoopsObject
22
{
23
    public function __construct()
24
    {
25
        $this->initVar('bid', XOBJ_DTYPE_INT, null, true);
26
        $this->initVar('mid', XOBJ_DTYPE_INT);
27
        $this->initVar('options', XOBJ_DTYPE_TXTBOX);
28
        $this->initVar('name', XOBJ_DTYPE_TXTBOX);
29
        $this->initVar('title', XOBJ_DTYPE_TXTBOX);
30
        $this->initVar('desciption', XOBJ_DTYPE_TXTBOX);
31
        $this->initVar('dirname', XOBJ_DTYPE_TXTBOX);
32
        $this->initVar('func_file', XOBJ_DTYPE_TXTBOX);
33
        $this->initVar('show_func', XOBJ_DTYPE_TXTBOX);
34
        $this->initVar('edit_func', XOBJ_DTYPE_TXTBOX);
35
        $this->initVar('template', XOBJ_DTYPE_TXTBOX);
36
        $this->initVar('tpl_content', XOBJ_DTYPE_TXTBOX);
37
        $this->initVar('bcachetime', XOBJ_DTYPE_INT);
38
        $this->initVar('bcachemodel', XOBJ_DTYPE_INT);
39
        $this->initVar('last_modified', XOBJ_DTYPE_INT);
40
    }
41
42
    /**
43
     * gets html form for editting block options
44
     */
45
    public function getOptions()
46
    {
47
        global $xoopsConfig;
48
        $edit_func = $this->getVar('edit_func');
49
        if (!$edit_func) {
50
            return false;
51
        }
52
        if (is_file(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file'))) {
53
            xoops_loadLanguage('blocks', $this->getVar('dirname'));
54
55
            require_once XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file');
56
            $options   = explode('|', $this->getVar('options'));
57
            $edit_form = $edit_func($options);
58
            if (!$edit_form) {
59
                return false;
60
            }
61
62
            return $edit_form;
63
        }
64
65
        return false;
66
    }
67
}
68