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
|
<?php
/**
* $Header: /cvsroot/bitweaver/_bit_wiki/lookup_page_inc.php,v 1.31 2010/04/25 15:25:10 lsces 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 below for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
*
* $Id: lookup_page_inc.php,v 1.31 2010/04/25 15:25:10 lsces Exp $
* @package wiki
* @subpackage functions
*/
/**
* required setup
*/
require_once( WIKI_PKG_PATH.'BitBook.php');
global $gContent;
include_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' );
// this is needed when the center module is applied to avoid abusing $_REQUEST
if( empty( $lookupHash )) {
$lookupHash = &$_REQUEST;
}
// if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up.
if( empty( $gContent ) || !is_object( $gContent ) || strtolower( get_class( $gContent ) ) != 'bitpage' ) {
$gContent = new BitPage( @BitBase::verifyId( $lookupHash['page_id'] ) ? $lookupHash['page_id'] : NULL, @BitBase::verifyId( $lookupHash['content_id'] ) ? $lookupHash['content_id'] : NULL );
$loadPage = (!empty( $lookupHash['page'] ) ? $lookupHash['page'] : NULL);
if( empty( $gContent->mPageId ) && empty( $gContent->mContentId ) ) {
//handle legacy forms that use plain 'page' form variable name
//if page had some special enities they were changed to HTML for for security reasons.
//now we deal only with string so convert it back - so we can support this case:
//You&Me --(detoxify in kernel)--> You&Me --(now)--> You&Me
//we could do htmlspecialchars_decode but it allows <> marks here, so we just transform & to & - it's not so scary.
$loadPage = str_replace("&", "&", $loadPage );
if( $loadPage && $existsInfo = $gContent->pageExists( $loadPage ) ) {
if (count($existsInfo)) {
if (count($existsInfo) > 1) {
// Display page so user can select which wiki page they want (there are multiple that share this name)
$gBitSmarty->assign( 'choose', $lookupHash['page'] );
$gBitSmarty->assign('dupePages', $existsInfo);
$gBitSystem->display('bitpackage:wiki/page_select.tpl', NULL, array( 'display_mode' => 'display' ));
die;
} else {
$gContent->mPageId = $existsInfo[0]['page_id'];
$gContent->mContentId = $existsInfo[0]['content_id'];
}
}
} elseif( $loadPage ) {
$gBitSmarty->assign('page', $loadPage);//to have the create page link in the error
}
}
$parse = ( !isset( $lookupHash['parse'] ) or $lookupHash['parse'] ) ? true : false;
if( $gContent->load( $parse ) && $loadPage ) {
$gContent->mInfo['title'] = $loadPage;
}
}
// we weren't passed a structure, but maybe this page belongs to one. let's check...
if( empty( $gStructure ) ) {
//Get the structures this page is a member of
if( !empty($lookupHash['structure']) ) {
$structure=$lookupHash['structure'];
} else {
$structure='';
}
$structs = $gContent->getStructures();
if (count($structs)==1) {
$gStructure = new LibertyStructure( $structs[0]['structure_id'] );
if( $gStructure->load() ) {
$gStructure->loadNavigation();
$gStructure->loadPath();
$gBitSmarty->assign( 'structureInfo', $gStructure->mInfo );
}
} else {
$gBitSmarty->assign('showstructs', $structs);
}
}
$gBitSmarty->clear_assign( 'gContent' );
$gBitSmarty->assign_by_ref( 'gContent', $gContent );
?>
|