예제 #1
0
파일: Settings.php 프로젝트: wallrio/suite
 /**
  * @param  array de opções definidas no load da aplicação
  * @return retorna um array com todas as definições
  */
 public function registerSettings($options = null)
 {
     if ($options == null) {
         $options = file_get_contents(Globals::get('path/app/path') . 'options.json');
         $options = json_decode($options, true);
     }
     $settings = array('mode' => isset($options['mode']) ? $options['mode'] : null, 'prefix' => isset($options['prefix']) ? $options['prefix'] : null, 'querymain' => isset($options['querymain']) ? $options['querymain'] : null, 'modeaccess' => isset($options['modeaccess']) ? $options['modeaccess'] : null, 'app' => isset($options['app']) ? $options['app'] : null, 'debug' => isset($options['debug']) ? $options['debug'] : null, 'charset' => isset($options['charset']) ? $options['charset'] : null, 'manager' => isset($options['manager']) ? $options['manager'] : null);
     $settings = Functions::arrayToObject($settings);
     $this->settings = $settings;
     return $settings;
 }
예제 #2
0
파일: Http.php 프로젝트: wallrio/suite
 public function getControllers($value = null, $getResponse = null)
 {
     // use method setAdapterSettings for use prefix URL
     $settings = isset($this->settings) ? $this->settings : null;
     $urlParam = 'url';
     if ($settings != null) {
         $getSettings = $settings->getSettings();
         $prefix = $getSettings->prefix;
     } else {
         $getSettings = null;
         $prefix = "";
     }
     if ($getResponse == null) {
         $getResponse = $this->getResponse();
     }
     $query = $getResponse->query;
     //$query = $destination;
     $query = str_replace($prefix, '', $query);
     //$query = str_replace('!', '', $query);
     $query = str_replace('//', '/', $query);
     // ajusta conforme prefix definido no index.php
     $queryAjust = $prefix == null ? $query : str_replace($prefix, '', $query);
     // cria um array com a querystring
     $variableArray = explode('&', $queryAjust);
     if ($query != null) {
         // modifica as chaves do array criado com as variaveis get da requisição;
         foreach ($variableArray as $key => $values) {
             $valueArray = explode('=', $values);
             $variableArray[$valueArray[0]] = $valueArray[1];
             unset($variableArray[$key]);
         }
     }
     // ajusta a variavel '$variables' caso não exista conteúdo na querystring URL
     if (isset($variableArray) && array_key_exists($urlParam, $variableArray) == false) {
         $variables = array($urlParam => '/');
     } else {
         if (!isset($variableArray)) {
             $queryparse = array($urlParam => '/');
         }
         $variables = $variableArray;
     }
     $variablesURL = $variables['url'];
     $variablesURLArray = explode('/', $variablesURL);
     $variablesURLArray = array_filter($variablesURLArray);
     $variablesURLArray = array_values($variablesURLArray);
     $variables = $variablesURLArray;
     // captura a aplicação setada
     if (isset($variablesURLArray[0]) && substr($variablesURLArray[0], 0, 1) == ':') {
         $app = substr($variablesURLArray[0], 1);
     } else {
         $app = 'default';
     }
     $key = array_search(':' . $app, $variables);
     if ($key !== false) {
         unset($variables[$key]);
     }
     $variables = implode('/', $variables);
     // separa os controllers pela barra
     $controllers = explode('/', $variables);
     $controllers = array_filter($controllers);
     $controllers = array_values($controllers);
     // caso a variavel $controllers esteja vazia será definida com array contendo uma entrada 'home'
     if (empty($controllers)) {
         $controllers = array('home');
     }
     // cria um array com cada entrada unindo os controllers
     $controllersOrderUnion = '';
     foreach ($controllers as $key => $values) {
         $controllersOrderUnion .= $values . '/';
         $controllersJoin[$key] = $controllersOrderUnion;
         $controllersJoin[$key] = substr($controllersJoin[$key], 0, strlen($controllersJoin[$key]) - 1);
     }
     // captura o ultimo controller
     $lastcontrol = end($controllers);
     // captura apenas todos os controllers
     $destination = isset($variables) ? $variables : null;
     $destination = $destination == null || $destination == '/' ? 'home' : $destination;
     // cria um array com cada entrada unindo os controllers de forma inversa
     $controllersJoinRev = array_reverse($controllersJoin);
     // ajusta conforme prefix definido no index.php
     $destination = substr($destination, 0, 1) == '/' ? substr($destination, 1) : $destination;
     $controllersRequest = array('destination' => $destination, 'lastaction' => $lastcontrol, 'list' => $controllers, 'listjoin' => $controllersJoin, 'listjoinrev' => $controllersJoinRev, 'queryparse' => $variableArray);
     if ($value == null) {
         $resultController = $controllersRequest;
     } else {
         $resultController = $controllersRequest[$value];
     }
     $resultController = Functions::arrayToObject($resultController);
     return $resultController;
 }
예제 #3
0
파일: Path.php 프로젝트: wallrio/suite
 public function setPath()
 {
     $managerApp = "v1";
     //$this->http = $http;
     //$this->settings = $settings;
     $getSettings = Globals::get('settings');
     //$settings->getSettings();
     $querymain = $getSettings->querymain;
     $prefix = $getSettings->prefix;
     $modeaccess = $getSettings->modeaccess;
     $app = $getSettings->app;
     $getResponse = Globals::get('http');
     //$http->getResponse();
     $domainHost = $getResponse->host;
     $domainPath = $getResponse->domain->path;
     $domainURL = $getResponse->domain->url;
     $suitePath = dirname(dirname(__FILE__));
     $suiteUrl = Functions::path2url(dirname(dirname(__FILE__)));
     $parsequeryUrl = $getResponse->parsequery->url;
     $parsequeryUrlArray = explode('/', $parsequeryUrl);
     foreach ($parsequeryUrlArray as $key => $value) {
         if (substr($value, 0, 1) == ":") {
             $app = substr($value, 1);
             break;
         }
     }
     /*if(substr($parsequeryUrlArray[0], 0,1)==':'){
     			$app = substr($parsequeryUrlArray[0], 1);			
     		}else{
     			$app = 'default';
     		}
     		print_r($key);*/
     //$getResponse = $http->getResponse();
     $destination = $getResponse->controllers->destination;
     $controllerList = $getResponse->controllers->list;
     $lastController = $controllerList[count($controllerList) - 1];
     if ($modeaccess == 'rewrite') {
         $appPathBase = $domainPath . 'app/' . $app . '/';
         $appUrlBase = $domainURL . 'app/' . $app . '/';
         $applink = $domainURL . '' . ($prefix != "" ? $prefix . '/' : "") . '';
         $appurl = $appUrlBase;
         $apppath = $appPathBase;
     } else {
         $appPathBase = $domainPath . 'app/' . $app . '/';
         $appUrlBase = $domainURL . 'app/' . $app . '/';
         $applink = $domainURL . '?' . $querymain . '=' . $prefix . '/';
         $appurl = $appUrlBase;
         $apppath = $appPathBase;
     }
     $appbaseUrl = $domainURL . 'app/';
     $appbasePath = $domainPath . 'app/';
     $destinationRePrefix = $destination;
     $destinationRePrefix = str_replace($prefix, '', $destination);
     $destinationRePrefix = str_replace('!', '', $destinationRePrefix);
     $modulesUrl = $appUrlBase . '_modules/';
     $modulesPath = $appPathBase . '_modules/';
     $firstController = $getResponse->controllers->list[0];
     if ($firstController == "!") {
         $destination = explode('/', $destination);
         unset($destination[0]);
         $destination = array_values($destination);
         $destination = implode('/', $destination);
         $destination = str_replace('!', 'home/Home', $destination);
         $lastController = str_replace('!', 'home/Home', $lastController);
         $controllerBaseUrl = $suiteUrl . '/manager/' . $managerApp . '/';
         $controllerBasePath = $suitePath . '/manager/' . $managerApp . '/';
         $controllerUrl = $suiteUrl . '/manager/' . $managerApp . '/_modules/' . $destinationRePrefix . '/';
         $controllerPath = $suitePath . '/manager/' . $managerApp . '/_modules/' . $destinationRePrefix . '/';
     } else {
         $controllerUrl = $appUrlBase . '_modules/' . $destinationRePrefix . '/';
         $controllerPath = $appPathBase . '_modules/' . $destinationRePrefix . '/';
         $controllerBaseUrl = $appUrlBase . '';
         $controllerBasePath = $appPathBase . '';
     }
     $controllerModelPath = $controllerPath . ucfirst($lastController) . '_model.php';
     $controllerModelUrl = $controllerUrl . ucfirst($lastController) . '_model.php';
     $controllerControlPath = $controllerPath . ucfirst($lastController) . '_control.php';
     $controllerControllUrl = $controllerUrl . ucfirst($lastController) . '_control.php';
     $controllerViewPath = $controllerPath . ucfirst($lastController) . '_view.php';
     $controllerViewUrl = $controllerUrl . ucfirst($lastController) . '_view.php';
     $pluginspath = $appPathBase . '' . $this->pluginFixName . '/';
     $pluginsurl = $appUrlBase . '' . $this->pluginFixName . '/';
     //$domainURL.'/'.$appProject.''.self::$pluginFixName.'/';
     $pluginslink = "";
     //$domainURL.'/'.$modeUrlPage.$prefix_url_string.'/'.self::$pluginFixName.'/';
     $managerpath = $suitePath . '/manager/' . $managerApp . '/';
     $managerurl = $suiteUrl . '/manager/' . $managerApp . '/';
     $managerlink = $applink . '!/';
     $managerpluginspath = $controllerBasePath . '' . $this->pluginFixName . '/';
     $managerpluginsurl = $controllerBaseUrl . '' . $this->pluginFixName . '/';
     $managerModulesUrl = $managerurl . '_modules/';
     $managerModulesPath = $managerpath . '_modules/';
     $managerLibsUrl = $suiteUrl . '/';
     $managerLibsPath = $suitePath . '/';
     $controllerModulePath = $controllerPath;
     $controllerModuleUrl = $controllerUrl;
     $path = array('app' => array('name' => $app, 'url' => $appurl . '', 'path' => $apppath . '', 'link' => $applink . '', 'appbase' => array('url' => $appbaseUrl, 'path' => $appbasePath), 'modules' => array('url' => $modulesUrl, 'path' => $modulesPath), 'plugins' => (object) array('path' => $pluginspath, 'url' => $pluginsurl, 'repository' => array('oficial' => 'http://suite.wallrio.com/plugins/repository/'))), 'controller' => array('url' => $controllerBaseUrl, 'path' => $controllerBasePath, 'modules' => array('path' => $controllerBasePath . '_modules/', 'url' => $controllerBaseUrl . '_modules/'), 'model' => array('path' => $controllerModelPath, 'url' => $controllerModelUrl), 'control' => array('path' => $controllerControlPath, 'url' => $controllerControllUrl), 'view' => array('path' => $controllerViewPath, 'url' => $controllerViewUrl), 'action' => array('path' => $controllerPath, 'url' => $controllerUrl), 'module' => array('path' => $controllerModulePath, 'url' => $controllerModuleUrl)), 'domain' => array('host' => $domainHost . '/', 'url' => $domainURL . '', 'path' => $domainPath . ''), 'manager' => (object) array('path' => $managerpath, 'url' => $managerurl, 'link' => $managerlink, 'libs' => array('url' => $managerLibsUrl, 'path' => $managerLibsPath), 'modules' => array('url' => $managerModulesUrl, 'path' => $managerModulesPath), 'plugins' => (object) array('path' => $managerpluginspath, 'url' => $managerpluginsurl)));
     $path = Functions::arrayToObject($path);
     $this->path = $path;
 }
예제 #4
0
파일: Globals.php 프로젝트: wallrio/suite
 /**
  * captura o valor armazenado na variavel
  * @param  [string] $varArg [nome da variavel]
  * @return []         [returna uma instancia para ser utilizada com um membro com nome definido na definição set da variavel]
  */
 public static function get($varArg = null)
 {
     // captura baseado em string ex: Globals::get('app/action/parameters');
     if (strpos($varArg, '/') != false) {
         $valueArray = explode('/', $varArg);
         $get = Globals::get();
         $gets = Functions::arrayToObject($get);
         $resultValue = "";
         foreach ($valueArray as $key => $value) {
             $gets = Functions::arrayToObject($gets);
             if (isset($gets->{$value})) {
                 $gets = $gets->{$value};
                 $resultValue = $gets;
             } else {
                 return "";
             }
         }
         if (!isset($gets)) {
             return "";
         }
         return $gets;
     }
     if ($varArg == null) {
         return self::arrayToObject(self::$vars);
     }
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     self::$varFocus = $varArg;
     $vars = self::$vars;
     if ($varArg == null) {
         return self::$_instance;
     } else {
         return isset($vars[$varArg]) ? $vars[$varArg] : self::$_instance;
     }
     return self::arrayToObject(self::$_instance);
 }
예제 #5
0
 /**
  * Retrieve configuration setting from config.php
  * overrided with relative config mode file
  *
  * @return type
  */
 public static function config()
 {
     // base-config file not found create with setup.php
     $configBaseFile = __BASE__ . '/config.php';
     //
     if (!file_exists($configBaseFile)) {
         Runtime::error('file not found: ' . $configBaseFile, 101);
     }
     //
     $configBase = (include $configBaseFile);
     //
     if (!is_array($configBase)) {
         Runtime::error("empty or corrupted 'config.php' " . "run '<a href='setup.php'>setup.php</a>'", 110);
     }
     //
     $configModeFile = __BASE__ . '/config/' . __NAME__ . '.' . __MODE__ . '.php';
     //
     if (!file_exists($configModeFile)) {
         Runtime::error('file not found: ' . $configModeFile, 102);
     }
     //
     $configMode = (include $configModeFile);
     //
     $configDefault = array('default' => array('code' => 'Default', 'action' => 'index'));
     //
     $config = array_replace_recursive($configDefault, $configBase, $configMode);
     //
     return Functions::arrayToObject($config);
 }