1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* About |
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 The XOOPS Co.Ltd. http://www.xoops.com.cn |
13
|
|
|
* @copyright XOOPS Project (http://xoops.org) |
14
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
15
|
|
|
* @package about |
16
|
|
|
* @since 1.0.0 |
17
|
|
|
* @author Mengjue Shao <[email protected]> |
18
|
|
|
* @author Susheng Yang <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class AboutPage |
25
|
|
|
*/ |
26
|
|
|
class AboutPage extends XoopsObject |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* AboutPage constructor. |
30
|
|
|
*/ |
31
|
|
|
public function __construct() |
32
|
|
|
{ |
33
|
|
|
$this->initVar('page_id', XOBJ_DTYPE_INT, null, false); |
34
|
|
|
$this->initVar('page_pid', XOBJ_DTYPE_INT, 0); |
35
|
|
|
$this->initVar('page_title', XOBJ_DTYPE_TXTBOX, ''); |
36
|
|
|
$this->initVar('page_menu_title', XOBJ_DTYPE_TXTBOX, ''); |
37
|
|
|
$this->initVar('page_image', XOBJ_DTYPE_TXTBOX, ''); |
38
|
|
|
$this->initVar('page_text', XOBJ_DTYPE_TXTBOX, ''); |
39
|
|
|
$this->initVar('page_author', XOBJ_DTYPE_TXTBOX, ''); |
40
|
|
|
$this->initVar('page_pushtime', XOBJ_DTYPE_INT); |
41
|
|
|
$this->initVar('page_blank', XOBJ_DTYPE_INT, 0); |
42
|
|
|
$this->initVar('page_menu_status', XOBJ_DTYPE_INT, 0); |
43
|
|
|
$this->initVar('page_type', XOBJ_DTYPE_INT, 0); |
44
|
|
|
$this->initVar('page_status', XOBJ_DTYPE_INT, 0); |
45
|
|
|
$this->initVar('page_order', XOBJ_DTYPE_INT, 0); |
46
|
|
|
//$this->initVar('page_url', XOBJ_DTYPE_TXTBOX,""); |
|
|
|
|
47
|
|
|
$this->initVar('page_index', XOBJ_DTYPE_INT, 0); |
48
|
|
|
$this->initVar('page_tpl', XOBJ_DTYPE_TXTBOX, ''); |
49
|
|
|
$this->initVar('dohtml', XOBJ_DTYPE_INT, 1); |
50
|
|
|
$this->initVar('dosmiley', XOBJ_DTYPE_INT, 0); |
51
|
|
|
$this->initVar('doxcode', XOBJ_DTYPE_INT, 0); |
52
|
|
|
$this->initVar('doimage', XOBJ_DTYPE_INT, 0); |
53
|
|
|
$this->initVar('dobr', XOBJ_DTYPE_INT, 0); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Class AboutPageHandler |
59
|
|
|
*/ |
60
|
|
|
class AboutPageHandler extends XoopsPersistableObjectHandler |
|
|
|
|
61
|
|
|
{ |
62
|
|
|
/** |
63
|
|
|
* AboutPageHandler constructor. |
64
|
|
|
* @param null|XoopsDatabase $db |
65
|
|
|
*/ |
66
|
|
|
public function __construct(XoopsDatabase $db) |
67
|
|
|
{ |
68
|
|
|
parent::__construct($db, 'about_page', 'AboutPage', 'page_id', 'page_title'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param int $pid |
73
|
|
|
* @param string $prefix |
74
|
|
|
* @param array $tags |
75
|
|
|
* @return array |
76
|
|
|
*/ |
77
|
|
|
public function &getTrees($pid = 0, $prefix = '--', $tags = array()) |
78
|
|
|
{ |
79
|
|
|
$pid = (int)$pid; |
80
|
|
|
if (!is_array($tags) || count($tags) == 0) { |
81
|
|
|
$tags = array('page_id', 'page_pid', 'page_title', 'page_title', 'page_menu_title', 'page_status', 'page_order'); |
82
|
|
|
} |
83
|
|
|
$criteria = new CriteriaCompo(); |
84
|
|
|
$criteria->setSort('page_order'); |
85
|
|
|
$criteria->setOrder('ASC'); |
86
|
|
|
$page_tree =& $this->getAll($criteria, $tags); |
87
|
|
|
require_once __DIR__ . '/tree.php'; |
88
|
|
|
$tree = new AboutTree($page_tree); |
89
|
|
|
$page_array =& $tree->makeTree($prefix, $pid, $tags); |
90
|
|
|
|
91
|
|
|
return $page_array; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param array $pages |
96
|
|
|
* @param int $key |
97
|
|
|
* @param int $level |
98
|
|
|
* @return array|bool |
99
|
|
|
*/ |
100
|
|
|
public function &menuTree($pages = array(), $key = 0, $level = 1) |
101
|
|
|
{ |
102
|
|
|
if (!is_array($pages) || 0 === count($pages)) { |
103
|
|
|
return false; |
104
|
|
|
} |
105
|
|
|
$menu = array(); |
106
|
|
|
|
107
|
|
|
foreach ($pages as $k => $v) { |
108
|
|
|
if ($v['page_pid'] == $key) { |
109
|
|
|
$menu[$k] = $v; |
110
|
|
|
$menu[$k]['level'] = $level; |
111
|
|
|
$child =& $this->menuTree($pages, $k, $level + 1); |
112
|
|
|
if (!empty($child)) { |
113
|
|
|
$menu[$k]['child'] = $child; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
return $menu; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param array $pages |
123
|
|
|
* @param int $key |
124
|
|
|
* @return array|bool |
125
|
|
|
*/ |
126
|
|
|
public function getBread($pages = array(), $key = 0) |
127
|
|
|
{ |
128
|
|
|
if (!is_array($pages) || 0 === count($pages)) { |
129
|
|
|
return false; |
130
|
|
|
} |
131
|
|
|
$bread = array(); |
132
|
|
|
|
133
|
|
|
if (isset($pages[$key])) { |
134
|
|
|
$current = $pages[$key]; |
135
|
|
|
$bread = array($current['page_id'] => $current['page_menu_title']); |
136
|
|
|
if ($current['page_pid'] > 0) { |
137
|
|
|
$p_brend = $this->getBread($pages, $current['page_pid']); |
138
|
|
|
if (!empty($p_brend)) { |
139
|
|
|
foreach ($p_brend as $k => $v) { |
140
|
|
|
$bread[$k] = $v; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
return $bread; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/* |
|
|
|
|
150
|
|
|
function insert() |
151
|
|
|
{ |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
function delete() |
155
|
|
|
{ |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
function getAll() |
159
|
|
|
{ |
160
|
|
|
} |
161
|
|
|
*/ |
162
|
|
|
} |
163
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.