Changeset 2192:511c654d4adb for inc/admin
- Timestamp:
- 10/01/13 21:54:38 (12 years ago)
- Branch:
- dcRepo
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.moduleslist.php
r2182 r2192 442 442 '</table></div>'; 443 443 444 if(!$count ) {444 if(!$count && $this->getSearchQuery() === null) { 445 445 echo 446 446 '<p class="message">'.__('No module matches your search.').'</p>'; … … 451 451 { 452 452 $submits = array(); 453 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 } 453 468 454 469 # Activate … … 465 480 if (in_array('delete', $actions) && $this->isPathDeletable($module['root'])) { 466 481 $submits[] = '<input type="submit" class="delete" name="delete" value="'.__('Delete').'" />'; 467 }468 469 # Install (form repository)470 if (in_array('install', $actions) && $this->path_writable) {471 $submits[] = '<input type="submit" name="install" value="'.__('Install').'" />';472 }473 474 # Update (from repository)475 if (in_array('update', $actions) && $this->path_writable) {476 $submits[] = '<input type="submit" name="update" value="'.__('Update').'" />';477 }478 479 # Select (from repository)480 if (in_array('choose', $actions) && $this->path_writable) {481 $submits[] = '<input type="submit" name="choose" value="'.__('Choose').'" />';482 482 } 483 483 … … 501 501 } 502 502 503 protected function displayOtherLineAction($id, $module, $actions) 504 { 505 return null; 506 } 507 503 508 public function executeAction($prefix, dcModules $modules, dcRepository $repository) 504 509 { … … 520 525 521 526 # --BEHAVIOR-- moduleBeforeActivate 522 $this->core->callBehavior($ type.'BeforeActivate', $id);527 $this->core->callBehavior($prefix.'BeforeActivate', $id); 523 528 524 529 $modules->activateModule($id); 525 530 526 531 # --BEHAVIOR-- moduleAfterActivate 527 $this->core->callBehavior($ type.'AfterActivate', $id);532 $this->core->callBehavior($prefix.'AfterActivate', $id); 528 533 529 534 http::redirect($this->getPageURL('msg=activate')); 530 535 } 531 536 532 if (!empty($_POST['deactivate'])) {537 elseif (!empty($_POST['deactivate'])) { 533 538 534 539 if (!$modules->moduleExists($id)) { … … 554 559 } 555 560 556 if (!empty($_POST['delete'])) {561 elseif (!empty($_POST['delete'])) { 557 562 558 563 $disabled = $modules->getDisabledModules(); … … 585 590 } 586 591 587 if (!empty($_POST['update'])) {592 elseif (!empty($_POST['update'])) { 588 593 589 594 $updated = $repository->get(); … … 610 615 611 616 # --BEHAVIOR-- moduleBeforeUpdate 612 $this->core->callBehavior($ type.'BeforeUpdate', $module);617 $this->core->callBehavior($prefix.'BeforeUpdate', $module); 613 618 614 619 $repository->process($module['file'], $dest); 615 620 616 621 # --BEHAVIOR-- moduleAfterUpdate 617 $this->core->callBehavior($ type.'AfterUpdate', $module);622 $this->core->callBehavior($prefix.'AfterUpdate', $module); 618 623 619 624 http::redirect($this->getPageURL('msg=upadte')); 620 625 } 621 626 622 if (!empty($_POST['install'])) {627 elseif (!empty($_POST['install'])) { 623 628 624 629 $updated = $repository->get(); … … 633 638 634 639 # --BEHAVIOR-- moduleBeforeAdd 635 $this->core->callBehavior($ type.'BeforeAdd', $module);640 $this->core->callBehavior($prefix.'BeforeAdd', $module); 636 641 637 642 $ret_code = $repository->process($module['file'], $dest); 638 643 639 644 # --BEHAVIOR-- moduleAfterAdd 640 $this->core->callBehavior($ type.'AfterAdd', $module);645 $this->core->callBehavior($prefix.'AfterAdd', $module); 641 646 642 647 http::redirect($this->getPageURL('msg='.($ret_code == 2 ? 'update' : 'install'))); … … 675 680 http::redirect($this->getPageURL('msg='.($ret_code == 2 ? 'update' : 'install')).'#'.$prefix); 676 681 } 682 683 return $this->executeOtherAction($prefix, $modules, $repository); 684 } 685 686 /** 687 * 688 * Way for child class to execute their own actions 689 * whitout rewriting all standard actions. 690 */ 691 protected function executeOtherAction($prefix, dcModules $modules, dcRepository $repository) 692 { 677 693 return null; 678 694 } … … 863 879 '<div class="box small '.($current ? 'current-theme' : 'theme').'">'; 864 880 881 if (in_array('name', $cols)) { 882 $line .= 883 '<h4 class="module-name">'.html::escapeHTML($module['name']).'</h4>'; 884 } 885 886 $line .= 887 '<div class="module-infos">'. 888 '<p>'; 889 890 if (in_array('desc', $cols)) { 891 $line .= 892 '<span class="module-desc">'.html::escapeHTML($module['desc']).'</span> '; 893 } 894 895 if (in_array('author', $cols)) { 896 $line .= 897 '<span class="module-author">'.sprintf(__('by %s'),html::escapeHTML($module['author'])).'</span> '; 898 } 899 900 if (in_array('version', $cols)) { 901 $line .= 902 '<span class="module-version">'.sprintf(__('version %s'),html::escapeHTML($module['version'])).'</span> '; 903 } 904 905 if (in_array('parent', $cols) && $has_parent) { 906 if ($is_parent_present) { 907 $line .= 908 '<span class="module-parent-ok">'.sprintf(__('(built on "%s")'),html::escapeHTML($parent)).'</span> '; 909 } 910 else { 911 $line .= 912 '<span class="module-parent-missing">'.sprintf(__('(requires "%s")'),html::escapeHTML($parent)).'</span> '; 913 } 914 } 915 916 $line .= 917 '</p>'. 918 '</div>'; 919 865 920 if (in_array('sshot', $cols)) { 866 921 # Screenshot from url … … 881 936 } 882 937 883 if (in_array('name', $cols)) {884 $line .=885 '<h4 class="module-name">'.html::escapeHTML($module['name']).'</h4>';886 }887 888 $line .=889 '<div class="module-infos">'.890 '<p>';891 892 if (in_array('desc', $cols)) {893 $line .=894 '<span class="module-desc">'.html::escapeHTML($module['desc']).'</span> ';895 }896 897 if (in_array('author', $cols)) {898 $line .=899 '<span class="module-author">'.sprintf(__('by %s'),html::escapeHTML($module['author'])).'</span> ';900 }901 902 if (in_array('version', $cols)) {903 $line .=904 '<span class="module-version">'.sprintf(__('version %s'),html::escapeHTML($module['version'])).'</span> ';905 }906 907 if (in_array('parent', $cols) && $has_parent) {908 if ($is_parent_present) {909 $line .=910 '<span class="module-parent-ok">'.sprintf(__('(built on "%s")'),html::escapeHTML($parent)).'</span> ';911 }912 else {913 $line .=914 '<span class="module-parent-missing">'.sprintf(__('(requires "%s")'),html::escapeHTML($parent)).'</span> ';915 }916 }917 918 $line .=919 '</p>'.920 '</div>';921 922 938 $line .= 923 939 '<div class="modules-actions">'; 924 940 925 941 # _GET actions 926 $line .=927 '<p>';928 942 929 943 if ($current && $has_css) { 930 944 $line .= 931 '< a href="'.$theme_url.'/style.css" class="button">'.__('View stylesheet').'</a>';945 '<p><a href="'.$theme_url.'/style.css" class="button">'.__('View stylesheet').'</a></p>'; 932 946 } 933 947 if ($current && $has_conf) { 934 948 $line .= 935 '<a href="'.$this->getPageURL('module='.$id.'&conf=1', false).'" class="button">'.__('Configure theme').'</a> '; 936 } 937 $line .= 938 '</p>'; 949 '<p><a href="'.$this->getPageURL('module='.$id.'&conf=1', false).'" class="button">'.__('Configure theme').'</a></p>'; 950 } 939 951 940 952 # Plugins actions … … 965 977 '</div>'; 966 978 967 if(!$count ) {979 if(!$count && $this->getSearchQuery() === null) { 968 980 echo 969 981 '<p class="message">'.__('No module matches your search.').'</p>'; 970 982 } 971 983 } 984 985 protected function displayOtherLineAction($id, $module, $actions) 986 { 987 $submits = array(); 988 989 $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; 1020 } 972 1021 }
Note: See TracChangeset
for help on using the changeset viewer.