summaryrefslogtreecommitdiff
path: root/protected/extensions
diff options
context:
space:
mode:
authorPatrick Seeger <pseeger@ccwn.org>2012-04-15 18:37:40 +0200
committerPatrick Seeger <pseeger@ccwn.org>2012-04-15 18:37:40 +0200
commitfeb2fe055435e7ecdc657cacee2aaf7dc339dbc9 (patch)
tree77fa07572ae7a5a2b6e808c97b9adc7f035059b3 /protected/extensions
parentba20ededac6fd68d281603e8c9273f5134d21a4c (diff)
Irgendwas in der art von posts
Diffstat (limited to 'protected/extensions')
-rw-r--r--protected/extensions/ddeditor/DDEditor.php228
-rw-r--r--protected/extensions/ddeditor/README108
-rw-r--r--protected/extensions/ddeditor/messages/de/ddeditor.php33
-rw-r--r--protected/extensions/ddeditor/messages/en/ddeditor.php26
-rw-r--r--protected/extensions/ddeditor/messages/en/ddeditor.php.merged33
-rw-r--r--protected/extensions/ddeditor/messages/messages.php17
-rw-r--r--protected/extensions/ddeditor/resources/editor.js140
-rw-r--r--protected/extensions/ddeditor/resources/styles.css15
-rw-r--r--protected/extensions/ddeditor/views/editor.php63
9 files changed, 663 insertions, 0 deletions
diff --git a/protected/extensions/ddeditor/DDEditor.php b/protected/extensions/ddeditor/DDEditor.php
new file mode 100644
index 0000000..798ef90
--- /dev/null
+++ b/protected/extensions/ddeditor/DDEditor.php
@@ -0,0 +1,228 @@
+<?php
+/**
+ * DDEditor Class File
+ *
+ * @author Joachim Werner <joachim.werner@diggin-data.de>
+ * @link http://www.diggin-data.de
+ */
+
+/**
+ * DDEditor creates a textarea editor for Markdown syntax
+ * The editor has some buttons to replace selected text in a textarea
+ * with common Mardown syntax
+ *
+ * @author Joachim Werner <joachim.werner@diggin-data.de>
+ * @version 0.4
+ */
+class DDEditor extends CWidget
+{
+ // {{{ Members
+ /**
+ * model - The model upon which the activeTextarea control is based on
+ *
+ * @var mixed
+ * @access public
+ */
+ public $model;
+ /**
+ * The attribute name for which the activeTextarea control shall be created
+ * @var mixed
+ * @access public
+ */
+ public $attribute;
+ /**
+ * Array of additional HTML options for the textarea control
+ *
+ * @var array
+ * @access public
+ */
+ public $htmlOptions=array();
+ public $additionalSnippets = array();
+ /**
+ * Request which returns via AJAX the rendered preview for the Markdown text
+ *
+ * @var mixed
+ * @access public
+ */
+ public $previewRequest;
+ /**
+ * The ID of the activeTextarea
+ *
+ * @var mixed
+ * @access private
+ */
+ private $editorId;
+ // }}}
+ // {{{ run
+ /**
+ * Runs the widget
+ *
+ * @access public
+ * @return void
+ */
+ public function run()
+ {
+ $this->registerClientScripts();
+ echo $this->createMarkup();
+ } // }}}
+ // {{{ createMarkup
+ /**
+ * Creates the widget's markup
+ *
+ * @access public
+ * @return void
+ */
+ public function createMarkup()
+ {
+ if(!isset($this->htmlOptions['rows'])) {
+ $attribute = $this->attribute;
+ $text = $this->model->$attribute;
+ if (strpos($text, "\n") === FALSE) {
+ //MAC?!
+ $text = str_replace( "\r", "\n", $text );
+ } else {
+ //Windows has \r\n
+ $text = str_replace( "\r", '', $text );
+ }
+ $this->htmlOptions['rows'] = count(explode("\n", $text));
+ }
+ $this->render(
+ 'editor',
+ array(
+ 'model'=>$this->model,
+ 'attribute'=>$this->attribute,
+ 'htmlOptions'=>$this->htmlOptions,
+ 'editorId' => $this->editorId,
+ 'additionalSnippets'=>$this->additionalSnippets,
+ )
+ );
+ } // }}}
+ // {{{ registerClientScripts
+ /**
+ * Registers the clientside widget files (css & js)
+ */
+ private function registerClientScripts() {
+ // Get the resources path
+ $resources = dirname(__FILE__).'/resources';
+
+ $cs = Yii::app()->clientScript;
+ // publish the files
+ $baseUrl = Yii::app()->assetManager->publish($resources);
+
+ // register the files
+
+ // Stylesheet
+ if(is_file($resources.'/styles.css')) {
+ $cs->registerCssFile($baseUrl.'/styles.css');
+ }
+ if(is_file($resources.'/editor.js')) {
+ $cs->registerScriptFile($baseUrl.'/editor.js');
+ }
+ self::resolveNameID($this->model,$this->attribute,$this->htmlOptions);
+ $this->editorId = $this->htmlOptions['id'];
+ $c=1;
+ // Create preview request URL
+ $url = Yii::app()->urlManager->createUrl($this->previewRequest,array('attribute'=>$this->attribute));
+
+ $scriptId = uniqid('ed_').'_';
+ // Bold
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-bold').click(function(){insertTags('".$this->editorId."','**','**','bold ')});");
+ // Italic
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-italic').click(function(){insertTags('".$this->editorId."','_','_','italic ')});");
+ // Headings
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-h').change(function(){insertTags('".$this->editorId."',padText('#',this.value)+' ',' '+padText('#',this.value),'Heading '+this.value)});");
+ // Link
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-link').click(function(){insertTags('".$this->editorId."','[','](http://...)','Link Description')});");
+ // Image
+ // $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-img').click(function(){insertTags('".$this->editorId."','![Alt Text](',' \"Title\")','Image URL')});");
+ // Image 2
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-img2').change(function(){insertTags('".$this->editorId."',this.value+'[Heading/Alt Text](',' \"Title\")','path/to/image.jpg')});");
+ // List Item
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-li').click(function(){insertTags('".$this->editorId."','* ','','List Item ')});");
+ // HR
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-hr').click(function(){insertTags('".$this->editorId."','****bslashN','','')});");
+ // Table
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-table').click(function(){insertTags('".$this->editorId."','| Header | Header |bslashN| ------ | ------ | bslashN| ',' | Cell |bslashN','Cell')});");
+ // Code
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-code').click(function(){insertTags('".$this->editorId."','`','`','sample code')});");
+ // Code2
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-code2').click(function(){if(this.value=='') return;insertTags('".$this->editorId."','~~~~bslashN['+this.value+']bslashN','bslashN~~~~bslashN','// Sample Ccode')});");
+ // Add Lines
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-addlines').click(function(){jQuery('#".$this->editorId."').attr('rows',jQuery('#".$this->editorId."').attr('rows')+5);});");
+ // Remove Lines
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-remlines').click(function(){jQuery('#".$this->editorId."').attr('rows',jQuery('#".$this->editorId."').attr('rows')-5);});");
+ // Preview
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$this->editorId."-editor-preview').click(function(){jQuery('#".$this->editorId."').toggle();jQuery('#".$this->editorId."-preview').toggle();jQuery.ajax({type:'POST',url: '".$url."',data: jQuery(':parent form').serialize(),success:function(data){jQuery('#".$this->editorId."-preview').html(data);}});});");
+ // Additional Snippets
+ if(sizeof($this->additionalSnippets)>0) {
+ $n=0;
+ foreach($this->additionalSnippets as $name=>$additionalSnippet) {
+ $ddId = $this->editorId."-editor-addS-".$n;
+ $cs->registerScript($scriptId.$c++,"jQuery('#".$ddId."').change(function(){insertTags('".$this->editorId."','','',this.value);this.selectedIndex=0;});");
+ $n++;
+ }
+ }
+ } // }}}
+ // {{{ resolveNameID
+ /**
+ * Generates input name and ID for a model attribute.
+ * This method will update the HTML options by setting appropriate 'name' and 'id' attributes.
+ * This method may also modify the attribute name if the name
+ * contains square brackets (mainly used in tabular input).
+ * @param CModel the data model
+ * @param string the attribute
+ * @param array the HTML options
+ */
+ public static function resolveNameID($model,&$attribute,&$htmlOptions)
+ {
+ if(!isset($htmlOptions['name']))
+ $htmlOptions['name']=self::resolveName($model,$attribute);
+ if(!isset($htmlOptions['id']))
+ $htmlOptions['id']=self::getIdByName($htmlOptions['name']);
+ else if($htmlOptions['id']===false)
+ unset($htmlOptions['id']);
+ } // }}}
+ // {{{ getIdByName
+ /**
+ * Generates a valid HTML ID based the name.
+ * @return string the ID generated based on name.
+ */
+ public static function getIdByName($name)
+ {
+ return str_replace(array('[]', '][', '[', ']'), array('', '_', '_', ''), $name);
+ } // }}}
+ // {{{ resolveName
+ /**
+ * Generates input name for a model attribute.
+ * Note, the attribute name may be modified after calling this method if the name
+ * contains square brackets (mainly used in tabular input) before the real attribute name.
+ * @param CModel the data model
+ * @param string the attribute
+ * @return string the input name
+ * @since 1.0.2
+ */
+ public static function resolveName($model,&$attribute)
+ {
+ if(($pos=strpos($attribute,'['))!==false)
+ {
+ if($pos!==0) // e.g. name[a][b]
+ return get_class($model).'['.substr($attribute,0,$pos).']'.substr($attribute,$pos);
+ if(($pos=strrpos($attribute,']'))!==false && $pos!==strlen($attribute)-1) // e.g. [a][b]name
+ {
+ $sub=substr($attribute,0,$pos+1);
+ $attribute=substr($attribute,$pos+1);
+ return get_class($model).$sub.'['.$attribute.']';
+ }
+ if(preg_match('/\](\w+\[.*)$/',$attribute,$matches))
+ {
+ $name=get_class($model).'['.str_replace(']','][',trim(strtr($attribute,array(']['=>']','['=>']')),']')).']';
+ $attribute=$matches[1];
+ return $name;
+ }
+ }
+ else
+ return get_class($model).'['.$attribute.']';
+ } // }}}
+}
+
+/* vim: set ai sw=4 sts=4 et fdm=marker fdc=4: */
diff --git a/protected/extensions/ddeditor/README b/protected/extensions/ddeditor/README
new file mode 100644
index 0000000..0d5e252
--- /dev/null
+++ b/protected/extensions/ddeditor/README
@@ -0,0 +1,108 @@
+# DDEditor Yii Extension
+
+This extension contains a widget to render an activeTextarea to enter Markdown text.
+
+The rendered widget contains some buttons to add markdown tags for
+
+* Bold, italic text
+* Links
+* Images
+* Code
+* Table structure.
+
+It is also capable of displaying dropdown lists with _additional text snippets_ for insertion.
+
+
+### Requirements
+* Yii 1.1.3 or above
+
+### Installation
+* Extract the release file under `protected/extensions`
+
+### Usage
+
+#### Include New Extension
+
+In your `config/main.php` file, add
+
+ // autoloading model and component classes
+ 'import'=>array(
+ ...
+ 'application.extensions.ddeditor.*',
+ ...
+ ),
+
+#### Create the controll in a form view:
+
+In e.g. `views/post/_form.php`, include the following code:
+
+ <?php $this->widget(
+ 'application.extensions.ddeditor.DDEditor',
+ array(
+ 'model'=>$model,
+ 'attribute'=>'content',
+ 'htmlOptions'=>array('rows'=>10, 'cols'=>70),
+ 'previewRequest'=>'post/preview')); ?>
+
+If you want to display an **extra dropdown list** with **snippets**, you may add the
+_additionalSnippets_ parameter:
+
+ <?php $mySnippets = array(
+ 'Users' => array(
+ 'id1' => 'John',
+ 'id2' => 'Paul',
+ ),
+ 'Phrases' => array(
+ 'Text Foo' => 'foo',
+ 'Text Bar' => 'bar'
+ )
+ ); ?>
+
+ <?php $this->widget(
+ 'application.extensions.ddeditor.DDEditor',
+ array(
+ 'model'=>$model,
+ 'attribute'=>'content',
+ 'htmlOptions'=>array('rows'=>10, 'cols'=>70),
+ 'previewRequest'=>'post/preview',
+ 'additionalSnippets'=>array('My Snippets'=>$mySnippets),
+ ); ?>
+
+
+#### Add a Controller Preview Action
+
+In order to receive a rendered preview of the textarea Markdown, add an action method to a controller:
+
+ public function actionPreview()
+ {
+ $parser=new CMarkdownParser;
+ echo $parser->safeTransform($_POST['Post'][$_GET['attribute']]);
+ }
+
+
+### Resources
+
+* [Demo](http://www.diggin-data.de/ddeditor)
+* [Discussion](http://www.yiiframework.com/forum/index.php?/topic/11384-new-extension-markdown-editor)
+
+
+### Changes
+
+#### March 29, 2010
+* **V0.4**
+ * Added code sample for using _additionalSnippets_ in README
+ * Added reset of _additional snippets_ dropdown list after selection
+
+#### March 28, 2010
+* **V0.3**
+ * Fixed _Depreciated: split_ warning
+ * Added _additionalSnippets_ member
+ * Added _Code Highlighter_ dropdown list
+
+#### August 31, 2010
+* **V0.2**
+ * Fixed setting `$previewReaquest`
+ * Fixed setting client script id's for using multiple editors in one form
+
+#### August 30, 2010
+* **V0.1** Initial release.
diff --git a/protected/extensions/ddeditor/messages/de/ddeditor.php b/protected/extensions/ddeditor/messages/de/ddeditor.php
new file mode 100644
index 0000000..390b819
--- /dev/null
+++ b/protected/extensions/ddeditor/messages/de/ddeditor.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Message translations.
+ *
+ * This file is automatically generated by 'yiic message' command.
+ * It contains the localizable messages extracted from source code.
+ * You may modify this file by translating the extracted messages.
+ *
+ * Each array element represents the translation (value) of a message (key).
+ * If the value is empty, the message is considered as not translated.
+ * Messages that no longer need translation will have their translations
+ * enclosed between a pair of '@@' marks.
+ *
+ * Message string can be used with plural forms format. Check i18n section
+ * of the guide for details.
+ *
+ * NOTE, this file must be saved in UTF-8 encoding.
+ *
+ * @version $Id: $
+ */
+return array (
+ 'Code' => 'Code',
+ 'Highslide' => 'Highslide',
+ 'IMG' => 'BILD',
+ 'Inline' => 'Im Fließtext',
+ 'B' => 'F',
+ 'H' => 'Ü',
+ 'HR' => 'HR',
+ 'I' => 'K',
+ 'Loading Preview...' => 'Lade Vorschau...',
+ 'Preview' => 'Vorschau',
+ 'Table' => 'Tabelle',
+);
diff --git a/protected/extensions/ddeditor/messages/en/ddeditor.php b/protected/extensions/ddeditor/messages/en/ddeditor.php
new file mode 100644
index 0000000..df2b3b0
--- /dev/null
+++ b/protected/extensions/ddeditor/messages/en/ddeditor.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Message translations.
+ *
+ * This file is automatically generated by 'yiic message' command.
+ * It contains the localizable messages extracted from source code.
+ * You may modify this file by translating the extracted messages.
+ *
+ * Each array element represents the translation (value) of a message (key).
+ * If the value is empty, the message is considered as not translated.
+ * Messages that no longer need translation will have their translations
+ * enclosed between a pair of '@@' marks.
+ *
+ * NOTE, this file must be saved in UTF-8 encoding.
+ *
+ * @version $Id: $
+ */
+return array (
+ 'B' => '',
+ 'H' => '',
+ 'HR' => '',
+ 'I' => '',
+ 'Loading Preview...' => '',
+ 'Preview' => '',
+ 'Table' => '',
+);
diff --git a/protected/extensions/ddeditor/messages/en/ddeditor.php.merged b/protected/extensions/ddeditor/messages/en/ddeditor.php.merged
new file mode 100644
index 0000000..15f12bb
--- /dev/null
+++ b/protected/extensions/ddeditor/messages/en/ddeditor.php.merged
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Message translations.
+ *
+ * This file is automatically generated by 'yiic message' command.
+ * It contains the localizable messages extracted from source code.
+ * You may modify this file by translating the extracted messages.
+ *
+ * Each array element represents the translation (value) of a message (key).
+ * If the value is empty, the message is considered as not translated.
+ * Messages that no longer need translation will have their translations
+ * enclosed between a pair of '@@' marks.
+ *
+ * Message string can be used with plural forms format. Check i18n section
+ * of the guide for details.
+ *
+ * NOTE, this file must be saved in UTF-8 encoding.
+ *
+ * @version $Id: $
+ */
+return array (
+ 'B' => '',
+ 'Code' => '',
+ 'H' => '',
+ 'HR' => '',
+ 'Highslide' => '',
+ 'I' => '',
+ 'IMG' => '',
+ 'Inline' => '',
+ 'Loading Preview...' => '',
+ 'Preview' => '',
+ 'Table' => '',
+);
diff --git a/protected/extensions/ddeditor/messages/messages.php b/protected/extensions/ddeditor/messages/messages.php
new file mode 100644
index 0000000..3de8acf
--- /dev/null
+++ b/protected/extensions/ddeditor/messages/messages.php
@@ -0,0 +1,17 @@
+<?php
+// This is hopefully a config array for the messages
+return array(
+ 'sourcePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..', //root dir of all source
+ 'messagePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'messages', //root dir of message translations
+ 'languages' => array('de','en'), //array of lang codes to translate to, e.g. es_mx
+ 'fileTypes' => array('php','js',), //array of extensions no dot all others excluded
+ 'exclude' => array( //list of paths or files to exclude
+ '.svn',
+ 'yiic',
+ 'yiic.php',
+ '/gii',
+ '/messages',
+ ),
+ //'translator' => 'Yii:t', //this is the default but lets be complete
+);
+?>
diff --git a/protected/extensions/ddeditor/resources/editor.js b/protected/extensions/ddeditor/resources/editor.js
new file mode 100644
index 0000000..7317d3b
--- /dev/null
+++ b/protected/extensions/ddeditor/resources/editor.js
@@ -0,0 +1,140 @@
+/**
+ * Some browser detection
+ */
+var clientPC = navigator.userAgent.toLowerCase(); // Get client info
+var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
+ && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1));
+var is_safari = ((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1));
+var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ));
+if (clientPC.indexOf('opera')!=-1) {
+ var is_opera = true;
+ var is_opera_preseven = (window.opera && !document.childNodes);
+ var is_opera_seven = (window.opera && document.childNodes);
+}
+
+//{{{ insertTags
+/**
+ * apply tagOpen/tagClose to selection in textarea, use sampleText instead
+ * of selection if there is none copied and adapted from phpBB
+ *
+ * @author phpBB development team
+ * @author MediaWiki development team
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @author Jim Raynor <jim_raynor@web.de>
+ */
+function insertTags(elID, tagOpen, tagClose, sampleText) {
+ tagOpen = tagOpen.replace(/bslashN/g,'\n');
+ tagClose = tagClose.replace(/bslashN/g,'\n');
+ var txtarea = document.getElementById(elID);
+ // IE
+ if(document.selection && !is_gecko) {
+ var theSelection = document.selection.createRange().text;
+ var replaced = true;
+ if(!theSelection){
+ replaced = false;
+ theSelection=sampleText;
+ }
+ txtarea.focus();
+
+ // This has change
+ text = theSelection;
+ if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
+ theSelection = theSelection.substring(0, theSelection.length - 1);
+ r = document.selection.createRange();
+ r.text = tagOpen + theSelection + tagClose + " ";
+ } else {
+ r = document.selection.createRange();
+ r.text = tagOpen + theSelection + tagClose;
+ }
+ if(!replaced){
+ r.moveStart('character',-text.length-tagClose.length);
+ r.moveEnd('character',-tagClose.length);
+ }
+ r.select();
+ // Mozilla
+ } else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
+ var replaced = false;
+ var startPos = txtarea.selectionStart;
+ var endPos = txtarea.selectionEnd;
+ if(endPos - startPos) replaced = true;
+ var scrollTop=txtarea.scrollTop;
+ var myText = (txtarea.value).substring(startPos, endPos);
+ if(!myText) { myText=sampleText;}
+ if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any
+ subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
+ } else {
+ subst = tagOpen + myText + tagClose;
+ }
+ txtarea.value = txtarea.value.substring(0, startPos) + subst +
+ txtarea.value.substring(endPos, txtarea.value.length);
+ txtarea.focus();
+
+ //set new selection
+ if(replaced){
+ var cPos=startPos+(tagOpen.length+myText.length+tagClose.length);
+ txtarea.selectionStart=cPos;
+ txtarea.selectionEnd=cPos;
+ }else{
+ txtarea.selectionStart=startPos+tagOpen.length;
+ txtarea.selectionEnd=startPos+tagOpen.length+myText.length;
+ }
+ txtarea.scrollTop=scrollTop;
+ // All others
+ } else {
+ var copy_alertText=alertText;
+ var re1=new RegExp("\\$1","g");
+ var re2=new RegExp("\\$2","g");
+ copy_alertText=copy_alertText.replace(re1,sampleText);
+ copy_alertText=copy_alertText.replace(re2,tagOpen+sampleText+tagClose);
+ var text;
+ if (sampleText) {
+ text=prompt(copy_alertText);
+ } else {
+ text="";
+ }
+ if(!text) { text=sampleText;}
+ text=tagOpen+text+tagClose;
+ //append to the end
+ txtarea.value += "\n"+text;
+
+ // in Safari this causes scrolling
+ if(!is_safari) {
+ txtarea.focus();
+ }
+
+ }
+ // reposition cursor if possible
+ if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();
+
+ return false;
+}
+// }}}
+
+// {{{ moreRows
+/**
+ * Adds 2 more rows to a textarea
+ */
+function moreRows(textareaId)
+{
+ document.getElementById(textareaId).rows = document.getElementById(textareaId).rows + 2;
+} // }}}
+
+// {{{ lessRows
+/**
+ * Reduces a textarea by 2 rows
+ */
+function lessRows(textareaId)
+{
+ if( document.getElementById(textareaId).rows>2 )
+ document.getElementById(textareaId).rows = document.getElementById(textareaId).rows - 2;
+}// }}}
+
+// {{{ padText
+function padText(text, length)
+{
+ var result="";
+ for(i=0; i<length; i++)
+ result = result + text;
+ return result;
+}
+// }}}
diff --git a/protected/extensions/ddeditor/resources/styles.css b/protected/extensions/ddeditor/resources/styles.css
new file mode 100644
index 0000000..0568bd3
--- /dev/null
+++ b/protected/extensions/ddeditor/resources/styles.css
@@ -0,0 +1,15 @@
+.ddeditor .preview
+{
+ display: none;
+ border: 1px solid #aaa;
+ padding: 3px;
+}
+.ddeditor BUTTON,SELECT
+{
+ font-size: 9pt;
+}
+.ddeditor BUTTON
+{
+ border: 1px solid blue;
+ background-color: #eee;
+}
diff --git a/protected/extensions/ddeditor/views/editor.php b/protected/extensions/ddeditor/views/editor.php
new file mode 100644
index 0000000..e8ab7be
--- /dev/null
+++ b/protected/extensions/ddeditor/views/editor.php
@@ -0,0 +1,63 @@
+<div class="ddeditor">
+<button
+ type="button"
+ id="<?php echo $editorId ?>-editor-bold"><b><?php echo Yii::t('ddeditor','B'); ?></b></button>
+<button
+ type="button"
+ id="<?php echo $editorId ?>-editor-italic"><i><?php echo Yii::t('ddeditor','I'); ?></i></button>
+<select id="<?php echo $editorId ?>-editor-h">
+ <option value=""><?php echo Yii::t('ddeditor','H'); ?></option>
+ <?php for($i=1; $i<=5; $i++ ) : ?>
+ <option value="<?php echo $i ?>"><?php echo Yii::t('ddeditor','H'); ?><?php echo $i ?></option>
+ <?php endfor; ?>
+</select>
+<button
+ type="button"
+ id="<?php echo $editorId ?>-editor-link">URL</button>
+<!--
+<button
+ type="button"
+ id="<?php echo $editorId ?>-editor-img">IMG</button>
+-->
+<select id="<?php echo $editorId ?>-editor-img2">
+ <option value=""><?php echo Yii::t('ddeditor','IMG'); ?></option>
+ <option value="!"><?php echo Yii::t('ddeditor','Inline'); ?></option>
+ <option value="*"><?php echo Yii::t('ddeditor','Highslide'); ?></option>
+</select>
+<button
+ type="button"
+ id="<?php echo $editorId ?>-editor-li">&bull;</button>
+<button
+ type="button"
+ id="<?php echo $editorId ?>-editor-hr"><?php echo Yii::t('ddeditor','HR'); ?></button>
+<button
+ type="button"
+ id="<?php echo $editorId ?>-editor-code">Code</button>
+<select id="<?php echo $editorId ?>-editor-code2">
+ <option value=""><?php echo Yii::t('ddeditor','Code'); ?></option>
+ <?php foreach(explode(", ","ABAP, CPP, CSS, DIFF, DTD, HTML, JAVA, JAVASCRIPT, MYSQL, PERL, PHP, PYTHON, RUBY, SQL, XML") as $language) : ?>
+ <option value="<?php echo strtolower($language) ?>"><?php echo $language; ?></option>
+ <?php endforeach; ?>
+</select>
+<button
+ type="button"
+ id="<?php echo $editorId ?>-editor-table"><?php echo Yii::t('ddeditor','Table'); ?></button>
+<button
+ type="button"
+ id="<?php echo $editorId; ?>-editor-addlines">+</button>
+<button
+ type="button"
+ id="<?php echo $editorId; ?>-editor-remlines">-</button>
+<button
+ type="button"
+ id="<?php echo $editorId; ?>-editor-preview"><?php echo Yii::t('ddeditor','Preview'); ?></button>
+<br/>
+<?php if(sizeof($additionalSnippets)>0) : ?>
+<?php $n=0; foreach($additionalSnippets as $name=>$additionalSnippet) : $additionalSnippet = array_merge(array($name),$additionalSnippet); ?>
+<?php echo CHtml::dropDownList($editorId.'-editor-addS-'.$n,'',$additionalSnippet); ?>
+<?php $n++; endforeach; ?>
+<br/>
+<?php endif; ?>
+<?php echo CHtml::activeTextArea($model,$attribute,$htmlOptions); ?>
+<div id="<?php echo $editorId; ?>-preview" class="preview"><?php echo Yii::t('ddeditor','Loading Preview...'); ?></div>
+</div>