1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
14
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
15
|
|
|
* @author trabis <[email protected]> |
16
|
|
|
* @version $Id$ |
17
|
|
|
*/ |
18
|
|
|
class AlumniCategoryForm extends Xoops\Form\ThemeForm |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @param AlumniCategory|XoopsObject $obj |
|
|
|
|
22
|
|
|
*/ |
23
|
|
|
public function __construct(AlumniCategory $obj) |
24
|
|
|
{ |
25
|
|
|
$xoops = Xoops::getInstance(); |
26
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
27
|
|
|
$admin_lang = '_AM_' . strtoupper($moduleDirName); |
|
|
|
|
28
|
|
|
|
29
|
|
|
$title = sprintf($obj->isNew() ? AlumniLocale::ADD_CAT : AlumniLocale::EDIT_CAT); |
30
|
|
|
parent::__construct($title, 'form', false, 'post', true); |
31
|
|
|
|
32
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
33
|
|
|
|
34
|
|
|
$this->setExtra('enctype="multipart/form-data"'); |
35
|
|
|
|
36
|
|
|
include_once XOOPS_ROOT_PATH . '/class/tree.php'; |
37
|
|
|
$categoryHandler = $xoops->getModuleHandler('category', 'alumni'); |
38
|
|
|
$arr = $categoryHandler->getAll(); |
39
|
|
|
$mytree = new XoopsObjectTree($arr, 'cid', 'pid'); |
40
|
|
|
|
41
|
|
|
$this->addElement(new Xoops\Form\Label(AlumniLocale::CATEGORY_PID, $mytree->makeSelBox('pid', 'title', '-', $obj->getVar('pid'), true))); |
42
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::CATEGORY_TITLE, 'title', 50, 255, $obj->getVar('title')), true); |
43
|
|
|
|
44
|
|
|
if ($obj->isNew()) { |
45
|
|
|
$default_img = 'default.gif'; |
|
|
|
|
46
|
|
|
} else { |
47
|
|
|
$default_img = str_replace('alumni/', '', $obj->getVar('img', 'e')); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$img = $obj->getVar('img') ?: 'default.gif'; |
51
|
|
|
$imgtray_img = new Xoops\Form\ElementTray(AlumniLocale::IMGCAT, '<br>'); |
|
|
|
|
52
|
|
|
$img_path = \XoopsBaseConfig::get('root-path') . '/modules/alumni/images/cat'; |
|
|
|
|
53
|
|
|
|
54
|
|
|
$imgpath_img = sprintf(AlumniLocale::FORMIMAGE_PATH, $img_path); |
|
|
|
|
55
|
|
|
$imageselect_img = new Xoops\Form\Select(sprintf(XoopsLocale::F_FILE_EXISTS_IN, $img_path . '/'), 'img', $img); |
|
|
|
|
56
|
|
|
$image_array_img = XoopsLists::getImgListAsArray($img_path); |
|
|
|
|
57
|
|
|
$imageselect_img->addOption("$default_img", $default_img); |
|
|
|
|
58
|
|
|
foreach ($image_array_img as $image_img) { |
|
|
|
|
59
|
|
|
$imageselect_img->addOption("$image_img", $image_img); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$alumni_upload_url = \XoopsBaseConfig::get('url') . '/modules/alumni/images/cat'; |
|
|
|
|
63
|
|
|
|
64
|
|
|
$imageselect_img->setExtra("onchange='showImgSelected(\"image_img\", \"img\", \"\", \"\", \"" . $alumni_upload_url . "\")'"); |
|
|
|
|
65
|
|
|
$imgtray_img->addElement($imageselect_img, false); |
|
|
|
|
66
|
|
|
$imgtray_img->addElement(new Xoops\Form\Label('', "<br><img src='" . $alumni_upload_url . '/' . $img . "' name='image_img' id='image_img' alt=''>")); |
|
|
|
|
67
|
|
|
|
68
|
|
|
$fileseltray_category_img = new Xoops\Form\ElementTray('<br>', '<br>'); |
|
|
|
|
69
|
|
|
$fileseltray_category_img->addElement(new Xoops\Form\File(AlumniLocale::FORMUPLOAD, 'img'), false); |
|
|
|
|
70
|
|
|
$fileseltray_category_img->addElement(new Xoops\Form\Label(''), false); |
|
|
|
|
71
|
|
|
$imgtray_img->addElement($fileseltray_category_img); |
|
|
|
|
72
|
|
|
$this->addElement($imgtray_img); |
|
|
|
|
73
|
|
|
|
74
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::ORDER, 'ordre', 4, 4, $obj->getVar('ordre')), false); |
75
|
|
|
$this->addElement(new Xoops\Form\Label(AlumniLocale::IFSCHOOL, '')); |
76
|
|
|
|
77
|
|
|
$photo_old = $obj->getVar('scphoto') ?: ''; |
|
|
|
|
78
|
|
|
$uploadirectory_photo = XOOPS_ROOT_PATH . "/uploads/{$moduleDirName}/photos/school_photos"; |
|
|
|
|
79
|
|
|
$imgtray_photo = new Xoops\Form\ElementTray(AlumniLocale::SCPHOTO, '<br>'); |
|
|
|
|
80
|
|
|
$imgpath_photo = sprintf(AlumniLocale::FORMIMAGE_PATH, $uploadirectory_photo); |
|
|
|
|
81
|
|
|
$fileseltray_photo = new Xoops\Form\ElementTray('', '<br>'); |
|
|
|
|
82
|
|
|
$fileseltray_photo->addElement(new XoopsFormFile(AlumniLocale::FORMUPLOAD, 'scphoto', $xoops->getModuleConfig('alumni_photomax')), false); |
|
|
|
|
83
|
|
View Code Duplication |
if ($photo_old) { |
|
|
|
|
84
|
|
|
$fileseltray_photo->addElement(new Xoops\Form\Label(AlumniLocale::SELECTED_PHOTO, '<a href="../photos/school_photos/' . $photo_old . '">' . $photo_old . '</a>', false)); |
|
|
|
|
85
|
|
|
$imgtray_checkbox = new Xoops\Form\Checkbox('', 'del_photo', 0); |
|
|
|
|
86
|
|
|
$imgtray_checkbox->addOption(1, AlumniLocale::DELPICT); |
|
|
|
|
87
|
|
|
$fileseltray_photo->addElement($imgtray_checkbox); |
|
|
|
|
88
|
|
|
} |
89
|
|
|
$imgtray_photo->addElement($fileseltray_photo); |
|
|
|
|
90
|
|
|
$this->addElement($imgtray_photo); |
|
|
|
|
91
|
|
|
$this->addElement(new Xoops\Form\Hidden('photo_old', $photo_old)); |
|
|
|
|
92
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::SCADDRESS, 'scaddress', 50, 255, $obj->getVar('scaddress')), false); |
93
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::SCADDRESS2, 'scaddress2', 50, 255, $obj->getVar('scaddress2')), false); |
94
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::SCCITY, 'sccity', 50, 255, $obj->getVar('sccity')), false); |
95
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::SCSTATE, 'scstate', 50, 255, $obj->getVar('scstate')), false); |
96
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::SCZIP, 'sczip', 50, 255, $obj->getVar('sczip')), false); |
97
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::SCPHONE, 'scphone', 50, 255, $obj->getVar('scphone')), false); |
98
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::SCFAX, 'scfax', 50, 255, $obj->getVar('scfax')), false); |
99
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::SCMOTTO, 'scmotto', 50, 255, $obj->getVar('scmotto')), false); |
100
|
|
|
$this->addElement(new Xoops\Form\Text(AlumniLocale::SCURL, 'scurl', 50, 255, $obj->getVar('scurl')), false); |
101
|
|
|
$this->addElement(new Xoops\Form\Hidden('op', 'save_category')); |
102
|
|
|
$this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit')); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.