【发布时间】:2012-05-26 04:59:41
【问题描述】:
是否有任何可用于 joomla 2.5 的插件来嵌入来自 github 存储库的代码。对于 word press,有一个插件可以实现相同的功能(http://wordpress.org/extend/plugins/github-code-viewer-2/)。我想使用
之类的东西将我的 github 存储库中的代码包含到我的 joomla/k2 文章中{github url='https://github.com/jamescarr/spring-integration/blob/master/spring-integration-file/src/main/java/org/springframework/integration/file/filters/AbstractFileListFilter.java'}
通过查看 wp 插件,我想编写自己的 joomla 插件,但 WP 插件正在使用 *wp_remote_fopen* 功能,我在 joomla 中没有找到相同类型的功能,并阅读了一些关于使用此类 remote_open 函数的漏洞。这是 WP 插件正在做的事情
function getGitHubFile($url, $ttl = null){
self::__loadCache($url, $ttl);
if (isset(self::$cache[$url])) {
$code = self::$cache[$url];
} else {
$code = wp_remote_fopen($url . '?raw=true');
if ($code == '') {
return 'You need cURL installed to use GitHub_Code_Viewer';
}
$code = str_replace('<', '<', $code);
self::__setCache($url, $code);
}
return $code;
}
【问题讨论】:
-
Wordpress 的 wp_remote_fopen 方法相当于在 Joomla 中使用 cURL。查看 php.net 以获取有关如何使用它的信息。如果服务器上禁用了 cURL,请尝试使用 fopen() 或 file_get_contents();
-
我们有没有相同的 joomla api 而不是使用 php api?
-
我不知道。 JFile 类仅用于本地文件。
标签: joomla github embed code-view