Permalink
Browse files

Organic Internet WYSIWYG editor module for Magento

  • Loading branch information...
organicinternet committed Jul 7, 2008
1 parent 9d1ad0c commit 8df1eb8d61947fb742f8e622e242832c73520ce2
Showing 302 changed files with 55,441 additions and 0 deletions.
@@ -0,0 +1,16 @@
+<?php
+
+if (!class_exists('OrganicInternet_Wysiwyg_Block_PageHead')) {
+class OrganicInternet_Wysiwyg_Block_PageHead extends Mage_Adminhtml_Block_Page_Head
+{
+ protected function getWysiwygActive()
+ {
+ return true;#$this->getConfigData('organicinternet_wysiwyg/active');
+ }
+
+ protected function getEditableAreas()
+ {
+ return 'description,short_description';#$this->getConfigData('organicinternet_wysiwyg/editable_areas');
+ }
+}
+}
@@ -0,0 +1,5 @@
+<?php
+
+class OrganicInternet_WysiwygEditor_Helper_Data extends Mage_Core_Helper_Abstract {
+
+}
@@ -0,0 +1,17 @@
+<?php
+
+class OrganicInternet_WysiwygEditor_Model_Source_EditableAreas
+{
+ public function toOptionArray()
+ {
+ return array(
+ array('value' => 'description', 'label' => Mage::helper('organicinternet_wysiwygeditor')->__('Product Description')),
+ array('value' => 'short_description', 'label' => Mage::helper('organicinternet_wysiwygeditor')->__('Product Short Description')),
+ array('value' => '_generaldescription', 'label' => Mage::helper('organicinternet_wysiwygeditor')->__('Category Description')),
+ array('value' => 'text', 'label' => Mage::helper('organicinternet_wysiwygeditor')->__('Newsletter Template')),
+ array('value' => 'page_content', 'label' => Mage::helper('organicinternet_wysiwygeditor')->__('CMS Page Content')),
+ array('value' => 'block_content', 'label' => Mage::helper('organicinternet_wysiwygeditor')->__('Static Block Content')),
+ );
+ }
+}
+
@@ -0,0 +1,11 @@
+<?php
+
+class OrganicInternet_WysiwygEditor_Model_Source_Editortype
+{
+ public function toOptionArray()
+ {
+ return array(
+ array('value' => 'tinymce', 'label' => 'Tiny MCE'),
+ );
+ }
+}
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<config>
+ <modules>
+ <OrganicInternet_WysiwygEditor>
+ <version>0.0.1</version>
+ </OrganicInternet_WysiwygEditor>
+ </modules>
+ <global>
+ <helpers>
+ <organicinternet_wysiwygeditor>
+ <class>OrganicInternet_WysiwygEditor_Helper</class>
+ </organicinternet_wysiwygeditor>
+ </helpers>
+ <blocks>
+ <organicinternet_wysiwygeditor>
+ <class>OrganicInternet_WysiwygEditor_Block</class>
+ </organicinternet_wysiwygeditor>
+ <!--
+ <adminhtml>
+ <rewrite>
+ <page_head>OrganicInternet_WysiwygEditor_Block_PageHead</page_head>
+ </rewrite>
+ </adminhtml>
+ -->
+ </blocks>
+ <models>
+ <organicinternet_wysiwygeditor>
+ <class>OrganicInternet_WysiwygEditor_Model</class>
+ </organicinternet_wysiwygeditor>
+ </models>
+ </global>
+ <adminhtml>
+ <layout>
+ <updates>
+ <organicinternet_wysiwygeditor>
+ <file>organicinternet_wysiwygeditor.xml</file>
+ </organicinternet_wysiwygeditor>
+ </updates>
+ </layout>
+ </adminhtml>
+ <default>
+ <advanced>
+ <organicinternet_wysiwygeditor>
+ <active>0</active>
+ <editor_type>tinymce</editor_type>
+ <editable_areas>description,short_description</editable_areas>
+ </organicinternet_wysiwygeditor>
+ </advanced>
+ </default>
+</config>
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<config>
+ <sections>
+<!-- payment tab -->
+ <advanced>
+ <groups>
+<!-- newmodule fieldset -->
+ <organicinternet_wysiwygeditor translate="label" module="organicinternet_wysiwygeditor">
+<!-- will have title 'New Module' -->
+ <label>WYSIWYG Editor</label>
+<!-- position between other payment methods -->
+ <sort_order>500</sort_order>
+<!-- do not show this configuration options in store scope -->
+ <show_in_default>1</show_in_default>
+ <show_in_website>1</show_in_website>
+ <show_in_store>0</show_in_store>
+ <fields>
+ <active translate="label">
+ <label>Enabled</label>
+ <frontend_type>select</frontend_type>
+ <source_model>adminhtml/system_config_source_yesno</source_model>
+ <sort_order>1</sort_order>
+ <show_in_default>1</show_in_default>
+ <show_in_website>1</show_in_website>
+ <show_in_store>0</show_in_store>
+ </active>
+ <editor_type translate="label">
+ <label>Editor Type</label>
+ <frontend_type>select</frontend_type>
+ <source_model>organicinternet_wysiwygeditor/source_editortype</source_model>
+ <sort_order>2</sort_order>
+ <show_in_default>1</show_in_default>
+ <show_in_website>1</show_in_website>
+ <show_in_store>0</show_in_store>
+ </editor_type>
+ <editable_areas translate="label">
+ <label>Editable Areas</label>
+ <frontend_type>multiselect</frontend_type>
+ <source_model>organicinternet_wysiwygeditor/source_editableareas</source_model>
+ <sort_order>6</sort_order>
+ <show_in_default>1</show_in_default>
+ <show_in_website>1</show_in_website>
+ <show_in_store>0</show_in_store>
+ </editable_areas>
+ </fields>
+ </organicinternet_wysiwygeditor>
+ </groups>
+ </advanced>
+ </sections>
+</config>
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<layout version="0.0.1">
+ <default>
+ <reference name="head">
+ <action method="setTemplate"><template>organicinternet_wysiwygeditor/page_head.phtml</template></action>
+ </reference>
+ </default>
+</layout>
@@ -0,0 +1,54 @@
+<title><?php echo htmlspecialchars(html_entity_decode($this->getTitle())) ?></title>
+<meta http-equiv="Content-Type" content="<?php echo $this->getContentType() ?>"/>
+
+<link rel="icon" href="<?php echo $this->getSkinUrl('favicon.ico') ?>" type="image/x-icon"/>
+<link rel="shortcut icon" href="<?php echo $this->getSkinUrl('favicon.ico') ?>" type="image/x-icon"/>
+
+<script type="text/javascript">
+ var BLANK_URL = '<?php echo $this->getJsUrl() ?>blank.html';
+ var BLANK_IMG = '<?php echo $this->getJsUrl() ?>spacer.gif';
+ var BASE_URL = '<?php echo $this->getUrl('*') ?>';
+ var SKIN_URL = '<?php echo $this->getSkinUrl() ?>';
+</script>
+
+<?php echo $this->getCssJsHtml() ?>
+
+<?php if($this->getCanLoadExtJs()): ?>
+<script type="text/javascript">
+ Ext.BLANK_IMAGE_URL = BLANK_IMG;
+ Ext.UpdateManager.defaults.loadScripts = false;
+ Ext.UpdateManager.defaults.disableCaching = true;
+</script>
+<?php endif; ?>
+
+<script type="text/javascript">
+ Fieldset.addToPrefix(<?php echo Mage::helper('adminhtml')->getCurrentUserId() ?>);
+</script>
+
+<?php echo $this->helper('core/js')->getTranslatorScript() ?>
+
+<?php if (true || $this->getWysiwygActive()) { ?>
+<script type="text/javascript" src="/js/tiny_mce/tiny_mce.js"></script>
+<script type="text/javascript">
+Event.observe(window, 'load', function() {
+ 'description,short_description,_generaldescription,text,page_content,block_content'.split(',').each(function(dom_id) {
+ if ($(dom_id)) {
+ $(dom_id).removeClassName('required-entry');
+ }
+ });
+ tinyMCE.init({
+ mode : "exact",
+ elements : "<?php echo $this->getEditableAreas() ? $this->getEditableAreas() : 'description,short_description,_generaldescription,text,page_content,block_content' ?>",
+ theme : "advanced",
+ strict_loading_mode : true,
+ width: "640",
+ height: "350",
+ content_css: "<?php echo $this->getSkinUrl() ?>tinymce_content.css",
+ theme_advanced_toolbar_location : "top",
+ theme_advanced_toolbar_align : "left",
+ theme_advanced_statusbar_location : "bottom",
+ relative_urls : false
+ });
+});
+</script>
+<?php } ?>
@@ -0,0 +1,9 @@
+<config>
+ <modules>
+ <OrganicInternet_WysiwygEditor>
+ <active>true</active>
+ <codePool>community</codePool>
+ <version>0.0.1</version>
+ </OrganicInternet_WysiwygEditor>
+ </modules>
+</config>
@@ -0,0 +1,98 @@
+/**
+ * $Id: PluginManager.js 352 2007-11-05 17:03:49Z spocke $
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
+ */
+
+(function() {
+ var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each;
+
+ /**#@+
+ * @class This class handles the loading of themes/plugins or other add-ons and their language packs.
+ * @member tinymce.AddOnManager
+ */
+ tinymce.create('tinymce.AddOnManager', {
+ items : [],
+ urls : {},
+ lookup : {},
+ onAdd : new Dispatcher(this),
+
+ /**#@+
+ * @method
+ */
+
+ /**
+ * Returns the specified add on by the short name.
+ *
+ * @param {String} n Add-on to look for.
+ * @return {tinymce.Theme/tinymce.Plugin} Theme or plugin add-on instance or undefined.
+ */
+ get : function(n) {
+ return this.lookup[n];
+ },
+
+ /**
+ * Loads a language pack for the specified add-on.
+ *
+ * @param {String} n Short name of the add-on.
+ */
+ requireLangPack : function(n) {
+ var u, s;
+
+ if (tinymce.EditorManager.settings) {
+ u = this.urls[n] + '/langs/' + tinymce.EditorManager.settings.language + '.js';
+ s = tinymce.EditorManager.settings;
+
+ if (s) {
+ if (!tinymce.dom.Event.domLoaded && !s.strict_mode)
+ tinymce.ScriptLoader.load(u);
+ else
+ tinymce.ScriptLoader.add(u);
+ }
+ }
+ },
+
+ /**
+ * Adds a instance of the add-on by it's short name.
+ *
+ * @param {String} id Short name/id for the add-on.
+ * @param {tinymce.Theme/tinymce.Plugin} o Theme or plugin to add.
+ * @return {tinymce.Theme/tinymce.Plugin} The same theme or plugin instance that got passed in.
+ */
+ add : function(id, o) {
+ this.items.push(o);
+ this.lookup[id] = o;
+ this.onAdd.dispatch(this, id, o);
+
+ return o;
+ },
+
+ /**
+ * Loads an add-on from a specific url.
+ *
+ * @param {String} n Short name of the add-on that gets loaded.
+ * @param {String} u URL to the add-on that will get loaded.
+ * @param {function} cb Optional callback to execute ones the add-on is loaded.
+ * @param {Object} s Optional scope to execute the callback in.
+ */
+ load : function(n, u, cb, s) {
+ var t = this;
+
+ if (t.urls[n])
+ return;
+
+ if (u.indexOf('/') != 0 && u.indexOf('://') == -1)
+ u = tinymce.baseURL + '/' + u;
+
+ t.urls[n] = u.substring(0, u.lastIndexOf('/'));
+ tinymce.ScriptLoader.add(u, cb, s);
+ }
+
+ /**#@-*/
+ });
+
+ // Create plugin and theme managers
+ tinymce.PluginManager = new tinymce.AddOnManager();
+ tinymce.ThemeManager = new tinymce.AddOnManager();
+}());
Oops, something went wrong.

0 comments on commit 8df1eb8

Please sign in to comment.