Example #1
0
 /**
  * 
  * @return string owner of the current file item
  * @throws \Exception
  */
 public function getOwnerViewAndPath()
 {
     if ($this->isPublicShare()) {
         $rootLinkItem = \OCP\Share::resolveReShare($this->sharing[0]);
         if (isset($rootLinkItem['uid_owner'])) {
             $owner = $rootLinkItem['uid_owner'];
         } else {
             throw new \Exception($this->fileId . ' is a broken share');
         }
         $view = new View('/' . $owner . '/files');
         $path = $rootLinkItem['file_target'];
     } else {
         $owner = \OCP\User::getUser();
         $view = new View('/' . $this->owner);
         $path = $view->getPath($this->fileId);
     }
     if (!$path) {
         throw new \Exception($this->fileId . ' can not be resolved');
     }
     $this->path = $path;
     $this->owner = $owner;
     if (!$view->file_exists($this->path)) {
         throw new \Exception($this->path . ' doesn\'t exist');
     }
     return array($view, $this->path);
 }
Example #2
0
 /**
  * 
  * @return string owner of the current file item
  * @throws \Exception
  */
 public function getOwnerViewAndPath($useDefaultRoot = false)
 {
     if ($this->isPublicShare()) {
         $rootLinkItem = \OCP\Share::resolveReShare($this->sharing[0]);
         if (isset($rootLinkItem['uid_owner'])) {
             $owner = $rootLinkItem['uid_owner'];
             \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
             \OC_Util::tearDownFS();
             \OC_Util::setupFS($rootLinkItem['uid_owner']);
         } else {
             throw new \Exception($this->fileId . ' is a broken share');
         }
         $view = new View('/' . $owner . '/files');
     } else {
         $owner = \OCP\User::getUser();
         $root = '/' . $owner;
         if ($useDefaultRoot) {
             $root .= '/' . 'files';
         }
         $view = new View($root);
     }
     $path = $view->getPath($this->fileId);
     if (!$path) {
         throw new \Exception($this->fileId . ' can not be resolved');
     }
     $this->path = $path;
     $this->owner = $owner;
     if (!$view->file_exists($this->path)) {
         throw new \Exception($this->path . ' doesn\'t exist');
     }
     return array($view, $this->path);
 }
Example #3
0
use infrajs\view\view;
//Template::$conf['root']=URN::getAbsRoot();
//Sequence::set(Template::$scope, array('~root'), Template::$conf['root']);
Template::$fs['load'] = function ($src) {
    return Load::loadTEXT($src);
};
$fn2 = function ($name = null) {
    return $conf = Config::pub($name);
};
Sequence::set(Template::$scope, array('infra', 'config'), $fn2);
Sequence::set(Template::$scope, array('Config', 'get'), $fn2);
Event::one('Controller.oninit', function () {
    Template::$scope['~conf'] = Config::get();
});
$fn3 = function () {
    return View::getPath();
};
Sequence::set(Template::$scope, array('infra', 'view', 'getPath'), $fn3);
$fn4 = function () {
    return View::getHost();
};
Sequence::set(Template::$scope, array('infra', 'view', 'getHost'), $fn4);
$fn5 = function ($s) {
    return Sequence::short($s);
};
Sequence::set(Template::$scope, array('infra', 'seq', 'short'), $fn5);
$fn6 = function ($s) {
    return Sequence::right($s);
};
Sequence::set(Template::$scope, array('infra', 'seq', 'right'), $fn6);
$fn7 = function () {