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; }
$votes_distrib[$i]['vote'] = 0; } for ($i = 0; $i < sizeof($poll_votes); $i++) { $votes_distrib[$poll_votes[$i]['vote']]['vote']++; } for ($i = 0; $i < sizeof($votes_distrib); $i++) { $votes_distrib[$i]['perc'] = round($votes_distrib[$i]['vote'] / sizeof($poll_votes), 2); $votes_distrib[$i]['text'] = $poll_data[0]['options'][$i]; $votes_distrib[$i]['width'] = $votes_distrib[$i]['perc'] * 200; } $smarty->assign("T_POLL_VOTES", $votes_distrib); $smarty->assign("T_POLL_TOTALVOTES", sizeof($poll_votes)); $form = new HTML_QuickForm("poll_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=forum&poll=" . $_GET['poll'], "", null, true); //Build the form foreach ($poll_data[0]['options'] as $key => $option) { $group[] = HTML_Quickform::createElement('radio', 'vote', null, $option, $key); } $form->addGroup($group, 'options', '', '<br/>'); $form->addRule('options', _PLEASEPICKANOPTION, 'required', null, 'client'); $form->addElement('submit', 'submit_poll', _VOTE, 'class = "flatButton"'); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); //pr($values); //debug(); $res = eF_getTableData("f_users_to_polls", "*", "f_poll_ID=" . $values['options']['vote'] . " and users_LOGIN='******'login'] . "'"); //debug(false); if (sizeof($res) > 0) { $message = _YOUHAVEALREADYVOTED; $message_type = 'failure'; } else { $fields = array('f_poll_ID' => $_GET['poll'], 'users_LOGIN' => $_SESSION['s_login'], 'vote' => $values['options']['vote'], 'timestamp' => time());
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; }