Template::GetPath PHP Method

GetPath() public static method

Get the relative path to the given file in the template directory.
public static GetPath ( $p_path, $p_filename ) : string
return string
    public static function GetPath($p_path, $p_filename)
    {
        $lookDir = "/look";
        $p_path = str_replace("//", "/", $p_path);
        // Remove any path that occurs before the 'look' dir.
        $p_path = strstr($p_path, $lookDir);
        // Remove the 'look' dir if it occurs at the beginning of the string.
        if (strncmp($p_path, $lookDir, strlen($lookDir)) == 0) {
            $p_path = substr($p_path, strlen($lookDir));
        }
        // Remove beginning and trailing slashes
        if ($p_path[0] == '/') {
            $p_path = substr($p_path, 1);
        }
        if ($p_path[strlen($p_path) - 1] == '/') {
            $p_path = substr($p_path, 0, strlen($p_path) - 1);
        }
        $p_filename = str_replace("//", "/", $p_filename);
        // Remove beginning slash
        if ($p_filename[0] == '/') {
            $p_filename = substr($p_filename, 1);
        }
        if (!empty($p_path)) {
            $templatePath = $p_path . "/" . $p_filename;
        } else {
            $templatePath = $p_filename;
        }
        return $templatePath;
    }