Changeset 2377:e2c358189e6c for inc/admin
- Timestamp:
- 10/15/13 18:18:02 (12 years ago)
- Branch:
- 2.6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.moduleslist.php
r2354 r2377 349 349 # Letter having modules 350 350 elseif (!empty($indexes[$char])) { 351 $title = sprintf(__('%d module', '%d modules', $indexes[$char]), $indexes[$char]);351 $title = sprintf(__('%d result', '%d results', $indexes[$char]), $indexes[$char]); 352 352 $buttons[] = '<li class="btn" title="'.$title.'"><a href="'.$this->getURL('m_nav='.$char).'" title="'.$title.'"> '.$char.' </a></li>'; 353 353 } 354 354 # Letter without modules 355 355 else { 356 $buttons[] = '<li class="btn no-link" title="'.__('no module').'"> '.$char.' </li>';356 $buttons[] = '<li class="btn no-link" title="'.__('no results').'"> '.$char.' </li>'; 357 357 } 358 358 } … … 524 524 '<div class="table-outer">'. 525 525 '<table id="'.html::escapeHTML($this->list_id).'" class="modules'.(in_array('expander', $cols) ? ' expandable' : '').'">'. 526 '<caption class="hidden">'.html::escapeHTML(__(' Modules list')).'</caption><tr>';526 '<caption class="hidden">'.html::escapeHTML(__('Plugins list')).'</caption><tr>'; 527 527 528 528 if (in_array('name', $cols)) { … … 633 633 '<td class="module-distrib">'.(self::isDistributedModule($id) ? 634 634 '<img src="images/dotclear_pw.png" alt="'. 635 __(' Modulefrom official distribution').'" title="'.636 __(' modulefrom official distribution').'" />'635 __('Plugin from official distribution').'" title="'. 636 __('Plugin from official distribution').'" />' 637 637 : '').'</td>'; 638 638 } … … 729 729 if(!$count && $this->getSearch() === null) { 730 730 echo 731 '<p class="message">'.__('No module matchesyour search.').'</p>';731 '<p class="message">'.__('No plugins matched your search.').'</p>'; 732 732 } 733 733 … … 804 804 * @note Set a notice on success through dcPage::addSuccessNotice 805 805 * @throw Exception Module not find or command failed 806 * @param string $prefix Prefix used on behaviors807 806 * @return Null 808 807 */ 809 public function doActions( $prefix)808 public function doActions() 810 809 { 811 810 if (empty($_POST) || !empty($_REQUEST['conf']) … … 823 822 $enabled = $this->modules->getDisabledModules(); 824 823 if (!isset($enabled[$id])) { 825 throw new Exception(__('No such module.'));824 throw new Exception(__('No such plugin.')); 826 825 } 827 826 828 827 # --BEHAVIOR-- moduleBeforeActivate 829 $this->core->callBehavior( $prefix.'BeforeActivate', $id);828 $this->core->callBehavior('pluginBeforeActivate', $id); 830 829 831 830 $this->modules->activateModule($id); 832 831 833 832 # --BEHAVIOR-- moduleAfterActivate 834 $this->core->callBehavior( $prefix.'AfterActivate', $id);835 836 dcPage::addSuccessNotice(__(' Modulehas been successfully activated.'));833 $this->core->callBehavior('pluginAfterActivate', $id); 834 835 dcPage::addSuccessNotice(__('Plugin has been successfully activated.')); 837 836 http::redirect($this->getURL()); 838 837 } … … 841 840 842 841 if (!$this->modules->moduleExists($id)) { 843 throw new Exception(__('No such module.'));842 throw new Exception(__('No such plugin.')); 844 843 } 845 844 … … 848 847 849 848 if (!$module['root_writable']) { 850 throw new Exception(__('You don\'t have permissions to deactivate this module.'));849 throw new Exception(__('You don\'t have permissions to deactivate this plugin.')); 851 850 } 852 851 853 852 # --BEHAVIOR-- moduleBeforeDeactivate 854 $this->core->callBehavior( $prefix.'BeforeDeactivate', $module);853 $this->core->callBehavior('pluginBeforeDeactivate', $module); 855 854 856 855 $this->modules->deactivateModule($id); 857 856 858 857 # --BEHAVIOR-- moduleAfterDeactivate 859 $this->core->callBehavior( $prefix.'AfterDeactivate', $module);860 861 dcPage::addSuccessNotice(__(' Modulehas been successfully deactivated.'));858 $this->core->callBehavior('pluginAfterDeactivate', $module); 859 860 dcPage::addSuccessNotice(__('Plugin has been successfully deactivated.')); 862 861 http::redirect($this->getURL()); 863 862 } … … 869 868 870 869 if (!$this->modules->moduleExists($id)) { 871 throw new Exception(__('No such module.'));870 throw new Exception(__('No such plugin.')); 872 871 } 873 872 … … 876 875 877 876 if (!$this->isDeletablePath($module['root'])) { 878 throw new Exception(__("You don't have permissions to delete this module."));877 throw new Exception(__("You don't have permissions to delete this plugin.")); 879 878 } 880 879 881 880 # --BEHAVIOR-- moduleBeforeDelete 882 $this->core->callBehavior( $prefix.'BeforeDelete', $module);881 $this->core->callBehavior('pluginBeforeDelete', $module); 883 882 884 883 $this->modules->deleteModule($id); 885 884 886 885 # --BEHAVIOR-- moduleAfterDelete 887 $this->core->callBehavior( $prefix.'AfterDelete', $module);886 $this->core->callBehavior('pluginAfterDelete', $module); 888 887 } 889 888 else { … … 891 890 } 892 891 893 dcPage::addSuccessNotice(__(' Modulehas been successfully deleted.'));892 dcPage::addSuccessNotice(__('Plugin has been successfully deleted.')); 894 893 http::redirect($this->getURL()); 895 894 } … … 899 898 $updated = $this->store->get(); 900 899 if (!isset($updated[$id])) { 901 throw new Exception(__('No such module.'));900 throw new Exception(__('No such plugin.')); 902 901 } 903 902 … … 908 907 909 908 # --BEHAVIOR-- moduleBeforeAdd 910 $this->core->callBehavior( $prefix.'BeforeAdd', $module);909 $this->core->callBehavior('pluginBeforeAdd', $module); 911 910 912 911 $ret_code = $this->store->process($module['file'], $dest); 913 912 914 913 # --BEHAVIOR-- moduleAfterAdd 915 $this->core->callBehavior( $prefix.'AfterAdd', $module);914 $this->core->callBehavior('pluginAfterAdd', $module); 916 915 917 916 dcPage::addSuccessNotice($ret_code == 2 ? 918 __(' Modulehas been successfully updated.') :919 __(' Modulehas been successfully installed.')917 __('Plugin has been successfully updated.') : 918 __('Plugin has been successfully installed.') 920 919 ); 921 920 http::redirect($this->getURL()); … … 926 925 $updated = $this->store->get(true); 927 926 if (!isset($updated[$id])) { 928 throw new Exception(__('No such module.'));927 throw new Exception(__('No such plugin.')); 929 928 } 930 929 931 930 if (!$this->modules->moduleExists($id)) { 932 throw new Exception(__('No such module.'));933 } 934 935 $tab = count($updated) > 1 ? '' : '# '.$prefix;931 throw new Exception(__('No such plugin.')); 932 } 933 934 $tab = count($updated) > 1 ? '' : '#plugins'; 936 935 937 936 $module = $updated[$id]; … … 949 948 950 949 # --BEHAVIOR-- moduleBeforeUpdate 951 $this->core->callBehavior( $prefix.'BeforeUpdate', $module);950 $this->core->callBehavior('pluginBeforeUpdate', $module); 952 951 953 952 $this->store->process($module['file'], $dest); 954 953 955 954 # --BEHAVIOR-- moduleAfterUpdate 956 $this->core->callBehavior( $prefix.'AfterUpdate', $module);957 958 dcPage::addSuccessNotice(__(' Modulehas been successfully updated.'));955 $this->core->callBehavior('pluginAfterUpdate', $module); 956 957 dcPage::addSuccessNotice(__('Plugin has been successfully updated.')); 959 958 http::redirect($this->getURL().$tab); 960 959 } … … 962 961 963 962 # --BEHAVIOR-- adminModulesListDoActions 964 $this->core->callBehavior('adminModulesListDoActions', $this, $id, $prefix);963 $this->core->callBehavior('adminModulesListDoActions', $this, $id, 'plugin'); 965 964 966 965 } … … 989 988 990 989 # --BEHAVIOR-- moduleBeforeAdd 991 $this->core->callBehavior( $prefix.'BeforeAdd', null);990 $this->core->callBehavior('pluginBeforeAdd', null); 992 991 993 992 $ret_code = $this->store->install($dest); 994 993 995 994 # --BEHAVIOR-- moduleAfterAdd 996 $this->core->callBehavior( $prefix.'AfterAdd', null);995 $this->core->callBehavior('pluginAfterAdd', null); 997 996 998 997 dcPage::addSuccessNotice($ret_code == 2 ? 999 __(' Modulehas been successfully updated.') :1000 __(' Modulehas been successfully installed.')998 __('Plugin has been successfully updated.') : 999 __('Plugin has been successfully installed.') 1001 1000 ); 1002 http::redirect($this->getURL().'# '.$prefix);1001 http::redirect($this->getURL().'#plugins'); 1003 1002 } 1004 1003 … … 1074 1073 1075 1074 if (!$this->modules->moduleExists($id)) { 1076 $this->core->error->add(__('Unknow moduleID'));1075 $this->core->error->add(__('Unknow plugin ID')); 1077 1076 return false; 1078 1077 } … … 1083 1082 1084 1083 if (!file_exists($file)) { 1085 $this->core->error->add(__('This modulehas no configuration file.'));1084 $this->core->error->add(__('This plugin has no configuration file.')); 1086 1085 return false; 1087 1086 } … … 1146 1145 echo 1147 1146 '<form id="module_config" action="'.$this->getURL('conf=1').'" method="post" enctype="multipart/form-data">'. 1148 '<h3>'.sprintf(__('Configure plugin"%s"'), html::escapeHTML($this->config_module['name'])).'</h3>'.1147 '<h3>'.sprintf(__('Configure "%s"'), html::escapeHTML($this->config_module['name'])).'</h3>'. 1149 1148 '<p><a class="back" href="'.$this->getRedir().'">'.__('Back').'</a></p>'; 1150 1149 } … … 1377 1376 if(!$count && $this->getSearch() === null) { 1378 1377 echo 1379 '<p class="message">'.__('No module matchesyour search.').'</p>';1378 '<p class="message">'.__('No themes matched your search.').'</p>'; 1380 1379 } 1381 1380 } … … 1401 1400 } 1402 1401 1403 public function doActions($prefix) 1404 { 1405 if (!empty($_POST) && empty($_REQUEST['conf']) && $this->isWritablePath()) { 1406 1407 # Select theme to use on curent blog 1408 if (!empty($_POST['module']) && !empty($_POST['select'])) { 1409 $id = $_POST['module']; 1402 public function doActions() 1403 { 1404 if (empty($_POST) || !empty($_REQUEST['conf']) 1405 || !$this->core->auth->isSuperAdmin() || !$this->isWritablePath()) { 1406 return null; 1407 } 1408 1409 # List actions 1410 if (!empty($_POST['module'])) { 1411 1412 $id = $_POST['module']; 1413 1414 if (!empty($_POST['select'])) { 1410 1415 1411 1416 if (!$this->modules->moduleExists($id)) { 1412 throw new Exception(__('No such module.'));1417 throw new Exception(__('No such theme.')); 1413 1418 } 1414 1419 … … 1417 1422 $this->core->blog->triggerBlog(); 1418 1423 1419 dcPage::addSuccessNotice(__(' Module has been successfully selected.'));1424 dcPage::addSuccessNotice(__('Theme has been successfully selected.')); 1420 1425 http::redirect($this->getURL().'#themes'); 1421 1426 } 1422 } 1423 1424 return parent::doActions($prefix); 1427 elseif (!empty($_POST['activate'])) { 1428 1429 $enabled = $this->modules->getDisabledModules(); 1430 if (!isset($enabled[$id])) { 1431 throw new Exception(__('No such theme.')); 1432 } 1433 1434 # --BEHAVIOR-- themeBeforeActivate 1435 $this->core->callBehavior('themeBeforeActivate', $id); 1436 1437 $this->modules->activateModule($id); 1438 1439 # --BEHAVIOR-- themeAfterActivate 1440 $this->core->callBehavior('themeAfterActivate', $id); 1441 1442 dcPage::addSuccessNotice(__('Theme has been successfully activated.')); 1443 http::redirect($this->getURL()); 1444 } 1445 1446 elseif (!empty($_POST['deactivate'])) { 1447 1448 if (!$this->modules->moduleExists($id)) { 1449 throw new Exception(__('No such theme.')); 1450 } 1451 1452 $module = $this->modules->getModules($id); 1453 $module['id'] = $id; 1454 1455 if (!$module['root_writable']) { 1456 throw new Exception(__('You don\'t have permissions to deactivate this theme.')); 1457 } 1458 1459 # --BEHAVIOR-- themeBeforeDeactivate 1460 $this->core->callBehavior('themeBeforeDeactivate', $module); 1461 1462 $this->modules->deactivateModule($id); 1463 1464 # --BEHAVIOR-- themeAfterDeactivate 1465 $this->core->callBehavior('themeAfterDeactivate', $module); 1466 1467 dcPage::addSuccessNotice(__('Theme has been successfully deactivated.')); 1468 http::redirect($this->getURL()); 1469 } 1470 1471 elseif (!empty($_POST['delete'])) { 1472 1473 $disabled = $this->modules->getDisabledModules(); 1474 if (!isset($disabled[$id])) { 1475 1476 if (!$this->modules->moduleExists($id)) { 1477 throw new Exception(__('No such module.')); 1478 } 1479 1480 $module = $this->modules->getModules($id); 1481 $module['id'] = $id; 1482 1483 if (!$this->isDeletablePath($module['root'])) { 1484 throw new Exception(__("You don't have permissions to delete this theme.")); 1485 } 1486 1487 # --BEHAVIOR-- themeBeforeDelete 1488 $this->core->callBehavior('themeBeforeDelete', $module); 1489 1490 $this->modules->deleteModule($id); 1491 1492 # --BEHAVIOR-- themeAfterDelete 1493 $this->core->callBehavior('themeAfterDelete', $module); 1494 } 1495 else { 1496 $this->modules->deleteModule($id, true); 1497 } 1498 1499 dcPage::addSuccessNotice(__('Theme has been successfully deleted.')); 1500 http::redirect($this->getURL()); 1501 } 1502 1503 elseif (!empty($_POST['install'])) { 1504 1505 $updated = $this->store->get(); 1506 if (!isset($updated[$id])) { 1507 throw new Exception(__('No such theme.')); 1508 } 1509 1510 $module = $updated[$id]; 1511 $module['id'] = $id; 1512 1513 $dest = $this->getPath().'/'.basename($module['file']); 1514 1515 # --BEHAVIOR-- themeBeforeAdd 1516 $this->core->callBehavior('themeBeforeAdd', $module); 1517 1518 $ret_code = $this->store->process($module['file'], $dest); 1519 1520 # --BEHAVIOR-- themeAfterAdd 1521 $this->core->callBehavior('themeAfterAdd', $module); 1522 1523 dcPage::addSuccessNotice($ret_code == 2 ? 1524 __('Theme has been successfully updated.') : 1525 __('Theme has been successfully installed.') 1526 ); 1527 http::redirect($this->getURL()); 1528 } 1529 1530 elseif (!empty($_POST['update'])) { 1531 1532 $updated = $this->store->get(true); 1533 if (!isset($updated[$id])) { 1534 throw new Exception(__('No such theme.')); 1535 } 1536 1537 if (!$this->modules->moduleExists($id)) { 1538 throw new Exception(__('No such theme.')); 1539 } 1540 1541 $tab = count($updated) > 1 ? '' : '#themes'; 1542 1543 $module = $updated[$id]; 1544 $module['id'] = $id; 1545 1546 if (!self::$allow_multi_install) { 1547 $dest = $module['root'].'/../'.basename($module['file']); 1548 } 1549 else { 1550 $dest = $this->getPath().'/'.basename($module['file']); 1551 if ($module['root'] != $dest) { 1552 @file_put_contents($module['root'].'/_disabled', ''); 1553 } 1554 } 1555 1556 # --BEHAVIOR-- themeBeforeUpdate 1557 $this->core->callBehavior('themeBeforeUpdate', $module); 1558 1559 $this->store->process($module['file'], $dest); 1560 1561 # --BEHAVIOR-- themeAfterUpdate 1562 $this->core->callBehavior('themeAfterUpdate', $module); 1563 1564 dcPage::addSuccessNotice(__('Theme has been successfully updated.')); 1565 http::redirect($this->getURL().$tab); 1566 } 1567 else { 1568 1569 # --BEHAVIOR-- adminModulesListDoActions 1570 $this->core->callBehavior('adminModulesListDoActions', $this, $id, 'theme'); 1571 1572 } 1573 } 1574 # Manual actions 1575 elseif (!empty($_POST['upload_pkg']) && !empty($_FILES['pkg_file']) 1576 || !empty($_POST['fetch_pkg']) && !empty($_POST['pkg_url'])) 1577 { 1578 if (empty($_POST['your_pwd']) || !$this->core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY, $_POST['your_pwd']))) { 1579 throw new Exception(__('Password verification failed')); 1580 } 1581 1582 if (!empty($_POST['upload_pkg'])) { 1583 files::uploadStatus($_FILES['pkg_file']); 1584 1585 $dest = $this->getPath().'/'.$_FILES['pkg_file']['name']; 1586 if (!move_uploaded_file($_FILES['pkg_file']['tmp_name'], $dest)) { 1587 throw new Exception(__('Unable to move uploaded file.')); 1588 } 1589 } 1590 else { 1591 $url = urldecode($_POST['pkg_url']); 1592 $dest = $this->getPath().'/'.basename($url); 1593 $this->store->download($url, $dest); 1594 } 1595 1596 # --BEHAVIOR-- themeBeforeAdd 1597 $this->core->callBehavior('themeBeforeAdd', null); 1598 1599 $ret_code = $this->store->install($dest); 1600 1601 # --BEHAVIOR-- themeAfterAdd 1602 $this->core->callBehavior('themeAfterAdd', null); 1603 1604 dcPage::addSuccessNotice($ret_code == 2 ? 1605 __('Theme has been successfully updated.') : 1606 __('Theme has been successfully installed.') 1607 ); 1608 http::redirect($this->getURL().'#themes'); 1609 } 1610 1611 return null; 1425 1612 } 1426 1613 }
Note: See TracChangeset
for help on using the changeset viewer.