Changes in [2162:ff2e89cb94bb:2164:ea097afa23e4]
- Files:
-
- 6 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/js/_plugins.js
r0 r2157 1 dotclear.moduleExpander = function(line) { 2 var td = line.firstChild; 3 4 var img = document.createElement('img'); 5 img.src = dotclear.img_plus_src; 6 img.alt = dotclear.img_plus_alt; 7 img.className = 'expand'; 8 $(img).css('cursor','pointer'); 9 img.line = line; 10 img.onclick = function() { dotclear.viewModuleContent(this,this.line); }; 11 12 td.insertBefore(img,td.firstChild); 13 }; 14 15 dotclear.modulesExpander = function(line,lines) { 16 var td = line.firstChild; 17 18 var img = document.createElement('img'); 19 img.src = dotclear.img_plus_src; 20 img.alt = dotclear.img_plus_alt; 21 img.className = 'expand'; 22 $(img).css('cursor','pointer'); 23 img.lines = lines; 24 img.onclick = function() { dotclear.viewModulesContent(this,this.lines); }; 25 26 td.insertBefore(img,td.firstChild); 27 }; 28 29 dotclear.viewModulesContent = function(img,lines) { 30 31 action = 'toggle'; 32 33 if (img.alt == dotclear.img_plus_alt) { 34 img.src = dotclear.img_minus_src; 35 img.alt = dotclear.img_minus_alt; 36 action = 'open'; 37 } else { 38 img.src = dotclear.img_plus_src; 39 img.alt = dotclear.img_plus_alt; 40 action = 'close'; 41 } 42 43 lines.each(function() { 44 var td = this.firstChild; 45 dotclear.viewModuleContent(td.firstChild,td.firstChild.line,action); 46 }); 47 }; 48 49 dotclear.viewModuleContent = function(img,line,action) { 50 51 var action = action || 'toggle'; 52 var cols = $('td',$(line)).length 53 var sp = line.id.split('_m_'); 54 var listId=sp[0]; 55 var moduleId= sp[1]; 56 57 var tr = document.getElementById('pe'+moduleId); 58 59 if ( !tr && ( action == 'toggle' || action == 'open' ) ) { 60 tr = document.createElement('tr'); 61 tr.id = 'pe'+moduleId; 62 63 var td = document.createElement('td'); 64 td.colSpan = cols; 65 td.className = 'expand'; 66 tr.appendChild(td); 67 68 img.src = dotclear.img_minus_src; 69 img.alt = dotclear.img_minus_alt; 70 71 // Get post content 72 $.get('services.php',{f:'getModuleById', id: moduleId, list: listId},function(data) { 73 var rsp = $(data).children('rsp')[0]; 74 75 if (rsp.attributes[0].value == 'ok') { 76 var author = $(rsp).find('author').text(); 77 var details = $(rsp).find('details').text(); 78 var support = $(rsp).find('support').text(); 79 var box = document.createElement('div'); 80 var dl = document.createElement('ul'); 81 dl.className = "mod-more"; 82 83 if (author) { 84 $(dl).append($('<li>'+dotclear.msg.module_author+' '+author+'</li>')); 85 } 86 if (details) { 87 var dd = ''; 88 dd += '<a class="details" href="'+details+'">'+dotclear.msg.module_details+'</a>'; 89 if (support) { 90 dd += ' - '; 91 dd += '<a class="support" href="'+support+'">'+dotclear.msg.module_support+'</a>'; 92 } 93 $(dl).append($('<li>'+dotclear.msg.module_help+' '+dd+'</li>')); 94 } 95 96 $(td).append($(box).addClass('two-boxes').append(dl)); 97 98 var section = $(rsp).find('section').text(); 99 var tags = $(rsp).find('tags').text(); 100 101 var boxb = document.createElement('div'); 102 var dlb = document.createElement('ul'); 103 dlb.className = "mod-more"; 104 105 if (section) { 106 $(dlb).append($('<li>'+dotclear.msg.module_section+' '+section+'</li>')); 107 } 108 if (tags) { 109 $(dlb).append($('<li>'+dotclear.msg.module_tags+' '+tags+'</li>')); 110 } 111 $(td).append($(boxb).addClass('two-boxes').append(dlb)); 112 } else { 113 alert($(rsp).find('message').text()); 114 } 115 }); 116 117 $(line).addClass('expand'); 118 line.parentNode.insertBefore(tr,line.nextSibling); 119 } 120 else if (tr && tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) ) 121 { 122 $(tr).css('display', 'table-row'); 123 $(line).addClass('expand'); 124 img.src = dotclear.img_minus_src; 125 img.alt = dotclear.img_minus_alt; 126 } 127 else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) ) 128 { 129 $(tr).css('display', 'none'); 130 $(line).removeClass('expand'); 131 img.src = dotclear.img_plus_src; 132 img.alt = dotclear.img_plus_alt; 133 } 134 135 parentTable = $(line).parents('table'); 136 if( parentTable.find('tr.expand').length == parentTable.find('tr.line').length ) { 137 img = parentTable.find('tr:not(.line) th:first img'); 138 img.attr('src',dotclear.img_minus_src); 139 img.attr('alt',dotclear.img_minus_alt); 140 } 141 142 if( parentTable.find('tr.expand').length == 0 ) { 143 img = parentTable.find('tr:not(.line) th:first img'); 144 img.attr('src',dotclear.img_plus_src); 145 img.attr('alt',dotclear.img_plus_alt); 146 } 147 148 }; 149 150 1 151 $(function() { 2 $('table.plugins form input[type=submit][name=delete]').click(function() { 3 var p_name = $('input[name=plugin_id]',$(this).parent()).val(); 4 return window.confirm(dotclear.msg.confirm_delete_plugin.replace('%s',p_name)); 5 }); 152 $('table.modules.expandable tr:not(.line)').each(function() { 153 dotclear.modulesExpander(this,$('table.modules tr.line')); 154 }); 155 $('table.modules.expandable tr.line').each(function() { 156 dotclear.moduleExpander(this); 157 }); 6 158 }); -
admin/plugins.php
r2007 r2163 13 13 require dirname(__FILE__).'/../inc/admin/prepend.php'; 14 14 15 dcPage::checkSuper(); 16 17 $default_tab = !empty($_REQUEST['tab']) ? html::escapeHTML($_REQUEST['tab']) : 'plugins'; 18 19 $p_paths = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT); 20 $p_path = array_pop($p_paths); 21 unset($p_paths); 22 23 $is_writable = false; 24 if (is_dir($p_path) && is_writeable($p_path)) { 25 $is_writable = true; 26 $p_path_pat = preg_quote($p_path,'!'); 27 } 28 29 $plugin_id = !empty($_POST['plugin_id']) ? $_POST['plugin_id'] : null; 30 31 if ($is_writable) 32 { 33 # Delete plugin 34 if ($plugin_id && !empty($_POST['delete'])) 35 { 36 try 37 { 38 if (empty($_POST['deactivated'])) 39 { 40 if (!$core->plugins->moduleExists($plugin_id)) { 41 throw new Exception(__('No such plugin.')); 42 } 43 44 $plugin = $core->plugins->getModules($plugin_id); 45 $plugin['id'] = $plugin_id; 46 47 if (!preg_match('!^'.$p_path_pat.'!', $plugin['root'])) { 48 throw new Exception(__('You don\'t have permissions to delete this plugin.')); 49 } 50 51 # --BEHAVIOR-- pluginBeforeDelete 52 $core->callBehavior('pluginsBeforeDelete', $plugin); 53 54 $core->plugins->deleteModule($plugin_id); 55 56 # --BEHAVIOR-- pluginAfterDelete 57 $core->callBehavior('pluginsAfterDelete', $plugin); 58 } 59 else 60 { 61 $core->plugins->deleteModule($plugin_id,true); 62 } 63 64 http::redirect('plugins.php?removed=1'); 65 } 66 catch (Exception $e) 67 { 68 $core->error->add($e->getMessage()); 69 } 70 } 71 # Deactivate plugin 72 elseif ($plugin_id && !empty($_POST['deactivate'])) 73 { 74 try 75 { 76 if (!$core->plugins->moduleExists($plugin_id)) { 77 throw new Exception(__('No such plugin.')); 78 } 79 80 $plugin = $core->plugins->getModules($plugin_id); 81 $plugin['id'] = $plugin_id; 82 83 if (!$plugin['root_writable']) { 84 throw new Exception(__('You don\'t have permissions to deactivate this plugin.')); 85 } 86 87 # --BEHAVIOR-- pluginBeforeDeactivate 88 $core->callBehavior('pluginsBeforeDeactivate', $plugin); 89 90 $core->plugins->deactivateModule($plugin_id); 91 92 # --BEHAVIOR-- pluginAfterDeactivate 93 $core->callBehavior('pluginsAfterDeactivate', $plugin); 94 95 http::redirect('plugins.php'); 96 } 97 catch (Exception $e) 98 { 99 $core->error->add($e->getMessage()); 100 } 101 } 102 # Activate plugin 103 elseif ($plugin_id && !empty($_POST['activate'])) 104 { 105 try 106 { 107 $p = $core->plugins->getDisabledModules(); 108 if (!isset($p[$plugin_id])) { 109 throw new Exception(__('No such plugin.')); 110 } 111 112 # --BEHAVIOR-- pluginBeforeActivate 113 $core->callBehavior('pluginsBeforeActivate', $plugin_id); 114 115 $core->plugins->activateModule($plugin_id); 116 117 # --BEHAVIOR-- pluginAfterActivate 118 $core->callBehavior('pluginsAfterActivate', $plugin_id); 119 120 http::redirect('plugins.php'); 121 } 122 catch (Exception $e) 123 { 124 $core->error->add($e->getMessage()); 125 } 126 } 15 dcPage::check('admin'); 16 17 # -------------------------------------------------- 18 # @todo Add settings to Dotclear update features 19 if ($core->blog->settings->system->plugins_allow_multi_install === null) { 20 $core->blog->settings->system->put( 21 'plugins_allow_multi_install', false, 'boolean', 'Allow multi-installation for plugins', true, true 22 ); 23 } 24 if ($core->blog->settings->system->repository_plugin_url === null) { 25 $core->blog->settings->system->put( 26 'repository_plugin_url', 'http://update.dotaddict.org/dc2/plugins.xml', 'string', 'Plugins XML feed location', true, true 27 ); 28 } 29 # -------------------------------------------------- 30 31 # -- Repository helper -- 32 $repository = new dcRepository( 33 $core->plugins, 34 $core->blog->settings->system->repository_plugin_url 35 ); 36 $repository->check(); 37 38 # -- Page helper -- 39 $list = new adminModulesList( 40 $core, 41 DC_PLUGINS_ROOT, 42 $core->blog->settings->system->plugins_allow_multi_install 43 ); 44 45 46 # -- Check for module configuration -- 47 $conf_file = false; 48 if (!empty($_REQUEST['conf']) && !empty($_REQUEST['module'])) { 49 if (!$core->plugins->moduleExists($_REQUEST['module'])) { 50 $core->error->add(__('Unknow module ID')); 51 } 52 else { 53 $module = $core->plugins->getModules($_REQUEST['module']); 54 $module = adminModulesList::setModuleInfo($_REQUEST['module'], $module); 55 56 if (!file_exists(path::real($module['root'].'/_config.php'))) { 57 $core->error->add(__('This module has no configuration file.')); 58 } 59 else { 60 $conf_file = path::real($module['root'].'/_config.php'); 61 } 62 } 63 } 64 65 # -- Display module configuration page -- 66 if ($conf_file) { 67 dcPage::open(__('Plugins management'), 68 69 # --BEHAVIOR-- pluginsToolsHeaders 70 $core->callBehavior('pluginsToolsHeaders', $core, $module['id']), 71 72 dcPage::breadcrumb( 73 array( 74 html::escapeHTML($core->blog->name) => '', 75 '<a href="'.$list->getPageURL().'">'.__('Plugins management').'</a>' => '', 76 '<span class="page-title">'.__('Plugin configuration').'</span>' => '' 77 )) 78 ); 79 80 if (!empty($_GET['done'])){ 81 dcPage::success(__('Plugin successfully configured.')); 82 } 83 84 try { 85 if (!$module['standalone_config']) { 86 echo 87 '<form id="module_config" action="'.$list->getPageURL('conf=1').'" method="post" enctype="multipart/form-data">'. 88 '<h3>'.sprintf(__('Configure plugin "%s"'), html::escapeHTML($module['name'])).'</h3>'. 89 '<p><a class="back" href="'.$list->getPageURL().'#plugins">'.__('Back').'</a></p>'; 90 } 91 92 include $conf_file; 93 94 if (!$module['standalone_config']) { 95 echo 96 '<p class="clear"><input type="submit" name="save" value="'.__('Save').'" />'. 97 form::hidden('module', $module['id']). 98 $core->formNonce().'</p>'. 99 '</form>'; 100 } 101 } 102 catch (Exception $e) { 103 echo '<div class="error"><p>'.$e->getMessage().'</p></div>'; 104 } 105 106 dcPage::close(); 107 108 # Stop reading code here 109 return; 110 } 111 112 # -- Execute actions -- 113 if (empty($_POST['conf']) && $core->auth->isSuperAdmin() && $list->isPathWritable()) { 114 127 115 # Plugin upload 128 elseif ((!empty($_POST['upload_pkg']) && !empty($_FILES['pkg_file'])) ||116 if ((!empty($_POST['upload_pkg']) && !empty($_FILES['pkg_file'])) || 129 117 (!empty($_POST['fetch_pkg']) && !empty($_POST['pkg_url']))) 130 118 { 131 119 try 132 120 { 133 if (empty($_POST['your_pwd']) || !$core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY, $_POST['your_pwd']))) {121 if (empty($_POST['your_pwd']) || !$core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY, $_POST['your_pwd']))) { 134 122 throw new Exception(__('Password verification failed')); 135 123 } 136 124 137 if (!empty($_POST['upload_pkg'])) 138 { 125 if (!empty($_POST['upload_pkg'])) { 139 126 files::uploadStatus($_FILES['pkg_file']); 140 127 141 $dest = $ p_path.'/'.$_FILES['pkg_file']['name'];142 if (!move_uploaded_file($_FILES['pkg_file']['tmp_name'], $dest)) {128 $dest = $list->getPath().'/'.$_FILES['pkg_file']['name']; 129 if (!move_uploaded_file($_FILES['pkg_file']['tmp_name'], $dest)) { 143 130 throw new Exception(__('Unable to move uploaded file.')); 144 131 } 145 132 } 146 else 147 { 133 else { 148 134 $url = urldecode($_POST['pkg_url']); 149 $dest = $p_path.'/'.basename($url); 150 151 try 152 { 153 $client = netHttp::initClient($url,$path); 154 $client->setUserAgent('Dotclear - http://www.dotclear.org/'); 155 $client->useGzip(false); 156 $client->setPersistReferers(false); 157 $client->setOutput($dest); 158 $client->get($path); 159 } 160 catch( Exception $e) 161 { 162 throw new Exception(__('An error occurred while downloading the file.')); 163 } 164 165 unset($client); 135 $dest = $list->getPath().'/'.basename($url); 136 $repository->download($url, $dest); 166 137 } 167 138 … … 169 140 $core->callBehavior('pluginsBeforeAdd', $plugin_id); 170 141 171 $ret_code = $core->plugins->installPackage($dest, $core->plugins);142 $ret_code = $core->plugins->installPackage($dest, $core->plugins); 172 143 173 144 # --BEHAVIOR-- pluginAfterAdd 174 145 $core->callBehavior('pluginsAfterAdd', $plugin_id); 175 146 176 http::redirect('plugins.php?added='.$ret_code); 177 } 178 catch (Exception $e) 179 { 147 http::redirect('plugins.php?msg='.($ret_code == 2 ? 'update' : 'install').'#plugins'); 148 } 149 catch (Exception $e) { 180 150 $core->error->add($e->getMessage()); 181 $default_tab = 'addplugin'; 182 } 183 } 184 } 185 186 # Plugin install 187 $plugins_install = $core->plugins->installModules(); 188 189 /* DISPLAY Main page 190 -------------------------------------------------------- */ 151 } 152 } 153 elseif (!empty($_POST['module'])) { 154 try { 155 $list->executeAction('plugins', $core->plugins, $repository); 156 } 157 catch (Exception $e) { 158 $core->error->add($e->getMessage()); 159 } 160 } 161 } 162 163 # -- Plugin install -- 164 $plugins_install = null; 165 if (!$core->error->flag()) { 166 $plugins_install = $core->plugins->installModules(); 167 } 168 169 # -- Page header -- 191 170 dcPage::open(__('Plugins management'), 192 171 dcPage::jsLoad('js/_plugins.js'). 193 dcPage::jsPageTabs($default_tab), 172 dcPage::jsPageTabs(). 173 174 # --BEHAVIOR-- pluginsToolsHeaders 175 $core->callBehavior('pluginsToolsHeaders', $core, false), 176 194 177 dcPage::breadcrumb( 195 178 array( … … 199 182 ); 200 183 201 if (!empty($_GET['removed'])) { 202 dcPage::success(__('Plugin has been successfully deleted.')); 203 } 204 if (!empty($_GET['added'])) { 205 dcPage::success(($_GET['added'] == 2 ? __('Plugin has been successfully upgraded') : __('Plugin has been successfully installed.'))); 206 } 207 208 # Plugins install messages 209 if (!empty($plugins_install['success'])) 210 { 211 echo '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; 184 # -- Succes messages -- 185 if (!empty($_GET['msg'])) { 186 $list->displayMessage($_GET['msg'],__('Plugins')); 187 } 188 189 # -- Plugins install messages -- 190 if (!empty($plugins_install['success'])) { 191 echo 192 '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; 212 193 foreach ($plugins_install['success'] as $k => $v) { 213 echo '<li>'.$k.'</li>'; 214 } 215 echo '</ul></div>'; 216 } 217 if (!empty($plugins_install['failure'])) 218 { 219 echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 194 echo 195 '<li>'.$k.'</li>'; 196 } 197 echo 198 '</ul></div>'; 199 } 200 if (!empty($plugins_install['failure'])) { 201 echo 202 '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 220 203 foreach ($plugins_install['failure'] as $k => $v) { 221 echo '<li>'.$k.' ('.$v.')</li>'; 222 } 223 echo '</ul></div>'; 204 echo 205 '<li>'.$k.' ('.$v.')</li>'; 206 } 207 echo 208 '</ul></div>'; 209 } 210 211 # -- Display modules lists -- 212 if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { 213 214 # Updated modules from repo 215 $modules = $repository->get(true); 216 if (!empty($modules)) { 217 echo 218 '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update plugins')).'">'. 219 '<h3>'.html::escapeHTML(__('Update plugins')).'</h3>'. 220 '<p>'.sprintf( 221 __('There is one plugin to update available from %2$s.', 'There are %s plugins to update available from %s.', count($modules)), 222 count($modules), 223 '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>' 224 ).'</p>'; 225 226 $list 227 ->newList('plugin-update') 228 ->setModules($modules) 229 ->setPageTab('update') 230 ->displayModulesList( 231 /*cols */ array('icon', 'name', 'version', 'current_version', 'desc'), 232 /* actions */ array('update') 233 ); 234 235 echo 236 '</div>'; 237 } 224 238 } 225 239 226 240 # List all active plugins 227 echo '<p>'.__('Plugins add new functionalities to Dotclear. '.228 'Here you can activate or deactivate installed plugins.').'</p>';229 230 echo (!$core->plugins->moduleExists('daInstaller') ?231 sprintf('<p><strong>'.__('You can find additional plugins for your blog on %s.').'</strong></p>',232 '<a href="http://plugins.dotaddict.org/dc2/">Dotaddict</a>') :233 sprintf('<p><strong>'.__('You can find additional plugins for your blog on %s or using the %s.').'</strong></p>',234 '<a href="http://plugins.dotaddict.org/dc2/">Dotaddict</a>',235 '<a href="plugin.php?p=daInstaller">'.__('DotAddict.org Installer').'</a>'));236 237 if ($is_writable) {238 echo '<p>'.__('To install or upgrade a plugin you generally just need to upload it '.239 'in "Install or upgrade a plugin" section.');240 } else {241 echo '<p>'.__('To install or upgrade a plugin you just need to extract it in your plugins directory.');242 }243 echo '</p>';244 245 241 echo 246 '<div class="multi-part" id="plugins" title="'.__('Plugins').'">'; 247 248 $p_available = $core->plugins->getModules(); 249 uasort($p_available,create_function('$a,$b','return strcasecmp($a["name"],$b["name"]);')); 250 if (!empty($p_available)) 251 { 242 '<div class="multi-part" id="plugins" title="'.__('Installed plugins').'">'; 243 244 $modules = $core->plugins->getModules(); 245 if (!empty($modules)) { 246 252 247 echo 253 248 '<h3>'.__('Activated plugins').'</h3>'. 254 '<div class="table-outer clear">'. 255 '<table class="plugins"><tr>'. 256 '<th>'.__('Plugin').'</th>'. 257 '<th class="nowrap">'.__('Version').'</th>'. 258 '<th class="nowrap">'.__('Details').'</th>'. 259 '<th class="nowrap">'.__('Action').'</th>'. 260 '</tr>'; 261 262 $distrib_plugins = array('aboutConfig','akismet','antispam','attachments','blogroll','blowupConfig','daInstaller', 263 'fairTrackbacks','importExport','maintenance','pages','pings','simpleMenu','tags','themeEditor','userPref','widgets'); 264 $distrib_img = '<img src="images/dotclear_pw.png"'. 265 ' alt="'.__('Plugin from official distribution').'" title="'.__('Plugin from official distribution').'" />'; 266 267 foreach ($p_available as $k => $v) 268 { 269 $is_deletable = $is_writable && preg_match('!^'.$p_path_pat.'!',$v['root']); 270 $is_deactivable = $v['root_writable']; 271 $is_distrib = in_array($k, $distrib_plugins); 272 273 echo 274 '<tr class="line wide">'. 275 '<td class="minimal nowrap"><strong>'.html::escapeHTML($k).'</strong></td>'. 276 '<td class="minimal">'.html::escapeHTML($v['version']).'</td>'. 277 '<td class="maximal'.($is_distrib ? ' distrib' : '').'"><strong>'.html::escapeHTML(__($v['name'])).'</strong> '. 278 '<br />'.html::escapeHTML(__($v['desc'])).($is_distrib ? ' '.$distrib_img : '').'</td>'. 279 '<td class="nowrap action">'; 280 281 if ($is_deletable || $is_deactivable) 282 { 283 echo 284 '<form action="plugins.php" method="post">'. 285 '<div>'. 286 $core->formNonce(). 287 form::hidden(array('plugin_id'),html::escapeHTML($k)). 288 ($is_deactivable ? '<input type="submit" name="deactivate" value="'.__('Deactivate').'" /> ' : ''). 289 ($is_deletable ? '<input type="submit" class="delete" name="delete" value="'.__('Delete').'" /> ' : ''). 290 '</div>'. 291 '</form>'; 292 } 293 294 echo 295 '</td>'. 296 '</tr>'; 297 } 298 echo 299 '</table></div>'; 300 } 301 302 $p_disabled = $core->plugins->getDisabledModules(); 303 uksort($p_disabled,create_function('$a,$b','return strcasecmp($a,$b);')); 304 if (!empty($p_disabled)) 305 { 249 '<p>'.__('Manage installed plugins from this list.').'</p>'; 250 251 $list 252 ->newList('plugin-activate') 253 ->setModules($modules) 254 ->setPageTab('plugins') 255 ->displayModulesList( 256 /* cols */ array('expander', 'icon', 'name', 'config', 'version', 'desc', 'distrib'), 257 /* actions */ array('deactivate', 'delete') 258 ); 259 } 260 261 # Deactivated modules 262 $modules = $core->plugins->getDisabledModules(); 263 if (!empty($modules)) { 264 306 265 echo 307 266 '<h3>'.__('Deactivated plugins').'</h3>'. 308 '<div class="clear table-outer">'. 309 '<table class="plugins"><tr>'. 310 '<th>'.__('Plugin').'</th>'. 311 '<th class="nowrap">'.__('Action').'</th>'. 312 '</tr>'; 313 314 foreach ($p_disabled as $k => $v) 315 { 316 $is_deletable = $is_writable && preg_match('!^'.$p_path_pat.'!',$v['root']); 317 $is_activable = $v['root_writable']; 318 319 echo 320 '<tr class="line wide">'. 321 '<td class="maximal nowrap"><strong>'.html::escapeHTML($k).'</strong></td>'. 322 '<td class="nowrap action">'; 323 324 if ($is_deletable || $is_activable) 325 { 326 echo 327 '<form action="plugins.php" method="post">'. 328 '<div>'. 329 $core->formNonce(). 330 form::hidden(array('plugin_id'),html::escapeHTML($k)). 331 form::hidden(array('deactivated'),1). 332 ($is_activable ? '<input type="submit" name="activate" value="'.__('Activate').'" /> ' : ''). 333 ($is_deletable ? '<input type="submit" class="delete" name="delete" value="'.__('Delete').'" /> ' : ''). 334 '</div>'. 335 '</form>'; 336 } 337 338 echo 339 '</td>'. 340 '</tr>'; 341 } 342 echo 343 '</table></div>'; 344 } 345 346 echo '</div>'; 347 348 # Add a new plugin 349 echo 350 '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade a plugin').'">'; 351 352 if ($is_writable) 353 { 267 '<p>'.__('Deactivated plugins are installed but not usable. You can activate them from here.').'</p>'; 268 269 $list 270 ->newList('plugin-deactivate') 271 ->setModules($modules) 272 ->setPageTab('plugins') 273 ->displayModulesList( 274 /* cols */ array('icon', 'name', 'distrib'), 275 /* actions */ array('activate', 'delete') 276 ); 277 } 278 279 echo 280 '</div>'; 281 282 if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { 283 284 # New modules from repo 285 $search = $list->getSearchQuery(); 286 $modules = $search ? $repository->search($search) : $repository->get(); 287 288 echo 289 '<div class="multi-part" id="new" title="'.__('Add plugins from Dotaddict').'">'. 290 '<h3>'.__('Add plugins from Dotaddict repository').'</h3>'; 291 292 $list 293 ->newList('plugin-new') 294 ->setModules($modules) 295 ->setPageTab('new') 296 ->displaySearchForm() 297 ->displayNavMenu() 298 ->displayModulesList( 299 /* cols */ array('expander', 'name', 'version', 'desc'), 300 /* actions */ array('install'), 301 /* nav limit */ true 302 ); 303 304 echo 305 '<p class="info vertical-separator">'.sprintf( 306 __("Visit %s repository, the resources center for Dotclear."), 307 '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>' 308 ). 309 '</p>'. 310 311 '</div>'; 312 313 # Add a new plugin 314 echo 315 '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade manually').'">'; 316 354 317 echo '<p>'.__('You can install plugins by uploading or downloading zip files.').'</p>'; 355 318 … … 357 320 echo 358 321 '<form method="post" action="plugins.php" id="uploadpkg" enctype="multipart/form-data" class="fieldset">'. 359 '<h 3>'.__('Upload a zip file').'</h3>'.322 '<h4>'.__('Upload a zip file').'</h4>'. 360 323 '<p class="field"><label for="pkg_file" class="classic required"><abbr title="'.__('Required field').'">*</abbr> '.__('Plugin zip file:').'</label> '. 361 324 '<input type="file" id="pkg_file" name="pkg_file" /></p>'. … … 370 333 echo 371 334 '<form method="post" action="plugins.php" id="fetchpkg" class="fieldset">'. 372 '<h 3>'.__('Download a zip file').'</h3>'.335 '<h4>'.__('Download a zip file').'</h4>'. 373 336 '<p class="field"><label for="pkg_url" class="classic required"><abbr title="'.__('Required field').'">*</abbr> '.__('Plugin zip file URL:').'</label> '. 374 337 form::field(array('pkg_url','pkg_url'),40,255).'</p>'. … … 378 341 $core->formNonce().'</p>'. 379 342 '</form>'; 380 } 381 else 382 { 383 echo 384 '<p class="static-msg">'. 385 __('To enable this function, please give write access to your plugins directory.'). 386 '</p>'; 387 } 388 echo '</div>'; 343 344 echo 345 '</div>'; 346 } 389 347 390 348 # --BEHAVIOR-- pluginsToolsTabs 391 $core->callBehavior('pluginsToolsTabs',$core); 349 $core->callBehavior('pluginsToolsTabs', $core); 350 351 # -- Notice for super admin -- 352 if ($core->auth->isSuperAdmin() && !$list->isPathWritable()) { 353 echo 354 '<p class="warning">'.__('Some functions are disabled, please give write access to your plugins directory to enable them.').'</p>'; 355 } 392 356 393 357 dcPage::close(); -
admin/services.php
r1699 r2156 27 27 $core->rest->addFunction('searchMeta',array('dcRestMethods','searchMeta')); 28 28 $core->rest->addFunction('setSectionFold',array('dcRestMethods','setSectionFold')); 29 $core->rest->addFunction('getModuleById',array('dcRestMethods','getModuleById')); 29 30 30 31 $core->rest->serve(); … … 442 443 return true; 443 444 } 444 445 445 446 public static function getModuleById($core, $get, $post) 447 { 448 if (empty($get['id'])) { 449 throw new Exception('No module ID'); 450 } 451 if (empty($get['list'])) { 452 throw new Exception('No list ID'); 453 } 454 455 $id = $get['id']; 456 $list = $get['list']; 457 $module = array(); 458 459 if ($list == 'plugin-activate') { 460 $modules = $core->plugins->getModules(); 461 if (empty($modules) || !isset($modules[$id])) { 462 throw new Exception('Unknow module ID'); 463 } 464 $module = $modules[$id]; 465 } 466 elseif ($list == 'plugin-new') { 467 $repository = new dcRepository( 468 $core->plugins, 469 $core->blog->settings->system->repository_plugin_url 470 ); 471 $repository->check(); 472 473 $modules = $repository->get(); 474 if (empty($modules) || !isset($modules[$id])) { 475 throw new Exception('Unknow module ID'); 476 } 477 $module = $modules[$id]; 478 } 479 else { 480 // behavior not implemented yet 481 } 482 483 if (empty($module)) { 484 throw new Exception('Unknow module ID'); 485 } 486 487 $module = adminModulesList::setModuleInfo($id, $module); 488 489 $rsp = new xmlTag('module'); 490 $rsp->id = $id; 491 492 foreach($module as $k => $v) { 493 $rsp->{$k}((string) $v); 494 } 495 496 return $rsp; 497 } 446 498 } 447 499 ?> -
admin/style/default.css
r2152 r2164 1947 1947 } 1948 1948 /* -------------------------------------------------------------------- plugins.php */ 1949 #plugins td.action {1949 .modules td.action, .modules td.icon { 1950 1950 vertical-align: middle; 1951 1951 } 1952 .distrib img { 1952 .modules td.icon img:last-child { 1953 width: 16px; 1954 height: 16px; 1955 } 1956 .modules td.icon img.expand { 1957 margin-bottom: 3px; 1958 } 1959 .modules td.distrib img { 1953 1960 display: block; 1954 1961 float: right; 1955 margin-top: -1em; 1962 } 1963 .modules dt { 1964 font-weight: bold; 1965 } 1966 .modules a.details { 1967 background: transparent url(search.png) no-repeat 2px 2px; 1968 padding: 4px 4px 0 20px; 1969 } 1970 .modules a.support { 1971 background: transparent url(../images/page_help.png) no-repeat 2px 2px; 1972 padding: 4px 4px 0 20px; 1973 } 1974 #m_search { 1975 background: transparent url(search.png) no-repeat 4px center; 1976 padding-left: 20px; 1977 } 1978 .modules tr.expand, .modules td.expand { 1979 background: #f7f7f7; 1980 border-color: #bee74b; 1981 } 1982 .modules tr.expand td:first-child { 1983 font-weight: bold; 1984 background: #DFE5E7; 1985 } 1986 .modules td.expand { 1987 padding: 0; 1988 } 1989 .mod-more, .mod-more li { 1990 margin: .25em 0 0 1em; 1991 padding: 0; 1992 list-style-type: none; 1993 } 1994 .mod-more { 1995 padding-top: .5em; 1956 1996 } 1957 1997 /* ---------------------------------------------------------- post.php, page.php */ -
inc/admin/lib.dc.page.php
r2161 r2164 605 605 self::jsVar('dotclear.msg.load_enhanced_uploader', 606 606 __('Loading enhanced uploader, please wait.')). 607 608 self::jsVar('dotclear.msg.module_author', 609 __('Author:')). 610 self::jsVar('dotclear.msg.module_details', 611 __('Details')). 612 self::jsVar('dotclear.msg.module_support', 613 __('Support')). 614 self::jsVar('dotclear.msg.module_help', 615 __('Help:')). 616 self::jsVar('dotclear.msg.module_section', 617 __('Section:')). 618 self::jsVar('dotclear.msg.module_tags', 619 __('Tags:')). 607 620 "\n//]]>\n". 608 621 "</script>\n"; -
inc/prepend.php
r1999 r2147 46 46 $__autoload['dcWorkspace'] = dirname(__FILE__).'/core/class.dc.workspace.php'; 47 47 $__autoload['dcPrefs'] = dirname(__FILE__).'/core/class.dc.prefs.php'; 48 $__autoload['dcRepository'] = dirname(__FILE__).'/core/class.dc.repository.php'; 49 $__autoload['dcRepositoryReader'] = dirname(__FILE__).'/core/class.dc.repository.reader.php'; 50 $__autoload['dcRepositoryParser'] = dirname(__FILE__).'/core/class.dc.repository.parser.php'; 48 51 49 52 $__autoload['rsExtPost'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; … … 61 64 $__autoload['dcPager'] = dirname(__FILE__).'/admin/lib.pager.php'; 62 65 $__autoload['dcAdminCombos'] = dirname(__FILE__).'/admin/lib.admincombos.php'; 66 $__autoload['adminModulesList'] = dirname(__FILE__).'/admin/lib.moduleslist.php'; 67 $__autoload['adminThemesList'] = dirname(__FILE__).'/admin/lib.moduleslist.php'; 63 68 64 69 $__autoload['dcTemplate'] = dirname(__FILE__).'/public/class.dc.template.php'; -
plugins/maintenance/_admin.php
r2116 r2163 29 29 $core->addBehavior('adminAfterDashboardOptionsUpdate', array('dcMaintenanceAdmin', 'adminAfterDashboardOptionsUpdate')); 30 30 $core->addBehavior('adminPageHelpBlock', array('dcMaintenanceAdmin', 'adminPageHelpBlock')); 31 $core->addBehavior('pluginsToolsHeaders', array('dcMaintenanceAdmin', 'pluginsToolsHeaders')); 31 32 32 33 /** … … 222 223 $core->auth->user_prefs->maintenance->put('dashboard_item', !empty($_POST['maintenance_dashboard_item']), 'boolean'); 223 224 } 224 225 225 226 226 /** … … 293 293 } 294 294 } 295 296 /** 297 * Add javascript for plugin configuration. 298 * 299 * @param $core <b>dcCore</b> dcCore instance 300 * @param $module <b>mixed</b> Module ID or false if none 301 * @return <b>string</b> Header code for js inclusion 302 */ 303 public static function pluginsToolsHeaders($core, $module) 304 { 305 if ($module == 'maintenance') { 306 return dcPage::jsLoad('index.php?pf=maintenance/js/settings.js'); 307 } 308 } 295 309 } -
plugins/maintenance/index.php
r2051 r2163 27 27 $code = empty($_POST['code']) ? null : (integer) $_POST['code']; 28 28 $tab = empty($_REQUEST['tab']) ? '' : $_REQUEST['tab']; 29 30 // Save settings31 32 if (!empty($_POST['settings'])) {33 34 try {35 $core->blog->settings->maintenance->put(36 'plugin_message',37 !empty($_POST['settings_plugin_message']),38 'boolean',39 'Display alert message of late tasks on plugin page',40 true,41 true42 );43 44 foreach($tasks as $t) {45 if (!empty($_POST['settings_recall_type']) && $_POST['settings_recall_type'] == 'all') {46 $ts = $_POST['settings_recall_time'];47 }48 else {49 $ts = empty($_POST['settings_ts_'.$t->id()]) ? 0 : $_POST['settings_ts_'.$t->id()];50 }51 $core->blog->settings->maintenance->put(52 'ts_'.$t->id(),53 abs((integer) $ts),54 'integer',55 sprintf('Recall time for task %s', $t->id()),56 true,57 $t->blog()58 );59 }60 61 http::redirect($p_url.'&done=1&tab='.$tab.'#'.$tab);62 }63 catch(Exception $e) {64 $core->error->add($e->getMessage());65 }66 }67 29 68 30 // Get task object … … 287 249 '</div>'; 288 250 } 289 290 // Settings291 292 echo293 '<div id="settings" class="multi-part" title="'.__('Alert settings').'">'.294 '<h3>'.__('Alert settings').'</h3>'.295 '<form action="'.$p_url.'" method="post">'.296 297 '<h4 class="pretty-title">'.__('Activation').'</h4>'.298 '<p><label for="settings_plugin_message" class="classic">'.299 form::checkbox('settings_plugin_message', 1, $core->blog->settings->maintenance->plugin_message).300 __('Display alert messages on late tasks').'</label></p>'.301 302 '<p class="info">'.sprintf(303 __('You can place list of late tasks on your %s.'),304 '<a href="preferences.php#user-favorites">'.__('Dashboard').'</a>'305 ).'</p>'.306 307 '<h4 class="pretty-title vertical-separator">'.__('Frequency').'</h4>'.308 309 '<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_all'), 'all').' '.310 '<label class="classic" for="settings_recall_all">'.311 '<strong>'.__('Use one recall time for all tasks').'</strong></label>'.312 313 '<p class="field wide vertical-separator"><label for="settings_recall_time">'.__('Recall time for all tasks:').'</label>'.314 form::combo('settings_recall_time', $combo_ts, 'seperate', 'recall-for-all').315 '</p>'.316 317 '<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_separate'), 'separate', 1).' '.318 '<label class="classic" for="settings_recall_separate">'.319 '<strong>'.__('Use one recall time per task').'</strong></label>';320 321 foreach($tasks as $t)322 {323 echo324 '<div class="two-boxes">'.325 326 '<p class="field wide"><label for="settings_ts_'.$t->id().'">'.$t->task().'</label>'.327 form::combo('settings_ts_'.$t->id(), $combo_ts, $t->ts(), 'recall-per-task').328 '</p>'.329 330 '</div>';331 }332 333 echo334 '<p class="field wide"><input type="submit" value="'.__('Save this settings').'" /> '.335 form::hidden(array('tab'), 'settings').336 form::hidden(array('settings'), 1).337 $core->formNonce().'</p>'.338 '</form>'.339 '</div>';340 251 } 341 252
Note: See TracChangeset
for help on using the changeset viewer.