- [x] [ResourceDispatcher] Modification du gestionnaire de ressource car ne marche pas en ligne
This commit is contained in:
parent
07f7dd55ca
commit
e3777bc732
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"host" : "sql31.free-h.org:3306",
|
||||
"host" : "sql31.free-h.org",
|
||||
"dbname" : "stefproject",
|
||||
"user" : "php",
|
||||
"password" : "Hx2c#e77"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
// $R->get('settings/', function(){ include __ROOT__.'/view.php'; });
|
||||
|
||||
// Dispatcher
|
||||
$R->get('f(?:/([\w-]+))*/?', function(){ new \manager\ResourceDispatcher($_GET['url']); });
|
||||
$R->get('f(?:/([\w-]+))*/?', function(){ new \manager\ResourceDispatcher($_GET['url'], true); });
|
||||
|
||||
// Api
|
||||
$R->post('api/?', function(){
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
class DataBase{
|
||||
|
||||
/* ATTRIBUTS STATIQUES */
|
||||
public static $config_path = array('/f/json/database/conf', '/f/json/database-local/conf');
|
||||
public static $config_path = array('f/json/database/conf', 'f/json/database-local/conf');
|
||||
private static $pdo;
|
||||
private static $instance;
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
if( self::$instance == null ){
|
||||
|
||||
// chargement de la configuration du server SQL
|
||||
if( $_SERVER['HTTP_HOST'] == 'stefprojectv2' )
|
||||
if( $_SERVER['HTTP_HOST'] != 'stefprojectv2' )
|
||||
$conf = json_decode( ResourceDispatcher::getResource(self::$config_path[0]), true );
|
||||
else
|
||||
$conf = json_decode( ResourceDispatcher::getResource(self::$config_path[1]), true );
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
class ModuleRequest{
|
||||
|
||||
// Constantes
|
||||
public static $config_path = '/f/json/modules/conf';
|
||||
public static $config_path = 'f/json/modules/conf';
|
||||
|
||||
|
||||
// Attributs prives utiles (initialisation)
|
||||
|
|
|
@ -22,15 +22,19 @@
|
|||
/* CONSTRUCTEUR & AMORCAGE DU DISPATCHER
|
||||
*
|
||||
* @url<String> L'url courante
|
||||
* @view<Boolean> Si VRAI, retourne header+contenu, sinon cree juste l'objet
|
||||
*
|
||||
* @return status<Boolean> Retourne si oui ou non tout s'est bien passe
|
||||
*
|
||||
*/
|
||||
public function __construct($url){
|
||||
public function __construct($url, $view=false){
|
||||
$this->error = ManagerError::Success;
|
||||
|
||||
|
||||
/* [0] On met a jour la configuration
|
||||
=====================================================*/
|
||||
// Extensions supportees
|
||||
$extensions_conf = json_decode( file_get_contents('http://'.$_SERVER['HTTP_HOST'].self::$extension_config_path), true );
|
||||
$extensions_conf = json_decode( file_get_contents(__ROOT__.self::$extension_config_path), true );
|
||||
|
||||
// Gestion de l'erreur de parsage
|
||||
if( $extensions_conf == null ){
|
||||
|
@ -41,7 +45,7 @@
|
|||
self::$supported_extensions = $extensions_conf;
|
||||
|
||||
// Dossiers supportes
|
||||
$parents_conf = json_decode( file_get_contents('http://'.$_SERVER['HTTP_HOST'].self::$parents_config_path), true );
|
||||
$parents_conf = json_decode( file_get_contents(__ROOT__.self::$parents_config_path), true );
|
||||
|
||||
// Gestion de l'erreur de parsage
|
||||
if( $parents_conf == null ){
|
||||
|
@ -72,11 +76,12 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
/* [4] On gere l'affichage pour l'appel externe
|
||||
/* [4] On gere l'affichage pour l'appel externe/interne
|
||||
==================================================*/
|
||||
$this->view();
|
||||
if( $view ) // Appel externe
|
||||
$this->view();
|
||||
|
||||
$this->error = ManagerError::Success;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -90,7 +95,8 @@
|
|||
*
|
||||
*/
|
||||
public static function getResource($route){
|
||||
return file_get_contents('http://'.$_SERVER['HTTP_HOST'].$route);
|
||||
$instance = new ResourceDispatcher($route);
|
||||
return $instance->getContent();
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,7 +203,7 @@
|
|||
|
||||
/* [6] On retourne si le fichier existe ou non
|
||||
==========================================================*/
|
||||
return file_exists( $this->path );
|
||||
return @file_get_contents( $this->path ) != false;
|
||||
|
||||
}
|
||||
|
||||
|
@ -208,11 +214,30 @@
|
|||
*
|
||||
*/
|
||||
public function view(){
|
||||
// S'il y a eu une erreur en amont
|
||||
if( $this->error != ManagerError::Success )
|
||||
return false; // on retourne faux
|
||||
|
||||
// On definit le header
|
||||
header('Content-Type: '.$this->header);
|
||||
|
||||
// On inclut le contenu
|
||||
include $this->path;
|
||||
echo file_get_contents($this->path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* FUNCTION QUI RETOURNE LE CONTENU DE LA RESSOURCE EN QUESTION
|
||||
*
|
||||
*/
|
||||
public function getContent(){
|
||||
// S'il y a eu une erreur en amont
|
||||
if( $this->error != ManagerError::Success )
|
||||
return false; // on retourne faux
|
||||
|
||||
|
||||
// On inclut le contenu
|
||||
return file_get_contents($this->path);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php define('__ROOT__', dirname(__FILE__));
|
||||
require_once __ROOT__.'/manager/autoloader.php';
|
||||
|
||||
ini_set('display_errors',1);
|
||||
ini_set('display_startup_errors',1);
|
||||
error_reporting(-1);
|
||||
|
||||
|
||||
|
||||
// $url = 'http://'.$_SERVER['HTTP_HOST'].'/config/modules.json';
|
||||
// echo file_get_contents($url);
|
||||
// Warning: file_get_contents(http://stefproject.xdrm.fr/config/modules.json): failed to open stream: HTTP request failed! HTTP/1.1 412 Precondition Failed in /var/www/vhosts/xdrm.fr/stefproject/test.php on line 10
|
||||
|
||||
|
||||
// $url = 'http://'.urlencode($_SERVER['HTTP_HOST'].'/config/modules.json');
|
||||
// echo file_get_contents($url);
|
||||
// Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/vhosts/xdrm.fr/stefproject/test.php on line 15 Warning: file_get_contents(http://stefproject.xdrm.fr%2Fconfig%2Fmodules.json): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/vhosts/xdrm.fr/stefproject/test.php on line 15
|
||||
|
||||
|
||||
$url = 'f/json/modules/conf';
|
||||
var_dump( \manager\ResourceDispatcher::getResource($url) );
|
||||
|
||||
?>
|
4
todo.md
4
todo.md
|
@ -13,8 +13,7 @@
|
|||
############
|
||||
# EN COURS #
|
||||
############
|
||||
|
||||
- [ ] [/users/view] Affichage basique de liste d'elements complexes (users/machines/journal, ...)
|
||||
- [.] [/users/view] Affichage basique de liste d'elements complexes (users/machines/journal, ...)
|
||||
- [x] Conception BDD + ameliorations
|
||||
- [x] Liste des tables
|
||||
- [x] Liste de attributs
|
||||
|
@ -32,6 +31,7 @@
|
|||
########
|
||||
# FAIT #
|
||||
########
|
||||
- [x] [ResourceDispatcher] Modification du gestionnaire de ressource car ne marche pas en ligne
|
||||
- [x] [css/container.css + js/action-script.js] Gestion de l'affichage de la page associee au sous-menu (.active)
|
||||
- [x] [view/*.php] Modification des views
|
||||
- [x] Mise a jour / Modification / Correction des images du menu-side
|
||||
|
|
12
view.php
12
view.php
|
@ -42,15 +42,15 @@
|
|||
|
||||
<!-- MENU DE LA PAGE -->
|
||||
<nav id='MENU-SIDE'>
|
||||
<span data-link='profile' data-desc='Profil' class='mb' ><?php echo file_get_contents( 'http://'.$_SERVER['HTTP_HOST'].'/f/svg/dashboard/st/menu-side' ); ?></span>
|
||||
<span data-link='profile' data-desc='Profil' class='mb' ><?php echo \manager\ResourceDispatcher::getResource('f/svg/dashboard/st/menu-side'); ?></span>
|
||||
|
||||
|
||||
<span data-link='dashboard' data-desc='Tableau de bord' class='apart' ><?php echo file_get_contents( 'http://'.$_SERVER['HTTP_HOST'].'/f/svg/dashboard/st/menu-side' ); ?></span>
|
||||
<span data-link='machines' data-desc='Véhicules' ><?php echo file_get_contents( 'http://'.$_SERVER['HTTP_HOST'].'/f/svg/machines/st/menu-side/' ); ?></span>
|
||||
<span data-link='users' data-desc='Utilisateurs' ><?php echo file_get_contents( 'http://'.$_SERVER['HTTP_HOST'].'/f/svg/users/st/menu-side/' ); ?></span>
|
||||
<span data-link='analytics' data-desc='Statistiques et suivi' ><?php echo file_get_contents( 'http://'.$_SERVER['HTTP_HOST'].'/f/svg/analytics/st/menu-side/' ); ?></span>
|
||||
<span data-link='dashboard' data-desc='Tableau de bord' class='apart' ><?php echo \manager\ResourceDispatcher::getResource('f/svg/dashboard/st/menu-side'); ?></span>
|
||||
<span data-link='machines' data-desc='Véhicules' ><?php echo \manager\ResourceDispatcher::getResource('f/svg/machines/st/menu-side' ); ?></span>
|
||||
<span data-link='users' data-desc='Utilisateurs' ><?php echo \manager\ResourceDispatcher::getResource('f/svg/users/st/menu-side' ); ?></span>
|
||||
<span data-link='analytics' data-desc='Statistiques et suivi' ><?php echo \manager\ResourceDispatcher::getResource('f/svg/analytics/st/menu-side'); ?></span>
|
||||
|
||||
<span data-link='settings' data-desc='Paramètres' class='mt' ><?php echo file_get_contents( 'http://'.$_SERVER['HTTP_HOST'].'/f/svg/settings/st/menu-side/' ); ?></span>
|
||||
<span data-link='settings' data-desc='Paramètres' class='mt' ><?php echo \manager\ResourceDispatcher::getResource('f/svg/settings/st/menu-side' ); ?></span>
|
||||
</nav>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue