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 MenusMenus_menuForm extends Xoops\Form\ThemeForm
24: {
25: 26: 27:
28: public function __construct(MenusMenu $obj)
29: {
30: global $menu_id;
31: $xoops = Xoops::getInstance();
32: $helper = Menus::getInstance();
33: $this_handler = $helper->getHandlerMenu();
34: $decorators = MenusDecorator::getAvailableDecorators();
35:
36: $title = $obj->isNew() ? sprintf(_AM_MENUS_ADD_MENUS) : sprintf(_AM_MENUS_EDIT_MENUS);
37:
38: parent::__construct($title, 'form', 'admin_menu.php', 'post', true);
39:
40: $this->addElement(new Xoops\Form\Text(_AM_MENUS_MENU_TITLE, 'title', 50, 255, $obj->getVar('title'), ''), true);
41:
42: $this->addElement(new Xoops\Form\Text(_AM_MENUS_MENU_ALTTITLE, 'alt_title', 50, 255, $obj->getVar('alt_title'), ''));
43:
44: $this->addElement(new Xoops\Form\Text(_AM_MENUS_MENU_LINK, 'link', 50, 255, $obj->getVar('link'), ''));
45:
46: $this->addElement(new Xoops\Form\Text(_AM_MENUS_MENU_IMAGE, 'image', 50, 255, $obj->getVar('image'), ''));
47:
48: $criteria = new CriteriaCompo(new Criteria('mid', $menu_id));
49: $criteria->add(new Criteria('id', $obj->getVar('id'), '<>'));
50: $criteria->setSort('weight');
51: $criteria->setOrder('ASC');
52: $results = $this_handler->getAll($criteria, array('title', 'id', 'pid'));
53: $parent_tree = new XoopsObjectTree($results, 'id', 'pid');
54: $parent_select = $parent_tree->makeSelBox('pid', 'title', '-- ', $obj->getVar('pid'), true);
55: $this->addElement(new Xoops\Form\Label(_AM_MENUS_MENU_PARENT, $parent_select));
56:
57: $formvis = new Xoops\Form\Select(_AM_MENUS_MENU_VISIBLE, "visible", $obj->getVar('visible'));
58: $formvis->addOption("0", XoopsLocale::NO);
59: $formvis->addOption("1", XoopsLocale::YES);
60: $this->addElement($formvis);
61:
62: $formtarget = new Xoops\Form\Select(_AM_MENUS_MENU_TARGET, "target", $obj->getVar('target'));
63: $formtarget->addOption("_self", _AM_MENUS_MENU_TARG_SELF);
64: $formtarget->addOption("_blank", _AM_MENUS_MENU_TARG_BLANK);
65: $formtarget->addOption("_parent", _AM_MENUS_MENU_TARG_PARENT);
66: $formtarget->addOption("_top", _AM_MENUS_MENU_TARG_TOP);
67: $this->addElement($formtarget);
68:
69: $formgroups = new Xoops\Form\SelectGroup(_AM_MENUS_MENU_GROUPS, "groups", true, $obj->getVar('groups'), 5, true);
70: $formgroups->setDescription(_AM_MENUS_MENU_GROUPS_HELP);
71: $this->addElement($formgroups);
72:
73: $formhooks = new Xoops\Form\Select(_AM_MENUS_MENU_ACCESS_FILTER, "hooks", $obj->getVar('hooks'), 5, true);
74: $accessFilter = array();
75: foreach ($decorators as $decorator) {
76: $decorator->accessFilter($accessFilter);
77: }
78: foreach ($accessFilter as $result) {
79: $formhooks->addOption($result['method'], $result['name']);
80: }
81: $this->addElement($formhooks);
82:
83: $formcss = new Xoops\Form\Text(_AM_MENUS_MENU_CSS, 'css', 50, 255, $obj->getVar('css'));
84: $this->addElement($formcss);
85:
86: $this->addElement(new Xoops\Form\Hidden('id', $obj->getVar('id')));
87: $this->addElement(new Xoops\Form\Hidden('mid', $obj->getVar('mid')));
88: $this->addElement(new Xoops\Form\Hidden('op', 'save'));
89: $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
90: }
91: }
92: