3 * Bacula(R) - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2016 Kern Sibbald
8 * The main author of Baculum is Marcin Haba.
9 * The original author of Bacula is Kern Sibbald, with contributions
10 * from many others, a complete list can be found in the file AUTHORS.
12 * You may use this file and others of this release according to the
13 * license defined in the LICENSE file, which includes the Affero General
14 * Public License, v3.0 ("AGPLv3") and some additional permissions and
15 * terms pursuant to its AGPLv3 Section 7.
17 * This notice must be preserved when any source code is
18 * conveyed and/or propagated.
20 * Bacula(R) is a registered trademark of Kern Sibbald.
23 Prado::using('System.Web.TUrlMapping');
25 class BaculumUrlMapping extends TUrlMapping {
27 private $services = array(
29 'url_manager' => 'Application.Web.Class.WebUrlMapping',
30 'url_pattern' => '!^(/index\.php)?/web([/,].*)?$!',
31 'endpoints' => 'Application.Web.endpoints'
34 'url_manager' => 'Application.API.Class.APIUrlMapping',
35 'url_pattern' => '!^(/index\.php)?/api([/,].*)?$!',
36 'endpoints' => 'Application.API.endpoints'
40 public function __construct() {
41 parent::__construct();
42 $this->setServiceUrlManager();
45 private function getServiceID() {
47 $url = $this->getRequestedUrl();
48 foreach ($this->services as $id => $params) {
49 if (preg_match($params['url_pattern'], $url) === 1) {
57 private function setServiceUrlManager() {
58 $service_id = $this->getServiceID();
59 $url = $this->getRequestedUrl();
60 if (array_key_exists($service_id, $this->services)) {
61 $service = $this->services[$service_id];
62 $path = Prado::getPathOfNamespace($service['url_manager'], Prado::CLASS_FILE_EXT);
63 if (file_exists($path)) {
64 $this->setDefaultMappingClass($service['url_manager']);
65 $this->setConfigFile($service['endpoints']);
67 } elseif (!empty($url)) {
68 throw new THttpException(404, 'pageservice_page_unknown', $url);
72 private function getRequestedUrl() {
73 $url = $this->getRequest()->getPathInfo();