|
1
|
|
|
<?php namespace XoopsModules\Pedigree; |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* pedigree HTML Input Interface Class Elements |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright ZySpec Incorporated |
|
7
|
|
|
* @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
|
8
|
|
|
* @package pedigree |
|
9
|
|
|
* @subpackage class |
|
10
|
|
|
* @author zyspec <[email protected]> |
|
11
|
|
|
* @since 1.3.1 |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
use XoopsModules\Pedigree; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Pedigree\HtmlInputAbstract |
|
20
|
|
|
* |
|
21
|
|
|
* @package \XoopsModules\Pedigree\Class |
|
22
|
|
|
* @author zyspec <[email protected]> |
|
23
|
|
|
* @copyright Copyright (c) 2014-2019 ZySpec Incorporated |
|
24
|
|
|
* @access public |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class Pedigree\HtmlInputAbstract |
|
30
|
|
|
*/ |
|
31
|
|
|
abstract class HtmlInputAbstract //extends Pedigree\Field |
|
|
|
|
|
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @return mixed |
|
35
|
|
|
*/ |
|
36
|
|
|
abstract public function editField(); |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param $name |
|
40
|
|
|
* @return mixed |
|
41
|
|
|
*/ |
|
42
|
|
|
abstract public function newField($name); |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return mixed |
|
46
|
|
|
*/ |
|
47
|
|
|
abstract public function viewField(); |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return mixed |
|
51
|
|
|
*/ |
|
52
|
|
|
abstract public function showField(); |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return mixed |
|
56
|
|
|
*/ |
|
57
|
|
|
abstract public function showValue(); |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return mixed |
|
61
|
|
|
*/ |
|
62
|
|
|
abstract public function searchField(); |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return mixed |
|
66
|
|
|
*/ |
|
67
|
|
|
abstract public function getSearchString(); |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param string $message |
|
71
|
|
|
* |
|
72
|
|
|
* @return void |
|
73
|
|
|
*/ |
|
74
|
|
|
public function echoMsg($message) |
|
75
|
|
|
{ |
|
76
|
|
|
echo "<span style='color: red;'><h3>{$message}</h3></span>"; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param $fieldnumber |
|
81
|
|
|
* |
|
82
|
|
|
* @return array |
|
83
|
|
|
*/ |
|
84
|
|
|
public function lookupField($fieldnumber) |
|
85
|
|
|
{ |
|
86
|
|
|
$ret = []; |
|
87
|
|
|
|
|
88
|
|
|
/** @var \Xmf\Database\Tables $pTables */ |
|
89
|
|
|
$pTables = new \Xmf\Database\Tables(); |
|
90
|
|
|
$exists = $pTables->useTable('pedigree_lookup' . $fieldnumber); |
|
91
|
|
|
if ($exists) { |
|
92
|
|
|
$tableName = $pTables->name('pedigree_lookup' . $fieldnumber); |
|
93
|
|
|
$SQL = "SELECT * FROM `{$tableName}` ORDER BY 'order'"; |
|
94
|
|
|
//$SQL = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_lookup' . $fieldnumber) . " ORDER BY 'order'"; |
|
|
|
|
|
|
95
|
|
|
$result = $GLOBALS['xoopsDB']->query($SQL); |
|
96
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
97
|
|
|
$ret[] = ['id' => $row['id'], 'value' => $row['value']]; |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
//array_multisort($ret,SORT_ASC); |
|
|
|
|
|
|
102
|
|
|
return $ret; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
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.