Dotclear

Changeset 2192:511c654d4adb


Ignore:
Timestamp:
10/01/13 21:54:38 (12 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
dcRepo
Message:

Next step for themes manager, to be continued

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • admin/blog_theme.php

    r2182 r2192  
    116116# -- Page header -- 
    117117dcPage::open(__('Themes management'), 
    118 //   (!$conf_file ? dcPage::jsLoad('js/_blog_theme.js') : ''). 
     118     dcPage::jsLoad('js/_blog_theme.js'). 
    119119     dcPage::jsPageTabs(). 
    120120     dcPage::jsColorPicker(), 
     
    181181          ->displayModulesList( 
    182182               /* 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(); 
     188if (!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') 
    184201          ); 
    185202} 
     
    205222          ->displayNavMenu() 
    206223          ->displayModulesList( 
    207                /* cols */          array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent'), 
     224               /* cols */          array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent', 'distrib'), 
    208225               /* actions */  array('install'), 
    209226               /* nav limit */     true 
  • admin/js/_blog_theme.js

    r2101 r2192  
    11$(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 
    2613          }); 
    2714     }); 
    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('&nbsp;&nbsp;'); 
    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*/ 
    7116}); 
  • inc/admin/lib.moduleslist.php

    r2182 r2192  
    442442          '</table></div>'; 
    443443 
    444           if(!$count) { 
     444          if(!$count && $this->getSearchQuery() === null) { 
    445445               echo  
    446446               '<p class="message">'.__('No module matches your search.').'</p>'; 
     
    451451     { 
    452452          $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          } 
    453468 
    454469          # Activate 
     
    465480          if (in_array('delete', $actions) && $this->isPathDeletable($module['root'])) { 
    466481               $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').'" />'; 
    482482          } 
    483483 
     
    501501     } 
    502502 
     503     protected function displayOtherLineAction($id, $module, $actions) 
     504     { 
     505          return null; 
     506     } 
     507 
    503508     public function executeAction($prefix, dcModules $modules, dcRepository $repository) 
    504509     { 
     
    520525 
    521526                    # --BEHAVIOR-- moduleBeforeActivate 
    522                     $this->core->callBehavior($type.'BeforeActivate', $id); 
     527                    $this->core->callBehavior($prefix.'BeforeActivate', $id); 
    523528 
    524529                    $modules->activateModule($id); 
    525530 
    526531                    # --BEHAVIOR-- moduleAfterActivate 
    527                     $this->core->callBehavior($type.'AfterActivate', $id); 
     532                    $this->core->callBehavior($prefix.'AfterActivate', $id); 
    528533 
    529534                    http::redirect($this->getPageURL('msg=activate')); 
    530535               } 
    531536 
    532                if (!empty($_POST['deactivate'])) { 
     537               elseif (!empty($_POST['deactivate'])) { 
    533538 
    534539                    if (!$modules->moduleExists($id)) { 
     
    554559               } 
    555560 
    556                if (!empty($_POST['delete'])) { 
     561               elseif (!empty($_POST['delete'])) { 
    557562 
    558563                    $disabled = $modules->getDisabledModules(); 
     
    585590               } 
    586591 
    587                if (!empty($_POST['update'])) { 
     592               elseif (!empty($_POST['update'])) { 
    588593 
    589594                    $updated = $repository->get(); 
     
    610615 
    611616                    # --BEHAVIOR-- moduleBeforeUpdate 
    612                     $this->core->callBehavior($type.'BeforeUpdate', $module); 
     617                    $this->core->callBehavior($prefix.'BeforeUpdate', $module); 
    613618 
    614619                    $repository->process($module['file'], $dest); 
    615620 
    616621                    # --BEHAVIOR-- moduleAfterUpdate 
    617                     $this->core->callBehavior($type.'AfterUpdate', $module); 
     622                    $this->core->callBehavior($prefix.'AfterUpdate', $module); 
    618623 
    619624                    http::redirect($this->getPageURL('msg=upadte')); 
    620625               } 
    621626 
    622                if (!empty($_POST['install'])) { 
     627               elseif (!empty($_POST['install'])) { 
    623628 
    624629                    $updated = $repository->get(); 
     
    633638 
    634639                    # --BEHAVIOR-- moduleBeforeAdd 
    635                     $this->core->callBehavior($type.'BeforeAdd', $module); 
     640                    $this->core->callBehavior($prefix.'BeforeAdd', $module); 
    636641 
    637642                    $ret_code = $repository->process($module['file'], $dest); 
    638643 
    639644                    # --BEHAVIOR-- moduleAfterAdd 
    640                     $this->core->callBehavior($type.'AfterAdd', $module); 
     645                    $this->core->callBehavior($prefix.'AfterAdd', $module); 
    641646 
    642647                    http::redirect($this->getPageURL('msg='.($ret_code == 2 ? 'update' : 'install'))); 
     
    675680               http::redirect($this->getPageURL('msg='.($ret_code == 2 ? 'update' : 'install')).'#'.$prefix); 
    676681          } 
     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     { 
    677693          return null; 
    678694     } 
     
    863879               '<div class="box small '.($current ? 'current-theme' : 'theme').'">'; 
    864880 
     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 
    865920               if (in_array('sshot', $cols)) { 
    866921                    # Screenshot from url 
     
    881936               } 
    882937 
    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  
    922938               $line .=  
    923939               '<div class="modules-actions">'; 
    924940                
    925941               # _GET actions 
    926                $line .=  
    927                '<p>'; 
    928942 
    929943               if ($current && $has_css) { 
    930944                    $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>'; 
    932946               } 
    933947               if ($current && $has_conf) { 
    934948                    $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               } 
    939951 
    940952               # Plugins actions 
     
    965977          '</div>'; 
    966978 
    967           if(!$count) { 
     979          if(!$count && $this->getSearchQuery() === null) { 
    968980               echo  
    969981               '<p class="message">'.__('No module matches your search.').'</p>'; 
    970982          } 
    971983     } 
     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     } 
    9721021} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map