Exemple #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 \Aimeos\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();
 }
Exemple #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 \Aimeos\MW\Container\Exception(sprintf('Unable to open file "%1$s"', $resource));
     }
     parent::__construct($resource, $name, $options);
     $this->data = $this->getData();
 }
Exemple #3
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 \Aimeos\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();
 }
Exemple #4
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 (!is_file($resource) && substr($resource, -4) !== '.csv') {
         $resource .= '.csv';
     }
     if (substr($name, -4) !== '.csv') {
         $name .= '.csv';
     }
     if (($this->fh = @fopen($resource, 'a+')) === false && ($this->fh = fopen($resource, 'r')) === false) {
         throw new \Aimeos\MW\Container\Exception(sprintf('Unable to open file "%1$s"', $resource));
     }
     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();
 }
Exemple #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();
 }