1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Pedigree; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
You may not change or alter any portion of this comment or credits |
7
|
|
|
of supporting developers from this source code or any supporting source code |
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Pedigree module for XOOPS |
17
|
|
|
* |
18
|
|
|
* @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} |
19
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
20
|
|
|
* @package pedigree |
21
|
|
|
* @subpackage class |
22
|
|
|
* @since 1.3.1 |
23
|
|
|
* @author XOOPS Module Dev Team |
24
|
|
|
* @author ZySpec <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
use XoopsModules\Pedigree\{ |
28
|
|
|
Helper |
|
|
|
|
29
|
|
|
}; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Animal Class |
33
|
|
|
*/ |
34
|
|
|
class Animal |
35
|
|
|
{ |
36
|
|
|
protected $myTree = []; |
37
|
|
|
protected $fields = []; |
38
|
|
|
protected $configValues = []; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* class constructor |
42
|
|
|
* |
43
|
|
|
* initializes the tree array |
44
|
|
|
* @param int|null $id |
45
|
|
|
*/ |
46
|
|
|
public function __construct($id = null) |
47
|
|
|
{ |
48
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
|
|
|
|
49
|
|
|
$id = null !== $id ? (int)$id : 1; |
50
|
|
|
$myTreeHandler = Helper::getInstance()->getHandler('Tree'); |
51
|
|
|
|
52
|
|
|
$criteria = new \CriteriaCompo(); |
53
|
|
|
$criteria->add(new \Criteria('id', $id)); |
54
|
|
|
$criteria->setLimit(1); |
55
|
|
|
$this->myTree = $myTreeHandler->getAll($criteria, null, false); |
56
|
|
|
/* |
57
|
|
|
$SQL = "SELECT * FROM " . $GLOBALS['xoopsDB']->prefix("pedigree_registry") . " WHERE id = {$id}"; |
58
|
|
|
$result = $GLOBALS['xoopsDB']->query($SQL); |
59
|
|
|
$row = $GLOBALS['xoopsDB']->fetchRow($result); |
60
|
|
|
$numfields = mysqli_num_fields($result); |
61
|
|
|
for ($i = 0; $i < $numfields; ++$i) { |
62
|
|
|
$key =$GLOBALS['xoopsDB']->getFieldName($result, $i); |
63
|
|
|
$this->$key = $row[$i]; |
64
|
|
|
} |
65
|
|
|
*/ |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Number of Fields |
70
|
|
|
* @return array |
71
|
|
|
*/ |
72
|
|
|
public function getNumOfFields() |
73
|
|
|
{ |
74
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
|
|
|
|
75
|
|
|
$fieldsHandler = Helper::getInstance()->getHandler('Fields'); |
76
|
|
|
$criteria = new \CriteriaCompo(); |
77
|
|
|
$criteria->setSort('`order`'); |
78
|
|
|
$criteria->setOrder('ASC'); |
79
|
|
|
$this->fields = $fieldsHandler->getIds($criteria); //get all object IDs |
80
|
|
|
$this->configValues = $fieldsHandler->getAll($criteria, null, false); //get objects as arrays |
81
|
|
|
if (empty($this->configValues)) { |
82
|
|
|
$this->configValues = ''; |
83
|
|
|
} |
84
|
|
|
/* |
85
|
|
|
$SQL = "SELECT * FROM " . $GLOBALS['xoopsDB']->prefix("pedigree_fields") . " ORDER BY `order`"; |
86
|
|
|
$result = $GLOBALS['xoopsDB']->query($SQL); |
87
|
|
|
$fields = []; |
88
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
89
|
|
|
$fields[] = $row['id']; |
90
|
|
|
$configValues[] = $row; |
91
|
|
|
|
92
|
|
|
} |
93
|
|
|
$this->configValues = isset($configValues) ? $configValues : ''; |
94
|
|
|
//print_r ($this->configValues); exit(); |
95
|
|
|
*/ |
96
|
|
|
unset($fieldsHandler, $criteria); |
97
|
|
|
|
98
|
|
|
return $this->fields; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return array |
103
|
|
|
*/ |
104
|
|
|
public function getConfig() |
105
|
|
|
{ |
106
|
|
|
return $this->configValues; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: