XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
smilies.php
Go to the documentation of this file.
1 <?php
20 defined('XOOPS_ROOT_PATH') or die('XOOPS root path not defined');
21 
29 {
30  function __construct()
31  {
32  parent::__construct();
33  $this->initVar('id',XOBJ_DTYPE_INT,null,false,5);
34  $this->initVar('code',XOBJ_DTYPE_TXTBOX,null,false);
35  $this->initVar('smile_url',XOBJ_DTYPE_TXTBOX,null,false);
36  $this->initVar('emotion',XOBJ_DTYPE_TXTBOX,null,false);
37  $this->initVar('display',XOBJ_DTYPE_INT,null,false,1);
38  }
39 
40  function smilies()
41  {
42  $this->__construct();
43  }
44 
45  function getForm($action = false)
46  {
47  if ($this->isNew()) {
48  $blank_img = 'blank.gif';
49  } else {
50  $blank_img = str_replace( 'smilies/', '', $this->getVar('smile_url', 'e') );
51  }
52  if ($action === false) {
53  $action = $_SERVER['REQUEST_URI'];
54  }
55 
56  $title = $this->isNew() ? sprintf(_AM_SYSTEM_SMILIES_ADD) : sprintf(_AM_SYSTEM_SMILIES_EDIT);
57 
58  $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
59  $form->setExtra('enctype="multipart/form-data"');
60  $form->addElement(new XoopsFormText(_AM_SYSTEM_SMILIES_CODE, 'code', 26, 25, $this->getVar('code')), true);
61  $form->addElement(new XoopsFormText(_AM_SYSTEM_SMILIES_DESCRIPTION, 'emotion', 50, 50, $this->getVar('emotion')), true);
62 
63  $imgtray_img = new XoopsFormElementTray( _AM_SYSTEM_SMILIES_FILE, '<br />' );
64  $imgpath_img = sprintf( _AM_SYSTEM_SMILIES_IMAGE_PATH, XOOPS_UPLOAD_PATH . '/smilies/' );
65  $imageselect_img = new XoopsFormSelect( $imgpath_img, 'smile_url', $blank_img );
66  $image_array_img = XoopsLists::getImgListAsArray( XOOPS_UPLOAD_PATH . '/smilies' );
67  $imageselect_img->addOption("$blank_img", $blank_img);
68  foreach ($image_array_img as $image_img) {
69  $imageselect_img->addOption("$image_img", $image_img);
70  }
71  $imageselect_img->setExtra( 'onchange="showImgSelected(\'xo-smilies-img\', \'smile_url\', \'smilies\', \'\', \'' . XOOPS_UPLOAD_URL . '\' )"' );
72  $imgtray_img->addElement( $imageselect_img, false);
73  $imgtray_img->addElement( new XoopsFormLabel( '', "<br /><img src='" . XOOPS_UPLOAD_URL . "/smilies/" . $blank_img . "' name='image_img' id='xo-smilies-img' alt='' />" ) );
74 
75  $fileseltray_img = new XoopsFormElementTray('<br />','<br /><br />');
76  $fileseltray_img->addElement(new XoopsFormFile(_AM_SYSTEM_SMILIES_UPLOADS , 'smile_url', 500000),false);
77  $fileseltray_img->addElement(new XoopsFormLabel(''), false);
78  $imgtray_img->addElement($fileseltray_img);
79  $form->addElement($imgtray_img);
80 
81  if (!$this->isNew()) {
82  $form->addElement(new XoopsFormHidden('smilies_id', $this->getVar('id')));
83  $display = $this->getVar('display');
84  } else {
85  $display = 0;
86  }
87 
88  $form->addElement(new XoopsFormRadioYN(_AM_SYSTEM_SMILIES_OFF, 'display', $display));
89 
90  $form->addElement(new XoopsFormHidden('op', 'save_smilie'));
91  $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
92  return $form;
93  }
94 }
95 
106 class systemsmiliesHandler extends XoopsPersistableObjectHandler
107 {
108 
109  function __construct($db)
110  {
111  parent::__construct($db, 'smiles', 'SystemSmilies', 'id', 'code');
112  }
113 
114 }
115 
116 ?>