public function render($name, $value = null, $attributes = array(), $errors = array()) { $js = ''; if (self::$isFirstRender) { sfContext::getInstance()->getResponse()->addSmtJavascript('jquery.min.js'); sfContext::getInstance()->getResponse()->addSmtJavascript('jquery-ui.min.js'); sfContext::getInstance()->getResponse()->addSmtJavascript('tiny_mce/tiny_mce'); sfContext::getInstance()->getResponse()->addSmtJavascript('op_emoji'); sfContext::getInstance()->getResponse()->addSmtJavascript('Selection'); sfContext::getInstance()->getResponse()->addSmtJavascript('decoration'); $relativeUrlRoot = sfContext::getInstance()->getRequest()->getRelativeUrlRoot(); $js .= sprintf("function op_mce_editor_get_config() { return %s; }\n", json_encode(self::getButtons())); $js .= sprintf('function op_get_relative_uri_root() { return "%s"; }', $relativeUrlRoot); self::$isFirstRender = false; } if ($js) { sfProjectConfiguration::getActive()->loadHelpers('Javascript'); $js = javascript_tag($js); } $id = $this->getId($name, $attributes); $this->setOption('textarea_template', '<div id="' . $id . '_buttonmenu" class="' . $id . '">' . get_partial('global/richTextareaOpenPNEButton', array('id' => $id, 'configs' => self::getButtons(), 'onclick_actions' => self::$buttonOnclickActions)) . '</div>' . $this->getOption('textarea_template')); return $js . parent::render($name, $value, $attributes, $errors); }
public function render($name, $value = null, $attributes = array(), $errors = array()) { if (sfConfig::get('sf_app') == 'mobile_frontend') { return parent::render($name, $value, $attributes, $errors); } $js = ''; if (self::$isFirstRenderOpenPNE) { sfProjectConfiguration::getActive()->loadHelpers('Partial'); sfContext::getInstance()->getResponse()->addJavascript('/sfProtoculousPlugin/js/prototype'); sfContext::getInstance()->getResponse()->addJavascript('op_emoji'); sfContext::getInstance()->getResponse()->addJavascript('Selection'); sfContext::getInstance()->getResponse()->addJavascript('decoration'); $relativeUrlRoot = sfContext::getInstance()->getRequest()->getRelativeUrlRoot(); foreach ($this->loadPluginList as $key => $path) { $js .= sprintf('tinymce.PluginManager.load("%s", "%s");' . "\n", $key, $path); } $js .= sprintf("function op_mce_editor_get_config() { return %s; }\n", json_encode(self::getButtons())); $js .= sprintf('function op_get_relative_uri_root() { return "%s"; }', $relativeUrlRoot); self::$isFirstRenderOpenPNE = false; } if ($js) { sfProjectConfiguration::getActive()->loadHelpers('Javascript'); $js = javascript_tag($js); } $id = $this->getId($name, $attributes); $this->setOption('textarea_template', '<div id="' . $id . '_buttonmenu" class="' . $id . '">' . get_partial('global/richTextareaOpenPNEButton', array('id' => $id, 'configs' => self::getButtons(), 'onclick_actions' => self::$buttonOnclickActions)) . '</div>' . $this->getOption('textarea_template')); return $js . parent::render($name, $value, $attributes, $errors); }