public function executeRichTextarea(sfWebRequest $request) { $this->sortForm = new BaseForm(); $this->configForm = new opRichTextareaOpenPNEConfigForm(); $this->buttonConfigForm = new opRichTextareaOpenPNEButtonConfigForm(); $this->buttonConfig = opWidgetFormRichTextareaOpenPNE::getAllButtons(); if ($request->isMethod(sfWebRequest::POST)) { $this->configForm->bind($request->getParameter('config')); $this->buttonConfigForm->bind($request->getParameter('button')); if ($this->configForm->isValid() && $this->buttonConfigForm->isValid()) { $this->configForm->save(); $this->buttonConfigForm->save(); } } }
public function configure() { //initialize new opWidgetFormRichTextareaOpenPNE(); $allButtons = opWidgetFormRichTextareaOpenPNE::getAllButtons(); $buttons = opWidgetFormRichTextareaOpenPNE::getButtons(); $diff = array_diff(array_keys($allButtons), array_keys($buttons)); foreach ($buttons as $key => $button) { $this->setWidget($key, new sfWidgetFormInputCheckbox()); $this->setValidator($key, new sfValidatorBoolean()); $this->setDefault($key, true); } foreach ($diff as $buttonName) { $this->setWidget($buttonName, new sfWidgetFormInputCheckbox()); $this->setValidator($buttonName, new sfValidatorBoolean()); $this->setDefault($buttonName, false); } $this->widgetSchema->setNameFormat('button[%s]'); }
function op_decoration($string, $is_strip = false, $is_use_stylesheet = null, $is_html_tag_followup = true) { if (is_null($is_use_stylesheet)) { $is_use_stylesheet = true; if (sfConfig::get('sf_app') == 'mobile_frontend') { $is_use_stylesheet = false; } } return opWidgetFormRichTextareaOpenPNE::toHtml($string, $is_strip, $is_use_stylesheet, $is_html_tag_followup); }
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); }
<?php opWidgetFormRichTextareaOpenPNE::addExtension('opRichTextareaKakiageExtension');
<?php include_once dirname(__FILE__) . '/../../bootstrap/unit.php'; sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('pc_frontend', 'test', true)); include_once sfConfig::get('sf_lib_dir') . '/vendor/symfony/lib/helper/HelperHelper.php'; use_helper('Tag'); $t = new lime_test(27, new lime_output_color()); //------------------------------------------------------------ $t->diag('opWidgetFormRichTextareaOpenPNE::toHtml() non strip'); $patterns = array(array('<op:s>どーん</op:s>', '<span class="op_s">どーん</span>', 'Check default strike tag.'), array('<op:s>どどー<op>ん</op:s>', '<span class="op_s">どどー<op>ん</span>', 'Check strike tag with broken tag.'), array('<op:s>どどー', '<span class="op_s">どどー</span>', 'Check strike tag what is not having end tag.'), array('<op:a<op:i>', '<op:a<span class="op_i"></span>', 'Check italic tag with broken tag where is top.'), array('<op:i color="#333<op:i>">#333</op:i>', '<op:i color="#333<span class="op_i">">#333</span>', 'Check italic tag what have some broken tags.'), array('<op:font color="#333333">#333</op:font>', '<span class="op_font" style="color:#333333;">#333</span>', 'Check default color tag what have some broken tags.'), array('<op:tetetetetete0111111>', '<span class="op_tetetetetete0111111"></span>', 'Check undefined op tag.'), array('<op:i<br />><op:', '<op:i<br />><op:', 'Check broken tag witdh br tag.'), array('<op:font color="expression(alert(0))">Attack!</op:font>', '<span class="op_font" style="">Attack!</span>', 'Check color tag witdh CSRF Attack.')); foreach ($patterns as $pattern) { $t->is(opWidgetFormRichTextareaOpenPNE::toHtml($pattern[0], false, true, true), $pattern[1], $pattern[2]); } //------------------------------------------------------------ $t->diag('opWidgetFormRichTextareaOpenPNE::toHtml() strip'); $patterns2 = array(array('<op:s>どーん</op:s>', 'どーん', 'Check default strike tag.'), array('<op:s>どどー<op>ん</op:s>', 'どどー<op>ん', 'Check strike tag with broken tag.'), array('<op:s>どどー', 'どどー', 'Check strike tag what is not having end tag.'), array('<op:a<op:i>', '<op:a', 'Check italic tag with broken tag where is top.'), array('<op:i color="#333<op:i>">#333</op:i>', '<op:i color="#333">#333', 'Check italic tag what have some broken tags.'), array('<op:font color="#333">#333</op:font>', '#333', 'Check default color tag what have some broken tags.'), array('<op:tetetetetete0111111>', '', 'Check undefined op tag.'), array('<op:i<br />><op:', '<op:i<br />><op:', 'Check broken tag witdh br tag.'), array('<op:font color="expression(alert(0))">Attack!</op:font>', 'Attack!', 'Check color tag witdh CSRF Attack.')); foreach ($patterns2 as $pattern2) { $t->is(opWidgetFormRichTextareaOpenPNE::toHtml($pattern2[0], true, true, true), $pattern2[1], $pattern2[2]); } //------------------------------------------------------------ $t->diag('opWidgetFormRichTextareaOpenPNE::toHtml() followup'); $patterns3 = array(array('<op:s>どーん', '<span class="op_s">どーん</span>', 'Check default strike tag.'), array('<op:s>どどー<op>ん', '<span class="op_s">どどー<op>ん</span>', 'Check strike tag with broken tag.'), array('<op:s>どどー', '<span class="op_s">どどー</span>', 'Check strike tag what is not having end tag.'), array('<op:a<op:i>', '<op:a<span class="op_i"></span>', 'Check italic tag with broken tag where is top.'), array('<op:i color="#333<op:i>">#333', '<op:i color="#333<span class="op_i">">#333</span>', 'Check italic tag what have some broken tags.'), array('<op:font color="#333333">#333', '<span class="op_font" style="color:#333333;">#333</span>', 'Check default color tag what have some broken tags.'), array('<op:tetetetetete0111111>', '<span class="op_tetetetetete0111111"></span>', 'Check undefined op tag.'), array('<op:i><op:<op:i><op:i><op:i><op:333333>', '<span class="op_i"><op:<span class="op_i"><span class="op_i"><span class="op_i"><span class="op_333333"></span></span></span></span></span>', 'Check 5 open tags what have not close tag.'), array('<op:font color="expression(alert(0))">Attack!', '<span class="op_font" style="">Attack!</span>', 'Check color tag witdh CSRF Attack.')); foreach ($patterns3 as $pattern3) { $t->is(opWidgetFormRichTextareaOpenPNE::toHtml($pattern3[0], false, true, true), $pattern3[1], $pattern3[2]); }
<?php opWidgetFormRichTextareaOpenPNE::addExtension('opRichTextareaSyntaxHighlightExtension');