PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/library/Digitalus/View/Helper/Content/LoadEditors.php

http://digitalus-cms.googlecode.com/
PHP | 150 lines | 98 code | 10 blank | 42 comment | 2 complexity | e109da4cf62056e554f7a6b53fbc76e6 MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * LoadEditors helper
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://digitalus-media.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to info@digitalus-media.com so we can send you a copy immediately.
  14. *
  15. * @author LowTower - lowtower@gmx.de
  16. * @category Digitalus CMS
  17. * @package Digitalus
  18. * @subpackage Digitalus_View
  19. * @copyright Copyright (c) 2007 - 2010, Digitalus Media USA (digitalus-media.com)
  20. * @license http://digitalus-media.com/license/new-bsd New BSD License
  21. * @version $Id: LoadEditors.php 774 2010-06-11 15:33:10Z lowtower@gmx.de $
  22. * @link http://www.digitaluscms.com
  23. * @since Release 1.9.0
  24. */
  25. /**
  26. * @see Zend_View_Helper_Abstract
  27. */
  28. require_once 'Zend/View/Helper/Abstract.php';
  29. /**
  30. * LoadEditors helper
  31. *
  32. * @author LowTower - lowtower@gmx.de
  33. * @copyright Copyright (c) 2007 - 2010, Digitalus Media USA (digitalus-media.com)
  34. * @license http://digitalus-media.com/license/new-bsd New BSD License
  35. * @version Release: @package_version@
  36. * @link http://www.digitaluscms.com
  37. * @since Release 1.9.0
  38. */
  39. class Digitalus_View_Helper_Content_LoadEditors extends Zend_View_Helper_Abstract
  40. {
  41. protected $_allowedEditors = array('ckeditor', 'fckeditor', 'markitup', 'tinymce', 'wymeditor', 'wysiwyg');
  42. protected $_editorTypes = array();
  43. protected $_scriptsPath = '';
  44. public function loadEditors($controls)
  45. {
  46. $this->_scriptsPath = $this->view->getBaseUrl() . '/scripts';
  47. $adminLanguage = $this->view->getAdminLanguage();
  48. $this->_editorTypes = $this->_getEditorTypes($controls);
  49. foreach ($this->_allowedEditors as $editor) {
  50. if (in_array($editor, $this->_editorTypes)) {
  51. switch (strtolower($editor)) {
  52. case 'ckeditor':
  53. // integrates CkEditor
  54. $this->view->jQuery()->addJavascriptFile($this->_scriptsPath . '/ckeditor/ckeditor.js');
  55. $this->view->jQuery()->addJavascriptFile($this->_scriptsPath . '/ckeditor/adapters/jquery.js');
  56. $this->view->jQuery()->onLoadCaptureStart();?>
  57. $('.ckeditor').ckeditor({
  58. language : '<?php echo $adminLanguage;?>',
  59. });<?php
  60. $this->view->jQuery()->onLoadCaptureEnd();
  61. break;
  62. case 'fckeditor':
  63. default:
  64. // integrates FckEditor
  65. $this->view->jQuery()->addJavascriptFile($this->_scriptsPath . '/fckeditor/jquery.FCKEditor.pack.js');
  66. $this->view->jQuery()->onLoadCaptureStart();?>
  67. $('.fckeditor').fck({
  68. path: '<?php echo $this->_scriptsPath . '/fckeditor/';?>',
  69. toolbar: 'Digitalus',
  70. height: 300
  71. });<?php
  72. $this->view->jQuery()->onLoadCaptureEnd();
  73. break;
  74. case 'markitup':
  75. // integrates MarkItUp
  76. $this->view->jQuery()->addStylesheet($this->_scriptsPath . '/markitup/skins/markitup/style.css');
  77. $this->view->jQuery()->addStylesheet($this->_scriptsPath . '/markitup/sets/html/style.css');
  78. $this->view->jQuery()->addJavascriptFile($this->_scriptsPath . '/markitup/jquery.markitup.js');
  79. $this->view->jQuery()->addJavascriptFile($this->_scriptsPath . '/markitup/sets/html/set.js');
  80. $this->view->jQuery()->onLoadCaptureStart();?>
  81. $('.markItUp').markItUp(
  82. mySettings
  83. );<?php
  84. $this->view->jQuery()->onLoadCaptureEnd();
  85. break;
  86. case 'tinymce':
  87. // integrates TinyMce
  88. $this->view->jQuery()->addJavascriptFile($this->_scriptsPath . '/tiny_mce/jquery.tinymce.js');
  89. $this->view->jQuery()->onLoadCaptureStart();?>
  90. jQuery('textarea.tinymce').tinymce({
  91. lang: '<?php echo $adminLanguage;?>',
  92. theme: 'advanced',
  93. script_url: '<?php echo $this->_scriptsPath . '/tiny_mce/tiny_mce.js';?>',
  94. });<?php
  95. $this->view->jQuery()->onLoadCaptureEnd();
  96. break;
  97. case 'wymeditor':
  98. // integrates WymEditor
  99. $this->view->jQuery()->addJavascriptFile($this->_scriptsPath . '/wymeditor/jquery.wymeditor.min.js');
  100. $this->view->jQuery()->onLoadCaptureStart();?>
  101. jQuery('.wymeditor').wymeditor({
  102. lang: '<?php echo $adminLanguage;?>',
  103. skin: 'compact',
  104. stylesheet: 'styles.css',
  105. postInit: function(wym) {
  106. wym.fullscreen();
  107. wym.hovertools();
  108. wym.resizable();
  109. wym.tidy();
  110. }
  111. });<?php
  112. $this->view->jQuery()->onLoadCaptureEnd();
  113. break;
  114. case 'wysiwyg':
  115. // integrates Jwysiwyg
  116. $this->view->jQuery()->addStylesheet($this->_scriptsPath . '/jquery/plugins/jwysiwyg/jquery.wysiwyg.css');
  117. $this->view->jQuery()->addJavascriptFile($this->_scriptsPath . '/jquery/plugins/jwysiwyg/jquery.wysiwyg.js');
  118. $this->view->jQuery()->onLoadCaptureStart();?>
  119. $('.wysiwyg').wysiwyg({
  120. controls: {
  121. separator04: {visible: true},
  122. insertOrderedList: {visible: true},
  123. insertUnorderedList: {visible: true},
  124. }
  125. });<?php
  126. $this->view->jQuery()->onLoadCaptureEnd();
  127. break;
  128. }
  129. }
  130. }
  131. }
  132. protected function _getEditorTypes($controls)
  133. {
  134. foreach ($controls as $control) {
  135. $this->_editorTypes[] = $control->getAttrib('type');
  136. }
  137. array_unique($this->_editorTypes);
  138. return $this->_editorTypes;
  139. }
  140. }