|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Mylinks; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* MyLinks category.php |
|
7
|
|
|
* |
|
8
|
|
|
* Xoops mylinks - a multicategory links module |
|
9
|
|
|
* |
|
10
|
|
|
* You may not change or alter any portion of this comment or credits |
|
11
|
|
|
* of supporting developers from this source code or any supporting source code |
|
12
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
16
|
|
|
* |
|
17
|
|
|
* @copyright :: © ZySpec Incorporated |
|
18
|
|
|
* @license :: {@link https://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
|
19
|
|
|
* @package :: mylinks |
|
20
|
|
|
* @subpackage:: class |
|
21
|
|
|
* @since :: File available since version 3.11 |
|
22
|
|
|
* @author :: zyspec ([email protected]) |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
$mylinksDir = basename(dirname(__DIR__)); |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Class mylinksCategory_base |
|
31
|
|
|
*/ |
|
32
|
|
|
class CategoryBase extends \XoopsObject |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* constructor |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
|
|
parent::__construct(); |
|
40
|
|
|
//definitions of the table field names from the database |
|
41
|
|
|
$this->initVar('cid', XOBJ_DTYPE_INT, null, false); |
|
42
|
|
|
$this->initVar('pid', XOBJ_DTYPE_INT, 0, true); |
|
43
|
|
|
$this->initVar('title', XOBJ_DTYPE_TXTBOX, null, true, 50); |
|
44
|
|
|
$this->initVar('imgurl', XOBJ_DTYPE_TXTAREA); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Returns category title using PHP5 |
|
49
|
|
|
* @return string |
|
50
|
|
|
*/ |
|
51
|
|
|
public function __toString() |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->title; |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Generates path from the root id to a given id($id) |
|
58
|
|
|
* @param int $id |
|
59
|
|
|
* @param string $path |
|
60
|
|
|
* @return string |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getPathFromId($id = null, $path = '') |
|
63
|
|
|
{ |
|
64
|
|
|
$id = isset($id) ? (int)$id : $this->cid; |
|
|
|
|
|
|
65
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
66
|
|
|
$name = $myts->htmlSpecialChars($this->title); |
|
|
|
|
|
|
67
|
|
|
$path = "/{$name}{$path}"; |
|
68
|
|
|
if (0 != $this->pid) { |
|
|
|
|
|
|
69
|
|
|
$path = $this->getPathFromId($this->pid, $path); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return $path; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|