setItem($item); $this->setZip($zip); } /** * Obtains a reference on the TAO Item Service. * * @return taoItems_models_classes_ItemsService A TAO Item Service. */ protected function getItemService() { return taoItems_models_classes_ItemsService::singleton(); } /** * Obtains a reference on the currently exported instance of Item. * * @return core_kernel_classes_Resource The currently exported item. */ protected function getItem() { return $this->item; } protected function setItem(core_kernel_classes_Resource $item) { $this->item = $item; } /** * Obtains a reference on the Zip Archive where the files related to the exported items will be stored. * * @return ZipArchive A created and open ZipArchive instance. */ public function getZip() { return $this->zip; } public function setZip(ZipArchive $zip) { $this->zip = $zip; } /** * Obtains a reference on the Item Model related to the currently exported item instance. * * @return core_kernel_classes_Container */ protected function getItemModel() { try { return $this->getItem()->getUniquePropertyValue(new core_kernel_classes_Property(taoItems_models_classes_ItemsService::PROPERTY_ITEM_MODEL)); } catch (common_Exception $e) { return null; } } protected function getItemDirectory() { return $this->getItemService()->getItemDirectory($this->getItem()); } /** * Add files or folders (and their content) to the Zip Archive that will contain all the files to the current export session. * For instance, if you want to copy the file 'taoItems/data/i123/item.xml' as 'myitem.xml' to your archive call addFile('path_to_item_location/item.xml', 'myitem.xml'). * As a result, you will get a file entry in the final ZIP archive at '/i123/myitem.xml'. * * @param string | StreamInterface $src The path to the source file or folder to copy into the ZIP Archive. * @param string *dest The relative to the destination within the ZIP archive. * @return integer The amount of files that were transfered from TAO to the ZIP archive within the method call. */ public function addFile($src, $dest) { $zip = $this->getZip(); return tao_helpers_File::addFilesToZip($zip, $src, $dest); } abstract public function export(); }