* @package extension * @version $Id$ * @link http://www.zentao.net */ class extension extends control { /** * Browse extensions. * * @param string $type browse type. * @access public * @return void */ public function browse($type = 'installed') { $this->view->header->title = $this->lang->extension->browse; $this->view->position[] = $this->lang->extension->browse; $this->view->tab = $type; $this->display(); } /** * Obtain an extension from the community. * * @param string $type * @param string $param * @access public * @return void */ public function obtain($type = 'byDownloads', $param = '', $recTotal = 0, $recPerPage = 10, $pageID = 1) { /* Init vars. */ $type = strtolower($type); $moduleID = $type == 'bymodule' ? (int)$param : 0; $extensions = array(); $pager = null; /* Get results from the api. */ $results = $this->extension->getExtensionsByAPI($type, $param, $recTotal, $recPerPage, $pageID); if($results) { $this->app->loadClass('pager', $static = true); $pager = new pager($results->dbPager->recTotal, $results->dbPager->recPerPage, $results->dbPager->pageID); $extensions = $results->extensions; } $this->view->moduleTree = $this->extension->getModulesByAPI(); $this->view->extensions = $extensions; $this->view->pager = $pager; $this->view->tab = 'obtain'; $this->view->type = $type; $this->view->moduleID = $moduleID; $this->display(); } /** * Install a extension * * @param string $extension * @param string $downLink * @param string $md5 * @param string $forceInstall * @access public * @return void */ public function install($extension, $downLink = '', $md5 = '', $forceInstall = 'no') { $this->view->error = ''; $this->view->header->title = $this->lang->extension->install . $this->lang->colon . $extension; /* Get the package file name. */ $packageFile = $this->extension->getPackageFile($extension); if($downLink) { /* Checking download path. */ $return = $this->extension->checkDownloadPath(); if($return->result != 'ok') { $this->view->error = $return->error; die($this->display()); } /* Check file exists or not. */ if(file_exists($packageFile) and $forceInstall == 'no') { $forceInstallLink = inlink('install', "extension=$extension&downLink=$downLink&md5=$md5&forecInstall=yes"); $this->view->error = sprintf($this->lang->extension->errorPackageFileExists, $packageFile, $forceInstallLink); die($this->display()); } /* Download the package file. */ $this->extension->downloadPackage($extension, helper::safe64Decode($downLink)); if(!file_exists($packageFile)) { $this->view->error = sprintf($this->lang->extension->errorDownloadFailed, $packageFile); die($this->display()); } elseif(md5_file($packageFile) != $md5) { $this->view->error = sprintf($this->lang->extension->errorMd5Checking, $packageFile); die($this->display()); } } /* Check the package file exists or not. */ if(!file_exists($packageFile)) { $this->view->error = sprintf($this->lang->extension->errorPackageNotFound, $packageFile); die($this->display()); } /* Checking the extension path. */ $return = $this->extension->checkExtensionPathes($extension); if($return->result != 'ok') { $this->view->error = $return->errors; die($this->display()); } /* Extract the package. */ $this->extension->extractPackage($extension); $this->extension->copyPackageFiles($extension); } public function uninstall() { } public function activate() { } public function deactivate() { } }