Dotclear

Changeset 2403:7a1ceeb53a49


Ignore:
Timestamp:
10/06/13 00:51:02 (12 years ago)
Author:
Lepeltier kévin <kevin@…>
Branch:
widgets
Message:

widgets : Oublie

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/widgets/index.php

    r2401 r2403  
    1313 
    1414include dirname(__FILE__).'/_default_widgets.php'; 
     15 
     16# Loading navigation, extra widgets and custom widgets 
     17$widgets_nav = null; 
     18if ($core->blog->settings->widgets->widgets_nav) { 
     19     $widgets_nav = dcWidgets::load($core->blog->settings->widgets->widgets_nav); 
     20} 
     21$widgets_extra = null; 
     22if ($core->blog->settings->widgets->widgets_extra) { 
     23     $widgets_extra = dcWidgets::load($core->blog->settings->widgets->widgets_extra); 
     24} 
     25$widgets_custom = null; 
     26if ($core->blog->settings->widgets->widgets_custom) { 
     27     $widgets_custom = dcWidgets::load($core->blog->settings->widgets->widgets_custom); 
     28} 
     29 
     30$append_combo = array( 
     31     '-' => 0, 
     32     __('navigation') => 'nav', 
     33     __('extra') => 'extra', 
     34     __('custom') => 'custom' 
     35); 
     36 
     37function literalNullString($v) 
     38{ 
     39     if ($v == '') { 
     40          return '&lt;'.__('empty string').'&gt;'; 
     41     } 
     42     return $v; 
     43} 
     44 
     45# Adding widgets to sidebars 
     46if (!empty($_POST['append']) && is_array($_POST['addw'])) 
     47{ 
     48     # Filter selection 
     49     $addw = array(); 
     50     foreach ($_POST['addw'] as $k => $v) { 
     51          if (($v == 'extra' || $v == 'nav' || $v == 'custom') && $__widgets->{$k} !== null ) { 
     52               $addw[$k] = $v; 
     53          } 
     54     } 
     55           
     56     # Append 1 widget 
     57     $wid = false; 
     58     if( gettype($_POST['append']) == 'array' && count($_POST['append']) == 1 ) { 
     59          $wid = array_keys($_POST['append']); 
     60          $wid = $wid[0]; 
     61     } 
     62      
     63     # Append widgets 
     64     if (!empty($addw)) 
     65     { 
     66          if (!($widgets_nav instanceof dcWidgets)) { 
     67               $widgets_nav = new dcWidgets; 
     68          } 
     69          if (!($widgets_extra instanceof dcWidgets)) { 
     70               $widgets_extra = new dcWidgets(); 
     71          } 
     72          if (!($widgets_custom instanceof dcWidgets)) { 
     73               $widgets_custom = new dcWidgets(); 
     74          } 
     75           
     76          foreach ($addw as $k => $v) 
     77          { 
     78               if( !$wid || $wid == $k ) 
     79               { 
     80                    switch ($v) { 
     81                         case 'nav': 
     82                              $widgets_nav->append($__widgets->{$k}); 
     83                              break; 
     84                         case 'extra': 
     85                              $widgets_extra->append($__widgets->{$k}); 
     86                              break; 
     87                         case 'custom': 
     88                              $widgets_custom->append($__widgets->{$k}); 
     89                              break; 
     90                    } 
     91               } 
     92                
     93          } 
     94           
     95          try { 
     96               $core->blog->settings->addNamespace('widgets'); 
     97               $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store()); 
     98               $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store()); 
     99               $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store()); 
     100               $core->blog->triggerBlog(); 
     101               http::redirect($p_url); 
     102          } catch (Exception $e) { 
     103               $core->error->add($e->getMessage()); 
     104          } 
     105     } 
     106} 
     107 
     108# Removing ? 
     109$removing = false; 
     110if ( isset($_POST['w']) && is_array($_POST['w']) ) { 
     111     foreach ($_POST['w'] as $nsid => $nsw) { 
     112          foreach ($nsw as $i => $v) { 
     113               if (!empty($v['_rem'])) { 
     114                    $removing = true; 
     115                    break 2; 
     116               } 
     117          } 
     118     } 
     119} 
     120 
     121# Move ? 
     122$move = false; 
     123if ( isset($_POST['w']) && is_array($_POST['w']) ) { 
     124     foreach ($_POST['w'] as $nsid => $nsw) { 
     125          foreach ($nsw as $i => $v) { 
     126               if (!empty($v['down'])) { 
     127                    $oldorder = $_POST['w'][$nsid][$i]['order']; 
     128                    $neworder = $oldorder + 1; 
     129                    if( isset($_POST['w'][$nsid][$neworder]) ) { 
     130                         $_POST['w'][$nsid][$i]['order'] = $neworder; 
     131                         $_POST['w'][$nsid][$neworder]['order'] = $oldorder; 
     132                         $move = true; 
     133                    } 
     134               } 
     135               if (!empty($v['up'])) { 
     136                    $oldorder = $_POST['w'][$nsid][$i]['order']; 
     137                    $neworder = $oldorder - 1; 
     138                    if( isset($_POST['w'][$nsid][$neworder]) ) { 
     139                         $_POST['w'][$nsid][$i]['order'] = $neworder; 
     140                         $_POST['w'][$nsid][$neworder]['order'] = $oldorder; 
     141                         $move = true; 
     142                    } 
     143               } 
     144          } 
     145     } 
     146} 
     147 
     148# Update sidebars 
     149if (!empty($_POST['wup']) || $removing || $move ) 
     150{ 
     151     if (!isset($_POST['w']) || !is_array($_POST['w'])) { 
     152          $_POST['w'] = array(); 
     153     } 
     154      
     155     try 
     156     { 
     157           
     158          # Removing mark as _rem widgets 
     159          foreach ($_POST['w'] as $nsid => $nsw) { 
     160               foreach ($nsw as $i => $v) { 
     161                    if (!empty($v['_rem'])) { 
     162                         unset($_POST['w'][$nsid][$i]); 
     163                         continue; 
     164                    } 
     165               } 
     166          } 
     167           
     168          if (!isset($_POST['w']['nav'])) { 
     169               $_POST['w']['nav'] = array(); 
     170          } 
     171          if (!isset($_POST['w']['extra'])) { 
     172               $_POST['w']['extra'] = array(); 
     173          } 
     174          if (!isset($_POST['w']['custom'])) { 
     175               $_POST['w']['custom'] = array(); 
     176          } 
     177           
     178          $widgets_nav = dcWidgets::loadArray($_POST['w']['nav'],$__widgets); 
     179          $widgets_extra = dcWidgets::loadArray($_POST['w']['extra'],$__widgets); 
     180          $widgets_custom = dcWidgets::loadArray($_POST['w']['custom'],$__widgets); 
     181           
     182          $core->blog->settings->addNamespace('widgets'); 
     183          $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store()); 
     184          $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store()); 
     185          $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store()); 
     186          $core->blog->triggerBlog(); 
     187           
     188          http::redirect($p_url); 
     189     } 
     190     catch (Exception $e) 
     191     { 
     192          $core->error->add($e->getMessage()); 
     193     } 
     194} 
     195elseif (!empty($_POST['wreset'])) 
     196{ 
     197     try 
     198     { 
     199          $core->blog->settings->addNamespace('widgets'); 
     200          $core->blog->settings->widgets->put('widgets_nav',''); 
     201          $core->blog->settings->widgets->put('widgets_extra',''); 
     202          $core->blog->settings->widgets->put('widgets_custom',''); 
     203          $core->blog->triggerBlog(); 
     204           
     205          http::redirect($p_url); 
     206     } 
     207     catch (Exception $e) 
     208     { 
     209          $core->error->add($e->getMessage()); 
     210     } 
     211} 
    15212?> 
    16213<html> 
     
    42239<body> 
    43240<?php 
    44 # Loading navigation, extra widgets and custom widgets 
    45 $widgets_nav = null; 
    46 if ($core->blog->settings->widgets->widgets_nav) { 
    47      $widgets_nav = dcWidgets::load($core->blog->settings->widgets->widgets_nav); 
    48 } 
    49 $widgets_extra = null; 
    50 if ($core->blog->settings->widgets->widgets_extra) { 
    51      $widgets_extra = dcWidgets::load($core->blog->settings->widgets->widgets_extra); 
    52 } 
    53 $widgets_custom = null; 
    54 if ($core->blog->settings->widgets->widgets_custom) { 
    55      $widgets_custom = dcWidgets::load($core->blog->settings->widgets->widgets_custom); 
    56 } 
    57  
    58 $append_combo = array( 
    59      '-' => 0, 
    60      __('navigation') => 'nav', 
    61      __('extra') => 'extra', 
    62      __('custom') => 'custom' 
    63 ); 
    64  
    65 function literalNullString($v) 
    66 { 
    67      if ($v == '') { 
    68           return '&lt;'.__('empty string').'&gt;'; 
    69      } 
    70      return $v; 
    71 } 
    72  
    73 # Adding widgets to sidebars 
    74 if (!empty($_POST['append']) && is_array($_POST['addw'])) 
    75 { 
    76      # Filter selection 
    77      $addw = array(); 
    78      foreach ($_POST['addw'] as $k => $v) { 
    79           if (($v == 'extra' || $v == 'nav' || $v == 'custom') && $__widgets->{$k} !== null ) { 
    80                $addw[$k] = $v; 
    81           } 
    82      } 
    83            
    84      # Append 1 widget 
    85      $wid = false; 
    86      if( gettype($_POST['append']) == 'array' && count($_POST['append']) == 1 ) { 
    87           $wid = array_keys($_POST['append']); 
    88           $wid = $wid[0]; 
    89      } 
    90       
    91      # Append widgets 
    92      if (!empty($addw)) 
    93      { 
    94           if (!($widgets_nav instanceof dcWidgets)) { 
    95                $widgets_nav = new dcWidgets; 
    96           } 
    97           if (!($widgets_extra instanceof dcWidgets)) { 
    98                $widgets_extra = new dcWidgets(); 
    99           } 
    100           if (!($widgets_custom instanceof dcWidgets)) { 
    101                $widgets_custom = new dcWidgets(); 
    102           } 
    103            
    104           foreach ($addw as $k => $v) 
    105           { 
    106                if( !$wid || $wid == $k ) 
    107                { 
    108                     switch ($v) { 
    109                          case 'nav': 
    110                               $widgets_nav->append($__widgets->{$k}); 
    111                               break; 
    112                          case 'extra': 
    113                               $widgets_extra->append($__widgets->{$k}); 
    114                               break; 
    115                          case 'custom': 
    116                               $widgets_custom->append($__widgets->{$k}); 
    117                               break; 
    118                     } 
    119                } 
    120                 
    121           } 
    122            
    123           try { 
    124                $core->blog->settings->addNamespace('widgets'); 
    125                $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store()); 
    126                $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store()); 
    127                $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store()); 
    128                $core->blog->triggerBlog(); 
    129                http::redirect($p_url); 
    130           } catch (Exception $e) { 
    131                $core->error->add($e->getMessage()); 
    132           } 
    133      } 
    134 } 
    135  
    136 # Removing ? 
    137 $removing = false; 
    138 if ( isset($_POST['w']) && is_array($_POST['w']) ) { 
    139      foreach ($_POST['w'] as $nsid => $nsw) { 
    140           foreach ($nsw as $i => $v) { 
    141                if (!empty($v['_rem'])) { 
    142                     $removing = true; 
    143                     break 2; 
    144                } 
    145           } 
    146      } 
    147 } 
    148  
    149 # Move ? 
    150 $move = false; 
    151 if ( isset($_POST['w']) && is_array($_POST['w']) ) { 
    152      foreach ($_POST['w'] as $nsid => $nsw) { 
    153           foreach ($nsw as $i => $v) { 
    154                if (!empty($v['down'])) { 
    155                     $oldorder = $_POST['w'][$nsid][$i]['order']; 
    156                     $neworder = $oldorder + 1; 
    157                     if( isset($_POST['w'][$nsid][$neworder]) ) { 
    158                          $_POST['w'][$nsid][$i]['order'] = $neworder; 
    159                          $_POST['w'][$nsid][$neworder]['order'] = $oldorder; 
    160                          $move = true; 
    161                     } 
    162                } 
    163                if (!empty($v['up'])) { 
    164                     $oldorder = $_POST['w'][$nsid][$i]['order']; 
    165                     $neworder = $oldorder - 1; 
    166                     if( isset($_POST['w'][$nsid][$neworder]) ) { 
    167                          $_POST['w'][$nsid][$i]['order'] = $neworder; 
    168                          $_POST['w'][$nsid][$neworder]['order'] = $oldorder; 
    169                          $move = true; 
    170                     } 
    171                } 
    172           } 
    173      } 
    174 } 
    175  
    176 # Update sidebars 
    177 if (!empty($_POST['wup']) || $removing || $move ) 
    178 { 
    179      if (!isset($_POST['w']) || !is_array($_POST['w'])) { 
    180           $_POST['w'] = array(); 
    181      } 
    182       
    183      try 
    184      { 
    185            
    186           # Removing mark as _rem widgets 
    187           foreach ($_POST['w'] as $nsid => $nsw) { 
    188                foreach ($nsw as $i => $v) { 
    189                     if (!empty($v['_rem'])) { 
    190                          unset($_POST['w'][$nsid][$i]); 
    191                          continue; 
    192                     } 
    193                } 
    194           } 
    195            
    196           if (!isset($_POST['w']['nav'])) { 
    197                $_POST['w']['nav'] = array(); 
    198           } 
    199           if (!isset($_POST['w']['extra'])) { 
    200                $_POST['w']['extra'] = array(); 
    201           } 
    202           if (!isset($_POST['w']['custom'])) { 
    203                $_POST['w']['custom'] = array(); 
    204           } 
    205            
    206           $widgets_nav = dcWidgets::loadArray($_POST['w']['nav'],$__widgets); 
    207           $widgets_extra = dcWidgets::loadArray($_POST['w']['extra'],$__widgets); 
    208           $widgets_custom = dcWidgets::loadArray($_POST['w']['custom'],$__widgets); 
    209            
    210           $core->blog->settings->addNamespace('widgets'); 
    211           $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store()); 
    212           $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store()); 
    213           $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store()); 
    214           $core->blog->triggerBlog(); 
    215            
    216           http::redirect($p_url); 
    217      } 
    218      catch (Exception $e) 
    219      { 
    220           $core->error->add($e->getMessage()); 
    221      } 
    222 } 
    223 elseif (!empty($_POST['wreset'])) 
    224 { 
    225      try 
    226      { 
    227           $core->blog->settings->addNamespace('widgets'); 
    228           $core->blog->settings->widgets->put('widgets_nav',''); 
    229           $core->blog->settings->widgets->put('widgets_extra',''); 
    230           $core->blog->settings->widgets->put('widgets_custom',''); 
    231           $core->blog->triggerBlog(); 
    232            
    233           http::redirect($p_url); 
    234      } 
    235      catch (Exception $e) 
    236      { 
    237           $core->error->add($e->getMessage()); 
    238      } 
    239 } 
    240 /*?> 
    241 <html> 
    242 <head> 
    243   <title><?php echo __('Widgets'); ?></title> 
    244   <style type="text/css"> 
    245   <?php echo file_get_contents(dirname(__FILE__).'/style.css'); ?> 
    246   </style> 
    247   <?php 
    248           echo 
    249                dcPage::jsLoad('js/jquery/jquery-ui.custom.js'). 
    250                dcPage::jsLoad('index.php?pf=widgets/widgets.js'); 
    251   ?> 
    252   <?php  
    253      $core->auth->user_prefs->addWorkspace('accessibility');  
    254      $user_dm_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; 
    255   ?> 
    256   <?php if (!$user_dm_nodragdrop) : ?> 
    257   <script type="text/javascript" src="index.php?pf=widgets/dragdrop.js"></script> 
    258   <?php endif; ?> 
    259   <script type="text/javascript"> 
    260   //<![CDATA[ 
    261   <?php echo dcPage::jsVar('dotclear.msg.confirm_widgets_reset', 
    262      __('Are you sure you want to reset sidebars?')); ?> 
    263   //]]> 
    264   </script> 
    265   <?php echo(dcPage::jsConfirmClose('sidebarsWidgets')); ?> 
    266 </head> 
    267 <body> 
    268 <?php*/ 
    269241echo dcPage::breadcrumb( 
    270242     array( 
Note: See TracChangeset for help on using the changeset viewer.

Sites map