Picture::newField()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 3
b 0
f 0
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\Breadcrumb Class
17
 *
18
 * @copyright   {@link https://xoops.org/ XOOPS Project}
19
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
20
 * @author      lucio <[email protected]>
21
 * @package     Pedigree
22
 * @since       1.31
23
 */
24
25
use XoopsModules\Pedigree;
26
27
/**
28
 * Class Picture
29
 */
30
class Picture extends Pedigree\HtmlInputAbstract
31
{
32
    /**
33
     * @param Field           $parentObject
34
     * @param Pedigree\Animal $animalObject
35
     */
36
    public function __construct($parentObject, $animalObject)
37
    {
38
        $this->fieldnumber  = $parentObject->getId();
0 ignored issues
show
Bug Best Practice introduced by
The property fieldnumber does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
39
        $this->fieldname    = $parentObject->fieldname;
0 ignored issues
show
Bug Best Practice introduced by
The property fieldname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
Bug introduced by
The property fieldname does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
40
        $this->value        = $animalObject->{'user' . $this->fieldnumber};
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug Best Practice introduced by
The property defaultvalue does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
Bug introduced by
The property defaultvalue does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
42
        $this->lookuptable  = $parentObject->hasLookup();
0 ignored issues
show
Bug Best Practice introduced by
The property lookuptable does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
43
        if ($this->lookuptable) {
44
            \xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber);
45
        }
46
        if ($parentObject->inAdvanced()) {
47
            \xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', \get_class($this));
48
        }
49
        if ($parentObject->inPie()) {
50
            \xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, \get_class($this));
51
        }
52
        if ('1' == $parentObject->viewinlist) {
0 ignored issues
show
Bug introduced by
The property viewinlist does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
53
            \xoops_error('userfield ' . $this->fieldnumber . ' cannot be included in listview', \get_class($this));
54
        }
55
        if ('1' == $parentObject->hassearch) {
0 ignored issues
show
Bug introduced by
The property hassearch does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
56
            \xoops_error('Search cannot be defined for userfield ' . $this->fieldnumber, \get_class($this));
57
        }
58
    }
59
60
    /**
61
     * @return \XoopsFormFile
62
     */
63
    public function editField()
64
    {
65
        $picturefield = new \XoopsFormFile($this->fieldname, 'user' . $this->fieldnumber, 1024000);
66
        $picturefield->setExtra("size ='50'");
67
68
        return $picturefield;
69
    }
70
71
    /**
72
     * @param string $name
73
     *
74
     * @return \XoopsFormFile
75
     */
76
    public function newField($name = '')
77
    {
78
        $picturefield = new \XoopsFormFile($this->fieldname, $name . 'user' . $this->fieldnumber, 1024000);
79
        $picturefield->setExtra("size ='50'");
80
81
        return $picturefield;
82
    }
83
84
    /**
85
     * @return \XoopsFormLabel
86
     */
87
    public function viewField()
88
    {
89
        $view = new \XoopsFormLabel($this->fieldname, '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_400.jpeg">');
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\PEDIGREE_UPLOAD_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
90
91
        return $view;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function showField()
98
    {
99
        return '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_150.jpeg">';
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\PEDIGREE_UPLOAD_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
100
    }
101
102
    /**
103
     * @return string
104
     */
105
    public function showValue()
106
    {
107
        return '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_400.jpeg">';
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\PEDIGREE_UPLOAD_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
108
    }
109
110
    /**
111
     * @return mixed|void
112
     */
113
    public function searchField()
114
    {
115
        return null;
116
    }
117
118
    /**
119
     * @return mixed|void
120
     */
121
    public function getSearchString()
122
    {
123
        return null;
124
    }
125
}
126