Minor Plugin fixes

skala
Julio Montoya 13 years ago
parent bd5165f0cd
commit 3982381e03
  1. 10
      main/admin/configure_plugin.php
  2. 23
      main/inc/lib/plugin.lib.php
  3. 56
      main/inc/lib/template.lib.php
  4. 7
      plugin/rss/index.php
  5. 2
      plugin/rss/lang/english.php

@ -37,9 +37,9 @@ if (isset($plugin_info['settings_form'])) {
if (isset($form)) {
//We override the form attributes
$attributes = array('action'=>api_get_self().'?name='.$plugin_name, 'method'=>'POST');
$form->updateAttributes($attributes);
$form->updateAttributes($attributes);
$content = Display::page_header($plugin_info['title']);
$content .= $form->toHtml();
$content .= $form->toHtml();
}
} else {
$message = Display::return_message(get_lang('NoConfigurationSettingsForThisPlugin'), 'warning');
@ -55,13 +55,13 @@ if (isset($form)) {
array('Plugins', $access_url_id, $plugin_name, 'setting', "status")));
foreach ($values as $key => $value) {
$key = Database::escape_string($plugin_name.'_'.$key);
api_add_setting($value, $key, $plugin_name, 'setting', 'Plugins', $plugin_name, null, null, null, $_configuration['access_url'], 1);
api_add_setting($value, $key, $plugin_name, 'setting', 'Plugins', $plugin_name, null, null, null, $_configuration['access_url'], 1);
}
$message = Display::return_message(get_lang('Updated'), 'success');
}
}
$tpl = new Template($tool_name);
$tpl = new Template($tool_name, true, true, false, true, false);
$tpl->assign('actions', $actions);
$tpl->assign('message', $message);
$tpl->assign('content', $content);

@ -128,9 +128,9 @@ class AppPlugin {
return $this->plugin_regions;
}
function load_region($region, $main_template) {
function load_region($region, $main_template, $forced = false) {
ob_start();
$this->get_all_plugin_contents_by_region($region, $main_template);
$this->get_all_plugin_contents_by_region($region, $main_template, $forced);
$content = ob_get_contents();
ob_end_clean();
return $content;
@ -142,7 +142,7 @@ class AppPlugin {
* @todo add caching
* @param string $plugin_name
*/
function load_plugin_lang_variables($plugin_name) {
function load_plugin_lang_variables($plugin_name) {
global $language_interface;
$root = api_get_path(SYS_PLUGIN_PATH);
@ -150,10 +150,11 @@ class AppPlugin {
$english_path = $root.$plugin_name."/lang/english.php";
if (is_readable($english_path)) {
include $english_path;
include $english_path;
foreach ($strings as $key => $string) {
//$$key = $string;
$GLOBALS[$key] = $string;
$GLOBALS[$key] = $string;
}
}
@ -180,15 +181,15 @@ class AppPlugin {
* @param obj template obj
* @todo improve this function
*/
function get_all_plugin_contents_by_region($region, $template) {
function get_all_plugin_contents_by_region($region, $template, $forced = false) {
global $_plugins;
if (isset($_plugins[$region]) && is_array($_plugins[$region])) {
//if (1) {
foreach ($_plugins[$region] as $plugin_name) {
//Load the plugin information
//Load the plugin information
foreach ($_plugins[$region] as $plugin_name) {
//The plugin_info variable is available inside the plugin index
$plugin_info = $this->get_plugin_info($plugin_name);
$plugin_info = $this->get_plugin_info($plugin_name, $forced);
//We also know where the plugin is
$plugin_info['current_region'] = $region;
@ -237,7 +238,6 @@ class AppPlugin {
}
/**
*
* Loads plugin info
* @staticvar array $plugin_data
* @param string plugin name
@ -250,7 +250,8 @@ class AppPlugin {
if (isset($plugin_data[$plugin_name]) && $forced == false) {
return $plugin_data[$plugin_name];
} else {
$plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/plugin.php";
$plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/plugin.php";
$plugin_info = array();
if (file_exists($plugin_file)) {
require $plugin_file;

@ -24,9 +24,18 @@ class Template {
var $user_is_logged_in = false;
var $twig = null;
/* Loads chamilo plugins */
var $load_plugins = false;
var $params = array();
function __construct($title = '', $show_header = true, $show_footer = true, $show_learnpath = false, $hide_global_chat = false) {
function __construct($title = '', $show_header = true, $show_footer = true, $show_learnpath = false, $hide_global_chat = false, $load_plugins = true) {
//Page title
$this->title = $title;
$this->show_learnpath = $show_learnpath;
$this->hide_global_chat = $hide_global_chat;
$this->load_plugins = $load_plugins;
//Twig settings
Twig_Autoloader::register();
@ -67,7 +76,7 @@ class Template {
$this->twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
$this->twig->addFilter('return_message', new Twig_Filter_Function('Display::return_message_and_translate'));
$this->twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate'));
$this->twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate'));
$this->twig->addFilter('display_page_subheader', new Twig_Filter_Function('Display::page_subheader_and_translate'));
/*
@ -78,12 +87,7 @@ class Template {
//'tag_variable' => array('{$', '}'),
));
$this->twig->setLexer($lexer);*/
//Page title
$this->title = $title;
$this->show_learnpath = $show_learnpath;
$this->hide_global_chat = $hide_global_chat;
//Setting system variables
$this->set_system_parameters();
@ -104,20 +108,22 @@ class Template {
//Chamilo plugins
if ($this->show_header) {
$this->plugin = new AppPlugin();
//1. Showing installed plugins in regions
$plugin_regions = $this->plugin->get_plugin_regions();
foreach ($plugin_regions as $region) {
$this->set_plugin_region($region);
}
//2. Loading the course plugin info
global $course_plugin;
if (isset($course_plugin) && !empty($course_plugin) && !empty($this->course_id)) {
//Load plugin get_langs
$this->plugin->load_plugin_lang_variables($course_plugin);
if ($this->load_plugins) {
$this->plugin = new AppPlugin();
//1. Showing installed plugins in regions
$plugin_regions = $this->plugin->get_plugin_regions();
foreach ($plugin_regions as $region) {
$this->set_plugin_region($region);
}
//2. Loading the course plugin info
global $course_plugin;
if (isset($course_plugin) && !empty($course_plugin) && !empty($this->course_id)) {
//Load plugin get_langs
$this->plugin->load_plugin_lang_variables($course_plugin);
}
}
}
}
@ -635,8 +641,8 @@ class Template {
/* Sets the plugin content in a template variable */
function set_plugin_region($plugin_region) {
if (!empty($plugin_region)) {
$content = $this->plugin->load_region($plugin_region, $this);
if (!empty($plugin_region)) {
$content = $this->plugin->load_region($plugin_region, $this, $this->force_plugin_load);
$this->assign('plugin_'.$plugin_region, $content);
}
return null;
@ -651,7 +657,7 @@ class Template {
$this->params[$tpl_var] = $value;
}
public function display($template = null, $cache_id = null, $compile_id = null, $parent = null) {
public function display($template = null, $cache_id = null, $compile_id = null, $parent = null) {
echo $this->twig->render($template, $this->params);
}
}

@ -9,16 +9,13 @@ $title = $title ? "<h4>$title</h4>" : '';
$css = $plugin->get_css();
$css = $css ? "<style type=\"text/css\" scoped=\"scoped\">$css</style>" : '';
$bullet = api_get_path(WEB_PLUGIN_PATH) . '/rss/resources/arrow-bullet.png';
if (empty($rss))
{
echo get_lang('no_rss');
if (empty($rss)) {
Display::display_warning_message(get_lang('no_rss'));
return;
}
echo<<<EOT
<div class="well sidebar-nav rss">
$css

@ -9,7 +9,7 @@
$strings['plugin_title'] = "RSS";
$strings['plugin_comment'] = "Display RSS content.";
$strings['rss'] = "Rss";
$strings['rss'] = "RSS";
$strings['block_title'] = "Block title";
$strings['title'] = "Title";

Loading…
Cancel
Save