/** * Call this before any output is made. It will process the form results, if applicable, * and return an according exit code. * * This indicates which (if any) submit button was pressed. If 'editing' is * returned, this means that either there was not data submitted yet, or that * form validation has failed. * * //This call ensures that MidCOM runs uncached. * * @return string One of 'editing', 'save', 'next', 'previous' and 'cancel' */ function process_form($ajax_mode = false) { // Make sure we have CSS loaded $this->add_stylesheet(MIDCOM_STATIC_URL . "/midcom.helper.datamanager2/legacy.css"); $results = $this->form->getSubmitValues(true); // Get the result (this includes validation) $exitcode = $this->compute_form_result(); // Check if we were really submitted, if yes, trigger the on_submit event // on the widgets as well: if ($exitcode != 'cancel' && $exitcode != 'previous') { foreach ($this->widgets as $name => $copy) { $this->widgets[$name]->on_submit($results); } } if ($exitcode == 'save' || $exitcode == 'next' || $exitcode == 'preview') { // Iterate over the widgets and tell them to re-synchronize with their // types. foreach ($this->widgets as $name => $copy) { if ($ajax_mode) { if (array_key_exists($name, $results)) { $this->widgets[$name]->sync_type_with_widget($results); } } else { if (!array_key_exists($name, $results)) { $results[$name] = null; } $this->widgets[$name]->sync_type_with_widget($results); } } } return $exitcode; }
/** * This module uses CKeditor editor released under * GNU Lesser General Public License Version 2.1 or later (the "LGPL") * CKeditor - The text editor for Internet - http://www.Ckeditor.net * Copyright (C) 2003-2007 Frederico Caldeira Knabben * * @author Paul Bukowski <*****@*****.**> * @copyright Copyright © 2007, Telaxus LLC * @version 1.0 * @license MIT * @package epesi-libs * @subpackage Ckeditor */ defined("_VALID_ACCESS") || die('Direct access forbidden'); if (!MOBILE_DEVICE && class_exists('HTML_Quickform')) { HTML_Quickform::registerElementType('ckeditor', 'modules/Libs/CKEditor/ckeditor.php', 'HTML_Quickform_ckeditor'); /* load_js('modules/Libs/CKEditor/onsubmit.js');*/ load_css('modules/Libs/CKEditor/frontend.css'); /* Libs_QuickFormCommon::add_on_submit_action("if(typeof(ckeditor_onsubmit)!='undefined')ckeditor_onsubmit(this)");*/ } class Libs_CKEditorCommon extends ModuleCommon { public static function QFfield_cb(&$form, $field, $label, $mode, $default, $desc, $rb_obj, $display_callbacks) { if ($mode == 'add' || $mode == 'edit') { $fck = $form->addElement('ckeditor', $field, $label); $fck->setFCKProps('99%', '300', true); if ($mode == 'edit') { $form->setDefaults(array($field => $default)); } } else {
$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());
<?php /** * Codepress editor * This module uses CodePress editor released under * GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 * * @author Paul Bukowski <*****@*****.**> * @copyright Copyright © 2008, Telaxus LLC * @license MIT * @version 0.1 * @package epesi-libs * @subpackage codepress */ defined("_VALID_ACCESS") || die('Direct access forbidden'); HTML_Quickform::registerElementType('codepress', 'modules/Libs/Codepress/HTML_Quickform_codepress_0.php', 'HTML_Quickform_codepress'); load_js('modules/Libs/Codepress/0.9.6/codepress.js'); eval_js_once('document.observe("e:load", function(){CodePress.run();})'); Libs_QuickFormCommon::add_on_submit_action('CodePress.update(this)'); class Libs_CodepressCommon extends ModuleCommon { }
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 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; }
/** * Form builder * @package CMS * @author Christopher Troup <*****@*****.**> * @version 2.0 */ require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/element.php'; require_once dirname(__FILE__) . '/PEAR/HTML/QuickForm/advmultiselect.php'; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php'; require_once 'HTML/QuickForm/Renderer/Tableless.php'; // Register the fckeditor form element type with the QuickForm object. HTML_Quickform::registerElementType('fckeditor', 'HTML_Quickform_fckeditor.php', 'HTML_Quickform_fckeditor'); HTML_Quickform::registerElementType('tinymce', 'HTML_Quickform_tinymce.php', 'HTML_Quickform_tinymce'); HTML_Quickform::registerElementType('swfchart', 'HTML_Quickform_swfchart.php', 'HTML_Quickform_swfchart'); HTML_Quickform::registerElementType('dbimage', 'HTML_Quickform_dbimage.php', 'HTML_Quickform_dbimage'); /** * Create object oriented Forms * * This is just a wrapper for the PEAR Quickform package. It simplifies syntax as well as registers custom form element * types, such as FCKeditor. * * @package CMS * @subpackage Core */ class Form extends HTML_QuickForm { public function display() { $renderer =& new HTML_QuickForm_Renderer_Tableless(); $this->accept($renderer);