Ejemplo n.º 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 = 'MW_Container_Content_' . $format;
     if (class_exists($this->_classname) === false) {
         throw new 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 MW_Container_Exception(sprintf('Unable to create directory "%1$s"', $resourcepath));
     }
     $this->_resource = new DirectoryIterator($resourcepath);
 }
Ejemplo n.º 2
0
 /**
  * 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 = 'MW_Container_Content_' . $format;
     if (class_exists($this->_classname) === false) {
         throw new MW_Container_Exception(sprintf('Unknown format "%1$s"', $format));
     }
     if (is_file($resourcepath) === false) {
         $resourcepath .= '.zip';
     }
     parent::__construct($resourcepath, $options);
     $this->_resourcepath = $resourcepath;
     $this->_container = new ZipArchive();
     $this->_container->open($resourcepath, ZipArchive::CREATE);
 }
Ejemplo n.º 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;
 }