[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/administrator/components/com_mostlyce/ -> admin.mostlyce.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @author Mambo Foundation Inc see README.php
   5  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   6  * See COPYRIGHT.php for copyright notices and details.
   7  * @license GNU/GPL Version 2, see LICENSE.php
   8  *
   9  * Redistributions of files must retain the above copyright notice.
  10  *
  11  * Mambo is free software; you can redistribute it and/or
  12  * modify it under the terms of the GNU General Public License
  13  * as published by the Free Software Foundation; version 2 of the License.
  14  */ 
  15  
  16  /** ensure this file is being included by a parent file */
  17  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  18  
  19  //Ensure user has access to this function
  20  if (!($acl->acl_check('administration', 'edit', 'users', $my->usertype, 'components', 'all') || $acl->acl_check('administration', 'edit', 'users', $my->usertype, 'components', 'com_mostlyce'))) {
  21      mosRedirect( 'index2.php', T_('You are not authorized to view this resource.') );
  22  }
  23  //Verify the MOStlyCE mambot has been installed
  24  if (!file_exists($mosConfig_absolute_path.'/mambots/editors/mostlyce/jscripts/tiny_mce/mostlyce_config.php')){
  25     mosRedirect( 'index2.php', T_('Cannot find mostlyce_config.php! Please install the MOStlyCE mambot.'));
  26  }
  27  
  28  include ($mosConfig_absolute_path.'/mambots/editors/mostlyce/jscripts/tiny_mce/mostlyce_config.php');
  29  
  30  class mosCE_Config extends mosDBTable {
  31          /** @var int */
  32          var $editor_themes=null;
  33          var $editor_compression=null;
  34          var $editor_lang=null;
  35          var $editor_lang_list=null;
  36          var $editor_width=null;
  37          var $editor_height=null;
  38          var $editor_css_override=null;
  39          var $editor_custom_css=null;
  40          var $editor_newlines=null;
  41          var $editor_convert_urls=null;
  42          var $editor_script_acl=null;
  43          var $editor_script_elms;
  44          var $editor_iframe_acl=null;
  45          var $editor_iframe_elms;
  46          var $editor_xtd_elms=null;
  47          var $editor_direction=null;
  48          var $editor_preview_bgcolor=null;
  49          var $editor_extra_plugins=null;
  50          var $editor_font_tools_acl=null;
  51          var $editor_plugin_datetime_acl=null;
  52          var $editor_plugin_dateformat=null;
  53          var $editor_plugin_timeformat=null;
  54          var $editor_plugin_emotions_acl=null;
  55          var $editor_plugin_print=null;
  56          var $editor_plugin_searchreplace=null;
  57          var $editor_plugin_media_acl=null;
  58          var $editor_plugin_table_acl=null;
  59          var $editor_plugin_spellchecker=null;
  60          var $editor_plugin_layer=null;
  61          var $editor_mosimage_icon=null;
  62          var $editor_plugin_img_mgr=null;
  63          var $editor_tmpl_dir=null;
  64  
  65          function mosCE_Config() {
  66                  $this->_alias = array(
  67                  'editor_themes'                                 =>'editor_themes',
  68                  'editor_compression'                         =>'editor_compression',
  69                  'editor_lang'                                =>'editor_lang',
  70                  'editor_lang_list'                           =>'editor_lang_list',
  71                  'editor_width'                               =>'editor_width',
  72                  'editor_height'                              =>'editor_height',
  73                  'editor_css_override'                        =>'editor_css_override',
  74                  'editor_custom_css'                          =>'editor_custom_css',
  75                  'editor_newlines'                            =>'editor_newlines',
  76                  'editor_convert_urls'                        =>'editor_convert_urls',
  77                  'editor_script_acl'                          =>'editor_script_acl',
  78                  'editor_script_elms'                         =>'editor_script_elms',
  79                  'editor_iframe_acl'                          =>'editor_iframe_acl',
  80                  'editor_iframe_elms'                         =>'editor_iframe_elms',
  81                  'editor_xtd_elms'                            =>'editor_xtd_elms',
  82                  'editor_direction'                           =>'editor_direction',
  83                  'editor_extra_plugins'                       =>'editor_extra_plugins',
  84                  'editor_font_tools_acl'                      =>'editor_font_tools_acl',
  85                  'editor_plugin_datetime_acl'                 =>'editor_plugin_datetime_acl',
  86                  'editor_plugin_dateformat'                   =>'editor_plugin_dateformat',
  87                  'editor_plugin_timeformat'                   =>'editor_plugin_timeformat',
  88                  'editor_plugin_emotions_acl'                 =>'editor_plugin_emotions_acl',
  89                  'editor_plugin_print'                        =>'editor_plugin_print',
  90                  'editor_plugin_searchreplace'                =>'editor_plugin_searchreplace',
  91                  'editor_plugin_media_acl'                    =>'editor_plugin_media_acl',
  92                  'editor_plugin_table_acl'                    =>'editor_plugin_table_acl',
  93                  'editor_plugin_spellchecker'                 =>'editor_plugin_spellchecker',
  94                  'editor_plugin_layer'                        =>'editor_plugin_layer',
  95                  'editor_mosimage_icon'                       =>'editor_mosimage_icon',
  96                  'editor_plugin_img_mgr'                         =>'editor_plugin_img_mgr',
  97                  'editor_tmpl_dir'                            =>'editor_tmpl_dir'
  98                  );
  99          }
 100  
 101          function getVarText() {
 102              $txt = '';
 103              foreach ($this->_alias as $k=>$v) {
 104                  $txt .= "\$$v = '".addslashes( $this->$k )."';\n";
 105              }
 106              return $txt;
 107          }
 108  
 109          function bindGlobals() {
 110              foreach ($this->_alias as $k=>$v) {
 111                  if(isset($GLOBALS[$v])) {
 112                      $this->$k = $GLOBALS[$v];
 113                  } else {
 114                      $this->$k = "";
 115                  }
 116              }
 117          }
 118  }
 119  
 120  require_once( 'components/com_mostlyce/admin.mostlyce.html.php' );
 121  $confightml = new HTML_expConfig();
 122  
 123  switch ($task) {
 124          case 'save':
 125              saveconfig();
 126              break;
 127          case 'config':
 128              showconfig($confightml, $database, $option);
 129              break;
 130          default:
 131              showconfig($confightml, $database, $option);
 132              break;
 133  }
 134  
 135  function showconfig($confightml, &$database, $option) {
 136          global $database, $mosConfig_absolute_path;
 137          $row = new mosCE_Config();
 138          $row->bindGlobals();
 139  
 140          // compile list of the languages
 141          $editor_lang = array();
 142  
 143          if ($handle=opendir( "$mosConfig_absolute_path/mambots/editors/mostlyce/jscripts/tiny_mce/langs/" )) {
 144              $i=0;
 145              while (false !== ($file = readdir($handle))) {
 146                  if ($file <> "." && $file <> "..") {
 147                      $editor_lang[] = mosHTML::makeOption( substr($file,0,-3) );
 148                  }
 149              }
 150            closedir($handle);
 151        }
 152  
 153          // sort list of languages
 154          sort($editor_lang);
 155          reset($editor_lang);
 156  
 157          $lists = array();
 158  
 159          $editor_newlines = array(
 160                  mosHTML::makeOption( 'br', T_('BR Elements') ),
 161                  mosHTML::makeOption( 'p', T_('P Elements') )
 162          );
 163  
 164          $editor_themes = array(
 165                  mosHTML::makeOption( 'advanced', T_('Advanced') ),
 166                  mosHTML::makeOption( 'simple', T_('Simple') )
 167          );
 168  
 169          $editor_compression = array(
 170                  mosHTML::makeOption( 'true', T_('On') ),
 171                  mosHTML::makeOption( 'false', T_('Off') )
 172          );
 173          
 174          $editor_direction = array(
 175                  mosHTML::makeOption( 'ltr', T_('Left to Right') ),
 176                  mosHTML::makeOption( 'rtl', T_('Right to Left') )
 177          );
 178          
 179          //Non-specific, used by several plugins
 180          $editor_true_false = array(
 181                  mosHTML::makeOption( 'true', T_('Yes') ),
 182                  mosHTML::makeOption( 'false', T_('No') )
 183          );
 184  
 185          $php_settings = new mosCE_Config();
 186  
 187          // build the html select lists
 188          //Standard Editor options
 189          $lists['editor_themes']                             = mosHTML::selectList( $editor_themes, 'editor_themes', 'class="inputbox" size="1"', 'value', 'text', $row->editor_themes );
 190          $lists['editor_compression']                        = mosHTML::selectList( $editor_compression, 'editor_compression', 'class="inputbox" size="1"', 'value', 'text', $row->editor_compression );
 191          $lists['editor_lang']                               = mosHTML::selectList( $editor_lang, 'editor_lang', 'class="inputbox" size="1"', 'value', 'text', $row->editor_lang );
 192          $lists['editor_css_override']                       = mosHTML::yesnoSelectList( 'editor_css_override', 'class="inputbox" size="1"', $row->editor_css_override );
 193          $lists['editor_newlines']                           = mosHTML::selectList( $editor_newlines, 'editor_newlines', 'class="inputbox" size="1"', 'value', 'text', $row->editor_newlines );
 194          $lists['editor_convert_urls']                       = mosHTML::selectList( $editor_true_false, 'editor_convert_urls', 'class="inputbox" size="1"', 'value', 'text', $row->editor_convert_urls );
 195          $lists['editor_script_acl']                         = mosHTML::selectList( $editor_true_false, 'editor_script_acl', 'class="inputbox" size="1"', 'value', 'text', $row->editor_script_acl );
 196          $lists['editor_iframe_acl']                         = mosHTML::selectList( $editor_true_false, 'editor_iframe_acl', 'class="inputbox" size="1"', 'value', 'text', $row->editor_iframe_acl );
 197          $lists['editor_direction']                          = mosHTML::selectList( $editor_direction, 'editor_direction', 'class="inputbox" size="1"', 'value', 'text', $row->editor_direction );
 198          //Editor Plugin options
 199          $lists['editor_font_tools_acl']                     = mosHTML::selectList( $editor_true_false, 'editor_font_tools_acl', 'class="inputbox" size="1"', 'value', 'text', $row->editor_font_tools_acl );
 200          $lists['editor_plugin_emotions_acl']                = mosHTML::selectList( $editor_true_false, 'editor_plugin_emotions_acl', 'class="inputbox" size="1"', 'value', 'text', $row->editor_plugin_emotions_acl );
 201          $lists['editor_plugin_print']                       = mosHTML::selectList( $editor_true_false, 'editor_plugin_print', 'class="inputbox" size="1"', 'value', 'text',  $row->editor_plugin_print );
 202          $lists['editor_plugin_searchreplace']               = mosHTML::selectList( $editor_true_false, 'editor_plugin_searchreplace', 'class="inputbox" size="1"', 'value', 'text',  $row->editor_plugin_searchreplace );
 203          $lists['editor_plugin_media_acl']                   = mosHTML::selectList( $editor_true_false, 'editor_plugin_media_acl', 'class="inputbox" size="1"', 'value', 'text', $row->editor_plugin_media_acl );
 204          $lists['editor_plugin_datetime_acl']                = mosHTML::selectList( $editor_true_false, 'editor_plugin_datetime_acl', 'class="inputbox" size="1"', 'value', 'text', $row->editor_plugin_datetime_acl );
 205          $lists['editor_plugin_table_acl']                   = mosHTML::selectList( $editor_true_false, 'editor_plugin_table_acl', 'class="inputbox" size="1"', 'value', 'text', $row->editor_plugin_table_acl );
 206          $lists['editor_plugin_spellchecker']                = mosHTML::selectList( $editor_true_false, 'editor_plugin_spellchecker', 'class="inputbox" size="1"', 'value', 'text', $row->editor_plugin_spellchecker );
 207          $lists['editor_plugin_layer']                       = mosHTML::selectList( $editor_true_false, 'editor_plugin_layer', 'class="inputbox" size="1"', 'value', 'text', $row->editor_plugin_layer );
 208          $lists['editor_plugin_img_mgr']                     = mosHTML::selectList( $editor_true_false, 'editor_plugin_img_mgr', 'class="inputbox" size="1"', 'value', 'text', $row->editor_plugin_img_mgr );
 209          $lists['editor_mosimage_icon']                     = mosHTML::selectList( $editor_true_false, 'editor_mosimage_icon', 'class="inputbox" size="1"', 'value', 'text', $row->editor_mosimage_icon );
 210  
 211          $confightml->showconfig($row, $lists, $option);
 212  }
 213  
 214  function saveconfig() {
 215          global $database;
 216  
 217          $row = new mosCE_Config();
 218          if (!$row->bind( $_POST )) {
 219                  mosRedirect( "index2.php?option=com_mostlyce", $row->getError() );
 220          }
 221  
 222          $config = "<?php \n";
 223          $config .= $row->getVarText();
 224          $config .= '?>';
 225  
 226          if ($fp = fopen('../mambots/editors/mostlyce/jscripts/tiny_mce/mostlyce_config.php', 'w')) {
 227              fputs($fp, $config, strlen($config));
 228              fclose ($fp);
 229              mosRedirect( 'index2.php?option=com_mostlyce&task=config', 'The configuration details have been updated!' );
 230          } else {
 231              mosRedirect( 'index2.php?option=com_mostlyce&task=config', 'An Error Has Occurred! Unable to open config file to write!' );
 232          }
 233  }
 234  ?>