60 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
class news {
 | 
						|
 | 
						|
	protected static $paramsList = array(
 | 
						|
		'visibility'
 | 
						|
	);
 | 
						|
	
 | 
						|
	public $params = array();
 | 
						|
	
 | 
						|
	public function __construct($params){
 | 
						|
		$this->setParams($params);
 | 
						|
		echo '<script type="text/javascript" src="http://www.google.com/jsapi"></script>
 | 
						|
				<div id="news"></div>
 | 
						|
					<script type="text/javascript">
 | 
						|
						google.load("elements", "1", {packages : ["newsshow"]});
 | 
						|
						function onLoad() {
 | 
						|
							var options = {
 | 
						|
								"format" : "300x250",
 | 
						|
								"language" : "fr",
 | 
						|
								"linkTarget" : "_blank"
 | 
						|
							}
 | 
						|
							// Load it using all of the defaults.
 | 
						|
							var content = document.getElementById(\'news\');
 | 
						|
							var newsShow = new google.elements.NewsShow(content, options);
 | 
						|
							make_draggable($(\'#news\'));
 | 
						|
						}
 | 
						|
						
 | 
						|
 | 
						|
						google.setOnLoadCallback(onLoad);
 | 
						|
					</script>';
 | 
						|
	}
 | 
						|
	
 | 
						|
	private function setParams($params){
 | 
						|
		$this->params = $params;
 | 
						|
	}
 | 
						|
	
 | 
						|
	public static function start($params){
 | 
						|
		$news = new news($params);
 | 
						|
	}
 | 
						|
	
 | 
						|
	public function setVisibility($visibility){
 | 
						|
		// Saving the position and z-index of the note:
 | 
						|
		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
 | 
						|
 | 
						|
		$path = $xmla->xpath("//item[@id='news']"); 
 | 
						|
		$path[0]->visibility = $visibility;
 | 
						|
		
 | 
						|
		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
 | 
						|
		
 | 
						|
		echo "ok";
 | 
						|
	}
 | 
						|
	
 | 
						|
	public static function updateConfig($updated){
 | 
						|
		foreach ($updated as $what=>$withWhat){
 | 
						|
			if(in_array($what, self::$paramsList)){
 | 
						|
				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
} |