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 ProfileCategory extends XoopsObject
27: {
28: 29: 30:
31: public function __construct()
32: {
33: $this->initVar('cat_id', XOBJ_DTYPE_INT, null, true);
34: $this->initVar('cat_title', XOBJ_DTYPE_TXTBOX);
35: $this->initVar('cat_description', XOBJ_DTYPE_TXTAREA);
36: $this->initVar('cat_weight', XOBJ_DTYPE_INT);
37: }
38:
39: 40: 41: 42: 43: 44: 45:
46: public function getForm($action = false)
47: {
48: if ($action === false) {
49: $action = $_SERVER['REQUEST_URI'];
50: }
51: $title = $this->isNew() ? sprintf(_PROFILE_AM_ADD, _PROFILE_AM_CATEGORY) : sprintf(_PROFILE_AM_EDIT, _PROFILE_AM_CATEGORY);
52:
53: include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
54:
55: $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
56: $form->addElement(new XoopsFormText(_PROFILE_AM_TITLE, 'cat_title', 35, 255, $this->getVar('cat_title')));
57: if (!$this->isNew()) {
58:
59: $form->addElement(new XoopsFormHidden('id', $this->getVar('cat_id')));
60: }
61: $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DESCRIPTION, 'cat_description', $this->getVar('cat_description', 'e')));
62: $form->addElement(new XoopsFormText(_PROFILE_AM_WEIGHT, 'cat_weight', 35, 35, $this->getVar('cat_weight', 'e')));
63:
64: $form->addElement(new XoopsFormHidden('op', 'save'));
65: $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
66:
67: return $form;
68: }
69: }
70:
71: 72: 73: 74:
75: class ProfileCategoryHandler extends XoopsPersistableObjectHandler
76: {
77: 78: 79:
80: public function __construct(XoopsDatabase $db)
81: {
82: parent::__construct($db, 'profile_category', 'profilecategory', 'cat_id', 'cat_title');
83: }
84: }
85: