Dotclear

Changeset 1699:5b68157bf85e


Ignore:
Timestamp:
09/03/13 14:15:53 (11 years ago)
Author:
Dsls
Branch:
default
Children:
1703:512d631f31bd, 1714:28737e5f6607, 1896:a514b85f3261
Message:

Turned cookies into user_prefs for sections folding/unfolding, closes #1573

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • admin/index.php

    r1698 r1699  
    6363     $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean'); 
    6464} 
     65 
     66// Handle folded/unfolded sections in admin from user preferences 
     67$ws = $core->auth->user_prefs->addWorkspace('toggles'); 
     68if (!$core->auth->user_prefs->toggles->prefExists('unfolded_sections')) { 
     69     $core->auth->user_prefs->toggles->put('unfolded_sections','','string','Folded sections in admin',null,true); 
     70} 
     71 
    6572 
    6673# Dashboard icons 
  • admin/js/_index.js

    r1638 r1699  
    7575     $('#quick h3').toggleWithLegend($('#quick').children().not('h3'),{ 
    7676          legend_click: true, 
    77           cookie: 'dcx_quick_entry' 
     77          user_pref: 'dcx_quick_entry' 
    7878     }); 
    7979}); 
  • admin/js/_post.js

    r1638 r1699  
    120120          // Hide some fields 
    121121          $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ 
    122                cookie: 'dcx_post_notes', 
     122               user_pref: 'dcx_post_notes', 
    123123               legend_click:true, 
    124124               hide: $('#post_notes').val() == '' 
     
    129129          }); 
    130130          $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{ 
    131                cookie: 'dcx_post_lang', 
     131               user_pref: 'dcx_post_lang', 
    132132               legend_click: true 
    133133          }); 
    134134          $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{ 
    135                cookie: 'dcx_post_password', 
     135               user_pref: 'dcx_post_password', 
    136136               legend_click: true, 
    137137               hide: $('#post_password').val() == '' 
    138138          }); 
    139139          $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{ 
    140                cookie: 'dcx_post_status', 
     140               user_pref: 'dcx_post_status', 
    141141               legend_click: true 
    142142          }); 
    143143          $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{ 
    144                cookie: 'dcx_post_dt', 
     144               user_pref: 'dcx_post_dt', 
    145145               legend_click: true 
    146146          }); 
    147147          $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{ 
    148                cookie: 'dcx_post_format', 
     148               user_pref: 'dcx_post_format', 
    149149               legend_click: true 
    150150          }); 
    151151          $('#cat_id').parent().children('label').toggleWithLegend($('#cat_id'),{ 
    152                cookie: 'cat_id', 
     152               user_pref: 'cat_id', 
    153153               legend_click: true 
    154154          }); 
    155155          $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{ 
    156                cookie: 'post_url', 
     156               user_pref: 'post_url', 
    157157               legend_click: true 
    158158          }); 
    159159          // We load toolbar on excerpt only when it's ready 
    160160          $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ 
    161                cookie: 'dcx_post_excerpt', 
     161               user_pref: 'dcx_post_excerpt', 
    162162               legend_click: true, 
    163163               hide: $('#post_excerpt').val() == '' 
  • admin/js/common.js

    r1635 r1699  
    6363          img_off_src: dotclear.img_minus_src, 
    6464          img_off_alt: dotclear.img_minus_alt, 
     65          unfolded_sections: dotclear.unfolded_sections, 
    6566          hide: true, 
    6667          speed: 0, 
    6768          legend_click: false, 
    6869          fn: false, // A function called on first display, 
    69           cookie: false, 
    70           reverse_cookie: false // Reverse cookie behavior 
     70          user_pref: false, 
     71          reverse_user_pref: false, // Reverse cookie behavior 
     72          user_pref:false, 
     73          reverse_user_pref: false 
    7174     }; 
    7275     var p = jQuery.extend(defaults,s); 
     
    7881          p.hide = p.reverse_cookie; 
    7982     } 
    80  
     83      
     84     var set_user_pref = p.hide ^ p.reverse_user_pref; 
     85     if (p.user_pref && (p.user_pref in p.unfolded_sections)) { 
     86          p.hide = p.reverse_user_pref; 
     87     } 
    8188     var toggle = function(i,speed) { 
    8289          speed = speed || 0; 
     
    102109               } 
    103110          } 
    104  
    105111          p.hide = !p.hide; 
    106112     }; 
     
    125131          } 
    126132          $(ctarget).click(function() { 
     133               if (p.user_pref && set_user_pref) { 
     134                    if (p.hide ^ p.reverse_user_pref) { 
     135                         jQuery.post('services.php',  
     136                              {'f':'setSectionFold','section':p.user_pref,'value':1,xd_check: dotclear.nonce}, 
     137                              function(data) {}); 
     138                    } else { 
     139                         jQuery.post('services.php',  
     140                              {'f':'setSectionFold','section':p.user_pref,'value':0,xd_check: dotclear.nonce}, 
     141                              function(data) {}); 
     142                    } 
     143                    jQuery.cookie(p.user_pref,'',{expires: -1}); 
     144               } 
    127145               toggle(i,p.speed); 
    128146               return false; 
     
    348366     } 
    349367     $('#blog-menu h3:first').toggleWithLegend($('#blog-menu ul:first'), 
    350           $.extend({cookie:'dc_blog_menu'},menu_settings) 
     368          $.extend({user_pref:'dc_blog_menu'},menu_settings) 
    351369     ); 
    352370     $('#system-menu h3:first').toggleWithLegend($('#system-menu ul:first'), 
    353           $.extend({cookie:'dc_system_menu'},menu_settings) 
     371          $.extend({user_pref:'dc_system_menu'},menu_settings) 
    354372     ); 
    355373     $('#plugins-menu h3:first').toggleWithLegend($('#plugins-menu ul:first'), 
    356           $.extend({cookie:'dc_plugins_menu'},menu_settings) 
     374          $.extend({user_pref:'dc_plugins_menu'},menu_settings) 
    357375     ); 
    358376     $('#favorites-menu h3:first').toggleWithLegend($('#favorites-menu ul:first'), 
    359           $.extend({cookie:'dc_favorites_menu',hide:false,reverse_cookie:true},menu_settings) 
     377          $.extend({user_pref:'dc_favorites_menu',hide:false,reverse_user_pref:true},menu_settings) 
    360378     ); 
    361379 
  • admin/services.php

    r1538 r1699  
    2626$core->rest->addFunction('setPostMeta',array('dcRestMethods','setPostMeta')); 
    2727$core->rest->addFunction('searchMeta',array('dcRestMethods','searchMeta')); 
     28$core->rest->addFunction('setSectionFold',array('dcRestMethods','setSectionFold')); 
    2829 
    2930$core->rest->serve(); 
     
    412413          return $rsp; 
    413414     } 
     415      
     416     public static function setSectionFold($core,$get,$post) 
     417     { 
     418          if (empty($post['section'])) { 
     419               throw new Exception('No section name'); 
     420          } 
     421          if ($core->auth->user_prefs->toggles === null) { 
     422               $core->auth->user_prefs->addWorkspace('toggles'); 
     423          } 
     424          $section = $post['section']; 
     425          $status = isset($post['value']) && ($post['value'] != 0); 
     426          if ($core->auth->user_prefs->toggles->prefExists('unfolded_sections')) { 
     427               $toggles = explode(',',trim($core->auth->user_prefs->toggles->unfolded_sections)); 
     428          } else { 
     429               $toggles = array(); 
     430          } 
     431          $k = array_search($section,$toggles); 
     432          if ($status) { // true == Fold section ==> remove it from unfolded list 
     433               if ($k !== false) { 
     434                    unset($toggles[$k]); 
     435               }  
     436          } else { // false == unfold section ==> add it to unfolded list 
     437               if ($k === false) { 
     438                    $toggles[]=$section; 
     439               };  
     440          } 
     441          $core->auth->user_prefs->toggles->put('unfolded_sections',join(',',$toggles)); 
     442          return true; 
     443     } 
     444           
     445      
    414446} 
    415447?> 
  • inc/admin/lib.dc.page.php

    r1686 r1699  
    114114          echo 
    115115          self::jsCommon(). 
     116          self::jsToggles(). 
    116117          $head; 
    117118 
     
    253254          echo 
    254255          self::jsCommon(). 
     256          self::jsToggles(). 
    255257          $head; 
    256258 
     
    444446     } 
    445447 
     448     public static function jsToggles() 
     449     { 
     450          if($GLOBALS['core']->auth->user_prefs->toggles) { 
     451               $unfolded_sections = explode(',',$GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections); 
     452               foreach ($unfolded_sections as $k=>&$v) { 
     453                    if ($v == '') { 
     454                         unset($unfolded_sections[$k]); 
     455                    } else { 
     456                         $v = "'".html::escapeJS($v)."':true"; 
     457                    } 
     458               } 
     459          } else { 
     460               $unfolded_sections=array(); 
     461          } 
     462          return '<script type="text/javascript">'."\n". 
     463                         "//<![CDATA[\n". 
     464                         'dotclear.unfolded_sections = {'.join(",",$unfolded_sections)."};\n". 
     465                         "\n//]]>\n". 
     466                    "</script>\n"; 
     467     } 
     468      
    446469     public static function jsCommon() 
    447470     { 
     
    544567          self::jsVar('dotclear.msg.load_enhanced_uploader', 
    545568               __('Loading enhanced uploader, please wait.')). 
    546           "\n//]]>\n". 
     569               "\n//]]>\n". 
    547570          "</script>\n"; 
    548571     } 
  • plugins/attachments/js/post.js

    r1606 r1699  
    11$(function() { 
    22     $('h5.s-attachments').toggleWithLegend($('.s-attachments').not('h5'),{ 
    3           cookie: 'dcx_attachments', 
     3          user_pref: 'dcx_attachments', 
    44          legend_click: true 
    55     }); 
  • plugins/pings/post.js

    r1606 r1699  
    1313          } 
    1414          $('h5.ping-services').toggleWithLegend($('p.ping-services'),{ 
    15                cookie: 'dcx_ping_services', 
     15               user_pref: 'dcx_ping_services', 
    1616               legend_click: true 
    1717          }); 
  • plugins/tags/js/post.js

    r1606 r1699  
    6060 
    6161     $('h5 .s-tags').toggleWithLegend($('.s-tags').not('label'),{ 
    62           cookie: 'post_tags', 
     62          user_pref: 'post_tags', 
    6363          legend_clik: true 
    6464     }); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map