PageRenderTime 23ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/plugins.php

https://bitbucket.org/dotclear/dotclear/
PHP | 252 lines | 172 code | 48 blank | 32 comment | 18 complexity | 2af870d5358e259e76a15368067b9f4b MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, Apache-2.0
  1. <?php
  2. # -- BEGIN LICENSE BLOCK ---------------------------------------
  3. #
  4. # This file is part of Dotclear 2.
  5. #
  6. # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
  7. # Licensed under the GPL version 2.0 license.
  8. # See LICENSE file or
  9. # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  10. #
  11. # -- END LICENSE BLOCK -----------------------------------------
  12. require dirname(__FILE__).'/../inc/admin/prepend.php';
  13. dcPage::check('admin');
  14. # -- Page helper --
  15. $list = new adminModulesList(
  16. $core->plugins,
  17. DC_PLUGINS_ROOT,
  18. $core->blog->settings->system->store_plugin_url
  19. );
  20. adminModulesList::$allow_multi_install = (boolean) DC_ALLOW_MULTI_MODULES;
  21. adminModulesList::$distributed_modules = explode(',', DC_DISTRIB_PLUGINS);
  22. if ($core->plugins->disableDepModules($core->adminurl->get('admin.plugins',array()))) {
  23. exit;
  24. }
  25. # -- Display module configuration page --
  26. if ($list->setConfiguration()) {
  27. # Get content before page headers
  28. include $list->includeConfiguration();
  29. # Gather content
  30. $list->getConfiguration();
  31. # Display page
  32. dcPage::open(__('Plugins management'),
  33. # --BEHAVIOR-- pluginsToolsHeaders
  34. $core->callBehavior('pluginsToolsHeaders', $core, true),
  35. dcPage::breadcrumb(
  36. array(
  37. html::escapeHTML($core->blog->name) => '',
  38. __('Plugins management') => $list->getURL('',false),
  39. '<span class="page-title">'.__('Plugin configuration').'</span>' => ''
  40. ))
  41. );
  42. # Display previously gathered content
  43. $list->displayConfiguration();
  44. dcPage::helpBlock('core_plugins_conf');
  45. dcPage::close();
  46. # Stop reading code here
  47. return;
  48. }
  49. # -- Execute actions --
  50. try {
  51. $list->doActions();
  52. }
  53. catch (Exception $e) {
  54. $core->error->add($e->getMessage());
  55. }
  56. # -- Plugin install --
  57. $plugins_install = null;
  58. if (!$core->error->flag()) {
  59. $plugins_install = $core->plugins->installModules();
  60. }
  61. # -- Page header --
  62. dcPage::open(__('Plugins management'),
  63. dcPage::jsLoad('js/_plugins.js').
  64. dcPage::jsPageTabs().
  65. # --BEHAVIOR-- pluginsToolsHeaders
  66. $core->callBehavior('pluginsToolsHeaders', $core, false),
  67. dcPage::breadcrumb(
  68. array(
  69. __('System') => '',
  70. __('Plugins management') => ''
  71. ))
  72. );
  73. # -- Plugins install messages --
  74. if (!empty($plugins_install['success'])) {
  75. echo
  76. '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>';
  77. foreach ($plugins_install['success'] as $k => $v) {
  78. echo
  79. '<li>'.$k.'</li>';
  80. }
  81. echo
  82. '</ul></div>';
  83. }
  84. if (!empty($plugins_install['failure'])) {
  85. echo
  86. '<div class="error">'.__('Following plugins have not been installed:').'<ul>';
  87. foreach ($plugins_install['failure'] as $k => $v) {
  88. echo
  89. '<li>'.$k.' ('.$v.')</li>';
  90. }
  91. echo
  92. '</ul></div>';
  93. }
  94. # -- Display modules lists --
  95. if ($core->auth->isSuperAdmin()) {
  96. # Updated modules from repo
  97. $modules = $list->store->get(true);
  98. if (!empty($modules)) {
  99. echo
  100. '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update plugins')).'">'.
  101. '<h3>'.html::escapeHTML(__('Update plugins')).'</h3>'.
  102. '<p>'.sprintf(
  103. __('There is one plugin to update available from repository.', 'There are %s plugins to update available from repository.', count($modules)),
  104. count($modules)
  105. ).'</p>';
  106. $list
  107. ->setList('plugin-update')
  108. ->setTab('update')
  109. ->setModules($modules)
  110. ->displayModules(
  111. /*cols */ array('checkbox', 'icon', 'name', 'version', 'current_version', 'desc'),
  112. /* actions */ array('update')
  113. );
  114. echo
  115. '<p class="info vertical-separator">'.sprintf(
  116. __("Visit %s repository, the resources center for Dotclear."),
  117. '<a href="http://plugins.dotaddict.org/dc2/">Dotaddict</a>'
  118. ).
  119. '</p>'.
  120. '</div>';
  121. }
  122. }
  123. echo
  124. '<div class="multi-part" id="plugins" title="'.__('Installed plugins').'">';
  125. # Activated modules
  126. $modules = $list->modules->getModules();
  127. if (!empty($modules)) {
  128. echo
  129. '<h3>'.($core->auth->isSuperAdmin() ?__('Activated plugins') : __('Installed plugins')).'</h3>'.
  130. '<p>'.__('You can configure and manage installed plugins from this list.').'</p>';
  131. $list
  132. ->setList('plugin-activate')
  133. ->setTab('plugins')
  134. ->setModules($modules)
  135. ->displayModules(
  136. /* cols */ array('expander', 'icon', 'name', 'version', 'desc', 'distrib','deps'),
  137. /* actions */ array('deactivate', 'delete', 'behavior')
  138. );
  139. }
  140. # Deactivated modules
  141. if ($core->auth->isSuperAdmin()) {
  142. $modules = $list->modules->getDisabledModules();
  143. if (!empty($modules)) {
  144. echo
  145. '<h3>'.__('Deactivated plugins').'</h3>'.
  146. '<p>'.__('Deactivated plugins are installed but not usable. You can activate them from here.').'</p>';
  147. $list
  148. ->setList('plugin-deactivate')
  149. ->setTab('plugins')
  150. ->setModules($modules)
  151. ->displayModules(
  152. /* cols */ array('expander', 'icon', 'name', 'version', 'desc', 'distrib'),
  153. /* actions */ array('activate', 'delete')
  154. );
  155. }
  156. }
  157. echo
  158. '</div>';
  159. if ($core->auth->isSuperAdmin() && $list->isWritablePath()) {
  160. # New modules from repo
  161. $search = $list->getSearch();
  162. $modules = $search ? $list->store->search($search) : $list->store->get();
  163. if (!empty($search) || !empty($modules)) {
  164. echo
  165. '<div class="multi-part" id="new" title="'.__('Add plugins').'">'.
  166. '<h3>'.__('Add plugins from repository').'</h3>';
  167. // '<p>'.__('Search and install plugins directly from repository.').'</p>';
  168. $list
  169. ->setList('plugin-new')
  170. ->setTab('new')
  171. ->setModules($modules)
  172. ->displaySearch()
  173. ->displayIndex()
  174. ->displayModules(
  175. /* cols */ array('expander', 'name', 'score', 'version', 'desc','deps'),
  176. /* actions */ array('install'),
  177. /* nav limit */ true
  178. );
  179. echo
  180. '<p class="info vertical-separator">'.sprintf(
  181. __("Visit %s repository, the resources center for Dotclear."),
  182. '<a href="http://plugins.dotaddict.org/dc2/">Dotaddict</a>'
  183. ).
  184. '</p>'.
  185. '</div>';
  186. }
  187. # Add a new plugin
  188. echo
  189. '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade manually').'">'.
  190. '<h3>'.__('Add plugins from a package').'</h3>'.
  191. '<p>'.__('You can install plugins by uploading or downloading zip files.').'</p>';
  192. $list->displayManualForm();
  193. echo
  194. '</div>';
  195. }
  196. # --BEHAVIOR-- pluginsToolsTabs
  197. $core->callBehavior('pluginsToolsTabs', $core);
  198. # -- Notice for super admin --
  199. if ($core->auth->isSuperAdmin() && !$list->isWritablePath()) {
  200. echo
  201. '<p class="warning">'.__('Some functions are disabled, please give write access to your plugins directory to enable them.').'</p>';
  202. }
  203. dcPage::helpBlock('core_plugins');
  204. dcPage::close();