/** * Process plugins in a package. * * @deprecated removed for J! 1.6 * * @throws Exception * @return EcrProjectManifest */ private function processPackagePlugins() { if (0 == count($this->project->plugins)) { return $this; } $pluginsElement = $this->manifest->addChild('plugins'); foreach ($this->project->plugins as $item) { //-- Get the project $project = EcrProjectHelper::getProject('plg_' . $item->scope . '_' . $item->name); $f = JPATH_ROOT . DS . EcrProjectHelper::findManifest($project); $plgElement = $pluginsElement->addChild('plugin'); $plgElement->addAttribute('plugin', $item->name); $plgElement->addAttribute('group', $item->scope); $plgElement->addAttribute('title', $item->title); if ($item->ordering) { $plgElement->addAttribute('order', $item->ordering); } $plgFilesElement = $plgElement->addChild('files'); $plgFilesElement->addAttribute('folder', 'plg_' . $item->scope . '_' . $item->name); foreach ($project->copies as $copy) { if (JFolder::exists($copy)) { $tName = str_replace('plugins' . DS . $item->scope . DS, '', $copy); $plgFolderElement = $plgFilesElement->addChild('folder', $tName); } else { if (JFile::exists($copy)) { $plgFileElement = $plgFilesElement->addChild('file', JFile::getName($copy)); } else { //-- @todo error $this->_addLog('Not found<br />SRC: ' . $copy, 'FILE NOT FOUND'); } } } if (count($project->langs)) { $plgLangsElement = $plgElement->addChild('languages'); $plgLangsElement->addAttribute('folder', 'plg_' . $item->scope . '_' . $item->name . '/language'); foreach ($project->langs as $tag => $scopes) { $plgFileElement = $plgLangsElement->addChild('language', $tag . '.' . $project->getLanguageFileName()); $plgFileElement->addAttribute('tag', $tag); } } $xml = EcrProjectHelper::getXML($f); if (false == $xml) { throw new Exception(sprintf(jgettext('Unable to load the xml file %s'), $f)); } $paramsElement = $plgElement->addChild('params'); if (isset($xml->params->param)) { foreach ($xml->params->param as $param) { $paramElement = $paramsElement->addChild('param'); foreach ($param->attributes() as $name => $value) { $paramElement->addAttribute($name, (string) $value); } if (isset($param->option)) { foreach ($param->option as $option) { $optionElement = $paramElement->addChild('option', (string) $option); foreach ($option->attributes() as $Name => $Value) { $optionElement->addAttribute($Name, (string) $Value); } } } } } } return $this; }
/** * Build a list of files to search for translation strings. * * @return void */ private function _buildFileList() { $scope = $this->_scope; $type = ''; if (strpos($scope, '_')) { $parts = explode('_', $scope); $type = $parts[0]; $scope = $parts[1]; } foreach ($this->project->copies as $copyItem) { if ($scope == 'admin') { //--admin scope - only load files from folders starting with 'admin' if ($this->project->type != 'plugin' && strpos($copyItem, JPATH_ADMINISTRATOR) === false) { continue; } } else { //--site scope - only load files from folders NOT starting with 'admin' if (strpos($copyItem, JPATH_ADMINISTRATOR) === 0) { continue; } } if (JFolder::exists($copyItem)) { //--Add all PHP and XML files from a given folder if (isset($this->project->buildOpts['lng_separate_javascript']) && $this->project->buildOpts['lng_separate_javascript']) { $filter = $type == 'js' ? '\\.js$' : '\\.php$|\\.xml$'; } else { $filter = '\\.php$|\\.xml$|\\.js$'; } $files = JFolder::files($copyItem, $filter, true, true); $this->_fileList = array_merge($this->_fileList, $files); } else { if (JFile::exists($copyItem)) { //--Add a single file if (!in_array($copyItem, $this->_fileList)) { $this->_fileList[] = $copyItem; } } } } //foreach if ($type != 'js') { $manifest = EcrProjectHelper::findManifest($this->project); if ($manifest && !in_array(JPATH_ROOT . DS . $manifest, $this->_fileList)) { $this->_fileList[] = JPATH_ROOT . DS . $manifest; } } if (!count($this->_fileList)) { return; } foreach ($this->_fileList as $fileName) { $definitions = $this->getKeys($fileName); foreach ($definitions as $definition => $fileName) { $this->_addDefinition($definition, $fileName); } //foreach } //foreach }
/** * Write the Joomla! manifest file. * * @return boolean */ private function writeJoomlaManifest() { $installXML = EcrProjectHelper::findManifest($this); $xmlBuildVars = array('version', 'description', 'author', 'authorEmail', 'authorUrl', 'license', 'copyright'); $manifest = EcrProjectHelper::getXML(JPATH_ROOT . DS . $installXML); if (false == $manifest) { JFactory::getApplication()->enqueueMessage(sprintf(jgettext('Can not load xml file %s'), $installXML), 'error'); return false; } if ($this->method) { if ($manifest->attributes()->method) { $manifest->attributes()->method = $this->method; } else { $manifest->addAttribute('method', $this->method); } } else { //-- Set the method to empty if ($manifest->attributes()->method) { $manifest->attributes()->method = ''; } } //-- Process credit vars foreach ($xmlBuildVars as $xmlName) { $manifest->{$xmlName} = $this->{$xmlName}; } $dtd = $this->getDTD($this->JCompat); $root = ''; $root .= '<?xml version="1.0" encoding="UTF-8"?>' . NL; if ($dtd) { $root .= '<!DOCTYPE ' . $dtd['type'] . ' PUBLIC "' . $dtd['public'] . '"' . NL . '"' . $dtd['uri'] . '">'; } $output = $root . $manifest->asFormattedXML(); //-- Write XML file to disc if (false == JFile::write(JPATH_ROOT . DS . $installXML, $output)) { JFactory::getApplication()->enqueueMessage(jgettext('Unable to write file'), 'error'); JFactory::getApplication()->enqueueMessage(JPATH_ROOT . DS . $installXML, 'error'); return false; } if (ECR_DEBUG) { $screenOut = $output; $screenOut = str_replace('<', '<', $screenOut); $screenOut = str_replace('>', '>', $screenOut); echo '<div class="ecr_debug">'; echo '<pre>' . $screenOut . '</pre>'; echo '</div>'; } return true; }
/** * 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; }