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


/**
 * Include required files.
 */
require_once(dirname(__FILE__) . '/includes/WURFLServiceConfiguration.php');


/* We calculate the $implentation variable whitch contains the list 
 * of available implementations of the DDR-Simple-API
 */
/*
$path_ddr_implementations = dirname(__FILE__) . '/common/ddrsimpleapi/implementation';
$implementations = array();
$handle = opendir($path_ddr_implementations);
while (false !== ($file = readdir($handle))) {		
	if(is_dir($path_ddr_implementations . '/' . $file) && $file != '.' && $file!='..' && $file!='basic'){
		$implementations[$file] = $file;
	}
}
closedir($handle);
*/

/*
 * We add javascript references for the admin interface.
 * (no JS done for the moment)
 */

$plugindir = $CFG->dirroot . '/filter/mobileOKPythia';
$baseurl = $CFG->wwwroot . '/filter/mobileOKPythia';
if (file_exists($plugindir . '/jquery-1.3.2.js')) {
	require_js($baseurl . '/jquery-1.3.2.js');
}
if (file_exists($plugindir . '/admin.js')) {
	require_js($baseurl . '/admin.js');
}

/*
 * We determine the list of homepage numbers availables
 */
$homepage_number = array();
for($i=1; $i<=30; $i++){
	$homepage_number[(string)$i] = $i;
}

/*
 * We determine the list of available themes
 */
$tmp = array();
$tmp += get_list_of_themes();
$themes = array();
foreach($tmp as $theme){
	$themes[$theme] = $theme;
}

$settings->add(new admin_setting_heading(
	'filter_mobileOKPythia_askpythia_title',
	'AskPythia', ''));

$config = DDRServiceConfigurationFactory::getServiceConfiguration('WURFL', $settings);
$config->addOptions();


$settings->add(new admin_setting_heading(
	'filter_mobileOKPythia_transpythia_title',
	'TransPythia', ''));


$settings->add(new admin_setting_configcheckbox(
	'filter_mobileOKPythia_resize_img',
	'Image resizing',
	'Adapt images to fit the screen size and supported formats of the requesting device.',
	1));

$settings->add(new admin_setting_configtext(
	'filter_mobileOKPythia_max_image_size',
	'Maximum size per image (in KB)',
	'Images whose size is still bigger than the above limit after conversion will be removed from served content when the device is identified as a mobile device.',
	'10')); 

$settings->add(new admin_setting_configcheckbox(
	'filter_mobileOKPythia_pagination',
	'Pagination',
	'Automatically paginate long articles on mobile devices.',
	1));
	
$settings->add(new admin_setting_configtext(
	'filter_mobileOKPythia_max_weight',
	'Maximum size per page (in KB)',
	'Pagination is triggered by the size of the page.',
	'20'));

$settings->add(new admin_setting_configcheckbox(
	'filter_mobileOKPythia_linear_tables',
	'Linearize tables',
	'Automatically linearizes tables when the requesting device does not support them.',
	1));

$settings->add(new admin_setting_configcheckbox(
	'filter_mobileOKPythia_delete_popup',
	'Suppress pop-ups',
	'Suppress pop-up windows when the requesting device is identified as a mobile device.',
	1));
	
$settings->add(new admin_setting_configcheckbox(
	'filter_mobileOKPythia_delete_script',
	'Suppress scripts',
	'Suppress scripts when the requesting device does not support scripting.',
	1));
	
$settings->add(new admin_setting_configcheckbox(
	'filter_mobileOKPythia_delete_embeds',
	'Suppress embedded elements',
	'Suppress embedded elements (applet, embed, iframe) when the requesting device is identified as a mobile device.',
	1));

$settings->add(new admin_setting_configcheckbox(
	'filter_mobileOKPythia_serve_xhtml',
	'XHTML content',
	'Serve content using the recommended application/xhtml+xml media type when the requesting device supports it. Note the content must pass markup validation or browsers may fail to render the resulting content.',
	1));
	
$settings->add(new admin_setting_heading(
	'filter_mobileOKPythia_powder_title',
	'POWDER', ''));

$settings->add(new admin_setting_configcheckbox(
	'filter_mobileOKPythia_link_powder',
	'mobileOK POWDER file',
	'Generate mobileOK POWDER file and link served content to the POWDER file using an HTTP <code>Link</code> header.',
	0));

$settings->add(new admin_setting_configtext(
	'filter_mobileOKPythia_powder_file',
	'POWDER file',
	'POWDER file to generate and return. The POWDER file is not overwritten if it already exists.',
	$CFG->dataroot . '/cache/powder.xml')); 

?>