Adding $_p (paths), $_u (current user info) and $app (system params) variables to be load in templates

skala
Julio Montoya 13 years ago
parent b9c24af42d
commit 55c76fb2c6
  1. 18
      main/course_home/activity.php
  2. 14
      main/inc/lib/main_api.lib.php
  3. 77
      main/inc/lib/template.lib.php
  4. 2
      main/inc/lib/userportal.lib.php
  5. 7
      main/template/default/layout/footer.tpl
  6. 2
      userportal-smarty.php

@ -19,23 +19,7 @@ require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
if (api_is_allowed_to_edit(null, true)) {
// HIDE
if (!empty($_GET['hide'])) { // visibility 1 -> 0
/* -- session condition for visibility
if (!empty($session_id)) {
$sql = "select session_id FROM $tool_table WHERE id='".intval($_GET["id"])."' AND session_id = '".intval($session_id)."'";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."' AND session_id = '".intval($session_id)."'";
} else {
$sql_select = "select * FROM $tool_table WHERE id='".$_GET["id"]."'";
$res_select = Database::query($sql_select);
$row_select = Database::fetch_array($res_select);
$sql = "INSERT INTO $tool_table(name,link,image,visibility,admin,address,added_tool,target,category,session_id)
VALUES('{$row_select['name']}','{$row_select['link']}','{$row_select['image']}','0','{$row_select['admin']}','{$row_select['address']}','{$row_select['added_tool']}','{$row_select['target']}','{$row_select['category']}','$session_id')";
}
} else {
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."'";
}*/
if (!empty($_GET['hide'])) {
$sql = "UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."'";
Database::query($sql);
Display::display_confirmation_message(get_lang('ToolIsNowHidden'));

@ -861,15 +861,17 @@ function _api_format_user($user) {
$firstname = $user['firstName'];
$lastname = $user['lastName'];
}
$result['complete_name'] = api_get_person_name($firstname, $lastname);
$result['firstname'] = $firstname;
$result['lastname'] = $lastname;
$result['firstname'] = $firstname;
$result['lastname'] = $lastname;
// Kept for historical reasons
$result['firstName'] = $firstname;
$result['lastName'] = $lastname;
$result['firstName'] = $firstname;
$result['lastName'] = $lastname;
if(isset($user['email'])) {
if (isset($user['email'])) {
$result['mail'] = $user['email'];
} else {
$result['mail'] = $user['mail'];
@ -880,9 +882,11 @@ function _api_format_user($user) {
$result['official_code'] = $user['official_code'];
$result['status'] = $user['status'];
$result['auth_source'] = $user['auth_source'];
if (isset($user['username'])) {
$result['username'] = $user['username'];
}
$result['theme'] = $user['theme'];
$result['language'] = $user['language'];
if (!isset($user['lastLogin']) && !isset($user['last_login'])) {

@ -1,62 +1,41 @@
<?php
/* For licensing terms, see /license.txt */
// Load Smarty library
require_once api_get_path(LIBRARY_PATH).'smarty/Smarty.class.php';
//include api_get_path(LIBRARY_PATH)."raintpl/rain.tpl.class.php";
//include api_get_path(LIBRARY_PATH)."dwoo/dwooAutoload.php";
class Template extends Smarty {
var $style = 'experimental'; //see the template folder
function __construct($title = '') {
$this->title = $title;
/*
*
* Rain TPL
raintpl::configure("base_url", null );
raintpl::configure("tpl_dir", api_get_path(SYS_CODE_PATH).'template/' );
raintpl::configure("cache_dir", api_get_path(SYS_ARCHIVE_PATH));
$this->tpl = new RainTPL();
*/
// Dwoo
//$this->dwoo = new Dwoo(api_get_path(SYS_ARCHIVE_PATH), api_get_path(SYS_ARCHIVE_PATH));
// Load a template file, this is reusable if you want to render multiple times the same template with different data
//$tpl = new Dwoo_Template_File('path/to/index.tpl');
// Create a data set, this data set can be reused to render multiple templates if it contains enough data to fill them all
//$this->tpl = new Dwoo_Data();
// Class Constructor.
// These automatically get set with each new instance.
$this->template_dir = api_get_path(SYS_CODE_PATH).'template/'; // '/web/www.example.com/guestbook/templates/';
$this->compile_dir = api_get_path(SYS_ARCHIVE_PATH); // '/web/www.example.com/guestbook/templates_c/';
$this->config_dir = api_get_path(SYS_ARCHIVE_PATH); // '/web/www.example.com/guestbook/configs/'; main/inc/conf/config?
$this->cache_dir = api_get_path(SYS_ARCHIVE_PATH); // '/web/www.example.com/guestbook/cache/';
$this->title = $title;
$this->template_dir = api_get_path(SYS_CODE_PATH).'template/';
$this->compile_dir = api_get_path(SYS_ARCHIVE_PATH);
//@todo check this config fir
$this->config_dir = api_get_path(SYS_ARCHIVE_PATH); // main/inc/conf/config?
$this->cache_dir = api_get_path(SYS_ARCHIVE_PATH);
$this->plugins_dir = api_get_path(LIBRARY_PATH).'smarty/plugins';
$this->caching = true;
$this->cache_lifetime = Smarty::CACHING_OFF; // no caching
//$this->cache_lifetime = 120;
$this->set_system_parameters();
$this->set_user_parameters();
$this->set_header_parameters();
$this->set_footer_parameters();
//Now we can call the get_lang from a template!!! Just use {"MyString"|get_lang}
//Creating a Smarty modifier - Now we can call the get_lang from a template!!! Just use {"MyString"|get_lang}
$this->registerPlugin("modifier","get_lang", "get_lang");
//To load a smarty plugin
//$this->loadPlugin('smarty_function_get_lang');
//$this->caching = Smarty::CACHING_LIFETIME_CURRENT;
$this->assign('style', $this->style);
}
@ -65,15 +44,28 @@ class Template extends Smarty {
if (api_get_user_id()) {
$user_info = api_get_user_info();
//$this->assign('user_info', $user_info);
$this->assign('user_complete_name', api_get_person_name($user_info['firstname'], $user_info['lastname']));
$this->assign('_u', $user_info);
}
}
}
private function set_system_parameters() {
$this->assign('WEB_PATH', api_get_path(WEB_PATH));
$this->assign('WEB_COURSE_PATH', api_get_path(WEB_COURSE_PATH));
$this->assign('WEB_MAIN_PATH', api_get_path(WEB_CODE_PATH));
global $_configuration;
//Setting app paths
$_p = array('web' => api_get_path(WEB_PATH),
'web_course' => api_get_path(WEB_COURSE_PATH),
'web_main' => api_get_path(WEB_CODE_PATH),
);
$this->assign('_p', $_p);
//Here we can add system parameters that can be use in any template
$app = array(
'software_name' => $_configuration['software_name'],
'system_version' => $_configuration['system_version']
);
$this->assign('app', $app);
}
@ -89,7 +81,7 @@ class Template extends Smarty {
global $menu_navigation;
global $_configuration, $show_learn_path;
$this->assign('system_charset', api_get_system_encoding());
$this->assign('system_charset', api_get_system_encoding());
if (isset($httpHeadXtra) && $httpHeadXtra) {
foreach ($httpHeadXtra as & $thisHttpHead) {
@ -300,9 +292,8 @@ class Template extends Smarty {
$this->assign('show_administrator_data', api_get_setting('show_administrator_data'));
$platform = get_lang('Platform').' <a href="'.$_configuration['software_url'].'" target="_blank">'.$_configuration['software_name'].' '.$_configuration['system_version'].'</a> &copy; '.date('Y');
$this->assign('platform_name', $platform);
//$platform = get_lang('Platform').' <a href="'.$_configuration['software_url'].'" target="_blank">'.$_configuration['software_name'].' '.$_configuration['system_version'].'</a> &copy; '.date('Y');
//$this->assign('platform_name', $platform);
$administrator_data = get_lang('Manager'). ' : '. Display::encrypted_mailto_link(api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')));
$this->assign('administrator_name', $administrator_data);

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
require_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
require_once api_get_path(SYS_CODE_PATH).'survey/survey.lib.php';

@ -6,13 +6,12 @@
{$administrator_name}
</div>
{/if}
<div align="right">
{$platform_name}
<div align="right">
{"Platform"|get_lang} <a href="{$_p.web}" target="_blank">{$app.software_name} {$app.version} </a> &copy; {$smarty.now|date_format:"%Y"}
</div>
</div>
<div class="footer_emails">
<div class="footer_emails">
{* Plugins for footer section *}
<div id="plugin-footer">
{$plugin_footer}

@ -20,7 +20,7 @@ $this_section = SECTION_COURSES;
api_block_anonymous_users(); // Only users who are logged in can proceed.
$userportal = new IndexManager(get_lang('MyCourses'));
$tpl = $userportal->tpl->get_template('layout/layout_3_col.tpl');
$tpl = $userportal->tpl->get_template('layout/layout_2_col.tpl');
//if (!$userportal->tpl->isCached($tpl, api_get_user_id())) {

Loading…
Cancel
Save