Changeset 2679:bae19d3adbc4 for inc
- Timestamp:
- 03/05/14 21:04:23 (11 years ago)
- Branch:
- default
- Location:
- inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.admincombos.php
r2566 r2679 51 51 */ 52 52 public static function getPostStatusesCombo() { 53 $status_combo = 53 $status_combo = array(); 54 54 foreach (self::$core->blog->getAllPostStatus() as $k => $v) { 55 55 $status_combo[$v] = (string) $k; … … 141 141 142 142 /** 143 Returns a combo containing all available formaters in admin 144 145 @return <b>array</b> the combo box (form::combo -compatible format) 146 */ 147 public static function getFormatersCombo() { 148 foreach (self::$core->getFormaters() as $v) { 149 $formaters_combo[$v] = $v; 150 } 143 Returns a combo containing all available editors in admin 144 145 @return <b>array</b> the combo box (form::combo -compatible format) 146 */ 147 public static function getEditorsCombo() 148 { 149 $editors_combo = array(); 150 151 foreach (self::$core->getEditors() as $v) { 152 $editors_combo[$v] = $v; 153 } 154 155 return $editors_combo; 156 } 157 158 /** 159 Returns a combo containing all available formaters by editor in admin 160 161 @param editor_id <b>string</b> Editor id (dcLegacyEditor, dcCKEditor, ...) 162 @return <b>array</b> the combo box (form::combo -compatible format) 163 */ 164 public static function getFormatersCombo($editor_id='') 165 { 166 $formaters_combo = array(); 167 168 if (!empty($editor_id)) { 169 foreach (self::$core->getFormaters($editor_id) as $formater) { 170 $formaters_combo[$formater] = $formater; 171 } 172 } else { 173 foreach (self::$core->getFormaters() as $editor => $formaters) { 174 foreach ($formaters as $formater) { 175 $formaters_combo[$editor][$formater] = $formater; 176 } 177 } 178 } 179 151 180 return $formaters_combo; 152 181 } -
inc/core/class.dc.core.php
r2641 r2679 101 101 102 102 $this->log = new dcLog($this); 103 104 $this->addFormater('xhtml', create_function('$s','return $s;'));105 $this->addFormater('wiki', array($this,'wikiTransform'));106 103 } 107 104 … … 211 208 //@} 212 209 213 214 210 /// @name Text Formatters methods 215 211 //@{ … … 219 215 argument: the string to transform. It returns the transformed string. 220 216 217 @param editor_id <b>string</b> Editor id (dcLegacyEditor, dcCKEditor, ...) 218 @param name <b>string</b> Formater name 219 @param func <b>callback</b> Function to use, must be a valid and callable callback 220 */ 221 public function addEditorFormater($editor_id,$name,$func) 222 { 223 if (is_callable($func)) { 224 $this->formaters[$editor_id][$name] = $func; 225 } 226 } 227 228 /// @name Text Formatters methods 229 //@{ 230 /** 231 Adds a new text formater which will call the function <var>$func</var> to 232 transform text. The function must be a valid callback and takes one 233 argument: the string to transform. It returns the transformed string. 234 221 235 @param name <b>string</b> Formater name 222 236 @param func <b>callback</b> Function to use, must be a valid and callable callback … … 224 238 public function addFormater($name,$func) 225 239 { 226 if (is_callable($func)) { 227 $this->formaters[$name] = $func; 228 } 229 } 230 231 /** 232 Returns formaters list. 233 240 $this->addEditorFormater('dcLegacyEditor',$name,$func); 241 } 242 243 /** 244 Returns editors list 245 246 @return <b>array</b> An array of editors values. 247 */ 248 public function getEditors() 249 { 250 $editors = array(); 251 252 foreach (array_keys($this->formaters) as $editor_id) { 253 $editors[$editor_id] = $this->plugins->moduleInfo($editor_id,'name'); 254 } 255 256 return $editors; 257 } 258 259 /** 260 Returns formaters list by editor 261 262 @param editor_id <b>string</b> Editor id (dcLegacyEditor, dcCKEditor, ...) 234 263 @return <b>array</b> An array of formaters names in values. 235 264 */ 236 public function getFormaters() 237 { 238 return array_keys($this->formaters); 265 public function getFormaters($editor_id='') 266 { 267 $formaters_list = array(); 268 269 if (!empty($editor_id) && isset($this->formaters[$editor_id])) { 270 $formaters_list = array_keys($this->formaters[$editor_id]); 271 } else { 272 foreach ($this->formaters as $editor => $formaters) { 273 $formaters_list[$editor] = array_keys($formaters); 274 } 275 } 276 277 return $formaters_list; 239 278 } 240 279 … … 243 282 transformed using that formater. 244 283 284 @param editor_id <b>string</b> Editor id (dcLegacyEditor, dcCKEditor, ...) 245 285 @param name <b>string</b> Formater name 246 286 @param str <b>string</b> String to transform 247 287 @return <b>string</b> String transformed 248 288 */ 289 public function callEditorFormater($editor_id,$name,$str) 290 { 291 if (isset($this->formaters[$editor_id]) && isset($this->formaters[$editor_id][$name])) { 292 return call_user_func($this->formaters[$editor_id][$name],$str); 293 } 294 295 return $str; 296 } 297 //@} 298 299 /** 300 If <var>$name</var> is a valid formater, it returns <var>$str</var> 301 transformed using that formater. 302 303 @param name <b>string</b> Formater name 304 @param str <b>string</b> String to transform 305 @return <b>string</b> String transformed 306 */ 249 307 public function callFormater($name,$str) 250 308 { 251 if (isset($this->formaters[$name])) { 252 return call_user_func($this->formaters[$name],$str); 253 } 254 255 return $str; 309 return $this->callEditorFormater('dcLegacyEditor',$name,$str); 256 310 } 257 311 //@} … … 648 702 - [url] => Blog URL 649 703 - [p] 650 704 - [permission] => true 651 705 - ... 652 706 … … 816 870 - [super] => (true|false) super admin 817 871 - [p] 818 872 - [permission] => true 819 873 - ... 820 874 … … 1484 1538 /** 1485 1539 Return elapsed time since script has been started 1486 @param 1487 1488 @return <b>float</b> 1540 @param $mtime <b>float</b> timestamp (microtime format) to evaluate delta from 1541 current time is taken if null 1542 @return <b>float</b> elapsed time 1489 1543 */ 1490 1544 public function getElapsedTime ($mtime=null) {
Note: See TracChangeset
for help on using the changeset viewer.