public function getForm($target = '/admin/Content') { $form = new Form('content_addedit', 'POST', $target, '', array('class' => 'admin')); $form->addElement('text', 'urlkey', 'Page URL Key'); if (Module_Content::hasRestriction()) { $form->addElement('select', 'access', 'Page Access', array('public' => 'Public', 'restricted' => 'Restricted')); } else { $form->addElement('hidden', 'access', 'public'); } $form->addElement('text', 'metatitle', 'SEO Title', array('style' => 'width: 70%;')); $form->addElement('text', 'metadesc', 'SEO Description', array('style' => 'width: 70%;')); $form->addElement('text', 'metakeywords', 'SEO Keywords', array('style' => 'width: 70%;')); $form->applyFilter('urlkey', 'trim'); $form->addRule('urlkey', 'Please enter a URL key', 'required', null, 'client'); $form->addElement('submit', 'submit', 'Continue'); if ($form->validate() && isset($_REQUEST['submit'])) { $this->setPageName($form->exportValue('urlkey')); $this->setTimestamp(date('Y-m-d H:i:s')); $metadata['title'] = $form->exportValue('metatitle'); $metadata['description'] = $form->exportValue('metadesc'); $metadata['keywords'] = $form->exportValue('metakeywords'); $_SESSION['metadata'] = $metadata; $this->setAccess($form->exportValue('access')); $this->save(); } return $form; }
public function getAddEditForm() { $form = new Form('page_addedit', 'POST', '/admin/Content', '', array('class' => 'admin')); $form->addElement('text', 'title', 'Page Title', array('value' => $this->getPageTitle())); $sql = 'select * from locale order by display_name'; $rows = Database::singleton()->query_fetch_all($sql); $languages = array(); foreach ($rows as $language) { $languages[$language['id']] = $language['display_name']; } $form->addElement('select', 'language', 'Language', $languages); $defaultValues['language'] = array($this->getLocaleId()); $form->setDefaults($defaultValues); $form->setConstants(array('action' => 'updatePage', 'id' => $this->getId(), 'section' => 'addEdit', 'parent_id' => $this->getParentId())); $form->addElement('hidden', 'id'); $form->addElement('hidden', 'section'); $form->addElement('hidden', 'action'); $oQFElement = HTML_Quickform::createElement('tinymce', 'editor', 'Content'); //$oQFElement->setFCKProps ( '/core/fckeditor/', 'Default', '100%', '500', array ('SkinPath' => 'editor/skins/office2003/', 'DefaultLanguage' => 'en', 'StylesXmlPath' => '/core/fckeditor/fckstyles.xml', 'UseBROnCarriageReturn' => 'true', 'StartupFocus' => 'false', // 'CustomConfigurationsPath' => 'config.js', 'EditorAreaCSS' => 'fck_editorarea.css' ) ); $oQFElement->setValue($this->getContent()); $form->addElement($oQFElement); $form->addElement('submit', 'submit', 'Save and auto-publish', array('id' => 'submit')); $form->addElement('submit', 'submit_leavestatus', 'Save (but don\'t publish)'); $form->applyFilter('urlkey', 'title'); $form->addRule('title', 'Please enter a Page Title', 'required', null, 'client'); $form->addRule('editor', 'Please enter some Page Content', 'required', null, 'client'); if ($form->validate() && (isset($_REQUEST['submit']) || isset($_REQUEST['submit_leavestatus']))) { $this->setContent($_REQUEST['editor']); $this->setLocaleId($_REQUEST['language']); $this->setPageTitle($_REQUEST['title']); $this->setTimestamp(date('Y-m-d H:i:s')); if (isset($_SESSION['metadata'])) { $this->setMetaData($_SESSION['metadata']); unset($_SESSION['metadata']); } if (isset($_REQUEST['submit'])) { $this->setStatus(true); } $this->save(); } return $form; }
public function getAddEditForm($target = '/admin/Menu') { require_once 'Menu.php'; if (isset($_REQUEST['id'])) { $item = new MenuItem($_REQUEST['id']); } $status = array('active' => 'Active', 'disabled' => 'Disabled'); $defaultValues['status'] = @array($item->status); $menu = new Menu(); $parent = $menu->toArray(); $defaultValues['parent'] = @array($item->parent); $form = new Form('menu_addedit', 'POST', $target, '', array('class' => 'admin')); if (@$item) { $form->setConstants(array('id' => $item->getId(), 'section' => 'addedit')); $form->addElement('hidden', 'id'); $links = $menu->getLinkables($item->module_id); } else { $form->setConstants(array('section' => 'addedit')); } $form->addElement('hidden', 'section'); $form->addElement('text', 'display', 'Display Name', array('value' => @$item->display)); $active = Config::getActiveModules(); $linkableType = array(); foreach ($active as $module) { $modulename = 'Module_' . $module['module']; include_once SITE_ROOT . '/modules/' . $module['module'] . '/' . $module['module'] . '.php'; $obj = new $modulename(); $test = new ReflectionClass($modulename); if ($test->hasMethod('getValidLinks')) { $linkableType[$module['id']] = $obj->linkType(); } } if (@(!$item)) { $keys = array_keys($linkableType); $links = $menu->getLinkables($keys[0]); } $defaultValues['link'] = @array($item->link_id); $defaultValues['linktype'] = @array($item->module_id); $defaultValues['target'] = @array($item->target); $form->addElement('select', 'status', 'Status', $status); $form->addElement('select', 'linktype', 'Link Type', $linkableType); $form->addElement('select', 'link', 'Link To', $links); $form->addElement('select', 'target', 'Open In', array('same' => 'Same Window', 'new' => 'New Window')); $form->addElement('select', 'parent', 'Parent Item', $parent); $form->addElement('submit', 'submit', 'Save'); $form->applyFilter('display', 'trim'); $form->addRule('display', 'Please enter a display name', 'required', null, 'client'); $form->addRule('parent', 'Please choose a parent', 'required', null, 'client'); $form->addRule('linktype', 'Please choose a link type', 'required', null, 'client'); $form->addRule('link', 'Please choose a link page', 'required', null, 'client'); $form->addRule('target', 'Please choose a target', 'required', null, 'client'); $form->addRule('status', 'Please choose a status', 'required', null, 'client'); $form->setDefaults($defaultValues); if (isset($_REQUEST['submit']) && $form->validate()) { $this->template = 'admin/menu.tpl'; $this->doMenuSubmit(); return false; } else { if (isset($_REQUEST['submit'])) { $formArray['errors'] = $form->_errors; } } return $form; }
public function contentForm($newRev = null) { $form = new Form('page_addedit', 'POST', '/admin/Content', '', array('class' => 'admin')); $form->addElement('text', 'title', 'Page Title', array('value' => $newRev->getPageTitle())); $sql = 'select * from locale order by display_name'; $rows = $this->db->query_fetch_all($sql); $languages = array(); foreach ($rows as $language) { $languages[$language['id']] = $language['display_name']; } $form->addElement('select', 'language', 'Language', $languages); $form->addElement('text', 'access', 'Page Access'); $defaultValues['language'] = array($newRev->getLocaleId()); $defaultValues['access'] = $newRev->getAccess(); $form->setDefaults($defaultValues); $form->setConstants(array('action' => 'updatePage', 'id' => $newRev->getId(), 'section' => 'addEdit')); $form->addElement('hidden', 'id'); $form->addElement('hidden', 'section'); $form->addElement('hidden', 'action'); $oQFElement = HTML_Quickform::createElement('tinymce', 'editor', 'Content'); //$oQFElement->setFCKProps ( '/core/fckeditor/', 'Default', '100%', '500', array ('SkinPath' => 'editor/skins/office2003/', 'DefaultLanguage' => 'en', 'StylesXmlPath' => '/core/fckeditor/fckstyles.xml', 'UseBROnCarriageReturn' => 'true', 'StartupFocus' => 'false', // 'CustomConfigurationsPath' => 'config.js', 'EditorAreaCSS' => 'fck_editorarea.css' ) ); $oQFElement->setValue($newRev->getContent()); $form->addElement($oQFElement); $form->addElement('submit', 'submit', 'Save and auto-publish', array('id' => 'submit')); $form->addElement('submit', 'submit_leavestatus', 'Save (but don\'t publish)'); $form->applyFilter('urlkey', 'title'); $form->addRule('title', 'Please enter a Page Title', 'required', null, 'client'); $form->addRule('editor', 'Please enter some Page Content', 'required', null, 'client'); return $form; }