SmartFormRichFileElement::__construct()   A
last analyzed

Complexity

Conditions 5
Paths 12

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 12
nop 3
dl 0
loc 29
rs 9.1448
c 0
b 0
f 0
1
<?php namespace XoopsModules\Smartobject\Form\Elements;
2
3
/**
4
 * Contains the SmartObjectControl class
5
 *
6
 * @license    GNU
7
 * @author     marcan <[email protected]>
8
 * @link       http://smartfactory.ca The SmartFactory
9
 * @package    SmartObject
10
 * @subpackage SmartObjectForm
11
 */
12
13
use XoopsModules\Smartobject;
14
15
/**
16
 * Class SmartFormRichFileElement
17
 * @package XoopsModules\Smartobject\Form\Elements
18
 */
19
class SmartFormRichFileElement extends \XoopsFormElementTray
20
{
21
    /**
22
     * SmartFormRichFileElement constructor.
23
     * @param string $form_caption
24
     * @param string $key
25
     * @param string $object
26
     */
27
    public function __construct($form_caption, $key, $object)
28
    {
29
        parent::__construct($form_caption, '&nbsp;');
30
        if ('' !== $object->getVar('url')) {
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $object (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
31
            $caption = '' !== $object->getVar('caption') ? $object->getVar('caption') : $object->getVar('url');
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $object (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
32
            $this->addElement(new \XoopsFormLabel('', _CO_SOBJECT_CURRENT_FILE . "<a href='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar('url')) . "' target='_blank' >" . $caption . '</a><br><br>'));
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $object (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
33
            //$this->addElement( new \XoopsFormLabel( '', "<br><a href = '".SMARTOBJECT_URL."admin/file.php?op=del&fileid=".$object->id()."'>"._CO_SOBJECT_DELETE_FILE."</a>"));
34
        }
35
36
//        require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformfileuploadelement.php';
37
        if ($object->isNew()) {
0 ignored issues
show
Bug introduced by
The method isNew cannot be called on $object (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
38
            $this->addElement(new SmartFormFileUploadElement($object, $key));
39
            $this->addElement(new \XoopsFormLabel('', '<br><br><small>' . _CO_SOBJECT_URL_FILE_DSC . '</small>'));
40
            $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URL_FILE));
41
            $this->addElement(new SmartFormTextElement($object, 'url_' . $key));
42
        }
43
        $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_CAPTION));
44
        $this->addElement(new SmartFormTextElement($object, 'caption_' . $key));
45
        $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_DESC . '<br>'));
46
        $this->addElement(new \XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description')));
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $object (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
47
48
        if (!$object->isNew()) {
0 ignored issues
show
Bug introduced by
The method isNew cannot be called on $object (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
49
            $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_CHANGE_FILE));
50
            $this->addElement(new SmartFormFileUploadElement($object, $key));
51
            $this->addElement(new \XoopsFormLabel('', '<br><br><small>' . _CO_SOBJECT_URL_FILE_DSC . '</small>'));
52
            $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URL_FILE));
53
            $this->addElement(new SmartFormTextElement($object, 'url_' . $key));
54
        }
55
    }
56
}
57