Beispiel #1
0
 private static function _load_type($type)
 {
     // Procura o arquivo de tipo
     $type_data = core::get_modular_parts($type, array('path_clip' => true, 'path_repeat' => true, 'path_extension' => '/types', 'make_fullpath' => true));
     // Obtém o nome e inclui a classe responsável
     $type_class = core::get_joined_class($type_data, 'types');
     core::do_require($type_data->fullpath);
     // Inclui e prepara a classe
     $type_object = new $type_class();
     $type_object->on_require();
     // Retorna o objeto com o tipo selecionado
     return self::$_types[$type];
 }
Beispiel #2
0
 public static function load_helper($helper)
 {
     // Primeiramente é necessário identificar se é um helper do próprio módulo
     // Para isto, o helper deve iniciar com duplo underline
     // Exemplo: __exemplo passará a ser site_exemplo
     if (substr($helper, 0, 2) === '__') {
         // Se for, a informação é substituida pelo módulo
         $helper = join('_', core::get_caller_module_path()) . '_' . substr($helper, 2);
     }
     // Agora é necessário localizar o helper e carregá-lo
     $modular_path = core::get_modular_parts($helper, array('path_extension' => '/helpers', 'make_fullpath' => true));
     // Se o helper já tiver sido carregado, evita o processo
     $helper_key = $modular_path->fullpath . ":helper";
     if (isset(self::$_loaded_classes[$helper_key])) {
         return $helper;
     }
     // Inclui o arquivo
     core::do_require($modular_path->fullpath);
     // Salva em loaded classes e retorna
     self::$_loaded_classes[$helper_key] = true;
     return $helper;
 }
Beispiel #3
0
 public static function _create_controller($modular_path_data, $cancel_print = false, $auto_execute = true, $can_detect_caller_path = false)
 {
     // Armazena o método padrão, ele será usado em vários momentos
     $default_method = core_config::get_config(null, 'route_default_method');
     // Define algumas informações principais
     $modular_path = new stdclass();
     $modular_path->url = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . "://{$_SERVER['SERVER_NAME']}" . dirname($_SERVER['SCRIPT_NAME']) . '/';
     // Se o path modular for false, então usa totalmente o padrão
     // Ex: http://127.0.0.1/
     if ($modular_path_data === null || $modular_path_data === false) {
         $modular_path->modular = (array) core_config::get_config(null, 'route_default_modular');
         $modular_path->path = (array) core_config::get_config(null, 'route_default_controller');
         $modular_path->method = $default_method;
         $modular_path->class = core::get_joined_class($modular_path, 'controller');
     } else {
         // Se puder detectar o path do caller (somente execute())
         if ($can_detect_caller_path === true && isset($modular_path_data[0]) === true) {
             // Se o primeiro caractere for um $, indica rota estrita inline
             if ($modular_path_data[0] === '$') {
                 $strict_route = true;
                 $modular_path_data = substr($modular_path_data, 1);
             }
             // Se o modular começar por / apenas remove a informação
             // Caso contrário, deverá preencher com o path do módulo de chamada
             if ($modular_path_data[0] === '/') {
                 $modular_path_data = substr($modular_path_data, 1);
             } else {
                 $modular_path_data = join('/', core::get_caller_module_path()) . '/' . $modular_path_data;
             }
         }
         // Se não definir o modo estrito de rota, obtém a informação
         if (!isset($strict_route)) {
             $strict_route = config('route_strict_mode');
         }
         // Extende a informação da URL
         $modular_path->url .= $modular_path_data;
         // Se houver uma definição de path, é necessário fazer uma busca por arquivos
         // Primeiramente, é necessário separar a chamada
         $modular_path_data = explode('/', $modular_path_data);
         // Depois é necessário buscar pelo modular do endereço solicitado
         // Ex: http://127.0.0.1/site
         $modular_path_data = core::get_modular_parts($modular_path_data, array('search_paths' => false, 'path_clip_empty' => true, 'make_fullpath' => true));
         // Se a modular não for definida, retorna um controller neutro
         if (isset($modular_path_data->modular) === false) {
             if ($strict_route === true) {
                 return new self($modular_path, null, $cancel_print, self::STATUS_CONTROLLER_INVALID | self::STATUS_MODULAR_REQUIRED, self::RETURN_TYPE_DEFAULT, false);
             } else {
                 $modular_path_data->modular = (array) core_config::get_config(null, 'route_default_modular');
             }
         }
         // Senão, armazena a informação
         $modular_path->modular = $modular_path_data->modular;
         // Depois é necessário buscar pelo controller do endereço solicitado
         // Ex: http://127.0.0.1/site/master ou simplesmente http://127.0.0.1/master
         $modular_path_data = core::get_modular_parts(@$modular_path_data->remains, array('start_dir' => $modular_path_data->fullpath . '/controllers', 'search_modules' => false));
         // Se o controller não for definido, define com o valor padrão
         if (!empty($modular_path_data->path)) {
             $modular_path->path = $modular_path_data->path;
         } else {
             if ($strict_route === false) {
                 $modular_path->path = (array) core_config::get_config(null, 'route_default_controller');
             } else {
                 return new self($modular_path, null, $cancel_print, self::STATUS_CONTROLLER_INVALID | self::STATUS_PATH_REQUIRED, self::RETURN_TYPE_DEFAULT, false);
             }
         }
         // Gera o nome completo da chamada
         $modular_path->class = core::get_joined_class($modular_path, 'controller');
         // Se não existir mais informações para o method, usa o valor padrão
         if (empty($modular_path_data->remains) === false) {
             $modular_path->method = array_shift($modular_path_data->remains);
         } else {
             if ($strict_route === false) {
                 $modular_path->method = $default_method;
             } else {
                 return new self($modular_path, null, $cancel_print, self::STATUS_CONTROLLER_INVALID | self::STATUS_METHOD_REQUIRED, self::RETURN_TYPE_DEFAULT, false);
             }
         }
     }
     // Gera o caminho completo do arquivo
     $modular_path->fullpath = core::get_path_fixed(CORE_MODULES . '/' . join('/_', $modular_path->modular) . '/controllers/' . join('/', $modular_path->path) . '.php');
     // Se o arquivo de controller não existir, usará o controler neutro
     if (is_file($modular_path->fullpath) === false) {
         return new self($modular_path, null, $cancel_print, self::STATUS_CONTROLLER_INVALID | self::STATUS_CONTROLLER_NOT_FOUND, self::RETURN_TYPE_DEFAULT, false);
     }
     // Senão, faz um require da classe solicitada
     if (class_exists($modular_path->class, false) === false) {
         core::do_require($modular_path->fullpath);
     }
     // Se for chamado um método diferente do padrão, mas este não existir, usa o método padrão
     try {
         if ($modular_path->method !== $default_method && method_exists($modular_path->class, $modular_path->method) === false) {
             if ($strict_route === true) {
                 return new self($modular_path, null, $cancel_print, self::STATUS_CONTROLLER_INVALID | self::STATUS_METHOD_REQUIRED, self::RETURN_TYPE_DEFAULT, false);
             }
             array_unshift($modular_path_data->remains, $modular_path->method);
             $modular_path->method = $default_method;
         }
     } catch (core_exception $e) {
         $modular_path->method = $default_method;
     }
     // Por fim, cria o controller com as definições passadas
     return new $modular_path->class($modular_path, @$modular_path_data->remains, $cancel_print, self::STATUS_SUCCESS, self::RETURN_TYPE_DEFAULT, $auto_execute);
 }
Beispiel #4
0
 private static function _load_low_priorities($start_dir)
 {
     $priority_path = array_slice(explode('/', core::get_path_fixed($start_dir)), 0, -1);
     // Enquanto puder...
     while (true) {
         // Une a prioridade
         $priority_unify = join('/', $priority_path);
         // Se os dados de configuração ainda não existe, carrega
         // O processo só continuará se esta informação não existir
         if (!isset(self::$_configs[$priority_unify])) {
             core::do_require(CORE_MODULES . "/{$priority_unify}/configs.php");
             array_pop($priority_path);
             continue;
         }
         break;
     }
 }
Beispiel #5
0
$config->language_session_key = 'language-id';
// string, false
// Alterar sessão automaticamente quando usar a request key
//NOTE: altere a informação para false para desabilitar a função
$config->language_session_autosync = true;
/** CONFIGURAÇÕES DE BANCO DE DADOS */
// Permitir conexão preguiçosa: conectar somente quando for necessário.
$config->database_lazy_mode = true;
// boolean
// Usar conexões persistentes por padrão
$config->database_persistent_mode = true;
// boolean
// Charset padrão para ser utilizado
$config->database_default_charset = 'utf8';
// string
/** CONFIGURAÇÕES DE SESSÃO */
// Prefixar sessões (isto evita conflito de sessões)
//NOTE: altere a informação para true para prefixar automaticamente
//NOTE: altere a informação para false para desabilitar a função
$config->session_prefix = true;
// Ao prefixar automaticamente, também incluir a modular
$config->session_prefix_modular = false;
/** CONFIGURAÇÕES DE SEGURANÇA */
// Chave de segurança para SHA256
//NOTE: prefira utilizar um dos itens em: http://bit.ly/aHeU8I
$config->security_key = 'default';
// Salva as configurações na raiz
core_config::save_configs('', $config);
// Carrega as configurações modular
core::do_require(CORE_MODULES . '/configs.php');