protected function setUp() { defined('ECR_DEBUG') or define('ECR_DEBUG', 0); defined('JPATH_COMPONENT') or define('JPATH_COMPONENT', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_easycreator'); require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'projecthelper.php'; require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'html.php'; $this->project = EcrProjectHelper::newProject('empty'); }
/** * Standard display method. * * @param null|string $tpl The name of the template file to parse; * * @return mixed|void */ public function display($tpl = null) { $input = JFactory::getApplication()->input; $task = $input->get('task'); $this->builder = new EcrProjectBuilder(); ecrLoadMedia('wizard'); $params = JComponentHelper::getParams('com_easycreator'); $this->templateList = EcrProjectTemplateHelper::getTemplateList(); $tplType = $input->get('tpl_type'); $tplFolder = $input->get('tpl_name'); $desc = isset($this->templateList[$tplType][$tplFolder]) ? $this->templateList[$tplType][$tplFolder]->description : ''; $project = EcrProjectHelper::newProject('empty'); $project->type = $input->get('tpl_type'); $project->tplName = $input->get('tpl_name'); $project->version = $input->getString('version', '1.0'); $project->description = $input->getString('description', $desc); $project->listPostfix = $input->get('list_postfix', 'List'); $project->JCompat = $input->getString('jcompat'); //-- Sanitize project name $project->name = $input->get('com_name'); $disallows = array('_'); $project->name = str_replace($disallows, '', $project->name); //-- Credits $s = $input->getString('author'); $project->author = $s ? $s : $params->get('cred_author'); $s = $input->getString('authorEmail'); $project->authorEmail = $s ? $s : $params->get('cred_author_email'); $s = $input->getString('authorUrl'); $project->authorUrl = $s ? $s : $params->get('cred_author_url'); $s = $input->getString('license'); $project->license = $s ? $s : $params->get('cred_license'); $s = $input->getString('copyright'); $project->copyright = $s ? $s : $params->get('cred_copyright'); $this->project = $project; if ($task && method_exists($this, $task)) { $this->{$task}(); } parent::display($tpl); EcrHtml::formEnd(); }
/** * 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; }