Example #1
0
 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]');
 }
Example #3
0
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);
 }
Example #5
0
<?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('&lt;op:s&gt;どーん&lt;/op:s&gt;', '<span class="op_s">どーん</span>', 'Check default strike tag.'), array('&lt;op:s&gt;どどー&lt;op&gt;ん&lt;/op:s&gt;', '<span class="op_s">どどー&lt;op&gt;ん</span>', 'Check strike tag with broken tag.'), array('&lt;op:s&gt;どどー', '<span class="op_s">どどー</span>', 'Check strike tag what is not having end tag.'), array('&lt;op:a&lt;op:i&gt;', '&lt;op:a<span class="op_i"></span>', 'Check italic tag with broken tag where is top.'), array('&lt;op:i color="#333&lt;op:i&gt;"&gt;#333&lt;/op:i&gt;', '&lt;op:i color="#333<span class="op_i">"&gt;#333</span>', 'Check italic tag what have some broken tags.'), array('&lt;op:font color="#333333"&gt;#333&lt;/op:font&gt;', '<span class="op_font" style="color:#333333;">#333</span>', 'Check default color tag what have some broken tags.'), array('&lt;op:tetetetetete0111111&gt;', '<span class="op_tetetetetete0111111"></span>', 'Check undefined op tag.'), array('&lt;op:i<br />&gt;&lt;op:', '&lt;op:i<br />&gt;&lt;op:', 'Check broken tag witdh br tag.'), array('&lt;op:font color="expression(alert(0))"&gt;Attack!&lt;/op:font&gt;', '<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('&lt;op:s&gt;どーん&lt;/op:s&gt;', 'どーん', 'Check default strike tag.'), array('&lt;op:s&gt;どどー&lt;op&gt;ん&lt;/op:s&gt;', 'どどー&lt;op&gt;ん', 'Check strike tag with broken tag.'), array('&lt;op:s&gt;どどー', 'どどー', 'Check strike tag what is not having end tag.'), array('&lt;op:a&lt;op:i&gt;', '&lt;op:a', 'Check italic tag with broken tag where is top.'), array('&lt;op:i color="#333&lt;op:i&gt;"&gt;#333&lt;/op:i&gt;', '&lt;op:i color="#333"&gt;#333', 'Check italic tag what have some broken tags.'), array('&lt;op:font color="#333"&gt;#333&lt;/op:font&gt;', '#333', 'Check default color tag what have some broken tags.'), array('&lt;op:tetetetetete0111111&gt;', '', 'Check undefined op tag.'), array('&lt;op:i<br />&gt;&lt;op:', '&lt;op:i<br />&gt;&lt;op:', 'Check broken tag witdh br tag.'), array('&lt;op:font color="expression(alert(0))"&gt;Attack!&lt;/op:font&gt;', '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('&lt;op:s&gt;どーん', '<span class="op_s">どーん</span>', 'Check default strike tag.'), array('&lt;op:s&gt;どどー&lt;op&gt;ん', '<span class="op_s">どどー&lt;op&gt;ん</span>', 'Check strike tag with broken tag.'), array('&lt;op:s&gt;どどー', '<span class="op_s">どどー</span>', 'Check strike tag what is not having end tag.'), array('&lt;op:a&lt;op:i&gt;', '&lt;op:a<span class="op_i"></span>', 'Check italic tag with broken tag where is top.'), array('&lt;op:i color="#333&lt;op:i&gt;"&gt;#333', '&lt;op:i color="#333<span class="op_i">"&gt;#333</span>', 'Check italic tag what have some broken tags.'), array('&lt;op:font color="#333333"&gt;#333', '<span class="op_font" style="color:#333333;">#333</span>', 'Check default color tag what have some broken tags.'), array('&lt;op:tetetetetete0111111&gt;', '<span class="op_tetetetetete0111111"></span>', 'Check undefined op tag.'), array('&lt;op:i&gt;&lt;op:&lt;op:i&gt;&lt;op:i&gt;&lt;op:i&gt;&lt;op:333333&gt;', '<span class="op_i">&lt;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('&lt;op:font color="expression(alert(0))"&gt;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');