本文整理汇总了PHP中GeSHi::merge_arrays方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::merge_arrays方法的具体用法?PHP GeSHi::merge_arrays怎么用?PHP GeSHi::merge_arrays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeSHi
的用法示例。
在下文中一共展示了GeSHi::merge_arrays方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_language
/**
* Gets language information and stores it for later use
*
* @param string The filename of the language file you want to load
* @since 1.0.0
* @access private
* @todo Needs to load keys for lexic permissions for keywords, regexps etc
*/
function load_language($file_name)
{
if ($file_name == $this->loaded_language) {
// this file is already loaded!
return;
}
//Prepare some stuff before actually loading the language file
$this->loaded_language = $file_name;
$this->parse_cache_built = false;
$this->enable_highlighting();
$language_data = array();
//Load the language file
require $file_name;
// Perhaps some checking might be added here later to check that
// $language data is a valid thing but maybe not
$this->language_data = $language_data;
// Set strict mode if should be set
if ($this->language_data['STRICT_MODE_APPLIES'] == GESHI_ALWAYS) {
$this->strict_mode = true;
}
// Set permissions for all lexics to true
// so they'll be highlighted by default
foreach (array_keys($this->language_data['KEYWORDS']) as $key) {
if (!empty($this->language_data['KEYWORDS'][$key])) {
$this->lexic_permissions['KEYWORDS'][$key] = true;
} else {
$this->lexic_permissions['KEYWORDS'][$key] = false;
}
}
foreach (array_keys($this->language_data['COMMENT_SINGLE']) as $key) {
$this->lexic_permissions['COMMENTS'][$key] = true;
}
foreach (array_keys($this->language_data['REGEXPS']) as $key) {
$this->lexic_permissions['REGEXPS'][$key] = true;
}
// for BenBE and future code reviews:
// we can use empty here since we only check for existance and emptiness of an array
// if it is not an array at all but rather false or null this will work as intended as well
// even if $this->language_data['PARSER_CONTROL'] is undefined this won't trigger a notice
if (!empty($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS'])) {
foreach ($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS'] as $flag => $value) {
// it's either true or false and maybe is true as well
$perm = $value !== GESHI_NEVER;
if ($flag == 'ALL') {
$this->enable_highlighting($perm);
continue;
}
if (!isset($this->lexic_permissions[$flag])) {
// unknown lexic permission
continue;
}
if (is_array($this->lexic_permissions[$flag])) {
foreach ($this->lexic_permissions[$flag] as $key => $val) {
$this->lexic_permissions[$flag][$key] = $perm;
}
} else {
$this->lexic_permissions[$flag] = $perm;
}
}
unset($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS']);
}
//NEW in 1.0.8: Allow styles to be loaded from a separate file to override defaults
$style_filename = substr($file_name, 0, -4) . '.style.php';
if (is_readable($style_filename)) {
//Clear any style_data that could have been set before ...
if (isset($style_data)) {
unset($style_data);
}
//Read the Style Information from the style file
include $style_filename;
//Apply the new styles to our current language styles
if (isset($style_data) && is_array($style_data)) {
$this->language_data['STYLES'] = GeSHi::merge_arrays($this->language_data['STYLES'], $style_data);
}
}
// Set default class for CSS
$this->overall_class = $this->language;
}