Ignore:
Timestamp:
07/02/10 14:19:31 (23 months ago)
Author:
fuze
Message:

Модуль "лучшие фото": html вынесен в шаблон.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/fuze/modules/mod_bestphoto/module.php

    r181 r219  
    2121                if (!isset($cfg['showmore'])) { $cfg['showmore'] = 1; } 
    2222                 
    23                 $col = 1; $maxcols = $cfg['maxcols']; 
    24  
    2523                $sql = "SELECT f.*, f.id as fid, f.pubdate as fpubdate, 
    2624                                           a.id as album_id, a.title as album,  
     
    3533         
    3634                $result = $inDB->query($sql) ; 
    37                          
     35                $is_best = false;        
    3836                if ($inDB->num_rows($result)){   
    39                         echo '<table cellspacing="2" border="0" width="100%">'; 
     37                        $is_best = true; 
     38                        $cons = array(); 
    4039                        while($con = $inDB->fetch_assoc($result)){ 
    41                                 $votes = $con[$cfg['sort']]; 
    42                                 if ($col==1) { echo '<tr>'; } echo '<td align="center" valign="middle" class="mod_lp_photo" width="'.round(100/$maxcols, 0).'%">'; 
    43                                 echo '<table width="100%" height="100" cellspacing="0" cellpadding="0">'; 
    4440                                if ($cfg['showtype']=='full'){ 
    45                                           echo '<tr><td align="center"><div class="mod_lp_titlelink"><a href="/photos/photo'.$con['id'].'.html" title="'.$con['title'].' ('.$con['rating'].')">'.$con['title'].'</a></div></td></tr>'; 
    46                                 } 
    47                                   echo '<tr>'; 
    48                                   echo '<td valign="middle" align="center">'; 
    49                                 echo '<a href="/photos/photo'.$con['id'].'.html" title="'.$con['title'].'">'; 
    50                                         echo '<img class="photo_thumb_img" src="/images/photos/small/'.$con['file'].'" alt="'.$con['title'].' ('.$con['rating'].')" border="0" />'; 
    51                                 echo '</a>'; 
    52                                 echo '</td></tr>'; 
    53                                 if ($cfg['showtype']=='full'){ 
    54                                         echo '<tr>'; 
    55                                         echo '<td align="center">'; 
    56                                                 if($cfg['showalbum']){ 
    57                                                         echo '<div class="mod_lp_albumlink"><a href="/photos/'.$con['album_id'].'" title="'.$con['album'].'">'.$con['album'].'</a></div>'; 
    58                                                 } 
    5941                                                if($cfg['showcom'] || $cfg['showdate']){ 
    60                                                         echo '<div class="mod_lp_details">'; 
    61                                                         echo '<table cellpadding="2" cellspacing="2" align="center" border="0"><tr>'; 
    6242                                                                if ($cfg['showdate']){ 
    6343                                                                        include_once($_SERVER['DOCUMENT_ROOT'].'/core/lib_karma.php'); 
    6444                                                                        if ($cfg['sort'] == 'rating'){ 
    65                                                                                 echo '<td style="font-weight:bold">'.cmsKarmaFormat($con['rating']).'</td>'; 
     45                                                                                $con['votes'] = cmsKarmaFormat($con['rating']); 
    6646                                                                        } else { 
    67                                                                                 echo '<td>'.$votes.'</td>'; 
     47                                                                                $con['votes'] = $con[$cfg['sort']]; 
    6848                                                                        } 
    6949                                                                } 
    7050                                                                if ($cfg['showcom']){ 
    71                                                                         echo '<td><img src="/images/icons/comments.gif" border="0"/></td>'; 
    72                                                                         echo '<td><a href="/photos/photo'.$con['id'].'.html#c">'.$inCore->getCommentsCount('photo', $con['id']).'</td>'; 
     51                                                                        $con['comments'] = $inCore->getCommentsCount('photo', $con['id']); 
    7352                                                                } 
    74                                                         echo '</tr></table>'; 
    75                                                         echo '</div>'; 
    7653                                                } 
    77                                         echo '</td>'; 
    78                                         echo '</tr>'; 
    7954                                } 
    80                                 echo '</table>'; 
    81                                 //echo '</div>'; 
    82                                 echo '</td>'; if ($col==$maxcols) { echo '</tr>'; $col=1; } else { $col++; } 
     55                                $cons[] = $con; 
    8356                        }                        
    84                         if ($col>1) { echo '<td colspan="'.($maxcols-$col+1).'">&nbsp;</td></tr>'; } 
    85                         echo '</table>'; 
    86                         if ($cfg['showmore']){ 
    87                                 echo '<div style="text-align:right"><a style="text-decoration:underline" href="/photos/top.html">'.$_LANG['BESTPHOTO_ALL_BEST_PHOTO'].'</a> &rarr;</div>'; 
    88                         } 
    89                 } else { echo '<p>'.$_LANG['BESTCONTENT_NOT_MATERIALS'].'</p>'; } 
     57                }  
     58                $smarty = $inCore->initSmarty('modules', 'mod_bestphoto.tpl');                   
     59                $smarty->assign('cons', $cons); 
     60                $smarty->assign('cfg', $cfg); 
     61                $smarty->assign('is_best', $is_best);                    
     62                $smarty->display('mod_bestphoto.tpl'); 
    9063                 
    91                                  
    9264                return true; 
    9365         
Note: See TracChangeset for help on using the changeset viewer.