Changeset 2487:53510da55dc5 for inc/admin
- Timestamp:
- 10/24/13 11:14:03 (12 years ago)
- Branch:
- 2.6
- Location:
- inc/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.dc.page.php
r2328 r2487 665 665 self::jsVar('dotclear.msg.confirm_delete_plugin', 666 666 __('Are you sure you want to delete "%s" plugin?')). 667 self::jsVar('dotclear.msg.confirm_delete_plugins', 668 __('Are you sure you want to delete selected plugins?')). 667 669 self::jsVar('dotclear.msg.use_this_theme', 668 670 __('Use this theme')). … … 671 673 self::jsVar('dotclear.msg.confirm_delete_theme', 672 674 __('Are you sure you want to delete "%s" theme?')). 675 self::jsVar('dotclear.msg.confirm_delete_themes', 676 __('Are you sure you want to delete selected themes?')). 673 677 self::jsVar('dotclear.msg.confirm_delete_backup', 674 678 __('Are you sure you want to delete this backup?')). -
inc/admin/lib.moduleslist.php
r2469 r2487 522 522 { 523 523 echo 524 '<form action="'.$this->getURL().'" method="post" class="modules-form-actions">'. 524 525 '<div class="table-outer">'. 525 526 '<table id="'.html::escapeHTML($this->list_id).'" class="modules'.(in_array('expander', $cols) ? ' expandable' : '').'">'. … … 527 528 528 529 if (in_array('name', $cols)) { 530 $colspan = 1; 531 if (in_array('checkbox', $cols)) { 532 $colspan++; 533 } 534 if (in_array('icon', $cols)) { 535 $colspan++; 536 } 529 537 echo 530 '<th class="first nowrap"'.( in_array('icon', $cols) ? ' colspan="2"' : '').'>'.__('Name').'</th>';538 '<th class="first nowrap"'.($colspan > 1 ? ' colspan="'.$colspan.'"' : '').'>'.__('Name').'</th>'; 531 539 } 532 540 … … 590 598 $tds = 0; 591 599 600 if (in_array('checkbox', $cols)) { 601 $tds++; 602 echo 603 '<td class="module-icon nowrap">'. 604 form::checkbox(array('modules['.$count.']', html::escapeHTML($this->list_id).'_modules_'.html::escapeHTML($id)), html::escapeHTML($id)). 605 '</td>'; 606 } 607 592 608 if (in_array('icon', $cols)) { 593 609 $tds++; … … 601 617 $tds++; 602 618 echo 603 '<td class="module-name nowrap" scope="row">'.html::escapeHTML($module['name']).'</td>'; 619 '<td class="module-name nowrap" scope="row">'; 620 if (in_array('checkbox', $cols)) { 621 if (in_array('expander', $cols)) { 622 echo 623 html::escapeHTML($module['name']); 624 } 625 else { 626 echo 627 '<label for="'.html::escapeHTML($this->list_id).'_modules_'.html::escapeHTML($id).'">'. 628 html::escapeHTML($module['name']). 629 '</label>'; 630 } 631 } 632 else { 633 echo 634 html::escapeHTML($module['name']). 635 form::hidden(array('modules['.$count.']'), html::escapeHTML($id)); 636 } 637 echo 638 $this->core->formNonce(). 639 '</td>'; 604 640 605 641 # Display score only for debug purpose … … 645 681 '<td class="module-actions nowrap">'. 646 682 647 '<form action="'.$this->getURL().'" method="post">'. 648 '<div>'. 649 $this->core->formNonce(). 650 form::hidden(array('module'), html::escapeHTML($id)). 651 652 implode(' ', $buttons). 653 654 '</div>'. 655 '</form>'. 683 '<div>'.implode(' ', $buttons).'</div>'. 656 684 657 685 '</td>'; … … 732 760 } 733 761 734 if ($count > 1&& !empty($actions) && $this->core->auth->isSuperAdmin()) {735 $buttons = $this->getGlobalActions($actions );736 737 echo738 '<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 }762 elseif ((in_array('checkbox', $cols) || $count > 1) && !empty($actions) && $this->core->auth->isSuperAdmin()) { 763 $buttons = $this->getGlobalActions($actions, in_array('checkbox', $cols)); 764 765 if (!empty($buttons)) { 766 if (in_array('checkbox', $cols)) { 767 echo 768 '<p class="checkboxes-helpers"></p>'; 769 } 770 echo 771 '<div>'.implode(' ', $buttons).'</div>'; 772 } 773 } 774 echo 775 '</form>'; 748 776 749 777 return $this; … … 769 797 case 'activate': if ($module['root_writable']) { 770 798 $submits[] = 771 '<input type="submit" name="activate " value="'.__('Activate').'" />';799 '<input type="submit" name="activate['.html::escapeHTML($id).']" value="'.__('Activate').'" />'; 772 800 } break; 773 801 … … 775 803 case 'deactivate': if ($module['root_writable']) { 776 804 $submits[] = 777 '<input type="submit" name="deactivate " value="'.__('Deactivate').'" class="reset" />';805 '<input type="submit" name="deactivate['.html::escapeHTML($id).']" value="'.__('Deactivate').'" class="reset" />'; 778 806 } break; 779 807 … … 782 810 $dev = !preg_match('!^'.$this->path_pattern.'!', $module['root']) && defined('DC_DEV') && DC_DEV ? ' debug' : ''; 783 811 $submits[] = 784 '<input type="submit" class="delete '.$dev.'" name="delete " value="'.__('Delete').'" />';812 '<input type="submit" class="delete '.$dev.'" name="delete['.html::escapeHTML($id).']" value="'.__('Delete').'" />'; 785 813 } break; 786 814 … … 788 816 case 'install': if ($this->path_writable) { 789 817 $submits[] = 790 '<input type="submit" name="install " value="'.__('Install').'" />';818 '<input type="submit" name="install['.html::escapeHTML($id).']" value="'.__('Install').'" />'; 791 819 } break; 792 820 … … 794 822 case 'update': if ($this->path_writable) { 795 823 $submits[] = 796 '<input type="submit" name="update " value="'.__('Update').'" />';824 '<input type="submit" name="update['.html::escapeHTML($id).']" value="'.__('Update').'" />'; 797 825 } break; 798 826 … … 816 844 * Get global action buttons to add to modules list. 817 845 * 818 * @param array $actions Actions keys 846 * @param array $actions Actions keys 847 * @param boolean $with_selection Limit action to selected modules 819 848 * @return Array of actions buttons 820 849 */ 821 protected function getGlobalActions($actions )850 protected function getGlobalActions($actions, $with_selection=false) 822 851 { 823 852 $submits = array(); … … 830 859 case 'activate': if ($this->path_writable) { 831 860 $submits[] = 832 '<input type="submit" name="activate" value="'.__('Activate all plugins from this list').'" />'; 861 '<input type="submit" name="activate" value="'.($with_selection ? 862 __('Activate selected plugins') : 863 __('Activate all plugins from this list') 864 ).'" />'; 833 865 } break; 834 866 … … 836 868 case 'deactivate': if ($this->path_writable) { 837 869 $submits[] = 838 '<input type="submit" name="deactivate" value="'.__('Deactivate all plugins from this list').'" class="reset" />'; 870 '<input type="submit" name="deactivate" value="'.($with_selection ? 871 __('Deactivate selected plugins') : 872 __('Deactivate all plugins from this list') 873 ).'" />'; 839 874 } break; 840 875 … … 842 877 case 'update': if ($this->path_writable) { 843 878 $submits[] = 844 '<input type="submit" name="update" value="'.__('Update all plugins from this list').'" />'; 879 '<input type="submit" name="update" value="'.($with_selection ? 880 __('Update selected plugins') : 881 __('Update all plugins from this list') 882 ).'" />'; 845 883 } break; 846 884 … … 849 887 850 888 # --BEHAVIOR-- adminModulesListGetGlobalActions 851 $tmp = $this->core->callBehavior('adminModulesListGetGlobalActions', $this );889 $tmp = $this->core->callBehavior('adminModulesListGetGlobalActions', $this, $with_selection); 852 890 853 891 if (!empty($tmp)) { … … 875 913 } 876 914 877 # Actions per module 878 if (!empty($_POST['module'])) { 879 880 $id = $_POST['module']; 881 882 if (!empty($_POST['activate'])) { 883 884 $enabled = $this->modules->getDisabledModules(); 885 if (!isset($enabled[$id])) { 886 throw new Exception(__('No such plugin.')); 887 } 888 889 # --BEHAVIOR-- moduleBeforeActivate 890 $this->core->callBehavior('pluginBeforeActivate', $id); 891 892 $this->modules->activateModule($id); 893 894 # --BEHAVIOR-- moduleAfterActivate 895 $this->core->callBehavior('pluginAfterActivate', $id); 896 897 dcPage::addSuccessNotice(__('Plugin has been successfully activated.')); 898 http::redirect($this->getURL()); 899 } 900 901 elseif (!empty($_POST['deactivate'])) { 902 903 if (!$this->modules->moduleExists($id)) { 904 throw new Exception(__('No such plugin.')); 905 } 906 907 $module = $this->modules->getModules($id); 908 $module['id'] = $id; 909 910 if (!$module['root_writable']) { 911 throw new Exception(__('You don\'t have permissions to deactivate this plugin.')); 912 } 913 914 # --BEHAVIOR-- moduleBeforeDeactivate 915 $this->core->callBehavior('pluginBeforeDeactivate', $module); 916 917 $this->modules->deactivateModule($id); 918 919 # --BEHAVIOR-- moduleAfterDeactivate 920 $this->core->callBehavior('pluginAfterDeactivate', $module); 921 922 dcPage::addSuccessNotice(__('Plugin has been successfully deactivated.')); 923 http::redirect($this->getURL()); 924 } 925 926 elseif (!empty($_POST['delete'])) { 927 928 $disabled = $this->modules->getDisabledModules(); 929 if (!isset($disabled[$id])) { 915 $modules = !empty($_POST['modules']) && is_array($_POST['modules']) ? array_values($_POST['modules']) : array(); 916 917 if (!empty($_POST['delete'])) { 918 919 if (is_array($_POST['delete'])) { 920 $modules = array_keys($_POST['delete']); 921 } 922 923 $list = $this->modules->getDisabledModules(); 924 925 $failed = false; 926 $count = 0; 927 foreach($modules as $id) 928 { 929 if (!isset($list[$id])) { 930 930 931 931 if (!$this->modules->moduleExists($id)) { … … 937 937 938 938 if (!$this->isDeletablePath($module['root'])) { 939 throw new Exception(__("You don't have permissions to delete this plugin.")); 939 $failed = true; 940 continue; 940 941 } 941 942 … … 952 953 } 953 954 954 dcPage::addSuccessNotice(__('Plugin has been successfully deleted.')); 955 http::redirect($this->getURL()); 956 } 957 elseif (!empty($_POST['install'])) { 958 959 $updated = $this->store->get(); 960 if (!isset($updated[$id])) { 961 throw new Exception(__('No such plugin.')); 962 } 963 964 $module = $updated[$id]; 965 $module['id'] = $id; 955 $count++; 956 } 957 958 if (!$count && $failed) { 959 throw new Exception(__("You don't have permissions to delete this plugin.")); 960 } 961 elseif ($failed) { 962 dcPage::addWarningNotice(__('Some plugins have not been delete.')); 963 } 964 else { 965 dcPage::addSuccessNotice( 966 __('Plugin has been successfully deleted.', 'Plugins have been successuflly deleted.', $count) 967 ); 968 } 969 http::redirect($this->getURL()); 970 } 971 972 elseif (!empty($_POST['install'])) { 973 974 if (is_array($_POST['install'])) { 975 $modules = array_keys($_POST['install']); 976 } 977 978 $list = $this->store->get(); 979 980 if (empty($list)) { 981 throw new Exception(__('No such plugin.')); 982 } 983 984 $count = 0; 985 foreach($list as $id => $module) { 986 987 if (!in_array($id, $modules)) { 988 continue; 989 } 966 990 967 991 $dest = $this->getPath().'/'.basename($module['file']); … … 970 994 $this->core->callBehavior('pluginBeforeAdd', $module); 971 995 972 $ ret_code = $this->store->process($module['file'], $dest);996 $this->store->process($module['file'], $dest); 973 997 974 998 # --BEHAVIOR-- moduleAfterAdd 975 999 $this->core->callBehavior('pluginAfterAdd', $module); 976 1000 977 dcPage::addSuccessNotice($ret_code == 2 ? 978 __('Plugin has been successfully updated.') : 979 __('Plugin has been successfully installed.') 1001 $count++; 1002 } 1003 1004 dcPage::addSuccessNotice( 1005 __('Plugin has been successfully installed.', 'Plugins have been successuflly installed.', $count) 1006 ); 1007 http::redirect($this->getURL()); 1008 } 1009 1010 elseif (!empty($_POST['activate'])) { 1011 1012 if (is_array($_POST['activate'])) { 1013 $modules = array_keys($_POST['activate']); 1014 } 1015 1016 $list = $this->modules->getDisabledModules(); 1017 if (empty($list)) { 1018 throw new Exception(__('No such plugin.')); 1019 } 1020 1021 $count = 0; 1022 foreach($list as $id => $module) { 1023 1024 if (!in_array($id, $modules)) { 1025 continue; 1026 } 1027 1028 # --BEHAVIOR-- moduleBeforeActivate 1029 $this->core->callBehavior('pluginBeforeActivate', $id); 1030 1031 $this->modules->activateModule($id); 1032 1033 # --BEHAVIOR-- moduleAfterActivate 1034 $this->core->callBehavior('pluginAfterActivate', $id); 1035 1036 $count++; 1037 } 1038 1039 dcPage::addSuccessNotice( 1040 __('Plugin has been successfully activated.', 'Plugins have been successuflly activated.', $count) 1041 ); 1042 http::redirect($this->getURL()); 1043 } 1044 1045 elseif (!empty($_POST['deactivate'])) { 1046 1047 if (is_array($_POST['deactivate'])) { 1048 $modules = array_keys($_POST['deactivate']); 1049 } 1050 1051 $list = $this->modules->getModules(); 1052 if (empty($list)) { 1053 throw new Exception(__('No such plugin.')); 1054 } 1055 1056 $failed = false; 1057 $count = 0; 1058 foreach($list as $id => $module) { 1059 1060 if (!in_array($id, $modules)) { 1061 continue; 1062 } 1063 1064 if (!$module['root_writable']) { 1065 $failed = true; 1066 continue; 1067 } 1068 1069 $module[$id] = $id; 1070 1071 # --BEHAVIOR-- moduleBeforeDeactivate 1072 $this->core->callBehavior('pluginBeforeDeactivate', $module); 1073 1074 $this->modules->deactivateModule($id); 1075 1076 # --BEHAVIOR-- moduleAfterDeactivate 1077 $this->core->callBehavior('pluginAfterDeactivate', $module); 1078 1079 $count++; 1080 } 1081 1082 if ($failed) { 1083 dcPage::addWarningNotice(__('Some plugins have not been deactivated.')); 1084 } 1085 else { 1086 dcPage::addSuccessNotice( 1087 __('Plugin has been successfully deactivated.', 'Plugins have been successuflly deactivated.', $count) 980 1088 ); 981 http::redirect($this->getURL()); 982 } 983 984 elseif (!empty($_POST['update'])) { 985 986 $updated = $this->store->get(true); 987 if (!isset($updated[$id])) { 988 throw new Exception(__('No such plugin.')); 989 } 990 991 if (!$this->modules->moduleExists($id)) { 992 throw new Exception(__('No such plugin.')); 993 } 994 995 $tab = count($updated) > 1 ? '' : '#plugins'; 996 997 $module = $updated[$id]; 998 $module['id'] = $id; 1089 } 1090 http::redirect($this->getURL()); 1091 } 1092 1093 elseif (!empty($_POST['update'])) { 1094 1095 if (is_array($_POST['update'])) { 1096 $modules = array_keys($_POST['update']); 1097 } 1098 1099 $list = $this->store->get(true); 1100 if (empty($list)) { 1101 throw new Exception(__('No such plugin.')); 1102 } 1103 1104 $count = 0; 1105 foreach($list as $module) { 1106 1107 if (!in_array($module['id'], $modules)) { 1108 continue; 1109 } 999 1110 1000 1111 if (!self::$allow_multi_install) { … … 1016 1127 $this->core->callBehavior('pluginAfterUpdate', $module); 1017 1128 1018 dcPage::addSuccessNotice(__('Plugin has been successfully updated.')); 1019 http::redirect($this->getURL().$tab); 1020 } 1021 else { 1022 1023 # --BEHAVIOR-- adminModulesListDoActions 1024 $this->core->callBehavior('adminModulesListDoActions', $this, $id, 'plugin'); 1025 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'); 1118 } 1119 } 1129 $count++; 1130 } 1131 1132 $tab = $count && $count == count($list) ? '#plugins' : '#update'; 1133 1134 dcPage::addSuccessNotice( 1135 __('Plugin has been successfully updated.', 'Plugins have been successuflly updated.', $count) 1136 ); 1137 http::redirect($this->getURL().$tab); 1138 } 1139 1120 1140 # Manual actions 1121 1141 elseif (!empty($_POST['upload_pkg']) && !empty($_FILES['pkg_file']) … … 1153 1173 ); 1154 1174 http::redirect($this->getURL().'#plugins'); 1175 } 1176 1177 else { 1178 1179 # --BEHAVIOR-- adminModulesListDoActions 1180 $this->core->callBehavior('adminModulesListDoActions', $this, $modules, 'plugin'); 1181 1155 1182 } 1156 1183 … … 1344 1371 { 1345 1372 echo 1373 '<form action="'.$this->getURL().'" method="post" class="modules-form-actions">'. 1346 1374 '<div id="'.html::escapeHTML($this->list_id).'" class="modules'.(in_array('expander', $cols) ? ' expandable' : '').' one-box">'; 1347 1375 … … 1376 1404 if (in_array('name', $cols) && !$current) { 1377 1405 $line .= 1378 '<h4 class="module-name">'.html::escapeHTML($module['name']).'</h4>'; 1406 '<h4 class="module-name">'; 1407 1408 if (in_array('checkbox', $cols)) { 1409 $line .= 1410 '<label for="'.html::escapeHTML($this->list_id).'_modules_'.html::escapeHTML($id).'">'. 1411 form::checkbox(array('modules['.$count.']', html::escapeHTML($this->list_id).'_modules_'.html::escapeHTML($id)), html::escapeHTML($id)). 1412 html::escapeHTML($module['name']). 1413 '</label>'; 1414 1415 } 1416 else { 1417 $line .= 1418 form::hidden(array('modules['.$count.']'), html::escapeHTML($id)). 1419 html::escapeHTML($module['name']); 1420 } 1421 1422 $line .= 1423 $this->core->formNonce(). 1424 '</h4>'; 1379 1425 } 1380 1426 … … 1409 1455 if (in_array('name', $cols) && $current) { 1410 1456 $line .= 1411 '<h4 class="module-name">'.html::escapeHTML($module['name']).'</h4>'; 1457 '<h4 class="module-name">'; 1458 1459 if (in_array('checkbox', $cols)) { 1460 $line .= 1461 '<label for="'.html::escapeHTML($this->list_id).'_modules_'.html::escapeHTML($id).'">'. 1462 form::checkbox(array('modules['.$count.']', html::escapeHTML($this->list_id).'_modules_'.html::escapeHTML($id)), html::escapeHTML($id)). 1463 html::escapeHTML($module['name']). 1464 '</label>'; 1465 } 1466 else { 1467 $line .= 1468 form::hidden(array('modules['.$count.']'), html::escapeHTML($id)). 1469 html::escapeHTML($module['name']); 1470 } 1471 1472 $line .= 1473 '</h4>'; 1412 1474 } 1413 1475 … … 1502 1564 if (!empty($actions)) { 1503 1565 $line .= 1504 '<form action="'.$this->getURL().'" method="post" class="actions-buttons">'. 1505 '<p>'. 1506 $this->core->formNonce(). 1507 form::hidden(array('module'), html::escapeHTML($id)). 1508 1509 implode(' ', $this->getActions($id, $module, $actions)). 1510 1511 '</p>'. 1512 '</form>'; 1566 '<p>'.implode(' ', $this->getActions($id, $module, $actions)).'</p>'; 1513 1567 } 1514 1568 … … 1523 1577 $res = $current ? $line.$res : $res.$line; 1524 1578 } 1579 1525 1580 echo 1526 1581 $res. … … 1532 1587 } 1533 1588 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 } 1589 elseif ((in_array('checkbox', $cols) || $count > 1) && !empty($actions) && $this->core->auth->isSuperAdmin()) { 1590 $buttons = $this->getGlobalActions($actions, in_array('checkbox', $cols)); 1591 1592 if (!empty($buttons)) { 1593 echo '<div>'.implode(' ', $buttons).'</div>'; 1594 } 1595 } 1596 1597 echo 1598 '</form>'; 1599 1600 return $this; 1548 1601 } 1549 1602 … … 1558 1611 if (in_array('select', $actions) && $this->path_writable) { 1559 1612 $submits[] = 1560 '<input type="submit" name="select " value="'.__('Use this one').'" />';1613 '<input type="submit" name="select['.html::escapeHTML($id).']" value="'.__('Use this one').'" />'; 1561 1614 } 1562 1615 } … … 1568 1621 } 1569 1622 1570 protected function getGlobalActions($actions )1623 protected function getGlobalActions($actions, $with_selection=false) 1571 1624 { 1572 1625 $submits = array(); … … 1574 1627 foreach($actions as $action) { 1575 1628 switch($action) { 1576 1577 1629 1578 1630 # Update (from store) 1579 1631 case 'update': if ($this->path_writable) { 1580 1632 $submits[] = 1581 '<input type="submit" name="update" value="'.__('Update all themes from this list').'" />'; 1633 '<input type="submit" name="update" value="'.($with_selection ? 1634 __('Update selected themes') : 1635 __('Update all themes from this list') 1636 ).'" />'; 1582 1637 } break; 1583 1638 … … 1605 1660 } 1606 1661 1607 # List actions 1608 if (!empty($_POST['module'])) { 1609 1610 $id = $_POST['module']; 1611 1612 if (!empty($_POST['select'])) { 1662 $modules = !empty($_POST['modules']) && is_array($_POST['modules']) ? array_values($_POST['modules']) : array(); 1663 1664 if (!empty($_POST['select'])) { 1665 1666 # Can select only one theme at a time! 1667 if (is_array($_POST['select'])) { 1668 $modules = array_keys($_POST['select']); 1669 $id = $modules[0]; 1613 1670 1614 1671 if (!$this->modules->moduleExists($id)) { … … 1623 1680 http::redirect($this->getURL().'#themes'); 1624 1681 } 1625 elseif (!empty($_POST['activate'])) { 1626 1627 $enabled = $this->modules->getDisabledModules(); 1628 if (!isset($enabled[$id])) { 1629 throw new Exception(__('No such theme.')); 1682 } 1683 1684 elseif (!empty($_POST['activate'])) { 1685 1686 if (is_array($_POST['activate'])) { 1687 $modules = array_keys($_POST['activate']); 1688 } 1689 1690 $list = $this->modules->getDisabledModules(); 1691 if (empty($list)) { 1692 throw new Exception(__('No such theme.')); 1693 } 1694 1695 $count = 0; 1696 foreach($list as $id => $module) { 1697 1698 if (!in_array($id, $modules)) { 1699 continue; 1630 1700 } 1631 1701 … … 1638 1708 $this->core->callBehavior('themeAfterActivate', $id); 1639 1709 1640 dcPage::addSuccessNotice(__('Theme has been successfully activated.')); 1641 http::redirect($this->getURL()); 1642 } 1643 1644 elseif (!empty($_POST['deactivate'])) { 1645 1646 if (!$this->modules->moduleExists($id)) { 1647 throw new Exception(__('No such theme.')); 1648 } 1649 1650 $module = $this->modules->getModules($id); 1651 $module['id'] = $id; 1710 $count++; 1711 } 1712 1713 dcPage::addSuccessNotice( 1714 __('Theme has been successfully activated.', 'Themes have been successuflly activated.', $count) 1715 ); 1716 http::redirect($this->getURL()); 1717 } 1718 1719 elseif (!empty($_POST['deactivate'])) { 1720 1721 if (is_array($_POST['deactivate'])) { 1722 $modules = array_keys($_POST['deactivate']); 1723 } 1724 1725 $list = $this->modules->getModules(); 1726 if (empty($list)) { 1727 throw new Exception(__('No such theme.')); 1728 } 1729 1730 $failed = false; 1731 $count = 0; 1732 foreach($list as $id => $module) { 1733 1734 if (!in_array($id, $modules)) { 1735 continue; 1736 } 1652 1737 1653 1738 if (!$module['root_writable']) { 1654 throw new Exception(__('You don\'t have permissions to deactivate this theme.')); 1655 } 1739 $failed = true; 1740 continue; 1741 } 1742 1743 $module[$id] = $id; 1656 1744 1657 1745 # --BEHAVIOR-- themeBeforeDeactivate … … 1663 1751 $this->core->callBehavior('themeAfterDeactivate', $module); 1664 1752 1665 dcPage::addSuccessNotice(__('Theme has been successfully deactivated.')); 1666 http::redirect($this->getURL()); 1667 } 1668 1669 elseif (!empty($_POST['delete'])) { 1670 1671 $disabled = $this->modules->getDisabledModules(); 1672 if (!isset($disabled[$id])) { 1753 $count++; 1754 } 1755 1756 if ($failed) { 1757 dcPage::addWarningNotice(__('Some themes have not been deactivated.')); 1758 } 1759 else { 1760 dcPage::addSuccessNotice( 1761 __('Theme has been successfully deactivated.', 'Themes have been successuflly deactivated.', $count) 1762 ); 1763 } 1764 http::redirect($this->getURL()); 1765 } 1766 1767 elseif (!empty($_POST['delete'])) { 1768 1769 if (is_array($_POST['delete'])) { 1770 $modules = array_keys($_POST['delete']); 1771 } 1772 1773 $list = $this->modules->getDisabledModules(); 1774 1775 $failed = false; 1776 $count = 0; 1777 foreach($modules as $id) 1778 { 1779 if (!isset($list[$id])) { 1673 1780 1674 1781 if (!$this->modules->moduleExists($id)) { 1675 throw new Exception(__('No such module.'));1782 throw new Exception(__('No such theme.')); 1676 1783 } 1677 1784 … … 1680 1787 1681 1788 if (!$this->isDeletablePath($module['root'])) { 1682 throw new Exception(__("You don't have permissions to delete this theme.")); 1789 $failed = true; 1790 continue; 1683 1791 } 1684 1792 … … 1695 1803 } 1696 1804 1697 dcPage::addSuccessNotice(__('Theme has been successfully deleted.')); 1698 http::redirect($this->getURL()); 1699 } 1700 1701 elseif (!empty($_POST['install'])) { 1702 1703 $updated = $this->store->get(); 1704 if (!isset($updated[$id])) { 1705 throw new Exception(__('No such theme.')); 1706 } 1707 1708 $module = $updated[$id]; 1709 $module['id'] = $id; 1805 $count++; 1806 } 1807 1808 if (!$count && $failed) { 1809 throw new Exception(__("You don't have permissions to delete this theme.")); 1810 } 1811 elseif ($failed) { 1812 dcPage::addWarningNotice(__('Some themes have not been delete.')); 1813 } 1814 else { 1815 dcPage::addSuccessNotice( 1816 __('Theme has been successfully deleted.', 'Themes have been successuflly deleted.', $count) 1817 ); 1818 } 1819 http::redirect($this->getURL()); 1820 } 1821 1822 elseif (!empty($_POST['install'])) { 1823 1824 if (is_array($_POST['install'])) { 1825 $modules = array_keys($_POST['install']); 1826 } 1827 1828 $list = $this->store->get(); 1829 1830 if (empty($list)) { 1831 throw new Exception(__('No such theme.')); 1832 } 1833 1834 $count = 0; 1835 foreach($list as $id => $module) { 1836 1837 if (!in_array($id, $modules)) { 1838 continue; 1839 } 1710 1840 1711 1841 $dest = $this->getPath().'/'.basename($module['file']); … … 1714 1844 $this->core->callBehavior('themeBeforeAdd', $module); 1715 1845 1716 $ ret_code = $this->store->process($module['file'], $dest);1846 $this->store->process($module['file'], $dest); 1717 1847 1718 1848 # --BEHAVIOR-- themeAfterAdd 1719 1849 $this->core->callBehavior('themeAfterAdd', $module); 1720 1850 1721 dcPage::addSuccessNotice($ret_code == 2 ? 1722 __('Theme has been successfully updated.') : 1723 __('Theme has been successfully installed.') 1724 ); 1725 http::redirect($this->getURL()); 1726 } 1727 1728 elseif (!empty($_POST['update'])) { 1729 1730 $updated = $this->store->get(true); 1731 if (!isset($updated[$id])) { 1732 throw new Exception(__('No such theme.')); 1733 } 1734 1735 if (!$this->modules->moduleExists($id)) { 1736 throw new Exception(__('No such theme.')); 1737 } 1738 1739 $tab = count($updated) > 1 ? '' : '#themes'; 1740 1741 $module = $updated[$id]; 1742 $module['id'] = $id; 1743 1744 if (!self::$allow_multi_install) { 1745 $dest = $module['root'].'/../'.basename($module['file']); 1746 } 1747 else { 1748 $dest = $this->getPath().'/'.basename($module['file']); 1749 if ($module['root'] != $dest) { 1750 @file_put_contents($module['root'].'/_disabled', ''); 1751 } 1752 } 1851 $count++; 1852 } 1853 1854 dcPage::addSuccessNotice( 1855 __('Theme has been successfully installed.', 'Themes have been successuflly installed.', $count) 1856 ); 1857 http::redirect($this->getURL()); 1858 } 1859 1860 elseif (!empty($_POST['update'])) { 1861 1862 if (is_array($_POST['update'])) { 1863 $modules = array_keys($_POST['update']); 1864 } 1865 1866 $list = $this->store->get(true); 1867 if (empty($list)) { 1868 throw new Exception(__('No such theme.')); 1869 } 1870 1871 $count = 0; 1872 foreach($list as $module) { 1873 1874 if (!in_array($module['id'], $modules)) { 1875 continue; 1876 } 1877 1878 $dest = $module['root'].'/../'.basename($module['file']); 1753 1879 1754 1880 # --BEHAVIOR-- themeBeforeUpdate … … 1760 1886 $this->core->callBehavior('themeAfterUpdate', $module); 1761 1887 1762 dcPage::addSuccessNotice(__('Theme has been successfully updated.')); 1763 http::redirect($this->getURL().$tab); 1764 } 1765 else { 1766 1767 # --BEHAVIOR-- adminModulesListDoActions 1768 $this->core->callBehavior('adminModulesListDoActions', $this, $id, 'theme'); 1769 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'); 1805 } 1806 } 1888 $count++; 1889 } 1890 1891 $tab = $count && $count == count($list) ? '#themes' : '#update'; 1892 1893 dcPage::addSuccessNotice( 1894 __('Theme has been successfully updated.', 'Themes have been successuflly updated.', $count) 1895 ); 1896 http::redirect($this->getURL().$tab); 1897 } 1898 1807 1899 # Manual actions 1808 1900 elseif (!empty($_POST['upload_pkg']) && !empty($_FILES['pkg_file']) … … 1842 1934 } 1843 1935 1936 else { 1937 1938 # --BEHAVIOR-- adminModulesListDoActions 1939 $this->core->callBehavior('adminModulesListDoActions', $this, $modules, 'theme'); 1940 1941 } 1942 1844 1943 return null; 1845 1944 }
Note: See TracChangeset
for help on using the changeset viewer.