Minor - Replacing block with region

skala
Julio Montoya 14 years ago
parent b319b95ff1
commit c7ab711b4c
  1. 4
      main/admin/settings.lib.php
  2. 2
      main/inc/lib/main_api.lib.php
  3. 37
      main/inc/lib/plugin.lib.php
  4. 16
      main/inc/lib/template.lib.php

@ -49,7 +49,7 @@ function handle_regions() {
/* We display all the possible plugins and the checkboxes */
$plugin_list = array();
$my_plugin_list = $plugin_obj->get_plugin_blocks();
$my_plugin_list = $plugin_obj->get_plugin_regions();
foreach($my_plugin_list as $plugin_item) {
$plugin_list[$plugin_item] = $plugin_item;
}
@ -121,7 +121,7 @@ function handle_plugins() {
echo '</tr>';
$plugin_list = array();
$my_plugin_list = $plugin_obj->get_plugin_blocks();
$my_plugin_list = $plugin_obj->get_plugin_regions();
foreach($my_plugin_list as $plugin_item) {
$plugin_list[$plugin_item] = $plugin_item;
}

@ -3404,7 +3404,7 @@ function api_number_of_plugins($location) {
/**
* Including the necessary plugins.
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @deprecated use AppPlugin::get_all_plugin_contents_by_block function
* @deprecated use AppPlugin::get_all_plugin_contents_by_region function
*/
function api_plugin($location) {
global $_plugins;

@ -1,7 +1,8 @@
<?php
/* See license terms in /license.txt */
class AppPlugin {
var $plugin_blocks = array (
var $plugin_regions = array (
// 'loginpage_main',
'login_top',
'login_bottom',
@ -24,8 +25,7 @@ class AppPlugin {
'course_tool_plugin'
);
function __construct() {
function __construct() {
}
/* For each of the possible plugin directories we check whether a file named "plugin.php" exists
@ -37,6 +37,7 @@ class AppPlugin {
$plugin_info['version'] = '0.1 alpha'; // The version number of the plugin.
$plugin_info['author'] = 'Patrick Cool'; // The author of the plugin.
*/
function read_plugins_from_path() {
/* We scan the plugin directory. Each folder is a potential plugin. */
$pluginpath = api_get_path(SYS_PLUGIN_PATH);
@ -52,14 +53,14 @@ class AppPlugin {
return $possible_plugins;
}
function get_installed_plugins_by_block(){
$usedplugins = array();
function get_installed_plugins_by_region(){
$used_plugins = array();
/* We retrieve all the active plugins. */
$result = api_get_settings('Plugins');
foreach ($result as $row) {
$usedplugins[$row['variable']][] = $row['selected_value'];
$used_plugins[$row['variable']][] = $row['selected_value'];
}
return $usedplugins;
return $used_plugins;
}
function get_installed_plugins() {
@ -132,17 +133,17 @@ class AppPlugin {
return false;
}
function get_plugin_blocks() {
sort($this->plugin_blocks);
return $this->plugin_blocks;
function get_plugin_regions() {
sort($this->plugin_regions);
return $this->plugin_regions;
}
function load_block($block, $main_template) {
function load_region($region, $main_template) {
ob_start();
$this->get_all_plugin_contents_by_block($block, $main_template);
$block_content = ob_get_contents();
$this->get_all_plugin_contents_by_region($region, $main_template);
$content = ob_get_contents();
ob_end_clean();
return $block_content;
return $content;
}
/**
@ -152,18 +153,18 @@ class AppPlugin {
* @param smarty obj
* @todo improve this function
*/
function get_all_plugin_contents_by_block($block, $template) {
function get_all_plugin_contents_by_region($region, $template) {
global $_plugins;
if (isset($_plugins[$block]) && is_array($_plugins[$block])) {
if (isset($_plugins[$region]) && is_array($_plugins[$region])) {
//if (1) {
foreach ($_plugins[$block] as $plugin_name) {
foreach ($_plugins[$region] as $plugin_name) {
//Load the plugin information
//The plugin_info variable is available inside the plugin index
$plugin_info = $this->get_plugin_info($plugin_name);
//We also where the plugin is
$plugin_info['current_region'] = $block;
$plugin_info['current_region'] = $region;
// Loading the plugin/XXX/index.php file
$plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/index.php";

@ -80,9 +80,9 @@ class Template extends Smarty {
//Chamilo plugins
$this->plugin = new AppPlugin();
$plugin_blocks = $this->plugin->get_plugin_blocks();
foreach ($plugin_blocks as $block) {
$this->set_plugin_block($block);
$plugin_regions = $this->plugin->get_plugin_regions();
foreach ($plugin_regions as $region) {
$this->set_plugin_region($region);
}
}
@ -588,12 +588,12 @@ class Template extends Smarty {
}
/* Sets the plugin content in a Smarty variable */
function set_plugin_block($plugin_block) {
if (!empty($plugin_block)) {
$block_content = $this->plugin->load_block($plugin_block, $this);
if (!empty($block_content)) {
function set_plugin_region($plugin_region) {
if (!empty($plugin_region)) {
$content = $this->plugin->load_region($plugin_region, $this);
if (!empty($content)) {
//Assigning the plugin with the smarty template
$this->assign('plugin_'.$plugin_block, $block_content);
$this->assign('plugin_'.$plugin_region, $content);
}
}
return null;

Loading…
Cancel
Save