예제 #1
0
 /**
  * Opens an existing file or creates a new one.
  *
  * Supported options are:
  * - dir-perm (default: 0755)
  *
  * @param string $resourcepath Path to the resource like a file
  * @param string $format Format of the content objects inside the container
  * @param array $options Associative list of key/value pairs for configuration
  */
 public function __construct($resourcepath, $format, array $options = array())
 {
     $this->classname = '\\Aimeos\\MW\\Container\\Content\\' . $format;
     if (class_exists($this->classname) === false) {
         throw new \Aimeos\MW\Container\Exception(sprintf('Unknown format "%1$s"', $format));
     }
     parent::__construct($resourcepath, $options);
     $perm = octdec($this->getOption('dir-perm', '0755'));
     if (!is_dir(realpath($resourcepath)) && mkdir($resourcepath, $perm, true) === false) {
         throw new \Aimeos\MW\Container\Exception(sprintf('Unable to create directory "%1$s"', $resourcepath));
     }
     $this->resource = new \DirectoryIterator($resourcepath);
 }
예제 #2
0
파일: Zip.php 프로젝트: mvnp/aimeos-core
 /**
  * Opens an existing container or creates a new one.
  *
  * Supported options are:
  * - tempdir (default: system temp directory)
  *
  * @param string $resourcepath Path to the resource like a file
  * @param string $format Format of the content objects inside the container
  * @param array $options Associative list of key/value pairs for configuration
  */
 public function __construct($resourcepath, $format, array $options = array())
 {
     $this->classname = '\\Aimeos\\MW\\Container\\Content\\' . $format;
     if (class_exists($this->classname) === false) {
         throw new \Aimeos\MW\Container\Exception(sprintf('Unknown format "%1$s"', $format));
     }
     if (is_file($resourcepath) === false && substr($resourcepath, -4) !== '.zip') {
         $resourcepath .= '.zip';
     }
     parent::__construct($resourcepath, $options);
     $this->resourcepath = $resourcepath;
     $this->container = new \ZipArchive();
     $this->container->open($resourcepath, \ZipArchive::CREATE);
 }
예제 #3
0
 /**
  * Opens an existing container or creates a new one.
  *
  * @param string $resourcepath Path to the resource like a file
  * @param string $format Format of the content objects inside the container
  * @param array $options Associative list of key/value pairs for configuration
  */
 public function __construct($resourcepath, $format, array $options = array())
 {
     if (file_exists($resourcepath)) {
         $type = \PHPExcel_IOFactory::identify($resourcepath);
         $reader = \PHPExcel_IOFactory::createReader($type);
         $this->container = $reader->load($resourcepath);
     } else {
         $this->container = new \PHPExcel();
         $this->container->removeSheetByIndex(0);
         switch ($format) {
             case 'Excel5':
                 $resourcepath .= '.xls';
                 break;
             case 'Excel2003XML':
                 $resourcepath .= '.xml';
                 break;
             case 'Excel2007':
                 $resourcepath .= '.xlsx';
                 break;
             case 'OOCalc':
                 $resourcepath .= '.ods';
                 break;
             case 'SYLK':
                 $resourcepath .= '.slk';
                 break;
             case 'Gnumeric':
                 $resourcepath .= '.gnumeric';
                 break;
             case 'CSV':
                 $resourcepath .= '.csv';
                 break;
         }
     }
     parent::__construct($resourcepath, $options);
     $this->iterator = $this->container->getWorksheetIterator();
     $this->resourcepath = $resourcepath;
     $this->format = $format;
 }