diff --git a/app/Migrations/Schema/V111/Version20160715122300.php b/app/Migrations/Schema/V111/Version20160715122300.php index 456886caf6..8981587a69 100644 --- a/app/Migrations/Schema/V111/Version20160715122300.php +++ b/app/Migrations/Schema/V111/Version20160715122300.php @@ -5,7 +5,6 @@ namespace Application\Migrations\Schema\V111; use Application\Migrations\AbstractMigrationChamilo; use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Types\Type; /** * Class Version20160715122300 @@ -23,6 +22,8 @@ class Version20160715122300 extends AbstractMigrationChamilo { $this->addSql('ALTER TABLE c_student_publication CHANGE session_id session_id INT DEFAULT NULL'); $this->addSql('UPDATE c_student_publication SET session_id = NULL WHERE session_id = 0'); + // Fix not existing session id + $this->addSql('DELETE FROM c_student_publication WHERE session_id not in (SELECT id FROM session)'); $this->addSql('ALTER TABLE c_student_publication ADD CONSTRAINT fk_session FOREIGN KEY (session_id) REFERENCES session (id)'); } diff --git a/main/document/showinframes.php b/main/document/showinframes.php index 37588f2487..72e4d4d42a 100755 --- a/main/document/showinframes.php +++ b/main/document/showinframes.php @@ -185,7 +185,7 @@ $js_glossary_in_documents = ' { type:"stylesheet", id:"_fr5", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/themes/smoothness/jquery-ui.min.css"}, { type:"stylesheet", id:"_fr6", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/themes/smoothness/theme.css"}, { type:"script", id:"_fr2", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"}, - { type:"script", id:"_fr3", src:"'.api_get_path(WEB_CODE_PATH).'glossary/glossary.js.php"} + { type:"script", id:"_fr3", src:"'.api_get_path(WEB_CODE_PATH).'glossary/glossary.js.php?'.api_get_cidreq().'"} ] });'; diff --git a/main/exercise/exercise_submit.php b/main/exercise/exercise_submit.php index 44422cae0f..4a49887834 100755 --- a/main/exercise/exercise_submit.php +++ b/main/exercise/exercise_submit.php @@ -45,7 +45,7 @@ if ($origin == 'learnpath') { $showGlossary = in_array($glossaryExtraTools, array('true', 'lp', 'exercise_and_lp')); } if ($showGlossary) { - $htmlHeadXtra[] = ''; + $htmlHeadXtra[] = ''; $htmlHeadXtra[] = api_get_js('jquery.highlight.js'); } diff --git a/main/glossary/glossary.js.php b/main/glossary/glossary.js.php index ec03eb4956..cf94158b2a 100644 --- a/main/glossary/glossary.js.php +++ b/main/glossary/glossary.js.php @@ -3,15 +3,27 @@ require_once __DIR__.'/../inc/global.inc.php'; +$origin = api_get_origin(); + $tpl = new Template(); -$templateName = 'glossary/glossary_auto.js.tpl'; -if (api_get_setting('show_glossary_in_documents') == 'ismanual') { - $templateName = 'glossary/glossary_manual.js.tpl'; +$glossaryExtraTools = api_get_setting('show_glossary_in_extra_tools'); + +if ($origin == 'learnpath') { + $showGlossary = in_array($glossaryExtraTools, array('lp', 'exercise_and_lp')); +} else { + $showGlossary = in_array($glossaryExtraTools, array('true', 'lp', 'exercise_and_lp')); } -$addReady = isset($_GET['add_ready']) ? true : false; -$tpl->assign('add_ready', $addReady); -$contentTemplate = $tpl->get_template($templateName); -header('Content-type: application/x-javascript'); -$tpl->display($contentTemplate); +if ($showGlossary) { + $templateName = 'glossary/glossary_auto.js.tpl'; + if (api_get_setting('show_glossary_in_documents') == 'ismanual') { + $templateName = 'glossary/glossary_manual.js.tpl'; + } + + $addReady = isset($_GET['add_ready']) ? true : false; + $tpl->assign('add_ready', $addReady); + $contentTemplate = $tpl->get_template($templateName); + header('Content-type: application/x-javascript'); + $tpl->display($contentTemplate); +} \ No newline at end of file diff --git a/main/gradebook/index.php b/main/gradebook/index.php index 73d0db9b30..95d4b58e1a 100755 --- a/main/gradebook/index.php +++ b/main/gradebook/index.php @@ -975,8 +975,6 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true) if ($action == 'export_table') { ob_clean(); - $sessionName = api_get_session_name(api_get_session_id()); - $sessionName = !empty($sessionName) ? " - $sessionName" : ''; $params = array( 'pdf_title' => sprintf(get_lang('GradeFromX'), $courseInfo['name']), 'course_code' => api_get_course_id(), @@ -986,16 +984,11 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true) 'student_info' => api_get_user_info(), 'show_grade_generated_date' => true, 'show_real_course_teachers' => false, - 'show_teacher_as_myself' => false + 'show_teacher_as_myself' => false, + 'orientation' => 'P' ); $pdf = new PDF('A4', $params['orientation'], $params); - - $address = api_get_setting('institution_address'); - $phone = api_get_setting('administratorTelephone'); - $address = str_replace('\n', '
', $address); - $pdf->custom_header = array('html' => "
$address
$phone
"); - $pdf->html_to_pdf_with_template( $table. $graph. diff --git a/main/gradebook/lib/GradebookUtils.php b/main/gradebook/lib/GradebookUtils.php index 8445382df2..1f45cb0d83 100644 --- a/main/gradebook/lib/GradebookUtils.php +++ b/main/gradebook/lib/GradebookUtils.php @@ -1564,9 +1564,6 @@ class GradebookUtils $table = $gradebooktable->return_table(); $graph = $gradebooktable->getGraph(); - $sessionName = api_get_session_name(api_get_session_id()); - $sessionName = !empty($sessionName) ? " - $sessionName" : ''; - $params = array( 'pdf_title' => sprintf(get_lang('GradeFromX'), $courseInfo['name']), 'session_info' => '', @@ -1593,11 +1590,6 @@ class GradebookUtils '
'.get_lang('Feedback').'
'; - /*$address = api_get_setting('institution_address'); - $phone = api_get_setting('administratorTelephone'); - $address = str_replace('\n', '
', $address); - - $pdf->custom_header = array('html' => "
$address
$phone
");*/ $result = $pdf->html_to_pdf_with_template( $content, $saveToFile, diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index c8ffa60aa5..02458aee9b 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -7502,16 +7502,21 @@ function api_get_user_blocked_by_captcha($username) /** * Remove tags from HTML anf return the $in_number_char first non-HTML char * Postfix the text with "..." if it has been truncated. - * @param integer $in_number_char + * @param string $text + * @param integer $number + * * @return string * @author hubert borderiou */ -function api_get_short_text_from_html($in_html, $in_number_char) +function api_get_short_text_from_html($text, $number) { - $out_res = api_remove_tags_with_space($in_html, false); + // Delete script and style tags + $text = preg_replace('/(<(script|style)\b[^>]*>).*?(<\/\2>)/is', "$1$3", $text); + $text = api_html_entity_decode($text); + $out_res = api_remove_tags_with_space($text, false); $postfix = "..."; - if (strlen($out_res) > $in_number_char) { - $out_res = substr($out_res, 0, $in_number_char).$postfix; + if (strlen($out_res) > $number) { + $out_res = substr($out_res, 0, $number).$postfix; } return $out_res; }