- private function setBrowserPath($path) {
- if(!empty($path)) {
- if($path == $this->browserUpDir['name']) {
- array_pop($_SESSION['restore_path']);
- } elseif($path == $this->browserRootDir['name']) {
- $_SESSION['restore_path'] = array();
- } else {
- array_push($_SESSION['restore_path'], $path);
- }
- }
- $this->setBrowserLocalizator();
- $this->prepareBrowserContent();
- }
-
- private function getBrowserPath($stringFormat = false) {
- return ($stringFormat === true) ? implode($_SESSION['restore_path']) : $_SESSION['restore_path'];
- }
-
- private function setBrowserLocalizator() {
- $localization = $this->getBrowserPath(true);
- $this->PathField->HeaderText = mb_strlen($localization) > 56 ? '...' . mb_substr($localization, -56) : $localization;
- }
-
- private function prepareBrowserContent() {
- $jobids = $this->getElementaryBackup();
-
- // generating Bvfs may takes a moment
- $this->generateBvfsCacheByJobids($jobids);
- $bvfsDirsList = $this->getModule('api')->set(array('bvfs', 'lsdirs'), array('jobids' => $jobids, 'path' => $this->getBrowserPath(true)));
- $bvfsDirs = is_object($bvfsDirsList) ? $bvfsDirsList->output : array();
- $dirs = $this->getModule('misc')->parseBvfsList($bvfsDirs);
- $bvfsFilesList = $this->getModule('api')->set(array('bvfs', 'lsfiles'), array('jobids' => $jobids, 'path' => $this->getBrowserPath(true)));
- $bvfsFiles = is_object($bvfsFilesList) ? $bvfsFilesList->output : array();
- $files = $this->getModule('misc')->parseBvfsList($bvfsFiles);
- $elements = array_merge($dirs, $files);
- if(count($this->getBrowserPath()) > 0) {
- array_unshift($elements, $this->browserRootDir);
- }
- $this->prepareBrowserFiles($elements);
- }
-
- private function getElementaryBackup() {
- $jobids = null;
- if($this->OnlySelectedBackupSelection->Checked === true) {
- $jobs = $this->getModule('api')->get(array('bvfs', 'getjobids', $this->BackupToRestore->SelectedValue));
- $ids = is_object($jobs) ? $jobs->output : array();
- foreach($ids as $jobid) {
- if(preg_match('/^([\d\,]+)$/', $jobid, $match) == 1) {
- $jobids = $match[1];
- break;
- }
- }
- } else {
- $jobsRecent = $this->getModule('api')->get(array('jobs', 'recent', $this->GroupBackupToRestore->SelectedValue, $this->BackupClientName->SelectedValue));
- if(isset($jobsRecent->output) && count($jobsRecent->output) > 0) {
- $ids = $jobsRecent->output;
- $jobids = implode(',', $ids);
- }
- }
-
- $completeJobids = (!is_null($jobids)) ? $jobids : $this->BackupToRestore->SelectedValue;
- return $completeJobids;
- }
-
- private function generateBvfsCacheByJobids($jobids) {
- $this->getModule('api')->set(array('bvfs', 'update'), array('jobids' => $jobids));
- }
-
- private function setFileVersions($versions) {
+ /**
+ * Set file browser path field.
+ *
+ * @return none
+ */
+ private function setBrowserPath() {
+ $this->PathField->Text = implode($_SESSION['restore_path']);
+ }
+
+ /**
+ * Generate Bvfs cache by job identifiers.
+ *
+ * @param string $jobids comma separated job identifiers
+ * @return none
+ */
+ private function generateBvfsCache($jobids) {
+ $this->getModule('api')->set(
+ array('bvfs', 'update'),
+ array('jobids' => $jobids)
+ );
+ }
+
+ /**
+ * Set versions for selected file.
+ *
+ * @param array $versions file versions data
+ * @return none
+ */
+ private function setFileVersions($versions = array()) {