Build the file name for the language database

@param   string  $lang           The language code to use
@param   string  $db_filename    A base filename to use
@return  string  The file name for the concerned language
480155
public function buildLanguageFileName($lang, $db_filename = null)
    {
        if (empty($db_filename)) {
            $db_filename = $this->getParsedOption('language_strings_db_filename');
        }
        $filename = pathinfo($db_filename,  PATHINFO_FILENAME);
        return $this->getParsedOption('language_filename', array($filename, $lang));
    }
807986
protected function getDatabaseSchemata(string $dbName): array
    {
        $sql = 'SELECT
            default_character_set_name,
            default_collation_name
            FROM information_schema.SCHEMATA
            WHERE schema_name = %s;';
        $sql = sprintf($sql, $this->quote($dbName));
        $row = $this->createQueryStatement($sql)->fetch();

        return $row;
    }
377432
public static function getLocaliseClassPrefix($lang)
    {
        $lang = static::toLanguageTag($lang);

        $lang = str_replace('-', '', $lang);

        return ucfirst($lang);
    }
45850
public function getLanguageName(string $languageCode): string
    {
        $posixLanguageCode = $this->localeConverter->convertToPOSIX($languageCode);
        if ($posixLanguageCode === null) {
            return '';
        }

        $posixLanguageCode = mb_substr($posixLanguageCode, 0, 2);
        $languageName = Intl::getLanguageBundle()->getLanguageName($posixLanguageCode, null, $posixLanguageCode);

        return ucwords($languageName);
    }
1087703
protected function pageFilename(Page $page, $lang=null)
    {
        // We basically want the page $page->id(), but localized for multilang
        $url = $page->url($lang);
        // Strip the temporary URL prefix
        $url = trim(str_replace(static::URLPREFIX, '', $url), '/');
        // Page URL fragment should not contain a protocol or domain name at this point;
        // did we fail to override the base URL with static::URLPREFIX?
        if (Str::startsWith($url, 'http') || Str::contains($url, '://')) {
            throw new Exception("Cannot use '$url' as basis for page's file name.");
        }
        // Special case: home page
        if (!$url) {
            $file = $this->outputdir . '/index.html';
        }
        // Don’t add any extension if we already have one in the URL
        // (using a short whitelist for likely use cases).
        elseif (preg_match('/\.(js|json|css|txt|svg|xml|atom|rss)$/i', $url)) {
            $file = $this->outputdir . '/' . $url;
        }
        else {
            $file = $this->outputdir . '/' . $url . $this->extension;
        }
        $validPath = $this->normalizePath($file);
        if ($this->filterPath($validPath) == false) {
            throw new Exception('Output path for page goes outside of static directory: ' . $file);
        }
        return $validPath;
    }
1002088
public function getLangPath($lang_folder_path = null)
    {
        if (empty($lang_folder_path)) {
            $paths = [
                base_path().DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'lang',
            ];

            if (function_exists('app_path')) {
                $paths[] = app_path().DIRECTORY_SEPARATOR.'lang';
            }

            foreach ($paths as $path) {
                if (file_exists($path)) {
                    return $path;
                    //@codeCoverageIgnoreStart
                }
            }

            $e = new Exception('', self::NO_LANG_FOLDER_FOUND_IN_THESE_PATHS);
            $e->setParameter($paths);
            throw $e;
            //@codeCoverageIgnoreEnd
        } else {
            if (file_exists($lang_folder_path)) {
                return $lang_folder_path;
            }

            $e = new Exception('', self::NO_LANG_FOLDER_FOUND_IN_YOUR_CUSTOM_PATH);
            $e->setParameter($lang_folder_path);
            throw $e;
        }
    }
1290968
protected function getAlterDatabaseCharset($charset, $database = null)
    {
        if ($database !== null) {
            $database = ' ' . $this->dba->ident($database);
        }
        $charset = $this->dba->quote($charset);

        return sprintf("%s\$this->execute(\"ALTER DATABASE%s CHARACTER SET %s;\");", $this->ind2, $database, $charset);
    }
614573
public static function load($lang)
    {
        if (isset(self::$_cache[$lang]))
        {
            return self::$_cache[$lang];
        }

        $table = [];
        $parts = explode('-', $lang);

        do
        {
            $path = implode(DIRECTORY_SEPARATOR, $parts);

            $files = [];
            foreach (self::$_i18nPaths as $includePath)
            {
                if (is_file($includePath . $path . self::$ext))
                {
                    $files[] = $includePath . $path . self::$ext;
                }
            }

            if ( ! empty($files))
            {
                $t = [];
                foreach ($files as $file)
                {
                    $t = array_merge($t, Base::load($file));
                }
                $table += $t;
            }
            array_pop($parts);
        }
        while ($parts);

        return self::$_cache[$lang] = $table;
    }
1038258
public function createDatabase($database, $charset = '', $options = []) {
        $sql = "CREATE DATABASE IF NOT EXISTS `{$database}`";
        if ($charset) {
            $sql .= ' DEFAULT CHARACTER SET ' . $charset;
        } else if ($this->charset) {
            $sql .= ' DEFAULT CHARACTER SET ' . $this->charset;
        } else {
            $sql .= ' DEFAULT CHARACTER SET UTF8MB4';
        }
        try {
            $rst = $this->exec($sql);

            return $rst > 0;
        } catch (\PDOException $e) {
            DatabaseDialect::$lastErrorMassge = $e->getMessage();

            return false;
        }
    }
67269
public function lang($lang = NULL)
	{
		if ( ! func_num_args())
		{
			return $this->_lang;
		}
		$this->_lang = $lang;
		return $this;
	}
315731
public function getDatabaseSchemata($dbName)
    {
        $sql = "SELECT
            default_character_set_name,
            default_collation_name
            FROM information_schema.SCHEMATA
            WHERE schema_name = %s;";
        $sql = sprintf($sql, $this->quote($dbName));
        $row = $this->pdo->query($sql)->fetch();

        return $row;
    }
1064663
function versionName( $lang = false )
    {
        if ( !$lang )
        {
            $lang = $this->initialLanguageCode();
        }

        if ( isset( $this->VersionNameCache[$lang] ) )
            return $this->VersionNameCache[$lang];

        $object = $this->attribute( 'contentobject' );
        if ( !$object )
        {
            $retValue = false;
            return $retValue;
        }

        $class = $object->attribute( 'content_class' );
        if ( !$class )
        {
            $retValue = false;
            return $retValue;
        }

        $this->VersionNameCache[$lang] = $class->contentObjectName( $object,
                                                                    $this->attribute( 'version' ),
                                                                    $lang );
        return $this->VersionNameCache[$lang];
    }
660150
public function getNodeTranslationByNodeIdQueryBuilder($nodeId, $lang)
    {
        $qb = $this->createQueryBuilder('nt')
            ->select('nt')
            ->innerJoin('nt.node', 'n', 'WITH', 'nt.node = n.id')
            ->where('n.deleted != 1')
            ->andWhere('nt.online = 1')
            ->andWhere('nt.lang = :lang')
            ->setParameter('lang', $lang)
            ->andWhere('n.id = :node_id')
            ->setParameter('node_id', $nodeId)
            ->setFirstResult(0)
            ->setMaxResults(1);

        return $qb->getQuery()->getOneOrNullResult();
    }
1041812
public function upload ($lang='english')
	{
		// Set language
		$this->_lang_set($lang);
		
		// Get configuartion data (we fill up 2 arrays - $config and $conf)
		
		$conf['img_path']			= $this->config->item('img_path',		'uploader_settings');
		$conf['allow_resize']		= $this->config->item('allow_resize',	'uploader_settings');
		
		$config['allowed_types']	= $this->config->item('allowed_types',	'uploader_settings');
		$config['max_size']			= $this->config->item('max_size',		'uploader_settings');
		$config['encrypt_name']		= $this->config->item('encrypt_name',	'uploader_settings');
		$config['overwrite']		= $this->config->item('overwrite',		'uploader_settings');
		$config['upload_path']		= $this->config->item('upload_path',	'uploader_settings');
		
		if (!$conf['allow_resize'])
		{
			$config['max_width']	= $this->config->item('max_width',		'uploader_settings');
			$config['max_height']	= $this->config->item('max_height',		'uploader_settings');
		}
		else
		{
			$conf['max_width']		= $this->config->item('max_width',		'uploader_settings');
			$conf['max_height']		= $this->config->item('max_height',		'uploader_settings');
			
			if ($conf['max_width'] == 0 and $conf['max_height'] == 0)
			{
				$conf['allow_resize'] = FALSE;
			}
		}
		
		// Load uploader
		$this->load->library('upload', $config);
		
		if ($this->upload->do_upload()) // Success
		{
			// General result data
			$result = $this->upload->data();
			
			// Shall we resize an image?
			if ($conf['allow_resize'] and $conf['max_width'] > 0 and $conf['max_height'] > 0 and (($result['image_width'] > $conf['max_width']) or ($result['image_height'] > $conf['max_height'])))
			{				
				// Resizing parameters
				$resizeParams = array
				(
					'source_image'	=> $result['full_path'],
					'new_image'		=> $result['full_path'],
					'width'			=> $conf['max_width'],
					'height'		=> $conf['max_height']
				);
				
				// Load resize library
				$this->load->library('image_lib', $resizeParams);
				
				// Do resize
				$this->image_lib->resize();
			}
			
			// Add our stuff
			$result['result']		= "file_uploaded";
			$result['resultcode']	= 'ok';
			$result['file_name']	= $conf['img_path'] . '/' . $result['file_name'];
			
			// Output to user
			$this->load->view('ajax_upload_result', $result);
		}
		else // Failure
		{
			// Compile data for output
			$result['result']		= $this->upload->display_errors(' ', ' ');
			$result['resultcode']	= 'failed';
			
			// Output to user
			$this->load->view('ajax_upload_result', $result);
		}
	}
334252
public function getLanguageCode($lang = null)
    {
        $parts = $this->_callInternalLocale('parseLocale', null, $lang, false);
        return isset($parts['language']) ? $parts['language'] : null;
    }
1291504
public function getLanguageFullname($language)
    {
        //Clean up the language name to prevent malicious code injection
        $language = preg_replace('#[^a-zA-Z0-9\-_]#', '', $language);

        $language = strtolower($language);

        // get fullpath-filename for a langname
        $fullpath = self::LANG_ROOT . $language . '.php';

        // we need to get contents :S
        if (false === ($data = file_get_contents($fullpath))) {
            $this->error = sprintf('%s->%s Unknown Language: %s', __CLASS__, __METHOD__, $language);

            return false;
        }

        // match the langname
        if (!preg_match('/\'LANG_NAME\'\s*=>\s*\'((?:[^\']|\\\')+?)\'/', $data, $matches)) {
            $this->error = sprintf('%s->%s(%s): Regex can not detect language', __CLASS__, __METHOD__, $language);

            return false;
        }

        // return fullname for langname
        return stripcslashes($matches[1]);
    }
600732
public function create($db = '')
    {
        $dbConfig = Db::getConfig();
        $prefix = $db == ''? $dbConfig['prefix'] : $dbConfig[$db]['prefix'];

        if (file_exists($this->_lockFile)) {
            echo "<b style='color:red'>数据库创建操作被锁定，请删除[{$this->_lockFile}]文件后重试</b>";
            exit;
        }

        if ($this->_generateSql($prefix) === false) {
            echo '执行sql语句出错，请检查配置';
            exit;
        }
        echo '执行成功,如非必要请不要解锁后再次执行，重复执行会清空原有rbac表中的数据';
        $this->_writeLock();
        exit;
    }