-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPageController.php
66 lines (59 loc) · 2.24 KB
/
PageController.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
<?php
/**
* This file is part of the {@link http://ontowiki.net OntoWiki} project.
*
* @copyright Copyright (c) 2013, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
*/
/**
* Controller for OntoWiki
*
* @category OntoWiki
* @package OntoWiki_Extensions_PAge
* @author Sebastian Tramp <[email protected]>
* @author Philipp Frischmuth <[email protected]>
*/
class PageController extends OntoWiki_Controller_Component
{
/**
* Default action. Forwards to get action.
*/
public function __call($action, $params)
{
$owApp = OntoWiki::getInstance();
$owNavigation = $owApp->getNavigation();
$owNavigation->disableNavigation();
$pagename = str_replace('Action', '', $action);
if ($pagename === 'index') {
// no action given... check config for a mapping of URL to static file
$mappings = array();
if (isset($this->_privateConfig->mappings)) {
$mappings = $this->_privateConfig->mappings->toArray();
}
$urlBase = $this->_owApp->getUrlBase();
foreach ($mappings as $key=>$mappingSpec) {
if ($mappingSpec['uri'] === $urlBase) {
$pagename = $mappingSpec['page'];
break;
}
}
}
$pageTitles = $this->_privateConfig->titles->toArray();
if (isset($pageTitles[$pagename])) {
$this->view->placeholder('main.window.title')->set($this->_owApp->translate->_($pageTitles[$pagename]));
} else {
$this->view->placeholder('main.window.title')->set($this->_owApp->translate->_($pagename));
}
// check for configured page base directory
$pageBaseDir = $this->_componentRoot.'page/';
if (isset($this->_privateConfig->directories->pageBase)) {
$pageBaseDir = ONTOWIKI_ROOT . $this->_privateConfig->directories->pageBase;
$this->view->addScriptPath($pageBaseDir);
}
if (!file_exists($pageBaseDir . $pagename . '.phtml')) {
$this->render('default');
return;
}
$this->render($pagename, null, true);
}
}