XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
userrank.php
Go to the documentation of this file.
1 <?php
19 defined("XOOPS_ROOT_PATH") or die("XOOPS root path not defined");
20 
28 {
29  function __construct()
30  {
31  parent::__construct();
32  $this->initVar( 'rank_id', XOBJ_DTYPE_INT, null, false, 5 );
33  $this->initVar( 'rank_title', XOBJ_DTYPE_TXTBOX, null, false );
34  $this->initVar( 'rank_min', XOBJ_DTYPE_INT, null, false, 8 );
35  $this->initVar( 'rank_max', XOBJ_DTYPE_INT,null, false, 8 );
36  $this->initVar( 'rank_special', XOBJ_DTYPE_INT, null, false,1 );
37  $this->initVar( 'rank_image', XOBJ_DTYPE_TXTBOX, null, false );
38  }
39 
40  function getForm($action = false)
41  {
42  if ($this->isNew()) {
43  $blank_img = 'blank.gif';
44  } else {
45  $blank_img = str_replace( 'ranks/', '', $this->getVar('rank_image', 'e'));
46  }
47  if ($action === false) {
48  $action = $_SERVER['REQUEST_URI'];
49  }
50 
51  $title = $this->isNew() ? sprintf(_AM_SYSTEM_USERRANK_ADD) : sprintf(_AM_SYSTEM_USERRANK_EDIT);
52 
53  $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
54  $form->setExtra('enctype="multipart/form-data"');
55 
56  $form->addElement( new XoopsFormText( _AM_SYSTEM_USERRANK_TITLE, 'rank_title', 50, 50, $this->getVar('rank_title'), true ) );
57  $form->addElement( new XoopsFormText( _AM_SYSTEM_USERRANK_MINPOST, 'rank_min', 10, 10, $this->getVar('rank_min') ) );
58  $form->addElement( new XoopsFormText( _AM_SYSTEM_USERRANK_MAXPOST, 'rank_max', 10, 10, $this->getVar('rank_max') ) );
59 
60  $imgtray_img = new XoopsFormElementTray( _AM_SYSTEM_USERRANK_IMAGE, '<br />' );
61  $imgpath_img = sprintf( _AM_SYSTEM_USERRANK_IMAGE_PATH, XOOPS_UPLOAD_PATH . '/ranks/' );
62  $imageselect_img = new XoopsFormSelect( $imgpath_img, 'rank_image', $blank_img);
63  $image_array_img = XoopsLists::getImgListAsArray( XOOPS_UPLOAD_PATH . '/ranks' );
64  $imageselect_img->addOption( "$blank_img", $blank_img );
65  foreach ($image_array_img as $image_img) {
66  $imageselect_img->addOption( "$image_img", $image_img );
67  }
68  $imageselect_img->setExtra( "onchange='showImgSelected(\"xo-ranks-img\", \"rank_image\", \"ranks\", \"\", \"" . XOOPS_UPLOAD_URL . "\")'" );
69  $imgtray_img->addElement( $imageselect_img, false );
70  $imgtray_img->addElement( new XoopsFormLabel( '', "<br /><img src='" . XOOPS_UPLOAD_URL . "/ranks/" . $blank_img . "' name='image_img' id='xo-ranks-img' alt='' />" ) );
71 
72  $fileseltray_img = new XoopsFormElementTray('<br />','<br /><br />');
73  $fileseltray_img->addElement( new XoopsFormFile( _AM_SYSTEM_USERRANK_UPLOAD , 'rank_image', 500000 ), false );
74  $fileseltray_img->addElement( new XoopsFormLabel(''), false );
75  $imgtray_img->addElement( $fileseltray_img );
76  $form->addElement( $imgtray_img );
77 
78  if (!$this->isNew()) {
79  $rank_special = $this->getVar('rank_special');
80  } else {
81  $rank_special = 0;
82  }
83 
84  $special_tray = new XoopsFormElementTray(_AM_SYSTEM_USERRANK_SPECIAL, '<br />');
85  $special_tray->setDescription( _AM_SYSTEM_USERRANK_SPECIAL_CAN );
86  $special_tray->addElement( new XoopsFormRadioYN( '', 'rank_special', $rank_special ) );
87  $form->addElement( $special_tray );
88  if ( !$this->isNew() ) {
89  $form->addElement( new XoopsFormHidden( 'rank_id', $this->getVar('rank_id')) );
90  }
91  $form->addElement( new XoopsFormHidden( 'op', 'userrank_save') );
92  $form->addElement( new XoopsFormButton( '', 'submit', _SUBMIT, 'submit') );
93  return $form;
94  }
95 }
96 
108 {
109 
110  function __construct( $db )
111  {
112  parent::__construct( $db, 'ranks', 'SystemUserrank', 'rank_id', 'rank_title' );
113  }
114 
115 }
116 
117 ?>