<?php


class CKEditor{
  
  
  static function load(){
  global $MAIN_PAGE;
    $MAIN_PAGE -> set_js(MAIN_SOURCE_URL.'/ext/ckeditor/ckeditor.js?t=A7HG4HT121.js');
    $MAIN_PAGE -> set_js(MAIN_URL.'/source/tmpl/default/js/editor/CKEditor.js');
  }
  
  
  function __construct(){
  
  }
  
  


}
/*


include_once(MAIN_SOURCE_PATH.'/ext/ckeditor/ckeditor.php');

class ck extends CKEditor{
	private $name = false;
	private $value='';
	private $vars = array();
	private $attr = array();
 	private $toolbars = array();
  private $toolbar = 'admin_toolbar';
  	
  	function __construct(){
  	global  $MAIN_USER;
  		//include(MAIN_SOURCE_PATH."/ext/ckeditor/ckeditor.php") ;
  		
  		
  			//	набор стандартных панелей
  		$this -> toolbars['admin_toolbar'] = " [
	['Source','-','Preview'],
	['Cut','Copy','Paste','PasteText','PasteWord'],
	['Undo','Redo','-','Replace','-','SelectAll','RemoveFormat'],
	['FitWindow','-','About'],
	
	['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
	['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],
	['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
	['Link','Unlink','Anchor'],
	['Image','Flash','Rule','Smiley','SpecialChar'],

	['Style','FontFormat','FontName','FontSize',],
	
	
]";
			 
	 $this -> toolbars['basic_toolbar'] =$this -> toolbars['user_toolbar'] = "[
	['Preview','FitWindow'],
	['Cut','Copy','Paste','PasteWord','Undo','Redo'],
	['Image','Link','Unlink'],
	['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
	['Bold','Italic','Underline','StrikeThrough',],
	['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],
]";
	   
	 $this -> toolbars['design_toolbar']   ="[
	['Preview','FitWindow'],
	['Cut','Copy','Paste','PasteWord','Undo','Redo'],
	['Link','Unlink'],
	['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
	['Bold','Italic','Underline','StrikeThrough',],
	['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],
]";
	      	//	администратору нужно дать расширенный набор функций редактора
		$c = $MAIN_USER -> is_admin() ? 'admin_toolbar' : 'user_toolbar';
		$this -> set_toolbar($c);
		
		
			//	некоторые стандартные переенные
		$this -> vars['AutoDetectLanguage'] = false;
  		$this -> vars['DefaultLanguage'] = 'ru';
  		$this -> vars['theme'] = 'default';
  		$this -> vars['skin'] = 'v2';

  		$this -> vars['filebrowserImageUploadUrl'] = '/?p_name=admin_images&act=editor_upload';
	 	$this -> vars['removePlugins'] = 'elementspath';
	 	$this -> vars['entities'] = false;
	 	
			//	стандартные атрибуты
		$this -> set_attr("rows", 8);
		$this -> set_attr("cols", 60);	 
  	}
  	
  		//	устанавливаем name редактора
  	public function set_name($v){
  		if ( empty($v) ){
			  sys_error(ERROR_500,"1024: bad name '$v' for editor");
		  }
  		$this -> name = $v;
  		return true;
  	}	
  		//	устанавлиаем первончальное содержимое редактора
  	public function set_value($v){
  		$this -> value = $v;
  		return true;
  	}

		//	устанавливаем атрибуты
  	public function set_attr($k,$v){
  		if ( empty($k) ){
  			sys_error(ERROR_500,'1024: empty attr ');
  		}
  		$this -> attr[$k] = $v;
  		return true;
  	}
  	public function set_toolbar($v){
  		if ( empty($v) ){
  			sys_error(ERROR_500,'1024: empty toolbar ');
  		}
  		
  		if (  empty($this -> toolbars[$v]) ){
  			sys_error(ERROR_500,'1024: no  toolbar '.$v);
  		}
  		$this -> toolbar = $v;
  		return true;
  	}
  	
  	
  	
  	
  		//	возвращаем код редактора
  	public function show(){
	
  		if ( empty($this -> name) ){
			sys_error(ERROR_500,"1024: empty name for editor");
		}
		$this -> set_attr("id", $this -> name);
		

		$config = '"toolbar":'.$this ->toolbars[$this -> toolbar].",";
		foreach($this -> vars as $k=>$v ){
			$config.= '"'.$k.'": "'.$v.'",';
		}
		$text = str_replace('{MAIN_SOURCE_URL}',MAIN_SOURCE_URL,SCRIPT_TMPL);
		$text = str_replace('{config}','{'.$config.'}',$text);
		return  $text;
  	}
  	
  	
  	
 	 
 	 
 	 
}

 


define('SCRIPT_TMPL',
<<<SCRIPT_TMPL
<script type="text/javascript">//<![CDATA[

window.CKEDITOR_BASEPATH='{MAIN_SOURCE_URL}/ext/ckeditor/';
window.editor = {};

editor.create = function(name){
	
	if ( !document.getElementById(name) ){
		alert('empty name')
	}
	
  CKEDITOR.remove( document.getElementById(name) );	
  
  CKEDITOR.replace(name, {config});
  
 
  
  CKEDITOR.on( 'dialogDefinition', function( ev ){
    var dialogName = ev.data.name;
   
   		//CKEDITOR.dialog.dialogDefinitionObject
    var dialogDefinition = ev.data.definition;
   
    if ( dialogName == 'image' ){
    	dialogDefinition.removeContents( 'advanced' );
    	dialogDefinition.removeContents( 'Link' );
    	
    		
    	var content = dialogDefinition.getContents( 'info' );
    	content.remove( 'txtVSpace' );
    	content.remove( 'txtHSpace' );
    	content.remove( 'txtBorder' );
    	content.remove( 'txtHeight' );
    	content.remove( 'txtWidth' );
    	content.remove( 'txtAlt' );
    	
    	//alert( content.elements[0].type )
    	
    }
    
    if ( dialogName == 'link' ){
    	dialogDefinition.removeContents( 'advanced' );
   		dialogDefinition.removeContents( 'target' );
   	}
   	
    if ( dialogName == 'flash' ){
    	dialogDefinition.removeContents( 'advanced' );
    }
  }
  
  
  
  )
} 

editor.text = function(name){
	alert('функция не работает');
	if ( !document.getElementById(name) ){
		alert('empty name')
	}
	return CKEDITOR.instances.name.getData();
}

//]]></script>

<script type="text/javascript" src="{MAIN_SOURCE_URL}/ext/ckeditor/ckeditor.js?t=A7HG4HT121"></script>



SCRIPT_TMPL

);*/

?>
