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_relatedForm extends Xoops\Form\ThemeForm
24: {
25: 26: 27:
28: public function __construct(PagePage_related $obj)
29: {
30: $helper = Page::getInstance();
31: $xoops = $helper->xoops();
32:
33: $xoops->theme()->addScript('modules/page/media/jquery/multi-select.0.3-7/js/jquery.multi-select.js');
34: $xoops->theme()->addScript('modules/page/media/jquery/multi-select-init.js');
35: $xoops->theme()->addStylesheet('modules/page/media/jquery/multi-select.0.3-7/css/multi-select.css');
36:
37:
38: $content_Handler = $helper->getContentHandler();
39: $link_Handler = $helper->getLinkHandler();
40:
41: $title = $obj->isNew() ? PageLocale::A_ADD_RELATED : PageLocale::A_EDIT_RELATED;
42:
43: parent::__construct($title, 'form', 'related.php', 'post', true);
44:
45:
46: $this->addElement(new Xoops\Form\Text(PageLocale::RELATED_NAME, 'related_name', 4, 255, $obj->getVar('related_name'), ''), true);
47:
48: $menu = new Xoops\Form\RadioYesNo(PageLocale::RELATED_MENU, 'related_domenu', $obj->getVar('related_domenu'));
49: $menu->setDescription(PageLocale::RELATED_MENU_DSC);
50: $this->addElement($menu, false);
51:
52: $navigation = new Xoops\Form\Select(PageLocale::RELATED_NAVIGATION, 'related_navigation', $obj->getVar('related_navigation'), 1, false);
53: $navigation->addOption(1, PageLocale::L_RELATED_NAVIGATION_OPTION1);
54: $navigation->addOption(2, PageLocale::L_RELATED_NAVIGATION_OPTION2);
55: $navigation->addOption(3, PageLocale::L_RELATED_NAVIGATION_OPTION3);
56: $navigation->addOption(4, PageLocale::L_RELATED_NAVIGATION_OPTION4);
57: $navigation->addOption(5, PageLocale::L_RELATED_NAVIGATION_OPTION5);
58: $navigation->setClass('span3');
59: $this->addElement($navigation);
60:
61: $related_links = $link_Handler->getContentByRelated($obj->getVar('related_id'));
62: $contents_used = $link_Handler->getContentUsed();
63: $contents = $content_Handler->getPageTitle(1);
64:
65: $related_links_form = new Xoops\Form\Select(PageLocale::RELATED_MAIN, 'datas', $related_links, $size = 20, $multiple = true);
66: foreach ($contents as $k => $content) {
67: if (!in_array($content['content_id'], $contents_used) || in_array($content['content_id'], $related_links)) {
68: $related_links_form->addOption($content['content_id'], $content['content_title']);
69: }
70: }
71: $this->addElement($related_links_form, true);
72:
73: $this->addElement(new Xoops\Form\Hidden('related_id', $obj->getVar('related_id')));
74:
75: 76: 77:
78: $buttonTray = new Xoops\Form\ElementTray('', '');
79: $buttonTray->addElement(new Xoops\Form\Hidden('op', 'save'));
80:
81: $buttonSubmit = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
82: $buttonSubmit->setClass('btn btn-success');
83: $buttonTray->addElement($buttonSubmit);
84:
85: $buttonReset = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
86: $buttonReset->setClass('btn btn-warning');
87: $buttonTray->addElement($buttonReset);
88:
89: $buttonCancel = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
90: $buttonCancel->setExtra("onclick='javascript:history.go(-1);'");
91: $buttonCancel->setClass('btn btn-danger');
92: $buttonTray->addElement($buttonCancel);
93:
94: $this->addElement($buttonTray);
95: }
96: }
97: