1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22: class BannersBannerForm extends Xoops\Form\ThemeForm
23: {
24: 25: 26:
27: public function __construct(BannersBanner $obj)
28: {
29: $xoops = Xoops::getInstance();
30: $xoops_upload_url = $xoops->url('uploads/');
31: $helper = Banners::getInstance();
32:
33: if ($obj->isNew()) {
34: $blank_img = 'blank.gif';
35: $html_banner = 0;
36: } else {
37: if (substr_count($obj->getVar('banner_imageurl'), $xoops_upload_url . '/banners/') == 0) {
38: $blank_img = 'blank.gif';
39: } else {
40: $namefile =
41: substr_replace($obj->getVar('banner_imageurl'), '', 0, strlen($xoops_upload_url . '/banners/'));
42: $pathfile = $xoops->path('uploads/banners/') . $namefile;
43: if (is_file($pathfile)) {
44: $blank_img = str_replace($xoops_upload_url . '/banners/', '', $obj->getVar('banner_imageurl', 'e'));
45: } else {
46: $blank_img = 'blank.gif';
47: }
48: }
49: $html_banner = $obj->getVar('banner_htmlbanner');
50: }
51:
52: $title = $obj->isNew() ? sprintf(_AM_BANNERS_BANNERS_ADD) : sprintf(_AM_BANNERS_BANNERS_EDIT);
53:
54: parent::__construct($title, 'form', 'banners.php', 'post', true);
55: $this->setExtra('enctype="multipart/form-data"');
56: $client_Handler = $helper->getHandlerBannerclient();
57: $client_select = new Xoops\Form\Select(_AM_BANNERS_CLIENTS_NAME, 'cid', $obj->getVar('banner_cid'));
58: $client_select->addOptionArray($client_Handler->getList());
59: $this->addElement($client_select, true);
60:
61: $imptotal =
62: new Xoops\Form\Text(_AM_BANNERS_BANNERS_IMPRESSIONSP, 'imptotal', 1, 255, $obj->getVar('banner_imptotal'));
63:
64: $this->addElement($imptotal, true);
65:
66: $imgtray_img = new Xoops\Form\ElementTray(_AM_BANNERS_BANNERS_IMAGE, '<br /><br />');
67: $imgtray_img->addElement(
68: new Xoops\Form\Text(_AM_BANNERS_BANNERS_IMGURL, 'imageurl', 8, 255, $obj->getVar('banner_imageurl'))
69: );
70: $imgpath_img = sprintf(_AM_BANNERS_BANNERS_IMAGE_PATH, $xoops->path('uploads/banners/'));
71: $imageselect_img = new Xoops\Form\Select($imgpath_img, 'banners_imageurl', $blank_img);
72: $imageselect_img->addOption($blank_img, $blank_img);
73: \Xoops\Core\Lists\ImageFile::setOptionsArray($imageselect_img, $xoops->path('uploads/banners'));
74: $imageselect_img->setExtra(
75: 'onchange="showImgSelected(\'xo-banners-img\', \'banners_imageurl\', \'banners\', \'\', \''
76: . $xoops_upload_url . '\' )"'
77: );
78: $imgtray_img->addElement($imageselect_img, false);
79: $imgtray_img->addElement(
80: new Xoops\Form\Label(
81: '',
82: "<br /><img src='" . $xoops_upload_url . "/banners/" . $blank_img
83: . "' name='image_img' id='xo-banners-img' alt='' />"
84: )
85: );
86: $fileseltray_img = new Xoops\Form\ElementTray('<br />', '<br /><br />');
87: $fileseltray_img->addElement(new Xoops\Form\File(_AM_BANNERS_BANNERS_UPLOADS, 'banners_imageurl'), false);
88: $fileseltray_img->addElement(new Xoops\Form\Label(''), false);
89: $imgtray_img->addElement($fileseltray_img);
90: $this->addElement($imgtray_img);
91:
92: $this->addElement(new Xoops\Form\Text(_AM_BANNERS_BANNERS_CLICKURL, 'clickurl', 5, 255, $obj->getVar('banner_clickurl')), false);
93:
94: $this->addElement(new Xoops\Form\RadioYesNo(_AM_BANNERS_BANNERS_USEHTML, 'htmlbanner', $html_banner));
95:
96: $this->addElement(new Xoops\Form\TextArea(_AM_BANNERS_BANNERS_CODEHTML, 'htmlcode', $obj->getVar('banner_htmlcode'), 5, 5), false);
97: if (!$obj->isNew()) {
98: $this->addElement(new Xoops\Form\Hidden('bid', $obj->getVar('banner_bid')));
99: }
100: $this->addElement(new Xoops\Form\Hidden('op', 'save'));
101: $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
102: }
103: }
104: