示例#1
0
/**
 * Gets the site uri.
 * @param $uri
 * @return string
 */
function uriSite($uri)
{
    if (Exido::config('global.core.use_friendly_url')) {
        return HOME . exido_fix_path($uri);
    }
    return HOME . Exido::config('global.core.index_file') . '/' . exido_fix_path($uri);
}
示例#2
0
/**
 * Returns all the files and directories in a resource path.
 * @param bool $path
 * @param bool $recursive
 * @return array
 */
function fileList($path = false, $recursive = false)
{
    $files = array();
    if ($path === false) {
        $paths = array_reverse(Exido::getIncludePaths());
        foreach ($paths as $path) {
            // Recursively get and merge all files
            $files = array_merge($files, fileList($path, $recursive));
        }
    } else {
        $path = exido_fix_path($path);
        if (is_readable($path)) {
            $items = (array) glob($path . '*');
            if (!empty($items)) {
                foreach ($items as $index => $item) {
                    $files[] = $item = exido_fix_path($item);
                    // Handle recursion
                    if (is_dir($item) and $recursive == true) {
                        // Filename should only be the basename
                        $item = pathinfo($item, PATHINFO_BASENAME);
                        // Append sub-directory search
                        $files = array_merge($files, fileList($path . $item, true));
                    }
                }
            }
        }
    }
    return $files;
}
示例#3
0
 /**
  * Creates a new log file.
  * @param string $directory
  * @throws Exception_Exido
  */
 public function __construct($directory)
 {
     // Check if the specified directory exists and available for writing.
     if (!is_dir($directory)) {
         if (!@mkdir($directory, DIR_WRITE_MODE, true)) {
             throw new Exception_Exido("Couldn't create a log directory");
         }
     }
     // Set log path
     $this->_directory = exido_fix_path(realpath($directory)) . '/';
 }
示例#4
0
 /**
  * The alias of helper function htmlJS() for simple using in views.
  * Default script folder is WEB-ROOT/js/
  * @param string $file
  * @param string $folder
  * @return View_Helper_Html
  */
 public function js($file, $folder = 'js')
 {
     if (is_array($file)) {
         foreach ($file as $f) {
             $this->js($f, $folder);
         }
     } else {
         $path = exido_fix_path($folder) . $file . '.js';
         self::$_js[$file] = $path;
         print htmlJS($file, $folder);
     }
     return $this;
 }
示例#5
0
 /**
  * Finds the path of a file by directory, filename, and extension.
  * If no extension is given, the default extension will be used.
  * @param string $dir
  * @param string $file
  * @param bool $required
  * @param null $ext
  * @return array|bool|string
  * @throws Exception_Exido
  */
 public static function findFile($dir, $file, $required = false, $ext = null)
 {
     // Use the defined extension by default
     $ext = $ext === null ? '.php' : '.' . $ext;
     // Create a partial path of the filename
     $pathfile = exido_fix_path($dir) . $file . $ext;
     // Debug log
     if (self::$log_debug) {
         self::$log->add('EXIDO_DEBUG_LOG', 'Include external file ' . $pathfile);
     }
     // The file has not been found yet
     $found = false;
     foreach (self::$_paths as $path) {
         if (is_file($path . $pathfile)) {
             if ($dir == 'config' or $dir == 'i18n') {
                 // A path has been found
                 $found[] = $path . $pathfile;
             } else {
                 // A path has been found and stop searching
                 $found = $path . $pathfile;
                 break;
             }
         }
     }
     if (is_array($found)) {
         $found = array_reverse($found);
     }
     if ($found == false) {
         if ($required === true) {
             // Invalid file
             throw new Exception_Exido("The required file %s is not found", array($dir . $file . '.php'));
         }
     }
     if ($found == true) {
         self::$_files[] = $found;
     }
     return $found;
 }
示例#6
0
/**
 * Replace backslash (\) with slash (/) and trim the trailing slash if needed.
 * @param $path
 * @return string
 */
function stringFixPath($path, $trim = true)
{
    return exido_fix_path($path, $trim);
}
示例#7
0
/**
 * Prints or returns a HTML css include tag. First param is the file name.
 * Second param is the directory where css file is located.
 * If the first param is an array, function prints all an array elements
 * as javascript include tags.
 * @param string $css
 * @param string $folder
 * @return string
 */
function htmlCSS($css, $folder = '')
{
    if (is_array($css)) {
        foreach ($css as $file => $folder) {
            print htmlCSS($file, $folder);
        }
        return '';
    }
    if (empty($folder)) {
        return '';
    }
    return '<link rel="stylesheet" type="text/css" href="' . exido_fix_path($folder) . $css . '.css" />' . EXIDO_EOL;
}