From 99f904adcc37d93c90defcd8ce898598e25be212 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 11 Mar 2015 16:55:04 +0100 Subject: Lot of plugins --- codemirror_ui/codemirror_ui.php | 153 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 codemirror_ui/codemirror_ui.php (limited to 'codemirror_ui/codemirror_ui.php') diff --git a/codemirror_ui/codemirror_ui.php b/codemirror_ui/codemirror_ui.php new file mode 100644 index 0000000..1493048 --- /dev/null +++ b/codemirror_ui/codemirror_ui.php @@ -0,0 +1,153 @@ +Documentation'; + static private $version = '1.0.5'; + static private $date = '08-05-2014'; + static private $licence = 'GPL'; + static private $requirements = array( + 'Roundcube' => '1.0', + 'PHP' => '5.3' + ); + + private $rcmail; + + function init(){ + $this->rcmail = rcmail::get_instance(); + switch($GLOBALS['codemirror']['mode']){ + case 'PHP': + $this->rcmail->output->add_header(''); + break; + case 'SQL': + $this->rcmail->output->add_header(''); + } + $this->include_stylesheet('lib/CodeMirror-2.3/lib/codemirror.css'); + $this->include_script('lib/CodeMirror-2.3/lib/codemirror.js'); + $this->include_script('lib/CodeMirror-2.3/lib/util/searchcursor.js'); + switch($GLOBALS['codemirror']['mode']){ + case 'PHP': + $this->PHP($GLOBALS['codemirror']['elem']); + break; + case 'SQL': + $this->SQL($GLOBALS['codemirror']['elem']); + } + $this->include_stylesheet('css/codemirror-ui.css'); + $this->include_script('js/codemirror-ui.js'); + } + + function PHP($elem){ + $this->include_script('lib/CodeMirror-2.3/mode/htmlmixed/htmlmixed.js'); + $this->include_script('lib/CodeMirror-2.3/mode/xml/xml.js'); + $this->include_script('lib/CodeMirror-2.3/mode/javascript/javascript.js'); + $this->include_script('lib/CodeMirror-2.3/mode/css/css.js'); + $this->include_script('lib/CodeMirror-2.3/mode/clike/clike.js'); + $this->include_script('lib/CodeMirror-2.3/mode/php/php.js'); + $this->rcmail->output->add_script(' + var textarea = document.getElementById("' . $elem . '"); + var uiOptions = { + path : "js/", + searchMode : "popup", + mode: "php", + imagePath : "plugins/codemirror_ui/images/silk", + buttons : ' . $GLOBALS['codemirror']['buttons'] . ', + saveCallback : ' . $GLOBALS['codemirror']['save'] . ' + } + var codeMirrorOptions = { + readOnly: ' . ($GLOBALS['codemirror']['readonly'] ? 'true' : 'false') . ', + lineNumbers: true, + matchBrackets: true, + mode: "application/x-httpd-php", + indentUnit: 2, + indentWithTabs: true, + enterMode: "keep", + tabMode: "shift", + tabSize: 2 + } + var editor = new CodeMirrorUI(textarea, uiOptions, codeMirrorOptions); + ', 'docready' + ); + } + + function SQL($elem){ + $this->include_script('lib/CodeMirror-2.3/mode/htmlmixed/htmlmixed.js'); + $this->include_script('lib/CodeMirror-2.3/mode/xml/xml.js'); + $this->include_script('lib/CodeMirror-2.3/mode/javascript/javascript.js'); + $this->include_script('lib/CodeMirror-2.3/mode/css/css.js'); + $this->include_script('lib/CodeMirror-2.3/mode/clike/clike.js'); + $this->include_script('lib/CodeMirror-2.3/mode/mysql/mysql.js'); + $this->rcmail->output->add_script(' + var textarea = document.getElementById("' . $elem . '"); + var uiOptions = { + path : "js/", + searchMode : "popup", + mode: "mysql", + imagePath : "plugins/codemirror_ui/images/silk", + buttons : ' . $GLOBALS['codemirror']['buttons'] . ', + saveCallback : ' . $GLOBALS['codemirror']['save'] . ' + } + var codeMirrorOptions = { + readOnly: ' . ($GLOBALS['codemirror']['readonly'] ? 'true' : 'false') . ', + lineNumbers: true, + matchBrackets: true, + mode: "text/x-mysql", + indentUnit: 2, + indentWithTabs: true, + enterMode: "keep", + tabMode: "shift", + fixedGutter: true, + tabSize: 2 + } + var editor = new CodeMirrorUI(textarea, uiOptions, codeMirrorOptions); + ', 'docready' + ); + } + + static public function about($keys = false){ + $requirements = self::$requirements; + foreach(array('required_', 'recommended_') as $prefix){ + if(is_array($requirements[$prefix.'plugins'])){ + foreach($requirements[$prefix.'plugins'] as $plugin => $method){ + if(class_exists($plugin) && method_exists($plugin, 'about')){ + /* PHP 5.2.x workaround for $plugin::about() */ + $class = new $plugin(false); + $requirements[$prefix.'plugins'][$plugin] = array( + 'method' => $method, + 'plugin' => $class->about($keys), + ); + } + else{ + $requirements[$prefix.'plugins'][$plugin] = array( + 'method' => $method, + 'plugin' => $plugin, + ); + } + } + } + } + return array( + 'plugin' => self::$plugin, + 'version' => self::$version, + 'date' => self::$date, + 'author' => self::$author, + 'comments' => self::$authors_comments, + 'licence' => self::$licence, + 'requirements' => $requirements, + ); + } +} + +?> \ No newline at end of file -- cgit v1.2.3