root/trunk/inc/news/blog.inc.php

Revision 15, 3.0 KB (checked in by alexx, 7 years ago)
  • fix last bug in communities (see [14])
  • execute a "conversion smarty style" script ;) : for i in find . -type f | grep "\.php$" | grep -v "\.svn"; do perl -pi -e "s/\\\$smarty->assign\((.*),(.*)\);/\\\$_SMARTY\[\$1\] = \$2;/" $i; done
Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25$_SMARTY['Title'] =  'Last blog\'s tickets';
26
27if($token[2] == 'friends')
28{
29    $where_blog = "blog.id IN ('".implode("','", $_SESSION['my_friends_id'])."') AND";
30    $where_rss_blog_ticket = "id IN ('".implode("','", $_SESSION['my_friends_id'])."') AND";
31    error_log($where);
32}
33$blog_r = $db->query('
34        SELECT
35           blog.id AS id,
36           id_blog,
37           title,
38           chapeau,
39           ticket,
40           date,
41       blog_categorie.name AS cat_name
42        FROM
43           blog
44    LEFT JOIN
45       blog_categorie
46    USING (id_cat)
47        WHERE
48           blog.status=? AND
49       !
50       blog.date > ?
51        ORDER BY date DESC
52', array('online', $where_blog, time()-604800));
53while($blog =& $blog_r->fetchRow())
54{
55        if(strlen($blog['ticket'])>100)
56    {
57        $key = $blog['date'].str_pad($blog['id_blog'],6,0);
58                $blogs[$key] = $blog;
59        if(!$author[$blog['id']])
60                {
61            $author[$blog['id']] =& get_cache_user_info($blog['id'], 'id,fname,lname');
62                }
63    }
64}
65$blog_r = $db->query('
66        SELECT
67           id,
68           id_blog,
69           title,
70           description as chapeau,
71           link,
72           date
73        FROM
74           rss_blog_ticket
75        WHERE
76       !
77       rss_blog_ticket.date > ? AND
78       rss_blog_ticket.date < ?
79        ORDER BY date DESC
80',array($where_rss_blog_ticket, time()-604800, time()) );
81while($blog =& $blog_r->fetchRow())
82{
83        if(strlen($blog['chapeau'])>100)
84    {
85        $key = $blog['date'].str_pad($blog['id_blog'],6,0);
86                $blogs[$key] =& $blog;
87        if(!$author[$blog['id']])
88        {
89            $author[$blog['id']] =& get_cache_user_info($blog['id'], 'id,fname,lname');
90        }
91    }
92   
93}
94krsort($blogs);
95
96foreach($blogs as $key=>$blog)
97{
98    $day = date('Ymd', $blog['date']);
99
100    if($day != $last_day)
101    {
102        $blogs[$key]['day'] = $day;
103        $last_day = $day;
104        if($last_blog_day_key) $blogs[$last_blog_day_key]['next_day']=$day;
105        $last_blog_day_key = $key;
106    }
107    $blogs[$key]['author'] = $author[$blog['id']];
108}
109
110$_SMARTY['blogs' ] =  $blogs;
111
112?>
Note: See TracBrowser for help on using the browser.