diff --git a/composer.json b/composer.json index 96a9922e58..7ccf7b82fd 100755 --- a/composer.json +++ b/composer.json @@ -44,7 +44,10 @@ "gedmo/doctrine-extensions": "2.3.*@dev", "symfony/web-profiler-bundle": "~2.2", "silex/web-profiler": "~1.0", - "chamilo/chash": "dev-master" + "chamilo/chash": "dev-master", + "igorw/config-service-provider": "1.0.*@dev", + "mpdf/mpdf": "dev-master" + }, "minimum-stability": "stable" } diff --git a/composer.lock b/composer.lock index ece5c91272..9871aa03f6 100755 --- a/composer.lock +++ b/composer.lock @@ -1,5 +1,5 @@ { - "hash": "efbe12c9388019d3ee06546522f55045", + "hash": "30986d7996f2fbec69104a2c373ca2e7", "packages": [ { "name": "chamilo/chash", @@ -7,12 +7,12 @@ "source": { "type": "git", "url": "https://github.com/chamilo/chash.git", - "reference": "9f95bd09119a7e696da383611693285aed1ef65a" + "reference": "3d31e9577df292fb2ee010b6182ca7dd543b2c67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chamilo/chash/zipball/9f95bd09119a7e696da383611693285aed1ef65a", - "reference": "9f95bd09119a7e696da383611693285aed1ef65a", + "url": "https://api.github.com/repos/chamilo/chash/zipball/3d31e9577df292fb2ee010b6182ca7dd543b2c67", + "reference": "3d31e9577df292fb2ee010b6182ca7dd543b2c67", "shasum": "" }, "require": { @@ -27,7 +27,7 @@ } }, "notification-url": "https://packagist.org/downloads/", - "time": "2013-03-28 15:28:21" + "time": "2013-03-29 10:44:52" }, { "name": "dflydev/doctrine-orm-service-provider", @@ -429,6 +429,61 @@ ], "time": "2013-03-27 16:49:35" }, + { + "name": "igorw/config-service-provider", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/igorw/ConfigServiceProvider.git", + "reference": "v1.1.5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/igorw/ConfigServiceProvider/zipball/v1.1.5", + "reference": "v1.1.5", + "shasum": "" + }, + "require": { + "silex/silex": "1.0.*@dev" + }, + "require-dev": { + "symfony/yaml": ">=2.1,<3.0" + }, + "suggest": { + "symfony/yaml": "~2.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Igorw\\Silex": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch", + "homepage": "http://wiedler.ch/igor/" + }, + { + "name": "Contributors", + "homepage": "https://github.com/igorw/ConfigServiceProvider/contributors" + } + ], + "description": "A config ServiceProvider for Silex with support for php, json and yaml.", + "keywords": [ + "silex" + ], + "time": "2013-03-09 15:35:23" + }, { "name": "knplabs/knp-menu", "version": "dev-master", @@ -555,6 +610,48 @@ ], "time": "2013-02-13 18:06:51" }, + { + "name": "mpdf/mpdf", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/finwe/mpdf.git", + "reference": "v5.6.1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/finwe/mpdf/zipball/v5.6.1", + "reference": "v5.6.1", + "shasum": "" + }, + "require": { + "php": ">=4.3.10" + }, + "type": "library", + "autoload": { + "classmap": [ + "mpdf.php", + "classes" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-1.0+" + ], + "authors": [ + { + "name": "Ian Back" + } + ], + "description": "A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support", + "homepage": "http://www.mpdf1.com/mpdf/index.php", + "keywords": [ + "pdf", + "php", + "utf-8" + ], + "time": "2013-01-26 08:22:27" + }, { "name": "pagerfanta/pagerfanta", "version": "dev-master", @@ -2120,7 +2217,9 @@ "pagerfanta/pagerfanta": 20, "knplabs/knp-menu": 20, "gedmo/doctrine-extensions": 20, - "chamilo/chash": 20 + "chamilo/chash": 20, + "igorw/config-service-provider": 20, + "mpdf/mpdf": 20 }, "platform": { "php": ">=5.3.2" diff --git a/index.php b/index.php index 059d0d2da2..6c47b332a4 100644 --- a/index.php +++ b/index.php @@ -8,20 +8,3 @@ //Temporal hack to redirect calls to the new web/index.php header('Location: web/index'); exit; - -define('CHAMILO_HOMEPAGE', true); - -$language_file = array('courses', 'index'); - -// Flag forcing the 'current course' reset, as we're not inside a course anymore. -// Maybe we should change this into an api function? an example: CourseManager::unset(); -$cidReset = true; - -$app = require_once 'main/inc/global.inc.php'; -require_once 'main/chat/chat_functions.lib.php'; - -// The section (for the tabs). -$this_section = SECTION_CAMPUS; - - - diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index 7349483473..3dd32345d1 100644 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -4,27 +4,21 @@ /** * This is a bootstrap file that loads all Chamilo dependencies including: * - * - Loading Chamilo settings in main/inc/configuration.php - * - Loading mysql database (Using Doctrine ORM or the Classic way: Database;;query()) - * - Twig templates - * - Loading language files - * - Loading mail settings (smtp/sendmail/mail) + * - Chamilo settings in main/inc/configuration.php or main/inc/configuration.yml + * - mysql database (Using Doctrine DBAL/ORM or the Classic way: Database::query()) + * - Templates (Using Twig) + * - Loading language files (No Symfony component) + * - Loading mail settings (SwiftMailer smtp/sendmail/mail) * - Debug (Using Monolog) - * - Redirecting to the main/install folder if the configuration.php file does not exists. * * - * It's recommended that ALL Chamilo scripts include this file. + * ALL Chamilo scripts must include this file in order to have the $app container * This script returns a $app Application instance so you have access to all the services. * * @package chamilo.include - * @todo use the $_configuration array for all the needed variables * */ -// Showing/hiding error codes in global error messages. -//define('SHOW_ERROR_CODES', false); - -// Determine the directory path where this current file lies. -// This path will be useful to include the other intialisation files. +// Determine the directory path for this file. $includePath = dirname(__FILE__); // Include the main Chamilo platform configuration file. @@ -41,35 +35,21 @@ if (file_exists($configurationFilePath) || file_exists($configurationYMLFile)) { $_configuration = array(); } -//Redirects to the main/install/ page -/* -if (!$alreadyInstalled) { - $global_error_code = 2; - // The system has not been installed yet. - require $includePath.'/global_error_message.inc.php'; - die(); -}*/ - // Include the main Chamilo platform library file. require_once $includePath.'/lib/main_api.lib.php'; // Do not over-use this variable. It is only for this script's local use. -$lib_path = $includePath.'/lib/'; +$libPath = $includePath.'/lib/'; // Fix bug in IIS that doesn't fill the $_SERVER['REQUEST_URI']. -api_request_uri(); +//@todo not sure if this is needed any more +//api_request_uri(); // This is for compatibility with MAC computers. ini_set('auto_detect_line_endings', '1'); //Fixes Htmlpurifier autoloader issue with composer -define('HTMLPURIFIER_PREFIX', $lib_path.'htmlpurifier/library'); - -//mpdf constants -//define("_MPDF_TEMP_PATH", api_get_path(SYS_ARCHIVE_PATH)); -// Forcing PclZip library to use a custom temporary folder. - -define('_MPDF_PATH', $lib_path.'mpdf/'); +define('HTMLPURIFIER_PREFIX', $libPath.'htmlpurifier/library'); //Composer autoloader require_once __DIR__.'../../../vendor/autoload.php'; @@ -83,17 +63,28 @@ use Symfony\Component\Yaml\Parser; $app = new Application(); +//@todo add a helper to read the configuration file once! + //Overwriting $_configuration if (file_exists($configurationYMLFile)) { $yaml = new Parser(); $configurationYML = $yaml->parse(file_get_contents($configurationYMLFile)); - if (isset($_configuration)) { - $_configuration = array_merge($_configuration, $configurationYML); - } else { - $_configuration = $configurationYML; + if (is_array($configurationYML) && !empty($configurationYML)) { + if (isset($_configuration)) { + $_configuration = array_merge($_configuration, $configurationYML); + } else { + $_configuration = $configurationYML; + } } } +/* +$settingsFile = __DIR__."/../../app/config/settings.yml"; +$app->register(new Igorw\Silex\ConfigServiceProvider($settingsFile, array( + 'database' => __DIR__.'/data', +))); +*/ + // Ensure that _configuration is in the global scope before loading // main_api.lib.php. This is particularly helpful for unit tests if (!isset($GLOBALS['_configuration'])) { @@ -473,11 +464,11 @@ $app['template_style'] = 'default'; $app['default_layout'] = $app['template_style'].'/layout/layout_1_col.tpl'; //Database constants -require_once $lib_path.'database.constants.inc.php'; -require_once $lib_path.'text.lib.php'; -require_once $lib_path.'array.lib.php'; -require_once $lib_path.'events.lib.inc.php'; -require_once $lib_path.'online.inc.php'; +require_once $libPath.'database.constants.inc.php'; +require_once $libPath.'text.lib.php'; +require_once $libPath.'array.lib.php'; +require_once $libPath.'events.lib.inc.php'; +require_once $libPath.'online.inc.php'; /* Database connection (for backward compatibility) */ global $database_connection; @@ -591,7 +582,7 @@ if ($alreadyInstalled && $checkConnection) { } // Load allowed tag definitions for kses and/or HTMLPurifier. -require_once $lib_path.'formvalidator/Rule/allowed_tags.inc.php'; +require_once $libPath.'formvalidator/Rule/allowed_tags.inc.php'; // which will then be usable from the banner and header scripts $app['this_section'] = SECTION_GLOBAL; diff --git a/main/inc/global_error_message.inc.php b/main/inc/global_error_message.inc.php deleted file mode 100644 index d063015ded..0000000000 --- a/main/inc/global_error_message.inc.php +++ /dev/null @@ -1,236 +0,0 @@ -Chamilo Homepage'; -$PoweredBy = 'Platform Chamilo © '.date('Y'); - -/** - * English language variables. - */ - -// Sections. -$SectionSystemRequirementsProblem = 'System requirements problem'; -$SectionInstallation = 'Installation'; -$SectionDatabaseUnavailable = 'Database is unavailable'; -$SectionTechnicalIssues = 'Technical issues'; -$SectionProtection = 'Protection measure'; - -// Error code. -$ErrorCode = 'Error code'; - -// Error code 1. -$IncorrectPhpVersionTitle = 'Incorrect PHP version'; -$IncorrectPhpVersionDescription = 'Warning: we have detected that your version of PHP is %s1. To install Chamilo, you need to have PHP %s2 or superior. If you don\'t know what we\'re talking about, please contact your hosting provider or your support team. - %s3 Read the installation guide.'; - -// Error code 2. -$InstallationTitle = 'Chamilo has not been installed'; -$InstallationDescription = 'Click to INSTALL Chamilo %s or read the installation guide'; - -// Error code 3. -// Error code 4. -// Error code 5. -$DatabaseUnavailableTitle = 'Database is unavailable'; -$DatabaseUnavailableDescription = 'This portal is currently experiencing database issues. Please report this to the portal administrator. Thank you for your help.'; - -// Error code 6. -$AlreadyInstalledTitle = 'Chamilo has already been installed'; -$AlreadyInstalledDescription = 'The system has already been installed. In order its content to be protected you are not allowed to start the installation script again.'; - -// Unspecified error. -$TechnicalIssuesTitle = 'Technical issues'; -$TechnicalIssuesDescription = 'This portal is currently experiencing technical issues. Please report this to the portal administrator. Thank you for your help.'; - -if (is_int($global_error_code) && $global_error_code > 0) { - - $theme = 'chamilo/'; - $css_path = 'main/css/'; - $css_file = $css_path.$theme.'default.css'; - $bootstrap_file = $css_path.'bootstrap.css'; - $css_base_file = $css_path.'base.css'; - $css_base_chamilo_file = $css_path.'base_chamilo.css'; - - $css_list = array($bootstrap_file, $css_base_file, $css_base_chamilo_file, $css_file); - - $root_sys = str_replace('\\', '/', realpath(dirname(__FILE__).'/../../')).'/'; - $root_rel = htmlentities($_SERVER['PHP_SELF']); - if (!empty($root_rel)) { - $pos = strrpos($root_rel, '/'); - $root_rel = substr($root_rel, 0, $pos - strlen($root_rel) + 1); - if (strpos($root_rel, '/main/') !== false) { - $pos = 0; - while (($test_pos = strpos(substr($root_rel, $pos, strlen($root_rel)), '/main/')) !== false) { - $pos = $test_pos + 1; - } - $root_rel = substr($root_rel, 0, $pos); - } elseif (strpos($root_rel, '/courses/') !== false) { - $pos = 0; - while (($test_pos = strpos(substr($root_rel, $pos, strlen($root_rel)), '/courses/')) !== false) { - $pos = $test_pos + 1; - } - $root_rel = substr($root_rel, 0, $pos); - } - } - - $installation_guide_url = $root_rel.'documentation/installation_guide.html'; - - $css_def = ''; - foreach ($css_list as $css_item) { - $css_base_chamilo_file = $root_sys.$css_item; - if (file_exists($css_base_chamilo_file)) { - $css_def .= @file_get_contents($css_base_chamilo_file); - } - } - - $css_def = str_replace("@import url('bootstrap.css');", '', $css_def); - $css_def = str_replace('main/', $root_rel.'main/', $css_def); - $css_def = str_replace('images/', $root_rel.$css_path.$theme.'images/', $css_def); - $css_def = str_replace('../../img/', $root_rel.'main/img/', $css_def); - - $global_error_message = array(); - - switch ($global_error_code) { - case 1: - $global_error_message['section'] = $SectionSystemRequirementsProblem; - $global_error_message['title'] = $IncorrectPhpVersionTitle; - $php_version = function_exists('phpversion') ? phpversion() : (defined('PHP_VERSION') ? PHP_VERSION : ''); - $php_version = empty($php_version) ? '' : '(PHP '.$php_version.')'; - $IncorrectPhpVersionDescription = str_replace('%s1', $php_version, $IncorrectPhpVersionDescription); - $IncorrectPhpVersionDescription = str_replace('%s2', REQUIRED_PHP_VERSION, $IncorrectPhpVersionDescription); - $pos = strpos($IncorrectPhpVersionDescription, '%s3'); - if ($pos !== false) { - $length = strlen($IncorrectPhpVersionDescription); - $read_installation_guide = substr($IncorrectPhpVersionDescription, $pos + 3, $length); - $IncorrectPhpVersionDescription = substr($IncorrectPhpVersionDescription, 0, $pos); - $IncorrectPhpVersionDescription .= '
'.$read_installation_guide.''; - } - $global_error_message['description'] = $IncorrectPhpVersionDescription; - break; - case 2: - $global_error_message['section'] = $SectionInstallation; - $global_error_message['title'] = $InstallationTitle; - if (($pos = strpos($InstallationDescription, '%s')) === false) { - $InstallationDescription = 'Click to INSTALL Chamilo %s or read the installation guide'; - } - $read_installation_guide = substr($InstallationDescription, $pos + 2); - $InstallationDescription = '
-

- - '.$read_installation_guide.' -

-
'; - $global_error_message['description'] = $InstallationDescription; - break; - case 3: - case 4: - case 5: - $global_error_message['section'] = $SectionDatabaseUnavailable; - $global_error_message['title'] = $DatabaseUnavailableTitle; - $global_error_message['description'] = $DatabaseUnavailableDescription; - break; - - case 6: - $global_error_message['section'] = $SectionProtection; - $global_error_message['title'] = $AlreadyInstalledTitle; - $global_error_message['description'] = $AlreadyInstalledDescription; - break; - - default: - $global_error_message['section'] = $SectionTechnicalIssues; - $global_error_message['title'] = $TechnicalIssuesTitle; - $global_error_message['description'] = $TechnicalIssuesDescription; - break; - } - - $show_error_codes = defined('SHOW_ERROR_CODES') && SHOW_ERROR_CODES && $global_error_code != 2; - $global_error_message['code'] = $show_error_codes ? $ErrorCode.': '.$global_error_code.'

' : ''; - $global_error_message['details'] = empty($global_error_message['details']) ? '' : ($show_error_codes ? ': '.$global_error_message['details'] : $global_error_message['details']); - - $global_error_message['organisation'] = $Organisation; - $global_error_message['powered_by'] = $PoweredBy; - - $global_error_message['encoding'] = 'UTF-8'; - $global_error_message['css'] = $css_def; - $global_error_message['chamilo_logo'] = $root_rel.$css_path.$theme.'images/header-logo.png'; - - -// {ORGANISATION} moved from the header - $global_error_message_page = -<< - - - {TITLE} - - - - -
-
-
-
-
- -
-
- - - -
-
-
-
- {DESCRIPTION} - {CODE} -
-
-
-
-
- - - - -EOM; - foreach ($global_error_message as $key => $value) { - $global_error_message_page = str_replace('{'.strtoupper($key).'}', $value, $global_error_message_page); - } - header('Content-Type: text/html; charset='.$global_error_message['encoding']); - die($global_error_message_page); -} diff --git a/src/ChamiloLMS/Resources/config/prod.php b/src/ChamiloLMS/Resources/config/prod.php index 81f253c481..b511db1cd5 100644 --- a/src/ChamiloLMS/Resources/config/prod.php +++ b/src/ChamiloLMS/Resources/config/prod.php @@ -26,6 +26,12 @@ $app['chamilo.log'] = $app['cache.path'].'chamilo.log'; //PCLZIP temp dir define('PCLZIP_TEMPORARY_DIR', $app['cache.path']); +//mpdf libs + +define("_MPDF_TEMP_PATH", $app['cache.path']); +define("_JPGRAPH_PATH", $app['cache.path']); +define("_MPDF_TTFONTDATAPATH", $app['cache.path']); + // Assetic /* $app['assetic.path_to_cache'] = $app['cache.path'] . DIRECTORY_SEPARATOR . 'assetic' ; diff --git a/user_portal.php b/user_portal.php index efcb8dd85a..7627a2eaac 100644 --- a/user_portal.php +++ b/user_portal.php @@ -1,84 +1,6 @@ - - $(document).ready(function() { - $(".document_preview_container").hide(); - $(".document_preview").click(function() { - var my_id = this.id; - var course_id = my_id.split("_")[2]; - var session_id = my_id.split("_")[3]; - - //showing div - $(".document_preview_container").hide(); - - $("#document_result_" +course_id+"_" + session_id).show(); - - //Loading - var image = $("img", this); - image.attr("src", "'.$close_icon.'"); - - $.ajax({ - url: "'.$url.'", - data: "course_id="+course_id+"&session_id="+session_id, - success: function(return_value) { - image.attr("src", "'.$folder_icon.'"); - $("#document_result_" +course_id+"_" + session_id).html(return_value); - - } - }); - - }); - }); - '; -} +exit; \ No newline at end of file