|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* TDMDownload |
|
4
|
|
|
* |
|
5
|
|
|
* You may not change or alter any portion of this comment or credits |
|
6
|
|
|
* of supporting developers from this source code or any supporting source code |
|
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
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
|
|
|
* @copyright Gregory Mage (Aka Mage) |
|
13
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
14
|
|
|
* @author Gregory Mage (Aka Mage) |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
if (!defined("XOOPS_ROOT_PATH")) { |
|
18
|
|
|
die("XOOPS root path not defined"); |
|
19
|
|
|
} |
|
20
|
|
|
class TDMDownloads_field extends XoopsObject |
|
21
|
|
|
{ |
|
22
|
|
|
// constructor |
|
23
|
|
|
public function __construct() |
|
24
|
|
|
{ |
|
25
|
|
|
$this->initVar("fid",XOBJ_DTYPE_INT,null,false,11); |
|
26
|
|
|
$this->initVar("title",XOBJ_DTYPE_TXTBOX, null, false); |
|
27
|
|
|
$this->initVar("img",XOBJ_DTYPE_TXTBOX, null, false); |
|
28
|
|
|
$this->initVar("weight",XOBJ_DTYPE_INT,null,false,11); |
|
29
|
|
|
$this->initVar("status",XOBJ_DTYPE_INT,null,false,5); |
|
30
|
|
|
$this->initVar("search",XOBJ_DTYPE_INT,null,false,5); |
|
31
|
|
|
$this->initVar("status_def",XOBJ_DTYPE_INT,null,false,5); |
|
32
|
|
|
|
|
33
|
|
|
//pour les jointures |
|
34
|
|
|
$this->initVar("data",XOBJ_DTYPE_TXTAREA, null, false); |
|
35
|
|
|
} |
|
36
|
|
|
public function TDMDownloads_field() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->__construct(); |
|
39
|
|
|
} |
|
40
|
|
|
public function get_new_enreg() |
|
41
|
|
|
{ |
|
42
|
|
|
global $xoopsDB; |
|
43
|
|
|
$new_enreg = $xoopsDB->getInsertId(); |
|
44
|
|
|
|
|
45
|
|
|
return $new_enreg; |
|
46
|
|
|
} |
|
47
|
|
|
public function getForm($action = false) |
|
48
|
|
|
{ |
|
49
|
|
|
global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
50
|
|
|
if ($action === false) { |
|
51
|
|
|
$action = $_SERVER['REQUEST_URI']; |
|
52
|
|
|
} |
|
53
|
|
|
include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php"); |
|
54
|
|
|
|
|
55
|
|
|
//nom du formulaire selon l'action (editer ou ajouter): |
|
56
|
|
|
$title = $this->isNew() ? sprintf(_AM_TDMDOWNLOADS_FORMADD) : sprintf(_AM_TDMDOWNLOADS_FORMEDIT); |
|
57
|
|
|
|
|
58
|
|
|
//création du formulaire |
|
59
|
|
|
$form = new XoopsThemeForm($title, 'form', $action, 'post', true); |
|
60
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
|
61
|
|
|
//titre |
|
62
|
|
|
if ($this->getVar('status_def') == 1) { |
|
63
|
|
|
$form->addElement(new xoopsFormLabel (_AM_TDMDOWNLOADS_FORMTITLE, $this->getVar('title'))); |
|
|
|
|
|
|
64
|
|
|
$form->addElement(new XoopsFormHidden('title', $this->getVar('title'))); |
|
|
|
|
|
|
65
|
|
|
} else { |
|
66
|
|
|
$form->addElement(new XoopsFormText(_AM_TDMDOWNLOADS_FORMTITLE, 'title', 50, 255, $this->getVar('title')), true); |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
//image |
|
69
|
|
|
$downloadsfield_img = $this->getVar('img') ? $this->getVar('img') : 'blank.gif'; |
|
70
|
|
|
$uploadirectory='/uploads/TDMDownloads/images/field'; |
|
71
|
|
|
$imgtray = new XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMAGE,'<br />'); |
|
72
|
|
|
$imgpath=sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory ); |
|
73
|
|
|
$imageselect= new XoopsFormSelect($imgpath, 'downloadsfield_img',$downloadsfield_img); |
|
74
|
|
|
$topics_array = XoopsLists :: getImgListAsArray( XOOPS_ROOT_PATH . $uploadirectory ); |
|
75
|
|
|
foreach ($topics_array as $image) { |
|
76
|
|
|
$imageselect->addOption("$image", $image); |
|
77
|
|
|
} |
|
78
|
|
|
$imageselect->setExtra( "onchange='showImgSelected(\"image3\", \"downloadsfield_img\", \"" . $uploadirectory . "\", \"\", \"" . XOOPS_URL . "\")'" ); |
|
79
|
|
|
$imgtray->addElement($imageselect,false); |
|
80
|
|
|
$imgtray -> addElement( new XoopsFormLabel( '', "<br /><img src='" . XOOPS_URL . "/" . $uploadirectory . "/" . $downloadsfield_img . "' name='image3' id='image3' alt='' /><br />" ) ); |
|
81
|
|
|
$fileseltray= new XoopsFormElementTray('','<br />'); |
|
82
|
|
|
$fileseltray->addElement(new XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD , 'attachedfile', $xoopsModuleConfig['maxuploadsize']), false); |
|
83
|
|
|
$fileseltray->addElement(new XoopsFormLabel('' ), false); |
|
84
|
|
|
$imgtray->addElement($fileseltray); |
|
85
|
|
|
$form->addElement($imgtray); |
|
86
|
|
|
//poids du champ |
|
87
|
|
|
$form->addElement(new XoopsFormText(_AM_TDMDOWNLOADS_FORMWEIGHT, 'weight', 5, 5, $this->getVar('weight', 'e')), false); |
|
88
|
|
|
// affiché? |
|
89
|
|
|
$status = $this->getVar('status') ? $this->getVar('status') : 0; |
|
90
|
|
|
$form->addElement(new XoopsFormRadioYN(_AM_TDMDOWNLOADS_FORMAFFICHE, 'status', $status)); |
|
|
|
|
|
|
91
|
|
|
// affiché dans le champ de recherche? |
|
92
|
|
|
$search = $this->getVar('search') ? $this->getVar('search') : 0; |
|
93
|
|
|
$form->addElement(new XoopsFormRadioYN(_AM_TDMDOWNLOADS_FORMAFFICHESEARCH, 'search', $search)); |
|
94
|
|
|
// pour passer "fid" si on modifie le champ |
|
95
|
|
|
if (!$this->isNew()) { |
|
96
|
|
|
$form->addElement(new XoopsFormHidden('fid', $this->getVar('fid'))); |
|
97
|
|
|
$form->addElement(new XoopsFormHidden('status_def', $this->getVar('status_def'))); |
|
98
|
|
|
} else { |
|
99
|
|
|
$form->addElement(new XoopsFormHidden('status_def', 0)); |
|
100
|
|
|
} |
|
101
|
|
|
//pour enregistrer le formulaire |
|
102
|
|
|
$form->addElement(new XoopsFormHidden('op', 'save_field')); |
|
103
|
|
|
//boutton d'envoi du formulaire |
|
104
|
|
|
$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
105
|
|
|
|
|
106
|
|
|
return $form; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
class TDMDownloadstdmdownloads_fieldHandler extends XoopsPersistableObjectHandler |
|
111
|
|
|
{ |
|
112
|
|
|
public function __construct(&$db) |
|
113
|
|
|
{ |
|
114
|
|
|
parent::__construct($db, "tdmdownloads_field", 'tdmdownloads_field', 'fid', 'title'); |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|