Changeset 2192:511c654d4adb
- Timestamp:
- 10/01/13 21:54:38 (12 years ago)
- Branch:
- dcRepo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/blog_theme.php
r2182 r2192 116 116 # -- Page header -- 117 117 dcPage::open(__('Themes management'), 118 // (!$conf_file ? dcPage::jsLoad('js/_blog_theme.js') : '').118 dcPage::jsLoad('js/_blog_theme.js'). 119 119 dcPage::jsPageTabs(). 120 120 dcPage::jsColorPicker(), … … 181 181 ->displayModulesList( 182 182 /* cols */ array('sshot', 'name', 'config', 'desc', 'author', 'version', 'parent'), 183 /* actions */ array('deactivate', 'delete') 183 /* actions */ array('select', 'deactivate', 'delete') 184 ); 185 } 186 187 $modules = $core->themes->getDisabledModules(); 188 if (!empty($modules)) { 189 190 echo 191 '<h3>'.__('Deactivated themes').'</h3>'. 192 '<p>'.__('Deactivated themes are installed but not usable. You can activate them from here.').'</p>'; 193 194 $list 195 ->newList('theme-deactivate') 196 ->setModules($modules) 197 ->setPageTab('themes') 198 ->displayModulesList( 199 /* cols */ array('name', 'distrib'), 200 /* actions */ array('activate', 'delete') 184 201 ); 185 202 } … … 205 222 ->displayNavMenu() 206 223 ->displayModulesList( 207 /* cols */ array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent' ),224 /* cols */ array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent', 'distrib'), 208 225 /* actions */ array('install'), 209 226 /* nav limit */ true -
admin/js/_blog_theme.js
r2101 r2192 1 1 $(function() { 2 $('#themes-actions').hide(); 3 var submit_s = $('#themes-actions input[name=select]'); 4 var submit_r = $('#themes-actions input[name=remove]'); 5 6 var details = $('#themes div.theme-details'); 7 $('div.theme-actions',details).hide(); 8 $('input:radio',details).hide(); 9 $('div.theme-info span, div.theme-info a',details).hide(); 10 details.removeClass('theme-details').addClass('theme-details-js'); 11 12 var themes_wrapper = $('<div id="themes-wrapper"></div>'); 13 var theme_box = $('<div id="theme-box"><div</div>'); 14 $('#themes').wrap(themes_wrapper).before(theme_box); 15 16 details.each(function() { 17 var box = this; 18 var a = $(document.createElement('a')); 19 a.attr('href','#'); 20 a.attr('title',$('>div h3>label',this).text()); 21 $(box).wrap(a); 22 $(box).parent().click(function(event) { 23 update_box(box); 24 event.preventDefault(); 25 return false; 2 $('.module-name').not('.current-theme .module-name').each(function(){ 3 $(this).toggleWithLegend($(this).parent().children('.module-infos'),{legend_click: true}); 4 }); 5 /* Exemple for toggle on screenshot 6 $('.module-sshot').not('.current-theme .module-name').each(function(){ 7 $(this).toggleWithLegend($(this).parent().children('.module-infos'),{ 8 img_on_src: '', 9 img_on_alt: '', 10 img_off_src: '', 11 img_off_alt: '', 12 legend_click: true 26 13 }); 27 14 }); 28 29 function update_box(e) { 30 theme_box.empty(); 31 var img = $('div.theme-shot',e).clone(); 32 var info = $('div.theme-info',e).clone(); 33 34 if ($(e).hasClass('current-theme')) { 35 var actions = $('div.theme-actions',e).clone(); 36 actions.show(); 37 } else { 38 var actions = $('<div class="theme-actions"></div>'); 39 if (submit_s.length > 0 && !$('input:radio',info).attr('disabled')) { 40 var select = $('<a href="#" class="button">' + dotclear.msg.use_this_theme + '</a>'); 41 select.addClass('select-button').click(function(){ 42 submit_s.click(); 43 return false; 44 }); 45 actions.append(select).append(' '); 46 } 47 if (submit_r.length > 0 && $('input:radio',info).attr('id') != 'theme_default') { 48 var remove = $('<a href="#" class="button delete">' + dotclear.msg.remove_this_theme + '</a>'); 49 remove.click(function() { 50 var t_name = $(this).parents('#theme-box').find('div.theme-info h3:first').text(); 51 t_name = $.trim(t_name); 52 if (window.confirm(dotclear.msg.confirm_delete_theme.replace('%s',t_name))) { 53 submit_r.click(); 54 } 55 return false; 56 }); 57 actions.append(remove); 58 } 59 } 60 61 $('input:radio',info).remove(); 62 $('span, a',info).show(); 63 64 theme_box.append(img).append(info).append(actions); 65 details.removeClass('theme-selected'); 66 $(e).addClass('theme-selected'); 67 $('input:radio',e).prop('checked',true); 68 } 69 70 update_box(details[0]); 15 */ 71 16 }); -
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.