本文整理汇总了PHP中get_dyna_libs函数的典型用法代码示例。如果您正苦于以下问题:PHP get_dyna_libs函数的具体用法?PHP get_dyna_libs怎么用?PHP get_dyna_libs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_dyna_libs函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_prefilter_preCompile
function smarty_prefilter_preCompile($source)
{
$file_type = strtolower(strrchr($this->_current_file, '.'));
$tmp_dir = 'themes/' . $GLOBALS['_CFG']['template'] . '/';
// 模æ¿æ‰€åœ¨è·¯å¾„
/**
* 处ç†æ¨¡æ¿æ–‡ä»¶
*/
if ($file_type == '.dwt') {
/* 将模æ¿ä¸æ‰€æœ‰library替æ¢ä¸ºé“¾æŽ¥ */
$pattern = '/<!--\\s#BeginLibraryItem\\s\\"\\/(.*?)\\"\\s-->.*?<!--\\s#EndLibraryItem\\s-->/s';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace_callback($pattern, create_function('$math', '
$temp = strtolower($math[1]);
return "{include file={$temp}}";
'), $source);
//$source = preg_replace($pattern, $replacement, $source);
/* æ£€æŸ¥æœ‰æ— åŠ¨æ€åº“文件,如果有为其赋值 */
$dyna_libs = get_dyna_libs($GLOBALS['_CFG']['template'], $this->_current_file);
if ($dyna_libs) {
foreach ($dyna_libs as $region => $libs) {
$pattern = '/<!--\\s*TemplateBeginEditable\\sname="' . $region . '"\\s*-->(.*?)<!--\\s*TemplateEndEditable\\s*-->/s';
if (preg_match($pattern, $source, $reg_match)) {
$reg_content = $reg_match[1];
/* 生æˆåŒ¹é…å—串 */
$keys = array_keys($libs);
$lib_pattern = '';
foreach ($keys as $lib) {
$lib_pattern .= '|' . str_replace('/', '\\/', substr($lib, 1));
}
$lib_pattern = '/{include\\sfile=(' . substr($lib_pattern, 1) . ')}/';
/* 修改$reg_contentä¸çš„内容 */
$GLOBALS['libs'] = $libs;
$reg_content = preg_replace_callback($lib_pattern, 'dyna_libs_replace', $reg_content);
/* 用修改过的内容替æ¢åŽŸæ¥å½“å‰åŒºåŸŸä¸å†…容 */
$source = preg_replace($pattern, $reg_content, $source);
}
}
}
/* åœ¨å¤´éƒ¨åŠ å…¥ç‰ˆæœ¬ä¿¡æ¯ */
$source = preg_replace('/<head>/i', "<head>\r\n<meta name=\"Generator\" content=\"" . APPNAME . ' ' . VERSION . "\" />", $source);
/* ä¿®æ£css路径 */
$source = preg_replace('/(<link\\shref=["|\'])(?:\\.\\/|\\.\\.\\/)?(css\\/)?([a-z0-9A-Z_]+\\.css["|\']\\srel=["|\']stylesheet["|\']\\stype=["|\']text\\/css["|\'])/i', '\\1' . $tmp_dir . '\\2\\3', $source);
/* ä¿®æ£js目录下js的路径 */
$source = preg_replace('/(<script\\s(?:type|language)=["|\']text\\/javascript["|\']\\ssrc=["|\'])(?:\\.\\/|\\.\\.\\/)?(js\\/[a-z0-9A-Z_\\-\\.]+\\.(?:js|vbs)["|\']><\\/script>)/', '\\1' . $tmp_dir . '\\2', $source);
/* æ›´æ¢ç¼–译模æ¿çš„ç¼–ç 类型 */
$source = preg_replace('/<meta\\shttp-equiv=["|\']Content-Type["|\']\\scontent=["|\']text\\/html;\\scharset=(?:.*?)["|\'][^>]*?>\\r?\\n?/i', '<meta http-equiv="Content-Type" content="text/html; charset=' . EC_CHARSET . '" />' . "\n", $source);
} elseif ($file_type == '.lbi') {
/* 去除meta */
$source = preg_replace('/<meta\\shttp-equiv=["|\']Content-Type["|\']\\scontent=["|\']text\\/html;\\scharset=(?:.*?)["|\']>\\r?\\n?/i', '', $source);
}
/* 替æ¢æ–‡ä»¶ç¼–ç 头部 */
if (strpos($source, "") !== FALSE) {
$source = str_replace("", '', $source);
}
$pattern = array('/<!--[^>|\\n]*?({.+?})[^<|{|\\n]*?-->/', '/<!--[^<|>|{|\\n]*?-->/', '/(href=["|\'])\\.\\.\\/(.*?)(["|\'])/i', '/((?:background|src)\\s*=\\s*["|\'])(?:\\.\\/|\\.\\.\\/)?(images\\/.*?["|\'])/is', '/((?:background|background-image):\\s*?url\\()(?:\\.\\/|\\.\\.\\/)?(images\\/)/is', '/([\'|"])\\.\\.\\//is');
$replace = array('\\1', '', '\\1\\2\\3', '\\1' . $tmp_dir . '\\2', '\\1' . $tmp_dir . '\\2', '\\1');
return preg_replace($pattern, $replace, $source);
}
示例2: smarty_prefilter_preCompile
function smarty_prefilter_preCompile($source)
{
$file_type = strtolower(strrchr($this->_current_file, '.'));
$tmp_dir = 'themes/' . $GLOBALS['_CFG']['template'] . '/';
// 模板所在路径
/**
* 处理模板文件
*/
if ($file_type == '.dwt') {
/* 将模板中所有library替换为链接 */
$pattern = '/<!--\\s#BeginLibraryItem\\s\\"\\/(.*?)\\"\\s-->.*?<!--\\s#EndLibraryItem\\s-->/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace($pattern, $replacement, $source);
/* 检查有无动态库文件,如果有为其赋值 */
$dyna_libs = get_dyna_libs($GLOBALS['_CFG']['template'], $this->_current_file);
if ($dyna_libs) {
foreach ($dyna_libs as $region => $libs) {
$pattern = '/<!--\\s*TemplateBeginEditable\\sname="' . $region . '"\\s*-->(.*?)<!--\\s*TemplateEndEditable\\s*-->/s';
if (preg_match($pattern, $source, $reg_match)) {
$reg_content = $reg_match[1];
/* 生成匹配字串 */
$keys = array_keys($libs);
$lib_pattern = '';
foreach ($keys as $lib) {
$lib_pattern .= '|' . str_replace('/', '\\/', substr($lib, 1));
}
$lib_pattern = '/{include\\sfile=(' . substr($lib_pattern, 1) . ')}/';
/* 修改$reg_content中的内容 */
$GLOBALS['libs'] = $libs;
$reg_content = preg_replace_callback($lib_pattern, 'dyna_libs_replace', $reg_content);
/* 用修改过的内容替换原来当前区域中内容 */
$source = preg_replace($pattern, $reg_content, $source);
}
}
}
/* 在头部加入版本信息 */
$source = preg_replace('/<head>/i', "<head>\r\n<meta name=\"Generator\" content=\"" . APPNAME . ' ' . VERSION . "\" />", $source);
/* 修正css路径 */
$source = preg_replace('/(<link\\shref=["|\'])(?:\\.\\/|\\.\\.\\/)?(css\\/)?([a-z0-9A-Z_]+\\.css["|\']\\srel=["|\']stylesheet["|\']\\stype=["|\']text\\/css["|\'])/i', '\\1' . $tmp_dir . '\\2\\3', $source);
/* 修正js目录下js的路径 */
$source = preg_replace('/(<script\\s(?:type|language)=["|\']text\\/javascript["|\']\\ssrc=["|\'])(?:\\.\\/|\\.\\.\\/)?(js\\/[a-z0-9A-Z_\\-\\.]+\\.(?:js|vbs)["|\']><\\/script>)/', '\\1' . $tmp_dir . '\\2', $source);
/* 更换编译模板的编码类型 */
$source = preg_replace('/<meta\\shttp-equiv=["|\']Content-Type["|\']\\scontent=["|\']text\\/html;\\scharset=(?:.*?)["|\'][^>]*?>\\r?\\n?/i', '<meta http-equiv="Content-Type" content="text/html; charset=' . EC_CHARSET . '" />' . "\n", $source);
} elseif ($file_type == '.lbi') {
/* 去除meta */
$source = preg_replace('/<meta\\shttp-equiv=["|\']Content-Type["|\']\\scontent=["|\']text\\/html;\\scharset=(?:.*?)["|\']>\\r?\\n?/i', '', $source);
}
/* 替换文件编码头部 */
if (strpos($source, "") !== FALSE) {
$source = str_replace("", '', $source);
}
$pattern = array('/<!--[^>|\\n]*?({.+?})[^<|{|\\n]*?-->/', '/<!--[^<|>|{|\\n]*?-->/', '/(href=["|\'])\\.\\.\\/(.*?)(["|\'])/i', '/((?:background|src)\\s*=\\s*["|\'])(?:\\.\\/|\\.\\.\\/)?(images\\/.*?["|\'])/is', '/((?:background|background-image):\\s*?url\\()(?:\\.\\/|\\.\\.\\/)?(images\\/)/is', '/([\'|"])\\.\\.\\//is');
$replace = array('\\1', '', '\\1\\2\\3', '\\1' . $tmp_dir . '\\2', '\\1' . $tmp_dir . '\\2', '\\1');
return preg_replace($pattern, $replace, $source);
}
示例3: smarty_prefilter_preCompile
function smarty_prefilter_preCompile($source)
{
$file_type = strtolower(strrchr($this->_current_file, '.'));
$tmp_dir = 'themes/' . $GLOBALS['_CFG']['template'] . '/';
// Ä£°åËùÔÚ·¾¶
/**
* ´¦ÀíÄ£°åÎļþ
*/
if ($file_type == '.dwt') {
/* ½«Ä£°åÖÐËùÓÐlibraryÌ滻ΪÁ´½Ó */
$pattern = '/<!--\\s#BeginLibraryItem\\s\\"\\/(.*?)\\"\\s-->.*?<!--\\s#EndLibraryItem\\s-->/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace($pattern, $replacement, $source);
/* ¼ì²éÓÐÎÞ¶¯Ì¬¿âÎļþ£¬Èç¹ûÓÐΪÆ丳ֵ */
$dyna_libs = get_dyna_libs($GLOBALS['_CFG']['template'], $this->_current_file);
if ($dyna_libs) {
foreach ($dyna_libs as $region => $libs) {
$pattern = '/<!--\\s*TemplateBeginEditable\\sname="' . $region . '"\\s*-->(.*?)<!--\\s*TemplateEndEditable\\s*-->/s';
if (preg_match($pattern, $source, $reg_match)) {
$reg_content = $reg_match[1];
/* Éú³ÉÆ¥Åä×Ö´® */
$keys = array_keys($libs);
$lib_pattern = '';
foreach ($keys as $lib) {
$lib_pattern .= '|' . str_replace('/', '\\/', substr($lib, 1));
}
$lib_pattern = '/{include\\sfile=(' . substr($lib_pattern, 1) . ')}/';
/* ÐÞ¸Ä$reg_contentÖеÄÄÚÈÝ */
$GLOBALS['libs'] = $libs;
$reg_content = preg_replace_callback($lib_pattern, 'dyna_libs_replace', $reg_content);
/* ÓÃÐ޸ĹýµÄÄÚÈÝÌæ»»ÔÀ´µ±Ç°ÇøÓòÖÐÄÚÈÝ */
$source = preg_replace($pattern, $reg_content, $source);
}
}
}
/* ÔÚÍ·²¿¼ÓÈë°æ±¾ÐÅÏ¢ */
$source = preg_replace('/<head>/i', "<head>\r\n<meta name=\"Generator\" content=\"" . APPNAME . ' ' . VERSION . "\" />", $source);
/* ÐÞÕýcss·¾¶ */
$source = preg_replace('/(<link\\shref=["|\'])(?:\\.\\/|\\.\\.\\/)?(css\\/)?([a-z0-9A-Z_]+\\.css["|\']\\srel=["|\']stylesheet["|\']\\stype=["|\']text\\/css["|\'])/i', '\\1' . $tmp_dir . '\\2\\3', $source);
/* ÐÞÕýjsĿ¼ÏÂjsµÄ·¾¶ */
$source = preg_replace('/(<script\\s(?:type|language)=["|\']text\\/javascript["|\']\\ssrc=["|\'])(?:\\.\\/|\\.\\.\\/)?(js\\/[a-z0-9A-Z_\\-\\.]+\\.(?:js|vbs)["|\']><\\/script>)/', '\\1' . $tmp_dir . '\\2', $source);
/* ¸ü»»±àÒëÄ£°åµÄ±àÂëÀàÐÍ */
$source = preg_replace('/<meta\\shttp-equiv=["|\']Content-Type["|\']\\scontent=["|\']text\\/html;\\scharset=(?:.*?)["|\'][^>]*?>\\r?\\n?/i', '<meta http-equiv="Content-Type" content="text/html; charset=' . EC_CHARSET . '" />' . "\n", $source);
} elseif ($file_type == '.lbi') {
/* È¥³ýmeta */
$source = preg_replace('/<meta\\shttp-equiv=["|\']Content-Type["|\']\\scontent=["|\']text\\/html;\\scharset=(?:.*?)["|\']>\\r?\\n?/i', '', $source);
}
/* Ìæ»»Îļþ±àÂëÍ·²¿ */
if (strpos($source, "") !== FALSE) {
$source = str_replace("", '', $source);
}
$pattern = array('/<!--[^>|\\n]*?({.+?})[^<|{|\\n]*?-->/', '/<!--[^<|>|{|\\n]*?-->/', '/(href=["|\'])\\.\\.\\/(.*?)(["|\'])/i', '/((?:background|src)\\s*=\\s*["|\'])(?:\\.\\/|\\.\\.\\/)?(images\\/.*?["|\'])/is', '/((?:background|background-image):\\s*?url\\()(?:\\.\\/|\\.\\.\\/)?(images\\/)/is', '/([\'|"])\\.\\.\\//is');
$replace = array('\\1', '', '\\1\\2\\3', '\\1' . $tmp_dir . '\\2', '\\1' . $tmp_dir . '\\2', '\\1');
return preg_replace($pattern, $replace, $source);
}