[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/FCKeditorX/ -> FCKeditorX.module.php (source)

   1  <?php
   2  /*

   3  #-------------------------------------------------------------------------

   4  # Module: FCKeditorX - WYSIWYG editor

   5  # Version: 0.9.x, Roberto Taglieto, alias MegaBob3

   6  #

   7  #-------------------------------------------------------------------------

   8  # CMS - CMS Made Simple is (c) 2005 by Ted Kulp (wishy@cmsmadesimple.org)

   9  # This project's homepage is: http://www.cmsmadesimple.org

  10  #

  11  #-------------------------------------------------------------------------

  12  #

  13  # This program is free software; you can redistribute it and/or modify

  14  # it under the terms of the GNU General Public License as published by

  15  # the Free Software Foundation; either version 2 of the License, or

  16  # (at your option) any later version.

  17  #

  18  # This program is distributed in the hope that it will be useful,

  19  # but WITHOUT ANY WARRANTY; without even the implied warranty of

  20  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

  21  # GNU General Public License for more details.

  22  # You should have received a copy of the GNU General Public License

  23  # along with this program; if not, write to the Free Software

  24  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

  25  # Or read it online: http://www.gnu.org/licenses/licenses.html#GPL

  26  #

  27  #-------------------------------------------------------------------------

  28  */
  29  
  30  
  31  class FCKeditorX extends CMSModule
  32  {
  33  
  34  	function GetName()
  35      {
  36          return "FCKeditorX";
  37      }
  38  
  39  
  40  	function GetFriendlyName()
  41      {
  42          return $this->Lang('friendlyname');
  43      }
  44  
  45  
  46  	function GetVersion()
  47      {
  48          return '1.0.5';
  49      }
  50  
  51  
  52  	function IsWYSIWYG() {
  53          return true;
  54      }
  55  
  56  
  57  	function GetHelp()
  58      {
  59          return $this->Lang('help');
  60      }
  61  
  62  
  63  	function GetAuthor()
  64      {
  65          return 'Roberto Tagliento/Morten Poulsen';
  66      }
  67  
  68  
  69  	function GetAuthorEmail()
  70      {
  71          return 'megabob3@yahoo.it/morten@poulsen.org';
  72      }
  73  
  74  	function GetChangeLog()
  75      {
  76          return $this->Lang('changelog');
  77      }
  78  
  79  	function IsPluginModule()
  80      {
  81          return true;
  82      }
  83  
  84  	function HasAdmin()
  85      {
  86          return true;
  87      }
  88  
  89  	function IsAdminOnly()
  90      {
  91          return true;
  92      }
  93  
  94  	function GetAdminSection()
  95      {
  96          return 'extensions';
  97      }
  98  
  99  
 100  	function GetAdminDescription()
 101      {
 102          return $this->Lang('moddescription');
 103      }
 104  
 105  
 106  	function VisibleToAdminUser()
 107      {
 108          return $this->CheckPermission('Modify FCKeditorX');
 109      }
 110  
 111  
 112  	function GetDependencies()
 113      {
 114          return array();
 115      }
 116  
 117  
 118  	function Install()
 119      {
 120          $this->CreatePermission('Modify FCKeditorX', 'Modify FCKeditorX');
 121  
 122          $this->SetPreference('FCKConfig.SkinSelected', 'default');
 123          $this->SetPreference('FCKConfig.CMSMSLanguage', '1');
 124          $this->SetPreference('FCKConfig.EnableXHTML', '1');
 125          $this->SetPreference('FCKConfig.ContextMenu', '1');
 126          $this->SetPreference('FCKConfig.BgColor', 'default');
 127          $this->SetPreference('FCKConfig.BodyCSS', 'default');
 128          $this->SetPreference('FCKConfig.Width', 'default');
 129          $this->SetPreference('FCKConfig.Height', 'default');
 130          $this->SetPreference('FCKConfig.ToolbarSet', 'default');
 131  
 132          $basic = "
 133  FCKConfig.ToolbarSets[\"Basic\"] = [
 134      ['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About']
 135  ] ;
 136  
 137  FCKConfig.ToolbarSets[\"Full\"] = [
 138      ['Source','-','Templates'],
 139      ['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
 140      ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
 141      ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
 142      ['OrderedList','UnorderedList','-','Outdent','Indent'],
 143      ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],'/',
 144      ['CMSModules','CMSContent','Link','Unlink','Anchor'],
 145      ['Image','Flash','Table','Rule','SpecialChar'],
 146      ['Form','Checkbox','Radio','TextField','Textarea','Select','Button'],
 147      ['ImageButton','HiddenField'],
 148      '/',
 149      ['Style','FontFormat','FontName','FontSize'],
 150      ['TextColor','BGColor'],
 151      ['About']
 152  ] ;
 153  ";
 154          $this->SetPreference('FCKConfig.CustomToolbar', $basic);
 155          $this->SetPreference('FCKConfig.Styles', '');
 156          //     $this->SetPreference('FCKConfig.ToolbarSets', '');

 157  
 158          ///////////////////////////////////////

 159  /*        global $gCms;

 160          $db =& $gCms->GetDb();

 161  

 162          $dict = NewDataDictionary($db);

 163          $flds = "

 164              fckx_id I KEY,

 165              data X

 166          ";

 167  

 168          $taboptarray = array('mysql' => 'TYPE=MyISAM');

 169          $sqlarray = $dict->CreateTableSQL(cms_db_prefix()."module_FCKX",

 170          $flds, $taboptarray);

 171          $dict->ExecuteSQLArray($sqlarray);

 172  

 173  

 174          $query  = "INSERT INTO " . cms_db_prefix() . "module_FCKX ( fckx_id , data ) ";

 175          $query .= "VALUES ('1', '')";

 176          $result = $db->Execute($query);

 177  

 178          $query  = "INSERT INTO " . cms_db_prefix() . "module_FCKX ( fckx_id , data ) ";

 179          $query .= "VALUES ('2', '')";

 180          $result = $db->Execute($query);

 181  */
 182  
 183  
 184          /* This was redeclared here again, but doesn't need to be here?  /westis

 185  

 186          $basic = "

 187          FCKConfig.ToolbarSets[\"Basic\"] = [

 188          ['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About']

 189          ] ;

 190          ";

 191          */
 192  
 193  
 194          //$db->Execute("UPDATE " . cms_db_prefix() . "module_FCKX SET data = ? WHERE fckx_id = ? LIMIT 1", array($basic, 2));

 195  
 196  
 197          ///////////////////////////////////////

 198  
 199          // put mention into the admin log

 200          $this->Audit( 0, $this->Lang('friendlyname'), $this->Lang('installed',$this->GetVersion()));
 201      }
 202  
 203  
 204  	function InstallPostMessage()
 205      {
 206          return $this->Lang('postinstall');
 207      }
 208  
 209  
 210  	function UninstallPostMessage()
 211      {
 212          return $this->Lang('postuninstall');
 213      }
 214  
 215  
 216  
 217  	function Upgrade($oldversion, $newversion)
 218      {
 219          $this->RemovePermission('Use FCKeditorX');
 220          $this->Install();
 221          $this->InstallPostMessage();
 222  
 223          //Remove custom table used in earlier versions

 224          global $gCms;
 225          $db =& $gCms->GetDb();
 226          $dict = NewDataDictionary( $db );
 227  
 228          $sqlarray = $dict->DropTableSQL( cms_db_prefix()."module_FCKX" );
 229          $dict->ExecuteSQLArray($sqlarray);
 230  
 231          //        $current_version = $oldversion;

 232          //

 233          //         switch($current_version)

 234          //         {

 235          //             case "1.0":

 236          //                  break;

 237          //             case "1.1":

 238          //                  break;

 239          //         }

 240          //

 241          //         // put mention into the admin log

 242          //         $this->Audit( 0, $this->Lang('friendlyname'), $this->Lang('upgraded',$this->GetVersion()));

 243  
 244      }
 245  
 246  
 247  	function Uninstall()
 248      {
 249          $this->RemovePreference('FCKConfig.SkinSelected');
 250          $this->RemovePreference('FCKConfig.CMSMSLanguage');
 251          $this->RemovePreference('FCKConfig.EnableXHTML');
 252          $this->RemovePreference('FCKConfig.ContextMenu');
 253          $this->RemovePreference('FCKConfig.BgColor');
 254          $this->RemovePreference('FCKConfig.BodyCSS');
 255          $this->RemovePreference('FCKConfig.Width');
 256          $this->RemovePreference('FCKConfig.Height');
 257          $this->RemovePreference('FCKConfig.ToolbarSet');
 258          $this->RemovePreference('FCKConfig.CustomToolbar');
 259          $this->RemovePreference('FCKConfig.Styles');
 260          //     $this->RemovePreference('FCKConfig.ToolbarSets');

 261  
 262          $this->RemovePermission('Modify FCKeditorX');
 263  
 264          global $gCms;
 265          $db =& $gCms->GetDb();
 266          $dict = NewDataDictionary( $db );
 267  
 268          $sqlarray = $dict->DropTableSQL( cms_db_prefix()."module_FCKX" );
 269          $dict->ExecuteSQLArray($sqlarray);
 270  
 271          // put mention into the admin log

 272          $this->Audit( 0, $this->Lang('friendlyname'), $this->Lang('uninstalled'));
 273      }
 274  
 275  	function SetParameters()
 276      {
 277          $this->CreateParameter('content', '', $this->lang('help_content'));
 278          $this->CreateParameter('toolbar', 'Default', $this->lang('help_toolbar'));
 279          $this->CreateParameter('height', '200', $this->lang('height_help'));
 280          $this->CreateParameter('width', '400', $this->lang('width_help'));
 281          $this->CreateParameter('context', '1', $this->lang('help_context'));
 282          $this->CreateParameter('skin', 'default', $this->lang('help_skin'));
 283          $this->CreateParameter('name', 'FCKXtextarea', $this->lang('help_name'), false);
 284      }
 285  
 286      /////////////////////////////////////////////////

 287      /////////////////////////////////////////////////

 288  
 289  	function WYSIWYGTextarea($name='textarea',$columns='80',$rows='15',$encoding='',$content='',$stylesheet='', $params=array()) {
 290  
 291          //echo "ss:".$stylesheet;

 292          if (isset($params['name']))
 293          $name = $params['name'];
 294  
 295          if (isset($params['content'])) $content = $params['content'];
 296  
 297          $ok = false;
 298  
 299          $html_out = '';
 300  
 301  
 302          if(ereg("MSIE", $_SERVER["HTTP_USER_AGENT"])) $ok = true;
 303          if(ereg("Firefox", $_SERVER["HTTP_USER_AGENT"])) $ok = true;
 304          if(ereg("Gecko", $_SERVER["HTTP_USER_AGENT"])) $ok = true;  //Maybe WRONG

 305  
 306          if(ereg("Konqueror", $_SERVER["HTTP_USER_AGENT"])) $ok = false;
 307          if(ereg("Safari", $_SERVER["HTTP_USER_AGENT"])) $ok = false;
 308          if(ereg("Opera", $_SERVER["HTTP_USER_AGENT"])) $ok = false;
 309  
 310          // Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5

 311          // Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)

 312          // Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.51

 313          // echo    $_SERVER["HTTP_USER_AGENT"];

 314  
 315  
 316          if ($ok) {
 317              include_once(dirname(__FILE__)."/FCKeditor/fckeditor.php");
 318  
 319              $html_out .= "<h6 style='line-height: 0pt;'>&nbsp;&nbsp;</h6>";
 320  
 321              //+++++++++++++++++++++++++++++++++++

 322              // PREPARATION custom style TO DISPLAY

 323              //+++++++++++++++++++++++++++++++++++

 324  
 325              $stylesheet = str_replace ( "../", "", $stylesheet);
 326  
 327              $templateid = NULL;
 328  
 329              // CHECK if there is a custom CSS to show

 330              if (strcmp($stylesheet, "") != 0)
 331              $templateid = substr($stylesheet, strpos($stylesheet,"=")+1);
 332              //echo $templateid;

 333  
 334              // END if (strcmp($stylesheet, "") != 0){

 335              //+++++++++++++++++++++++++++++++++++

 336              // END PREPARATION custom style TO DISPLAY

 337              //+++++++++++++++++++++++++++++++++++

 338  
 339  
 340              $html_out .= "";
 341  
 342              $oFCKeditor = new FCKeditor($name) ;
 343  
 344              $diff = str_replace($this->cms->config["root_url"].'/', '', $this->cms->config["uploads_url"]);
 345  
 346              $oFCKeditor->BasePath = $this->cms->config["root_url"].'/modules/FCKeditorX/FCKeditor/';
 347  
 348              if (intval($rows) == 0)
 349              $rows = 13;
 350  
 351              $ToolbarSet = $this->GetPreference('FCKConfig.ToolbarSet');
 352              if (strcmp($ToolbarSet, 'default') != 0)
 353              $oFCKeditor->ToolbarSet = $ToolbarSet;
 354              if (isset($params['toolbar']))
 355              $oFCKeditor->ToolbarSet = $params['toolbar'];
 356  
 357              $height = $this->GetPreference('FCKConfig.Height');
 358              if ($height == 0)
 359              $oFCKeditor->Height = $rows*33+20*3;
 360              else
 361              $oFCKeditor->Height = $height;
 362              if (isset($params['height']))
 363              $oFCKeditor->Height = $params['height'];
 364  
 365  
 366              $width = $this->GetPreference('FCKConfig.Width');
 367              if ($width != 0)
 368              $oFCKeditor->Width = $width;
 369              if (isset($params['width']))
 370              $oFCKeditor->Width = $params['width'];
 371  
 372  
 373              $oFCKeditor->Value = $content ;
 374  
 375  
 376              //GET FCKeditor CMSMS configuration

 377              $skin = $this->GetPreference('FCKConfig.SkinSelected');
 378              if (isset($params['skin']))
 379              $skin = $params['skin'];
 380  
 381  
 382              $xhtml = $this->GetPreference("FCKConfig.EnableXHTML");
 383              if (isset($params['xhtml']))
 384              $xhtml = $params['xhtml'];
 385  
 386              $context = $this->GetPreference("FCKConfig.ContextMenu");
 387              if (isset($params['context']))
 388              $context = $params['context'];
 389  
 390              $lang = $this->GetPreference('FCKConfig.CMSMSLanguage');
 391              if ($lang){
 392                  $lang = $this->cms->userprefs["default_cms_language"];
 393                  if (strpos($lang, "_"))
 394                  $lang = substr($lang, 0, 2);
 395                  else
 396                  $lang = false;
 397              }
 398              if (isset($params['lang']))
 399              $lang = $params['lang'];
 400  
 401              //LOAD CMSMS config of FCKeditor

 402              $oFCKeditor->Config['CustomConfigurationsPath'] = '' ;
 403              $oFCKeditor->Config['SkinPath'] = $oFCKeditor->BasePath."editor/skins/$skin/";
 404  
 405              if (!$lang)
 406              $oFCKeditor->Config['AutoDetectLanguage'] = 'true';
 407              else{
 408                  $oFCKeditor->Config['AutoDetectLanguage'] = 'false';
 409                  $oFCKeditor->Config['DefaultLanguage'] = $lang;
 410              }
 411  
 412              if ($context == 0)
 413              $oFCKeditor->Config['ContextMenu'] = "['']";
 414  
 415              if ($xhtml == 1){
 416                  $oFCKeditor->Config['EnableXHTML'] = 'true';
 417                  $oFCKeditor->Config['EnableSourceXHTML'] = 'true';
 418              }
 419  
 420              $oFCKeditor->Config['EditorAreaCSS'] = $this->cms->config["root_url"].'/modules/FCKeditorX/fck_editorarea.css.php?id='.$templateid ;
 421  
 422              $oFCKeditor->Config['StylesXmlPath'] = $this->cms->config["root_url"].'/modules/FCKeditorX/fckstyles.xml.php?id='.$templateid ;
 423  
 424              $oFCKeditor->Config['LinkBrowserURL']  = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector=connectors/php/connector.php' ;
 425              $oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php' ;
 426              $oFCKeditor->Config['FlashBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/php/connector.php' ;
 427              $oFCKeditor->Config['LinkUploadURL']   = $oFCKeditor->BasePath.'editor/filemanager/upload/php/upload.php' ;
 428              $oFCKeditor->Config['ImageUploadURL']  = $oFCKeditor->BasePath.'editor/filemanager/upload/php/upload.php?Type=Image' ;
 429              $oFCKeditor->Config['FlashUploadURL']  = $oFCKeditor->BasePath.'editor/filemanager/upload/php/upload.php?Type=Flash' ;
 430              $oFCKeditor->Config['SourcePopup']='false';
 431  
 432              $oFCKeditor->Config["CustomConfigurationsPath"] = $this->cms->config["root_url"].'/modules/FCKeditorX/FCKeditorXcfg.js.php'  ;
 433  
 434              $html_out .= $oFCKeditor->CreateHtml();
 435          }
 436          else{
 437              $html_out .= '<textarea name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" id="'.$name.'">';
 438              $html_out .= $content;
 439              $html_out .= '</textarea>';
 440          }
 441  
 442          return $html_out;
 443  
 444      }
 445  
 446  	function WYSIWYGPageFormSubmit()
 447      {
 448          return 'var listitems=document.getElementsByTagName(\'iframe\');
 449                  for (i=0; i<listitems.length; i++) {
 450                      if (listitems[i].id.endsWith(\'___Frame\')) {
 451                          var newid = listitems[i].id.replace(\'___Frame\',\'\');
 452                          if ($(newid) != null) {
 453                              var oEditor = FCKeditorAPI.GetInstance(newid);
 454                              if (oEditor != null)
 455                              {
 456                                  $(newid).value = oEditor.GetXHTML();
 457                              }
 458                          }
 459                      }
 460                  }';
 461      }
 462  
 463  	function DoAction($action, $id, $params, $return_id=-1)
 464      {
 465  
 466          if ( strcmp('default', $action) == 0  )
 467          return $this->WYSIWYGTextarea('','','','','','', $params);
 468  
 469          $who_act = 0;
 470          if ($this->CheckPermission('Modify FCKeditorX')){
 471              switch ($action){
 472                  case 'edit_setting':
 473                      $this->SavePref($params);
 474                      break;
 475                  case 'edit_styles':
 476                      $this->UpdateStyle($params);
 477                      $who_act = 1;
 478                      break;
 479                  case 'edit_toolbar':
 480                      $this->UpdateToolbar($params);
 481                      $who_act = 2;
 482                      break;
 483                  case 'defaultadmin':{
 484                      // only let people access module preferences if they have permission

 485                      break;
 486                  }
 487              }
 488              $this->DisplayAdminPanel($id, $params, $return_id, '', $who_act);
 489          }
 490          else{
 491              $this->DisplayErrorPage($id, $params, $return_id,
 492              $this->Lang('accessdenied'));
 493          }
 494  
 495      }
 496  
 497  
 498  
 499      /*---------------------------------------------------------

 500      DisplayErrorPage($id, $params, $return_id, $message)

 501      NOT PART OF THE MODULE API

 502      ---------------------------------------------------------*/
 503  	function DisplayErrorPage($id, &$params, $returnid, $message='')
 504      {
 505          $this->smarty->assign('title_error', $this->Lang('error'));
 506          if ($message != '')
 507          {
 508              $this->smarty->assign_by_ref('message', $message);
 509          }
 510  
 511          // Display the populated template

 512          echo $this->ProcessTemplate('error.tpl');
 513      }
 514  
 515      /*---------------------------------------------------------

 516      DisplayAdminPanel($id, $params, $return_id, $message)

 517      NOT PART OF THE MODULE API

 518  

 519      It sets smarty tag values, and then calls the

 520      code necessary to render the template.

 521      ---------------------------------------------------------*/
 522  	function DisplayAdminPanel($id, &$params, $returnid, $message='', $who_act)
 523      {
 524          /////////////////////////////////////

 525          /////////////////////////////////////

 526          echo $this->StartTabHeaders();
 527          echo $this->SetTabHeader("settings",$this->Lang("settings"), ($who_act == 0)?true:false);
 528          echo $this->SetTabHeader("styles",$this->Lang("styles"), ($who_act == 1)?true:false);
 529          echo $this->SetTabHeader("toolbar",$this->Lang("toolbar_text"), ($who_act == 2)?true:false);
 530          echo $this->EndTabHeaders();
 531  
 532          echo $this->StartTabContent();
 533  
 534          echo $this->StartTab("settings");
 535          echo $this->DisplaySettings($id, $params, $returnid, $message);
 536          echo $this->EndTab();
 537  
 538          echo $this->StartTab("styles");
 539          echo $this->DisplayStyles($id, $params, $returnid, $message);
 540          echo $this->EndTab();
 541  
 542          echo $this->StartTab("toolbar");
 543          echo $this->DisplayToolbar($id, $params, $returnid, $message);
 544          echo $this->EndTab();
 545  
 546          echo $this->EndTabContent();
 547          /////////////////////////////////////

 548          /////////////////////////////////////

 549      }
 550  
 551  	function DisplayToolbar($id, &$params, $returnid, $message=''){
 552  
 553          /*global $gCms;

 554          $db =& $gCms->GetDb();

 555  

 556          $styles = $db->GetOne("SELECT data FROM ".cms_db_prefix()."module_FCKX WHERE fckx_id = 2");

 557  */
 558          $styles=$this->GetPreference("FCKConfig.CustomToolbar");
 559          $this->smarty->assign('startform', $this->CreateFormStart($id, 'edit_toolbar', $returnid));
 560          $this->smarty->assign('endform', $this->CreateFormEnd());
 561  
 562          $this->smarty->assign('toolbar_textarea', $this->CreateTextArea(false, $id, $styles, "toolbar"));
 563  
 564          $this->smarty->assign('submit', $this->CreateInputSubmit($id, "submit", $this->Lang("update")));
 565  
 566          $this->smarty->assign('title', $this->Lang("toolbar_text"));
 567  
 568          $this->smarty->assign('info4toolbars', $this->Lang('info4toolbars'));
 569  
 570          return $this->ProcessTemplate('toolbarpanel.tpl');
 571  
 572      }
 573  
 574  	function DisplayStyles($id, &$params, $returnid, $message=''){
 575  
 576          /*global $gCms;

 577          $db =& $gCms->GetDb();

 578  

 579          $styles =& $db->GetOne("SELECT data FROM ".cms_db_prefix()."module_FCKX WHERE fckx_id = 1");

 580  */
 581          $styles=$this->GetPreference("FCKConfig.Styles");
 582          $this->smarty->assign('startform', $this->CreateFormStart($id, 'edit_styles', $returnid));
 583          $this->smarty->assign('endform', $this->CreateFormEnd());
 584  
 585          $this->smarty->assign('styles_textarea', $this->CreateTextArea(false, $id, $styles, 'styles'));
 586  
 587          $this->smarty->assign('submit', $this->CreateInputSubmit($id, "submit", $this->Lang("update")));
 588  
 589          $this->smarty->assign('title', $this->Lang("styles"));
 590  
 591          $this->smarty->assign('info4styles', $this->Lang('info4styles'));
 592  
 593          return $this->ProcessTemplate('stylespanel.tpl');
 594  
 595      }
 596  
 597  	function DisplaySettings($id, &$params, $returnid, $message=''){
 598  
 599          $skin = $this->GetPreference("FCKConfig.SkinSelected");
 600          $lang = intval($this->GetPreference("FCKConfig.CMSMSLanguage"));
 601          $xhtml = intval($this->GetPreference("FCKConfig.EnableXHTML"));
 602          $importallstyles = intval($this->GetPreference("FCKConfig.ImportAllStyles"));
 603          $context = intval($this->GetPreference("FCKConfig.ContextMenu"));
 604          $toolbar = $this->GetPreference("FCKConfig.ToolbarSet");
 605          if (strcmp($toolbar , '') == 0)
 606          $toolbar  = 'default';
 607          $BgColor = $this->GetPreference("FCKConfig.BgColor");
 608          $BodyCSS = strtolower($this->GetPreference("FCKConfig.BodyCSS"));
 609          $height = intval($this->GetPreference('FCKConfig.Height'));
 610          if ($height == 0)
 611          $height = 'default';
 612          $width = $this->GetPreference('FCKConfig.Width');
 613          $unit = substr($width, -1, 1);
 614          if (strcmp("%", $unit) != 0)
 615          $unit = "px";
 616  
 617          $width = intval($this->GetPreference('FCKConfig.Width'));
 618          if ($width == 0)
 619          $width = 'default';
 620  
 621          if ((strcmp($BodyCSS , '') == 0)||(strcmp($BodyCSS , 'default') == 0))
 622          $BodyCSS  = 'text-align: left; background-color: #ffffff;';
 623  
 624          $skins_available = Array();
 625  
 626          $d = dir(dirname(__FILE__).'/FCKeditor/editor/skins');
 627  
 628          $i = 0;
 629          //FIND ALL SKIN AVAILABLE

 630          while ($entry = $d->read()) {
 631              if ($entry[0]!=".") {
 632                  if (is_dir(dirname(__FILE__).'/FCKeditor/editor/skins/'.$entry )) {
 633                      $skins_available[trim($entry)] = trim($entry);
 634                      $i++;
 635                  }
 636              }
 637          }
 638          $d->close();
 639  
 640  
 641          $this->smarty->assign('startform', $this->CreateFormStart($id, 'edit_setting', $returnid));
 642          $this->smarty->assign('endform', $this->CreateFormEnd());
 643  
 644          $this->smarty->assign('logoimg', '<img src="'.$this->cms->config["root_url"].'/modules/FCKeditorX/FCKeditor/editor/dialog/fck_about/logo_fckeditor.gif" width="236" height="41">');
 645  
 646          $this->smarty->assign('skin_text', $this->Lang('skin_text'));
 647  
 648          $this->smarty->assign('skin_input', $this->CreateInputDropdown($id, "skin", $skins_available, -1, $skin, ''));
 649  
 650          $this->smarty->assign('lang_text', $this->Lang('lang_text'));
 651          $val_lang = -1;
 652          if ($lang == 1)
 653          $val_lang = $lang;
 654          $this->smarty->assign('lang_input', $this->CreateInputCheckbox($id, "use_cms_lang", $lang, $val_lang, ''));
 655  
 656          $this->smarty->assign('toolbar_text', $this->Lang('toolbar_text'));
 657          $this->smarty->assign('toolbar_input', $this->CreateInputText($id, "toolbar", $toolbar));
 658          $this->smarty->assign('toolbar_help', $this->Lang('toolbar_help'));
 659  
 660          $this->smarty->assign('bg_text', $this->Lang('bg_text'));
 661          $this->smarty->assign('bg_input', $this->CreateInputText($id, "BgColor", $BgColor));
 662          $this->smarty->assign('bg_help', $this->Lang('bg_help'));
 663  
 664          $this->smarty->assign('bd_css_text', $this->Lang('bg_css_text'));
 665          $this->smarty->assign('bd_css_input', $this->CreateInputText($id, "BodyCSS", $BodyCSS, '60'));
 666          $this->smarty->assign('bd_css_help', $this->Lang('bg_css_help'));
 667  
 668          $this->smarty->assign('importallstyles_text', $this->Lang('importallstyles_text'));
 669          $this->smarty->assign('importallstyles_input', $this->CreateInputCheckbox($id, "importallstyles", "1", $importallstyles));
 670          $this->smarty->assign('importallstyles_warning', $this->Lang('importallstyles_warning'));
 671  
 672          $this->smarty->assign('xhtml_text', $this->Lang('xhtml_text'));
 673          $val_xhtml = -1;
 674          if ($xhtml == 1) $val_xhtml = $xhtml;
 675          $this->smarty->assign('xhtml_input', $this->CreateInputCheckbox($id, "xhtml", $xhtml, $val_xhtml, ''));
 676  
 677          $this->smarty->assign('context_text', $this->Lang('context_text'));
 678          $val_context = -1;
 679          if ($context == 1)
 680          $val_context = $context;
 681          $this->smarty->assign('context_input', $this->CreateInputCheckbox($id, "context", $context, $val_context, ''));
 682          $this->smarty->assign('context_help', $this->Lang('context_help'));
 683  
 684          $this->smarty->assign('height_text', $this->Lang('height_text'));
 685          $this->smarty->assign('height_input', $this->CreateInputText($id, "height", $height));
 686          $this->smarty->assign('height_help', $this->Lang('height_help'));
 687  
 688          $this->smarty->assign('width_text', $this->Lang('width_text'));
 689          $this->smarty->assign('width_input', $this->CreateInputText($id, "width", $width));
 690          $this->smarty->assign('width_help', $this->Lang('width_help'));
 691  
 692          $this->smarty->assign('unit_input', $this->CreateInputDropdown($id, "unit", array("px" => "px", "%" => "%"), -1, $unit, ''));
 693  
 694          $this->smarty->assign('submit', $this->CreateInputSubmit($id, "submit", $this->Lang("update")));
 695          $this->smarty->assign('testarea', $this->CreateTextArea(true,$id,"This is a testing area","testarea",'','','','','60','8','FCKeditorX'));
 696  
 697          // Display the populated template

 698          return $this->ProcessTemplate('settingpanel.tpl');
 699      }
 700  
 701  	function UpdateToolbar(&$params){
 702          $this->SetPreference('FCKConfig.CustomToolbar',$params["toolbar"]);
 703          $this->ShowMessage($this->Lang("toolbar_updated"));
 704  
 705      }
 706  
 707  	function UpdateStyle(&$params){
 708          $this->SetPreference('FCKConfig.Styles',$params["styles"]);
 709          $this->ShowMessage($this->Lang("styles_updated"));
 710      }
 711  
 712   function SavePref(&$params){
 713  
 714          if (isset($params['skin']))
 715          $this->SetPreference('FCKConfig.SkinSelected', $params['skin']);
 716  
 717          if (isset($params['toolbar']))
 718          $this->SetPreference('FCKConfig.ToolbarSet', $params['toolbar']);
 719  
 720          if (isset($params['BgColor']))
 721          $this->SetPreference('FCKConfig.BgColor', $params['BgColor']);
 722  
 723          if (isset($params['BodyCSS']))
 724          $this->SetPreference('FCKConfig.BodyCSS', $params['BodyCSS']);
 725  
 726          if (isset($params['height']))
 727          $this->SetPreference('FCKConfig.Height', intval($params['height']));
 728  
 729          if (isset($params['width'])){
 730              $width  = $params['width'];
 731              $width .= $params['unit'];
 732              $this->SetPreference('FCKConfig.Width', $width);
 733          }
 734  
 735  
 736          if (isset($params['use_cms_lang']))
 737          $this->SetPreference('FCKConfig.CMSMSLanguage', 1);
 738          else
 739          $this->SetPreference('FCKConfig.CMSMSLanguage', 0);
 740  
 741          if (isset($params['importallstyles']))
 742          $this->SetPreference('FCKConfig.ImportAllStyles', 1);
 743          else
 744          $this->SetPreference('FCKConfig.ImportAllStyles', 0);
 745  
 746          if (isset($params['xhtml']))
 747          $this->SetPreference('FCKConfig.EnableXHTML', 1);
 748          else
 749          $this->SetPreference('FCKConfig.EnableXHTML', 0);
 750  
 751          if (isset($params['context']))
 752          $this->SetPreference('FCKConfig.ContextMenu', 1);
 753          else
 754          $this->SetPreference('FCKConfig.ContextMenu', 0);
 755  
 756  
 757          $this->ShowMessage($this->Lang("setting_updated"));
 758  
 759      }
 760  
 761  }
 762  
 763  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7