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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
<?php
/**
* $Header: /cvsroot/bitweaver/_bit_wiki/display_bitpage_inc.php,v 1.14 2006/02/04 19:04:34 squareing Exp $
*
* Copyright (c) 2004 bitweaver.org
* Copyright (c) 2003 tikwiki.org
* Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
*
* $Id: display_bitpage_inc.php,v 1.14 2006/02/04 19:04:34 squareing Exp $
* @package wiki
* @subpackage functions
*/
/**
* required setup
*/
include_once( WIKI_PKG_PATH.'BitBook.php');
$gBitSystem->verifyPackage( 'wiki' );
$gBitSystem->verifyPermission( 'bit_p_view' );
// Check permissions to access this page
if( !$gContent->isValid() ) {
$gBitSystem->fatalError( 'Page cannot be found' );
}
$displayHash = array( 'perm_name' => 'bit_p_view' );
$gContent->invokeServices( 'content_display_function', $displayHash );
/*
$gBitSmarty->assign('structure','n');
//Has a structure page been requested
if (isset($_REQUEST["structure_id"])) {
$structure_id = $_REQUEST["structure_id"];
} else {
//if not then check if page is the head of a structure
$structure_id = $structlib->get_struct_ref_if_head( $gContent->mPageName );
}
$gBitSmarty->assign_by_ref('page',$gContent->mInfo['title']);
*/
require_once( WIKI_PKG_PATH.'page_setup_inc.php' );
// Let creator set permissions
if($gBitSystem->isFeatureActive( 'wiki_creator_admin' )) {
if( $gContent->isOwner() ) {
$gBitUser->mPrefs['bit_p_admin_wiki'] = TRUE;
}
}
if(isset($_REQUEST["copyrightpage"])) {
$gBitSmarty->assign_by_ref('copyrightpage',$_REQUEST["copyrightpage"]);
}
if( $gBitSystem->isFeatureActive( 'feature_backlinks' ) ) {
// Get the backlinks for the page "page"
$backlinks = $gContent->getBacklinks();
$gBitSmarty->assign_by_ref('backlinks', $backlinks);
}
// Update the pagename with the canonical name. This makes it
// possible to link to a page using any case, but the page is still
// displayed with the original capitalization. So if there's a page
// called 'About Me', then one can conveniently make a link to it in
// the text as '... learn more ((about me)).'. When the link is
// followed,
$gBitSystem->setBrowserTitle( $gContent->mInfo['title'] );
// BreadCrumbNavigation here
// Get the number of pages from the default or userPreferences
// Remember to reverse the array when posting the array
$anonpref = $wikilib->getPreference('userbreadCrumb',4);
if(!empty($user)) {
$userbreadCrumb = $gBitUser->getPreference( 'userbreadCrumb', $anonpref );
} else {
$userbreadCrumb = $anonpref;
}
if(!isset($_SESSION["breadCrumb"])) {
$_SESSION["breadCrumb"]=Array();
}
if(!in_array($gContent->mInfo['title'],$_SESSION["breadCrumb"])) {
if(count($_SESSION["breadCrumb"])>$userbreadCrumb) {
array_shift($_SESSION["breadCrumb"]);
}
array_push($_SESSION["breadCrumb"],$gContent->mInfo['title']);
} else {
// If the page is in the array move to the last position
$pos = array_search($gContent->mInfo['title'], $_SESSION["breadCrumb"]);
unset($_SESSION["breadCrumb"][$pos]);
array_push($_SESSION["breadCrumb"],$gContent->mInfo['title']);
}
//print_r($_SESSION["breadCrumb"]);
// Now increment page hits since we are visiting this page
if( $gBitSystem->isFeatureActive( 'count_admin_pvs' ) || !$gBitUser->isAdmin() ) {
$gContent->addHit();
}
// Check if we have to perform an action for this page
// for example lock/unlock
if( isset( $_REQUEST["action"] ) && (($_REQUEST["action"] == 'lock' || $_REQUEST["action"]=='unlock' ) &&
($gBitUser->hasPermission( 'bit_p_admin_wiki' )) || ($user and ($gBitUser->hasPermission( 'bit_p_lock' )) and ($gBitSystem->isFeatureActive( 'feature_wiki_usrlock' )))) ) {
$gContent->setLock( ($_REQUEST["action"] == 'lock' ? 'L' : NULL ) );
$gBitSmarty->assign('lock', ($_REQUEST["action"] == 'lock') );
}
// Save to notepad if user wants to
if( $gBitSystem->isPackageActive( 'notepad' ) && $gBitUser->isValid() && $gBitUser->hasPermission( 'bit_p_notepad' ) && isset($_REQUEST['savenotepad'])) {
require_once( NOTEPAD_PKG_PATH.'notepad_lib.php' );
$notepadlib->replace_note( $user, 0, $gContent->mPageName, $gContent->mInfo['data'] );
}
// Assign lock status
$gBitSmarty->assign('lock', $gContent->isLocked() );
// If not locked and last version is user version then can undo
$gBitSmarty->assign('canundo','n');
if( !$gContent->isLocked() && ( ($gBitUser->hasPermission( 'bit_p_edit' ) == 'y' && $gContent->mInfo["modifier_user_id"]==$gBitUser->mUserId) || $gBitUser->hasPermission( 'bit_p_remove' ) ) ) {
$gBitSmarty->assign('canundo','y');
}
if($gBitUser->hasPermission( 'bit_p_admin_wiki' )) {
$gBitSmarty->assign('canundo','y');
}
// Process an undo here
if(isset($_REQUEST["undo"])) {
if($gBitUser->hasPermission( 'bit_p_admin_wiki' ) || ($gContent->mInfo["flag"]!='L' && ( ($gBitUser->hasPermission( 'bit_p_edit' ) && $gContent->mInfo["user"]==$user)||($gBitUser->hasPermission( 'bit_p_remove' ))) )) {
// Remove the last version
$gContent->removeLastVersion();
// If page was deleted then re-create
if( !$fPID ) {
$wikilib->create_page($gContent->mInfo['title'],0,'',$gBitSystem->getUTCTime(),'Tiki initialization');
}
}
}
if ($gBitSystem->isFeatureActive( 'wiki_uses_slides' )) {
$slides = split("-=[^=]+=-",$gContent->mInfo["data"]);
if(count($slides)>1) {
$gBitSmarty->assign('show_slideshow','y');
} else {
$slides = explode(defined('PAGE_SEP') ? PAGE_SEP : "...page...",$gContent->mInfo["data"]);
if(count($slides)>1) {
$gBitSmarty->assign('show_slideshow','y');
} else {
$gBitSmarty->assign('show_slideshow','n');
}
}
} else {
$gBitSmarty->assign('show_slideshow','n');
}
if(isset($_REQUEST['refresh'])) {
$gContent->invalidateCache();
}
// Here's where the data is parsed
// if using cache
//
// get cache information
// if cache is valid then pdata is cache
// else
// pdata is parse_data
// if using cache then update the cache
// assign_by_ref
$gBitSmarty->assign('cached_page','n');
$wiki_cache=$gBitSystem->getPreference( 'wiki_cache' );
if(isset($gContent->mInfo['wiki_cache']) && $gContent->mInfo['wiki_cache']>0) {
$wiki_cache=$gContent->mInfo['wiki_cache'];
}
if($wiki_cache>0) {
$cache_info = $gContent->get_cache_info($gContent->mInfo['title']);
$now = $gBitSystem->getUTCTime();
if($cache_info['cache_timestamp']+$wiki_cache > $now) {
$pdata = $cache_info['cache'];
$gBitSmarty->assign('cached_page','y');
} else {
$pdata = $gContent->parseData();
$gContent->updateCache( $pdata );
}
} else {
$pdata = $gContent->parseData();
}
$pages = $wikilib->countPages($pdata);
if( $pages > 1 ) {
if(!isset($_REQUEST['pagenum'])) {
$_REQUEST['pagenum']=1;
}
$pdata=$wikilib->get_page($pdata,$_REQUEST['pagenum']);
$gBitSmarty->assign('pages',$pages);
if($pages>$_REQUEST['pagenum']) {
$gBitSmarty->assign('next_page',$_REQUEST['pagenum']+1);
} else {
$gBitSmarty->assign('next_page',$_REQUEST['pagenum']);
}
if($_REQUEST['pagenum']>1) {
$gBitSmarty->assign('prev_page',$_REQUEST['pagenum']-1);
} else {
$gBitSmarty->assign('prev_page',1);
}
$gBitSmarty->assign('first_page',1);
$gBitSmarty->assign('last_page',$pages);
$gBitSmarty->assign('pagenum',$_REQUEST['pagenum']);
}
$gBitSmarty->assign_by_ref('parsed',$pdata);
//$gBitSmarty->assign_by_ref('last_modified',date("l d of F, Y [H:i:s]",$gContent->mInfo["last_modified"]));
$gBitSmarty->assign_by_ref('last_modified',$gContent->mInfo["last_modified"]);
if(empty($gContent->mInfo["user"])) {
$gContent->mInfo["user"]='anonymous';
}
$gBitSmarty->assign_by_ref('lastUser',$gContent->mInfo["user"]);
$gBitSmarty->assign_by_ref('description',$gContent->mInfo["description"]);
// Comments engine!
if( $gBitSystem->isFeatureActive( 'feature_wiki_comments' ) ) {
$comments_vars = Array('page');
$comments_prefix_var='wiki page:';
$comments_object_var='page';
$commentsParentId = $gContent->mContentId;
$comments_return_url = WIKI_PKG_URL.'index.php?page_id='.$gContent->mPageId;
include_once( LIBERTY_PKG_PATH.'comments_inc.php' );
}
if( $gBitSystem->isFeatureActive( 'feature_wiki_attachments' ) ) {
if(isset($_REQUEST["removeattach"])) {
$owner = $wikilib->get_attachment_owner($_REQUEST["removeattach"]);
if( ($user && ($owner == $user) ) || ($gBitUser->hasPermission( 'bit_p_wiki_admin_attachments' )) ) {
$wikilib->remove_wiki_attachment($_REQUEST["removeattach"]);
}
}
if(isset($_REQUEST["attach"]) && ($gBitUser->hasPermission( 'bit_p_wiki_admin_attachments' ) || $gBitUser->hasPermission( 'bit_p_wiki_attach_files' ))) {
// Process an attachment here
if(isset($_FILES['userfile1'])&&is_uploaded_file($_FILES['userfile1']['tmp_name'])) {
$fp = fopen($_FILES['userfile1']['tmp_name'],"rb");
$data = '';
$fhash='';
if($w_use_db == 'n') {
$fhash = md5($name = $_FILES['userfile1']['name']);
$fw = fopen($w_use_dir.$fhash,"wb");
if(!$fw) {
$gBitSmarty->assign('msg',tra('Cannot write to this file:').$fhash);
$gBitSystem->display( 'error.tpl' );
die;
}
}
while(!feof($fp)) {
if($w_use_db == 'y') {
$data .= fread($fp,8192*16);
} else {
$data = fread($fp,8192*16);
fwrite($fw,$data);
}
}
fclose($fp);
if($w_use_db == 'n') {
fclose($fw);
$data='';
}
$size = $_FILES['userfile1']['size'];
$name = $_FILES['userfile1']['name'];
$type = $_FILES['userfile1']['type'];
$wikilib->wiki_attach_file($gContent->mInfo['title'],$name,$type,$size, $data, $_REQUEST["attach_comment"], $user,$fhash);
}
}
$gBitSmarty->assign('atts',$gContent->mStorage);
$gBitSmarty->assign('atts_count',count($gContent->mStorage));
}
if( $gBitSystem->isFeatureActive( 'feature_wiki_footnotes' ) && $gBitUser->isValid() ) {
if( $footnote = $gContent->getFootnote( $gBitUser->mUserId ) ) {
$gBitSmarty->assign( 'footnote', $gContent->parseData( $footnote ) );
}
}
if( $gBitSystem->isFeatureActive( 'wiki_feature_copyrights' ) ) {
require_once( WIKI_PKG_PATH.'copyrights_lib.php' );
$copyrights = $copyrightslib->list_copyrights( $gContent->mPageId );
$gBitSmarty->assign('pageCopyrights', $copyrights["data"]);
}
// Watches
if( $gBitSystem->isFeatureActive( 'feature_user_watches' ) ) {
if( isset( $_REQUEST['watch_event'] ) ) {
if( $gBitUser->isRegistered() ) {
if($_REQUEST['watch_action']=='add') {
$gBitUser->storeWatch( $_REQUEST['watch_event'], $_REQUEST['watch_object'], $gContent->mContentTypeGuid, $gContent->mPageName, $gContent->getDisplayUrl() );
} else {
$gBitUser->expungeWatch( $_REQUEST['watch_event'], $_REQUEST['watch_object'] );
}
} else {
$gBitSmarty->assign('msg', tra("This feature requires a registered user.").": feature_user_watches");
$gBitSystem->display( 'error.tpl' );
die;
}
}
$gBitSmarty->assign('user_watching_page','n');
if( $watch = $gBitUser->getEventWatches( 'wiki_page_changed', $gContent->mPageId ) ) {
$gBitSmarty->assign('user_watching_page','y');
}
}
$sameurl_elements=Array('title','page');
// Display the Index Template
$gBitSmarty->assign_by_ref( 'pageInfo', $gContent->mInfo );
if( isset( $_REQUEST['s5'] ) ) {
include_once( WIKI_PKG_PATH.'s5.php');
}
$gBitSystem->display('bitpackage:wiki/show_page.tpl');
// xdebug_dump_function_profile(XDEBUG_PROFILER_CPU);
?>
|