コード例 #1
0
ファイル: url.php プロジェクト: jhonlennon/estrutura-mvc
/**
 * Retorna url formatada
 * @param type $Controller_Action
 * @param array $Variables
 * @param type $Modulo
 * @param array $VariaveisGet
 * @param boolean $secure
 * @return string
 */
function url($Controller_Action = '', array $Variables = null, $Modulo = null, array $VariaveisGet = null, $secure = false)
{
    # Base
    $url = base_url();
    # Modulo
    if ($Modulo === null) {
        $Modulo = APP::getCurrentModule();
    }
    if ($Modulo != APP::getDefaultModule() or $Controller_Action and APP::getModules(explode('/', $Controller_Action)[0])) {
        $url .= '/' . $Modulo;
    }
    # Controller/Action
    if (!empty($Controller_Action)) {
        if ($Variables) {
            if (count($ex = explode('/', $Controller_Action)) == 1) {
                if (controller_exists($ex[0])) {
                    $url .= "/{$ex[0]}/index";
                } else {
                    $url .= '/index/' . $ex[0];
                }
            } else {
                $url .= '/' . $Controller_Action;
            }
        } else {
            $url .= '/' . $Controller_Action;
        }
    } else {
        if ($Variables) {
            $url .= 'index/index';
        }
    }
    # Variaveis
    if ($Variables) {
        # Chaves númericas
        if (key($Variables) === 0) {
            foreach ($Variables as $key => $value) {
                $url .= '/' . url_paranformat($value);
            }
        } else {
            foreach ($Variables as $key => $value) {
                $url .= '/' . url_paranformat($key) . '/' . url_paranformat($value);
            }
        }
    }
    # Retornando a URL
    if ($VariaveisGet) {
        $url .= '?' . http_build_query($VariaveisGet);
    }
    # HTTPS
    if ($secure) {
        $url = str_replace('http:', 'https:', $url);
    }
    return $url;
}
コード例 #2
0
ファイル: core.php プロジェクト: jhonlennon/estrutura-mvc
/**
 * Retorna todas as pasta para o include
 * @return array
 */
function get_all_paths()
{
    # Pega o valor já gravado
    if (APP::getGlobal('get_all_paths')) {
        return APP::getGlobal('get_all_paths');
    }
    # Pastas do sistema
    $Paths = ['', 'system', 'system/core', 'system/crud', 'system/helpers', 'system/helpers/Bootstrap', 'system/models', 'system/libraries', 'system/models', 'system/valueobject'];
    # Não possuí cache listando pastas
    if (!APP::getCurrentModule()) {
        return $Paths;
    } else {
        $Paths = array_merge([APP::getCurrentModule(true)], list_paths(APP::getCurrentModule(true)), $Paths);
        $module = APP::getModules()[APP::getCurrentModule()];
        $general = is_array(get_config('library')) ? get_config('library') : [];
        if (is_array($module)) {
            foreach (['library'] as $key => $value) {
                if (is_array($value)) {
                    $general = array_merge($general, $value);
                } else {
                    $general[] = $value;
                }
            }
        }
        foreach ($general as $key => $path) {
            $Paths = array_merge([$path], list_paths($path), $Paths);
        }
        APP::setGlobal('get_all_paths', $Paths);
        return $Paths;
    }
}