Changeset 2679:bae19d3adbc4
- Timestamp:
- 03/05/14 21:04:23 (12 years ago)
- Branch:
- default
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/js/_preferences.js
r2566 r2679 20 20 return true; 21 21 }); 22 23 // choose format depending of editor based on formats_by_editor defined in preferences.php 24 if (formats_by_editor !== undefined) { 25 var _editors = $.parseJSON(formats_by_editor); 26 27 $('#user_editor').change(function() { 28 if (!_editors[$(this).val()]) {return;} 29 30 $('#user_post_format option').remove(); 31 for (var format in _editors[$(this).val()]) { 32 $('#user_post_format').append('<option value="'+format+'">'+format+'</option>'); 33 } 34 }); 35 } 22 36 }); -
admin/post.php
r2666 r2679 19 19 $post_dt = ''; 20 20 $post_format = $core->auth->getOption('post_format'); 21 $editor = $core->auth->getOption('editor'); 21 22 $post_password = ''; 22 23 $post_url = ''; … … 60 61 61 62 # Formaters combo 62 $formaters_combo = dcAdminCombos::getFormatersCombo( );63 $formaters_combo = dcAdminCombos::getFormatersCombo($editor); 63 64 64 65 # Languages combo … … 378 379 dcPage::jsMetaEditor(). 379 380 dcPage::jsLoad('js/_post.js'). 380 $core->callBehavior('adminPostEditor' ).381 $core->callBehavior('adminPostEditor',$editor). 381 382 dcPage::jsConfirmClose('entry-form','comment-form'). 382 383 # --BEHAVIOR-- adminPostHeaders -
admin/preferences.php
r2567 r2679 27 27 28 28 $user_options = $core->auth->getOptions(); 29 if (empty($user_options['editor'])) { 30 $user_options['editor'] = ''; 31 } 29 32 30 33 $core->auth->user_prefs->addWorkspace('dashboard'); … … 58 61 } 59 62 63 # Editors combo 64 $editors_combo = dcAdminCombos::getEditorsCombo(); 65 $editors = array_keys($editors_combo); 66 60 67 # Formaters combo 61 68 $formaters_combo = dcAdminCombos::getFormatersCombo(); 69 70 if (!empty($user_options['editor'])) { 71 $formaters_combo_editor = $formaters_combo[$user_options['editor']]; 72 } elseif (count($editors)!=0) { 73 $formaters_combo_editor = $formaters_combo[$editors[0]]; 74 } else { 75 $formaters_combo = array(); 76 } 62 77 63 78 $status_combo = dcAdminCombos::getPostStatusescombo(); … … 155 170 } 156 171 $user_options['post_format'] = $_POST['user_post_format']; 172 $user_options['editor'] = $_POST['user_editor']; 157 173 $user_options['enable_wysiwyg'] = !empty($_POST['user_wysiwyg']); 158 174 … … 317 333 sprintf(__('Password strength: %s'),__('very strong'))."']});\n". 318 334 "});\n". 335 'var formats_by_editor = \''.json_encode($formaters_combo).'\';'. 319 336 "\n//]]>\n". 320 337 "</script>\n". … … 455 472 '<h4>'.__('Edition').'</h4>'. 456 473 474 '<p class="field"><label for="user_editor">'.__('Preferred editor:').'</label>'. 475 form::combo('user_editor',$editors_combo,$user_options['editor']).'</p>'. 476 457 477 '<p class="field"><label for="user_post_format">'.__('Preferred format:').'</label>'. 458 form::combo('user_post_format',$formaters_combo ,$user_options['post_format']).'</p>'.478 form::combo('user_post_format',$formaters_combo_editor,$user_options['post_format']).'</p>'. 459 479 460 480 '<p class="field"><label for="user_post_status">'.__('Default entry status:').'</label>'. -
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) { -
locales/fr/main.po
r2666 r2679 2030 2030 msgstr "Édition" 2031 2031 2032 msgid "Preferred editor:" 2033 msgstr "Editeur préféré :" 2034 2032 2035 msgid "Preferred format:" 2033 2036 msgstr "Format d'édition préféré :" -
plugins/dcLegacyEditor/_admin.php
r2614 r2679 23 23 24 24 if ($self_ns->active) { 25 $core->addBehavior('adminPostEditor',array('dcLegacyEditorBehaviors','adminPostEditor')); 26 $core->addBehavior('adminPopupMedia',array('dcLegacyEditorBehaviors','adminPopupMedia')); 27 $core->addBehavior('adminPopupLink',array('dcLegacyEditorBehaviors','adminPopupLink')); 28 $core->addBehavior('adminPopupPosts',array('dcLegacyEditorBehaviors','adminPopupPosts')); 25 $wiki2xhtml = new wiki2xhtml(); 26 27 $core->addEditorFormater('dcLegacyEditor','xhtml',create_function('$s','return $s;')); 28 $core->addEditorFormater('dcLegacyEditor','wiki',array($wiki2xhtml,'transform')); 29 30 $core->addBehavior('adminPostEditor',array('dcLegacyEditorBehaviors','adminPostEditor')); 31 $core->addBehavior('adminPopupMedia',array('dcLegacyEditorBehaviors','adminPopupMedia')); 32 $core->addBehavior('adminPopupLink',array('dcLegacyEditorBehaviors','adminPopupLink')); 33 $core->addBehavior('adminPopupPosts',array('dcLegacyEditorBehaviors','adminPopupPosts')); 29 34 } -
plugins/dcLegacyEditor/inc/dc.legacy.editor.behaviors.php
r2614 r2679 15 15 protected static $p_url = 'index.php?pf=dcLegacyEditor'; 16 16 17 public static function adminPostEditor() { 17 public static function adminPostEditor($editor) { 18 if ($editor!='dcLegacyEditor') {return;} 19 18 20 return 19 21 self::jsToolBar().
Note: See TracChangeset
for help on using the changeset viewer.