Ejemplo n.º 1
0
/**
 * Shortcut for calling an ajax controller method and printing the result
 * @param string $controllerName: the name of the controller under which it is
 *                                stored in the DI container
 * @param string $methodName: the method that you want to call
 * @param array $urlParams: an array with variables extracted from the routes
 * @param Pimple $container: an instance of a pimple container. if not passed, a
 *                           new one will be instantiated. This can be used to
 *                           set different security values prehand or simply
 *                           swap or overwrite objects in the container.
 */
function callAjaxController($controllerName, $methodName, $urlParams, $container = null)
{
    // ajax requests come with csrf checks enabled. If you pass your own container
    // dont forget to enable the csrf check though if you need it. When in doubt
    // enable the csrf check
    if ($container === null) {
        $container = createDIContainer();
        $container['Security']->setCSRFCheck(true);
        $container['Security']->setIsAdminCheck(false);
    }
    callController($controllerName, $methodName, $urlParams, $container);
}
Ejemplo n.º 2
0
    if ($disableCSRF) {
        $security->setCSRFCheck(false);
    }
    if ($disableAdminCheck) {
        $security->setIsAdminCheck(false);
    }
    $security->runChecks();
    // call the controller and render the page
    $controller = $container[$controllerName];
    $page = $controller->{$methodName}($urlParams);
    $page->printPage();
}
/*************************
 * Define your routes here
 ************************/
/**
 * Normal Routes
 */
$this->create('apptemplate_index', '/')->action(function ($params) {
    callController('IndexController', 'index', $params, true);
});
/**
 * Ajax Routes
 */
$this->create('apptemplate_ajax_setsystemvalue', '/setsystemvalue')->post()->action(function ($params) {
    $container = createDIContainer();
    $security = $container['Security'];
    $security->runChecks();
    $controller = $container[$controllerName];
    $container->setsystemvalue($params);
});
Ejemplo n.º 3
0
define('BASE_FOLDER', CORE_FOLDER . 'base' . DS);
define('STRUCTURE_FOLDER', CORE_FOLDER . 'structure' . DS);
// All the specific Models, Views and Controllers
define('MVC_FOLDER', APP_FOLDER . 'mvc' . DS);
define('MODELS_FOLDER', MVC_FOLDER . 'models' . DS);
define('VIEWS_FOLDER', MVC_FOLDER . 'views' . DS);
define('CONTROLLERS_FOLDER', MVC_FOLDER . 'controllers' . DS);
// Folder containing all constants for the framework and the website
define('CONFIG_FOLDER', APP_FOLDER . 'config' . DS);
// All the public resources
define('REL_IMG_FOLDER', 'img/');
define('REL_CSS_FOLDER', 'css/');
define('JSON_FOLDER', ROOT . DS . 'json' . DS);
// External libraries
define('LIB_FOLDER', ROOT . DS . 'lib' . DS);
// Constants
require_once CONFIG_FOLDER . 'base.php';
require_once CONFIG_FOLDER . 'db.php';
require_once CONFIG_FOLDER . 'constants.php';
// Some mechanics (optional)
require_once BASE_FOLDER . 'init.php';
setReporting();
removeMagicQuotes();
unregisterGlobals();
// Managing the URL
require_once BASE_FOLDER . 'routing.php';
urlSetup();
// Loading necessary file following the URL analysis
require_once BASE_FOLDER . 'loading.php';
callController();
Ejemplo n.º 4
0
        $security->setIsAdminCheck(false);
    }
    if ($annotationReader->hasAnnotation('AppEnabledExcemption')) {
        $security->setAppEnabledCheck(false);
    }
    if ($annotationReader->hasAnnotation('IsLoggedInExcemption')) {
        $security->setLoggedInCheck(false);
    }
    if ($annotationReader->hasAnnotation('IsSubAdminExcemption')) {
        $security->setIsSubAdminCheck(false);
    }
    $security->runChecks();
}
/*************************
 * Define your routes here
 ************************/
/**
 * Normal Routes
 */
$this->create('apptemplate_advanced_index', '/')->action(function ($params) {
    callController('ItemController', 'index', $params);
});
$this->create('apptemplate_advanced_index_redirect', '/redirect')->action(function ($params) {
    callController('ItemController', 'redirectToIndex', $params);
});
/**
 * Ajax Routes
 */
$this->create('apptemplate_advanced_ajax_setsystemvalue', '/setsystemvalue')->post()->action(function ($params) {
    callController('ItemController', 'setSystemValue', $params);
});
Ejemplo n.º 5
0
        $argument = $status['argument'];
        // argument from the path fle
        if ($argument == 'any') {
            $filename = $requestFile;
            // loads any file with any name if exists
        } else {
            $filename = $argument;
            // loads specific file if defined in path file
        }
        callController($controllerClass, $function, $filename);
    } elseif (count($status) == 2) {
        $controllerClass = $status['controller'];
        // controller class name from path file
        $function = $status['function'];
        // function name from path file
        callController($controllerClass, $function);
    }
}
function callController($controllerClass, $function, $filename = NULL)
{
    if (file_exists(controllerDir . $controllerClass . '.php')) {
        require controllerDir . $controllerClass . '.php';
        if (array_search($controllerClass, get_declared_classes())) {
            // checks name of controller class
            searchExecuteMethod($controllerClass, $function, $filename);
            // search and execute method inside a controller class
        } else {
            (new error())->noController($controllerClass);
            exit;
        }
    } elseif (!file_exists(controllerDir . $controllerClass . 'php') && environment == 'development') {
Ejemplo n.º 6
0
/**
 * Shortcut for calling an ajax controller method and printing the result
 * @param string $controllerName: the name of the controller under which it is
 *                                stored in the DI container
 * @param string $methodName: the method that you want to call
 * @param array $urlParams: an array with variables extracted from the routes
 * @param bool $disableAdminCheck: disables the check for adminuser rights
 */
function callAjaxController($controllerName, $methodName, $urlParams, $disableAdminCheck = true)
{
    callController($controllerName, $methodName, $urlParams, $disableAdminCheck, true);
}
<?php

//નવી ફાઈલ એડ કરેલ છે
function callController()
{
    $args = func_get_args();
    $callable = explode('@', $args[0]);
    unset($args[0]);
    if (isset($args[1])) {
        //with args
        $controller = new $callable[0]();
        return $controller->{$callable}[1](implode(',', $args));
    }
    return $controller->{$callable}[1]();
}
$sidebar = callController('VimalController@hello', 'hsdfahsdfj');
echo $sidebar;