/** * @return \stdClass */ private function getG11nInfo() { $info = new stdClass(); $this->languages = Ecrg11nHelper::getLanguages(); $baseLink = ''; $info->scope = $this->project->scope ? $this->project->scope : 'admin'; $info->id = $this->project->dbId; $info->extension = $this->project->comName; switch ($this->project->type) { case 'component': $comName = $this->project->comName; break; case 'plugin': $comName = 'plg_content_' . $this->project->comName; break; case 'template': $comName = 'tpl_' . $this->project->comName; break; default: echo 'undefined type: ' . $this->project->type; $comName = $this->project->comName; break; } //switch $info->exists = g11nExtensionHelper::isExtension($comName, $info->scope); $info->templateLink = $info->exists ? $baseLink . '&task=g11n.createTemplate&extension=' . $this->project->comName : ''; $cachedFiles = Ecrg11nHelper::getCachedFiles(); $this->scopes = array('admin' => JPATH_ADMINISTRATOR, 'site' => JPATH_SITE); $baseLink = 'index.php?option=com_g11n'; $info->editLink = $baseLink . '&task=g11n.edit'; $info->templateCommands = array(); $info->updateLinks = array(); $info->cacheLinks = array(); $types = array(''); $options = new JRegistry($this->project->buildOpts); if ('ON' == $options->get('lng_separate_javascript')) { $types[] = '.js'; } $types[] = '.config'; $extensionName = $this->project->comName; if (strpos($extensionName, '.')) { $extensionName = substr($extensionName, 0, strpos($extensionName, '.')); } foreach ($this->scopes as $scope => $path) { foreach ($types as $type) { if ('.config' == $type && 'admin' != $scope) { continue; } $scopeType = $scope . $type; if (!isset($this->languages[$scopeType])) { $this->languages[$scopeType] = $this->languages[$scope]; } try { $info->templateExists[$scopeType] = g11nStorage::templateExists($comName . $type, $scope); } catch (Exception $e) { $info->templateCommands[$scopeType] = $e->getMessage(); $info->templateLink = ''; } //try try { $info->templateStatus[$scopeType] = g11nStorage::templateExists($comName . $type, $scope); } catch (Exception $e) { $info->templateStatus[$scopeType] = $e->getMessage(); echo ''; } //try foreach ($this->languages[$scopeType] as $lang) { $exists = g11nExtensionHelper::findLanguageFile($lang['tag'], $comName . $type, $scope); $info->fileStatus[$scopeType][$lang['tag']] = $exists ? true : false; // g11nExtensionHelper::findLanguageFile($lang['tag'] // , $item->extension, $scope); $link = $baseLink . '&task=utility.updateLanguage'; $link .= '&extension=' . $info->extension . '&scope=' . $scope; $link .= '&langTag=' . $lang['tag']; $info->updateLinks[$scopeType][$lang['tag']] = $link; if (!array_key_exists($extensionName, $cachedFiles) || !array_key_exists($scope, $cachedFiles[$extensionName])) { $info->cacheStatus[$scopeType][$lang['tag']] = false; continue; } $info->cacheStatus[$scopeType][$lang['tag']] = false; $fName = $lang['tag'] . '.' . $this->project->comName; foreach ($cachedFiles[$extensionName][$scope] as $file) { if (strpos($file, $fName) === 0) { $info->cacheStatus[$scope][$lang['tag']] = true; } } //foreach } //foreach } //foreach } return $info; }
public function g11nCreateTemplate() { $input = JFactory::getApplication()->input; try { $project = EcrProjectHelper::getProject(); $scope = $input->get('scope'); switch ($project->type) { case 'template': $comName = 'tpl_' . $project->comName; break; default: $comName = $project->comName; break; } $parts = explode('.', $scope); if (2 == count($parts)) { $scope = $parts[0]; $comName .= '.' . $parts[1]; } Ecrg11nHelper::createTemplate($comName, $scope, $project->version); } catch (Exception $e) { JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error'); } $input->set('task', 'g11nUpdate'); parent::display(); }