<?php

/**
 * This block contains a link to the mobileOK checker. It implements the two
 * needed functions : init and get_content.
 * 
 * @author lequeux
 *
 */
class block_MobileOKChecker extends block_base {
	
	function init(){
		$this->title = 'Test it in the MobileOK checker';
		$this->version = '2009080700';
	}
	
	function get_content(){
		global $CFG;
		
		if(array_key_exists('edit', $_GET) && $_GET['edit'] == '1'){
			$current_page = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
			$current_page = str_replace('edit=1', 'edit=0', $current_page);
			$link = 'http://validator.w3.org/mobile/check?docAddr=' 
				. urlencode($current_page) . '&async=true&view=cat';
			
			$this->content->text .= '<center><a href="' . $link . '" target="_blank">';
			$this->content->text .= '<img alt="Link to the MobileOK Checker" '
				. 'src="'. $CFG->wwwroot . '/blocks/MobileOKChecker/images/mobileOK-newblue.gif" /></center>';
		}
		else{
			$this->content->text = '';
		}
		$this->content->footer = '';
		
		return $this->content;
	}
	
}

?>