|
1
|
|
|
<?php namespace XoopsModules\Smartobject; |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* You may not change or alter any portion of this comment or credits |
|
5
|
|
|
* of supporting developers from this source code or any supporting source code |
|
6
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
* |
|
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
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @copyright XOOPS Project https://xoops.org/ |
|
15
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
|
16
|
|
|
* @package |
|
17
|
|
|
* @since |
|
18
|
|
|
* @author XOOPS Development Team |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
use XoopsLists; |
|
22
|
|
|
use XoopsModules\Smartobject; |
|
23
|
|
|
|
|
24
|
|
|
// defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
25
|
|
|
//require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartmlobject.php'; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Class SmartobjectTagHandler |
|
29
|
|
|
*/ |
|
30
|
|
|
class TagHandler extends Smartobject\PersistableMlObjectHandler |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* SmartobjectTagHandler constructor. |
|
34
|
|
|
* @param \XoopsDatabase $db |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct(\XoopsDatabase $db) |
|
37
|
|
|
{ |
|
38
|
|
|
parent::__construct($db, 'tag', 'tagid', 'name', 'description', 'smartobject'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return mixed |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getLanguages() |
|
45
|
|
|
{ |
|
46
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
47
|
|
|
$aLanguages = XoopsLists::getLangList(); |
|
48
|
|
|
$ret['default'] = _CO_SOBJECT_ALL; |
|
|
|
|
|
|
49
|
|
|
foreach ($aLanguages as $lang) { |
|
50
|
|
|
$ret[$lang] = $lang; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
return $ret; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArrayis initialized the first time when the foreach loop is entered. You can also see that the value of thebarkey is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.