예제 #1
0
 /**
  * Show disk usage
  *
  * @param   object   $model     Project model
  * @param   string   $repoName
  * @param   integer  $by
  * @return  string
  */
 public function diskspace($model, $repoName = 'local', $by = '')
 {
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'diskspace'));
     if (!isset($this->repo)) {
         $this->repo = new \Components\Projects\Models\Repo($model, $repoName);
     }
     $url = Route::url('index.php?option=' . $this->_option . '&alias=' . $model->get('alias') . '&active=files&action=diskspace');
     // Report usage with all history?
     if ($this->params->get('disk_usage') == true || $by == 'admin') {
         $view->dirsize = $this->repo->call('getDiskUsage', $params = array('working' => true, 'history' => true));
         $view->totalspace = $this->repo->call('getDiskUsage', $params = array('working' => false, 'history' => false));
     } else {
         $view->totalspace = $this->repo->call('getDiskUsage', $params = array('working' => false, 'history' => true));
         $view->dirsize = $view->totalspace;
     }
     // Get publication usage
     if (Plugin::isEnabled('projects', 'publications') && $by == 'admin') {
         require_once Component::path('com_publications') . DS . 'helpers' . DS . 'html.php';
         $filters = array();
         $filters['project'] = $model->get('id');
         $filters['ignore_access'] = 1;
         $filters['dev'] = 1;
         $database = \App::get('db');
         $objP = new \Components\Publications\Tables\Publication($database);
         $pubs = $objP->getRecords($filters);
         $view->pubDiskUsage = \Components\Publications\Helpers\Html::getDiskUsage($pubs);
         $view->pubQuota = $model->params->get('pubQuota') ? $model->params->get('pubQuota') : \Components\Projects\Helpers\Html::convertSize(floatval($model->config()->get('pubQuota', '1')), 'GB', 'b');
     }
     $view->total = $this->repo->count();
     $view->quota = $model->params->get('quota', \Components\Projects\Helpers\Html::convertSize(floatval($model->config()->get('defaultQuota', '1')), 'GB', 'b'));
     $view->by = $by;
     $view->model = $model;
     $view->option = $this->_option;
     $view->config = $model->config();
     $view->title = isset($this->_area['title']) ? $this->_area['title'] : '';
     $view->params = $this->params;
     return $view->loadTemplate();
 }
예제 #2
0
 /**
  * Get disk space
  *
  * @param      object  	$model
  *
  * @return     string
  */
 public function pubDiskSpace($model)
 {
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'diskspace'));
     // Include styling and js
     \Hubzero\Document\Assets::addPluginStylesheet('projects', 'files', 'diskspace');
     \Hubzero\Document\Assets::addPluginScript('projects', 'files', 'diskspace');
     $database = App::get('db');
     // Build query
     $filters = array();
     $filters['limit'] = Request::getInt('limit', 25);
     $filters['start'] = Request::getInt('limitstart', 0);
     $filters['sortby'] = Request::getVar('t_sortby', 'title');
     $filters['sortdir'] = Request::getVar('t_sortdir', 'ASC');
     $filters['project'] = $model->get('id');
     $filters['ignore_access'] = 1;
     $filters['dev'] = 1;
     // get dev versions
     // Instantiate project publication
     $objP = new \Components\Publications\Tables\Publication($database);
     // Get all publications
     $view->rows = $objP->getRecords($filters);
     // Get used space
     $view->dirsize = \Components\Publications\Helpers\Html::getDiskUsage($view->rows);
     $view->params = $model->params;
     $view->quota = $view->params->get('pubQuota') ? $view->params->get('pubQuota') : \Components\Projects\Helpers\Html::convertSize(floatval($model->config()->get('pubQuota', '1')), 'GB', 'b');
     // Get total count
     $view->total = $objP->getCount($filters);
     $view->project = $model;
     $view->option = $this->_option;
     $view->title = isset($this->_area['title']) ? $this->_area['title'] : '';
     return $view->loadTemplate();
 }