root/branches/portal_by_daris/panels.php

Revision 23, 3.9 KB (checked in by daris, 3 years ago)

portal: removed avatar in news option

Line 
1<?php
2/***********************************************************************
3
4        PunBB extension
5        Portal
6        Daris <daris91@gmail.com>
7
8************************************************************************/
9
10if (defined('FORUM_PORTAL') && $forum_user['g_read_board'] != '0')
11{
12        if (file_exists(FORUM_PORTAL.'lang/'.$forum_user['language'].'/portal.php'))
13                require_once FORUM_PORTAL.'lang/'.$forum_user['language'].'/portal.php';
14        else
15                require_once FORUM_PORTAL.'lang/English/portal.php';
16
17        $left_width = isset($forum_config['o_portal_left_width']) ? intval($forum_config['o_portal_left_width']) : '15';
18        $right_width = isset($forum_config['o_portal_right_width']) ? intval($forum_config['o_portal_right_width']) : '15';
19
20        $panels_output = array(
21                0 => array(),
22                1 => array(),
23                2 => array(),
24                3 => array()
25        );
26
27        foreach ($forum_panels as $location => $panels)
28        {
29                foreach ($panels as $cur_panel)
30                {
31                        if ($left_width == 0 && $location == 0 || $right_width == 0 && $location == 3 || FORUM_PAGE == 'pages' && $location == 3 || $forum_config['o_portal_panels_all_pages'] == 1 && $location == 3 && !in_array(FORUM_PAGE, array('news', 'pages')))
32                                continue;
33                       
34                        ob_start();
35       
36                        // default class for content element, panels can change it
37                        $cur_panel['class'] = 'panel-content';
38       
39                        $file = FORUM_ROOT.'extensions/'.$cur_panel['file'];
40                       
41                        // if panel file exists require it
42                        if ($cur_panel['file'] != '' && file_exists($file) && is_file($file))
43                                require_once $file;
44
45                        // if panel doesn't contain php code just echo it
46                        else if (strpos($cur_panel['content'], '<?') === false)
47                                echo $cur_panel['content'];
48       
49                        // else evaluate panel content
50                        else
51                                eval('?>'.$cur_panel['content']);
52       
53                        $cur_panel['content'] = ob_get_contents();
54                        ob_end_clean();
55
56                        if (!trim($cur_panel['content']))
57                                continue;
58               
59                                ob_start();
60?>      <div class="panel">
61
62                <div class="main-head">
63                        <h2 class="hn"><span><?php echo $cur_panel['name'] ?></span></h2>
64                </div>
65
66                <div class="main-content <?php echo $cur_panel['class'] ?>">
67<?php echo $cur_panel['content'] ?>
68
69                </div>
70
71        </div>
72<?php
73
74                        // insert panel html to specified side
75                        $panels_output[$location][] = ob_get_contents();
76       
77                        ob_end_clean();
78                }
79        }
80
81        // generate portal_top replacement
82        $tpl_temp = "\n".'<div id="leftside">';
83        $tpl_temp .= "\n".implode("\n", $panels_output[0]);
84        $tpl_temp .= "\n".'</div>';
85
86        $tpl_temp .= "\n".'<div id="rightside">';
87        $tpl_temp .= "\n".implode("\n", $panels_output[3]);
88        $tpl_temp .= "\n".'</div>';
89
90        $tpl_temp .= "\n".'<div id="center">';
91        $tpl_temp .= (FORUM_PAGE == 'news' ? "\n".implode("\n", $panels_output[1]) : '');
92       
93        $tpl_main = str_replace('<!-- portal_top -->', $tpl_temp, $tpl_main);
94
95        // generate portal_bottom replacement
96        $tpl_temp = (FORUM_PAGE == 'news' ? "\n".implode("\n", $panels_output[2]) : '');
97        $tpl_temp .= "\n".'</div>';
98
99        $tpl_temp .= "\n".'<div style="clear: both"></div>';
100        $tpl_main = str_replace('<!-- portal_bottom -->', $tpl_temp, $tpl_main);
101
102        $style_center = '';
103
104        if (!count($panels_output[0]))
105                $left_width = 0;
106       
107        if (!count($panels_output[3]))
108                $right_width = 0;
109
110        // Calculate center width
111        $center_width = 100 - $left_width - $right_width;
112        if (count($panels_output[0]) && count($panels_output[3]))
113        {
114                $center_width -= 2;
115                $left_width .= '%; margin-right: 1'; // 1%
116        }
117        elseif (!count($panels_output[0]) && !count($panels_output[3])) { /* do nothing */ }
118       
119        elseif (!count($panels_output[0]))
120                $center_width -= 1;
121
122        elseif (!count($panels_output[3]))
123        {
124                $center_width -= 1;
125                $style_center .= 'float: right;';
126        }
127       
128        // Generate css
129        $style = array();
130        if ($left_width != 0)
131                $style[] = '#leftside { width: '.$left_width.'%; }';
132               
133        if ($right_width != 0)
134                $style[] = '#rightside { width: '.$right_width.'%; }';
135       
136        $style[] = '#center { width: '.$center_width.'%; '.$style_center.'}';
137
138        $style_html = '<style type="text/css">'."\n".implode("\n", $style)."\n".'</style>';
139
140        $tpl_main = str_replace('</head>', $style_html."\n".'</head>', $tpl_main);
141}
Note: See TracBrowser for help on using the browser.