1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # |
---|
4 | # This file is part of allBlogs, a plugin for Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2009 Philippe Amalgame and contributors |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ------------------------------------ |
---|
12 | |
---|
13 | if (!defined('DC_RC_PATH')) { return; } |
---|
14 | |
---|
15 | require dirname(__FILE__).'/_widgets.php'; |
---|
16 | |
---|
17 | l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/public'); |
---|
18 | |
---|
19 | $core->url->register('switchblog','switchblog','^switchblog$',array('switchurl','switchblog')); |
---|
20 | |
---|
21 | class switchurl extends dcUrlHandlers |
---|
22 | { |
---|
23 | public static function switchblog($args) |
---|
24 | { |
---|
25 | global $core; |
---|
26 | $url = $_POST['switchblog']; |
---|
27 | header('location:'.$url.''); |
---|
28 | |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | class publicAllBlogs |
---|
33 | { |
---|
34 | public static function allBlogs(&$w) |
---|
35 | { |
---|
36 | global $core; |
---|
37 | if ($w->homeonly && $core->url->type != 'default') { |
---|
38 | return; |
---|
39 | } |
---|
40 | if ($w->combo == '1') { |
---|
41 | $display = 'combo'; |
---|
42 | } |
---|
43 | $excluded = explode(",",$w->excluded); |
---|
44 | |
---|
45 | $res ='<div id="allblogs">'; |
---|
46 | //liste des blogs |
---|
47 | |
---|
48 | $thisblog = $core->blog->id; |
---|
49 | |
---|
50 | $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); |
---|
51 | $blogs = array(); |
---|
52 | |
---|
53 | //liste des blogs |
---|
54 | if (isset($display) != 'combo') { |
---|
55 | $res .= ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''); |
---|
56 | $res.= '<ul id=\'allblogs\'>'; |
---|
57 | while ($rs_blogs->fetch()) { |
---|
58 | $blog = $core->getBlog($rs_blogs->blog_id); |
---|
59 | $k = $rs_blogs->blog_id; |
---|
60 | if($blog->blog_status==1 && !$w->$k && !in_array($blog->blog_id,$excluded)) { |
---|
61 | if ($blog->blog_id != $thisblog) { |
---|
62 | $res .= '<li><a href="'.$blog->blog_url.'" title="'.__('Visit blog:').' '.$blog->blog_name.'">'.$blog->blog_name.'</a></li>'; |
---|
63 | } else { |
---|
64 | $res .= '<li><strong>'.$blog->blog_name.'</strong></li>'; |
---|
65 | } |
---|
66 | } |
---|
67 | } |
---|
68 | $res.='</ul>'; |
---|
69 | } else { |
---|
70 | $thisblogurl = $core->blog->url; |
---|
71 | $res.= '<form action="'.$thisblogurl.'switchblog" method="post"><h2><label for="switchblog">'.html::escapeHTML($w->title).'</label></h2>'. |
---|
72 | '<p><select name="switchblog" id="switchblog">'; |
---|
73 | while ($rs_blogs->fetch()) { |
---|
74 | $blog = $core->getBlog($rs_blogs->blog_id); |
---|
75 | $k = $rs_blogs->blog_id; |
---|
76 | if($blog->blog_status==1 && !$w->$k && !in_array($blog->blog_id,$excluded)) { |
---|
77 | if ($blog->blog_id != $thisblog) { |
---|
78 | $res .= '<option value="'.$blog->blog_url.'">'.$blog->blog_name.'</option>'; |
---|
79 | } else { |
---|
80 | $res .= '<option value="'.$blog->blog_url.'" selected="selected">'.$blog->blog_name.'</option>'; |
---|
81 | } |
---|
82 | } |
---|
83 | } |
---|
84 | $res.='</select></p><p><input type="submit" value="'.__('hop').'" /></p></form>'; |
---|
85 | // |
---|
86 | } |
---|
87 | $res .= '</div>'; |
---|
88 | return $res; |
---|
89 | } |
---|
90 | } |
---|
91 | ?> |
---|