Adding some commets + using get_lang and other examples in the show user info plugin see #4450

skala
Julio Montoya 14 years ago
parent 7743980b2f
commit 44c220b1a6
  1. 15
      main/admin/settings.lib.php
  2. 26
      main/inc/lib/plugin.lib.php
  3. 2
      main/template/default/layout/layout_1_col.tpl
  4. 2
      main/template/default/layout/layout_2_col.tpl
  5. 16
      plugin/show_user_info/index.php
  6. 2
      plugin/show_user_info/plugin.php
  7. 33
      plugin/show_user_info/template.tpl

@ -38,7 +38,7 @@ function handle_plugins() {
echo '<form name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">';
echo '<table class="data_table">';
echo '<tr>';
echo '<th width="300px">';
echo '<th width="400px">';
echo get_lang('Plugin');
echo '</th><th>';
echo get_lang('PluginArea').'';
@ -62,8 +62,6 @@ function handle_plugins() {
echo '</th>';
echo '</tr>';
$usedplugins = $plugin_obj->get_installed_plugins_by_block();
/* We display all the possible plugins and the checkboxes */
$plugin_list = array();
@ -88,21 +86,10 @@ function handle_plugins() {
echo "<a href='".api_get_path(WEB_PLUGIN_PATH).$plugin."/readme.txt'>readme.txt</a>";
}
echo '</td><td>';
$selected_plugins = $plugin_obj->get_areas_by_plugin($plugin);
echo Display::select('plugin_'.$plugin.'[]', $plugin_list, $selected_plugins, array('multiple' => 'multiple', 'style' => 'width:500px'));
/* display_plugin_cell('loginpage_main', $plugin_info, $plugin, $usedplugins);
display_plugin_cell('loginpage_menu', $plugin_info, $plugin, $usedplugins);
display_plugin_cell('campushomepage_main', $plugin_info, $plugin, $usedplugins);
display_plugin_cell('campushomepage_menu', $plugin_info, $plugin, $usedplugins);
display_plugin_cell('mycourses_main', $plugin_info, $plugin, $usedplugins);
display_plugin_cell('mycourses_menu', $plugin_info, $plugin, $usedplugins);
display_plugin_cell('header', $plugin_info, $plugin, $usedplugins);
display_plugin_cell('footer', $plugin_info, $plugin, $usedplugins);
display_plugin_cell('course_tool_plugin', $plugin_info, $plugin, $usedplugins);*/
echo '</td></tr>';
}
}

@ -110,6 +110,13 @@ class AppPlugin {
return $block_content;
}
/**
*
*
* @param string $block
* @param smarty obj
* @todo improve this function
*/
function get_all_plugin_contents_by_block($block, $main_template) {
global $_plugins;
if (isset($_plugins[$block]) && is_array($_plugins[$block])) {
@ -122,13 +129,7 @@ class AppPlugin {
$plugin_info['current_block'] = $block;
// Loading the plugin/XXX/index.php file
include api_get_path(SYS_PLUGIN_PATH)."$plugin_name/index.php";
//Loading the smarty template files if exists
$template_list = array();
if (isset($plugin_info) && isset($plugin_info['templates'])) {
$template_list = $plugin_info['templates'];
}
require api_get_path(SYS_PLUGIN_PATH)."$plugin_name/index.php";
//We set the $template variable in order to use smarty
if (isset($_template) && !empty($_template)) {
@ -136,6 +137,15 @@ class AppPlugin {
$main_template->assign($key, $value);
}
}
//Loading the smarty template files if exists
$template_list = array();
if (isset($plugin_info) && isset($plugin_info['templates'])) {
$template_list = $plugin_info['templates'];
}
//var_dump($plugin_info);
if (!empty($template_list)) {
foreach($template_list as $plugin_tpl) {
if (!empty($plugin_tpl)) {
@ -160,7 +170,7 @@ class AppPlugin {
require $plugin_file;
}
$plugin_data[$plugin_name] = $plugin_info;
return $plugin_data;
return $plugin_info;
}
}

@ -20,7 +20,7 @@
</section>
{if !empty($plugin_content_bottom)}
<div class="clear"></div>
<div id="plugin_content_bottom">
<div id="plugin_content_bottom" class="span12">
{$plugin_content_bottom}
</div>
{/if}

@ -51,7 +51,7 @@
</section>
{if !empty($plugin_content_bottom)}
<div id="plugin_content_bottom">
<div id="plugin_content_bottom" class="span12">
{$plugin_content_bottom}
</div>
{/if}

@ -1,22 +1,18 @@
<?php
//A user must be logged in
$_template['show_message'] = false;
if (!api_is_anonymous()) {
$_template['show_message'] = true;
//Getting the current user id
$user_id = api_get_user_id();
//Getting the current user info
$user_info = api_get_user_info($user_id);
//Showing the complete name (that means the firstname and lastname depending of the language)
echo 'This is a simple echo';
//If you want to see more data you can do a var_dump($user_info);
//You can also change the style
echo '<h4>This is an echo with style :)</h4>';
//You can also use smarty setting variables in the special variable called template
$_template['user_info'] = $user_info;
$_template['user_email'] = $user_info['mail'];
$_template['my_user_info'] = $user_info;
$_template['my_username'] = $user_info['username'];
}

@ -12,7 +12,7 @@
//the plugin title
$plugin_info['title'] = 'Show user information';
//the comments that go with the plugin
$plugin_info['comment'] = "Shows the user information";
$plugin_info['comment'] = "Shows a welcome message, (this is an example to uses smarty)";
//the plugin version
$plugin_info['version'] = '1.0';
//the plugin author

@ -1,4 +1,33 @@
This is a chamilo plugin using smarty
{*
This is a Chamilo plugin using Smarty you can use handy shorcuts like:
1. Shortcuts
$_p = url chamilo paths
$_u = user information of the current user
2. i18n
You can use i18n variables just use this syntax:
{"HelloWorld"|get_lang}
Now you can add your variables in the main/lang/english/ or main/lang/spanish/ for example in spanish:
$HelloWorld = "Hola Mundo";
3. Portal settings
You can access the portal settings using:
{"siteName"|api_get_setting}
For more settings check the settings_current database
4. Read more
You can also see more examples in the the main/template/default/layout files
*}
{if $show_message}
<div class="well">
Welcome, {$user_info.complete_name}
{"Welcome"|get_lang} {$my_user_info.complete_name} ({$my_username})
<br />
The administrator - {"siteName"|api_get_setting}
</div>
{/if}
Loading…
Cancel
Save