Example #1
0
 /**
  * Initializes the text content object.
  *
  * Supported options are:
  * - bin-maxsize (default: 1MB)
  *
  * @param string $resource Path to the actual file
  * @param string $name Name of the file
  * @param array $options Associative list of key/value pairs for configuration
  */
 public function __construct($resource, $name, array $options = array())
 {
     if (($this->_fh = @fopen($resource, 'a+')) === false && ($this->_fh = fopen($resource, 'r')) === false) {
         throw new MW_Container_Exception(sprintf('Unable to open file "%1$s"', $resource));
     }
     parent::__construct($resource, $name, $options);
     $this->_size = $this->_getOption('bin-maxsize', 0x100000);
     $this->_data = $this->_getData();
 }
Example #2
0
 /**
  * Initializes the text content object.
  *
  * Supported options are:
  * - gzip-level (default: 5)
  *
  * @param string $resource Path to the actual file
  * @param string $name Name of the file
  * @param array $options Associative list of key/value pairs for configuration
  */
 public function __construct($resource, $name, array $options = array())
 {
     if (!is_file($resource) && substr($resource, -3) !== '.gz') {
         $resource .= '.gz';
     }
     if (substr($name, -3) !== '.gz') {
         $name .= '.gz';
     }
     $level = $this->_getOption('gzip-level', 5);
     if (($this->_fh = @gzopen($resource, 'rb' . $level)) === false && ($this->_fh = gzopen($resource, 'wb')) === false) {
         throw new MW_Container_Exception(sprintf('Unable to open file "%1$s"', $resource));
     }
     parent::__construct($resource, $name, $options);
     $this->_data = $this->_getData();
 }
Example #3
0
 /**
  * Initializes the CSV content object.
  *
  * Supported options are:
  * - csv-separator (default: ',')
  * - csv-enclosure (default: '"')
  * - csv-escape (default: '"')
  * - csv-lineend (default: LF)
  * - csv-lineend-subst (default: ' ')
  *
  * @param string $resource Path to the actual file
  * @param string $name Name of the CSV file
  * @param array $options Associative list of key/value pairs for configuration
  */
 public function __construct($resource, $name, array $options = array())
 {
     if (($this->_fh = @fopen($resource, 'a+')) === false && ($this->_fh = fopen($resource, 'r')) === false) {
         throw new MW_Container_Exception(sprintf('Unable to open file "%1$s"', $resource));
     }
     if (substr($name, -4) !== '.csv') {
         $name .= '.csv';
     }
     parent::__construct($resource, $name, $options);
     $this->_separator = $this->_getOption('csv-separator', ',');
     $this->_enclosure = $this->_getOption('csv-enclosure', '"');
     $this->_escape = $this->_getOption('csv-escape', '"');
     $this->_lineend = $this->_getOption('csv-lineend', chr(10));
     $this->_endsubst = $this->_getOption('csv-lineend-subst', ' ');
     $this->_data = $this->_getData();
 }
Example #4
0
 /**
  * Initializes the text content object.
  *
  * Supported options are:
  * - text-lineend (default: LF)
  * - text-maxsize (default: 1MB)
  *
  * @param string $resource Path to the actual file
  * @param string $name Name of the file
  * @param array $options Associative list of key/value pairs for configuration
  */
 public function __construct($resource, $name, array $options = array())
 {
     if (!is_file($resource) && substr($resource, -4) !== '.txt') {
         $resource .= '.txt';
     }
     if (substr($name, -4) !== '.txt') {
         $name .= '.txt';
     }
     if (($this->_fh = @fopen($resource, 'a+')) === false && ($this->_fh = fopen($resource, 'r')) === false) {
         throw new MW_Container_Exception(sprintf('Unable to open file "%1$s"', $resource));
     }
     parent::__construct($resource, $name, $options);
     $this->_lineend = $this->_getOption('text-lineend', chr(10));
     $this->_size = $this->_getOption('text-maxsize', 0x100000);
     $this->_data = $this->_getData();
 }
Example #5
0
 /**
  * Initializes the PHPExcel content object.
  *
  * @param PHPExcel_Worksheet $sheet PHPExcel sheet
  * @param array $options Associative list of key/value pairs for configuration
  */
 public function __construct(PHPExcel_Worksheet $sheet, $name, array $options = array())
 {
     parent::__construct($sheet, $name, $options);
     $this->_sheet = $sheet;
     $this->_iterator = $sheet->getRowIterator();
 }