Location: PHPKode > projects > SOA For Virtuemart (WebServices) > com_vm_soa/admin/admin.vm_soa.php
<?php

/**
 * @package    	com_vm_soa (WebServices for virtuemart)
 * @author		Mickael Cabanas (cabanas.mickael|at|gmail.com)
 * @link 		http://sourceforge.net/projects/soa-virtuemart/
 * @license    	GNU/GPL
*/

defined('_JEXEC') or die('Restricted access');
 error_reporting(E_ALL);
 ini_set("display_errors", 1);
 ini_set("memory_limit","-1");


/**
 * Fonction d'interception des erreurs utilisée pour la mise au point
 */
function myErrorHandler($errno, $errstr, $errfile, $errline){
//	echo "<br>---> An error occured";
    switch ($errno) {
    case E_ERROR:
		echo "<br>---> E_ERROR";
		echo "<pre>";
		debug_print_backtrace();
		echo "</pre>";
        break;
    case E_WARNING:
//		echo "<br>---> E_WARNING";
//		echo "<pre>";
//		debug_print_backtrace();
//		echo "</pre>";
        break;
    case E_PARSE:
		echo "<br>---> E_PARSE";
		echo "<pre>";
		debug_print_backtrace();
		echo "</pre>";
        break;
    case E_NOTICE:
		echo "<br>---> E_NOTICE";
		echo "<pre>";
		debug_print_backtrace();
		echo "</pre>";
        break;
    case E_CORE_ERROR:
		echo "<br>---> E_CORE_ERROR";
		echo "<pre>";
		debug_print_backtrace();
		echo "</pre>";
        break;
    case E_CORE_WARNING:
		echo "<br>---> E_CORE_WARNING";
		echo "<pre>";
		debug_print_backtrace();
		echo "</pre>";
        break;
    case E_COMPILE_ERROR:
		echo "<br>---> E_COMPILE_ERROR";
		echo "<pre>";
		debug_print_backtrace();
		echo "</pre>";
        break;
    case E_COMPILE_WARNING:
		echo "<br>---> E_COMPILE_WARNING";
		echo "<pre>";
		debug_print_backtrace();
		echo "</pre>";
        break;
    case E_USER_ERROR:
		echo "<br>---> E_USER_ERROR";
		echo "<pre>";
		debug_print_backtrace();
		echo "</pre>";
        if ($errstr == "(SQL)"){
            // handling an sql error
            echo "<b>SQL Error</b> [$errno] " . SQLMESSAGE . "<br />\n";
            echo "Query : " . SQLQUERY . "<br />\n";
            echo "On line " . SQLERRORLINE . " in file " . SQLERRORFILE . " ";
            echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
            echo "Aborting...<br />\n";
        } else {
            echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
            echo "  Fatal error on line $errline in file $errfile";
            echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
            echo "Aborting...<br />\n";
        }
        exit(1);
        break;

    case E_USER_WARNING:
		echo "<br>---> E_USER_WARNING";
		echo "<pre>";
		debug_print_backtrace();
		echo "</pre>";
        break;
   case E_USER_NOTICE:
		echo "<br>---> E_USER_NOTICE";
		echo "<pre>";
		debug_print_backtrace();
		echo "</pre>";
        break;
    }
   /* Don't execute PHP internal error handler */
    return true;
}

/**
 * La ligne qui suit permet d'activer la fonction d'interception d'erreurs ci-dessus
 */
//set_error_handler("myErrorHandler");

/**
 * On lit la configuration
 */
$erreur_conf=false;
require_once(JPATH_COMPONENT.DS.'vm_soa_conf.php');
// On vérifie si ça vaut la peine de continuer (si on ne demande pas la configuration, il faut que la configuration soit initialisée)
if ((JRequest::getVar('act', 'vm_soa') != 'config') && ((!is_array($conf)) /*|| ($conf['URL']=='')*/))
{
	$erreur_conf=true;
}

if ($erreur_conf == true)
{
	die('Vous devez d\'abord configurer le composant avant de l\'utiliser');
}
/**
 * On charge la classe de traces pour l'activer
 */
require_once(JPATH_COMPONENT.DS.'trace.php');
$trace=new trace($conf['trace']);
JRequest::setVar('trace', $trace);
$msg="option=".JRequest::getVar('option')."\n"."act=".JRequest::getVar('act')."\n"."task=".JRequest::getVar('task');
// JRequest::getVar('trace')->pop_up_message($msg);
if ((JRequest::getVar('task') == 'save') && (JRequest::getVar('act') == 'config'))
{
	$conf=JRequest::getVar('conf');
	if (array_key_exists('trace_raz', $conf) && ($conf['trace_raz'] == 'on'))
	{
		JRequest::getVar('trace')->raz_file();
	}
}
JRequest::getVar('trace')->trace_it(__FILE__." début", 1, 1);
JRequest::getVar('trace')->trace_it(__FILE__." option=".JRequest::getVar('option'), 10);
JRequest::getVar('trace')->trace_it(__FILE__." act=".JRequest::getVar('act'), 10);
JRequest::getVar('trace')->trace_it(__FILE__." task=".JRequest::getVar('task'), 10);
// Require the base controller
require_once (JPATH_COMPONENT.DS.'controller.php');
// On récupère la variable atc (action du menu initialisée dans le xml de configuration) pour aiguiller sur le controller de l'action par défaut on utilise le controller qui porte le nom du composant
// Certains composants récupèrent la variable controller : il semble que c'est une variable gérée par le composant qui la positionne en paramètre dans les url ou les formulaires
$controller = JRequest::getVar('act', 'vm_soa');
//echo "<br>controller=".$controller;
//require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'controllers'.DS.$controller.'.php');
require_once(JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php');
$classname = 'vm_soaController'.$controller;
//echo "<br>classname=".$classname;
$controller = new $classname( );
//$a=JRequest::get();
//echo "<hr>";
 echo "<center>";
 echo "<hr>";
 echo "<a href=https://sourceforge.net/projects/soa-virtuemart/ ><img src=http://extensions.joomla.org/components/com_mtree/img/listings/m/13433.jpg width=150 alt=SOA For Virtuemart/> </a>	";
 echo "<hr>";
 echo "</center>";
//print_r($a);
//echo "</pre>";
//echo "<hr>";
//echo "<br>fichier d'entrée : task=".JRequest::getVar('task');
//if ( JRequest::getVar('task') == 'cancel')
//{
//	JRequest::setVar('act', 'JpoVmDol15');
//}
// Ici c'est act qui nous sert d'aiguillage
$controller->execute( JRequest::getVar('act', 'vm_soa'));
$controller->redirect();
JRequest::getVar('trace')->trace_it(__FILE__." fin", 1, -1);
?>

Return current item: SOA For Virtuemart (WebServices)