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
|
<?php
/**
* $Header: /cvsroot/bitweaver/_bit_wiki/lookup_page_inc.php,v 1.7 2006/02/04 10:32:44 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: lookup_page_inc.php,v 1.7 2006/02/04 10:32:44 squareing Exp $
* @package wiki
* @subpackage functions
*/
/**
* required setup
*/
require_once( WIKI_PKG_PATH.'BitBook.php');
global $gContent, $wikilib;
include_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' );
// 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 ) || !$gContent->isValid() ) {
$gContent = new BitPage( @BitBase::verifyId( $_REQUEST['page_id'] ) ? $_REQUEST['page_id'] : NULL, @BitBase::verifyId( $_REQUEST['content_id'] ) ? $_REQUEST['content_id'] : NULL );
$loadPage = (!empty( $_REQUEST['page'] ) ? $_REQUEST['page'] : NULL);
if( empty( $gContent->mPageId ) && empty( $gContent->mContentId ) ) {
//handle legacy forms that use plain 'page' form variable name
if( $loadPage && $existsInfo = $wikilib->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', $_REQUEST['page'] );
$gBitSmarty->assign('dupePages', $existsInfo);
$gBitSystem->display('bitpackage:wiki/page_select.tpl');
die;
} else {
$gContent->mPageId = $existsInfo[0]['page_id'];
}
}
}
}
if( !$gContent->load() && $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($_REQUEST['structure']) ) {
$structure=$_REQUEST['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);
}
}
if( $gContent->isValid() && $gBitSystem->isPackageActive( 'stickies' ) ) {
require_once( STICKIES_PKG_PATH.'BitSticky.php' );
global $gNote;
$gNote = new BitSticky( NULL, NULL, $gContent->mContentId );
$gNote->load();
$gBitSmarty->assign_by_ref( 'stickyInfo', $gNote->mInfo );
}
// if we are looking up a page
if( $gBitSystem->isFeatureActive( 'feature_warn_on_edit' ) && $gContent->isValid() ) {
// Notice if a page is being edited or if it was being edited and not anymore
// print($GLOBALS["HTTP_REFERER"]);
// IF isset the referer and if the referer is editpage then unset taking the pagename from the
// query or homepage if not query
if (isset($_SERVER['HTTP_REFERER']) && (strstr($_SERVER['HTTP_REFERER'], WIKI_PKG_URL.'edit') ) ) {
$purl = parse_url($_SERVER['HTTP_REFERER']);
if (!isset($purl["query"])) {
$purl["query"] = '';
}
parse_str($purl["query"], $purlquery);
if (!isset($purlquery["page"])) {
$purlquery["page"] = $gBitSystem->getPreference( 'wikiHomePage' );
}
if (isset($_SESSION["edit_lock"])) {
// TODO - find out if this function is supposed to exist - wolff_borg
//$gBitUser->expungeSemaphore($purlquery["page"], $_SESSION["edit_lock"]);
}
}
if (strstr($_SERVER['REQUEST_URI'], WIKI_PKG_URL . 'edit')) {
$purl = parse_url($_SERVER['REQUEST_URI']);
if (!isset($purl["query"])) {
$purl["query"] = '';
}
parse_str($purl["query"], $purlquery);
// When WIKI_PKG_URL.'edit.php' is loading, check to see if there is an editing conflict
if( $gBitUser->hasSemaphoreConflict( $gContent->mContentId, $gBitSystem->mPrefs['warn_on_edit_time'] * 60 ) ) {
$gBitSmarty->assign('editpageconflict', 'y');
} else {
if (!(isset($_REQUEST['save'])) && $gContent->isValid() ) {
$_SESSION["edit_lock"] = $gBitUser->storeSemaphore( $gContent->mContentId );
$gBitSmarty->assign('editpageconflict', 'n');
}
}
}
if( $semUser = $gBitUser->hasSemaphoreConflict( $gContent->mContentId, $gBitSystem->mPrefs['warn_on_edit_time'] * 60 ) ) {
$gContent->mErrors['edit_conflict'] = 'This page is being edited by '.$gBitUser->getDisplayName( TRUE, $semUser ).'. Proceed at your own peril';
$gBitSmarty->assign( 'semUser', $semUser );
$beingedited = 'y';
} else {
$beingedited = 'n';
}
$gBitSmarty->assign('beingEdited', $beingedited);
}
$gBitSmarty->clear_assign( 'gContent' );
$gBitSmarty->assign( 'gContent', $gContent );
$gBitSmarty->assign_by_ref( 'pageInfo', $gContent->mInfo );
?>
|