XOOPS  2.6.0
avatar_user.php
Go to the documentation of this file.
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 
23 {
24  public function __construct(AvatarsAvatar $obj)
25  {
28  // Get avatar handler
29  $avatar_handler = $helper->getHandlerAvatar();
30 
31  $action = $_SERVER['REQUEST_URI'];
32  parent::__construct(AvatarsLocale::USERFORM, 'avatar_user_form', $action, "post", true);
33  $this->setExtra('enctype="multipart/form-data"');
34  // select and uploads
35  $avatar_select = new Xoops\Form\Select('', 'user_avatar', $xoops->user->getVar('user_avatar'));
36  $avatar_list = $avatar_handler->getListByType('S', true);
37  $avatar_selected = $xoops->user->getVar("user_avatar", "E");
38  $avatar_selected = in_array($avatar_selected, array_keys($avatar_list)) ? $avatar_selected : "blank.gif";
39  $avatar_select->addOptionArray($avatar_list);
42  $avatar_select->setExtra("onchange='showImgSelected(\"avatar\", \"user_avatar\", \"uploads\", \"\", \"" . $xoops_url . "\")'");
43  $avatar_tray = new Xoops\Form\ElementTray(XoopsLocale::FILE, '&nbsp;');
44  $avatar_tray->addElement($avatar_select);
45  $avatar_tray->addElement(new Xoops\Form\Label('', "<a href=\"javascript:openWithSelfMain('" . $xoops_url . "/modules/avatars/popup.php','avatars',600,400);\">" . XoopsLocale::LIST_. "</a><br />"));
46  $avatar_tray->addElement(new Xoops\Form\Label('', "<br /><img src='" . $xoops_upload_url . "/" . $avatar_selected . "' name='avatar' id='avatar' alt='' />"));
47  if ($helper->getConfig('avatars_allowupload') == 1 && $xoops->user->getVar('posts') >= $helper->getConfig('avatars_postsrequired')) {
48  $fileseltray_img = new Xoops\Form\ElementTray('<br />', '<br /><br />');
49  $fileseltray_img->addElement(new Xoops\Form\File(XoopsLocale::A_UPLOAD, 'user_avatar'), false);
50  $avatar_tray->addElement($fileseltray_img);
51  }
52  $this->addElement($avatar_tray);
53  // Hidden
54  $this->addElement(new Xoops\Form\Hidden('avatar_type', 'c'));
55  $this->addElement(new Xoops\Form\Hidden('uid', $xoops->user->getVar('uid')));
56  $this->addElement(new Xoops\Form\Hidden('op', 'save'));
57  $this->addElement(new Xoops\Form\Hidden('avatar_id', $obj->getVar('avatar_id', 'e')));
58  // Button
59  $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
60  }
61 }
setExtra($extra)
Definition: Form.php:374
const A_SUBMIT
Definition: en_US.php:128
$xoops_url
Definition: backend.php:32
static getInstance()
Definition: Xoops.php:160
addElement(Element $formElement, $required=false)
Definition: Form.php:206
const USERFORM
Definition: en_US.php:50
$_SERVER['REQUEST_URI']
getVar($key, $format= 's')
$xoops_upload_url
Definition: misc.php:30
__construct(AvatarsAvatar $obj)
Definition: avatar_user.php:24
$xoops
Definition: admin.php:25
static get($name)
static getInstance()
Definition: helper.php:34
$helper
const A_UPLOAD
Definition: en_US.php:133