Esempio n. 1
0
 /**
  * Load the module.
  *
  * @return boolean
  * @since 1.1
  */
 public function load($force = false)
 {
     if (!$force && $this->get_settings('once') && $this->is_loaded()) {
         return true;
     }
     if ($path = Momtaz_Modules::locate_module($this->get_path())) {
         // Load the module main file.
         momtaz_load_template($path, false);
         // Set the module loader status.
         $this->statuses['loaded'] = true;
         return true;
     }
     return false;
 }
Esempio n. 2
0
/**
 * Retrieve the name of the highest priority template file that exists.
 *
 * Searches in the registered template stacks so that locations
 * which have a high priority checked first.
 *
 * @since 1.1
 */
function momtaz_locate_template($template_names, $load = false, $load_once = true, $_args = null)
{
    // No file found yet
    $located = '';
    // Try to find a template file
    foreach ((array) $template_names as $template_name) {
        // Continue if template is empty
        if (empty($template_name)) {
            continue;
        }
        // Trim off any slashes from the template name
        $template_name = ltrim($template_name, '/');
        // Loop through template stack
        foreach (Momtaz_Stacks::get() as $template_stack) {
            if (empty($template_stack->path)) {
                continue;
            }
            $stack_path = trailingslashit($template_stack->path);
            if (file_exists($stack_path . $template_name)) {
                $located = $stack_path . $template_name;
                break;
            }
        }
        if (!empty($located)) {
            break;
        }
    }
    // Maybe load the template if one was located
    if ($load && !empty($located)) {
        momtaz_load_template($located, $load_once, $_args);
    }
    return $located;
}