/** * This method will process all results added in a response */ function processResults() { // include support for wysiwyg editors if (!empty($this->wysiwyg_ids) || !empty($this->wysiwyg_forms)) { require_once dirname(__FILE__) . '/editors/YDAjaxEditor.php'; // add suport for wysiwyg editors applyed to IDs foreach ($this->wysiwyg_ids as $htmlID) { $this->response->addScript(YDAjaxEditor::JSinit($htmlID)); } // add support for wysiwyg editors applyed to form elements // foreach form, cycle all wysiwyg elements to compute their initialization foreach ($this->wysiwyg_forms as $formName => $formElements) { foreach ($formElements as $formElementID) { $this->response->addScript(YDAjaxEditor::JSinit($formElementID)); } } } // return XML to client browser return $this->response->getXML(); }
/** * This is a helper method to compute all JS that is needed to get a form element * * @param $formElement Form element object * @param $options The options for the form element */ function __getJSFormElement($formElement, $options) { $js = ''; // check if this element is a wysiwyg editor if (in_array($formElement->getAttribute('id'), $this->wysiwyg_ids)) { // include editor lib require_once dirname(__FILE__) . '/editors/YDAjaxEditor.php'; // wysiwyg editor require to copy their html to a textarea before submit $js .= YDAjaxEditor::JScopy($formElement->getAttribute('id')); } // add JS return value $js .= $formElement->getJS($options); // compute javascript function name $jsfunction = $this->prefix . 'get' . $formElement->getName(); // add javascript function code to custom js (to be included in template head) if (!$this->isOnResponse()) { //$this->customjs[$jsfunction . '()' ] = $js; $this->template->addJavascript("function " . $jsfunction . '()' . "{" . $js . "}\n", true); } else { $this->response->addScript($jsfunction . '=function(){' . $js . '}'); } // add function name to arguments list return $jsfunction . '()'; }