Adding support to $app container in all files see #4467 and #5523

skala
Julio Montoya 12 years ago
parent 25093f5434
commit 2e89bc4b97
  1. 29
      index.php
  2. 2
      main/admin/index.php
  3. 2
      main/auth/courses.php
  4. 25
      main/auth/courses_controller.php
  5. 9
      main/course_home/course_home.php
  6. 4
      main/coursecopy/classes/Course.class.php
  7. 2
      main/coursecopy/classes/Document.class.php
  8. 3
      main/create_course/add_course.php
  9. 4
      main/document/document.php
  10. 458
      main/inc/global.inc.php
  11. 24
      main/inc/lib/display.lib.php
  12. 7
      main/inc/lib/events.lib.inc.php
  13. 24
      main/inc/lib/internationalization.lib.php
  14. 244
      main/inc/lib/main_api.lib.php
  15. 38
      main/inc/lib/page.lib.php
  16. 83
      main/inc/lib/template.lib.php
  17. 4
      main/inc/lib/usermanager.lib.php
  18. 5
      main/install/index.php
  19. 3
      main/newscorm/lp_subscribe_users.php
  20. 2
      main/template/default/auth/courses_categories.php
  21. 6
      main/template/default/layout/error.tpl
  22. 118
      src/ChamiloLMS/Controller/IndexController.php
  23. 2
      vendor/autoload.php
  24. 6
      vendor/composer/autoload_real.php

@ -4,6 +4,11 @@
/**
* @package chamilo.main
*/
//Temporal hack
header('Location: web/index');
exit;
define('CHAMILO_HOMEPAGE', true);
$language_file = array('courses', 'index');
@ -18,25 +23,5 @@ require_once 'main/chat/chat_functions.lib.php';
// The section (for the tabs).
$this_section = SECTION_CAMPUS;
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('bxslider'));
$htmlHeadXtra[] = '
<script>
$(document).ready(function(){
$("#slider").bxSlider({
infiniteLoop : true,
auto : true,
pager : true,
autoHover : true,
pause : 10000
});
});
</script>';
//set cookie for check if client browser are cookies enabled
//setcookie('TestCookie', 'cookies_yes', time()+3600*24*31*12);
//use Symfony\Component\HttpFoundation\Cookie;
//$cookie = new Cookie('TestCookie', 'cookies_yes', time()+3600*24*31*12);
//$response->headers->setCookie($cookie);
$app->run();

@ -299,9 +299,7 @@ if (api_is_platform_admin()) {
$blocks['version_check']['items'] = null;
}
$tpl = new Template();
$tpl->assign('blocks', $blocks);
$tpl->display('default/admin/settings_index.tpl');

@ -114,7 +114,7 @@ if (empty($nameTools)) {
// course description controller object
$courses_controller = new CoursesController();
$ctok = $_SESSION['sec_token'];
$ctok = isset($_SESSION['sec_token']) ? $_SESSION['sec_token'] : null;
// We are moving a course or category of the user up/down the list (=Sort My Courses).
if (isset($_GET['move'])) {

@ -18,7 +18,7 @@ class CoursesController { // extends Controller {
/**
* Constructor
*/
public function __construct() {
public function __construct() {
$this->toolname = 'auth';
$actived_theme_path = api_get_template();
$this->view = new View($this->toolname, $actived_theme_path);
@ -34,7 +34,7 @@ class CoursesController { // extends Controller {
public function courses_list($action, $message = '') {
$data = array();
$user_id = api_get_user_id();
$data['user_courses'] = $this->model->get_courses_of_user($user_id);
$data['user_course_categories'] = $this->model->get_user_course_categories();
$data['courses_in_category'] = $this->model->get_courses_in_category();
@ -60,7 +60,7 @@ class CoursesController { // extends Controller {
* @param string error message(optional)
*/
public function categories_list($action, $message='', $error='') {
$data = array();
$data = array();
$data['user_course_categories'] = $this->model->get_user_course_categories();
$data['action'] = $action;
$data['message'] = $message;
@ -81,23 +81,24 @@ class CoursesController { // extends Controller {
*/
public function courses_categories($action, $category_code = null, $message = '', $error = '', $content = null) {
$data = array();
$browse_course_categories = $this->model->browse_course_categories();
$browse_course_categories = $this->model->browse_course_categories();
if ($action == 'display_random_courses') {
$data['browse_courses_in_category'] = $this->model->browse_courses_in_category(null, 10);
} else {
if (!isset($category_code)) {
$category_code = $browse_course_categories[0][1]['code']; // by default first category
}
}
$data['browse_courses_in_category'] = $this->model->browse_courses_in_category($category_code);
}
$data['browse_course_categories'] = $browse_course_categories;
$data['code'] = Security::remove_XSS($category_code);
// getting all the courses to which the user is subscribed to
$curr_user_id = api_get_user_id();
$user_courses = $this->model->get_courses_of_user($curr_user_id);
$user_courses = $this->model->get_courses_of_user($curr_user_id);
$user_coursecodes = array();
// we need only the course codes as these will be used to match against the courses of the category
@ -106,14 +107,14 @@ class CoursesController { // extends Controller {
$user_coursecodes[] = $value['code'];
}
}
if (api_is_drh()) {
$courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
foreach ($courses as $course) {
$user_coursecodes[] = $course['code'];
}
}
}
$data['user_coursecodes'] = $user_coursecodes;
$data['action'] = $action;
$data['message'] = $message;
@ -179,7 +180,7 @@ class CoursesController { // extends Controller {
$message = $result['message'];
$content = $result['content'];
}
if (!empty($search_term)) {
$this->search_courses($search_term, $message, $error);
} else {

@ -232,11 +232,10 @@ $reqdate = "&reqdate=$temps";
/* Introduction section (editable by course admins) */
$content = Display::return_introduction_section(TOOL_COURSE_HOMEPAGE, array(
'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/',
'CreateDocumentDir' => 'document/',
'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/'
)
);
'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/',
'CreateDocumentDir' => 'document/',
'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/'
));
/* SWITCH TO A DIFFERENT HOMEPAGE VIEW
the setting homepage_view is adjustable through

@ -38,10 +38,12 @@ class Course
if (is_array($resources)) {
foreach($resources as $id => $resource) {
if( $resource->links_to($resource_to_check) ) {
return true;
}
if ($type == RESOURCE_LEARNPATH && get_class($resource)=='CourseCopyLearnpath') {
if($resource->has_item($resource_to_check)) {
if ($resource->has_item($resource_to_check)) {
return true;
}
}

@ -35,7 +35,7 @@ class Document extends Resource
*/
function Document($id,$path,$comment,$title,$file_type,$size)
{
parent::Resource($id,RESOURCE_DOCUMENT);
parent::Resource($id, RESOURCE_DOCUMENT);
$this->path = 'document'.$path;
$this->comment = $comment;
$this->title = $title;

@ -324,5 +324,4 @@ if ($form->validate()) {
$tpl->assign('message', $message);
$tpl->assign('content', $content);
$template = $tpl->get_template('layout/layout_1_col.tpl');
$tpl->display($template);
$tpl->display();

@ -23,16 +23,17 @@
* 3) Read files and directories from the directory defined in part 2
* 4) Display all of that on an HTML page
*
* @todo eliminate code duplication with document/document.php, scormdocument.php
*
* @package chamilo.document
*/
/**
* Code
*/
// Language files that need to be included
$language_file = array('document', 'slideshow', 'gradebook', 'create_course');
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_DOCUMENT;
$this_section = SECTION_COURSES;
@ -618,6 +619,7 @@ $(document).ready( function() {
Display::display_header('', 'Doc');
// Lib for event log, stats & tracking & record of the access
event_access_tool(TOOL_DOCUMENT);

@ -115,9 +115,12 @@ require_once __DIR__.'../../../vendor/autoload.php';
//Start Silex
use Silex\Application;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
$app = new Application();
$app['configuration_file'] = $main_configuration_file_path;
$app['conf'] = $_configuration;
$app['configuration'] = $_configuration;
//require_once __DIR__.'/../../resources/config/prod.php';
require_once __DIR__.'/../../resources/config/dev.php';
@ -201,12 +204,37 @@ $app->register(new Silex\Provider\UrlGeneratorServiceProvider());
$app->register(new Silex\Provider\ValidatorServiceProvider());
$app->register(
new Silex\Provider\TranslationServiceProvider(),
array(
'locale_fallback' => 'en'
)
);
$app->register(new Silex\Provider\TranslationServiceProvider(), array(
'locale' => 'en',
'locale_fallback' => 'en'
));
//Handling po files
use Symfony\Component\Translation\Loader\PoFileLoader;
use Symfony\Component\Translation\Dumper\PoFileDumper;
$app['translator'] = $app->share($app->extend('translator', function($translator, $app) {
$translator->addLoader('pofile', new PoFileLoader());
$language = api_get_language_interface();
$iterator = new FilesystemIterator(api_get_path(SYS_PATH).'resources/locale/'.$language);
$filter = new RegexIterator($iterator, '/\.(po)$/');
foreach ($filter as $entry) {
//$domain = $entry->getBasename('.inc.po');
$locale = api_get_language_isocode($language); //'es_ES';
//var_dump($locale);exit;
//$translator->addResource('pofile', $entry->getPathname(), $locale, $domain);
$translator->addResource('pofile', $entry->getPathname(), $locale, 'messages');
}
return $translator;
}));
//$app['translator.domains'] = array();
// Classic way or Controllers ways
$app['classic_layout'] = false;
//Form provider
$app->register(new Silex\Provider\FormServiceProvider());
@ -262,7 +290,9 @@ $app['monolog']->addDebug('Testing the Monolog logging.');
$app['monolog']->addInfo('Testing the Monolog logging.');
$app['monolog']->addError('Testing the Monolog logging.');
*/
$app['translator.messages'] = array();
//The script is allowed?
$app['allowed'] = true;
//Setting the Twig service provider
$app->register(
@ -286,64 +316,53 @@ $app->register(
//Setting Twig options
$app['twig'] = $app->share(
$app->extend(
'twig',
function ($twig, $app) {
$twig->addFilter('get_lang', new Twig_Filter_Function('get_lang'));
$twig->addFilter('get_path', new Twig_Filter_Function('api_get_path'));
$twig->addFilter('get_setting', new Twig_Filter_Function('api_get_setting'));
$twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
$twig->addFilter('return_message', new Twig_Filter_Function('Display::return_message_and_translate'));
$twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate'));
$twig->addFilter(
'display_page_subheader',
new Twig_Filter_Function('Display::page_subheader_and_translate')
);
$twig->addFilter('icon', new Twig_Filter_Function('Template::get_icon_path'));
$twig->addFilter('format_date', new Twig_Filter_Function('Template::format_date'));
return $twig;
}
)
$app->extend('twig', function ($twig, $app) {
$twig->addFilter('get_lang', new Twig_Filter_Function('get_lang'));
$twig->addFilter('get_path', new Twig_Filter_Function('api_get_path'));
$twig->addFilter('get_setting', new Twig_Filter_Function('api_get_setting'));
$twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
$twig->addFilter('return_message', new Twig_Filter_Function('Display::return_message_and_translate'));
$twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate'));
$twig->addFilter(
'display_page_subheader',
new Twig_Filter_Function('Display::page_subheader_and_translate')
);
$twig->addFilter('icon', new Twig_Filter_Function('Template::get_icon_path'));
$twig->addFilter('format_date', new Twig_Filter_Function('Template::format_date'));
return $twig;
})
);
//Setting Doctrine service provider (DBAL)
if (isset($_configuration['main_database'])) {
$app->register(
new Silex\Provider\DoctrineServiceProvider(),
array(
'db.options' => array(
'driver' => 'pdo_mysql',
'dbname' => $_configuration['main_database'],
'user' => $_configuration['db_user'],
'password' => $_configuration['db_password'],
'host' => $_configuration['db_host'],
)
$app->register(new Silex\Provider\DoctrineServiceProvider(), array(
'db.options' => array(
'driver' => 'pdo_mysql',
'dbname' => $_configuration['main_database'],
'user' => $_configuration['db_user'],
'password' => $_configuration['db_password'],
'host' => $_configuration['db_host'],
)
);
));
//Setting Doctrine ORM
$app->register(
new Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider,
array(
'orm.auto_generate_proxies' => true,
"orm.proxies_dir" => $app['db.orm.proxies_dir'],
//'orm.proxies_namespace' => '\Doctrine\ORM\Proxy\Proxy',
"orm.em.options" => array(
"mappings" => array(
array(
"type" => "annotation",
"namespace" => "Entity",
"path" => api_get_path(INCLUDE_PATH).'Entity',
)
),
$app->register(new Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider, array(
'orm.auto_generate_proxies' => true,
"orm.proxies_dir" => $app['db.orm.proxies_dir'],
//'orm.proxies_namespace' => '\Doctrine\ORM\Proxy\Proxy',
"orm.em.options" => array(
"mappings" => array(
array(
"type" => "annotation",
"namespace" => "Entity",
"path" => api_get_path(INCLUDE_PATH).'Entity',
)
),
)
);
),
));
//Setting Doctrine2 extensions
$timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
$app['db.event_manager']->addEventSubscriber($timestampableListener);
@ -362,22 +381,21 @@ class ChamiloServiceProvider implements ServiceProviderInterface
public function register(Application $app)
{
//Template
$app['template'] = $app->share(
function () use ($app) {
return new Template(null, $app);
}
);
$app['template'] = $app->share(function () use ($app) {
$template = new Template(null, $app);
return $template;
});
}
public function boot(Application $app)
{
}
}
//Registering Chamilo service provider
$app->register(new ChamiloServiceProvider(), array());
//Manage error messages
use Symfony\Component\HttpKernel\Exception\HttpException;
$app->error(
function (\Exception $e, $code) use ($app) {
@ -401,36 +419,21 @@ $app->error(
//$code = ($e instanceof HttpException) ? $e->getStatusCode() : 500;
$app['template']->assign('error_code', $code);
$app['template']->assign('error_message', $message);
$response = $app['template']->render_layout('error.tpl');
$response = $app['template']->render_layout('error.tpl');
return new Response($response);
}
);
/*
use Symfony\Component\HttpKernel\Debug\ErrorHandler;
ErrorHandler::register();
*/
use Symfony\Component\HttpFoundation\RedirectResponse;
//Filters
$app->before(
function () use ($app) {
$app->error(function (\LogicException $e, $code) {
var_dump($code);
// this handler will only \LogicException exceptions
// and exceptions that extends \LogicException
});*/
if (!file_exists($app['configuration_file'])) {
return new RedirectResponse(api_get_path(WEB_CODE_PATH).'install');
}
//Check the PHP version
if (api_check_php_version() == false) {
$app->abort(500, "Incorrect PHP version");
}
if (!is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
$app->abort(500, "archive folder must be writeable");
}
//$app['request']->getSession()->start();
}
);
/*use Symfony\Component\HttpKernel\Debug\ErrorHandler;
ErrorHandler::register();*/
if ($app['debug']) {
$logger = new Doctrine\DBAL\Logging\DebugStack();
@ -444,22 +447,6 @@ if ($app['debug']) {
});
}
$app->finish(
function () use ($app) {
//@todo will be removed before a stable release
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0]; /*
$message = "Page loaded in:".($mtime - START);
$app['monolog']->addInfo($message);
$message = "memory_get_usage: ".format_file_size(memory_get_usage(true));
$app['monolog']->addInfo($message);
$message = "memory_get_peak_usage: ".format_file_size(memory_get_peak_usage(true));
$app['monolog']->addInfo($message);*/
}
);
$app['template.show_header'] = true;
$app['template.show_footer'] = true;
$app['template.show_learnpath'] = true;
@ -468,8 +455,8 @@ $app['template.load_plugins'] = true;
//Default template style
$app['template_style'] = 'default';
$app['default_layout'] = 'layout_1_col.tpl';
//Default layout
$app['default_layout'] = $app['template_style'].'/layout/layout_1_col.tpl';
//Database constants
require_once $lib_path.'database.constants.inc.php';
@ -500,7 +487,6 @@ if (!$_configuration['db_host']) {
//$app->abort(500, "Database is unavailable"); //error 3
}*/
/* RETRIEVING ALL THE CHAMILO CONFIG SETTINGS FOR MULTIPLE URLs FEATURE*/
if (!empty($_configuration['multiple_access_urls'])) {
$_configuration['access_url'] = 1;
@ -533,7 +519,7 @@ if (isset($_configuration['main_database']) && !Database::select_db(
/* Initialization of the default encodings */
// The platform's character set must be retrieved at this early moment.
$sql = "SELECT selected_value FROM settings_current WHERE variable = 'platform_charset';";
/*$sql = "SELECT selected_value FROM settings_current WHERE variable = 'platform_charset';";
$result = Database::query($sql);
while ($row = @Database::fetch_array($result)) {
@ -541,7 +527,9 @@ while ($row = @Database::fetch_array($result)) {
}
if (empty($charset)) {
$charset = 'UTF-8';
}
}*/
//Charset is UTF-8
$charset = 'UTF-8';
// Preserving the value of the global variable $charset.
$charset_initial_value = $charset;
@ -587,12 +575,9 @@ if ($already_installed) {
// Load allowed tag definitions for kses and/or HTMLPurifier.
require_once $lib_path.'formvalidator/Rule/allowed_tags.inc.php';
// Load HTMLPurifier.
//require_once $lib_path.'htmlpurifier/library/HTMLPurifier.auto.php'; // It will be loaded later, in a lazy manner.
// Before we call local.inc.php, let's define a global $this_section variable
// which will then be usable from the banner and header scripts
$this_section = SECTION_GLOBAL;
$app['this_section'] = SECTION_GLOBAL;
// include the local (contextual) parameters of this course or section
require $includePath.'/local.inc.php';
@ -603,42 +588,37 @@ require $includePath.'/local.inc.php';
$administrator['email'] = isset($administrator['email']) ? $administrator['email'] : 'admin@example.com';
$administrator['name'] = isset($administrator['name']) ? $administrator['name'] : 'Admin';
//Including mail settings
$mail_conf = api_get_path(CONFIGURATION_PATH).'mail.conf.php';
if (file_exists($mail_conf)) {
require_once $mail_conf;
}
$mail_settings = array();
$app->register(
new Silex\Provider\SwiftmailerServiceProvider(),
array(
'swiftmailer.options' => array(
'host' => isset($platform_email['SMTP_HOST']) ? $platform_email['SMTP_HOST'] : null,
'port' => isset($platform_email['SMTP_PORT']) ? $platform_email['SMTP_PORT'] : null,
'username' => isset($platform_email['SMTP_USER']) ? $platform_email['SMTP_USER'] : null,
'password' => isset($platform_email['SMTP_PASS']) ? $platform_email['SMTP_PASS'] : null,
'encryption' => null,
'auth_mode' => null
)
$app->register(new Silex\Provider\SwiftmailerServiceProvider(), array(
'swiftmailer.options' => array(
'host' => isset($platform_email['SMTP_HOST']) ? $platform_email['SMTP_HOST'] : null,
'port' => isset($platform_email['SMTP_PORT']) ? $platform_email['SMTP_PORT'] : null,
'username' => isset($platform_email['SMTP_USER']) ? $platform_email['SMTP_USER'] : null,
'password' => isset($platform_email['SMTP_PASS']) ? $platform_email['SMTP_PASS'] : null,
'encryption' => null,
'auth_mode' => null
)
);
));
//if (isset($platform_email['SMTP_MAILER']) && $platform_email['SMTP_MAILER'] == 'smtp') {
$app['mailer'] = $app->share(
function ($app) {
return new \Swift_Mailer($app['swiftmailer.transport']);
}
);
$app['mailer'] = $app->share(function ($app) {
return new \Swift_Mailer($app['swiftmailer.transport']);
});
// check and modify the date of user in the track.e.online table
// Check and modify the date of user in the track.e.online table
if (!$x = strpos($_SERVER['PHP_SELF'], 'whoisonline.php')) {
LoginCheck(isset($_user['user_id']) ? $_user['user_id'] : '');
}
error_reporting(-1);
if (api_get_setting('server_type') == 'test') {
//error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
} else {
@ -693,194 +673,56 @@ if (api_get_setting('server_type') == 'test') {
// if we use the javascript version (without go button) we receive a get
// if we use the non-javascript version (with the go button) we receive a post
$user_language = '';
if (!empty($_GET['language'])) {
$user_language = $_GET['language'];
}
if (!empty($_POST['language_list'])) {
$user_language = str_replace('index.php?language=', '', $_POST['language_list']);
}
$user_language = api_get_user_language();
// Include all files (first english and then current interface language)
$langpath = api_get_path(SYS_LANG_PATH);
/* This will only work if we are in the page to edit a sub_language */
if (isset($this_script) && $this_script == 'sub_language') {
require_once '../admin/sub_language.class.php';
// getting the arrays of files i.e notification, trad4all, etc
$language_files_to_load = SubLanguageManager:: get_lang_folder_files_list(
api_get_path(SYS_LANG_PATH).'english',
true
);
//getting parent info
$parent_language = SubLanguageManager::get_all_information_of_language($_REQUEST['id']);
//getting sub language info
$sub_language = SubLanguageManager::get_all_information_of_language($_REQUEST['sub_language_id']);
$english_language_array = $parent_language_array = $sub_language_array = array();
foreach ($language_files_to_load as $language_file_item) {
$lang_list_pre = array_keys($GLOBALS);
//loading english
$path = $langpath.'english/'.$language_file_item.'.inc.php';
if (file_exists($path)) {
include $path;
}
$lang_list_post = array_keys($GLOBALS);
$lang_list_result = array_diff($lang_list_post, $lang_list_pre);
unset($lang_list_pre);
// english language array
$english_language_array[$language_file_item] = compact($lang_list_result);
//cleaning the variables
foreach ($lang_list_result as $item) {
unset(${$item});
}
$parent_file = $langpath.$parent_language['dokeos_folder'].'/'.$language_file_item.'.inc.php';
if (file_exists($parent_file) && is_file($parent_file)) {
include_once $parent_file;
}
// parent language array
$parent_language_array[$language_file_item] = compact($lang_list_result);
//cleaning the variables
foreach ($lang_list_result as $item) {
unset(${$item});
}
$sub_file = $langpath.$sub_language['dokeos_folder'].'/'.$language_file_item.'.inc.php';
if (file_exists($sub_file) && is_file($sub_file)) {
include $sub_file;
}
// sub language array
$sub_language_array[$language_file_item] = compact($lang_list_result);
//cleaning the variables
foreach ($lang_list_result as $item) {
unset(${$item});
}
}
}
$app['this_script'] = isset($this_script) ? $this_script : null;
// Checking if we have a valid language. If not we set it to the platform language.
$app['language_interface'] = $language_interface = api_get_language_interface();
$valid_languages = api_get_languages();
if (!empty($valid_languages)) {
if (!in_array($user_language, $valid_languages['folder'])) {
$user_language = api_get_setting('platformLanguage');
}
$language_priority1 = api_get_setting('languagePriority1');
$language_priority2 = api_get_setting('languagePriority2');
$language_priority3 = api_get_setting('languagePriority3');
$language_priority4 = api_get_setting('languagePriority4');
if (in_array(
$user_language,
$valid_languages['folder']
) && (isset($_GET['language']) || isset($_POST['language_list']))
) {
$user_selected_language = $user_language; // $_GET['language'];
$_SESSION['user_language_choice'] = $user_selected_language;
$platformLanguage = $user_selected_language;
}
// Sometimes the variable $language_interface is changed
// temporarily for achieving translation in different language.
// We need to save the genuine value of this variable and
// to use it within the function get_lang(...).
//$language_interface_initial_value = $language_interface;
if (!empty($language_priority4) && api_get_language_from_type($language_priority4) !== false) {
$language_interface = api_get_language_from_type($language_priority4);
} else {
$language_interface = api_get_setting('platformLanguage');
}
//load_translations($app);
if (!empty($language_priority3) && api_get_language_from_type($language_priority3) !== false) {
$language_interface = api_get_language_from_type($language_priority3);
} else {
if (isset($_SESSION['user_language_choice'])) {
$language_interface = $_SESSION['user_language_choice'];
//Filters
$app->before(
function () use ($app) {
if (!file_exists($app['configuration_file'])) {
return new RedirectResponse(api_get_path(WEB_CODE_PATH).'install');
}
}
if (!empty($language_priority2) && api_get_language_from_type($language_priority2) !== false) {
$language_interface = api_get_language_from_type($language_priority2);
} else {
if (isset($_user['language'])) {
$language_interface = $_user['language'];
//Check the PHP version
if (api_check_php_version() == false) {
$app->abort(500, "Incorrect PHP version");
}
}
if (!empty($language_priority1) && api_get_language_from_type($language_priority1) !== false) {
$language_interface = api_get_language_from_type($language_priority1);
} else {
if ($_course['language']) {
$language_interface = $_course['language'];
if (!is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
$app->abort(500, "archive folder must be writeable");
}
//$app['request']->getSession()->start();
}
}
);
// Sometimes the variable $language_interface is changed
// temporarily for achieving translation in different language.
// We need to save the genuine value of this variable and
// to use it within the function get_lang(...).
$language_interface_initial_value = $language_interface;
$app->finish(
function () use ($app) {
//@todo will be removed before a stable release
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
/**
* Include all necessary language files
* - trad4all
* - notification
* - custom tool language files
*/
$language_files = array();
$language_files[] = 'trad4all';
$language_files[] = 'notification';
$language_files[] = 'accessibility';
if (isset($language_file)) {
if (!is_array($language_file)) {
$language_files[] = $language_file;
} else {
$language_files = array_merge($language_files, $language_file);
}
}
// if a set of language files has been properly defined
if (is_array($language_files)) {
// if the sub-language feature is on
if (api_get_setting('allow_use_sub_language') == 'true') {
require_once api_get_path(SYS_CODE_PATH).'admin/sub_language.class.php';
$parent_path = SubLanguageManager::get_parent_language_path($language_interface);
foreach ($language_files as $index => $language_file) {
// include English
include $langpath.'english/'.$language_file.'.inc.php';
// prepare string for current language and its parent
$lang_file = $langpath.$language_interface.'/'.$language_file.'.inc.php';
$parent_lang_file = $langpath.$parent_path.'/'.$language_file.'.inc.php';
// load the parent language file first
if (file_exists($parent_lang_file)) {
include $parent_lang_file;
}
// overwrite the parent language translations if there is a child
if (file_exists($lang_file)) {
include $lang_file;
}
}
} else {
// if the sub-languages feature is not on, then just load the
// set language interface
foreach ($language_files as $index => $language_file) {
// include English
include $langpath.'english/'.$language_file.'.inc.php';
// prepare string for current language
$langfile = $langpath.$language_interface.'/'.$language_file.'.inc.php';
if (file_exists($langfile)) {
include $langfile;
}
}
$message = "Page loaded in:".($mtime - START);
$app['monolog']->addInfo($message);
$message = "memory_get_usage: ".format_file_size(memory_get_usage(true));
$app['monolog']->addInfo($message);
$message = "memory_get_peak_usage: ".format_file_size(memory_get_peak_usage(true));
$app['monolog']->addInfo($message);
}
}
);
// The global variable $charset has been defined in a language file too (trad4all.inc.php), this is legacy situation.
// So, we have to reassign this variable again in order to keep its value right.
@ -977,11 +819,19 @@ $app['posts.controller'] = $app->share(function() use ($app) {
});
$app->mount('/', "posts.controller");*/
//All old stuff
$app->get('/', 'index.controller:classicAction');
$app->post('/', 'index.controller:classicAction');
//index.php
$app->get('/', 'index.controller:indexAction');
$app->get('/index', 'index.controller:indexAction')->bind('index');
//user_portal.php
$app->get('/userportal', 'userportal.controller:indexAction');
//Logout
$app->get('/logout', 'index.controller:logoutAction');
//LP controller
$app->get('/learnpath/subscribe_users/{id}', 'learnpath.controller:indexAction')->bind('subscribe_users');
$app->post('/learnpath/subscribe_users/{id}', 'learnpath.controller:indexAction')->bind('subscribe_users');

@ -33,17 +33,24 @@ class Display
*/
public static function display_header($tool_name = '', $help = null, $page_header = null)
{
global $app;
$app['classic_layout'] = true;
/*
self::$global_template = new Template($tool_name);
self::$global_template->set_help($help);
if (!empty(self::$preview_style)) {
self::$global_template->preview_theme = self::$preview_style;
self::$global_template->set_css_files();
self::$global_template->set_js_files();
}*/
if ($app['allowed'] == true) {
ob_start(array($app['template'], 'manage_display'));
} else {
$app->run();
exit;
}
if (!empty($page_header)) {
self::$global_template->assign('header', $page_header);
}
echo self::$global_template->show_header_template();
}
/**
@ -51,6 +58,7 @@ class Display
*/
public static function display_reduced_header()
{
$app['classic_layout'] = true;
global $show_learnpath, $tool_name, $app;
$app['template.show_header'] = false;
$app['template.show_footer'] = false;
@ -61,6 +69,7 @@ class Display
public static function display_no_header()
{
$app['classic_layout'] = true;
global $tool_name, $app, $show_learnpath;
$disable_js_and_css_files = true;
$app['template.show_header'] = false;
@ -86,7 +95,12 @@ class Display
*/
public static function display_footer()
{
echo self::$global_template->show_footer_template();
global $app;
$out = ob_get_contents();
ob_end_clean();
$app['template']->assign('content', $out);
$app->run();
//echo self::$global_template->show_footer_template();
}
public static function page()

@ -73,7 +73,6 @@ function event_open()
*/
function event_login()
{
global $_user;
global $TABLETRACK_LOGIN;
@ -85,11 +84,11 @@ function event_login()
'".$reallyNow."'
)";
Database::query($sql);
// auto subscribe
$user_status = $_user['status'];
$user_status = $_user['status'] == SESSIONADMIN ? 'sessionadmin' :
$_user['status'] == COURSEMANAGER ? 'teacher' :
$_user['status'] == DRH ? 'DRH' : 'student';
$_user['status'] == COURSEMANAGER ? 'teacher' :
$_user['status'] == DRH ? 'DRH' : 'student';
$autoSubscribe = api_get_setting($user_status.'_autosubscribe');
if ($autoSubscribe) {
$autoSubscribe = explode('|', $autoSubscribe);

@ -125,16 +125,23 @@ $_api_is_translated_call = false;
*/
function get_lang($variable, $reserved = null, $language = null)
{
global $app;
$translated = $app['translator']->trans($variable);
if ($translated == $variable) {
$translated = $app['translator']->trans("lang$variable");
}
return $translated;
$language_interface = api_get_language_interface();
global
// For serving some old hacks:
// By manipulating this global variable the translation may be done in different languages too (not the elegant way).
$language_interface,
//$language_interface,
// Because of possibility for manipulations of the global variable $language_interface, we need its initial value.
$language_interface_initial_value,
// For serving the function is_translated()
$_api_is_translated, $_api_is_translated_call;
$_api_is_translated, $_api_is_translated_call, $used_lang_vars, $_configuration;
global $used_lang_vars, $_configuration;
// add language_measure_frequency to your main/inc/conf/configuration.php in order to generate language
// variables frequency measurements (you can then see them trhough main/cron/lang/langstats.php)
// The $langstats object is instanciated at the end of main/inc/global.inc.php
@ -153,7 +160,8 @@ function get_lang($variable, $reserved = null, $language = null)
$encoding = api_get_system_encoding();
$is_utf8_encoding = api_is_utf8($encoding);
$langpath = api_get_path(SYS_LANG_PATH);
$test_server_mode = api_get_setting('server_type') == 'test';
//$test_server_mode = api_get_setting('server_type') == 'test';
$test_server_mode = false;
$show_special_markup = api_get_setting('hide_dltt_markup') != 'true' || $test_server_mode;
$initialized = true;
}
@ -186,8 +194,10 @@ function get_lang($variable, $reserved = null, $language = null)
$read_global_variables = $is_interface_language && !$test_server_mode && !$_api_is_translated_call;
// Reloading the language files when it is necessary.
if (!$read_global_variables) {
/*if (!$read_global_variables) {
global $language_files;
var_dump($language_files);exit;
if (isset($language_files)) {
$parent_language = null;
if (api_get_setting('allow_use_sub_language') == 'true') {
@ -209,9 +219,10 @@ function get_lang($variable, $reserved = null, $language = null)
}
}
}
*/
// Translation mode for production servers.
if (!$test_server_mode) {
if (!$test_server_mode) { $read_global_variables = false;
if ($read_global_variables) {
if (isset($GLOBALS[$variable])) {
$langvar = $GLOBALS[$variable];
@ -430,7 +441,6 @@ function api_get_platform_isocodes()
);
if (Database::num_rows($sql_result)) {
while ($row = Database::fetch_array($sql_result)) {
;
$iso_code[] = trim($row['isocode']);
}
}

@ -220,6 +220,7 @@ define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path
// Constants for api_get_path() and api_get_path_type(), etc. - registered path types.
define('WEB_PATH', 'WEB_PATH');
define('WEB_PUBLIC_PATH', 'WEB_PUBLIC_PATH');
define('SYS_PATH', 'SYS_PATH');
define('REL_PATH', 'REL_PATH');
define('WEB_SERVER_ROOT_PATH', 'WEB_SERVER_ROOT_PATH');
@ -588,6 +589,7 @@ function api_get_path($path_type, $path = null) {
// Initialization of a table taht contains common-purpose paths.
$paths[WEB_PATH] = $root_web;
$paths[WEB_PUBLIC_PATH] = $root_web."web/";
$paths[SYS_PATH] = $root_sys;
$paths[REL_PATH] = $root_rel;
$paths[WEB_SERVER_ROOT_PATH] = $server_base_web.'/';
@ -959,7 +961,7 @@ function api_protect_course_script($print_headers = false, $allow_session_admins
$is_visible = true;
break;
}
//If pasword is set and user is not registered to the course then the course is not visible
//If password is set and user is not registered to the course then the course is not visible
if ($is_allowed_in_course == false & isset($course_info['registration_code']) && !empty($course_info['registration_code'])) {
$is_visible = false;
}
@ -3009,7 +3011,7 @@ function api_not_allowed($print_headers = false, $message = null) {
$osso->logout();
}
}
Header::response_code(403);
$home_url = api_get_path(WEB_PATH);
$user_id = api_get_user_id();
$course = api_get_course_id();
@ -3045,15 +3047,19 @@ function api_not_allowed($print_headers = false, $message = null) {
$app['template.show_header'] = $show_headers;
$app['template.show_footer'] = $show_headers;
$tpl = new Template();
$tpl->assign('content', $msg);
// $tpl = new Template();
//$tpl->assign('content', $msg);
$app['template']->assign('content', $msg);
$app['allowed'] = true;
if (($user_id!=0 && !api_is_anonymous()) && (!isset($course) || $course == -1) && empty($_GET['cidReq'])) {
// if the access is not authorized and there is some login information
// but the cidReq is not found, assume we are missing course data and send the user
// to the user_portal
$tpl->display_one_col_template();
exit;
//$tpl->display_one_col_template();
//$app->abort('403');
$app['allowed'] = false;
return false;
}
if (!empty($_SERVER['REQUEST_URI']) && (!empty($_GET['cidReq']) || $this_section == SECTION_MYPROFILE)) {
@ -3061,9 +3067,10 @@ function api_not_allowed($print_headers = false, $message = null) {
//only display form and return to the previous URL if there was a course ID included
if ($user_id != 0 && !api_is_anonymous()) {
//if there is a user ID, then the user is not allowed but the session is still there. Say so and exit
$tpl->assign('content', $msg);
$tpl->display_one_col_template();
exit;
//$tpl->assign('content', $msg);
$app['template']->assign('content', $msg);
$app['allowed'] = false;
return false;
}
// If the user has no user ID, then his session has expired
@ -3085,14 +3092,15 @@ function api_not_allowed($print_headers = false, $message = null) {
$content .= $form->return_form();
$content .='</div>';
$tpl->assign('content', $content);
$tpl->display_one_col_template();
exit;
$app['template']->assign('content', $content);
$app['allowed'] = false;
return false;
//$app->abort(403);
}
if ($user_id !=0 && !api_is_anonymous()) {
$tpl->display_one_col_template();
exit;
$app['allowed'] = false;
return false;
}
$msg = null;
// Check if the cookies are enabled. If are enabled and if no course ID was included in the requested URL, then the user has either lost his session or is anonymous, so redirect to homepage
@ -3102,9 +3110,9 @@ function api_not_allowed($print_headers = false, $message = null) {
$msg = Display::return_message(get_lang('NotAllowed').'<br /><br /><a href="'.$home_url.'">'.get_lang('PleaseLoginAgainFromHomepage').'</a><br />', 'error', false);
}
$msg = Display::div($msg, array('align'=>'center'));
$tpl->assign('content', $msg);
$tpl->display_one_col_template();
exit;
$app['template']->assign('content', $msg);
$app['allowed'] = false;
return false;
}
@ -3623,7 +3631,7 @@ function api_get_language_from_type($lang_type){
$toreturn = ($_SESSION['user_language_choice']);
break;
case 'course_lang' :
if ($_course['language'] && !empty($_course['language']) )
if (isset($_course['language']) && !empty($_course['language']) )
$toreturn = $_course['language'];
break;
default :
@ -6814,4 +6822,204 @@ function api_mail_html($recipient_name, $recipient_email, $subject, $body, $send
$mail->ClearAddresses();
return 1;
}
function api_get_user_language() {
$user_language = null;
if (!empty($_GET['language'])) {
$user_language = $_GET['language'];
}
if (!empty($_POST['language_list'])) {
$user_language = str_replace('index.php?language=', '', $_POST['language_list']);
}
return $user_language;
}
function api_get_language_interface() {
$valid_languages = api_get_languages();
$user_language = api_get_user_language();
$_course = api_get_course_info();
if (!empty($valid_languages)) {
if (!in_array($user_language, $valid_languages['folder'])) {
$user_language = api_get_setting('platformLanguage');
}
$language_priority1 = api_get_setting('languagePriority1');
$language_priority2 = api_get_setting('languagePriority2');
$language_priority3 = api_get_setting('languagePriority3');
$language_priority4 = api_get_setting('languagePriority4');
if (in_array(
$user_language,
$valid_languages['folder']
) && (isset($_GET['language']) || isset($_POST['language_list']))
) {
$user_selected_language = $user_language;
$_SESSION['user_language_choice'] = $user_selected_language;
$platformLanguage = $user_selected_language;
}
if (!empty($language_priority4) && api_get_language_from_type($language_priority4) !== false) {
$language_interface = api_get_language_from_type($language_priority4);
} else {
$language_interface = api_get_setting('platformLanguage');
}
if (!empty($language_priority3) && api_get_language_from_type($language_priority3) !== false) {
$language_interface = api_get_language_from_type($language_priority3);
} else {
if (isset($_SESSION['user_language_choice'])) {
$language_interface = $_SESSION['user_language_choice'];
}
}
if (!empty($language_priority2) && api_get_language_from_type($language_priority2) !== false) {
$language_interface = api_get_language_from_type($language_priority2);
} else {
if (isset($_user['language'])) {
$language_interface = $_user['language'];
}
}
if (!empty($language_priority1) && api_get_language_from_type($language_priority1) !== false) {
$language_interface = api_get_language_from_type($language_priority1);
} else {
if (isset($_course['language']) && !empty($_course['language'])) {
$language_interface = $_course['language'];
}
}
}
return $language_interface;
}
function load_translations($app) {
$langPath = api_get_path(SYS_LANG_PATH);
$this_script = $app['this_script'];
$language_interface = $app['language_interface'];
/* This will only work if we are in the page to edit a sub_language */
if (isset($this_script) && $this_script == 'sub_language') {
require_once api_get_path(SYS_CODE_PATH).'admin/sub_language.class.php';
// getting the arrays of files i.e notification, trad4all, etc
$language_files_to_load = SubLanguageManager:: get_lang_folder_files_list(
api_get_path(SYS_LANG_PATH).'english',
true
);
//getting parent info
$parent_language = SubLanguageManager::get_all_information_of_language($_REQUEST['id']);
//getting sub language info
$sub_language = SubLanguageManager::get_all_information_of_language($_REQUEST['sub_language_id']);
$english_language_array = $parent_language_array = $sub_language_array = array();
foreach ($language_files_to_load as $language_file_item) {
$lang_list_pre = array_keys($GLOBALS);
//loading english
$path = $langPath.'english/'.$language_file_item.'.inc.php';
if (file_exists($path)) {
include $path;
}
$lang_list_post = array_keys($GLOBALS);
$lang_list_result = array_diff($lang_list_post, $lang_list_pre);
unset($lang_list_pre);
// english language array
$english_language_array[$language_file_item] = compact($lang_list_result);
//cleaning the variables
foreach ($lang_list_result as $item) {
unset(${$item});
}
$parent_file = $langPath.$parent_language['dokeos_folder'].'/'.$language_file_item.'.inc.php';
if (file_exists($parent_file) && is_file($parent_file)) {
include_once $parent_file;
}
// parent language array
$parent_language_array[$language_file_item] = compact($lang_list_result);
//cleaning the variables
foreach ($lang_list_result as $item) {
unset(${$item});
}
$sub_file = $langPath.$sub_language['dokeos_folder'].'/'.$language_file_item.'.inc.php';
if (file_exists($sub_file) && is_file($sub_file)) {
include $sub_file;
}
// sub language array
$sub_language_array[$language_file_item] = compact($lang_list_result);
//cleaning the variables
foreach ($lang_list_result as $item) {
unset(${$item});
}
}
}
/**
* Include all necessary language files
* - trad4all
* - notification
* - custom tool language files
*/
$language_files = array();
$language_files[] = 'trad4all';
$language_files[] = 'notification';
$language_files[] = 'accessibility';
if (isset($language_file)) {
if (!is_array($language_file)) {
$language_files[] = $language_file;
} else {
$language_files = array_merge($language_files, $language_file);
}
}
if (isset($app['languages_file'])) {
$language_files = array_merge($language_files, $this->app['languages_file']);
}
// if a set of language files has been properly defined
if (is_array($language_files)) {
// if the sub-language feature is on
if (api_get_setting('allow_use_sub_language') == 'true') {
require_once api_get_path(SYS_CODE_PATH).'admin/sub_language.class.php';
$parent_path = SubLanguageManager::get_parent_language_path($language_interface);
foreach ($language_files as $index => $language_file) {
// include English
include $langPath.'english/'.$language_file.'.inc.php';
// prepare string for current language and its parent
$lang_file = $langPath.$language_interface.'/'.$language_file.'.inc.php';
$parent_lang_file = $langPath.$parent_path.'/'.$language_file.'.inc.php';
// load the parent language file first
if (file_exists($parent_lang_file)) {
include $parent_lang_file;
}
// overwrite the parent language translations if there is a child
if (file_exists($lang_file)) {
include $lang_file;
}
}
} else {
// if the sub-languages feature is not on, then just load the
// set language interface
foreach ($language_files as $index => $language_file) {
// include English
include $langPath.'english/'.$language_file.'.inc.php';
// prepare string for current language
$langFile = $langPath.$language_interface.'/'.$language_file.'.inc.php';
if (file_exists($langFile)) {
include $langFile;
}
}
}
}
}

@ -39,9 +39,9 @@ class PageController
if (api_get_setting('allow_social_tool') == 'true') {
if (!$no_image) {
$profile_content .='<a style="text-align:center" href="'.api_get_path(WEB_PATH).'main/social/home.php"><img src="'.$img_array['file'].'" '.$img_array['style'].' ></a>';
$profile_content .='<a style="text-align:center" href="'.api_get_path(WEB_CODE_PATH).'social/home.php"><img src="'.$img_array['file'].'" '.$img_array['style'].' ></a>';
} else {
$profile_content .='<a style="text-align:center" href="'.api_get_path(WEB_PATH).'main/auth/profile.php"><img title="'.get_lang('EditProfile').'" src="'.$img_array['file'].'" '.$img_array['style'].'></a>';
$profile_content .='<a style="text-align:center" href="'.api_get_path(WEB_CODE_PATH).'auth/profile.php"><img title="'.get_lang('EditProfile').'" src="'.$img_array['file'].'" '.$img_array['style'].'></a>';
}
}
self::show_right_block(null, null, 'user_image_block', array('content' => $profile_content));
@ -80,25 +80,39 @@ class PageController
$my_account_content = array();
if ($show_create_link) {
$my_account_content[] = array('href' => 'main/create_course/add_course.php', 'title' => api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate'));
$my_account_content[] = array(
'href' => api_get_path(WEB_CODE_PATH).'create_course/add_course.php',
'title' => api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate'));
}
//Sort courses
$url = api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses';
$my_account_content[] = array('href' => $url, 'title' => get_lang('SortMyCourses'));
$my_account_content[] = array(
'href' => $url,
'title' => get_lang('SortMyCourses')
);
//Course management
if ($show_course_link) {
if (!api_is_drh()) {
$my_account_content[] = array('href' => 'main/auth/courses.php', 'title' => get_lang('CourseCatalog'));
$my_account_content[] = array('href' => api_get_path(WEB_CODE_PATH).'auth/courses.php', 'title' => get_lang('CourseCatalog'));
if (isset($_GET['history']) && intval($_GET['history']) == 1) {
$my_account_content [] = array('href' => 'user_portal.php', 'title' => get_lang('DisplayTrainingList'));
$my_account_content [] = array(
'href' => 'user_portal.php',
'title' => get_lang('DisplayTrainingList')
);
} else {
$my_account_content [] = array('href' => 'user_portal.php?history=1', 'title' => get_lang('HistoryTrainingSessions'));
$my_account_content [] = array(
'href' => 'user_portal.php?history=1',
'title' => get_lang('HistoryTrainingSessions')
);
}
} else {
$my_account_content .= array('href' => 'main/dashboard/index.php', 'title' => get_lang('Dashboard'));
$my_account_content .= array(
'href' => api_get_path(WEB_CODE_PATH).'dashboard/index.php',
'title' => get_lang('Dashboard')
);
}
}
self::show_right_block(get_lang('Courses'), $my_account_content, 'course_block');
@ -111,6 +125,7 @@ class PageController
* @assert () != ''
*/
static function return_profile_block() {
global $app;
// @todo Add a platform setting to add the user image.
if (api_get_setting('allow_message_tool') == 'true') {
if (api_get_setting('allow_social_tool') == 'true') {
@ -464,14 +479,15 @@ class PageController
$elements = array();
if ($show_menu) {
if ($show_create_link) {
$elements[] = array('href' => 'main/create_course/add_course.php', 'title' => (api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')));
$elements[] = array('href' => api_get_path(WEB_CODE_PATH).'create_course/add_course.php',
'title' => (api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')));
}
if ($show_course_link) {
if (!api_is_drh() && !api_is_session_admin()) {
$elements[] = array('href' => 'main/auth/courses.php', 'title' => get_lang('CourseCatalog'));
$elements[] = array('href' => api_get_path(WEB_CODE_PATH).'auth/courses.php', 'title' => get_lang('CourseCatalog'));
} else {
$elements[] = array('href' => 'main/dashboard/index.php', 'title' => get_lang('Dashboard'));
$elements[] = array('href' => api_get_path(WEB_CODE_PATH).'dashboard/index.php', 'title' => get_lang('Dashboard'));
}
}
}

@ -27,19 +27,24 @@ class Template
public $load_plugins = false; /* Loads chamilo plugins */
public $force_plugin_load = true;
public $app;
public $navigation_array;
function __construct($title = null, $app = null)
{
if (empty($app)) {
global $app;
$this->app = $app;
$this->app = &$app;
} else {
//ugly fix just for now
$this->app = $app;
$this->app = &$app;
}
$this->app['template_style'] = 'default';
$this->app['default_layout'] = 'layout_1_col.tpl';
$this->app['classic_layout'] = true;
$this->navigation_array = $this->return_navigation_array();
// $this->app['template_style'] = 'default';
// $this->app['default_layout'] = $this->app['template_style'].'/layout/layout_1_col.tpl';
$show_header = $app['template.show_header'];
$show_footer = $app['template.show_footer'];
@ -133,7 +138,10 @@ class Template
return $result;
}
function set_help($help_input = null)
/**
* @param string $help_input
*/
public function set_help($help_input = null)
{
if (!empty($help_input)) {
$help = $help_input;
@ -146,9 +154,7 @@ class Template
if (!empty($help)) {
$help = Security::remove_XSS($help);
$help_content = '<li class="help">';
$help_content .= '<a href="'.api_get_path(
WEB_CODE_PATH
).'help/help.php?open='.$help.'&height=400&width=600" class="ajax" title="'.get_lang('Help').'">';
$help_content .= '<a href="'.api_get_path(WEB_CODE_PATH).'help/help.php?open='.$help.'&height=400&width=600" class="ajax" title="'.get_lang('Help').'">';
$help_content .= '<img src="'.api_get_path(WEB_IMG_PATH).'help.large.png" alt="'.get_lang(
'Help'
).'" title="'.get_lang('Help').'" />';
@ -467,7 +473,13 @@ class Template
$extra_headers = null;
if (isset($htmlHeadXtra) && $htmlHeadXtra) {
foreach ($htmlHeadXtra as & $this_html_head) {
foreach ($htmlHeadXtra as $this_html_head) {
$extra_headers .= $this_html_head."\n";
}
}
if (isset($this->app['extraJS'])) {
foreach ($this->app['extraJS'] as $this_html_head) {
$extra_headers .= $this_html_head."\n";
}
}
@ -478,11 +490,15 @@ class Template
/**
* Set header parameters
*/
private function set_header_parameters()
{
global $httpHeadXtra, $_course, $interbreadcrumb, $language_file, $_configuration, $this_section;
private function set_header_parameters() {
global $interbreadcrumb;
$_course = api_get_course_info();
$_configuration = $this->app['configuration'];
$this_section = $this->app['this_section'];
$nameTools = $this->title;
$navigation = $this->return_navigation_array();
$navigation = $this->navigation_array;
$this->menu_navigation = $navigation['menu_navigation'];
@ -494,7 +510,7 @@ class Template
// Get language iso-code for this page - ignore errors
$this->assign('document_language', api_get_language_isocode());
$course_title = $_course['name'];
$course_title = isset($_course['name']) ? $_course['name'] : null;
$title_list = array();
@ -568,9 +584,7 @@ class Template
if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) {
$bug_notification_link = '<li class="report">
<a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank">
<img src="'.api_get_path(
WEB_IMG_PATH
).'bug.large.png" style="vertical-align: middle;" alt="'.get_lang('ReportABug').'" title="'.get_lang(
<img src="'.api_get_path(WEB_IMG_PATH).'bug.large.png" style="vertical-align: middle;" alt="'.get_lang('ReportABug').'" title="'.get_lang(
'ReportABug'
).'"/></a>
</li>';
@ -583,7 +597,7 @@ class Template
//Preparing values for the menu
//Logout link
$this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id());
$this->assign('logout_link', api_get_path(WEB_PUBLIC_PATH).'logout');
//Profile link
if (api_get_setting('allow_social_tool') == 'true') {
@ -611,7 +625,7 @@ class Template
$this->assign('menu', $menu);
//Breadcrumb
$breadcrumb = $this->return_breadcrumb($interbreadcrumb, $language_file, $nameTools);
$breadcrumb = $this->return_breadcrumb($interbreadcrumb, $nameTools);
$this->assign('breadcrumb', $breadcrumb);
//Extra content
@ -698,8 +712,6 @@ class Template
$this->assign('teachers', $teacher_data);
}
}
/* $stats = '';
$this->assign('execution_stats', $stats); */
}
function show_header_template()
@ -714,6 +726,11 @@ class Template
$this->display($tpl);
}
function manage_display($content)
{
//$this->assign('content', $content);
}
/* Sets the plugin content in a template variable */
function set_plugin_region($plugin_region)
{
@ -739,9 +756,12 @@ class Template
$this->app['twig']->addGlobal($key, $value);
}
public function display($template)
public function display($template = null)
{
echo $this->app['twig']->render($template);
if (!empty($template)) {
$this->app['default_layout'] = $template;
}
$this->app->run();
}
function show_page_loaded_info()
@ -758,7 +778,7 @@ class Template
function return_menu()
{
$navigation = $this->return_navigation_array();
$navigation = $this->navigation_array;
$navigation = $navigation['navigation'];
// Displaying the tabs
@ -905,7 +925,6 @@ class Template
$navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
$navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
// My Courses
if (api_is_allowed_to_create_course()) {
@ -919,9 +938,7 @@ class Template
}
// My Profile
$navigation['myprofile']['url'] = api_get_path(
WEB_CODE_PATH
).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '');
$navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '');
$navigation['myprofile']['title'] = get_lang('ModifyProfile');
// Link to my agenda
@ -1050,7 +1067,6 @@ class Template
function return_notification_menu()
{
$_course = api_get_course_info();
$course_id = api_get_course_id();
$user_id = api_get_user_id();
@ -1141,7 +1157,6 @@ class Template
function return_navigation_array()
{
$navigation = array();
$menu_navigation = array();
$possible_tabs = $this->get_tabs();
@ -1263,9 +1278,10 @@ class Template
return $return;
}
function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
{
function return_breadcrumb($interbreadcrumb)
{
$session_id = api_get_session_id();
$session_name = api_get_session_name($session_id);
$_course = api_get_course_info();
@ -1373,11 +1389,12 @@ class Template
// part 3: The tool itself. If we are on the course homepage we do not want to display the title of the course because this
// is the same as the first part of the breadcrumbs (see part 1)
/*
if (isset($nameTools) && $language_file != 'course_home') { // TODO: This condition $language_file != 'course_home' might bring surprises.
$navigation_item['url'] = '#';
$navigation_item['title'] = $nameTools;
$navigation[] = $navigation_item;
}
}*/
$final_navigation = array();
$counter = 0;

@ -320,7 +320,7 @@ class UserManager {
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
if ($_configuration['multiple_access_urls']) {
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$url = api_get_access_url($access_url_id);
@ -1516,7 +1516,7 @@ class UserManager {
case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
$sqluo = "SELECT * FROM $t_ufo WHERE field_id = ".$rowuf['id'];
$resuo = Database::query($sqluo);
$values = split(';',$fvalues);
$values = explode(';',$fvalues);
if (Database::num_rows($resuo) > 0) {
$check = false;
while ($rowuo = Database::fetch_array($resuo)) {

@ -67,15 +67,18 @@ if (!array_key_exists($install_language, get_language_folder_list())) {
require api_get_path(SYS_LANG_PATH).'english/trad4all.inc.php';
require api_get_path(SYS_LANG_PATH).'english/admin.inc.php';
require api_get_path(SYS_LANG_PATH).'english/install.inc.php';
if ($install_language != 'english') {
include_once api_get_path(SYS_LANG_PATH).$install_language.'/trad4all.inc.php';
include_once api_get_path(SYS_LANG_PATH).$install_language.'/install.inc.php';
include_once api_get_path(SYS_LANG_PATH).$install_language.'/admin.inc.php';
}
// These global variables must be set for proper working of the function get_lang(...) during the installation.
$language_interface = $install_language;
$language_interface_initial_value = $install_language;
///$language_interface_initial_value = $install_language;
// Character set during the installation, it is always to be 'UTF-8'.
$charset = 'UTF-8';

@ -5,7 +5,7 @@ use Symfony\Component\HttpFoundation\Response;
require_once '../inc/global.inc.php';
class SubscribeUserToLP {
class LearnpathController {
function indexAction(Application $app) {
$request = $app['request'];
@ -16,7 +16,6 @@ class SubscribeUserToLP {
if (empty($lpId)) {
var_dump($lpId);
//return $app->redirect('lp_controller.php');
}
$course = $app['orm.em']->getRepository('Entity\EntityCourse')->find(api_get_course_int_id());

@ -116,8 +116,6 @@ $stok = Security::get_token();
}
}
}
}
}
}

@ -1,7 +1,5 @@
{% extends 'default/layout/layout_1_col.tpl' %}
{% block content %}
{{ error_code }}
{{ error_message }}
{{ error_code }} - {{ error_message }}
{{ content }}
{% endblock %}

@ -11,23 +11,69 @@ use Symfony\Component\HttpFoundation\Response;
*/
class IndexController
{
public $section;
/**
* Handles default Chamilo scripts handled by Display::display_header() and display_footer()
*
* @param \Silex\Application $app
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response|void
*/
public function classicAction(Application $app)
{
//User is not allowed
if ($app['allowed'] == false) {
return $app->abort(403);
}
//Rendering page
$response = $app['twig']->render($app['default_layout']);
//Classic style
if ($app['classic_layout'] == true) {
//assign('content', already done in display::display_header() and display_footer()
} else {
return $app->redirect('index');
}
return new Response($response, 200, array());
}
function logoutAction(Application $app) {
$this->logout();
return $app->redirect($app['url_generator']->generator('index'));
}
/**
* @param \Silex\Application $app
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function indexAction(Application $app)
{
$extraJS = array();
$extraJS[] = api_get_jquery_libraries_js(array('bxslider'));
$extraJS[] = '<script>
$(document).ready(function(){
$("#slider").bxSlider({
infiniteLoop : true,
auto : true,
pager : true,
autoHover : true,
pause : 10000
});
});
</script>';
$app['this_section'] = SECTION_CAMPUS;
$app['extraJS'] = $extraJS;
$request = $app['request'];
$app['languages_file'] = array('courses', 'index', 'admin');
$app['cidReset'] = true;
//$token = $app['security']->getToken();
//echo $app['translator']->trans('Wiki Search Results');
//echo $app['translator']->trans('Profile');
//Actions
$logout = $request->get('logout');
if (!empty($logout)) {
$this->logout();
$app->redirect($app['url_generator']->generator('index'));
}
//$token = $app['security']->getToken();
//$article = $app['orm.em']->getRepository('Entity\EntityCourse');
//$courses_query = $app['orm.em']->createQuery('SELECT a FROM Entity\EntityCourse a');
@ -53,12 +99,12 @@ class IndexController
}
//If we are not logged in and customapages activated
if (!api_get_user_id() && CustomPages::enabled()) {
$logged_out = $request->get('loggedout');
if ($logged_out) {
CustomPages::display(CustomPages::LOGGED_OUT);
if (!api_get_user_id() && \CustomPages::enabled()) {
$loggedOut = $request->get('loggedout');
if ($loggedOut) {
\CustomPages::display(\CustomPages::LOGGED_OUT);
} else {
CustomPages::display(CustomPages::INDEX_UNLOGGED);
\CustomPages::display(\CustomPages::INDEX_UNLOGGED);
}
}
@ -87,28 +133,28 @@ class IndexController
}
//Hot courses & announcements
$hot_courses = null;
$announcements_block = null;
$hotCourses = null;
$announcementsBlock = null;
// When loading a chamilo page do not include the hot courses and news
if (!isset($_REQUEST['include'])) {
if (api_get_setting('show_hot_courses') == 'true') {
$hot_courses = \PageController::return_hot_courses();
$hotCourses = \PageController::return_hot_courses();
}
$announcements_block = \PageController::return_announcements();
$announcementsBlock = \PageController::return_announcements();
}
$app['template']->assign('hot_courses', $hot_courses);
$app['template']->assign('announcements_block', $announcements_block);
$app['template']->assign('hot_courses', $hotCourses);
$app['template']->assign('announcements_block', $announcementsBlock);
//Homepage
$app['template']->assign('home_page_block', \PageController::return_home_page());
//Navigation links
$nav_links = $app['template']->return_navigation_links();
$navLinks = $app['template']->return_navigation_links();
$app['template']->assign('navigation_course_links', $nav_links);
$app['template']->assign('main_navigation_block', $nav_links);
$app['template']->assign('navigation_course_links', $navLinks);
$app['template']->assign('main_navigation_block', $navLinks);
\PageController::return_notice();
\PageController::return_help();
@ -163,42 +209,44 @@ class IndexController
}
/**
* @param Silex\Application $app
* @param \Silex\Application $app
*/
function set_login_form(Application $app)
{
$user_id = api_get_user_id();
$login_form = null;
if (!$user_id || api_is_anonymous($user_id)) {
$userId = api_get_user_id();
$loginForm = null;
if (!$userId || api_is_anonymous($userId)) {
// Only display if the user isn't logged in.
$app['template']->assign('login_language_form', api_display_language_form(true));
//self::display_login_form($app);
$app['template']->assign('login_form', self::display_login_form($app));
if (api_get_setting('allow_lostpassword') == 'true' || api_get_setting('allow_registration') == 'true') {
$login_form .= '<ul class="nav nav-list">';
$loginForm .= '<ul class="nav nav-list">';
if (api_get_setting('allow_registration') != 'false') {
$login_form .= '<li><a href="main/auth/inscription.php">'.get_lang('Reg').'</a></li>';
$loginForm .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'auth/inscription.php">'.get_lang('Reg').'</a></li>';
}
if (api_get_setting('allow_lostpassword') == 'true') {
$login_form .= '<li><a href="main/auth/lostPassword.php">'.get_lang('LostPassword').'</a></li>';
$loginForm .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'auth/lostPassword.php">'.get_lang('LostPassword').'</a></li>';
}
$login_form .= '</ul>';
$loginForm .= '</ul>';
}
$app['template']->assign('login_options', $login_form);
$app['template']->assign('login_options', $loginForm);
}
}
/**
*
*/
function logout()
{
$user_id = api_get_user_id();
online_logout($user_id, true);
$userId = api_get_user_id();
online_logout($userId, true);
}
/**
* @param \Silex\Application $app
*
* @return string
*/
function display_login_form(Application $app)

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInitb9f8cc78eb61aedad036fc9290633b9f::getLoader();
return ComposerAutoloaderInitcdfd4dba8f133654da821bebfcae84b3::getLoader();

@ -2,7 +2,7 @@
// autoload_real.php generated by Composer
class ComposerAutoloaderInitb9f8cc78eb61aedad036fc9290633b9f
class ComposerAutoloaderInitcdfd4dba8f133654da821bebfcae84b3
{
private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInitb9f8cc78eb61aedad036fc9290633b9f
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitb9f8cc78eb61aedad036fc9290633b9f', 'loadClassLoader'));
spl_autoload_register(array('ComposerAutoloaderInitcdfd4dba8f133654da821bebfcae84b3', 'loadClassLoader'));
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitb9f8cc78eb61aedad036fc9290633b9f', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitcdfd4dba8f133654da821bebfcae84b3', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

Loading…
Cancel
Save