<?php
/**
 * This file is part of the mobileOK Pythia plug-in for Joomla! and defines the
 * {@link JButtonW3CmobileOKChecker} class.
 * 
 * @author Sylvain Lequeux
 * @author Francois Daoust <fd@w3.org>
 * @package mobileOKPythia
 * @subpackage Joomla
 * @version $Revision: 1.4 $
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 or later
 * @copyright Copyright (c) 2009, W3C (MIT, ERCIM, Keio)
 */

// No direct access allowed to this file
defined( '_JEXEC' ) or die( 'Restricted access' );


/**
 * The JButtonW3CmobileOKChecker class defines the button
 * that links to the W3C mobileOK Checker service in edit
 * mode in administrative pages.   
 *
 * @author Sylvain Lequeux
 * @author Francois Daoust <fd@w3.org>
 * @package mobileOKPythia
 * @subpackage Joomla
 * @version $Revision: 1.4 $
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 or later
 * @copyright Copyright (c) 2009, W3C (MIT, ERCIM, Keio)
 */
class JButtonW3CmobileOKChecker extends JButton {
	function fetchButton( $type='Standard', $name = '', $text = '', $task = '', $list = true, $hideMenu = false ){
		$path = JURI::base() . '../plugins/system/mobileOKPythia/images/mobileOK.png';
		$text = "mobileOK?";
		
		$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
		$cid = intval($cid[0]);
		$link = JURI::base() . '../index.php?option=com_content&id='.$cid;
		$link = 'http://validator.w3.org/mobile/check?docAddr=' . urlencode($link) . '&async=true&view=cat';
		
		$html = '<a href="'.$link.'" target="_blank">';
		$html .= '<img src="'.$path.'" width="32" height="32" alt="Check the mobile-friendliness of your post with the W3C mobileOK Checker (opens in a new window)"/>';
		$html .= '<br />' . $text . '</a>';
		return $html;
	}
	
	function fetchId( $type='Standard', $name = '', $text = '', $task = '', $list = true, $hideMenu = false )
	{
		return $this->_parent->_name.'-'.$name;
	}
	
}
?>