root/branches/portal_by_daris/page.php

Revision 5, 3.8 KB (checked in by daris, 3 years ago)

portal: language files review

Line 
1<?php
2/***********************************************************************
3
4        PunBB extension
5        Portal
6        Daris <daris91@gmail.com>
7
8************************************************************************/
9
10
11// Make sure no one attempts to run this script "directly"
12if (!defined('FORUM'))
13        exit;
14
15if (!defined('FORUM_ROOT'))
16        define('FORUM_ROOT', '../../');
17
18if (!defined('FORUM_PORTAL'))
19        define('FORUM_PORTAL', $ext_info['path'].'/');
20
21($hook = get_hook('xn_portal_by_daris_pg_start')) ? eval($hook) : null;
22
23if ($forum_user['g_read_board'] == '0')
24        message($lang_common['No view']);
25
26// Load the portal.php language file
27if (file_exists(FORUM_PORTAL.'lang/'.$forum_user['language'].'/portal.php'))
28        require FORUM_PORTAL.'lang/'.$forum_user['language'].'/portal.php';
29else
30        require FORUM_PORTAL.'lang/English/portal.php';
31
32require FORUM_ROOT.'include/parser.php';
33
34$id = (isset($_GET['page']) ? intval($_GET['page']) : null);
35
36
37if (isset($id))
38{
39        // Fetch page
40        $query = array(
41                'SELECT'        => 'pg.id, pg.title, pg.content',
42                'FROM'          => 'pages AS pg',
43                'WHERE'         => 'pg.id='.$id
44        );
45
46        ($hook = get_hook('xn_portal_by_daris_pg_qr_get_page')) ? eval($hook) : null;
47        $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
48
49        if ($forum_db->num_rows($result) > 0)
50        {
51                $page = $forum_db->fetch_assoc($result);
52                $page['content'] = preg_replace('#\[page_title=(.*?)\]#s', "\n\t\t\t".'</div>'."\n\t\t".'</div>'."\n\t".'<div class="main-head">'."\n\t\t".'<h2 class="hn"><span>$1</span></h2>'."\n\t".'</div>'."\n\n\t".'<div class="main-content panel">'."\n\t\t".'<div class="entry-content panel-content">'."\n\t\t", $page['content']);
53        }
54        else
55                $page = array('title' => $lang_portal['Page does not exist'], 'content' => $lang_portal['Page does not exist']);
56
57        // Setup breadcrumbs
58        $forum_page['crumbs'] = array(
59                array($forum_config['o_board_title'], forum_link($forum_url['index'])),
60                array($page['title'], forum_link($forum_url['page_id'], array($id, sef_friendly($page['title'])))),
61        );
62
63        ($hook = get_hook('xn_portal_by_daris_pg_pre_header_load')) ? eval($hook) : null;
64
65        define('FORUM_ALLOW_INDEX', 1);
66        define('FORUM_PAGE', 'pages');
67        require FORUM_ROOT.'header.php';
68       
69        ob_start();
70
71        ($hook = get_hook('xn_portal_by_daris_pg_main_output_start')) ? eval($hook) : null;
72
73?>
74<div id="forum-main" class="main">
75
76        <div class="main-head">
77                <h2 class="hn"><span><?php echo forum_htmlencode($page['title']) ?></span></h2>
78        </div>
79
80        <div class="main-content panel">
81                <div class="entry-content panel-content">
82                        <?php echo $page['content'] ?>
83                </div>
84        </div>
85</div>
86<?php
87
88
89}
90else
91{
92        // Fetch list of pages
93        $query = array(
94                'SELECT'        => 'pg.id, pg.title, pg.content',
95                'FROM'          => 'pages AS pg',
96                'ORDER BY'      => 'pg.title ASC',
97        );
98
99        ($hook = get_hook('xn_portal_by_daris_pg_qr_get_pages')) ? eval($hook) : null;
100        $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
101
102        define('FORUM_ALLOW_INDEX', 1);
103        define('FORUM_PAGE', 'pages');
104        require FORUM_ROOT.'header.php';
105
106?>
107<div id="forum-main" class="main">
108
109        <div class="main-head">
110                <h2><span><?php echo $lang_portal['Pages'] ?></span></h2>
111        </div>
112
113        <div class="main-content portal">
114                <div class="entry-content">
115<?php
116
117        // If there are pages
118        if ($forum_db->num_rows($result))
119        {
120                while ($page = $forum_db->fetch_assoc($result)) {
121
122?>
123                        <a href="<?php echo forum_link($forum_url['page_id'], array($page['id'], sef_friendly($page['title']))) ?>"><?php echo forum_htmlencode($page['title']) ?></a><br />
124<?php
125
126                }
127        }
128        // Else there are no pages
129        else
130        {
131                echo $lang_portal['No pages'];
132
133        }
134?>
135                </div>
136        </div>
137</div>
138<?php
139}
140
141
142//$forum_id = $id;
143
144($hook = get_hook('xn_portal_by_daris_pg_end')) ? eval($hook) : null;
145
146$tpl_temp = trim(ob_get_contents());
147$tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
148ob_end_clean();
149// END SUBST - <!-- forum_main -->
150
151require FORUM_ROOT.'footer.php';
152
Note: See TracBrowser for help on using the browser.