Passed
Push — master ( b847d6...d6d54c )
by Michael
09:34 queued 05:00
created

class/Picture.php (1 issue)

Labels
Severity
1
<?php namespace XoopsModules\Pedigree;
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
*/
12
/**
13
 * Pedigree\Picture Class
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      lucio <[email protected]>
18
 * @package     \XoopsModules\Pedigree\Class
19
 * @since       1.31
20
 *
21
 */
22
use XoopsModules\Pedigree;
0 ignored issues
show
This use statement conflicts with another class in this namespace, XoopsModules\Pedigree\Pedigree. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/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 before OtherDir/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:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
23
24
/**
25
 * Class Picture
26
 */
27
class Picture extends Pedigree\HtmlInputAbstract
28
{
29
    /**
30
     * @param Pedigree\Field  $parentObject
31
     * @param Pedigree\Animal $animalObject
32
     */
33
    public function __construct($parentObject, $animalObject)
34
    {
35
        $this->fieldnumber  = $parentObject->getId();
36
        $this->fieldname    = $parentObject->fieldname;
37
        $this->value        = $animalObject->{'user' . $this->fieldnumber};
38
        $this->defaultvalue = $parentObject->defaultvalue;
39
        $this->lookuptable  = $parentObject->hasLookup();
40
        if ($this->lookuptable) {
41
            xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber);
42
        }
43
        if ($parentObject->inAdvanced()) {
44
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', get_class($this));
45
        }
46
        if ($parentObject->inPie()) {
47
            xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, get_class($this));
48
        }
49
        if ('1' == $parentObject->viewinlist) {
50
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be included in listview', get_class($this));
51
        }
52
        if ('1' == $parentObject->hassearch) {
53
            xoops_error('Search cannot be defined for userfield ' . $this->fieldnumber, get_class($this));
54
        }
55
    }
56
57
    /**
58
     * @return \XoopsFormFile
59
     */
60
    public function editField()
61
    {
62
        $picturefield = new \XoopsFormFile($this->fieldname, 'user' . $this->fieldnumber, 1024000);
63
        $picturefield->setExtra("size ='50'");
64
65
        return $picturefield;
66
    }
67
68
    /**
69
     * @param string $name
70
     *
71
     * @return \XoopsFormFile
72
     */
73
    public function newField($name = '')
74
    {
75
        $picturefield = new \XoopsFormFile($this->fieldname, $name . 'user' . $this->fieldnumber, 1024000);
76
        $picturefield->setExtra("size ='50'");
77
78
        return $picturefield;
79
    }
80
81
    /**
82
     * @return \XoopsFormLabel
83
     */
84
    public function viewField()
85
    {
86
        $view = new \XoopsFormLabel($this->fieldname, '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_400.jpeg">');
87
88
        return $view;
89
    }
90
91
    /**
92
     * @return string
93
     */
94
    public function showField()
95
    {
96
        return '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_150.jpeg">';
97
    }
98
99
    /**
100
     * @return string
101
     */
102
    public function showValue()
103
    {
104
        return '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_400.jpeg">';
105
    }
106
107
    /**
108
     * @return null
109
     */
110
    public function searchField()
111
    {
112
        return null;
113
    }
114
115
    /**
116
     * @return null
117
     */
118
    public function getSearchString()
119
    {
120
        return null;
121
    }
122
}
123