<?php
class Library_Virtual_Document extends Library_Virtual_Abstract {
	/**
	 * Objekt s radkem tabulky
	 * @var Zend_Db_Table_Row_Abstract
	 */
	private $_thisRow;
	
	public function __construct(Zend_Db_Table_Row_Abstract $row, Library_Virtual_Abstract $parent, $name = null) {
		$this->_thisRow = $row;
		
		if (!$name) {
			$name = $row->document_name;
		}
		
		parent::__construct($name, $parent);
	}
	
	public function addToArchive(ZipArchive $archive) {
		//nacteni cesty
		$path = $this->getPath();
		
		//kontorla existence dokumentu
		if (!is_file(APPLICATION_PATH . "/../contents/" . $this->_thisRow->uuid)) {
			return $this;
		}
		
		//zapsani souboru
		$archive->addFile(APPLICATION_PATH . "/../contents/" . $this->_thisRow->uuid, "/" . $path);
		
		return $this;
	}
	
	public function getUuid() {
		return $this->_thisRow->uuid;
	}
}