|
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, ' '); |
|
30
|
|
|
if ('' !== $object->getVar('url')) { |
|
|
|
|
|
|
31
|
|
|
$caption = '' !== $object->getVar('caption') ? $object->getVar('caption') : $object->getVar('url'); |
|
|
|
|
|
|
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>')); |
|
|
|
|
|
|
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()) { |
|
|
|
|
|
|
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'))); |
|
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
if (!$object->isNew()) { |
|
|
|
|
|
|
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
|
|
|
|
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.