本文整理汇总了PHP中Codes::process方法的典型用法代码示例。如果您正苦于以下问题:PHP Codes::process方法的具体用法?PHP Codes::process怎么用?PHP Codes::process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codes
的用法示例。
在下文中一共展示了Codes::process方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
//.........这里部分代码省略.........
$patterns_map['/\\[(users)=([^\\]]+?)\\]/i'] = 'Codes::render_users';
// [users=present]
$patterns_map['/\\[(file|download)=([^\\]]+?)\\]/i'] = 'Codes::render_object';
// [file=<id>] or [file=<id>, title] or download=<id>] or [download=<id>, title]
$patterns_map['/\\[(comment)=([^\\]]+?)\\]/i'] = 'Codes::render_object';
// [comment=<id>] or [comment=<id>, title]
$patterns_map['/\\[(link)(?:=([^\\]]+?))?\\](.*?)\\[\\/link\\]/is'] = 'Codes::render_link';
// [link]url[/link] or [link=label]url[/link]
$patterns_map['/\\[(button)=([^\\]]+?)\\](.*?)\\[\\/button\\]/is'] = 'Codes::render_link';
// [button=label]url[/button]
$patterns_map['/\\[(button)=([^\\|]+?)\\|([^\\]]+?)]/is'] = 'Codes::render_link';
// [button=label|url]
$patterns_map['/\\[(click)=([^\\|]+?)\\|([^\\]]+?)]/is'] = 'Codes::render_link';
// [click=label|url]
$patterns_map['/(\\[)([^ ][^\\]\\|]+?[^ ])\\|([^ ][^\\]]+?[^ ])\\]/is'] = 'Codes::render_link';
// [label|url]
$patterns_map['#(\\s)([a-z]+?://[a-z0-9_\\-\\.\\~\\/@&;:=%$\\?]+)#'] = 'Codes::render_link';
// make URL clickable
$patterns_map['#(\\s)(www\\.[a-z0-9\\-]+\\.[a-z0-9_\\-\\.\\~]+(?:/[^,< \\r\\n\\)]*)?)#i'] = 'Codes::render_link';
// web server url
$patterns_map['/http[s]*:\\/\\/www\\.youtube\\.com\\/watch\\?v=([a-zA-Z0-9_\\-]+)[a-zA-Z0-9_\\-&=]*/i'] = '<iframe class="youtube-player" type="text/html" width="445" height="364" src="http://www.youtube.com/embed/$1" frameborder="0"></iframe>';
// YouTube link
$patterns_map['/http[s]*:\\/\\/youtu\\.be\\/([a-zA-Z0-9_\\-]+)/i'] = '<iframe class="youtube-player" type="text/html" width="445" height="364" src="http://www.youtube.com/embed/$1" frameborder="0"></iframe>';
// YouTube link too
$patterns_map['/\\[clicks=([^\\]]+?)]/is'] = 'Codes::render_clicks';
// [clicks=url] // @TODO: put in extension
$patterns_map['/\\[email\\](.*?)\\[\\/email\\]/is'] = 'Codes::render_email';
// [email]url[/email]
$patterns_map['/(\\s)([a-z0-9_\\-\\.\\~]+?@[a-z0-9_\\-\\.\\~]+\\.[a-z0-9_\\-\\.\\~]+)/i'] = 'Codes::render_email';
// mail address
$patterns_map['/\\[published(?:\\.([^\\]=]+?))?(?:=([^\\]]+?))?\\]\\n*/is'] = 'Codes::render_published';
// [published(.decorated)], [published=section:4029], [published.decorated=section:4029,x]
$patterns_map['/\\[updated(?:\\.([^\\]=]+?))?(?:=([^\\]]+?))?\\]\\n*/is'] = 'Codes::render_updated';
// [updated(.decorated)], [updated(.decorated)=section:4029,x]
$patterns_map['/\\[sections(?:\\.([^\\]=]+?))?(?:=([^\\]]+?))?\\]\\n*/is'] = 'Codes::render_sections';
// [sections(.decorated)] (site map), [sections(.decorated)=section:4029] (sub-sections), [sections.simple=self] (assigned)
$patterns_map['/\\[categories(?:\\.([^\\]=]+?))?(?:=([^\\]]+?))?\\]\\n*/is'] = 'Codes::render_categories';
// [categories(.decorated)] (category tree), [categories(.decorated)=categories:4029] (sub-categories)
$patterns_map['/\\[wikipedia=([^\\]]+?)\\]/is'] = 'Codes::render_wikipedia';
// [wikipedia=keyword] or [wikipedia=keyword, title]
$patterns_map['/\\[be\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/be.gif" alt="belgian flag" /> ';
// [be] belgian flag
$patterns_map['/\\[ca\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/ca.gif" alt="canadian flag" /> ';
// [ca] canadian flag
$patterns_map['/\\[ch\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/ch.gif" alt="swiss flag" /> ';
// [ch] swiss flag
$patterns_map['/\\[de\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/de.gif" alt="german flag" /> ';
// [de] german flag
$patterns_map['/\\[en\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/gb.gif" alt="english flag" /> ';
// [en] english flag
$patterns_map['/\\[es\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/es.gif" alt="spanish flag" /> ';
// [es] spanish flag
$patterns_map['/\\[fr\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/fr.gif" alt="french flag" /> ';
// [fr] french flag
$patterns_map['/\\[gr\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/gr.gif" alt="greek flag" /> ';
// [gr] greek flag
$patterns_map['/\\[it\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/it.gif" alt="italian flag" /> ';
// [it] italian flag
$patterns_map['/\\[pt\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/pt.gif" alt="portugal flag" /> ';
// [pt] portugal flag
$patterns_map['/\\[us\\]/i'] = ' <img src="' . $context['url_to_root'] . 'skins/_reference/flags/us.gif" alt="us flag" /> ';
// [us] us flag
$patterns_map['/\\[clear\\]\\n*/i'] = ' <br style="clear: both;" /> ';
// [clear]
$patterns_map['/\\[nl\\]\\n*/i'] = BR;
// [nl] new line
// load formatting codes from files
$dir = $context['path_to_root'] . 'codes/';
if ($handle = Safe::opendir($dir)) {
while (false !== ($file = Safe::readdir($handle))) {
if ($file == '..') {
continue;
}
if ($file == '.') {
continue;
}
//convention :
//get file only begining with code_
if (!(substr($file, 0, 5) == 'code_')) {
continue;
}
include_once $dir . $file;
//get formatting code patterns from this class
$classname = stristr($file, '.', TRUE);
$code = new $classname();
$code->get_pattern($patterns_map);
unset($code);
}
Safe::closedir($handle);
}
// cache all patterns in one unique file for next time
Codes::save_patterns($patterns_map);
}
// end generating patterns from scratch
}
// end setting $patterns
$text = Codes::process($text, $patterns_map);
// done
return $text;
}