Source for file mostlyce.php

Documentation is available at mostlyce.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @author Mambo Foundation Inc see README.php
  5. @copyright Mambo Foundation Inc.
  6. *  See COPYRIGHT.php for copyright notices and details.
  7. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
  8. *  LICENSE.php
  9. *  Mambo is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU General Public License
  11. *  as published by the Free Software Foundation; version 2 of the
  12. *  License.
  13. */
  14. /**
  15. @version $Id: mostlyce.php
  16. @package Mambo_4.6
  17. @Based on tinymce.php
  18. @copyright (C) 2000 - 2007 The Mambo Foundation
  19. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  20. *  Mambo is Free Software
  21. */
  22.  
  23. /** ensure this file is being included by a parent file */
  24. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  25.  
  26. Global $mosConfig_live_site$jspath$mosConfig_absolute_path;
  27. include ($mosConfig_absolute_path."/mambots/editors/mostlyce/jscripts/tiny_mce/mostlyce_config.php");
  28.  
  29. $_MAMBOTS->registerFunction'onInitEditor''botmostlyceEditorInit' );
  30. $_MAMBOTS->registerFunction'onGetEditorContents''botmostlyceEditorGetContents' );
  31. $_MAMBOTS->registerFunction'onEditorArea''botmostlyceEditorEditorArea' );
  32.  
  33. // --- Start custom code DHS Informatisering - opensource@dhs.nl, www.dhs.nl  
  34. // This code makes it possible to use mostlyce in a website that combines normal and SSL-connections
  35. if (isset($_SERVER['HTTPS']&&  $_SERVER['HTTPS'== "on"
  36.     $jspath "https:" stristr $mosConfig_live_site"//" );
  37. else {
  38.     $jspath "http:" stristr $mosConfig_live_site"//" );
  39. }
  40. // Replaced every occurrence of '$mosConfig_live_site' with '$jspath' in this file
  41. // --- End custom code DHS Informatisering ---
  42.  
  43. //Render Row Buttons
  44. function renderButton$row$remove_font )
  45. {
  46.     $row explode','$row );
  47.     foreach$row as $key => $rowitem {
  48.         ifstrpos$rowitem'-' )  === 0{
  49.             unset$row[$key);
  50.         }
  51.         if$remove_font ){
  52.             if$rowitem == 'fontselect' || $rowitem == 'fontsizeselect' || $rowitem == 'forecolor' || $rowitem == 'backcolor' {
  53.                 unset$row[$key);
  54.             }
  55.         }
  56.     }
  57.     return $new_row implode','array_values$row ) );
  58. }
  59.  
  60. /**
  61. * TinyMCE WYSIWYG Editor - javascript initialisation
  62. */
  63. function botmostlyceEditorInit({
  64.  
  65.    global $mosConfig_live_site$my$database$mosConfig_absolute_path$jspath$adminside;
  66.  
  67.    require $mosConfig_absolute_path."/mambots/editors/mostlyce/jscripts/tiny_mce/mostlyce_config.php" );
  68.  
  69.         //Allows for dynamic editor sizing by apps like Remository
  70.         $get_width mosGetParam($_GET,'width',NULL);
  71.         $get_height mosGetParam($_GET,'height',NULL);
  72.         if ($get_width{$editor_width = (int)$get_width}
  73.         if ($get_height{$editor_height = (int)$get_height
  74.         
  75.         // Get the default stylesheet
  76.         $query "SELECT template FROM #__templates_menu WHERE client_id='0' AND menuid='0'";
  77.         $database->setQuery$query );
  78.         $cur_template $database->loadResult();
  79.         // Assigned template
  80.         if isset$Itemid && $Itemid != "" && $Itemid != {
  81.             $query "SELECT template FROM #__templates_menu WHERE client_id='0' AND menuid='$Itemid' LIMIT 1";
  82.             $database->setQuery$query );
  83.             $cur_template $database->loadResult($database->loadResult($cur_template;
  84.         }
  85.         
  86.         //Plugin settings and Authorization
  87.         $invalid_elements['object,applet';
  88.  
  89.         //Check access level and MOStlyCE Admin preference.  Set editor items accordingly.  
  90.         //Script Elements (Only loads for Admin)
  91.         if( ($adminside>0&& ($editor_script_acl=='true') ) {
  92.             $elements["script[$editor_script_elms]";
  93.         else {
  94.             $invalid_elements["script";
  95.         }
  96.         //IFrame Elements (Only loads for Admin)
  97.         if( ($adminside>0&& ($editor_iframe_acl=='true') ) {
  98.             $elements["iframe[$editor_iframe_elms]";
  99.         }
  100.         //Media Plugin
  101.         if ($editor_plugin_media_acl=='true'{
  102.             $plugins['media';
  103.         
  104.         //Font Options
  105.         if $editor_font_tools_acl=='true' {
  106.             $elements["font[face|size|color|style]";
  107.             $remove_font false;
  108.        }else{
  109.             $remove_font true;
  110.        }
  111.         //Emotions Plugin
  112.         if$editor_plugin_emotions_acl=='true' {
  113.             $plugins['emotions';
  114.         
  115.         //Print Plugin
  116.         if$editor_plugin_print=='true' {
  117.             $plugins['print';
  118.         
  119.         //Search & Replace Plugin
  120.         if$editor_plugin_searchreplace=='true' {
  121.             $plugins['searchreplace';
  122.         
  123.         //Table Plugin
  124.         if$editor_plugin_table_acl=='true' {
  125.             $plugins['table';
  126.         
  127.         //DateTime Plugin
  128.         if$editor_plugin_datetime_acl=='true' {
  129.             $plugins['insertdatetime';
  130.         
  131.         //SpellChecker Plugin
  132.         if$editor_plugin_spellchecker=='true' {
  133.             $plugins['spellchecker';
  134.         
  135.         //Layer Plugin
  136.         if$editor_plugin_layer=='true' {
  137.             $plugins['layer';
  138.         }   
  139.         //Image/File Manager Plugin
  140.         if ($editor_plugin_img_mgr=='true'{
  141.             $file_browser_callback='fileBrowserCallBack';
  142.         else {
  143.             $file_browser_callback='';
  144.         }
  145.           
  146.         //Paragraphs or breaks
  147.         if $editor_newlines == 'p' ){
  148.             $p_newlines "true";
  149.             $br_newlines "false";
  150.         }
  151.         if $editor_newlines == 'br' ){
  152.             $p_newlines "false";
  153.             $br_newlines "true";
  154.         }
  155.  
  156.         $css_template $mosConfig_live_site."/templates/".$cur_template."/css/";
  157.         $content_css ($editor_css_override == '1' $css_template.$editor_custom_css $css_template."template_css.css";
  158.  
  159.         $editor_layout_row1 renderButtonstr_replace"\r\n"""$editor_layout_row1 )$remove_font );
  160.         $editor_layout_row2 renderButtonstr_replace"\r\n"""$editor_layout_row2 )$remove_font );
  161.         $editor_layout_row3 renderButtonstr_replace"\r\n"""$editor_layout_row3 )$remove_font );
  162.         $editor_layout_row4 renderButtonstr_replace"\r\n"""$editor_layout_row4 )$remove_font );
  163.         
  164.         //Plugins List
  165.         $plugins[$editor_extra_plugins;
  166.         $plugins implode','$plugins );
  167.         $elements[$editor_xtd_elms;
  168.         $elements implode','$elements );
  169.         $invalid_elements implode','$invalid_elements );
  170.  
  171. //Check TinyMCE compression setting and set correct file path
  172. if ($editor_compression==true)
  173. $tinymce_file "mambots/editors/mostlyce/jscripts/tiny_mce/tiny_mce_gzip.php"}
  174. else
  175. $tinymce_file "mambots/editors/mostlyce/jscripts/tiny_mce/tiny_mce.js"}
  176.         
  177.         return <<<EOD
  178. <!--//TinyMCE/MOStlyCE-->    
  179. <script type="text/javascript" src="$jspath/$tinymce_file"></script>
  180. <script type="text/javascript" src="$jspath/mambots/editors/mostlyce/jscripts/tiny_mce/mostlyce_functions.js"></script>
  181. <script type="text/javascript">
  182. if ($editor_compression==true) {
  183. tinyMCE_GZ.init({
  184.     plugins : "$plugins,preview,advlink,advimage,paste,fullscreen,directionality",
  185.     themes : '$editor_themes',
  186.     languages : '$editor_lang',
  187.     disk_cache : true,
  188.     debug : false
  189. });
  190. }
  191. </script>
  192. <!-- Standard init and GZ init need to be in seperate script tags! -->
  193. <script type="text/javascript">
  194.     tinyMCE.init({
  195.         mode : "specific_textareas",
  196.         theme : "$editor_themes",
  197.         language : "$editor_lang",
  198.         lang_list : "$editor_lang_list",
  199.         table_color_fields : true,
  200.         paste_use_dialog : true,
  201.         advimage_constrain_proportions : true,
  202.         invalid_elements: "$invalid_elements",
  203.         force_br_newlines : "$br_newlines",
  204.         force_p_newlines : "$p_newlines",
  205.         directionality : "$editor_direction",
  206.         file_browser_callback : "$file_browser_callback",
  207.         plugins : "$plugins,preview,advlink,advimage,paste,fullscreen,directionality",
  208.         theme_advanced_layout_manager : "RowLayout",
  209.         theme_advanced_containers : "top1,top2,top3,top4,mceEditor,mceElementpath",
  210.         theme_advanced_containers_default_class : "mceToolbar",
  211.         theme_advanced_containers_default_align : "center",
  212.         theme_advanced_container_top1_align : "left",
  213.         theme_advanced_container_top2_align : "left",
  214.         theme_advanced_container_top3_align : "left",
  215.         theme_advanced_container_top4_align : "left",
  216.         theme_advanced_container_top1 : "$editor_layout_row1",
  217.         theme_advanced_container_top2 : "$editor_layout_row2",
  218.         theme_advanced_container_top3 : "$editor_layout_row3",
  219.         theme_advanced_container_top4 : "$editor_layout_row4",
  220.         theme_advanced_container_top1_class : "mceToolbarTop",
  221.         theme_advanced_container_top2_class : "mceToolbarTop",
  222.         theme_advanced_container_top3_class : "mceToolbarTop",
  223.         theme_advanced_container_top4_class : "mceToolbarTop",
  224.         theme_advanced_container_mceElementpath_class : "mcePathBottom",
  225.         width : "$editor_width",
  226.         height : "$editor_height",
  227.         mambo_base_url: "$mosConfig_live_site/",
  228.         document_base_url: "$mosConfig_live_site/",
  229.         content_css : "$content_css",
  230.         plugin_insertdate_dateFormat : "$editor_plugin_dateformat",
  231.         plugin_insertdate_timeFormat : "$editor_plugin_timeformat",
  232.         extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],$elements",
  233.         theme_advanced_resize_horizontal : false,
  234.         theme_advanced_resizing : true,
  235.         apply_source_formatting : false,
  236.         spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv"
  237.         });
  238.         
  239.         function fileBrowserCallBack(field_name, url, type, win) {
  240.         var connector = "../../filemanager/browser.html?Connector=connectors/php/connector.php";
  241.         var enableAutoTypeSelection = false;
  242.         
  243.         var cType;
  244.         tinymcpuk_field = field_name;
  245.         tinymcpuk = win;
  246.         
  247.         switch (type) {
  248.             case "image":
  249.                 cType = "Image";
  250.                 break;
  251.             case "flash":
  252.                 cType = "Flash";
  253.                 break;
  254.             case "file":
  255.                 cType = "File";
  256.                 break;
  257.             case "media":
  258.                 cType = "Media";
  259.                 break;
  260.         }
  261.         
  262.         if (enableAutoTypeSelection && cType) {
  263.             connector += "&Type=" + cType;
  264.         }
  265.         
  266.         window.open(connector, "tinymcpuk", "modal,width=600,height=400");
  267.     }
  268. </script>
  269. <!-- /tinyMCE -->
  270. EOD;
  271. }
  272. /**
  273. * TinyMCE WYSIWYG Editor - copy editor contents to form field
  274. @param string The name of the editor area
  275. @param string The name of the form field
  276. */
  277. function botmostlyceEditorGetContents$editorArea$hiddenField {
  278.         global $jspath;
  279.  
  280.         return <<<EOD
  281.         tinyMCE.triggerSave();
  282. EOD;
  283. }
  284. /**
  285. * mostlyce WYSIWYG Editor - display the editor
  286. @param string The name of the editor area
  287. @param string The content of the field
  288. @param string The name of the form field
  289. @param string The width of the editor area
  290. @param string The height of the editor area
  291. @param int The number of columns for the editor area
  292. @param int The number of rows for the editor area
  293. */
  294. function botmostlyceEditorEditorArea$name$content$hiddenField$width$height$col$row$showbut={
  295.         global $jspath$_MAMBOTS$mosConfig_absolute_path;
  296.         include ($mosConfig_absolute_path."/mambots/editors/mostlyce/jscripts/tiny_mce/mostlyce_config.php");
  297.  
  298.         $results $_MAMBOTS->trigger'onCustomEditorButton' );
  299.         $buttons array();
  300.         foreach ($results as $result{
  301.                $buttons['<img src="'.$jspath.'/mambots/editors-xtd/'.$result[0].'" onclick="tinyMCE.execCommand(\'mceInsertContent\',false,\''.$result[1].'\')" />';
  302.         }
  303.         //Hide old {mosimage} button if requested
  304.         if ($editor_mosimage_icon == 'false'{
  305.           unset($buttons[array_search(0,$buttons)]);
  306.         }
  307.         $buttons implode""$buttons );
  308.  
  309.         return <<<EOD
  310. <textarea id="$hiddenField" name="$hiddenField" cols="$col" rows="$row" style="width:{$width}px; height:{$height}px;" mce_editable="true">$content</textarea>
  311. <br />$buttons
  312. EOD;
  313. }
  314. ?>

Documentation generated on Mon, 05 May 2008 16:21:33 +0400 by phpDocumentor 1.4.0