Beispiel #1
0
/**
 * Controller.
 * 
 * This function will locate the associated element and display it in the
 * place of this function call
 * 
 * @param string $name
 */
function get_show_view($name = null)
{
    //initializing variables
    $html = "";
    $args = func_get_args();
    $folders = add_view_path();
    $view = files_find($folders, $name . ".php");
    $model = files_find($folders, "models" . DS . $name . ".php");
    if (is_null($name)) {
        return false;
    }
    if (!$view && !$model) {
        return false;
    }
    $path = $view;
    if (file_exists($model)) {
        ob_start();
        require $model;
        $html = ob_get_clean();
    } else {
        ob_start();
        require $path;
        $html = ob_get_clean();
    }
    if ($html) {
        $html = $html;
    }
    //replace_template_codes( $html, @$args[1] ); ****this was throwing an error but looks important
    return $html;
}
/**
 * Retrieve the name of the highest priority template file that exists.
 *
 * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which
 * inherit from a parent theme can just overload one file.
 *
 * @since 1.0.0
 * @param string|array $template_names Template file(s) to search for, in order.
 * @param bool $load If true the template file will be loaded if it is found.
 * @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false.
 * @return string The template filename if one is located.
 */
function locate_template($template_names)
{
    //initializing
    $folders = add_view_path();
    $located = '';
    foreach ((array) $template_names as $template_name) {
        $view = files_find($folders, $template_name . ".php");
        $model = files_find($folders, "models" . DS . $template_name . ".php");
        if (!$view && !$model) {
            continue;
        }
        $located = $template_name;
        break;
    }
    return $located;
}