~quam-plures-core/quam-plures/bug-614012

« back to all changes in this revision

Viewing changes to qp_inc/templates/_template.funcs.php

  • Committer: Tilman Blumenbach
  • Author(s): Yabs
  • Date: 2010-07-25 11:35:24 UTC
  • mfrom: (7512.2.3 qp-404s)
  • Revision ID: tilman@ax86.net-20100725113524-xezuync9zhw1ds3x
MergedĀ qp-404s

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 *
35
35
 * @param string What are we going to display. Most of the time the global $disp should be passed.
36
36
 */
37
 
function template_init( $disp )
 
37
function template_init( & $disp )
38
38
{
39
39
        /**
40
40
         * @var Blog
92
92
                        break;
93
93
        }
94
94
 
 
95
        $current_disp = $disp;
 
96
        if(
 
97
                        (
 
98
                                $disp != 'posts'
 
99
                                && !empty( $MainList )
 
100
                                && ( $ffs = mainlist_get_item() )
 
101
                                && ( $bar = param( 'page', 'integer', 1, true ) )
 
102
                                && (
 
103
                                        ( $ffs->split_pages() != 'hello world' )
 
104
                                        && $bar > 1
 
105
                                        && $bar > $ffs->pages
 
106
                                )
 
107
                        )
 
108
                        || ( ( $bar = param( 'page', 'integer', 1, true ) ) && $bar < 0 )
 
109
                )
 
110
        {
 
111
                $disp = '404';
 
112
                $disp_detail = '404-post-page-not-found';
 
113
        }
 
114
 
 
115
        if( !empty( $MainList )
 
116
                        && ( $foo = param( $MainList->page_param, 'integer', 1, true ) )
 
117
                        &&
 
118
                        (
 
119
                                (
 
120
                                        $foo > 1 && $foo > $MainList->total_pages
 
121
                                )
 
122
                                ||
 
123
                                (
 
124
                                        $foo < 0
 
125
                                )
 
126
                        )
 
127
                )
 
128
        {
 
129
                $disp = '404';
 
130
                $disp_detail = '404-mainlist-page-not-found';
 
131
        }
 
132
 
 
133
        if( !empty( $MainList ) )
 
134
        {
 
135
                $MainList->restart();
 
136
        }
 
137
 
 
138
        if( $current_disp != $disp )
 
139
        { // looks like we 404'd
 
140
                global $disp_handlers, $ads_current_template_path;
 
141
                if( !empty( $disp_handlers[ $disp ] ) && file_exists( $disp_handler = $ads_current_template_path.$disp_handlers[$disp] ) )
 
142
                {
 
143
                        $Debuglog->add('blog_main: include '.rel_path_to_base($disp_handler).' (custom to this template)', 'template');
 
144
                        require $disp_handler;
 
145
                        exit;
 
146
                }
 
147
                else
 
148
                {       // Use the default handler from the templates dir:
 
149
                        $Debuglog->add('blog_main: include '.rel_path_to_base($ads_current_template_path.'index.main.php').' (default handler)', 'template');
 
150
                        require $ads_current_template_path.'index.main.php';
 
151
                        exit;
 
152
                }
 
153
        }
 
154
 
95
155
        // SEO stuff:
96
156
        $seo_page_type = NULL;
97
157
        switch( $disp )