1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17:
18:
19:
20: 21: 22: 23: 24: 25:
26: class SystemUserrank extends XoopsObject
27: {
28: 29: 30:
31: public function __construct()
32: {
33: parent::__construct();
34: $this->initVar('rank_id', XOBJ_DTYPE_INT, null, false, 5);
35: $this->initVar('rank_title', XOBJ_DTYPE_TXTBOX, null, false);
36: $this->initVar('rank_min', XOBJ_DTYPE_INT, null, false, 8);
37: $this->initVar('rank_max', XOBJ_DTYPE_INT, null, false, 8);
38: $this->initVar('rank_special', XOBJ_DTYPE_INT, null, false, 1);
39: $this->initVar('rank_image', XOBJ_DTYPE_TXTBOX, null, false);
40: }
41:
42: 43: 44: 45: 46:
47: public function getForm($action = false)
48: {
49: if ($this->isNew()) {
50: $blank_img = 'blank.gif';
51: } else {
52: $blank_img = str_replace('ranks/', '', $this->getVar('rank_image', 'e'));
53: }
54: if ($action === false) {
55: $action = $_SERVER['REQUEST_URI'];
56: }
57:
58: $title = $this->isNew() ? sprintf(_AM_SYSTEM_USERRANK_ADD) : sprintf(_AM_SYSTEM_USERRANK_EDIT);
59:
60: $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
61: $form->setExtra('enctype="multipart/form-data"');
62:
63: $form->addElement(new XoopsFormText(_AM_SYSTEM_USERRANK_TITLE, 'rank_title', 50, 50, $this->getVar('rank_title'), true));
64: $form->addElement(new XoopsFormText(_AM_SYSTEM_USERRANK_MINPOST, 'rank_min', 10, 10, $this->getVar('rank_min')));
65: $form->addElement(new XoopsFormText(_AM_SYSTEM_USERRANK_MAXPOST, 'rank_max', 10, 10, $this->getVar('rank_max')));
66:
67: $imgtray_img = new XoopsFormElementTray(_AM_SYSTEM_USERRANK_IMAGE, '<br>');
68: $imgpath_img = sprintf(_AM_SYSTEM_USERRANK_IMAGE_PATH, XOOPS_UPLOAD_PATH . '/ranks/');
69: $imageselect_img = new XoopsFormSelect($imgpath_img, 'rank_image', $blank_img);
70: $image_array_img = XoopsLists::getImgListAsArray(XOOPS_UPLOAD_PATH . '/ranks');
71: $imageselect_img->addOption("$blank_img", $blank_img);
72: foreach ($image_array_img as $image_img) {
73: $imageselect_img->addOption("$image_img", $image_img);
74: }
75: $imageselect_img->setExtra("onchange='showImgSelected(\"xo-ranks-img\", \"rank_image\", \"ranks\", \"\", \"" . XOOPS_UPLOAD_URL . "\")'");
76: $imgtray_img->addElement($imageselect_img, false);
77: $imgtray_img->addElement(new XoopsFormLabel('', "<br><img src='" . XOOPS_UPLOAD_URL . '/ranks/' . $blank_img . "' name='image_img' id='xo-ranks-img' alt='' />"));
78:
79: $fileseltray_img = new XoopsFormElementTray('<br>', '<br><br>');
80: $fileseltray_img->addElement(new XoopsFormFile(_AM_SYSTEM_USERRANK_UPLOAD, 'rank_image', 500000), false);
81: $fileseltray_img->addElement(new XoopsFormLabel(''), false);
82: $imgtray_img->addElement($fileseltray_img);
83: $form->addElement($imgtray_img);
84:
85: $rank_special = 0;
86: if (!$this->isNew()) {
87: $rank_special = $this->getVar('rank_special');
88: }
89:
90: $special_tray = new XoopsFormElementTray(_AM_SYSTEM_USERRANK_SPECIAL, '<br>');
91: $special_tray->setDescription(_AM_SYSTEM_USERRANK_SPECIAL_CAN);
92: $special_tray->addElement(new XoopsFormRadioYN('', 'rank_special', $rank_special));
93: $form->addElement($special_tray);
94: if (!$this->isNew()) {
95: $form->addElement(new XoopsFormHidden('rank_id', $this->getVar('rank_id')));
96: }
97: $form->addElement(new XoopsFormHidden('op', 'userrank_save'));
98: $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
99:
100: return $form;
101: }
102: }
103:
104: 105: 106: 107: 108: 109: 110: 111: 112: 113:
114: class SystemuserrankHandler extends XoopsPersistableObjectHandler
115: {
116: 117: 118:
119: public function __construct(XoopsDatabase $db)
120: {
121: parent::__construct($db, 'ranks', 'SystemUserrank', 'rank_id', 'rank_title');
122: }
123: }
124: