C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$RWF6OMG\mambots\content\mospaging.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
/**
* @version $Id: mospaging.php 2574 2006-02-23 18:48:16Z stingrey $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined'_VALID_MOS' ) or die( 'Restricted access' );

$_MAMBOTS->registerFunction'onPrepareContent''botMosPaging' );

/**
* Page break mambot
*
* <b>Usage:</b>
* <code>{mospagebreak}</code>
* <code>{mospagebreak title=The page title}</code>
* or
* <code>{mospagebreak heading=The first page}</code>
* or
* <code>{mospagebreak title=The page title&heading=The first page}</code>
* or
* <code>{mospagebreak heading=The first page&title=The page title}</code>
*
*/
function botMosPaging$published, &$row, &$params$page=) {
    global 
$mainframe$Itemid$database$_MAMBOTS;

    
// simple performance check to determine whether bot should process further
    
if ( strpos$row->text'mospagebreak' ) === false ) {
        return 
true;
    }
    
     
// expression to search for
     
$regex '/{(mospagebreak)\s*(.*?)}/i';

     
// check whether mambot has been unpublished
    
if (!$published || $params->get'intro_only' )|| $params->get'popup' )) {
        
$row->text preg_replace$regex''$row->text );
        return;
    }

    
// find all instances of mambot and put in $matches
    
$matches = array();
    
preg_match_all$regex$row->text$matchesPREG_SET_ORDER );

    
// split the text around the mambot
    
$text preg_split$regex$row->text );

    
// count the number of pages
    
$n count$text );

    
// we have found at least one mambot, therefore at least 2 pages
    
if ($n 1) {
        
// check if param query has previously been processed
        
if ( !isset($_MAMBOTS->_content_mambot_params['mospaging']) ) {
            
// load mambot params info
            
$query "SELECT params"
            
"\n FROM #__mambots"
            
"\n WHERE element = 'mospaging'"
            
"\n AND folder = 'content'"
            
;
            
$database->setQuery$query );
            
$database->loadObject($mambot);        
            
            
// save query to class variable
            
$_MAMBOTS->_content_mambot_params['mospaging'] = $mambot;
        }
        
        
// pull query data from class variable
        
$mambot $_MAMBOTS->_content_mambot_params['mospaging'];
        
         
$botParams = new mosParameters$mambot->params );

         
$title    $botParams->def'title');

         
// adds heading or title to <site> Title
         
if ( $title ) {
            
$page_text $page 1;
            
$row->page_title _PN_PAGE .' '$page_text;
            if ( !
$page ) {
                
// processing for first page
                
parse_strhtml_entity_decode$matches[0][2] ), $args );

                if ( @
$args['heading'] ) {
                    
//$row->page_title = $args['heading'];
                    
$row->page_title '';
                } else {
                    
$row->page_title '';
                }
            } else if ( 
$matches[$page-1][2] ) {
                
parse_strhtml_entity_decode$matches[$page-1][2] ), $args );

                if ( @
$args['title'] ) {
                    
$row->page_title ': 'stripslashes$args['title'] );
                }
            }
         }

        
// reset the text, we already hold it in the $text array
        
$row->text '';

        
$hasToc $mainframe->getCfg'multipage_toc' );

        if ( 
$hasToc ) {
            
// display TOC
            
createTOC$row$matches$page );
        } else {
            
$row->toc '';
        }

        
// traditional mos page navigation
        
require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php' );
        
$pageNav = new mosPageNav$n$page);

        
// page counter
        
$row->text .= '<div class="pagenavcounter">';
        
$row->text .= $pageNav->writeLeafsCounter();
        
$row->text .= '</div>';

        
// page text
        
$row->text .= $text[$page];

        
$row->text .= '<br />';
        
$row->text .= '<div class="pagenavbar">';

        
// adds navigation between pages to bottom of text
        
if ( $hasToc ) {
            
createNavigation$row$page$n );
        }

        
// page links shown at bottom of page if TOC disabled
        
if (!$hasToc) {
            
$row->text .= $pageNav->writePagesLinks'index.php?option=com_content&amp;task=view&amp;id='$row->id .'&amp;Itemid='$Itemid );
        }

        
$row->text .= '</div><br />';
    }

    return 
true;
}

function 
createTOC( &$row, &$matches, &$page ) {
    global 
$Itemid;

    
$nonseflink 'index.php?option=com_content&amp;task=view&amp;id='$row->id .'&amp;Itemid='$Itemid;
    
$link 'index.php?option=com_content&amp;task=view&amp;id='$row->id .'&amp;Itemid='$Itemid;
    
$link sefRelToAbs$link );

    
$heading $row->title;
    
// allows customization of first page title by checking for `heading` attribute in first bot
    
if ( @$matches[0][2] ) {
        
parse_strhtml_entity_decode$matches[0][2] ), $args );

        if ( @
$args['heading'] ) {
            
$heading $args['heading'];
            
$row->title .= ' - '$heading;
        }
    }

    
// TOC Header
    
$row->toc '
    <table cellpadding="0" cellspacing="0" class="contenttoc" align="right">
    <tr>
        <th>'
        
_TOC_JUMPTO .
        
'</th>
    </tr>
    '
;

    
// TOC First Page link
    
$row->toc .= '
    <tr>
        <td>
        <a href="'
$link .'" class="toclink">'
        
$heading .
        
'</a>
        </td>
    </tr>
    '
;

    
$i 2;
    
$args2 = array();

    foreach ( 
$matches as $bot ) {
        
$link $nonseflink .'&amp;limit=1&amp;limitstart='. ($i-1);
        
$link sefRelToAbs$link );

        if ( @
$bot[2] ) {
            
parse_strhtml_entity_decode$bot[2] ), $args2 );
            
            if ( @
$args2['title'] ) {
                
$row->toc .= '
                <tr>
                    <td>
                    <a href="'
$link .'" class="toclink">'
                    
stripslashes$args2['title'] ) .
                    
'</a>
                    </td>
                </tr>
                '
;
            } else {
                
$row->toc .= '
                <tr>
                    <td>
                    <a href="'
$link .'" class="toclink">'
                    
_PN_PAGE .' '$i .
                    
'</a>
                    </td>
                </tr>
                '
;
            }
        } else {
            
$row->toc .= '
            <tr>
                <td>
                <a href="'
$link .'" class="toclink">'
                
_PN_PAGE .' '$i .
                
'</a>
                </td>
            </tr>
            '
;
        }
        
$i++;
    }

    
$row->toc .= '</table>';
}

function 
createNavigation( &$row$page$n ) {
    global 
$Itemid;

    
$link 'index.php?option=com_content&amp;task=view&amp;id='$row->id .'&amp;Itemid='$Itemid;

    if ( 
$page $n-) {
        
$link_next $link .'&amp;limit=1&amp;limitstart='. ( $page );
        
$link_next sefRelToAbs$link_next );

        
$next '<a href="'$link_next .'">' ._CMN_NEXT _CMN_NEXT_ARROW .'</a>';
    } else {
        
$next _CMN_NEXT;
    }

    if ( 
$page ) {
        
$link_prev $link .'&amp;limit=1&amp;limitstart='. ( $page );
        
$link_prev sefRelToAbs$link_prev );

        
$prev '<a href="'$link_prev .'">'_CMN_PREV_ARROW _CMN_PREV .'</a>';
    } else {
        
$prev _CMN_PREV;
    }

    
$row->text .= '<div>' $prev ' - ' $next .'</div>';
}
?>