コード例 #1
0
ファイル: dbupdater.php プロジェクト: cuongnd/etravelservice
 /**
  * Constructor.
  *
  * @param EcrProjectBase $project
  * @param string         $adapter
  */
 public function __construct(EcrProjectBase $project, $adapter = 'mysql')
 {
     if (class_exists('easyLogger')) {
         $this->logger = EcrLogger::getInstance('ecr');
     }
     if (!$this->setAdapter($adapter)) {
         return false;
     }
     $buildsPath = $project->getZipPath();
     $this->log('Looking for versions in ' . $buildsPath);
     if (false == JFolder::exists($buildsPath)) {
         return;
     }
     $folders = JFolder::folders($buildsPath);
     $this->log(sprintf('Found %d version(s) ', count($folders)));
     if (!$folders) {
         return;
     }
     $this->versions = $folders;
     $this->project = $project;
 }
コード例 #2
0
ファイル: stuffer.php プロジェクト: cuongnd/etravelservice
 /**
  * Creates install files.
  *
  * @throws Exception
  * @return void
  */
 public function create_install_file()
 {
     $input = JFactory::getApplication()->input;
     $type1 = $input->get('type1');
     $type2 = $input->get('type2');
     $input->set('task', 'install');
     if (!$type1 || !$type2) {
         EcrHtml::message(__METHOD__ . ' - Missing values', 'error');
         parent::display();
         return;
     }
     try {
         //-- Get the project
         $project = EcrProjectHelper::getProject();
         $installPath = JPATH_ADMINISTRATOR . DS . 'components' . DS . $project->comName . DS . 'install';
         //-- Init buildopts
         $buildopts = $input->get('buildopts', array(), 'array');
         //-- Setup logging
         $buildopts['fileName'] = date('ymd_Hi') . '_' . $type1 . '_' . $type2 . '.log';
         $this->logger = EcrLogger::getInstance('ecr', $buildopts);
         $this->logger->log('Start: ' . $type1 . ' - ' . $type2);
         if (false == JFolder::exists($installPath)) {
             if (false == JFolder::create($installPath)) {
                 throw new Exception('Unable to create install folder ' . $installPath);
             }
             $this->logger->log('Folder created: ' . $installPath);
         }
         //-- PHP or SQL
         switch ($type1) {
             case 'php':
                 //-- Install or uninstall
                 switch ($type2) {
                     case 'install':
                         EcrHtml::message(__METHOD__ . ' Unfinished install php', 'notice');
                         break;
                     case 'uninstall':
                         EcrHtml::message(__METHOD__ . ' Unfinished uninstall php', 'notice');
                         break;
                     default:
                         throw new Exception('Unknown type: ' . $type1 . ' - ' . $type2);
                         break;
                 }
                 break;
             case 'sql':
                 //-- Install or uninstall
                 switch ($type2) {
                     case 'install':
                     case 'uninstall':
                     case 'update':
                         $f = 'process' . $type1 . $type2;
                         $this->{$f}($project, $installPath);
                         break;
                     default:
                         throw new Exception('Unknown type: ' . $type1 . ' - ' . $type2);
                         break;
                 }
                 break;
             default:
                 EcrHtml::message('Unknown type: ' . $type1, 'error');
                 break;
         }
     } catch (EcrExceptionLog $e) {
         EcrHtml::message($e);
         parent::display();
         return;
     } catch (Exception $e) {
         EcrHtml::message($e);
         $this->logger->log($e->getMessage(), 'exception');
     }
     $this->logger->log('Finished =;)');
     $this->logger->writeLog();
     echo $this->logger->printLogBox();
     parent::display();
 }
コード例 #3
0
ファイル: ziper.php プロジェクト: cuongnd/etravelservice
 /**
  * Create the package.
  *
  * @param EcrProjectBase             $project The project
  * @param EcrProjectModelBuildpreset $preset
  * @param array                      $buildOpts
  *
  * @return bool true on success
  */
 public function create(EcrProjectBase $project, EcrProjectModelBuildpreset $preset, array $buildOpts)
 {
     $this->project = $project;
     $this->preset = $preset;
     //snew EcrProjectModelBuildpreset($buildOpts);
     //@todo PHP 5.3
     $this->build_dir = $preset->buildFolder ? $preset->buildFolder : $this->project->getZipPath();
     //-- Init buildopts
     $this->initBuildOpts($buildOpts);
     //-- Setup logging
     $buildOpts['fileName'] = date('ymd_Hi') . '_packing.log';
     $this->logger = EcrLogger::getInstance('ecr', $buildOpts);
     $this->logger->log('Start building');
     $this->logger->log('Build dir:<br />' . $this->build_dir);
     try {
         $this->setTempDir()->logStep(1)->performActions('precopy')->logStep(2)->copyCopies()->copyLanguage()->processInstall()->copyMedia()->logStep(3)->copyPackageElements()->logStep(4)->cleanProject()->logStep(6)->performActions('postcopy')->logStep(7)->deleteManifest()->createMD5()->createManifest()->logStep(8)->createArchive()->logStep(9)->performActions('postbuild')->removeBuildDir()->logStep(10);
     } catch (EcrExceptionZiper $e) {
         $this->logger->log('ABORT: ' . $e->getMessage(), 'ERROR', JLog::ERROR);
         $this->logger->writeLog();
         $this->setError('ERROR: ' . $e->getMessage());
         return false;
     }
     $this->logger->log('FINISHED');
     if (false == $this->validBuild) {
         $this->logger->log('*** FAILURE ***', '', JLog::ERROR);
         $this->logger->log('The package has NOT been build due to the following errors:', 'error', JLog::ERROR);
         foreach ($this->failures as $failure) {
             $this->logger->log($failure, '', JLog::ERROR);
         }
     }
     $this->logger->writeLog();
     return true;
 }
コード例 #4
0
ファイル: builder.php プロジェクト: cuongnd/etravelservice
 /**
  * Register an existing project.
  *
  * @param string $type  Project type
  * @param string $name  Project name
  * @param string $scope Project scope e.g. admin, site
  *
  * @return EcrProjectBase on success | false on error
  */
 public function registerProject($type, $name, $scope = '')
 {
     //--Get component parameters
     $comParams = JComponentHelper::getParams('com_easycreator');
     //-- Setup logging
     $options = array();
     $opts = array('logging', 'hotlogging', 'files', 'profile');
     foreach ($opts as $o) {
         if ($comParams->get($o)) {
             $options[] = $o;
         }
     }
     $options['fileName'] = date('ymd_Hi') . '_register.log';
     $this->logger = EcrLogger::getInstance('ecr', $options);
     if (false == array_key_exists($type, EcrProjectHelper::getProjectTypes())) {
         JFactory::getApplication()->enqueueMessage(sprintf(jgettext('The project type %s is not defined yet'), $type), 'error');
         $this->setError(sprintf(jgettext('The project type %s is not defined yet'), $type));
         return false;
     }
     $project = EcrProjectHelper::newProject($type);
     $project->comName = $name;
     $project->scope = $scope;
     foreach (EcrEasycreator::$packFormats as $name => $ext) {
         if ($comParams->get($name)) {
             $project->buildOpts[$name] = '1';
         }
     }
     for ($i = 1; $i < 5; $i++) {
         $project->buildOpts['custom_name_' . $i] = $comParams->get('custom_name_' . $i);
     }
     //-- Set the Joomla! compatibility version to the version we are actually running on
     $project->JCompat = ECR_JVERSION;
     $xmlPath = EcrProjectHelper::findManifest($project);
     if (false == $xmlPath) {
         JFactory::getApplication()->enqueueMessage(jgettext('No manifest file found'), 'error');
         $this->setError(jgettext('No manifest file found'));
         return false;
     }
     $data = EcrProjectHelper::parseXMLInstallFile(JPATH_ROOT . DS . $xmlPath);
     $project->name = $data->name;
     $this->logger->log('Registering: ' . $project->type . ' - ' . $project->name . '<br />' . 'aka "' . $project->comName . '"<br />scope: ' . $project->scope);
     $pXml = $project->update();
     if (false == $pXml) {
         $this->logger->log('', 'Unable to create EasyCreator manifest');
         $this->logger->writeLog();
         return false;
     } else {
         $this->logger->log('EasyCreator manifest created');
         $this->logger->logFileWrite('', '', $pXml);
     }
     $this->logger->log('FINISHED');
     $this->logger->writeLog();
     return $project;
 }