Changeset 233


Ignore:
Timestamp:
07/22/10 13:01:09 (19 months ago)
Author:
fuze
Message:

Модуль новинки каталога вынесен в шаблон

Location:
branches/fuze
Files:
1 added
1 edited

Legend:

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

    r181 r233  
    3030                } 
    3131                 
    32                 $showtype = $cfg['showtype']; 
    33  
    3432                $sql = "SELECT i.*, i.pubdate as fdate, c.view_type as viewtype 
    3533                                FROM cms_uc_items i, cms_uc_cats c 
     
    4038                $result = $inDB->query($sql); 
    4139                 
     40                $items = array(); 
     41                $is_uc = false; 
     42                 
    4243                if ($inDB->num_rows($result)){   
    43                         if ($showtype=='thumb'){ 
     44                        $is_uc = true; 
     45                        if ($cfg['showtype']=='thumb'){ 
    4446                                        while($item = $inDB->fetch_assoc($result)){ 
    45                                                 echo '<div class="uc_latest_item">'; 
    46                                                         echo '<table border="0" cellspacing="2" cellpadding="0" width="100%">'; 
    47                                                                 echo '<tr><td height="110" align="center" valign="middle">'; 
    48                                                                         echo '<a href="/catalog/item'.$item['id'].'.html">'; 
    49                                                                         if (strlen($item['imageurl'])>4) { 
    50                                                                                 echo '<img alt="'.$item['title'].'" src="/images/catalog/small/'.$item['imageurl'].'.jpg" border="0" />'; 
    51                                                                         } else { 
    52                                                                                 echo '<img alt="'.$item['title'].'" src="/images/catalog/small/nopic.jpg" border="0" />';                                                                
    53                                                                         } 
    54                                                                         echo '</a>'; 
    55                                                                 echo '</td></tr>'; 
    56                                                                 echo '<tr><td align="center" valign="middle">'; 
    57                                                                         echo '<a class="uc_latest_link" href="/catalog/item'.$item['id'].'.html">'.$item['title'].'</a>';                                                                
    58                                                                 echo '</td></tr>';       
    59                                                                 if ($item['viewtype']=='shop'){ 
    60                                                                         echo '<tr><td align="center" valign="middle">'; 
    61                                                                                 $price = number_format($item['price'], 2, '.', ' '); 
    62                                                                                 echo '<div id="uc_latest_price">'.$price.' ðóá.</div>';                                                          
    63                                                                         echo '</td></tr>';       
    64                                                                 }                                                                                                        
    65                                                         echo '</table>'; 
    66                                                 echo '</div>';                           
     47                                                if (strlen($item['imageurl'])<4) { 
     48                                                        $item['imageurl'] = 'nopic'; 
     49                                                } elseif (!file_exists(PATH.'/images/catalog/small/'.$item['imageurl'].'.jpg')) { 
     50                                                        $item['imageurl'] = 'nopic'; 
     51                                                }  
     52                                                if ($item['viewtype']=='shop'){ 
     53                                                        $item['price'] = number_format($item['price'], 2, '.', ' '); 
     54                                                } 
     55                                                $items[] =      $item;                                                                                           
    6756                                        } 
    6857                        } 
    6958                         
    70                         if ($showtype='list'){ 
    71                                 echo '<table width="100%" cellspacing="0" cellpadding="4" class="uc_latest_list">'; 
     59                        if ($cfg['showtype']=='list'){ 
    7260                                        while($item = $inDB->fetch_assoc($result)){ 
    73                                                 $fdata = unserialize($item['fieldsdata']); 
    74                                                 echo '<tr>'; 
    75                                                         echo '<td width="" valign="top"><a class="uc_latest_link" href="/catalog/item'.$item['id'].'.html">'.substr($item['title'], 0, 40).'...</a></td>'; 
     61                                                        $item['fieldsdata'] = unserialize($item['fieldsdata']); 
     62                                                        $item['title'] = substr($item['title'], 0, 40); 
     63                                                         
    7664                                                        for($f = 0; $f<$cfg['showf']; $f++){ 
    77                                                                 echo '<td valign="top">'.$inCore->getUCSearchLink($item['category_id'], null, $f, $fdata[$f]).'</td>'; 
    78                                                         }                                                        
    79                                                         echo '<td width="" align="right" valign="top">'.$inCore->dateFormat($item['fdate']).'</td>'; 
    80                                                                 echo '<td align="right">'; 
     65                                                                $item['fdata'][] = $inCore->getUCSearchLink($item['category_id'], null, $f, $item['fieldsdata'][$f]); 
     66                                                        }        
     67                                                                                                         
     68                                                        $item['fdate'] = $inCore->dateFormat($item['fdate']); 
    8169                                                        if ($item['viewtype']=='shop'){ 
    82                                                                         $price = number_format($item['price'], 2, '.', ' '); 
    83                                                                         echo '<div id="uc_latest_price">'.$price.' ðóá.</div>';  
     70                                                                $item['price'] = number_format($item['price'], 2, '.', ' '); 
    8471                                                        }        
    85                                                                 echo '</td>'; 
    86                                                 echo '</tr>'; 
     72                                                        $items[] =      $item;   
    8773                                        }                                
    88                                 echo '</table>'; 
    89                                 if ($cfg['fulllink']){ 
    90                                         echo '<div style="margin-top:5px; text-align:right; clear:both"><a href="/catalog">Âåñü êàòàëîã</a> &rarr;</div>'; 
    91                                 } 
    9274                        } 
    93                 } else { echo '<p>Íåò îáúåêòîâ äëÿ îòîáðàæåíèÿ.</p>'; } 
     75                }  
     76                 
     77                $smarty = $inCore->initSmarty('modules', 'mod_latest_uc.tpl');                   
     78                $smarty->assign('items', $items); 
     79                $smarty->assign('cfg', $cfg); 
     80                $smarty->assign('is_uc', $is_uc);                        
     81                $smarty->display('mod_latest_uc.tpl'); 
    9482                 
    9583                return true; 
Note: See TracChangeset for help on using the changeset viewer.