/** * 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(); }