-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.php
More file actions
129 lines (123 loc) · 4.82 KB
/
Copy pathindex.php
File metadata and controls
129 lines (123 loc) · 4.82 KB
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
<?php /* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
##
## Documentation module
## (c) Copyright 2011 Jacques Archimède (Eureka)
##
$wikipage_id = (int) w2PgetParam($_REQUEST, 'wikipage_id', 0);
$page = w2PgetParam($_REQUEST, 'page', "");
$wikipage_namespace = "";
global $AppUI;
// check permissions for this module
$canView = canView('documentation');
$canAdd = canAdd('documentation');
$canEditWiki = canEdit('documentation', $wikipage_id);
$canDeleteWiki = canDelete('documentation', $wikipage_id);
if (!$canView) {
$AppUI->redirect('m=public&a=access_denied');
}
$q = new w2p_Database_Query;
if (!$page && $wikipage_id == 0 && isset($_GET['project_id'])) {
$q->addTable("projects");
$q->addQuery("project_short_name");
$q->addWhere('project_id =' . $_GET['project_id']);
$project = $q->loadHash();
$q->clear();
$wikipage_namespace =
isset($project['project_short_name']) ?
$project['project_short_name'] :
$AppUI->_('Project').$_GET['project_id'];
$wikipage_namespace = str_replace(
array(' ', '<', '[', '(', '"', ';'),
array(' ', ' ', ' ', ' ', ' ', ' '),
$wikipage_namespace
);
}
if (!$page && !$wikipage_namespace && $wikipage_id == 0) {
$project = new CProject();
$extra = array('where' => 'project_active = 1');
$allowedprojects = $project->getAllowedRecords(
$AppUI->user_id,
'projects.project_id,project_short_name, project_name',
'project_name',
null,
$extra,
'projects'
);
$q->addTable("projects");
$q->addQuery("projects.project_id, CONCAT(company_name, ': ', project_name)");
$q->addJoin("companies", "co", "co.company_id = project_company");
$projectslist = $q->loadHashList();
$q->clear();
$projects = array();
foreach ($allowedprojects as $prj_id => $prj_name) {
$wikipage_namespace = $prj_name ? $prj_name : $AppUI->_('Project').$prj_id;
$wikipage_namespace = str_replace(
array(' ', '<', '[', '(', '"', ';'),
array('_', '_', '_', '_', '_', '_'),
$wikipage_namespace
);
$projects[$wikipage_namespace.":"] = $projectslist[$prj_id];
}
asort($projects);
$projects = arrayMerge(array('0' => $AppUI->_('(None)', UI_OUTPUT_RAW)), $projects);
include_once (W2P_BASE_DIR . "/modules/documentation/views/projects.php");
} else {
if ($wikipage_id > 0) {
$wiki = new CWiki();
$wikipage = $wiki->getPage($wikipage_id);
$wikipage_namespace = $wiki->getNamespace();
$page = $wiki->pagename();
} else {
if ($page) {
list($wikipage_namespace, $page) = explode(":", $page);
}
if (!$page || $wikipage_namespace != "Special") {
$wiki = new CWiki($wikipage_namespace);
if ($page) {
list($page, $view) = explode("/", $page);
$wikipage = $wiki->loadPage($wikipage_namespace.':'.$page);
$wikipage_id = $wikipage->getWikipageId();
} else {
$wikipage = $wiki->loadStartPage();
$page = $wiki->pagename();
$wikipage_id = $wikipage->getWikipageId();
}
}
}
if ($wikipage_namespace == "Special") {
$page = strtolower($page);
if (file_exists(W2P_BASE_DIR . "/modules/documentation/special/".$page.".php")) {
include_once (W2P_BASE_DIR . "/modules/documentation/special/".$page.".php");
} else {
include_once (W2P_BASE_DIR . "/modules/documentation/special/unknown.php");
}
} elseif ($wikipage_namespace == "Image") {
include_once (W2P_BASE_DIR . "/modules/documentation/views/image.php");
} elseif ($wikipage_id == 0 && $canAdd) { // No start page for this project
require_once W2P_BASE_DIR . "/modules/documentation/config.php";
$canDelete = $canDeleteWiki;
$wikipage = array(
'wikipage_parser' => $WIKI_CONFIG['default_parser'],
'wikipage_lang' => $WIKI_CONFIG['default_lang'],
'wikipage_start' => 1,
'wikipage_namespace' => $wikipage_namespace,
'wikipage_name' => $wiki->pagename(),
'wikipage_title' => str_replace("_", " ", $wiki->pagename()),
'wikipage_content' => "",
);
include_once (W2P_BASE_DIR . "/modules/documentation/views/addedit.form.php");
} else {
if (isset($_GET['suppressHeaders'])) {
if ($view == "PDF" ) {
include_once (W2P_BASE_DIR . "/modules/documentation/views/pdf.php");
} else {
include_once (W2P_BASE_DIR . "/modules/documentation/views/fullpage.php");
}
} else {
include_once (W2P_BASE_DIR . "/modules/documentation/views/page.php");
}
}
}