PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/mwCalendar.php

http://mwcalendar.googlecode.com/
PHP | 100 lines | 53 code | 27 blank | 20 comment | 7 complexity | 4af2db7f4795b426663be26e64363762 MD5 | raw file
  1<?php
  2 //error_reporting(E_ALL);
  3 ini_set("display_errors", 0);
  4 //include("file_with_errors.php");
  5 //error_log( "c:\Inetpub\wwwroot\mediawiki\extensions\calendar\trunk\php.log");
  6
  7# Confirm MW environment
  8if (!defined('MEDIAWIKI')) {
  9	die( 'This file is a MediaWiki extension, it is not a valid entry point' );
 10}
 11
 12########## DEBUGGER ################
 13define( 'mwcalendar_debugger', 0); // 0=off, 1=standard, 2=custom, 3=all
 14########## DEBUGGER ################
 15
 16######### OPTIONS ###############
 17define( 'mwcalendar_email_ical_mode', 1 ); // 0=off, 1=attachment, 2=embedded, 3=html email only
 18define( 'mwcalendar_email_allday_format',1 ); // 1=20101215-20101216 (Outlook?), 2=20101215T000000-20101215T325959
 19define( 'mwc_week_start_monday', true);
 20######### OPTIONS ###############
 21
 22# set the version
 23define('mwcalendar_version','0.3.3'); //do not modify format
 24define('mwcalendar_version_label',' (beta)'); //do not modify format
 25define( 'mwcalendar_base_path', dirname(__FILE__) );
 26
 27require_once( mwcalendar_base_path . '/includes/main.php' );
 28require_once( mwcalendar_base_path . '/includes/conversion.php' );
 29require_once( mwcalendar_base_path . '/includes/helpers.php');
 30
 31# Credits	
 32$wgExtensionCredits['parserhook'][] = array(
 33    'name'=>'mwCalendar',
 34    'author'=>'Eric Fortin',
 35    'url'=>'http://www.mediawiki.org/wiki/Extension:MW_Calendar',
 36    'description'=>'MediaWiki Calendar',
 37    'version'=> mwcalendar_version . mwcalendar_version_label
 38);
 39
 40$wgExtensionFunctions[] = "mwCalendar";
 41$wgExtensionMessagesFiles['mwCalendar'] = mwcalendar_base_path . "/includes/i18n.php";
 42
 43$wgShowSQLErrors=true;
 44
 45function mwCalendar() {
 46	global $wgParser;
 47	$wgParser->setHook( "mwcalendar", "launchCalendar" );
 48	wfLoadExtensionMessages( 'mwCalendar' ); 
 49}
 50
 51function launchCalendar($paramstring, $params = array()) {
 52	global $wgVersion,$wgParser, $mwcDebugger;
 53
 54	##version check!
 55	if(version_compare($wgVersion, '1.14.0', '<')){
 56		return "You must be running MediaWiki version (1.14.0) or higher. Sorry, your version is ($wgVersion).";
 57	}
 58	
 59	$wgParser->disableCache();
 60	
 61	// conversion option; no need to do any normal calendar initializations
 62	if($ret = run_conversion($params)) {return $ret;}	
 63
 64	$calendar = new mwCalendar($params);
 65
 66	$ret = $calendar->display();
 67	
 68	if(mwcalendar_debugger){
 69		$ret .= "<center><b><font color=red>*** DEBUG MODE ACTIVATED ***</font></b></center>";
 70	}
 71	
 72	$ret .= '<small>v.'.mwcalendar_version . mwcalendar_version_label.'</small><br>';
 73
 74	return $ret;
 75}
 76
 77// this will query any wiki-page calendar previous used and port that 
 78// data into this new database calendar
 79function run_conversion($params){
 80	global $run_conversion, $calendar_source, $calendar_target, $calendar_startdate;
 81	
 82	# $calendar_source - ex: "Calendar:Main Page/Team Calendar"
 83	# $calendar_target - ex: "Supprot Team"
 84	# $calendar_startdate - ex: "1/1/2009" - any standard date would work as php auto detects the date
 85	
 86	# $run_conversion: (careful, this WILL create duplicates... run only ONCE!
 87		# true - run conversion and update database
 88		# false (default) - only display pages found - trial run
 89	
 90	if( isset($calendar_source) && isset($calendar_target) && isset($calendar_startdate)  ){
 91		$conversion = new conversion($run_conversion);
 92		return $conversion->convert( $calendar_source, $calendar_target, $calendar_startdate );
 93	}
 94	
 95	return false;
 96}
 97
 98
 99
100