Changeset 2215:0775c8672865
- Timestamp:
- 10/02/13 17:00:38 (12 years ago)
- Branch:
- dcRepo
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/blog_theme.php
r2196 r2215 15 15 dcPage::check('admin'); 16 16 17 # -------------------------------------------------- 18 # @todo Add settings to Dotclear update features 17 # -- "First time" settings setup -- 19 18 if ($core->blog->settings->system->repository_theme_url === null) { 20 19 $core->blog->settings->system->put( … … 22 21 ); 23 22 } 24 # --------------------------------------------------25 23 26 24 # -- Loading themes -- … … 28 26 $core->themes->loadModules($core->blog->themes_path, null); 29 27 30 # -- Repositoryhelper --31 $ repository = new dcRepository(28 # -- Page helper -- 29 $list = new adminThemesList( 32 30 $core->themes, 31 $core->blog->themes_path, 33 32 $core->blog->settings->system->repository_theme_url 34 33 ); 35 $repository->check(); 36 37 # -- Page helper -- 38 $list = new adminThemesList( 39 $core, 40 $core->blog->themes_path, 41 false 34 $list::$distributed_modules = array( 35 'blueSilence', 36 'blowupConfig', 37 'customCSS', 38 'default', 39 'ductile' 42 40 ); 43 41 44 42 # -- Theme screenshot -- 45 if (!empty($_GET['shot']) && $core->themes->moduleExists($_GET['shot'])) 46 { 47 if (empty($_GET['src'])) { 48 $f = $core->blog->themes_path.'/'.$_GET['shot'].'/screenshot.jpg'; 49 } else { 50 $f = $core->blog->themes_path.'/'.$_GET['shot'].'/'.path::clean($_GET['src']); 51 } 52 53 $f = path::real($f); 54 43 if (!empty($_GET['shot']) && $list->modules->moduleExists($_GET['shot'])) { 44 45 $f= path::real(empty($_GET['src']) ? 46 $core->blog->themes_path.'/'.$_GET['shot'].'/screenshot.jpg' : 47 $core->blog->themes_path.'/'.$_GET['shot'].'/'.path::clean($_GET['src']) 48 ); 49 55 50 if (!file_exists($f)) { 56 51 $f = dirname(__FILE__).'/images/noscreenshot.png'; 57 52 } 58 59 http::cache(array_merge(array($f), get_included_files()));60 53 54 http::cache(array_merge(array($f), get_included_files())); 55 61 56 header('Content-Type: '.files::getMimeType($f)); 62 57 header('Content-Length: '.filesize($f)); 63 58 readfile($f); 64 59 65 60 exit; 66 61 } 67 62 68 63 # -- Display module configuration page -- 69 if ($list->setConfigurationFile($core-> themes, $core->blog->settings->system->theme)) {64 if ($list->setConfigurationFile($core->blog->settings->system->theme)) { 70 65 71 66 # Get content before page headers … … 105 100 106 101 # -- Execute actions -- 107 if (!empty($_POST) && empty($_REQUEST['conf']) && $core->auth->isSuperAdmin() && $list->isPathWritable()) { 108 try { 109 $list->executeAction('themes', $core->themes, $repository); 110 } 111 catch (Exception $e) { 112 $core->error->add($e->getMessage()); 113 } 102 try { 103 $list->doActions('themes'); 104 } 105 catch (Exception $e) { 106 $core->error->add($e->getMessage()); 114 107 } 115 108 … … 139 132 140 133 # Updated modules from repo 141 $modules = $ repository->get(true);134 $modules = $list->repository->get(true); 142 135 if (!empty($modules)) { 143 136 echo … … 168 161 '<div class="multi-part" id="themes" title="'.__('Installed themes').'">'; 169 162 170 $modules = $ core->themes->getModules();163 $modules = $list->modules->getModules(); 171 164 if (!empty($modules)) { 172 165 … … 180 173 ->setPageTab('themes') 181 174 ->displayModulesList( 182 /* cols */ array('sshot', ' name', 'config', 'desc', 'author', 'version', 'parent'),175 /* cols */ array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'), 183 176 /* actions */ array('select', 'deactivate', 'delete') 184 177 ); 185 178 } 186 179 187 $modules = $ core->themes->getDisabledModules();180 $modules = $list->modules->getDisabledModules(); 188 181 if (!empty($modules)) { 189 182 … … 209 202 # New modules from repo 210 203 $search = $list->getSearchQuery(); 211 $modules = $search ? $repository->search($search) : $repository->get(); 212 213 echo 214 '<div class="multi-part" id="new" title="'.__('Add themes from Dotaddict').'">'. 215 '<h3>'.__('Add themes from Dotaddict repository').'</h3>'; 216 217 $list 218 ->newList('theme-new') 219 ->setModules($modules) 220 ->setPageTab('new') 221 ->displaySearchForm() 222 ->displayNavMenu() 223 ->displayModulesList( 224 /* cols */ array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent', 'distrib'), 225 /* actions */ array('install'), 226 /* nav limit */ true 227 ); 228 229 echo 230 '<p class="info vertical-separator">'.sprintf( 231 __("Visit %s repository, the resources center for Dotclear."), 232 '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' 233 ). 234 '</p>'. 235 204 $modules = $search ? $list->repository->search($search) : $list->repository->get(); 205 206 if (!empty($search) || !empty($modules)) { 207 echo 208 '<div class="multi-part" id="new" title="'.__('Add themes from Dotaddict').'">'. 209 '<h3>'.__('Add themes from Dotaddict repository').'</h3>'; 210 211 $list 212 ->newList('theme-new') 213 ->setModules($modules) 214 ->setPageTab('new') 215 ->displaySearchForm() 216 ->displayNavMenu() 217 ->displayModulesList( 218 /* cols */ array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'), 219 /* actions */ array('install'), 220 /* nav limit */ true 221 ); 222 223 echo 224 '<p class="info vertical-separator">'.sprintf( 225 __("Visit %s repository, the resources center for Dotclear."), 226 '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' 227 ). 228 '</p>'. 229 230 '</div>'; 231 } 232 233 # Add a new plugin 234 echo 235 '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'. 236 '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>'; 237 238 $list->displayManualForm(); 239 240 echo 236 241 '</div>'; 237 238 # Add a new plugin239 echo240 '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">';241 242 echo '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>';243 244 $list->displayManualForm();245 246 echo247 '</div>';248 242 } 249 243 250 244 dcPage::close(); 251 ?> -
admin/index.php
r2175 r2215 129 129 { 130 130 $repo = new dcRepository($mod, $url); 131 $repo->check();132 131 $upd = $repo->get(true); 133 132 if (!empty($upd)) { -
admin/plugins.php
r2182 r2215 15 15 dcPage::check('admin'); 16 16 17 # -------------------------------------------------- 18 # @todo Add settings to Dotclear update features 17 # -- "First time" settings setup -- 19 18 if ($core->blog->settings->system->plugins_allow_multi_install === null) { 20 19 $core->blog->settings->system->put( … … 27 26 ); 28 27 } 29 # -------------------------------------------------- 30 31 # -- Repository helper -- 32 $repository = new dcRepository( 28 29 # -- Page helper -- 30 $list = new adminModulesList( 33 31 $core->plugins, 32 DC_PLUGINS_ROOT, 34 33 $core->blog->settings->system->repository_plugin_url 35 34 ); 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 $list::setDistributedModules(array( 35 36 $list::$allow_multi_install = $core->blog->settings->system->plugins_allow_multi_install; 37 $list::$distributed_modules = array( 46 38 'aboutConfig', 47 39 'akismet', … … 61 53 'userPref', 62 54 'widgets' 63 ) );55 ); 64 56 65 57 # -- Display module configuration page -- 66 if ($list->setConfigurationFile( $core->plugins)) {58 if ($list->setConfigurationFile()) { 67 59 68 60 # Get content before page headers … … 101 93 102 94 # -- Execute actions -- 103 if (!empty($_POST) && empty($_REQUEST['conf']) && $core->auth->isSuperAdmin() && $list->isPathWritable()) { 104 try { 105 $list->executeAction('plugins', $core->plugins, $repository); 106 } 107 catch (Exception $e) { 108 $core->error->add($e->getMessage()); 109 } 95 try { 96 $list->doActions('plugins'); 97 } 98 catch (Exception $e) { 99 $core->error->add($e->getMessage()); 110 100 } 111 101 … … 140 130 echo 141 131 '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; 132 142 133 foreach ($plugins_install['success'] as $k => $v) { 143 134 echo … … 145 136 } 146 137 echo 138 147 139 '</ul></div>'; 148 140 } … … 150 142 echo 151 143 '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 144 152 145 foreach ($plugins_install['failure'] as $k => $v) { 153 146 echo 154 147 '<li>'.$k.' ('.$v.')</li>'; 155 148 } 149 156 150 echo 157 151 '</ul></div>'; … … 162 156 163 157 # Updated modules from repo 164 $modules = $ repository->get(true);158 $modules = $list->repository->get(true); 165 159 if (!empty($modules)) { 166 160 echo … … 191 185 '<div class="multi-part" id="plugins" title="'.__('Installed plugins').'">'; 192 186 193 $modules = $ core->plugins->getModules();187 $modules = $list->modules->getModules(); 194 188 if (!empty($modules)) { 195 196 189 echo 197 190 '<h3>'.__('Activated plugins').'</h3>'. … … 209 202 210 203 # Deactivated modules 211 $modules = $ core->plugins->getDisabledModules();204 $modules = $list->modules->getDisabledModules(); 212 205 if (!empty($modules)) { 213 214 206 echo 215 207 '<h3>'.__('Deactivated plugins').'</h3>'. … … 233 225 # New modules from repo 234 226 $search = $list->getSearchQuery(); 235 $modules = $search ? $repository->search($search) : $repository->get(); 236 237 echo 238 '<div class="multi-part" id="new" title="'.__('Add plugins from Dotaddict').'">'. 239 '<h3>'.__('Add plugins from Dotaddict repository').'</h3>'; 240 241 $list 242 ->newList('plugin-new') 243 ->setModules($modules) 244 ->setPageTab('new') 245 ->displaySearchForm() 246 ->displayNavMenu() 247 ->displayModulesList( 248 /* cols */ array('expander', 'name', 'version', 'desc'), 249 /* actions */ array('install'), 250 /* nav limit */ true 251 ); 252 253 echo 254 '<p class="info vertical-separator">'.sprintf( 255 __("Visit %s repository, the resources center for Dotclear."), 256 '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>' 257 ). 258 '</p>'. 259 260 '</div>'; 227 $modules = $search ? $list->repository->search($search) : $list->repository->get(); 228 229 if (!empty($search) || !empty($modules)) { 230 echo 231 '<div class="multi-part" id="new" title="'.__('Add plugins from Dotaddict').'">'. 232 '<h3>'.__('Add plugins from Dotaddict repository').'</h3>'; 233 234 $list 235 ->newList('plugin-new') 236 ->setModules($modules) 237 ->setPageTab('new') 238 ->displaySearchForm() 239 ->displayNavMenu() 240 ->displayModulesList( 241 /* cols */ array('expander', 'name', 'version', 'desc'), 242 /* actions */ array('install'), 243 /* nav limit */ true 244 ); 245 246 echo 247 '<p class="info vertical-separator">'.sprintf( 248 __("Visit %s repository, the resources center for Dotclear."), 249 '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>' 250 ). 251 '</p>'. 252 253 '</div>'; 254 } 261 255 262 256 # Add a new plugin 263 257 echo 264 '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade manually').'">'; 265 266 echo '<p>'.__('You can install plugins by uploading or downloading zip files.').'</p>'; 267 258 '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade manually').'">'. 259 '<p>'.__('You can install plugins by uploading or downloading zip files.').'</p>'; 260 268 261 $list->displayManualForm(); 269 262 … … 282 275 283 276 dcPage::close(); 284 ?> -
admin/services.php
r2174 r2215 447 447 { 448 448 if (empty($get['id'])) { 449 449 throw new Exception('No module ID'); 450 450 } 451 451 if (empty($get['list'])) { 452 452 throw new Exception('No list ID'); 453 453 } 454 454 … … 482 482 483 483 if (empty($module)) { 484 484 throw new Exception('Unknow module ID'); 485 485 } 486 486 … … 489 489 $rsp = new xmlTag('module'); 490 490 $rsp->id = $id; 491 491 492 492 foreach($module as $k => $v) { 493 493 $rsp->{$k}((string) $v); -
inc/admin/lib.moduleslist.php
r2195 r2215 1 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 if (!defined('DC_ADMIN_CONTEXT')) { return; } 2 13 3 14 class adminModulesList … … 5 16 public $core; 6 17 public $modules; 7 8 public static $allow_multi_install; 18 public $repository; 19 20 public static $allow_multi_install = false; 9 21 public static $distributed_modules = array(); 10 22 11 23 protected $list_id = 'unknow'; 24 protected $data = array(); 12 25 13 26 protected $config_module = ''; … … 30 43 protected $sort_asc = true; 31 44 32 public function __construct($core, $root, $allow_multi_install=false) 33 { 34 $this->core = $core; 35 self::$allow_multi_install = (boolean) $allow_multi_install; 36 $this->setPathInfo($root); 45 public function __construct(dcModules $modules, $modules_root, $xml_url) 46 { 47 $this->core = $modules->core; 48 $this->modules = $modules; 49 $this->repository = new dcRepository($modules, $xml_url); 50 51 $this->setPathInfo($modules_root); 37 52 $this->setNavSpecial(__('other')); 38 39 $this->init();40 }41 42 protected function init()43 {44 return null;45 53 } 46 54 47 55 public function newList($list_id) 48 56 { 49 $this-> modules= array();57 $this->data = array(); 50 58 $this->page_tab = ''; 51 59 $this->list_id = $list_id; … … 124 132 $query = $this->getSearchQuery(); 125 133 126 if (empty($this-> modules) && $query === null) {134 if (empty($this->data) && $query === null) { 127 135 return $this; 128 136 } … … 140 148 echo 141 149 '<p class="message">'.sprintf( 142 __('Found %d result for search "%s":', 'Found %d results for search "%s":', count($this-> modules)),143 count($this-> modules), html::escapeHTML($query)150 __('Found %d result for search "%s":', 'Found %d results for search "%s":', count($this->data)), 151 count($this->data), html::escapeHTML($query) 144 152 ). 145 153 '</p>'; … … 163 171 public function displayNavMenu() 164 172 { 165 if (empty($this-> modules) || $this->getSearchQuery() !== null) {173 if (empty($this->data) || $this->getSearchQuery() !== null) { 166 174 return $this; 167 175 } … … 169 177 # Fetch modules required field 170 178 $indexes = array(); 171 foreach ($this-> modulesas $id => $module) {179 foreach ($this->data as $id => $module) { 172 180 if (!isset($module[$this->sort_field])) { 173 181 continue; … … 246 254 public function setModules($modules) 247 255 { 248 $this-> modules= array();256 $this->data = array(); 249 257 if (!empty($modules) && is_array($modules)) { 250 258 foreach($modules as $id => $module) { 251 $this-> modules[$id] = self::parseModuleInfo($id, $module);259 $this->data[$id] = self::parseModuleInfo($id, $module); 252 260 } 253 261 } … … 257 265 public function getModules() 258 266 { 259 return $this-> modules;267 return $this->data; 260 268 } 261 269 … … 297 305 } 298 306 299 public static function setDistributedModules($modules)300 {301 self::$distributed_modules = $modules;302 }303 304 307 public static function isDistributedModule($module) 305 308 { … … 361 364 $sort_field = $this->getSortQuery(); 362 365 363 # Sort modules by id366 # Sort modules by $sort_field (default sname) 364 367 $modules = $this->getSearchQuery() === null ? 365 self::sortModules($this-> modules, $sort_field, $this->sort_asc) :366 $this-> modules;368 self::sortModules($this->data, $sort_field, $this->sort_asc) : 369 $this->data; 367 370 368 371 $count = 0; … … 425 428 426 429 if (!empty($actions) && $this->core->auth->isSuperAdmin()) { 430 $buttons = $this->getActions($id, $module, $actions); 431 427 432 echo 428 '<td class="module-actions nowrap">'; 429 430 $this->displayLineActions($id, $module, $actions); 431 432 echo 433 '<td class="module-actions nowrap">'. 434 435 '<form action="'.$this->getPageURL().'" method="post">'. 436 '<div>'. 437 $this->core->formNonce(). 438 form::hidden(array('module'), html::escapeHTML($id)). 439 form::hidden(array('tab'), $this->page_tab). 440 441 implode(' ', $buttons). 442 443 '</div>'. 444 '</form>'. 445 433 446 '</td>'; 434 447 } … … 448 461 } 449 462 450 protected function displayLineActions($id, $module, $actions, $echo=true)463 protected function getActions($id, $module, $actions) 451 464 { 452 465 $submits = array(); 453 466 454 # Update (from repository) 455 if (in_array('update', $actions) && $this->path_writable) { 456 $submits[] = '<input type="submit" name="update" value="'.__('Update').'" />'; 457 } 458 459 # Install (form repository) 460 if (in_array('install', $actions) && $this->path_writable) { 461 $submits[] = '<input type="submit" name="install" value="'.__('Install').'" />'; 462 } 463 464 $tmp = $this->displayOtherLineAction($id, $module, $actions); 465 if (!empty($tmp) && is_array($tmp)) { 466 $submits = array_merge($submits, $tmp); 467 } 468 469 # Activate 470 if (in_array('deactivate', $actions) && $module['root_writable']) { 471 $submits[] = '<input type="submit" name="deactivate" value="'.__('Deactivate').'" class="reset" />'; 472 } 473 474 # Deactivate 475 if (in_array('activate', $actions) && $module['root_writable']) { 476 $submits[] = '<input type="submit" name="activate" value="'.__('Activate').'" />'; 477 } 478 479 # Delete 480 if (in_array('delete', $actions) && $this->isPathDeletable($module['root'])) { 481 $submits[] = '<input type="submit" class="delete" name="delete" value="'.__('Delete').'" />'; 482 } 483 484 # Parse form 485 if (!empty($submits)) { 486 $res = 487 '<form action="'.$this->getPageURL().'" method="post">'. 488 '<div>'. 489 $this->core->formNonce(). 490 form::hidden(array('module'), html::escapeHTML($id)). 491 form::hidden(array('tab'), $this->page_tab). 492 implode(' ', $submits). 493 '</div>'. 494 '</form>'; 495 496 if (!$echo) { 497 return $res; 498 } 499 echo $res; 500 } 501 } 502 503 protected function displayOtherLineAction($id, $module, $actions) 504 { 505 return null; 506 } 507 508 public function executeAction($prefix, dcModules $modules, dcRepository $repository) 509 { 510 if (!$this->core->auth->isSuperAdmin() || !$this->isPathWritable()) { 467 # Use loop to keep requested order 468 foreach($actions as $action) { 469 switch($action) { 470 471 # Deactivate 472 case 'activate': if ($module['root_writable']) { 473 $submits[] = 474 '<input type="submit" name="activate" value="'.__('Activate').'" />'; 475 } break; 476 477 # Activate 478 case 'deactivate': if ($module['root_writable']) { 479 $submits[] = 480 '<input type="submit" name="deactivate" value="'.__('Deactivate').'" class="reset" />'; 481 } break; 482 483 # Delete 484 case 'delete': if ($this->isPathDeletable($module['root'])) { 485 $submits[] = 486 '<input type="submit" class="delete" name="delete" value="'.__('Delete').'" />'; 487 } break; 488 489 # Install (from repository) 490 case 'install': if ($this->path_writable) { 491 $submits[] = 492 '<input type="submit" name="install" value="'.__('Install').'" />'; 493 } break; 494 495 # Update (from repository) 496 case 'update': if ($this->path_writable) { 497 $submits[] = 498 '<input type="submit" name="update" value="'.__('Update').'" />'; 499 } break; 500 } 501 } 502 503 return $submits; 504 } 505 506 public function doActions($prefix) 507 { 508 if (empty($_POST) || !empty($_REQUEST['conf']) 509 || !$this->core->auth->isSuperAdmin() || !$this->isPathWritable()) { 511 510 return null; 512 511 } … … 519 518 if (!empty($_POST['activate'])) { 520 519 521 $enabled = $ modules->getDisabledModules();520 $enabled = $this->modules->getDisabledModules(); 522 521 if (!isset($enabled[$id])) { 523 522 throw new Exception(__('No such module.')); … … 527 526 $this->core->callBehavior($prefix.'BeforeActivate', $id); 528 527 529 $ modules->activateModule($id);528 $this->modules->activateModule($id); 530 529 531 530 # --BEHAVIOR-- moduleAfterActivate … … 537 536 elseif (!empty($_POST['deactivate'])) { 538 537 539 if (!$ modules->moduleExists($id)) {538 if (!$this->modules->moduleExists($id)) { 540 539 throw new Exception(__('No such module.')); 541 540 } 542 541 543 $module = $ modules->getModules($id);542 $module = $this->modules->getModules($id); 544 543 $module['id'] = $id; 545 544 … … 551 550 $this->core->callBehavior($prefix.'BeforeDeactivate', $module); 552 551 553 $ modules->deactivateModule($id);552 $this->modules->deactivateModule($id); 554 553 555 554 # --BEHAVIOR-- moduleAfterDeactivate … … 561 560 elseif (!empty($_POST['delete'])) { 562 561 563 $disabled = $ modules->getDisabledModules();562 $disabled = $this->modules->getDisabledModules(); 564 563 if (!isset($disabled[$id])) { 565 564 566 if (!$ modules->moduleExists($id)) {565 if (!$this->modules->moduleExists($id)) { 567 566 throw new Exception(__('No such module.')); 568 567 } 569 568 570 $module = $ modules->getModules($id);569 $module = $this->modules->getModules($id); 571 570 $module['id'] = $id; 572 571 … … 578 577 $this->core->callBehavior($prefix.'BeforeDelete', $module); 579 578 580 $ modules->deleteModule($id);579 $this->modules->deleteModule($id); 581 580 582 581 # --BEHAVIOR-- moduleAfterDelete … … 584 583 } 585 584 else { 586 $ modules->deleteModule($id, true);585 $this->modules->deleteModule($id, true); 587 586 } 588 587 589 588 http::redirect($this->getPageURL('msg=delete')); 589 } 590 591 elseif (!empty($_POST['install'])) { 592 593 $updated = $this->repository->get(); 594 if (!isset($updated[$id])) { 595 throw new Exception(__('No such module.')); 596 } 597 598 $module = $updated[$id]; 599 $module['id'] = $id; 600 601 $dest = $this->getPath().'/'.basename($module['file']); 602 603 # --BEHAVIOR-- moduleBeforeAdd 604 $this->core->callBehavior($prefix.'BeforeAdd', $module); 605 606 $ret_code = $this->repository->process($module['file'], $dest); 607 608 # --BEHAVIOR-- moduleAfterAdd 609 $this->core->callBehavior($prefix.'AfterAdd', $module); 610 611 http::redirect($this->getPageURL('msg='.($ret_code == 2 ? 'update' : 'install'))); 590 612 } 591 613 … … 597 619 } 598 620 599 if (!$ modules->moduleExists($id)) {621 if (!$this->modules->moduleExists($id)) { 600 622 throw new Exception(__('No such module.')); 601 623 } … … 617 639 $this->core->callBehavior($prefix.'BeforeUpdate', $module); 618 640 619 $ repository->process($module['file'], $dest);641 $this->repository->process($module['file'], $dest); 620 642 621 643 # --BEHAVIOR-- moduleAfterUpdate … … 623 645 624 646 http::redirect($this->getPageURL('msg=upadte')); 625 }626 627 elseif (!empty($_POST['install'])) {628 629 $updated = $repository->get();630 if (!isset($updated[$id])) {631 throw new Exception(__('No such module.'));632 }633 634 $module = $updated[$id];635 $module['id'] = $id;636 637 $dest = $this->getPath().'/'.basename($module['file']);638 639 # --BEHAVIOR-- moduleBeforeAdd640 $this->core->callBehavior($prefix.'BeforeAdd', $module);641 642 $ret_code = $repository->process($module['file'], $dest);643 644 # --BEHAVIOR-- moduleAfterAdd645 $this->core->callBehavior($prefix.'AfterAdd', $module);646 647 http::redirect($this->getPageURL('msg='.($ret_code == 2 ? 'update' : 'install')));648 647 } 649 648 } … … 667 666 $url = urldecode($_POST['pkg_url']); 668 667 $dest = $this->getPath().'/'.basename($url); 669 $ repository->download($url, $dest);668 $this->repository->download($url, $dest); 670 669 } 671 670 … … 673 672 $this->core->callBehavior($prefix.'BeforeAdd', null); 674 673 675 $ret_code = $ repository->install($dest);674 $ret_code = $this->repository->install($dest); 676 675 677 676 # --BEHAVIOR-- moduleAfterAdd … … 681 680 } 682 681 683 return $this->executeOtherAction($prefix, $modules, $repository);684 }685 686 /**687 *688 * Way for child class to execute their own actions689 * whitout rewriting all standard actions.690 */691 protected function executeOtherAction($prefix, dcModules $modules, dcRepository $repository)692 {693 682 return null; 694 683 } … … 740 729 * 741 730 */ 742 public function setConfigurationFile( dcModules $modules,$id=null)731 public function setConfigurationFile($id=null) 743 732 { 744 733 if (empty($_REQUEST['conf']) || empty($_REQUEST['module']) && !$id) { … … 750 739 } 751 740 752 if (!$ modules->moduleExists($id)) {741 if (!$this->modules->moduleExists($id)) { 753 742 $core->error->add(__('Unknow module ID')); 754 743 return false; 755 744 } 756 745 757 $module = $ modules->getModules($id);746 $module = $this->modules->getModules($id); 758 747 $module = self::parseModuleInfo($id, $module); 759 748 $file = path::real($module['root'].'/_config.php'); … … 842 831 # Sort modules by id 843 832 $modules = $this->getSearchQuery() === null ? 844 self::sortModules($this-> modules, $sort_field, $this->sort_asc) :845 $this-> modules;833 self::sortModules($this->data, $sort_field, $this->sort_asc) : 834 $this->data; 846 835 847 836 $res = ''; … … 861 850 862 851 $current = $this->core->blog->settings->system->theme == $id; 863 864 if (preg_match('#^http(s)?://#', $this->core->blog->settings->system->themes_url)) { 865 $theme_url = http::concatURL($this->core->blog->settings->system->themes_url, '/'.$id); 866 } else { 867 $theme_url = http::concatURL($this->core->blog->url, $this->core->blog->settings->system->themes_url.'/'.$id); 868 } 852 $distrib = self::isDistributedModule($id) ? ' dc-box' : ''; 853 854 $theme_url = preg_match('#^http(s)?://#', $this->core->blog->settings->system->themes_url) ? 855 http::concatURL($this->core->blog->settings->system->themes_url, '/'.$id) : 856 http::concatURL($this->core->blog->url, $this->core->blog->settings->system->themes_url.'/'.$id); 869 857 870 858 $has_conf = file_exists(path::real($this->core->blog->themes_path.'/'.$id).'/_config.php'); … … 877 865 878 866 $line = 879 '<div class="box '.($current ? 'medium current-theme' : 'small theme'). '">';867 '<div class="box '.($current ? 'medium current-theme' : 'small theme').$distrib.'">'; 880 868 881 869 if (in_array('name', $cols)) { … … 899 887 900 888 $line .= 901 '<div class="module-sshot"><img src="'.$sshot.'" alt="'.__('screenshot.').'" /></div>'; 889 '<div class="module-sshot"><img src="'.$sshot.'" alt="'. 890 sprintf(__('%s screenshot.'), html::escapeHTML($module['name'])).'" /></div>'; 902 891 } 903 892 … … 930 919 '<span class="module-parent-missing">'.sprintf(__('(requires "%s")'),html::escapeHTML($parent)).'</span> '; 931 920 } 921 } 922 923 if (in_array('version', $cols)) { 924 $line .= 925 '<span class="module-version">'.sprintf(__('version %s'),html::escapeHTML($module['version'])).'</span> '; 926 } 927 928 $has_details = in_array('details', $cols) && !empty($module['details']); 929 $has_support = in_array('support', $cols) && !empty($module['support']); 930 if ($has_details || $has_support) { 931 $line .= 932 '<span class="mod-more">'.__('Help:').' '; 933 934 if ($has_details) { 935 $line .= 936 '<a class="module-details" href="'.$module['details'].'">'.__('Details').'</a>'; 937 } 938 939 if ($has_support) { 940 $line .= 941 ' - <a class="module-support" href="'.$module['support'].'">'.__('Support').'</a>'; 942 } 943 944 $line .= 945 '</span>'; 932 946 } 933 947 … … 958 972 959 973 # _POST actions 960 if (!empty($actions) && $this->core->auth->isSuperAdmin()) {974 if (!empty($actions)) { 961 975 $line .= 962 $this->displayLineActions($id, $module, $actions, false); 976 '<form action="'.$this->getPageURL().'" method="post">'. 977 '<div>'. 978 $this->core->formNonce(). 979 form::hidden(array('module'), html::escapeHTML($id)). 980 form::hidden(array('tab'), $this->page_tab). 981 982 implode(' ', $this->getActions($id, $module, $actions)). 983 984 '</div>'. 985 '</form>'; 963 986 } 964 987 … … 983 1006 } 984 1007 985 protected function displayOtherLineAction($id, $module, $actions)1008 protected function getActions($id, $module, $actions) 986 1009 { 987 1010 $submits = array(); 988 1011 989 1012 $this->core->blog->settings->addNamespace('system'); 990 if ($id == $this->core->blog->settings->system->theme) { 991 return null; 992 } 993 994 # Select theme to use on curent blog 995 if (in_array('select', $actions) && $this->path_writable) { 996 $submits[] = '<input type="submit" name="select" value="'.__('Choose').'" />'; 997 } 998 999 return $submits; 1000 } 1001 1002 protected function executeOtherAction($prefix, dcModules $modules, dcRepository $repository) 1003 { 1004 # Select theme to use on curent blog 1005 if (!empty($_POST['module']) && !empty($_POST['select'])) { 1006 $id = $_POST['module']; 1007 1008 if (!$modules->moduleExists($id)) { 1009 throw new Exception(__('No such module.')); 1010 } 1011 1012 $this->core->blog->settings->addNamespace('system'); 1013 $this->core->blog->settings->system->put('theme',$id); 1014 $this->core->blog->triggerBlog(); 1015 1016 http::redirect($this->getPageURL('msg=select').'#themes'); 1017 } 1018 1019 return null; 1013 if ($id != $this->core->blog->settings->system->theme) { 1014 1015 # Select theme to use on curent blog 1016 if (in_array('select', $actions) && $this->path_writable) { 1017 $submits[] = '<input type="submit" name="select" value="'.__('Choose').'" />'; 1018 } 1019 } 1020 1021 return array_merge( 1022 $submits, 1023 parent::getActions($id, $module, $actions) 1024 ); 1025 } 1026 1027 public function doActions($prefix) 1028 { 1029 if (!empty($_POST) && empty($_REQUEST['conf']) && $this->isPathWritable()) { 1030 1031 # Select theme to use on curent blog 1032 if (!empty($_POST['module']) && !empty($_POST['select'])) { 1033 $id = $_POST['module']; 1034 1035 if (!$this->modules->moduleExists($id)) { 1036 throw new Exception(__('No such module.')); 1037 } 1038 1039 $this->core->blog->settings->addNamespace('system'); 1040 $this->core->blog->settings->system->put('theme',$id); 1041 $this->core->blog->triggerBlog(); 1042 1043 http::redirect($this->getPageURL('msg=select').'#themes'); 1044 } 1045 } 1046 1047 return parent::doActions($prefix); 1020 1048 } 1021 1049 } -
inc/core/class.dc.repository.php
r2214 r2215 44 44 $this->xml_url = $xml_url; 45 45 $this->user_agent = sprintf('Dotclear/%s)', DC_VERSION); 46 47 $this->check(); 46 48 } 47 49 -
plugins/maintenance/_config.php
r2182 r2215 61 61 62 62 echo 63 '<p>'.__(' Managealert for maintenance task.').'</p>'.63 '<p>'.__('Setup alert for maintenance task.').'</p>'. 64 64 65 65 '<h4 class="pretty-title">'.__('Activation').'</h4>'.
Note: See TracChangeset
for help on using the changeset viewer.