|
|
|
|
@ -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')) { |
|
|
|
|
|