Completed
Pull Request — master (#2)
by Michael
02:01
created

ToolsBlocksCall::ToolsBlocksCall()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * tools Module for XOOPS
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright       XOOPS Project (http://xoops.org)
13
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
14
 * @package         tools
15
 * @since           2.00
16
 * @author          Susheng Yang <[email protected]>
17
 */
18
defined('XOOPS_ROOT_PATH') || exit('XOOPS Root Path not defined');
19
20
/**
21
 * Class ToolsBlocksCall
22
 */
23
class ToolsBlocksCall extends XoopsObject
24
{
25
    /**
26
     * ToolsBlocksCall constructor.
27
     */
28
    public function __construct()
29
    {
30
        $this->initVar('bid', XOBJ_DTYPE_INT, null, true);
31
        $this->initVar('mid', XOBJ_DTYPE_INT);
32
        $this->initVar('options', XOBJ_DTYPE_TXTBOX);
33
        $this->initVar('name', XOBJ_DTYPE_TXTBOX);
34
        $this->initVar('title', XOBJ_DTYPE_TXTBOX);
35
        $this->initVar('desciption', XOBJ_DTYPE_TXTBOX);
36
        $this->initVar('dirname', XOBJ_DTYPE_TXTBOX);
37
        $this->initVar('func_file', XOBJ_DTYPE_TXTBOX);
38
        $this->initVar('show_func', XOBJ_DTYPE_TXTBOX);
39
        $this->initVar('edit_func', XOBJ_DTYPE_TXTBOX);
40
        $this->initVar('template', XOBJ_DTYPE_TXTBOX);
41
        $this->initVar('tpl_content', XOBJ_DTYPE_TXTBOX);
42
        $this->initVar('bcachetime', XOBJ_DTYPE_INT);
43
        $this->initVar('bcachemodel', XOBJ_DTYPE_INT);
44
        $this->initVar('last_modified', XOBJ_DTYPE_INT);
45
    }
46
47
    /**
48
     * gets html form for editting block options
49
     *
50
     */
51
    public function getOptions()
52
    {
53
        global $xoopsConfig;
54
        $edit_func = $this->getVar('edit_func');
55
        if (!$edit_func) {
56
            return false;
57
        }
58
        if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file'))) {
59
            if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/blocks.php')) {
60
                require_once XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/blocks.php';
61
            } elseif (file_exists(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/english/blocks.php')) {
62
                require_once XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/english/blocks.php';
63
            }
64
            require_once XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file');
65
            $options   = explode('|', $this->getVar('options'));
66
            $edit_form = $edit_func($options);
67
            if (!$edit_form) {
68
                return false;
69
            }
70
71
            return $edit_form;
72
        }
73
74
        return false;
75
    }
76
}
77
78
/**
79
 * Class ToolsBlocksCallHandler
80
 */
81
class ToolsBlocksCallHandler extends XoopsPersistableObjectHandler
82
{
83
    /**
84
     * ToolsBlocksCallHandler constructor.
85
     * @param null|\XoopsDatabase $db
86
     */
87
    public function __construct($db)
88
    {
89
        parent::__construct($db, 'tools_blocks', 'ToolsBlocksCall', 'bid', 'name');
90
    }
91
}
92