Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/2458/head
jmontoyaa 8 years ago
commit 61df9eacb7
  1. 1
      plugin/test2pdf/lang/english.php
  2. 85
      plugin/test2pdf/src/download-pdf.php
  3. 1
      plugin/test2pdf/src/index.test2pdf.php
  4. 11
      plugin/test2pdf/src/test2pdf.lib.php
  5. 14
      plugin/test2pdf/src/test2pdf_plugin.class.php

@ -13,4 +13,3 @@ $strings['PluginDisabledFromAdminPanel'] = "The plugin has been disabled from th
$strings['AnswersColumn'] = "Answers: ";
$strings['Statement']= "Statement";
$strings['PageX']= "Page %s";

@ -26,7 +26,7 @@ $id_quiz = (int) $_GET['id_quiz'];
class PDF extends FPDF
{
function Header()
public function Header()
{
global $title_course;
global $title_quiz;
@ -50,7 +50,7 @@ class PDF extends FPDF
$this->Ln(10);
}
function Footer()
public function Footer()
{
global $test2pdfPlugin;
// Position at 1.5 cm from bottom
@ -74,15 +74,15 @@ class PDF extends FPDF
$this->Cell(0, 10, date('Y'), 0, 0, 'R');
}
var $B;
var $I;
var $U;
var $HREF;
var $fontList;
var $issetfont;
var $issetcolor;
public $B;
public $I;
public $U;
public $HREF;
public $fontList;
public $issetfont;
public $issetcolor;
function PDF($orientation='P', $unit='mm', $format='A4')
public function PDF($orientation='P', $unit='mm', $format='A4')
{
//Call parent constructor
$this->__construct($orientation, $unit, $format);
@ -91,50 +91,46 @@ class PDF extends FPDF
$this->I=0;
$this->U=0;
$this->HREF='';
$this->fontlist=array('arial', 'times', 'courier', 'helvetica', 'symbol');
$this->fontlist=['arial', 'times', 'courier', 'helvetica', 'symbol'];
$this->issetfont=false;
$this->issetcolor=false;
}
function WriteHTML($html)
public function WriteHTML($html)
{
//HTML parser
$html=strip_tags($html, "<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><style>"); //supprime tous les tags sauf ceux reconnus
$html=str_replace("\n", ' ', $html); //remplace retour à la ligne par un espace
$a=preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); //éclate la chaîne avec les balises
foreach($a as $i=>$e)
{
if($i%2==0)
{
foreach ($a as $i=>$e) {
if ($i%2==0) {
//Text
if($this->HREF)
if ($this->HREF) {
$this->PutLink($this->HREF, $e);
else
} else {
$this->Write(5, stripslashes(txtentities($e)));
}
else
{
} else {
//Tag
if($e[0]=='/')
if ($e[0]=='/') {
$this->CloseTag(strtoupper(substr($e, 1)));
else
{
} else {
//Extract attributes
$a2=explode(' ', $e);
$tag=strtoupper(array_shift($a2));
$attr=array();
foreach($a2 as $v)
{
if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
$attr=[];
foreach ($a2 as $v) {
if (preg_match('/([^=]*)=["\']?([^"\']*)/', $v, $a3)) {
$attr[strtoupper($a3[1])]=$a3[2];
}
}
$this->OpenTag($tag, $attr);
}
}
}
}
function OpenTag($tag, $attr)
public function OpenTag($tag, $attr)
{
//Opening tag
switch ($tag) {
@ -154,10 +150,12 @@ class PDF extends FPDF
break;
case 'IMG':
if (isset($attr['SRC']) && (isset($attr['WIDTH']) || isset($attr['HEIGHT']))) {
if(!isset($attr['WIDTH']))
if (!isset($attr['WIDTH'])) {
$attr['WIDTH'] = 0;
if(!isset($attr['HEIGHT']))
}
if (!isset($attr['HEIGHT'])) {
$attr['HEIGHT'] = 0;
}
$this->Image($attr['SRC'], $this->GetX(), $this->GetY(), px2mm($attr['WIDTH']), px2mm($attr['HEIGHT']));
}
break;
@ -183,17 +181,21 @@ class PDF extends FPDF
}
}
function CloseTag($tag)
public function CloseTag($tag)
{
//Closing tag
if($tag=='STRONG')
if ($tag=='STRONG') {
$tag='B';
if($tag=='EM')
}
if ($tag=='EM') {
$tag='I';
if($tag=='B' || $tag=='I' || $tag=='U')
}
if ($tag=='B' || $tag=='I' || $tag=='U') {
$this->SetStyle($tag, false);
if($tag=='A')
}
if ($tag=='A') {
$this->HREF='';
}
if ($tag=='FONT') {
if ($this->issetcolor==true) {
$this->SetTextColor(0);
@ -205,20 +207,20 @@ class PDF extends FPDF
}
}
function SetStyle($tag, $enable)
public function SetStyle($tag, $enable)
{
//Modify style and select corresponding font
$this->$tag+=($enable ? 1 : -1);
$style='';
foreach(array('B','I','U') as $s)
{
if($this->$s>0)
foreach (['B','I','U'] as $s) {
if ($this->$s>0) {
$style.=$s;
}
}
$this->SetFont('', $style);
}
function PutLink($URL, $txt)
public function PutLink($URL, $txt)
{
//Put a hyperlink
$this->SetTextColor(0, 0, 255);
@ -259,7 +261,6 @@ if ($_GET['type'] == 'question' || $_GET['type'] == 'all') {
$j = 0;
$pdf->WriteHTML(utf8_decode(removeQuotes($InfoQuestion['description'])));
$pdf->Ln();
} else {
$pdf->MultiCell(0, 7, ($key+$j).' - '.utf8_decode($InfoQuestion['question']), 0, 'L', false);
}
@ -290,7 +291,7 @@ if ($_GET['type'] == 'question' || $_GET['type'] == 'all') {
}
$j=1;
if ($_GET['type'] == 'answer' || $_GET['type'] == 'all') {
$array_resp = array();
$array_resp = [];
foreach ($array_question_id as $key => $value) {
$InfoQuestion = getInfoQuestion($course_id, $value);
if ($InfoQuestion['question'] == $test2pdfPlugin->get_lang('Statement')) {

@ -4,4 +4,3 @@
* Index of the Test to pdf plugin courses list
* @package chamilo.plugin.test2pdf
*/

@ -11,7 +11,7 @@ require_once '../../../main/inc/global.inc.php';
require_once '../config.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
$letters = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
$letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
/**
* List exercises
@ -38,7 +38,7 @@ function showExerciseCourse($course_id, $session_id = 0)
if (!$res) {
die("Error Database $tableQuiz");
}
$aux = array();
$aux = [];
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row;
}
@ -85,7 +85,7 @@ function getQuestions($c_id, $quizId)
if (!$res) {
die("Error Database $tableQuizQuestion");
}
$aux = array();
$aux = [];
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row['question_id'];
}
@ -131,7 +131,7 @@ function getAnswers($c_id, $id)
if (!$res) {
die("Error Database $tableQuizAnswer");
}
$aux = array();
$aux = [];
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row;
}
@ -243,7 +243,7 @@ function hex2dec($color = '#000000')
$vert = hexdec($V);
$B = substr($color, 5, 2);
$bleu = hexdec($B);
$tbl_couleur = array();
$tbl_couleur = [];
$tbl_couleur['R'] = $rouge;
$tbl_couleur['V'] = $vert;
$tbl_couleur['B'] = $bleu;
@ -271,4 +271,3 @@ function txtentities($html)
$trans = array_flip($trans);
return strtr($html, $trans);
}

@ -20,7 +20,7 @@ class Test2pdfPlugin extends Plugin
*
* @return StaticPlugin
*/
static function create()
public static function create()
{
static $result = null;
return $result ? $result : $result = new self();
@ -31,16 +31,16 @@ class Test2pdfPlugin extends Plugin
parent::__construct(
'1.0',
'Jose Angel Ruiz - NoSoloRed (original author)',
array(
[
'enable_plugin' => 'boolean'
)
]
);
}
/**
* This method creates the tables required to this plugin
*/
function install()
public function install()
{
//Installing course settings
$this->install_course_fields_in_all_courses();
@ -50,14 +50,14 @@ class Test2pdfPlugin extends Plugin
/**
* This method drops the plugin tables
*/
function uninstall()
public function uninstall()
{
//Deleting course settings
$this->uninstall_course_fields_in_all_courses($this->course_settings);
$tablesToBeDeleted = array(
$tablesToBeDeleted = [
TABLE_TEST2PDF
);
];
foreach ($tablesToBeDeleted as $tableToBeDeleted) {
$table = Database::get_main_table($tableToBeDeleted);
$sql = "DROP TABLE IF EXISTS $tableToBeDeleted";

Loading…
Cancel
Save