Пример #1
0
 function upload()
 {
     // Initialise variables.
     $app = JFactory::getApplication('administrator');
     $this->setState('action', 'upload');
     switch (JRequest::getWord('installtype')) {
         case 'folder':
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             JError::raiseWarning(100, JText::_('NO_UPLOAD_TYPE_FOUND'));
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         JError::raiseWarning(100, JText::_('UNABLE_TO_FIND_INSTALL_PACKAGE'));
         return false;
     }
     // Get an ja extension uploader instance
     $uploader = jaExtUploader::getInstance();
     $result = $uploader->upload($package['dir']);
     if (!$result) {
         // There was an error uploading the package
         $msg = JText::sprintf('THERE_WAS_AN_ERROR_UPLOADING_THE_PACKAGE_S', $package['type']);
         JError::raiseWarning(100, $msg);
         //$result = false;
     } else {
         // Package uploaded sucessfully
         $msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', $package['type']);
         //$result = true;
     }
     // Cleanup the install files
     if (!JFile::exists($package['packagefile'])) {
         $config = JFactory::getConfig();
         $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
Пример #2
0
 function upload()
 {
     global $mainframe;
     $this->setState('action', 'upload');
     switch (JRequest::getWord('installtype')) {
         case 'folder':
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             JError::raiseWarning(100, JText::_('No Upload Type Found'));
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         JError::raiseWarning(100, JText::_('Unable to find install package'));
         return false;
     }
     // Get an ja extension uploader instance
     $uploader =& jaExtUploader::getInstance();
     $result = $uploader->upload($package['dir']);
     // Cleanup the install files
     if (!is_file($package['packagefile'])) {
         $config =& JFactory::getConfig();
         $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     //
     return $result;
 }