Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file contains the abstract WYSIWYG editor class.
  4:  *
  5:  * @package Core
  6:  * @subpackage Backend
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Timo Hummel
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Base class for all WYSIWYG editors
 20:  *
 21:  * @package Core
 22:  * @subpackage Backend
 23:  */
 24: abstract class cWYSIWYGEditor {
 25:     /**
 26:      * Access key under which the wysiwyg editor settings will be stored
 27:      * @var string
 28:      */
 29:     protected static $_sConfigPrefix = '[\'wysiwyg\']';
 30: 
 31:     /**
 32:      *
 33:      * @var string
 34:      */
 35:     protected $_sPath;
 36: 
 37:     /**
 38:      *
 39:      * @var string
 40:      */
 41:     protected $_sEditor;
 42: 
 43:     /**
 44:      *
 45:      * @var string
 46:      */
 47:     protected $_sEditorName;
 48: 
 49:     /**
 50:      *
 51:      * @var string
 52:      */
 53:     protected $_sEditorContent;
 54: 
 55:     /**
 56:      *
 57:      * @var array
 58:      */
 59:     protected $_aSettings;
 60: 
 61:     /**
 62:      *
 63:      * @param string $sEditorName
 64:      * @param string $sEditorContent
 65:      */
 66:     public function __construct($sEditorName, $sEditorContent) {
 67:         $cfg = cRegistry::getConfig();
 68: 
 69:         $this->_sPath = $cfg['path']['all_wysiwyg_html'];
 70:         $this->_setEditorName($sEditorName);
 71:         $this->_setEditorContent($sEditorContent);
 72:     }
 73: 
 74:     /**
 75:      *
 76:      * @param string $sContent
 77:      */
 78:     protected function _setEditorContent($sEditorContent) {
 79:         $this->_sEditorContent = $sEditorContent;
 80:     }
 81: 
 82:     /**
 83:      *
 84:      * @param string $sEditor
 85:      */
 86:     protected function _setEditor($sEditor) {
 87:         global $cfg;
 88: 
 89:         if (is_dir($cfg['path']['all_wysiwyg'] . $sEditor)) {
 90:             if (substr($sEditor, strlen($sEditor) - 1, 1) != "/") {
 91:                 $sEditor = $sEditor . "/";
 92:             }
 93: 
 94:             $this->_sEditor = $sEditor;
 95:         }
 96:     }
 97: 
 98:     /**
 99:      * Sets given setting if setting was not yet defined.
100:      * Overwriting defined setting can be achieved with $bForceSetting = true.
101:      *
102:      * @param string $sKey of setting to set
103:      * @param string $sValue of setting to set
104:      * @param bool $bForceSetting to overwrite defined setting
105:      */
106:     protected function _setSetting($sKey, $sValue, $bForceSetting = false) {
107:         if ($bForceSetting || !array_key_exists($sKey, $this->_aSettings)) {
108:             $this->_aSettings[$sKey] = $sValue;
109:         }
110:     }
111: 
112:     /**
113:      *
114:      * @param string $sKey
115:      */
116:     protected function _unsetSetting($sKey) {
117:         unset($this->_aSettings[$sKey]);
118:     }
119: 
120:     /**
121:      *
122:      * @return string
123:      */
124:     protected function _getEditorPath() {
125:         return $this->_sPath . $this->_sEditor;
126:     }
127: 
128:     /**
129:      *
130:      * @param string $sEditorName
131:      */
132:     protected function _setEditorName($sEditorName) {
133:         $this->_sEditorName = $sEditorName;
134:     }
135: 
136:     /**
137:      *
138:      * @throws cBadMethodCallException if this method is not overridden in the
139:      *         subclass
140:      */
141:     protected function _getScripts() {
142:         throw new cBadMethodCallException('You need to override the method _getScripts');
143:     }
144: 
145:     /**
146:      *
147:      * @throws cBadMethodCallException if this method is not overridden in the
148:      *         subclass
149:      */
150:     protected function _getEditor() {
151:         throw new cBadMethodCallException('You need to override the method _getEditor');
152:     }
153: 
154:     /**
155:      * Find out which WYSIWYG editor is currently chosen
156:      * @return string The name of current WYSIWYG editor
157:      */
158:     public static function getCurrentWysiwygEditorName() {
159:         // define fallback WYSIWYG editor
160:         define('DEFAULT_WYSIWYG_EDITOR', 'tinymce3');
161: 
162:         $curWysiwygEditor = getEffectiveSetting('wysiwyg', 'editor', constant('DEFAULT_WYSIWYG_EDITOR'));
163: 
164:         // no paths are allowed in WYSIWYG editor
165:         // fall back to defaults if editor folder does not exist
166:         if (0 === strlen($curWysiwygEditor)
167:         || false === cFileHandler::exists(cRegistry::getConfigValue('path', 'all_wysiwyg') . $curWysiwygEditor)
168:         || false !== strpos($curWysiwygEditor, '.')
169:         || false !== strpos($curWysiwygEditor, '/')
170:         || false !== strpos($curWysiwygEditor, '\\')) {
171:             $curWysiwygEditor = constant('DEFAULT_WYSIWYG_EDITOR');
172:         }
173: 
174:         return $curWysiwygEditor;
175:     }
176: 
177:     /**
178:      * Saves configuration of WYSIWYG editor into a file
179:      * This function does not validate input! This has to be done by classes that extend cWYSIWYGEditor
180:      * because this class does not know what each WYSIWYG editor expects.
181:      * @param array Array with configuration values for the current WYSIWYG editor to save
182:      * @return array Array with values that were not accepted
183:      */
184:     public static function safeConfig($config) {
185:         $erroneousSettings = array();
186: 
187:         // specify filename scheme
188:         // for tinymce 4 this will be config.wysiwyg_tinymce4.php
189:         $configFile = 'config.wysiwyg_' . static::getCurrentWysiwygEditorName() . '.php';
190: 
191:         // get path to current config folder
192:         $configPath = cRegistry::getConfigValue('path', 'contenido_config');
193: 
194:         // write content to file as array in $cfg['tinymce4']
195:         $filePrefix = '<?php ' . PHP_EOL;
196:         $filePrefix .= "defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');\n";
197:         $filePrefix .= 'global $cfg;' . PHP_EOL . PHP_EOL;
198: 
199:         $content = $filePrefix . '$cfg' . static::$_sConfigPrefix . ' = ' . var_export($config, true) . ';' . PHP_EOL;
200: 
201:         // first try to write then check what went wrong in case of error
202:         if (true !== cFileHandler::write($configPath . $configFile, $content)) {
203:             // just pass back that the file could not be written
204:             $erroneusSettings['saving'] = array('config_file' => 'wysiwyg config file could not be written');
205:             // write more detailed information with sensitive information such as full path into error log
206:             error_log('Error writing ' . $configPath . $configFile);
207:             return $erroneusSettings;
208:         }
209: 
210:         return $erroneousSettings;
211:     }
212: }
213: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen