/** * Event call to return data for a specific project * * @param object $model Project model * @param string $action Plugin task * @param string $areas Plugins to return data * @return array Return array of html */ public function onProject($model, $action = '', $areas = null, $params = array()) { $returnhtml = true; $arr = array('html' => '', 'metadata' => ''); // Get this area details $this->_area = $this->onProjectAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (empty($this->_area) || !in_array($this->_area['name'], $areas)) { return; } } // Project model $this->model = $model; // Check authorization if ($this->model->exists() && !$this->model->access('member')) { return $arr; } // Are we returning HTML? if ($returnhtml) { // Load repo model $repoName = !empty($params['repo']) ? $params['repo'] : Request::getVar('repo', 'local'); $this->repo = new \Components\Projects\Models\Repo($this->model, $repoName); $default = $this->params->get('default_action', 'browse'); $this->_publishing = Plugin::isEnabled('projects', 'publications') ? 1 : 0; $this->_database = \App::get('db'); $this->_uid = User::get('id'); $this->_task = $action ? $action : Request::getVar('action', $default); $this->subdir = trim(urldecode(Request::getVar('subdir', '')), DS); $this->publication = Request::getInt('pid', 0); // Set repo path if (!$this->model->exists()) { // Contribute process outside of projects $this->model->set('provisioned', 1); $this->_path = $this->getMembersPath(); } else { if (!$this->repo->exists()) { // Default to local repo (will redirect to add repo page in the future) $this->repo = new \Components\Projects\Models\Repo($this->model, 'local'); } $this->_path = $this->repo->get('path'); } // Establish connection to external services if ($this->model->exists() && !$this->model->isProvisioned()) { $this->_connect = new \Components\Projects\Helpers\Connect($this->model, $this->_uid, date_default_timezone_get()); // Sync service is Google if (!empty($this->_connect->_active) && $this->repo->isLocal()) { $this->_remoteService = 'google'; } } $ctask = 'connections'; if (($connection = Request::getInt('connection', null)) || $this->_task == 'editconnection' || $this->_task == 'saveconnection' || $this->_task == 'newconnection' || $this->_task == 'deleteconnection' || $this->_task == 'refreshconnection') { $ctask = $this->_task; $this->_task = 'connections'; } // File actions switch ($this->_task) { // Basic file management case 'upload': $arr['html'] = $this->_upload(); break; case 'save': case 'saveprov': $arr['html'] = $this->_save(); break; case 'delete': case 'removeit': $arr['html'] = $this->_delete(); break; case 'move': case 'moveit': $arr['html'] = $this->_move(); break; case 'rename': case 'renameit': $arr['html'] = $this->_rename(); break; case 'share': case 'shareit': $arr['html'] = $this->_share(); break; // History // History case 'history': $arr['html'] = $this->_history(); break; case 'diff': $arr['html'] = $this->_diff(); break; // Serve/preview // Serve/preview case 'compile': $arr['html'] = $this->_compile(); break; case 'serve': $arr['html'] = $this->serve(); break; case 'download': case 'open': $arr['html'] = $this->_download(); break; // Manage directory // Manage directory case 'newdir': $arr['html'] = $this->_newDir(); break; case 'deletedir': $arr['html'] = $this->_deleteDir(); break; case 'savedir': $arr['html'] = $this->_saveDir(); break; // Manage deleted // Manage deleted case 'trash': $arr['html'] = $this->_showTrash(); break; case 'restore': $arr['html'] = $this->_restore(); break; // Disk space management // Disk space management case 'diskspace': $arr['html'] = $this->diskspace($this->model, $this->repo->get('name'), $this->_uid); break; case 'optimize': case 'advoptimize': $arr['html'] = $this->optimize($this->model, $this->repo->get('name')); break; // Publishing selectors // Publishing selectors case 'select': case 'filter': $arr['html'] = $this->_select(); break; // Connections // Connections case 'connect': case 'disconnect': $arr['html'] = $this->_connect(); break; // Sync with remote // Sync with remote case 'sync': $arr['html'] = $this->_iniSync(); break; case 'sync_status': $arr['html'] = $this->syncStatus(); break; case 'sync_error': $arr['html'] = $this->syncError(); break; // New connected methods // New connected methods case 'connections': require_once __DIR__ . DS . 'connections.php'; $controller = new connections($this, $this->_option, $connection); $arr['html'] = $controller->execute($ctask); break; // File browser // File browser case 'browse': default: $arr['html'] = $this->_browse(); break; } } // Return data return $arr; }