Пример #1
0
 public static function make($file, $primary = 'primary/main')
 {
     if (is_null($primary)) {
         $primary = $file;
     }
     if (!file_exists(LOCALROOT . "views/{$primary}.php")) {
         return false;
     }
     //        if(!file_exists(LOCALROOT . "views/$file.php")){
     //            return false;
     //        }
     Globals::set('view_aux', $file);
     include LOCALROOT . "views/{$primary}.php";
     return true;
 }
Пример #2
0
 public static function getRoute()
 {
     $route = $_SERVER['REQUEST_METHOD'] !== 'GET' ? strtolower($_SERVER['REQUEST_METHOD']) . ':' : '';
     $url = explode('/', Globals::get('r'));
     Globals::set('url', $url);
     foreach ($url as $i => $session) {
         if (is_numeric($session)) {
             $route .= "-num";
         } else {
             $route .= $i ? '-' : '';
             $route .= is_numeric($session) ? 'num' : $session;
         }
     }
     Globals::set('route', $route);
 }
Пример #3
0
 public function versionAction()
 {
     Globals::set('manager')->inner('parameters', array('title' => 'About Suite', 'subtitle' => 'Version', 'content' => Globals::get()->suite->version));
     return array('continue' => true, 'view' => array(array('main' => array('path' => __DIR__ . '/Index_view.php'))));
 }
Пример #4
0
 public function getHtml($valueAction)
 {
     $html_view = null;
     $html_view_meta = null;
     $html_view_metaind = null;
     $html_view_header = null;
     $html_view_main = null;
     $html_view_footer = null;
     $resultView = isset($valueAction['view']) ? $valueAction['view'] : null;
     $resultContinue = isset($valueAction['continue']) ? $valueAction['continue'] : null;
     $resultParameters = isset($valueAction['parameters']) ? $valueAction['parameters'] : null;
     // define parametros da action
     if ($resultParameters != null) {
         Globals::set('current')->action = array('parameters' => $resultParameters);
     }
     $controller_link = Globals::get('http/domain/url') . Globals::get('http/controllers/destination') . '/';
     Globals::set('current')->controller = array('link' => $controller_link);
     if (is_array($resultView)) {
         // inclui na página conteúdo baseado no view do return
         foreach ($resultView as $key2 => $value2) {
             foreach ($value2 as $key3 => $value3) {
                 if ($key3 === 'html') {
                     $html_view_main .= $value3;
                 } elseif ($key3 === 'meta') {
                     if (key($value3) == 'path') {
                         $html_view_meta .= Functions::requireToVar($value3[key($value3)]);
                     } else {
                         if (key($value3) == 'html') {
                             $html_view_meta .= $value3[key($value3)];
                         }
                     }
                 } elseif ($key3 === 'header') {
                     if (key($value3) == 'path') {
                         $html_view_header .= Functions::requireToVar($value3[key($value3)]);
                     } else {
                         if (key($value3) == 'html') {
                             $html_view_header .= $value3[key($value3)];
                         }
                     }
                 } elseif ($key3 === 'main') {
                     if (key($value3) == 'path') {
                         $html_view_main .= Functions::requireToVar($value3[key($value3)]);
                     } else {
                         if (key($value3) == 'html') {
                             $html_view_main .= $value3[key($value3)];
                         }
                     }
                 } elseif ($key3 === 'footer') {
                     if (key($value3) == 'path') {
                         $html_view_footer .= Functions::requireToVar($value3[key($value3)]);
                     } else {
                         if (key($value3) == 'html') {
                             $html_view_footer .= $value3[key($value3)];
                         }
                     }
                 } else {
                     if (file_exists($value3)) {
                         $html_view_main .= Functions::requireToVar($value3);
                     }
                 }
             }
         }
     }
     return array('continue' => $resultContinue, 'view' => array('meta' => $html_view_meta, 'header' => $html_view_header, 'main' => $html_view_main, 'footer' => $html_view_footer));
 }
Пример #5
0
 public function setCurrent()
 {
     $path = Globals::get()->path;
     $http = Globals::get()->http;
     $appPath = $path->controller->path;
     $modulesPath = $appPath . '/_modules/';
     // captura conteúdo do controller baseado em seu retorno
     //$resultAction = $this->getHtml($valueAction);
     $nameControl = $http->controllers->destination;
     $nameControl = str_replace('!', '', $nameControl);
     // verifica _assets no controller -----------------------------
     $metaInd = $modulesPath . $nameControl . '/_assets/' . 'meta.php';
     if (file_exists($metaInd)) {
         Globals::set('path')->inner('module')->add(array('current' => array('meta' => array('url' => Globals::get('path/controller/action/url') . '_assets/', 'path' => Globals::get('path/controller/action/path') . '_assets/'))));
         $currentActionPath = Globals::get('path/controller/action/path');
         $currentActionUrl = Globals::get('path/controller/action/url');
         $currentMetaPath = Globals::get('path/module/current/meta/path');
         $currentMetaUrl = Globals::get('path/module/current/meta/url');
         $currentModulePath = explode('/', Globals::get('path/controller/action/path'));
         unset($currentModulePath[count($currentModulePath) - 1]);
         $currentModulePath = implode('/', $currentModulePath) . '/';
         $currentModuleUrl = explode('/', Globals::get('path/controller/action/url'));
         unset($currentModuleUrl[count($currentModuleUrl) - 1]);
         $currentModuleUrl = implode('/', $currentModuleUrl) . '/';
         //$currentModuleUrl = Globals::get('path/controller/module/url');
         Globals::set('current')->path = array('module' => array('path' => $currentModulePath, 'url' => $currentModuleUrl), 'action' => array('path' => $currentActionPath, 'url' => $currentActionUrl), 'meta' => array('path' => $currentMetaPath, 'url' => $currentMetaUrl));
         /*echo '<pre>';
         		print_r(Globals::get('current'));
         		echo '</pre>';*/
         $html_view_metaind = Functions::requireToVar($metaInd);
     } else {
         // se no controller atual não existir o aquivo assets/meta.php, verifica nos controllers anteriores
         $controller = Globals::get('http/controllers/listjoinrev');
         foreach ($controller as $key => $value) {
             $controllerNames = str_replace('!', '', $value);
             $controllerPath = Globals::get('path/controller/modules/path') . $controllerNames . '/';
             $controllerPathAsset = $controllerPath . '_assets/';
             $controllerPathMeta = $controllerPath . '_assets/meta.php';
             $controllerUrl = Globals::get('path/controller/modules/url') . $controllerNames . '/';
             $controllerUrlAsset = $controllerUrl . '_assets/';
             $controllerUrlMeta = $controllerUrl . '_assets/meta.php';
             if (file_exists($controllerPathMeta)) {
                 Globals::set('path')->inner('module')->add(array('current' => array('meta' => array('url' => $controllerUrlAsset, 'path' => $controllerPathAsset))));
                 $currentActionPath = Globals::get('path/controller/action/path');
                 $currentActionUrl = Globals::get('path/controller/action/url');
                 $currentModulePath = Globals::get('path/controller/module/path');
                 $currentModuleUrl = Globals::get('path/controller/module/url');
                 $currentMetaPath = Globals::get('path/module/current/meta/path');
                 $currentMetaUrl = Globals::get('path/module/current/meta/url');
                 Globals::set('current')->path = array('module' => array('path' => $currentModulePath, 'url' => $currentModuleUrl), 'action' => array('path' => $currentActionPath, 'url' => $currentActionUrl), 'meta' => array('path' => $currentMetaPath, 'url' => $currentMetaUrl));
                 $html_view_metaind = Functions::requireToVar($controllerPathMeta);
             }
         }
     }
 }
Пример #6
0
 public function load($options = null)
 {
     $suite = Globals::set()->suite = $this->optionsGlobals;
     Globals::$visibleall = true;
     // cria o container com as classes
     Globals::setPrivate('app')->container = array('settings' => function () {
         require_once 'Settings.php';
         return new Settings();
     }, 'http' => function () {
         require_once 'Http.php';
         return new Http();
     }, 'controller' => function () {
         require_once 'Controller.php';
         return new Controller();
     }, 'view' => function () {
         require_once 'View.php';
         return new View();
     }, 'path' => function () {
         require_once 'Path.php';
         return new Path();
     }, 'plugins' => function () {
         require_once 'Plugins.php';
         return new Plugins();
     });
     $settings = Globals::getPrivate("app")->container->settings;
     $this->settings = $settings = $settings();
     // inicializa a classe Http
     $http = Globals::getPrivate("app")->container->http;
     $this->http = $http = $http();
     // inicializa a classe controller
     $controller = Globals::getPrivate("app")->container->controller;
     $this->controller = $controller = $controller();
     // inicializa a classe controller
     $path = Globals::getPrivate("app")->container->path;
     $this->path = $path = $path();
     // inicializa a classe controller
     $controller = Globals::getPrivate("app")->container->controller;
     $this->controller = $controller = $controller();
     // inicializa a classe controller
     $plugins = Globals::getPrivate("app")->container->plugins;
     $this->plugins = $plugins = $plugins();
     // registra as definições iniciais
     $settings->registerSettings($options);
     // ajusta as definições iniciais
     $settings->define();
     // define requisição/Resposta HTTP
     $http->setAdapterSettings($settings);
     $getResponse = $http->getResponse();
     Globals::set()->http = $getResponse;
     // define settings definido no load
     $getSettings = $settings->getSettings();
     Globals::set()->settings = $getSettings;
     // define os caminhos atuais
     $path->setPath($settings);
     $getPath = $path->getPath();
     Globals::set()->path = $getPath;
     //define e carrega o diretório dos arquivos observadores
     Events::setPaths(array(Globals::get('path/manager/path'), Globals::get('path/app/path')));
     Events::loadObserver();
     // define application base
     $getControllers = Globals::get('http/controllers');
     if ($getControllers->list[0] == '!') {
         Globals::set('app')->run = "!";
     } else {
         Globals::set('app')->run = "#" . Globals::get('path/app/name');
         //$getPath->name;
     }
     if (Globals::get('app/run') == '!') {
         $HTTP_SUITE_PAR = isset($_SERVER['HTTP_SUITE_PAR']) ? $_SERVER['HTTP_SUITE_PAR'] : null;
     } else {
         $resultCheckFirstAccess = $settings->checkFirstAccess();
         if ($resultCheckFirstAccess == true) {
             $resultEvents = Events::Attach('info[welcome]', array('value' => '', 'action' => ''));
             if (!$resultEvents) {
                 $html = '<h1>Suite</h1>';
                 $html .= '<h3>First Access</h3>';
                 $html .= '<p>';
                 $html .= '</p>';
                 echo $html;
                 exit;
             }
         }
         // verifica se a requisião atual é de origem do próprio Suite
         //$result = Functions::checkRequestBySuite();
         //if($result == false){
         // verifica as informações iniciais, como estrutura de diretórios e outros
         $resultCheckStruct = $settings->checkStruct();
         if ($resultCheckStruct == false) {
             // anexa evento
             $resultEvents = Events::Attach('error[app_not_found]', array('value' => '', 'action' => ''));
             if (!$resultEvents) {
                 $html = '<h1>Suite</h1>';
                 $html .= '<h3>Application not found</h3>';
                 $html .= '<p>';
                 $html .= '<strong>Name:</strong> ' . Globals::get('path/app/name');
                 $html .= '<br><strong>Path:</strong> ' . Globals::get('path/app/path');
                 $html .= '</p>';
                 echo $html;
                 exit;
             }
         }
         //}
     }
     // captura a lista de plugins
     $pluginsList = $plugins->getList();
     // redefine ordem dos plugins
     $pluginsList = $plugins->reDefinePlugins($pluginsList);
     // cria um objeto com todos os plugins
     $pluginsObj = $plugins->getPlugins($pluginsList);
     Globals::set("plugins")->inner('list', $pluginsList);
     Globals::set("plugins")->inner('action', $pluginsObj);
     // redireciona a página se foi setado um preixo para a url
     $http->checkPrefixUrl($settings, $path);
     // executa caso o plugin for chamado diretamente via url ou código
     $plugins->callDirect($http, $path);
     //captura todos os controllers e as options
     $controllersList = $controller->getControllers();
     $appListArray = Functions::scanOnlyDir(Globals::get('path/app/appbase/path'));
     Globals::set('app')->list = $appListArray;
     Globals::set('app')->options = array('master' => $controller->getOptionMaster(), 'modules' => $controllersList);
     $controllersManagerList = $controller->getControllers(Globals::get()->path->manager->modules->path);
     Globals::set('manager')->options = array('master' => $controller->getOptionMaster(Globals::get('path/manager/modules/path')), 'modules' => $controllersManagerList);
     //Globals::set('manager')->access = "";
     // verifica dependencias de plugins no controler Master
     $resultDependenceMaster = $plugins->checkDependence('_control');
     $resultDependenceMasterObj = json_decode($resultDependenceMaster);
     Globals::set('plugins')->dependence = array("_control" => $resultDependenceMasterObj->data[0]);
     $lastaction = Globals::get('http/controllers/lastaction');
     // verifica dependencias de plugins no controler Master
     $resultDependenceModules = $plugins->checkDependence($lastaction);
     $resultDependenceModulesObj = json_decode($resultDependenceModules);
     Globals::set('plugins')->inner('dependence')->add(array($lastaction => $resultDependenceModulesObj->data[0]));
     //Globals::set('plugins')->dependence = array("_control"=>$resultDependenceMasterObj->data[0]);
     if (Globals::get('app/run') == '!') {
         $result = Functions::checkModeAdmin();
         if ($result == false) {
             $queryurl = Globals::get('http/query');
             $queryurl = substr($queryurl, 4);
             header("location: " . Globals::get('path/manager/link') . "/manager/access&destin=" . $queryurl);
             return;
         } else {
             // verifica dependencia da aplicação
             //$plugins->checkDependence('_control');
         }
         // verifica se esta online no Manager ------------------------------
         $result = Functions::checkOnline(false);
         if ($result == true) {
             // cria um menu baseado nos controllers -----------------------
             $controllerArray = Globals::get('manager/options/modules');
             //$controller->getControllers('');
             /*echo '<pre>';
             		print_r($controllerArray);
             		echo '</pre>';*/
             $menu = Menu::makeMenu($controllerArray, Globals::get('path/manager/modules/path'), true);
             Globals::set('manager')->menu = $menu;
             // registra a versão atual
             Globals::set("suite")->inner('update', array('status' => 'updated', 'version' => $suite['version'], 'link' => '', 'html' => ''));
             $resultCheckUpdateStatus = Functions::checkUpdateStatus($suite['version']);
             if ($resultCheckUpdateStatus != false) {
                 $pathUpdate = Globals::get('path/manager/libs/url') . 'update.php';
                 Globals::set("suite")->inner('update', array('status' => 'outdated', 'version' => $resultCheckUpdateStatus->version, 'link' => $resultCheckUpdateStatus->link == '[auto]' ? $pathUpdate : $resultCheckUpdateStatus->link));
                 $alertHtml = Globals::get("alert/html");
                 $alertHtml .= Functions::requireToVar(Globals::get('path/controller/path') . '_html/update.php');
                 Globals::set("alert")->inner('html', $alertHtml);
             }
         }
     } else {
         $controllerArray = Globals::get('app/options/modules');
         //$controller->getControllers('',Globals::get('path/app/path'));
         $menu = Menu::makeMenu($controllerArray, Globals::get('path/app/modules/path'), false);
         Globals::set('app')->menu = $menu;
         if ($resultDependenceModulesObj->status == 'found') {
             // anexa evento
             Events::Attach('plugin[founddependence]', array('value' => $resultDependenceMaster, 'action' => $lastaction));
         }
         if ($resultDependenceMasterObj->status == 'found') {
             // anexa evento
             Events::Attach('plugin[founddependence]', array('value' => $resultDependenceMaster, 'action' => ''));
         }
     }
     if ($getSettings->mode == "page") {
         $this->pageMake();
     }
 }
<?php

session_start();
header('Content-Type: text/html; charset=utf-8');
header('Content-Language: pt-br');
$path = __DIR__ . '/src/';
$dir = scandir($path);
foreach ($dir as $k => $d) {
    if (!substr_count($d, '.php')) {
        continue;
    }
    $class = explode('.php', $d);
    $class = reset($class);
    if (class_exists($class)) {
        continue;
    }
    include $path . $d;
}
$r = isset($_GET['r']) ? $_GET['r'] : '';
$r = explode('?', $r);
$r = reset($r);
Globals::set('r', $r);
App::setupLibrary();
App::setupModels();
App::setupControllers();
App::getRoute();
App::close();
Пример #8
0
 public function setUp()
 {
     Globals::set('getIds', [7, 6]);
     $argv = [__FILE__, '-d', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'tests'];
     $this->binary = new Binary($argv);
 }
Пример #9
0
 /**
  * @depends testSetArray
  * @covers Phramework\Testphase\Globals::get
  */
 public function testGetVariableAsIndex($array)
 {
     $variableIndex = '1';
     Globals::set('variableIndex', $variableIndex);
     $return = Globals::get(sprintf('array[%s]', 'variableIndex'));
     $this->assertSame($array[$variableIndex], $return);
     //literal integer
     $return = Globals::get(sprintf('array[%s]', 2));
     $this->assertSame($array[2], $return);
 }
Пример #10
0
 /**
  *
  */
 public function addCache()
 {
     Globals::set('MongularCache', TRUE);
 }
Пример #11
0
 public function TestAction()
 {
     Globals::set('manager')->inner('parameters', array('title' => 'Plugins', 'subtitle' => '', 'content' => '<div id="novis"></div>'));
     return array('continue' => true, 'view' => array(array('html' => '')));
 }
Пример #12
0
 /**
  * Method to destroy all data in the session and end it.
  */
 public function clear_session()
 {
     \Globals::set('_SESSION', array());
     session_destroy();
 }