|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
You may not change or alter any portion of this comment or credits |
|
4
|
|
|
of supporting developers from this source code or any supporting source code |
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
/** |
|
12
|
|
|
* Pedigree module for XOOPS |
|
13
|
|
|
* |
|
14
|
|
|
* @copyright {@link http://sourceforge.net/projects/thmod/ The TXMod XOOPS Project} |
|
15
|
|
|
* @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} |
|
16
|
|
|
* @license GPL 2.0 or later |
|
17
|
|
|
* @package pedigree |
|
18
|
|
|
* @subpackage class |
|
19
|
|
|
* @author XOOPS Mod Development Team |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class Animal |
|
24
|
|
|
*/ |
|
25
|
|
|
class PedigreeAnimal |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
protected $dirname; |
|
28
|
|
|
protected $configValues = array(); |
|
29
|
|
|
/** |
|
30
|
|
|
* @param int $animalnumber {@internal param int $id animal Id}} |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct($animalnumber = 0) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->dirname = basename(dirname(__DIR__)); |
|
35
|
|
|
$animalNum = (0 == (int)$animalnumber) ? 1 : (int)$animalnumber; |
|
36
|
|
|
$ptreeHandler = xoops_getModuleHandler('tree', $this->dirname); |
|
37
|
|
|
$ptree = $ptreeHandler->getAll(new Criteria('Id', $animalNum), null, false, true); |
|
38
|
|
|
while (list($key, $val) = each($ptree)) { |
|
39
|
|
|
$this->$key = $val; |
|
40
|
|
|
} |
|
41
|
|
|
/* |
|
|
|
|
|
|
42
|
|
|
global $xoopsDB; |
|
43
|
|
|
if (0 == $animalnumber) { |
|
44
|
|
|
$SQL = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE ID = '1'"; |
|
45
|
|
|
} else { |
|
46
|
|
|
$SQL = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE ID = ' . $animalnumber; |
|
47
|
|
|
} |
|
48
|
|
|
$result = $GLOBALS['xoopsDB']->query($SQL); |
|
49
|
|
|
$row = $GLOBALS['xoopsDB']->fetchRow($result); |
|
50
|
|
|
$numfields = $GLOBALS['xoopsDB']->getFieldsNum($result); |
|
51
|
|
|
for ($i = 0; $i < $numfields; ++$i) { |
|
52
|
|
|
$key = mysqli_fetch_field_direct($result, $i)->name; |
|
53
|
|
|
$this->$key = $row[$i]; |
|
54
|
|
|
} |
|
55
|
|
|
*/ |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @return array |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getNumOfFields() |
|
62
|
|
|
{ |
|
63
|
|
|
$fields = array(); |
|
64
|
|
|
$fieldsHandler = xoops_getModuleHandler('fields', $this->dirname); |
|
65
|
|
|
$allFieldsArray = $fieldsHandler->getAll(null, null, false, true); |
|
66
|
|
|
foreach ($allFieldsArray as $key=>$val) { |
|
67
|
|
|
$fields[] = $key; |
|
68
|
|
|
$configValues[] = $val; |
|
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
/* |
|
|
|
|
|
|
71
|
|
|
global $xoopsDB; |
|
72
|
|
|
$SQL = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . ' ORDER BY `order`'; |
|
73
|
|
|
$fields = array(); |
|
74
|
|
|
$result = $GLOBALS['xoopsDB']->query($SQL); |
|
75
|
|
|
$count = 0; |
|
76
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
77
|
|
|
$fields[] = $row['Id']; |
|
78
|
|
|
++$count; |
|
79
|
|
|
$configValues[] = $row; |
|
80
|
|
|
} |
|
81
|
|
|
*/ |
|
82
|
|
|
$this->configValues = isset($configValues) ? $configValues : ''; |
|
|
|
|
|
|
83
|
|
|
//print_r ($this->configValues); die(); |
|
|
|
|
|
|
84
|
|
|
return $fields; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @return mixed |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getConfig() |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->configValues; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.