Пример #1
0
/**
 * Get the resource relative to object's script file, this is quite useful to
 * get the resource content that locates in the composer's vendor folder.
 *
 * @author Jack
 * @date Sat Feb 21 10:22:35 2015
 * @param name
 * 		The name of the resource
 * @param obj
 * 		The object
 * @return
 * 		The content of the resource
 */
function content_relative($name, $obj)
{
    $path = class_script_path($obj);
    if ($path) {
        $p = path_join(dirname($path), $name);
        if (\file_exists($p)) {
            return \file_get_contents($p);
        }
    }
    return null;
}
Пример #2
0
/**
 * Get the uri relative to widget's path
 *
 * @author Jack
 * @date Sat Mar  7 10:03:19 2015
 */
function widget_uri($widget, $uri = '/')
{
    $path = get_widget_path($widget);
    if ($path) {
        if (strpos($path, FCPATH) === false) {
            // We might be in the soft link(in development mode)
            $base_dir = dirname(dirname(dirname(class_script_path('Clips\\Widget'))));
            $base = path_join('vendor/guitarpoet/clips-tool/', substr($path, strlen($base_dir)));
        } else {
            $base = substr($path, strlen(FCPATH));
        }
        return path_join($base, $uri);
    }
    return false;
}