1
1
<?php
2
2
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
+
3
15
class AddafileController extends Zend_Controller_Action
4
16
{
5
17
6
18
public function init ()
7
19
{
8
- /* Initialize action controller here */
9
-
10
20
}
11
21
12
22
public function indexAction ()
13
23
{
24
+ //Database connexion
14
25
$ id = '63 ' ;
15
26
$ conn = oci_connect ('DBA_PARAPHEUR ' , '12345678 ' , 'XE ' );
16
27
if (!$ conn ){
17
28
echo 'Connection error. ' ;
18
29
}
30
+ //Select the file from ID
19
31
$ sql = 'SELECT * FROM CONTENU WHERE ID_FICHIER=:id ' ;
20
32
$ stid = oci_parse ($ conn , $ sql );
21
33
oci_bind_by_name ($ stid , ":id " , $ id );
22
34
$ result = oci_execute ($ stid );
35
+
36
+ //Fetch the row
23
37
if ($ result !== false ){
24
38
while ($ row = oci_fetch_assoc ($ stid )){
25
39
echo $ row ['CONTENU ' ]->load ();
26
40
//or
27
41
echo $ row ['CONTENU ' ]->read (2000 );
28
42
}
29
43
}
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');
67
44
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 );
83
47
$ this ->getResponse ()->setHeader ('Content-disposition ' ,'inline;filename= ' .$ module .'_ ' .$ m_no .'.pdf ' , true );
84
48
85
49
$ this ->getResponse ()->setHeader ('Cache-Control: no-cache, must-revalidate ' );
86
50
$ this ->getResponse ()->setHeader ('Content-Transfer-Encoding ' , 'binary ' , true );
87
51
$ this ->getResponse ()->setHeader ('Last-Modified ' , date ('r ' ));
88
52
89
- //Efface ce qui est contenue dans la balise body
90
53
$ 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 ();
99
55
100
-
101
- //$clobcontent=$row['CONTENT']->load();
102
- //echo $clobcontent;
103
- //$this->_helper->layout->disableLayout();
56
+ //Set the body
57
+ $ this ->getResponse ()->setBody ($ pdf ->render ());
104
58
}
105
59
106
60
public function signAction ()
@@ -110,17 +64,19 @@ public function signAction()
110
64
111
65
if ($ this ->getRequest ()->isPost ()) {
112
66
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 ();
114
70
$ 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()
117
74
$ upload ->receive ();
118
75
} catch (Zend_File_Transfer_Exception $ e ) {
119
76
$ e ->getMessage ();
120
77
}
121
78
$ formData = $ form ->getValues ();
122
79
$ filename = $ upload ->getFileName ('upfile ' );
123
- // $name=$formData->getValue('upfile');
124
80
$ filesize = $ upload ->getFileSize ('upfile ' );
125
81
$ filemimeType = $ upload ->getMimeType ('upfile ' );
126
82
@@ -153,6 +109,7 @@ public function signAction()
153
109
$ id_typefichier =1 ; //is a PDF
154
110
$ taille =500 ;
155
111
112
+ //Get from tables Courrier, Fichier and Contenu
156
113
$ courrier = new Application_Model_DbTable_Courrier ();
157
114
$ fichier = new Application_Model_DbTable_Fichier ();
158
115
$ contenu = new Application_Model_DbTable_Contenu ();
@@ -165,7 +122,6 @@ public function signAction()
165
122
166
123
$ pdfString = $ pdf ->render ();
167
124
$ contenu ->ajouterContenu ($ id_fichier , $ pdfString );
168
- // return $this->_helper->redirector('index');
169
125
$ this ->_helper ->redirector ('index ' , 'index ' );
170
126
}
171
127
}
@@ -174,9 +130,7 @@ public function signAction()
174
130
}
175
131
176
132
public function imagickAction ()
177
- {
178
-
179
- $ this ->_helper ->layout ->disableLayout ();
133
+ { $ this ->_helper ->layout ->disableLayout ();
180
134
}
181
135
182
136
0 commit comments