Passed
Push — master ( 8b5e26...f79285 )
by Michael
04:32
created

PedigreeHtmlInputAbstract::lookupField()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Pedigree;
4
5
/**
6
 *  pedigree HTML Input Interface Class Elements
7
 *
8
 * @copyright  ZySpec Incorporated
9
 * @license    {@link https://www.gnu.org/licenses/gpl-2.0.html GNU Public License}
10
 * @package    pedigree
11
 * @subpackage class
12
 * @author     zyspec <[email protected]>
13
 * @since      1.3.1
14
 */
15
16
/**
17
 * HtmlInputAbstract
18
 *
19
 * @package   pedigree
20
 * @author    zyspec <[email protected]>
21
 * @copyright Copyright (c) 2014 ZySpec Incorporated
22
 * @access    public
23
 */
24
require_once __DIR__ . '/field.php';
25
26
/**
27
 * Class HtmlInputAbstract
28
 */
29
abstract class PedigreeHtmlInputAbstract extends Field
30
{
31
    /**
32
     * @return mixed
33
     */
34
    abstract public function editField();
35
36
    /**
37
     * @param $name
38
     * @return mixed
39
     */
40
    abstract public function newField($name);
41
42
    /**
43
     * @return mixed
44
     */
45
    abstract public function viewField();
46
47
    /**
48
     * @return mixed
49
     */
50
    abstract public function showField();
51
52
    /**
53
     * @return mixed
54
     */
55
    abstract public function showValue();
56
57
    /**
58
     * @return mixed
59
     */
60
    abstract public function searchField();
61
62
    /**
63
     * @return mixed
64
     */
65
    abstract public function getSearchString();
66
67
    /**
68
     * @param string $message
69
     */
70
    public function echoMsg($message)
71
    {
72
        echo "<span style='color: red;'><h3>{$message}</h3></span>";
73
    }
74
75
    /**
76
     * @param $fieldnumber
77
     *
78
     * @return array
79
     */
80
    public function lookupField($fieldnumber)
81
    {
82
        $ret = [];
83
        global $xoopsDB;
84
        $SQL    = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_lookup' . $fieldnumber) . " ORDER BY 'order'";
85
        $result = $GLOBALS['xoopsDB']->query($SQL);
86
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
87
            $ret[] = ['id' => $row['id'], 'value' => $row['value']];
88
        }
89
90
        //array_multisort($ret,SORT_ASC);
91
        return $ret;
92
    }
93
}
94