Skip to content

Commit 0bafebb

Browse files
committed
commit commentaire nettoyage essai 1
1 parent 8afbf37 commit 0bafebb

20 files changed

+199
-426
lines changed

.zfproject.xml

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<controllerFile controllerName="Error"/>
1414
<controllerFile controllerName="ShowPdf">
1515
<actionMethod actionName="index"/>
16+
<actionMethod actionName="testValidate"/>
1617
</controllerFile>
1718
<controllerFile controllerName="Listfiles">
1819
<actionMethod actionName="index"/>
@@ -26,6 +27,7 @@
2627
</controllersDirectory>
2728
<formsDirectory>
2829
<formFile formName="Addafile"/>
30+
<formFile formName="Validate"/>
2931
</formsDirectory>
3032
<layoutsDirectory>
3133
<layoutScriptsDirectory>
@@ -60,6 +62,9 @@
6062
<viewControllerScriptsDirectory forControllerName="Admin">
6163
<viewScriptFile forActionName="index"/>
6264
</viewControllerScriptsDirectory>
65+
<viewControllerScriptsDirectory forControllerName="ShowPdf">
66+
<viewScriptFile forActionName="testValidate"/>
67+
</viewControllerScriptsDirectory>
6368
</viewScriptsDirectory>
6469
<viewHelpersDirectory/>
6570
<viewFiltersDirectory enabled="false"/>

application/controllers/AddafileController.php

+29-75
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,60 @@
11
<?php
22

3+
/*
4+
* File : AddafileController.php
5+
* Author : Mathilde De l'Hermuzière
6+
* Created :
7+
* Date de modification
8+
* Numéros de versions – Nom et Prénom du modificateur
9+
*
10+
* Description du fichier
11+
*
12+
* Projet parapheur 2014
13+
*/
14+
315
class AddafileController extends Zend_Controller_Action
416
{
517

618
public function init()
719
{
8-
/* Initialize action controller here */
9-
1020
}
1121

1222
public function indexAction()
1323
{
24+
//Database connexion
1425
$id = '63';
1526
$conn = oci_connect('DBA_PARAPHEUR', '12345678', 'XE');
1627
if (!$conn){
1728
echo 'Connection error.';
1829
}
30+
//Select the file from ID
1931
$sql = 'SELECT * FROM CONTENU WHERE ID_FICHIER=:id';
2032
$stid = oci_parse($conn, $sql);
2133
oci_bind_by_name($stid, ":id", $id);
2234
$result = oci_execute($stid);
35+
36+
//Fetch the row
2337
if($result !== false){
2438
while($row = oci_fetch_assoc($stid)){
2539
echo $row['CONTENU']->load();
2640
//or
2741
echo $row['CONTENU']->read(2000);
2842
}
2943
}
30-
31-
// $id=66;
32-
// //Désactiver le layout
33-
// $this->_helper->layout->disableLayout();
34-
// $this->_helper->viewRenderer->setNoRender(true);
35-
36-
37-
// //Here i will try to unclob a PDF file.
38-
// $table = new Application_Model_DbTable_Contenu();
39-
// $rows = $table->obtenirPdf($id);
40-
41-
// //$thepdf=new Zend_Pdf();
42-
// foreach($rows as $row){
43-
// //foreach ($row AS $field_name => $field_value)
44-
// //{
45-
46-
// if (is_resource($row) ) {
47-
// print(fread($row, 1000000)."\n");
48-
49-
50-
// } else {
51-
// // print($row."\n");
52-
53-
// }
54-
// //}
55-
// }
56-
// //$pdf = Zend_Pdf::load(realpath(APPLICATION_PATH . '/data/a.pdf'));
57-
// //$pdf->render();
58-
// $pdf = Zend_Pdf::parse($row);
59-
//$pdf->save(APPLICATION_PATH. '/data/test-pdf.pdf');
60-
61-
// // Set headers
62-
// header('Content-Type: application/pdf');
63-
// header('Content-Disposition: inline; filename=filename.pdf');
64-
// header('Cache-Control: private, max-age=0, must-revalidate');
65-
// header('Pragma: public');
66-
// ini_set('zlib.output_compression','0');
6744

68-
// // Get File Contents and echo to output
69-
// echo file_get_contents($pdf);
70-
71-
// // Prevent anything else from being outputted
72-
// die();
73-
// Set PDF headers
74-
//header ('Content-Type:', 'application/pdf');
75-
//header ('Content-Disposition:', 'inline;');
76-
77-
// Output pdf
78-
//echo $pdf->render();
79-
80-
81-
//Changement des header afin d'indiquer que la page est une application PDF
82-
/*$this->getResponse()->setHeader('Content-type', 'application/pdf', true);
45+
//---------------------SET AND SEND HEADER AS TO INDICATE IT IS A PDF APPLICATION---------------
46+
$this->getResponse()->setHeader('Content-type', 'application/pdf', true);
8347
$this->getResponse()->setHeader('Content-disposition','inline;filename='.$module.'_'.$m_no.'.pdf', true);
8448

8549
$this->getResponse()->setHeader('Cache-Control: no-cache, must-revalidate');
8650
$this->getResponse()->setHeader('Content-Transfer-Encoding', 'binary', true);
8751
$this->getResponse()->setHeader('Last-Modified', date('r'));
8852

89-
//Efface ce qui est contenue dans la balise body
9053
$this->getResponse()->clearBody();
91-
//Envoie les headers modifi�s au pr�alable
92-
$this->getResponse()->sendHeaders();*/
93-
94-
//Renvoie la chaine de caract�re du PDF (donc le contenu) dans le Body
95-
96-
//$page1 = clone $pdf->pages[1];
97-
//$this->getResponse()->setBody($pdf->render());
98-
//$pdf = Zend_Pdf::parse($row[1]);
54+
$this->getResponse()->sendHeaders();
9955

100-
101-
//$clobcontent=$row['CONTENT']->load();
102-
//echo $clobcontent;
103-
//$this->_helper->layout->disableLayout();
56+
//Set the body
57+
$this->getResponse()->setBody($pdf->render());
10458
}
10559

10660
public function signAction()
@@ -110,17 +64,19 @@ public function signAction()
11064

11165
if ($this->getRequest()->isPost()) {
11266
if ($form->isValid($request->getPost())) {
113-
$upload = new Zend_File_Transfer_Adapter_Http();
67+
68+
//Set destination for the PDF file : data file into application
69+
$upload = new Zend_File_Transfer_Adapter_Http();
11470
$upload->setDestination(realpath(APPLICATION_PATH . '\data'));
115-
//$upload->setDestination(realpath('c:'));
116-
try { //be sure to call receive() before getValues()
71+
72+
try {
73+
// call receive() before getValues()
11774
$upload->receive();
11875
} catch (Zend_File_Transfer_Exception $e) {
11976
$e->getMessage();
12077
}
12178
$formData = $form->getValues();
12279
$filename = $upload->getFileName('upfile');
123-
// $name=$formData->getValue('upfile');
12480
$filesize = $upload->getFileSize('upfile');
12581
$filemimeType = $upload->getMimeType('upfile');
12682

@@ -153,6 +109,7 @@ public function signAction()
153109
$id_typefichier=1; //is a PDF
154110
$taille=500;
155111

112+
//Get from tables Courrier, Fichier and Contenu
156113
$courrier = new Application_Model_DbTable_Courrier();
157114
$fichier = new Application_Model_DbTable_Fichier();
158115
$contenu = new Application_Model_DbTable_Contenu();
@@ -165,7 +122,6 @@ public function signAction()
165122

166123
$pdfString = $pdf->render();
167124
$contenu->ajouterContenu($id_fichier, $pdfString);
168-
// return $this->_helper->redirector('index');
169125
$this->_helper->redirector('index', 'index');
170126
}
171127
}
@@ -174,9 +130,7 @@ public function signAction()
174130
}
175131

176132
public function imagickAction()
177-
{
178-
179-
$this->_helper->layout->disableLayout();
133+
{ $this->_helper->layout->disableLayout();
180134
}
181135

182136

application/controllers/AdminController.php

-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ class AdminController extends Zend_Controller_Action
55

66
public function init()
77
{
8-
/* Initialize action controller here */
98
}
109

1110
public function indexAction()
1211
{
13-
// action body
1412
}
1513

1614
public function diagnosticAction()
1715
{
18-
// action body
1916
}
2017

2118
}

application/controllers/IndexController.php

-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ class IndexController extends Zend_Controller_Action
55

66
public function init()
77
{
8-
/* Initialize action controller here */
98
}
109

1110
public function indexAction()
@@ -66,8 +65,6 @@ public function indexAction()
6665

6766
public function addfileAction()
6867
{
69-
// action body
70-
7168
}
7269

7370
}

application/controllers/ListfilesController.php

-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ class ListfilesController extends Zend_Controller_Action
55

66
public function init()
77
{
8-
/* Initialize action controller here */
98
}
109

1110
public function indexAction()
1211
{
13-
1412
}
1513

1614
public function testAction()
1715
{
18-
1916
}
2017

2118

0 commit comments

Comments
 (0)