美国虚拟主机Hostease

Mediawiki中文技术论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8037|回复: 0

在MediaWiki中添加Google Calendar

[复制链接]
发表于 2011-12-12 15:54:19 | 显示全部楼层 |阅读模式
BlueHost主机优惠码
1. 新建文件 extensions/googleCalendar.php
  1. <?php
  2. # Google Calendars
  3. #
  4. # Tag :
  5. #   <googlecalendar>calendar id</googlecalendar>
  6. # Ex :
  7. #   from url http://www.google.com/calendar/embed?src=lvrhikf5hj035b7thmmaucvs7c%40group.calendar.google.com&ctz=Asia/Shanghai
  8. #   <googlecalendar>lvrhikf5hj035b7thmmaucvs7c@group.calendar.google.com</googlecalendar>
  9. #
  10. # Enjoy !

  11. $wgExtensionFunctions[] = 'wfGoogleCalendar';
  12. $wgExtensionCredits['parserhook'][] = array
  13. (
  14.         'name' => 'Google Calendar',
  15.         'description' => 'Display Google Calendar',
  16.         'author' => 'Kasper Souren',
  17.         'url' => 'http://wiki.couchsurfing.com/en/Google_Calendar_MediaWiki_plugin'
  18. );

  19. function wfGoogleCalendar()
  20. {
  21.         global $wgParser;
  22.         $wgParser->setHook('googlecalendar', 'renderGoogleCalendar');
  23. }

  24. # The callback function for converting the input text to HTML output
  25. function renderGoogleCalendar($input)
  26. {
  27.         $input = htmlspecialchars($input);

  28.                 $output = '<iframe src="http://www.google.com/calendar/embed?src='.$input.'&ctz=Asia/Shanghai" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>';

  29.         return $output;
  30. }
  31. ?>
复制代码
2. 修改LocalSettings.php

在这个文件的最后加入一行

require_once('extensions/googleCalendar.php');
3. 在MediaWiki中添加Google Calendar

<googlecalendar>lvrhikf5hj035b7thmmaucvs7c@group.calendar.google.com</googlecalendar>
4. 说明

从代码中可以看到,实现的功能实际上就是把一个输入转换成所需要的HTML代码输出,
不仅仅是对Google Calendar,对其他要在MediaWiki中添加复杂HTML代码的情况同样适用
以上路径都是相对于MediaWiki主目录
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

美国主机评测网站

Archiver|手机版|小黑屋|Mediawiki中文技术论坛

GMT+8, 2024-4-25 18:51 , Processed in 0.047011 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表