richdocuments/lib/view.php

49 lines
1.3 KiB
PHP
Raw Normal View History

2013-08-07 21:14:36 +03:00
<?php
2013-08-08 00:22:21 +03:00
/**
* ownCloud - Office App
*
* @author Victor Dubiniuk
* @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/
2013-08-07 21:14:36 +03:00
namespace OCA\Office;
class View extends \OC\Files\View{
const OFFICE_DIRNAME='/office';
protected static $officeView;
public static function initOfficeView($uid){
$view = new \OC\Files\View('/' . $uid);
if (!$view->is_dir(self::OFFICE_DIRNAME)) {
$view->mkdir(self::OFFICE_DIRNAME);
}
2013-08-08 00:08:20 +03:00
//if (!self::$officeView){
// self::$officeView = new \OC\Files\View('/' . $uid . self::OFFICE_DIRNAME);
//}
2013-08-07 21:14:36 +03:00
2013-08-08 00:08:20 +03:00
// it was a bad idea to use a static method.
// to be changed later
return new \OC\Files\View('/' . $uid . self::OFFICE_DIRNAME);
2013-08-07 21:14:36 +03:00
}
public static function storeDocument($uid, $path){
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
2013-08-08 00:08:20 +03:00
$newName = '/' . self::getHashByGenesis($uid, $path) . '.odt';
$view = new \OC\Files\View('/' . $uid);
$view->copy('/files' . $path, self::OFFICE_DIRNAME . $newName);
2013-08-07 21:14:36 +03:00
\OC_FileProxy::$enabled = $proxyStatus;
2013-08-08 00:08:20 +03:00
return $newName;
}
public static function getHashByGenesis($uid, $genesisPath){
$officeView = self::initOfficeView($uid);
return sha1($officeView->file_get_contents($genesisPath));
2013-08-07 21:14:36 +03:00
}
}