1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: class PagePage_contentForm extends Xoops\Form\ThemeForm
24: {
25: 26: 27:
28: public function __construct(PagePage_content $obj)
29: {
30: $helper = Page::getInstance();
31: $xoops = $helper->xoops();
32: $xoops->theme()->addStylesheet('modules/page/css/styles.css');
33:
34: $title = $obj->isNew() ? PageLocale::A_ADD_CONTENT : PageLocale::A_EDIT_CONTENT;
35: parent::__construct($title, 'form', 'content.php', 'post', true, 'raw');
36: $tabTray = new Xoops\Form\TabTray('', 'uniqueid');
37:
38: 39: 40:
41: $tab1 = new Xoops\Form\Tab(PageLocale::TAB_MAIN, 'main');
42:
43:
44:
45: $content_author = $obj->isNew() ? $xoops->user->getVar('uid') : $obj->getVar('content_author');
46: $tab1->addElement(new Xoops\Form\SelectUser(XoopsLocale::AUTHOR, 'content_author', true, $content_author, 1, false), true);
47:
48:
49: $tab1->addElement(new Xoops\Form\DateTime(XoopsLocale::DATE, 'content_create', $obj->getVar('content_create')));
50:
51: $tab1->addElement(new Xoops\Form\Text(XoopsLocale::TITLE, 'content_title', 12, 255, $obj->getVar('content_title'), ''), true);
52:
53: $editor_configs=array();
54: $editor_configs['editor'] = $helper->getConfig('page_editor');
55: $editor_configs['rows'] = 12;
56: $editor_configs['cols'] = 12;
57:
58:
59: $editor_configs['name'] = 'content_shorttext';
60: $editor_configs['value'] = $obj->getVar('content_shorttext', 'e');
61: $tab1->addElement(new Xoops\Form\Editor(XoopsLocale::SHORT_TEXT, 'content_shorttext', $editor_configs), true);
62:
63:
64: $editor_configs['name'] = 'content_text';
65: $editor_configs['value'] = $obj->getVar('content_text', 'e');
66: $text = new Xoops\Form\Editor(XoopsLocale::TEXT, 'content_text', $editor_configs);
67: $text->setDescription(PageLocale::CONTENT_TEXT_DESC);
68: $tab1->addElement($text, false);
69:
70:
71: $weight = new Xoops\Form\Text(XoopsLocale::WEIGHT, 'content_weight', 1, 5, $obj->getVar('content_weight'), '');
72: $weight->setPattern('^\d+$', PageLocale::E_WEIGHT);
73: $tab1->addElement($weight, true);
74:
75: $tabTray->addElement($tab1);
76:
77: 78: 79:
80: $tab2 = new Xoops\Form\Tab(PageLocale::TAB_METAS, 'metas');
81:
82: $tab2->addElement(new Xoops\Form\TextArea(PageLocale::CONTENT_META_KEYWORDS, 'content_mkeyword', $obj->getVar('content_mkeyword'), 1, 11, PageLocale::CONTENT_META_KEYWORDS_DSC));
83:
84: $tab2->addElement(new Xoops\Form\TextArea(PageLocale::CONTENT_META_DESCRIPTION, 'content_mdescription', $obj->getVar('content_mdescription'), 5, 11));
85:
86: $tabTray->addElement($tab2);
87:
88: 89: 90:
91: $tab3 = new Xoops\Form\Tab(PageLocale::TAB_OPTIONS, 'options');
92:
93: $content_option = $obj->getOptions();
94: $checkbox = new Xoops\Form\Checkbox(XoopsLocale::OPTIONS, 'content_option', $content_option, false);
95: $checkbox->setDescription(PageLocale::CONTENT_OPTIONS_DSC);
96: foreach ($obj->options as $option) {
97: $checkbox->addOption($option, \Xoops\Locale::translate('L_CONTENT_DO' . strtoupper($option), 'page'));
98: }
99: $tab3->addElement($checkbox);
100:
101: $tab3->addElement(new Xoops\Form\RadioYesNo(PageLocale::Q_ON_MAIN_PAGE, 'content_maindisplay', $obj->getVar('content_maindisplay')));
102:
103: $tab3->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::ACTIVE, 'content_status', $obj->getVar('content_status')));
104:
105: $tabTray->addElement($tab3);
106:
107: 108: 109:
110: if ($helper->isUserAdmin()) {
111: $tab4 = new Xoops\Form\Tab(PageLocale::TAB_PERMISSIONS, 'permissions');
112:
113: $group_list = $xoops->getHandlerMember()->getGroupList();
114: $full_list = array_keys($group_list);
115: if (!$obj->isNew()) {
116: $module_id = $helper->getModule()->getVar('mid', 'n');
117: $groups_ids_view = $helper->getGrouppermHandler()->getGroupIds('page_view_item', $obj->getVar('content_id'), $module_id);
118: $groups_ids_view = array_values($groups_ids_view);
119: $groups_can_view_checkbox = new Xoops\Form\Checkbox(PageLocale::CONTENT_SELECT_GROUPS, 'groups_view_item[]', $groups_ids_view, false);
120: } else {
121: $groups_can_view_checkbox = new Xoops\Form\Checkbox(PageLocale::CONTENT_SELECT_GROUPS, 'groups_view_item[]', $full_list, false);
122: }
123: $groups_can_view_checkbox->addOptionArray($group_list);
124: $tab4->addElement($groups_can_view_checkbox);
125:
126: $tabTray->addElement($tab4);
127: }
128:
129: $this->addElement($tabTray);
130:
131: $this->addElement(new Xoops\Form\Hidden('content_id', $obj->getVar('content_id')));
132:
133: 134: 135:
136: $buttonTray = new Xoops\Form\ElementTray('', '');
137: $buttonTray->addElement(new Xoops\Form\Hidden('op', 'save'));
138:
139: $buttonSubmit = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
140: $buttonSubmit->setClass('btn btn-success');
141: $buttonTray->addElement($buttonSubmit);
142:
143: $buttonReset = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
144: $buttonReset->setClass('btn btn-warning');
145: $buttonTray->addElement($buttonReset);
146:
147: $buttonCancel = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
148: $buttonCancel->setExtra("onclick='javascript:history.go(-1);'");
149: $buttonCancel->setClass('btn btn-danger');
150: $buttonTray->addElement($buttonCancel);
151:
152: $this->addElement($buttonTray);
153: }
154: }
155: