Ind*_*ial 3 php mysql embed object
我正在使用CMS进行PHP的Web应用程序,它需要缩短插入(嵌入)内容的过程,例如来自youtube的视频或者通过编写以下内容的vimeo,这些内容存储在数据库中:
<youtube id="wfI0Z6YJhL0" />
Run Code Online (Sandbox Code Playgroud)
在某种替换后会输出以下内容:
<!-- Custom formatting before object !-->
<object width="640" height="385"><param name="movie" value="http://www.youtube-nocookie.com/v/wfI0Z6YJhL0&hl=sv_SE&fs=1?rel=0&color1=0xe1600f&color2=0xfebd01"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/wfI0Z6YJhL0&hl=sv_SE&fs=1?rel=0&color1=0xe1600f&color2=0xfebd01" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
<!-- Custom formatting after object !-->
Run Code Online (Sandbox Code Playgroud)
我怎么能在PHP中这样做?
bug*_*com 11
我写了一个类,它完全符合你对我自己的cms的要求.我已经为你上传了src,虽然我从来没有发布它,但源代码是在BSD风格的许可下发布的.自定义标签
它基本上允许你做你所要求的.在课堂上有一些示例自定义标签,所以我不会在这里粘贴代码.让我知道你怎么去.
编辑1:请求的示例代码.:-)
编辑2:我应该添加它支持埋藏自定义标签.
编辑3:它还支持内联模板和标签替换,即
<ct:inline some="attribute">
This is an in line template. <br />
This is a #{tag} that can be accessed by the callback function
</ct:inline>
Run Code Online (Sandbox Code Playgroud)
PHP/HTML:example.php
<?php
$current_dir = dirname(__FILE__).DIRECTORY_SEPARATOR;
require_once dirname($current_dir).DIRECTORY_SEPARATOR.'customtags.php';
$ct = new CustomTags(array(
'parse_on_shutdown' => true,
'tag_directory' => $current_dir.'tags'.DIRECTORY_SEPARATOR,
'sniff_for_buried_tags' => true
));
?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Oliver Lillie">
<!-- Date: 2010-07-10 -->
</head>
<body>
<ct:youtube id="wfI0Z6YJhL0" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
自定义标签PHP功能:tags/youtube/tag.php:
function ct_youtube($tag)
{
return '<object id="'.$tag['attributes']->id.'" value="http://www.youtube.com/v/'.$tag['attributes']->id.'" /><param ......>';
}
Run Code Online (Sandbox Code Playgroud)
输出:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Oliver Lillie">
<!-- Date: 2010-07-10 -->
</head>
<body>
<object id="wfI0Z6YJhL0" value="http://www.youtube.com/v/wfI0Z6YJhL0" /><param ......>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)