Dotclear


Ignore:
Timestamp:
10/15/13 18:18:02 (12 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
2.6
Message:

Better split of modules terms, aka plugin vs theme, fixed #1772

File:
1 edited

Legend:

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

    r2354 r2377  
    349349               # Letter having modules 
    350350               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]); 
    352352                    $buttons[] = '<li class="btn" title="'.$title.'"><a href="'.$this->getURL('m_nav='.$char).'" title="'.$title.'"> '.$char.' </a></li>'; 
    353353               } 
    354354               # Letter without modules 
    355355               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>'; 
    357357               } 
    358358          } 
     
    524524          '<div class="table-outer">'. 
    525525          '<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>'; 
    527527 
    528528          if (in_array('name', $cols)) { 
     
    633633                    '<td class="module-distrib">'.(self::isDistributedModule($id) ?  
    634634                         '<img src="images/dotclear_pw.png" alt="'. 
    635                          __('Module from official distribution').'" title="'. 
    636                          __('module from official distribution').'" />'  
     635                         __('Plugin from official distribution').'" title="'. 
     636                         __('Plugin from official distribution').'" />'  
    637637                    : '').'</td>'; 
    638638               } 
     
    729729          if(!$count && $this->getSearch() === null) { 
    730730               echo  
    731                '<p class="message">'.__('No module matches your search.').'</p>'; 
     731               '<p class="message">'.__('No plugins matched your search.').'</p>'; 
    732732          } 
    733733 
     
    804804      * @note  Set a notice on success through dcPage::addSuccessNotice 
    805805      * @throw Exception Module not find or command failed 
    806       * @param string    $prefix        Prefix used on behaviors 
    807806      * @return     Null 
    808807      */ 
    809      public function doActions($prefix) 
     808     public function doActions() 
    810809     { 
    811810          if (empty($_POST) || !empty($_REQUEST['conf'])  
     
    823822                    $enabled = $this->modules->getDisabledModules(); 
    824823                    if (!isset($enabled[$id])) { 
    825                          throw new Exception(__('No such module.')); 
     824                         throw new Exception(__('No such plugin.')); 
    826825                    } 
    827826 
    828827                    # --BEHAVIOR-- moduleBeforeActivate 
    829                     $this->core->callBehavior($prefix.'BeforeActivate', $id); 
     828                    $this->core->callBehavior('pluginBeforeActivate', $id); 
    830829 
    831830                    $this->modules->activateModule($id); 
    832831 
    833832                    # --BEHAVIOR-- moduleAfterActivate 
    834                     $this->core->callBehavior($prefix.'AfterActivate', $id); 
    835  
    836                     dcPage::addSuccessNotice(__('Module has been successfully activated.')); 
     833                    $this->core->callBehavior('pluginAfterActivate', $id); 
     834 
     835                    dcPage::addSuccessNotice(__('Plugin has been successfully activated.')); 
    837836                    http::redirect($this->getURL()); 
    838837               } 
     
    841840 
    842841                    if (!$this->modules->moduleExists($id)) { 
    843                          throw new Exception(__('No such module.')); 
     842                         throw new Exception(__('No such plugin.')); 
    844843                    } 
    845844 
     
    848847 
    849848                    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.')); 
    851850                    } 
    852851 
    853852                    # --BEHAVIOR-- moduleBeforeDeactivate 
    854                     $this->core->callBehavior($prefix.'BeforeDeactivate', $module); 
     853                    $this->core->callBehavior('pluginBeforeDeactivate', $module); 
    855854 
    856855                    $this->modules->deactivateModule($id); 
    857856 
    858857                    # --BEHAVIOR-- moduleAfterDeactivate 
    859                     $this->core->callBehavior($prefix.'AfterDeactivate', $module); 
    860  
    861                     dcPage::addSuccessNotice(__('Module has been successfully deactivated.')); 
     858                    $this->core->callBehavior('pluginAfterDeactivate', $module); 
     859 
     860                    dcPage::addSuccessNotice(__('Plugin has been successfully deactivated.')); 
    862861                    http::redirect($this->getURL()); 
    863862               } 
     
    869868 
    870869                         if (!$this->modules->moduleExists($id)) { 
    871                               throw new Exception(__('No such module.')); 
     870                              throw new Exception(__('No such plugin.')); 
    872871                         } 
    873872 
     
    876875 
    877876                         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.")); 
    879878                         } 
    880879 
    881880                         # --BEHAVIOR-- moduleBeforeDelete 
    882                          $this->core->callBehavior($prefix.'BeforeDelete', $module); 
     881                         $this->core->callBehavior('pluginBeforeDelete', $module); 
    883882 
    884883                         $this->modules->deleteModule($id); 
    885884 
    886885                         # --BEHAVIOR-- moduleAfterDelete 
    887                          $this->core->callBehavior($prefix.'AfterDelete', $module); 
     886                         $this->core->callBehavior('pluginAfterDelete', $module); 
    888887                    } 
    889888                    else { 
     
    891890                    } 
    892891 
    893                     dcPage::addSuccessNotice(__('Module has been successfully deleted.')); 
     892                    dcPage::addSuccessNotice(__('Plugin has been successfully deleted.')); 
    894893                    http::redirect($this->getURL()); 
    895894               } 
     
    899898                    $updated = $this->store->get(); 
    900899                    if (!isset($updated[$id])) { 
    901                          throw new Exception(__('No such module.')); 
     900                         throw new Exception(__('No such plugin.')); 
    902901                    } 
    903902 
     
    908907 
    909908                    # --BEHAVIOR-- moduleBeforeAdd 
    910                     $this->core->callBehavior($prefix.'BeforeAdd', $module); 
     909                    $this->core->callBehavior('pluginBeforeAdd', $module); 
    911910 
    912911                    $ret_code = $this->store->process($module['file'], $dest); 
    913912 
    914913                    # --BEHAVIOR-- moduleAfterAdd 
    915                     $this->core->callBehavior($prefix.'AfterAdd', $module); 
     914                    $this->core->callBehavior('pluginAfterAdd', $module); 
    916915 
    917916                    dcPage::addSuccessNotice($ret_code == 2 ? 
    918                          __('Module has been successfully updated.') : 
    919                          __('Module has been successfully installed.') 
     917                         __('Plugin has been successfully updated.') : 
     918                         __('Plugin has been successfully installed.') 
    920919                    ); 
    921920                    http::redirect($this->getURL()); 
     
    926925                    $updated = $this->store->get(true); 
    927926                    if (!isset($updated[$id])) { 
    928                          throw new Exception(__('No such module.')); 
     927                         throw new Exception(__('No such plugin.')); 
    929928                    } 
    930929 
    931930                    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'; 
    936935 
    937936                    $module = $updated[$id]; 
     
    949948 
    950949                    # --BEHAVIOR-- moduleBeforeUpdate 
    951                     $this->core->callBehavior($prefix.'BeforeUpdate', $module); 
     950                    $this->core->callBehavior('pluginBeforeUpdate', $module); 
    952951 
    953952                    $this->store->process($module['file'], $dest); 
    954953 
    955954                    # --BEHAVIOR-- moduleAfterUpdate 
    956                     $this->core->callBehavior($prefix.'AfterUpdate', $module); 
    957  
    958                     dcPage::addSuccessNotice(__('Module has been successfully updated.')); 
     955                    $this->core->callBehavior('pluginAfterUpdate', $module); 
     956 
     957                    dcPage::addSuccessNotice(__('Plugin has been successfully updated.')); 
    959958                    http::redirect($this->getURL().$tab); 
    960959               } 
     
    962961 
    963962                    # --BEHAVIOR-- adminModulesListDoActions 
    964                     $this->core->callBehavior('adminModulesListDoActions', $this, $id, $prefix); 
     963                    $this->core->callBehavior('adminModulesListDoActions', $this, $id, 'plugin'); 
    965964 
    966965               } 
     
    989988 
    990989               # --BEHAVIOR-- moduleBeforeAdd 
    991                $this->core->callBehavior($prefix.'BeforeAdd', null); 
     990               $this->core->callBehavior('pluginBeforeAdd', null); 
    992991 
    993992               $ret_code = $this->store->install($dest); 
    994993 
    995994               # --BEHAVIOR-- moduleAfterAdd 
    996                $this->core->callBehavior($prefix.'AfterAdd', null); 
     995               $this->core->callBehavior('pluginAfterAdd', null); 
    997996 
    998997               dcPage::addSuccessNotice($ret_code == 2 ? 
    999                     __('Module has been successfully updated.') : 
    1000                     __('Module has been successfully installed.') 
     998                    __('Plugin has been successfully updated.') : 
     999                    __('Plugin has been successfully installed.') 
    10011000               ); 
    1002                http::redirect($this->getURL().'#'.$prefix); 
     1001               http::redirect($this->getURL().'#plugins'); 
    10031002          } 
    10041003 
     
    10741073 
    10751074          if (!$this->modules->moduleExists($id)) { 
    1076                $this->core->error->add(__('Unknow module ID')); 
     1075               $this->core->error->add(__('Unknow plugin ID')); 
    10771076               return false; 
    10781077          } 
     
    10831082 
    10841083          if (!file_exists($file)) { 
    1085                $this->core->error->add(__('This module has no configuration file.')); 
     1084               $this->core->error->add(__('This plugin has no configuration file.')); 
    10861085               return false; 
    10871086          } 
     
    11461145                    echo 
    11471146                    '<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>'. 
    11491148                    '<p><a class="back" href="'.$this->getRedir().'">'.__('Back').'</a></p>'; 
    11501149               } 
     
    13771376          if(!$count && $this->getSearch() === null) { 
    13781377               echo  
    1379                '<p class="message">'.__('No module matches your search.').'</p>'; 
     1378               '<p class="message">'.__('No themes matched your search.').'</p>'; 
    13801379          } 
    13811380     } 
     
    14011400     } 
    14021401 
    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'])) { 
    14101415 
    14111416                    if (!$this->modules->moduleExists($id)) { 
    1412                          throw new Exception(__('No such module.')); 
     1417                         throw new Exception(__('No such theme.')); 
    14131418                    } 
    14141419 
     
    14171422                    $this->core->blog->triggerBlog(); 
    14181423 
    1419                     dcPage::addSuccessNotice(__('Module has been successfully selected.')); 
     1424                    dcPage::addSuccessNotice(__('Theme has been successfully selected.')); 
    14201425                    http::redirect($this->getURL().'#themes'); 
    14211426               } 
    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; 
    14251612     } 
    14261613} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map