1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* Alxarafe. Development of PHP applications in a flash!
|
4
|
|
|
* Copyright (C) 2018 Alxarafe <[email protected]>
|
5
|
|
|
*/
|
6
|
|
|
namespace Alixar\Helpers;
|
7
|
|
|
|
8
|
|
|
class AlixarDispatcher extends \Alxarafe\Helpers\Dispatcher
|
9
|
|
|
{
|
10
|
|
|
|
11
|
|
|
public $path;
|
12
|
|
|
|
13
|
|
|
public function __construct()
|
14
|
|
|
{
|
15
|
|
|
parent::__construct();
|
16
|
|
|
|
17
|
|
|
$this->searchDir['Alixar'] = constant('BASE_PATH');
|
18
|
|
|
$this->searchDir['Plugins'] = constant('BASE_PATH') . '/plugins';
|
19
|
|
|
|
20
|
|
|
$this->path = null;
|
21
|
|
|
|
22
|
|
|
var_dump($this);
|
|
|
|
|
23
|
|
|
}
|
24
|
|
|
|
25
|
|
|
/**
|
26
|
|
|
* Define the constants of the application
|
27
|
|
|
*/
|
28
|
|
|
public function defineConstants(): void
|
29
|
|
|
{
|
30
|
|
|
parent::defineConstants();
|
31
|
|
|
|
32
|
|
|
/**
|
33
|
|
|
* Alixar is a fork of Dolibarr powered with Alxarafe
|
34
|
|
|
* Alxarafe. Development of PHP applications in a flash!
|
35
|
|
|
* Copyright (C) 2018 Alxarafe <[email protected]>
|
36
|
|
|
*/
|
37
|
|
|
|
38
|
|
|
define('DOL_BASE_PATH', BASE_PATH . '/dolibarr/htdocs');
|
39
|
|
|
define('DOL_BASE_URI', BASE_URI . '/dolibarr/htdocs');
|
40
|
|
|
define('DOL_DOCUMENT_ROOT', DOL_BASE_PATH);
|
41
|
|
|
|
42
|
|
|
define('CORE_FOLDER', '/core');
|
43
|
|
|
define('CONFIG_FOLDER', '/core');
|
44
|
|
|
define('CONTROLLERS_FOLDER', '/controllers');
|
45
|
|
|
define('HELPERS_FOLDER', '/helpers');
|
46
|
|
|
define('MODELS_FOLDER', '/models');
|
47
|
|
|
define('SKINS_FOLDER', '/views/skins');
|
48
|
|
|
define('TEMPLATES_FOLDER', '/views/templates');
|
49
|
|
|
define('PLUGINS_FOLDER', '/plugins');
|
50
|
|
|
define('CACHE_FOLDER', '/../cache');
|
51
|
|
|
//define('VENDOR_FOLDER', BASE_URI . '/vendor');
|
52
|
|
|
|
53
|
|
|
define('CORE_PATH', BASE_PATH . CORE_FOLDER);
|
54
|
|
|
define('CONFIG_PATH', BASE_PATH . CONFIG_FOLDER);
|
55
|
|
|
define('CONTROLLERS_PATH', BASE_PATH . CONTROLLERS_FOLDER);
|
56
|
|
|
define('HELPERS_PATH', BASE_PATH . HELPERS_FOLDER);
|
57
|
|
|
define('MODELS_PATH', BASE_PATH . MODELS_FOLDER);
|
58
|
|
|
define('SKINS_PATH', BASE_PATH . SKINS_FOLDER);
|
59
|
|
|
define('TEMPLATES_PATH', BASE_PATH . TEMPLATES_FOLDER);
|
60
|
|
|
define('PLUGINS_PATH', BASE_PATH . PLUGINS_FOLDER);
|
61
|
|
|
define('CACHE_PATH', BASE_PATH . CACHE_FOLDER);
|
62
|
|
|
//define('VENDOR_PATH', BASE_PATH . VENDOR_FOLDER);
|
63
|
|
|
|
64
|
|
|
/**
|
65
|
|
|
* Alixar:
|
66
|
|
|
*
|
67
|
|
|
* When updating ckeditor, the moono-lisa skin disappears
|
68
|
|
|
* and includes kama and moono.
|
69
|
|
|
*/
|
70
|
|
|
define('CKEDITOR_SKIN', 'moono-lisa'); // Do not use moono-lisa. Use kama o moono.
|
71
|
|
|
}
|
72
|
|
|
|
73
|
|
|
/**
|
74
|
|
|
* Run the application.
|
75
|
|
|
* First check if an Alxarafe class is being invoked.
|
76
|
|
|
* If not, try to locate a modified Dolibarr file to include in the index.php.
|
77
|
|
|
* The name of the file will be returned in $this->path.
|
78
|
|
|
*
|
79
|
|
|
* @link (Spanish) https://alxarafe.es/crear-el-primer-controlador-con-alxarafe-para-alixar-fork-de-dolibarr/
|
80
|
|
|
* @link (English) https://alxarafe.com/create-the-first-controller-with-alxarafe-for-alixar-fork-of-dolibarr/
|
81
|
|
|
*
|
82
|
|
|
* @return bool
|
83
|
|
|
*/
|
84
|
|
|
public function process(): bool
|
85
|
|
|
{
|
86
|
|
|
$controller = filter_input(INPUT_GET, 'controller'); // ?: 'home';
|
87
|
|
|
$method = filter_input(INPUT_GET, 'method'); // ?: 'home';
|
88
|
|
|
|
89
|
|
|
$this->path = "dolibarr/htdocs/$controller/$method.php";
|
90
|
|
|
if (file_exists($this->path)) {
|
91
|
|
|
return true;
|
92
|
|
|
}
|
93
|
|
|
$this->path = null;
|
94
|
|
|
//die($controller . '/' . $method . ' not found!');
|
95
|
|
|
|
96
|
|
|
echo "<p>Entrando en process...</p>";
|
97
|
|
|
if (parent::process()) {
|
98
|
|
|
return true;
|
99
|
|
|
}
|
100
|
|
|
echo "<p>¿Ha retornado false?</p>";
|
101
|
|
|
|
102
|
|
|
|
103
|
|
|
|
104
|
|
|
return false;
|
105
|
|
|
}
|
106
|
|
|
}
|
107
|
|
|
|