Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 4 commits
  • 2 files changed
  • 0 comments
  • 2 contributors
2  Test/Case/View/Helper/TinyMceHelperTest.php
@@ -185,4 +185,4 @@ public function testBeforeRender() {
185 185
 		$this->assertEqual($this->View->_scripts[0], '<script type="text/javascript" src="/TinyMCE/js/tiny_mce/tiny_mce.js"></script>');
186 186
 	}
187 187
 
188  
-}
  188
+}
101  View/Helper/TinyHelper.php
... ...
@@ -0,0 +1,101 @@
  1
+<?php
  2
+/**
  3
+ * Copyright 2009-2010, Cake Development Corporation (http://cakedc.com)
  4
+ *
  5
+ * Licensed under The LGPL License
  6
+ * Redistributions of files must retain the above copyright notice.
  7
+ *
  8
+ * @copyright Copyright 2009-2010, Cake Development Corporation (http://cakedc.com)
  9
+ * @license LGPL License (http://www.opensource.org/licenses/lgpl-2.1.php)
  10
+ */
  11
+
  12
+/**
  13
+ * TinyMCE Helper
  14
+ *
  15
+ * @package tiny_m_c_e
  16
+ * @subpackage tiny_m_c_e.views.helpers
  17
+ */
  18
+
  19
+class TinyHelper extends AppHelper {
  20
+
  21
+/**
  22
+ * Other helpers used by FormHelper
  23
+ *
  24
+ * @var array
  25
+ */
  26
+	public $helpers = array('Html');
  27
+
  28
+/**
  29
+ * Configuration
  30
+ *
  31
+ * @var array
  32
+ */
  33
+	public $configs = array('default' => array(
  34
+		'mode' => 'textareas',
  35
+		'theme' => 'advanced',
  36
+		'skin'=> 'o2k7',
  37
+		'theme_advanced_toolbar_location' => 'top',
  38
+		'theme_advanced_toolbar_align' => 'left',
  39
+		'visual' => 'true',
  40
+		'accessibility_warnings' => 'false',
  41
+		'fix_list_elements' => 'true',
  42
+		'verify_html' => 'true',
  43
+		'verify_css_classes' => 'false',
  44
+		'plugins' => 'spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template',
  45
+		'paste_auto_cleanup_on_paste' => 'true',
  46
+		'paste_remove_spans' => 'true',
  47
+		'paste_remove_styles' => 'true',
  48
+		'theme_advanced_buttons1' => 'save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect,fullscreen',
  49
+		'theme_advanced_buttons2' => 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor',
  50
+		'theme_advanced_buttons3' => 'spellchecker,tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,media,advhr,|,print,|,ltr,rtl,|',
  51
+		'width' => '100%',
  52
+		'height'=> '300',
  53
+		'language' => 'nl',
  54
+		'file_browser_callback' => 'fileBrowserCallBack',
  55
+		'convert_urls' => true,
  56
+		'relative_urls' => false
  57
+	));
  58
+
  59
+/**
  60
+ * Default values
  61
+ *
  62
+ * @var array
  63
+ */
  64
+	protected $_defaults = array();
  65
+
  66
+/**
  67
+ * Adds a new editor to the script block in the head
  68
+ *
  69
+ * @see http://wiki.moxiecode.com/index.php/TinyMCE:Configuration for a list of keys
  70
+ * @param mixed If array camel cased TinyMce Init config keys, if string it checks if a config with that name exists
  71
+ * @return void
  72
+ */
  73
+	public function editor($options = array()) {
  74
+		if (is_string($options)) {
  75
+			if (isset($this->configs[$options])) {
  76
+				$options = $this->configs[$options];
  77
+			} else {
  78
+				throw new OutOfBoundsException(sprintf(__('Invalid TinyMCE configuration preset %s', true), $options));
  79
+			}
  80
+		}
  81
+		$options = array_merge($this->_defaults, $options);
  82
+		$lines = '';
  83
+
  84
+		foreach ($options as $option => $value) {
  85
+			$lines .= Inflector::underscore($option) . ' : "' . $value . '",' . "\n";
  86
+		}
  87
+		$lines = rtrim($lines);
  88
+		$lines = rtrim($lines, ',');
  89
+		$this->Html->scriptBlock('tinyMCE.init({' . "\n" . $lines . '});' . "\n", array('inline' => false));
  90
+	}
  91
+
  92
+/**
  93
+ * beforeRender callback
  94
+ *
  95
+ * @return void
  96
+ */
  97
+	public function beforeRender() {
  98
+		$this->Html->script('/tiny_mce/js/tiny_mce/tiny_mce.js', false);
  99
+		$this->editor('default');
  100
+	}
  101
+}

No commit comments for this range

Something went wrong with that request. Please try again.