Changeset 236


Ignore:
Timestamp:
07/28/10 10:35:12 (19 months ago)
Author:
fuze
Message:

Модуль популярные статьи: добавлен выбор категории

Location:
branches/fuze
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/fuze/admin/modules/mod_bestcontent/backend.php

    r181 r236  
    3737                $cfg['showlink'] = $_REQUEST['showlink']; 
    3838                $cfg['showdesc'] = $_REQUEST['showdesc']; 
     39                $cfg['cat_id'] = $_REQUEST['cat_id']; 
    3940 
     41                if (!isset($_REQUEST['subs'])) { $cfg['subs'] = 0; } else { $cfg['subs'] = 1; } 
     42                 
    4043        $inCore->saveModuleConfig($_REQUEST['id'], $cfg); 
    4144                $msg = 'Íàñòðîéêè ñîõðàíåíû.'; 
    4245 
    4346        } 
    44          
     47        if (!isset($cfg['subs'])) { $cfg['subs'] = 0;} 
    4548        if (@$msg) { echo '<p class="success">'.$msg.'</p>'; } 
    4649 
     
    6770Íåò</td> 
    6871    </tr> 
     72        <tr> 
     73            <td valign="top"><strong>Ìàòåðèàëû èç ðàçäåëà:</strong> </td> 
     74            <td valign="top"><div><select name="cat_id" id="cat_id"> 
     75              <option value="-1">-- Âñå ðàçäåëû --</option> 
     76              <?php 
     77                  if (isset($cfg['cat_id'])) { 
     78                        echo $inCore->getListItemsNS('cms_category', $cfg['cat_id']); 
     79                    } else { 
     80                       echo $inCore->getListItemsNS('cms_category'); 
     81                    } 
     82              ?> 
     83            </select></div> 
     84              <div style="margin-top:5px"> 
     85                <table border="0" cellspacing="0" cellpadding="0"> 
     86                  <tr> 
     87                    <td><input name="subs" type="checkbox" value="1" <?php if (@$cfg['subs']) { echo 'checked'; } ?>/></td> 
     88                    <td>Âìåñòå ñ ïîäðàçäåëàìè </td> 
     89                  </tr> 
     90                </table> 
     91            </div></td> 
     92     </tr> 
    6993  </table> 
    7094  <p> 
  • branches/fuze/modules/mod_bestcontent/module.php

    r181 r236  
    2323                        return; 
    2424                } 
     25                if (!isset($cfg['subs'])) { $cfg['subs'] = 1; } 
    2526                $today = date("Y-m-d H:i:s"); 
     27                if ($cfg['cat_id'] != '-1') { 
     28                        if (!$cfg['subs']){ 
     29                                //âûáèðàåì èç êàòåãîðèè 
     30                                $catsql = ' AND c.category_id = '.$cfg['cat_id']; 
     31                        } else { 
     32                                //âûáèðàåì èç êàòåãîðèè è ïîäêàòåãîðèé 
     33                                $rootcat = $inDB->get_fields('cms_category', 'id='.$cfg['cat_id'], 'NSLeft, NSRight'); 
     34                                $catsql = "AND (c.category_id = cat.id AND cat.NSLeft >= {$rootcat['NSLeft']} AND cat.NSRight <= {$rootcat['NSRight']})"; 
     35                        }                
     36                } else { $catsql = 'AND c.category_id = cat.id'; }  
     37 
    2638 
    2739                $sql = "SELECT c.*, c.pubdate as fpubdate,  
    2840                        IFNULL(r.total_rating, 0) as points, 
    2941                                                u.nickname as author, u.login as author_login 
    30                                 FROM cms_users u, cms_content c 
     42                                FROM cms_category cat, cms_users u, cms_content c 
    3143                                LEFT JOIN cms_ratings_total r ON r.item_id=c.id AND r.target='content' 
    3244                                WHERE c.published = 1 AND c.user_id = u.id AND c.canrate = 1 
    3345                AND (c.is_end=0 OR (c.is_end=1 AND c.enddate >= '$today' AND c.pubdate <= '$today'))  
     46                                ".$catsql." 
    3447                                GROUP BY r.item_id 
    3548                                ORDER BY points DESC"; 
     
    3750                $sql .= "\n" . "LIMIT ".$cfg['shownum']; 
    3851         
    39                 $result = $inDB->query($sql) or die('<pre>'.$sql.'</pre>'.mysql_error()); 
     52                $result = $inDB->query($sql); 
    4053                 
    4154                if ($inDB->num_rows($result)){ 
Note: See TracChangeset for help on using the changeset viewer.