Dotclear

Changeset 2428:3eff307817bf


Ignore:
Timestamp:
10/17/13 17:41:32 (11 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
2.6
Message:

Add batch actions on plugins and themes lists

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/lib.moduleslist.php

    r2377 r2428  
    732732          } 
    733733 
     734          if ($count > 1 && !empty($actions) && $this->core->auth->isSuperAdmin()) { 
     735               $buttons = $this->getGlobalActions($actions); 
     736 
     737               echo  
     738               '<form action="'.$this->getURL().'" method="post" class="global-actions-buttons">'. 
     739               '<div>'. 
     740               $this->core->formNonce(). 
     741               form::hidden(array('modules'), '1'). 
     742 
     743               implode(' ', $buttons). 
     744 
     745               '</div>'. 
     746               '</form>'; 
     747          } 
     748 
    734749          return $this; 
    735750     } 
     
    795810          } 
    796811 
     812          return $submits; 
     813     } 
     814 
     815     /** 
     816      * Get global action buttons to add to modules list. 
     817      * 
     818      * @param array     $actions  Actions keys 
     819      * @return     Array of actions buttons 
     820      */ 
     821     protected function getGlobalActions($actions) 
     822     { 
     823          $submits = array(); 
     824 
     825          # Use loop to keep requested order 
     826          foreach($actions as $action) { 
     827               switch($action) { 
     828 
     829                    # Deactivate 
     830                    case 'activate': if ($this->path_writable) { 
     831                         $submits[] =  
     832                         '<input type="submit" name="activate" value="'.__('Activate all plugins from this list').'" />'; 
     833                    } break; 
     834 
     835                    # Activate 
     836                    case 'deactivate': if ($this->path_writable) { 
     837                         $submits[] =  
     838                         '<input type="submit" name="deactivate" value="'.__('Deactivate all plugins from this list').'" class="reset" />'; 
     839                    } break; 
     840 
     841                    # Update (from store) 
     842                    case 'update': if ($this->path_writable) { 
     843                         $submits[] =  
     844                         '<input type="submit" name="update" value="'.__('Update all plugins from this list').'" />'; 
     845                    } break; 
     846 
     847                    # Behavior 
     848                    case 'behavior': 
     849 
     850                         # --BEHAVIOR-- adminModulesListGetGlobalActions 
     851                         $tmp = $this->core->callBehavior('adminModulesListGetGlobalActions', $this); 
     852 
     853                         if (!empty($tmp)) { 
     854                              $submits[] = $tmp; 
     855                         } 
     856                    break; 
     857               } 
     858          } 
    797859 
    798860          return $submits; 
     
    813875          } 
    814876 
    815           # List actions 
     877          # Actions per module 
    816878          if (!empty($_POST['module'])) { 
    817879 
     
    893955                    http::redirect($this->getURL()); 
    894956               } 
    895  
    896957               elseif (!empty($_POST['install'])) { 
    897958 
     
    9631024                    $this->core->callBehavior('adminModulesListDoActions', $this, $id, 'plugin'); 
    9641025 
     1026               } 
     1027          } 
     1028          # Global actions 
     1029          elseif (!empty($_POST['modules'])) { 
     1030 
     1031               if (!empty($_POST['activate'])) { 
     1032 
     1033                    $modules = $this->modules->getDisabledModules(); 
     1034                    if (empty($modules)) { 
     1035                         throw new Exception(__('No such plugin.')); 
     1036                    } 
     1037 
     1038                    foreach($modules as $id => $module) { 
     1039 
     1040                         # --BEHAVIOR-- moduleBeforeActivate 
     1041                         $this->core->callBehavior('pluginBeforeActivate', $id); 
     1042 
     1043                         $this->modules->activateModule($id); 
     1044 
     1045                         # --BEHAVIOR-- moduleAfterActivate 
     1046                         $this->core->callBehavior('pluginAfterActivate', $id); 
     1047 
     1048                    } 
     1049 
     1050                    dcPage::addSuccessNotice(__('Plugins have been successfully activated.')); 
     1051                    http::redirect($this->getURL()); 
     1052               } 
     1053 
     1054               elseif (!empty($_POST['deactivate'])) { 
     1055 
     1056                    $modules = $this->modules->getModules(); 
     1057                    if (empty($modules)) { 
     1058                         throw new Exception(__('No such plugin.')); 
     1059                    } 
     1060 
     1061                    $failed = false; 
     1062                    foreach($modules as $id => $module) { 
     1063                         $module[$id] = $id; 
     1064 
     1065                         if (!$module['root_writable']) { 
     1066                              $failed = true; 
     1067                              continue; 
     1068                         } 
     1069 
     1070                         # --BEHAVIOR-- moduleBeforeDeactivate 
     1071                         $this->core->callBehavior('pluginBeforeDeactivate', $module); 
     1072 
     1073                         $this->modules->deactivateModule($id); 
     1074 
     1075                         # --BEHAVIOR-- moduleAfterDeactivate 
     1076                         $this->core->callBehavior('pluginAfterDeactivate', $module); 
     1077                    } 
     1078 
     1079                    if ($failed) { 
     1080                         dcPage::addWarningNotice(__('Some plugins have not been deactivated.')); 
     1081                    } 
     1082                    else { 
     1083                         dcPage::addSuccessNotice(__('Plugins have been successfully deactivated.')); 
     1084                    } 
     1085                    http::redirect($this->getURL()); 
     1086               } 
     1087 
     1088               elseif (!empty($_POST['update'])) { 
     1089 
     1090                    $updated = $this->store->get(true); 
     1091                    if (empty($updated)) { 
     1092                         throw new Exception(__('No such plugin.')); 
     1093                    } 
     1094 
     1095                    foreach($updated as $module) { 
     1096 
     1097                         if (!self::$allow_multi_install) { 
     1098                              $dest = $module['root'].'/../'.basename($module['file']); 
     1099                         } 
     1100                         else { 
     1101                              $dest = $this->getPath().'/'.basename($module['file']); 
     1102                              if ($module['root'] != $dest) { 
     1103                                   @file_put_contents($module['root'].'/_disabled', ''); 
     1104                              } 
     1105                         } 
     1106 
     1107                         # --BEHAVIOR-- moduleBeforeUpdate 
     1108                         $this->core->callBehavior('pluginBeforeUpdate', $module); 
     1109 
     1110                         $this->store->process($module['file'], $dest); 
     1111 
     1112                         # --BEHAVIOR-- moduleAfterUpdate 
     1113                         $this->core->callBehavior('pluginAfterUpdate', $module); 
     1114                    } 
     1115 
     1116                    dcPage::addSuccessNotice(__('Plugins have been successfully updated.')); 
     1117                    http::redirect($this->getURL().'#plugins'); 
    9651118               } 
    9661119          } 
     
    13781531               '<p class="message">'.__('No themes matched your search.').'</p>'; 
    13791532          } 
     1533 
     1534          if ($count > 1 && !empty($actions) && $this->core->auth->isSuperAdmin()) { 
     1535               $buttons = $this->getGlobalActions($actions); 
     1536 
     1537               echo  
     1538               '<form action="'.$this->getURL().'" method="post" class="global-actions-buttons">'. 
     1539               '<div>'. 
     1540               $this->core->formNonce(). 
     1541               form::hidden(array('modules'), '1'). 
     1542 
     1543               implode(' ', $buttons). 
     1544 
     1545               '</div>'. 
     1546               '</form>'; 
     1547          } 
    13801548     } 
    13811549 
     
    13981566               parent::getActions($id, $module, $actions) 
    13991567          ); 
     1568     } 
     1569 
     1570     protected function getGlobalActions($actions) 
     1571     { 
     1572          $submits = array(); 
     1573 
     1574          foreach($actions as $action) { 
     1575               switch($action) { 
     1576 
     1577 
     1578                    # Update (from store) 
     1579                    case 'update': if ($this->path_writable) { 
     1580                         $submits[] =  
     1581                         '<input type="submit" name="update" value="'.__('Update all themes from this list').'" />'; 
     1582                    } break; 
     1583 
     1584                    # Behavior 
     1585                    case 'behavior': 
     1586 
     1587                         # --BEHAVIOR-- adminModulesListGetGlobalActions 
     1588                         $tmp = $this->core->callBehavior('adminModulesListGetGlobalActions', $this); 
     1589 
     1590                         if (!empty($tmp)) { 
     1591                              $submits[] = $tmp; 
     1592                         } 
     1593                    break; 
     1594               } 
     1595          } 
     1596 
     1597          return $submits; 
    14001598     } 
    14011599 
     
    15701768                    $this->core->callBehavior('adminModulesListDoActions', $this, $id, 'theme'); 
    15711769 
     1770               } 
     1771          } 
     1772          # Global actions 
     1773          elseif (!empty($_POST['modules'])) { 
     1774 
     1775               if (!empty($_POST['update'])) { 
     1776 
     1777                    $updated = $this->store->get(true); 
     1778                    if (empty($updated)) { 
     1779                         throw new Exception(__('No such theme.')); 
     1780                    } 
     1781 
     1782                    foreach($updated as $module) { 
     1783 
     1784                         if (!self::$allow_multi_install) { 
     1785                              $dest = $module['root'].'/../'.basename($module['file']); 
     1786                         } 
     1787                         else { 
     1788                              $dest = $this->getPath().'/'.basename($module['file']); 
     1789                              if ($module['root'] != $dest) { 
     1790                                   @file_put_contents($module['root'].'/_disabled', ''); 
     1791                              } 
     1792                         } 
     1793 
     1794                         # --BEHAVIOR-- moduleBeforeUpdate 
     1795                         $this->core->callBehavior('themesBeforeUpdate', $module); 
     1796 
     1797                         $this->store->process($module['file'], $dest); 
     1798 
     1799                         # --BEHAVIOR-- moduleAfterUpdate 
     1800                         $this->core->callBehavior('themesAfterUpdate', $module); 
     1801                    } 
     1802 
     1803                    dcPage::addSuccessNotice(__('Themes have been successfully updated.')); 
     1804                    http::redirect($this->getURL().'#themes'); 
    15721805               } 
    15731806          } 
  • locales/en/main.po

    r2417 r2428  
    28642864msgstr "" 
    28652865 
     2866msgid "Activate all plugins from this list" 
     2867msgstr "" 
     2868 
     2869msgid "Plugins have been successfully activated." 
     2870msgstr "" 
     2871 
     2872msgid "Deactivate all plugins from this list" 
     2873msgstr "" 
     2874 
     2875msgid "Plugins have been successfully deactivated." 
     2876msgstr "" 
     2877 
     2878msgid "Some plugins have not been deactivated." 
     2879msgstr "" 
     2880 
     2881msgid "Update all plugins from this list" 
     2882msgstr "" 
     2883 
     2884msgid "Plugins have been successfully updated." 
     2885msgstr "" 
     2886 
    28662887msgid "Zip file path:" 
    28672888msgstr "" 
     
    29542975 
    29552976msgid "Theme has been successfully updated." 
     2977msgstr "" 
     2978 
     2979msgid "Update all theme from this list" 
     2980msgstr "" 
     2981 
     2982msgid "Themes have been successfully updated." 
    29562983msgstr "" 
    29572984 
  • locales/fr/main.po

    r2417 r2428  
    28772877msgstr "Ce plugin a été installé." 
    28782878 
     2879msgid "Activate all plugins from this list" 
     2880msgstr "Activer tous les plugins de cette liste" 
     2881 
     2882msgid "Plugins have been successfully activated." 
     2883msgstr "Ces plugins ont été activés." 
     2884 
     2885msgid "Deactivate all plugins from this list" 
     2886msgstr "Désactiver tous les plugins de cette liste" 
     2887 
     2888msgid "Plugins have been successfully deactivated." 
     2889msgstr "Ces plugins ont été désactivés." 
     2890 
     2891msgid "Some plugins have not been deactivated." 
     2892msgstr "Certains plugins n'ont pas pu être désactivés." 
     2893 
     2894msgid "Update all plugins from this list" 
     2895msgstr "Mettre à jour tous les plugins de cette liste" 
     2896 
     2897msgid "Plugins have been successfully updated." 
     2898msgstr "Ces plugins ont été mis à jour." 
     2899 
    28792900msgid "Zip file path:" 
    28802901msgstr "Chemin du fichier zip :" 
     
    29682989msgid "Theme has been successfully updated." 
    29692990msgstr "Ce thème a été mis à jour." 
     2991 
     2992msgid "Update all theme from this list" 
     2993msgstr "Mettre à jour tous les thèmes de cette liste" 
     2994 
     2995msgid "Themes have been successfully updated." 
     2996msgstr "Ces thèmes ont été mis à jour." 
    29702997 
    29712998msgid "Theme has been successfully installed." 
Note: See TracChangeset for help on using the changeset viewer.

Sites map