avoid the ugly include for varstream, use a dummy VarStream::init()
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 22 Oct 2006 21:16:39 +0000 (21:16 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 22 Oct 2006 21:16:39 +0000 (21:16 +0000)
instead.

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1008 839d8a87-29fc-0310-9880-83ba4fa771e5

classes/varstream.php
include/validations/photos.inc.php
modules/carnet/contacts.pdf.inc.php

index 49c31f6..744ca34 100644 (file)
 
 class VarStream
 {
-    // {{{ properties
-
     // Stream handler to read from global variables
-    var $varname;
-    var $position;
-
-    // }}}
-    // {{{ stream_open
+    private $varname;
+    private $position;
 
     function stream_open($path, $mode, $options, &$opened_path)
     {
@@ -43,16 +38,10 @@ class VarStream
         return true;
     }
 
-    // }}}
-    // {{{ stream_close
-
     function stream_close()
     {
     }
 
-    // }}}
-    // {{{ stream_read
-
     function stream_read($count)
     {
         $ret = substr($GLOBALS[$this->varname], $this->position, $count);
@@ -60,9 +49,6 @@ class VarStream
         return $ret;
     }
 
-    // }}}
-    // {{{ stream_write
-
     function stream_write($data)
     {
         $len = strlen($data);
@@ -74,25 +60,16 @@ class VarStream
         $this->position += $len;
     }
 
-    // }}}
-    // {{{ stream_eof
-
     function stream_eof()
     {
         return $this->position >= strlen($GLOBALS[$this->varname]);
     }
 
-    // }}}
-    // {{{ stream_tell
-
     function stream_tell()
     {
         return $this->position;
     }
 
-    // }}}
-    // {{{ stream_seek
-
     function stream_seek($offs, $whence)
     {
         switch ($whence) {
@@ -116,16 +93,14 @@ class VarStream
         return 0;
     }
 
-    // }}}
-    // {{{ stream_flush
-
     function stream_flush()
     {
     }
 
-    // }}}
+    static function init()
+    {
+        stream_wrapper_register('var','VarStream');
+    }
 }
 
-stream_wrapper_register('var','VarStream');
-
 ?>
index 6cab17e..95860e3 100644 (file)
@@ -54,8 +54,9 @@ class PhotoReq extends Validate
     {
         global $page;
 
+        VarStream::init();
+
         // calcul de la taille de l'image
-        require_once dirname(__FILE__).'/../../classes/varstream.php';
         $GLOBALS['photoreq'] = $_data;
         $image_infos = getimagesize('var://photoreq');
         unset ($GLOBALS['photoreq']);
index e50bf96..32617b1 100644 (file)
 
 define ('FPDF_FONTPATH', dirname(__FILE__).'/fonts/');
 require_once '/usr/share/fpdf/fpdf.php';
-require_once dirname(__FILE__).'/../../classes/varstream.php';
+
+VarStream::init();
 
 class ContactsPDF extends FPDF
 {
-    var $col = 0;
-    var $y0;
+    public $title  = "Mes contacts sur Polytechnique.org";
+
+    private $col = 0;
+    private $y0;
 
-    var $title  = "Mes contacts sur Polytechnique.org";
-    var $broken = false;
-    var $error  = false;
+    private $broken = false;
+    private $error  = false;
 
-    var $report = 0;
+    private $report = 0;
 
     function ContactsPDF()
     {
@@ -339,7 +341,6 @@ class ContactsPDF extends FPDF
 
         return $self;
     }
-
 }
 
 ?>