if (is_array($t_author)) {
         $t_author = implode($t_author, ', ');
     }
     if (!is_blank($t_contact)) {
         $t_author = '<br />' . sprintf(lang_get('plugin_author'), '<a href="mailto:' . string_display_line($t_contact) . '">' . string_display_line($t_author) . '</a>');
     } else {
         $t_author = '<br />' . string_display_line(sprintf(lang_get('plugin_author'), $t_author));
     }
 }
 if (!is_blank($t_url)) {
     $t_url = '<br />' . lang_get('plugin_url') . lang_get('word_separator') . "<a href=\"{$t_url}\">{$t_url}</a>";
 }
 $t_ready = true;
 if (is_array($t_requires)) {
     foreach ($t_requires as $t_plugin => $t_version) {
         $t_dependency = plugin_dependency($t_plugin, $t_version);
         if (1 == $t_dependency) {
             $t_depends[] = '<span class="small dependency_met">' . string_display_line($t_plugins[$t_plugin]->name . ' ' . $t_version) . '</span>';
         } else {
             if (-1 == $t_dependency) {
                 $t_ready = false;
                 $t_depends[] = '<span class="small dependency_dated">' . string_display_line($t_plugins[$t_plugin]->name . ' ' . $t_version) . '</span>';
             } else {
                 $t_ready = false;
                 $t_depends[] = '<span class="small dependency_unmet">' . string_display_line($t_plugin . ' ' . $t_version) . '</span>';
             }
         }
     }
 }
 if (0 < count($t_depends)) {
     $t_depends = implode($t_depends, '<br />');
Exemplo n.º 2
0
/**
 * Initialize a single plugin.
 * @param string Plugin basename
 * @return boolean True if plugin initialized, false otherwise.
 */
function plugin_init($p_basename)
{
    global $g_plugin_cache, $g_plugin_cache_init;
    # handle dependent plugins
    if (isset($g_plugin_cache[$p_basename])) {
        $t_plugin = $g_plugin_cache[$p_basename];
        # hard dependencies; return false if the dependency is not registered,
        # does not meet the version requirement, or is not yet initialized.
        if (is_array($t_plugin->requires)) {
            foreach ($t_plugin->requires as $t_required => $t_version) {
                if (plugin_dependency($t_required, $t_version, true) !== 1) {
                    return false;
                }
            }
        }
        # soft dependencies; only return false if the soft dependency is
        # registered, but not yet initialized.
        if (is_array($t_plugin->uses)) {
            foreach ($t_plugin->uses as $t_used => $t_version) {
                if (isset($g_plugin_cache[$t_used]) && !isset($g_plugin_cache_init[$t_used])) {
                    return false;
                }
            }
        }
        # if plugin schema needs an upgrade, do not initialize
        if (plugin_needs_upgrade($t_plugin)) {
            return false;
        }
        plugin_push_current($p_basename);
        # load plugin error strings
        global $g_lang_strings;
        $t_lang = lang_get_current();
        $t_plugin_errors = $t_plugin->errors();
        foreach ($t_plugin_errors as $t_error_name => $t_error_string) {
            $t_error_code = "plugin_{$p_basename}_{$t_error_name}";
            $g_lang_strings[$t_lang]['MANTIS_ERROR'][$t_error_code] = $t_error_string;
        }
        # finish initializing the plugin
        $t_plugin->__init();
        $g_plugin_cache_init[$p_basename] = true;
        plugin_pop_current();
        return true;
    } else {
        return false;
    }
}