Cheetah
ChWsbEditor.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbEditorQuery');
9 
14 define('CH_EDITOR_STANDARD', 1);
15 
20 define('CH_EDITOR_FULL', 2);
21 
26 define('CH_EDITOR_MINI', 3);
27 
68 {
69  protected $_sObject;
70  protected $_aObject;
71 
76  public function __construct($aObject)
77  {
78  $this->_sObject = $aObject['object'];
79  $this->_aObject = $aObject;
80  }
81 
87  static public function getObjectInstance($sObject = false)
88  {
89  if (!$sObject)
90  $sObject = getParam('sys_editor_default');
91 
92  if (isset($GLOBALS['chWsbClasses']['ChWsbEditor!'.$sObject]))
93  return $GLOBALS['chWsbClasses']['ChWsbEditor!'.$sObject];
94 
95  $aObject = ChWsbEditorQuery::getEditorObject($sObject);
96  if (!$aObject || !is_array($aObject))
97  return false;
98 
99  if (empty($aObject['override_class_name']))
100  return false;
101 
102  $sClass = $aObject['override_class_name'];
103  if (!empty($aObject['override_class_file']))
104  require_once(CH_DIRECTORY_PATH_ROOT . $aObject['override_class_file']);
105  else
106  ch_import($sClass);
107 
108  $o = new $sClass($aObject);
109 
110  return ($GLOBALS['chWsbClasses']['ChWsbEditor!'.$sObject] = $o);
111  }
112 
116  public function getObjectName ()
117  {
118  return $this->_sObject;
119  }
120 
124  public function getWidth ($iViewMode)
125  {
126  // override this function in particular editor class
127  }
128 
135  public function attachEditor ($sSelector, $iViewMode, $bDynamicMode = false)
136  {
137  // override this function in particular editor class
138  }
139 
143  protected function _addJsCss ($bDynamicMode = false)
144  {
145  // override this function in particular editor class
146  }
147 
154  protected function _replaceMarkers ($s, $a)
155  {
156  if (empty($s) || empty($a) || !is_array($a))
157  return $s;
158 
159  foreach ($a as $sKey => $sValue)
160  $s = str_replace('{' . $sKey . '}', $sValue, $s);
161 
162  return $s;
163  }
164 
165 }
ChWsbEditor\__construct
__construct($aObject)
Definition: ChWsbEditor.php:76
ChWsbEditor\attachEditor
attachEditor($sSelector, $iViewMode, $bDynamicMode=false)
Definition: ChWsbEditor.php:135
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
php
ChWsbEditor\getWidth
getWidth($iViewMode)
Definition: ChWsbEditor.php:124
ChWsbEditor\getObjectName
getObjectName()
Definition: ChWsbEditor.php:116
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
ChWsbEditor\getObjectInstance
static getObjectInstance($sObject=false)
Definition: ChWsbEditor.php:87
ChWsbEditor
Definition: ChWsbEditor.php:68
$s
$s
Definition: embed.php:13
ChWsbEditorQuery\getEditorObject
static getEditorObject($sObject)
Definition: ChWsbEditorQuery.php:24
ChWsbEditor\$_aObject
$_aObject
Definition: ChWsbEditor.php:70
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$o
$o
Definition: cmd.php:193
ChWsbEditor\_replaceMarkers
_replaceMarkers($s, $a)
Definition: ChWsbEditor.php:154
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChWsbEditor\$_sObject
$_sObject
Definition: ChWsbEditor.php:69
ChWsbEditor\_addJsCss
_addJsCss($bDynamicMode=false)
Definition: ChWsbEditor.php:143
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10