<commit_before><?php
class ICalFunction extends Plugin
{


	function __construct($hp, $loader)
	{
		// Laden der Daten
		// Nicht Editieren!
		parent::__construct($hp, $loader);

		// Plugin Config:
		// -----------------------------------------------

		// Der Name des Plugins:
		$this->name = "ICal Functions";

		// Die Version des Plugins:
		$this->version = "1.0";

		// Der Autor des Plugins:
		$this->autor = "MRH";

		//Die Homepage des Autors:
		$this->homepage = "http://mrh-development.de";

		//Notizen zu dem Plugin:
		$this->notes = "Outlook Support";
	}


	/*

	Lade alle fr das System relevanten Daten.

	z.B. Datenbank Aufrufe, Datei Aufrufe, etc.

	*/
	function OnEnable()
	{
		$hp = $this->hp;
	
		$configs = array(
		  array(
		    "name"      => "calendar_display_iCalLink",
		    "desc"      => "Zeige einen Verwei auf den iCal Kalender innerhalb der Kalender Seiten",
		    "cat"       => "System",
		    "type"      => "bool",
		    "default"   => true
		  )

		);

		$hp->config->registerArray($configs);
	}


	/*

	Hier werden die eigentlichen Aufgaben des Plugins erledigt.
	Wie zum Beispiel das hinzufgen von Weiterleitungen.

	*/
	function OnLoad()
	{		
		$hp = $this->hp;
		$get = $hp->get();
		
		if (isset($get['iCal']))
		{
			//header("Content-Type: text/Calendar");
		
			$subpage = null;
			
			if (isset($get['subpage']))
			{
				$subpage = intval($get['subpage']);
			}
			
			$site = new pluginTemplate($hp, "iCal");
			$site->load("config");
			$site->get("Main");
			$vars = $site->getVars();
						
			$site = new pluginTemplate($hp, "iCal");
			$site->setArray($vars);
			$site->load("data");
			
			$data = $this->getEvents($subpage);
			
			
			$site->set("events", $data);
			
			
			$site->display();
			
			exit;
		}

	}

	function OnSiteCreated()
	{
		
	}

	private function getEvents($subpage = null)
	{
		$hp = $this->hp;
		$dbprefix = $hp->getprefix();
		$info = $hp->info;
		$error = $hp->error;
		$right = $hp->right;

		$sql = "SELECT ID, name, date, enddate, start, end, description, display, DATE_FORMAT(time, '%Y%m%dT%H%i%s') as time FROM `$dbprefix"."events` WHERE `level` = '0';";
		$erg = $hp->mysqlquery($sql);
		
		$data = array();
		
		while ($row = mysql_fetch_array($erg))
		{
			$subpages = explode(",", $row['display']);
			
			if (($subpage != null) && (!in_array($subpage, $subpages)))
			{
				continue;
			}
			
		
			$data[] = $this->getEventData($row);		
		}
		
		return $data;
	
	}<commit_msg>Fixes ICal Error<commit_after><?php
class ICalFunction extends Plugin
{


	function __construct($hp, $loader)
	{
		// Laden der Daten
		// Nicht Editieren!
		parent::__construct($hp, $loader);

		// Plugin Config:
		// -----------------------------------------------

		// Der Name des Plugins:
		$this->name = "ICal Functions";

		// Die Version des Plugins:
		$this->version = "1.0";

		// Der Autor des Plugins:
		$this->autor = "MRH";

		//Die Homepage des Autors:
		$this->homepage = "http://mrh-development.de";

		//Notizen zu dem Plugin:
		$this->notes = "Outlook Support";
	}


	/*

	Lade alle fr das System relevanten Daten.

	z.B. Datenbank Aufrufe, Datei Aufrufe, etc.

	*/
	function OnEnable()
	{
		$hp = $this->hp;
	
		$configs = array(
		  array(
		    "name"      => "calendar_display_iCalLink",
		    "desc"      => "Zeige einen Verwei auf den iCal Kalender innerhalb der Kalender Seiten",
		    "cat"       => "System",
		    "type"      => "bool",
		    "default"   => true
		  )

		);

		$hp->config->registerArray($configs);
	}


	/*

	Hier werden die eigentlichen Aufgaben des Plugins erledigt.
	Wie zum Beispiel das hinzufgen von Weiterleitungen.

	*/
	function OnLoad()
	{		
		$hp = $this->hp;
		$get = $hp->get();
		
		if (isset($get['iCal']))
		{
			header("Content-Type: text/Calendar");
		
			$subpage = null;
			
			if (isset($get['subpage']))
			{
				$subpage = intval($get['subpage']);
			}
			
			$site = new pluginTemplate($hp, "iCal");
			$site->load("config");
			$site->get("Main");
			$vars = $site->getVars();
						
			$site = new pluginTemplate($hp, "iCal");
			$site->setArray($vars);
			$site->load("data");
			
			$data = $this->getEvents($subpage);
			
			
			$site->set("events", $data);
			
			
			$site->display();
			
			exit;
		}

	}

	function OnSiteCreated()
	{
		
	}

	private function getEvents($subpage = null)
	{
		$hp = $this->hp;
		$dbprefix = $hp->getprefix();
		$info = $hp->info;
		$error = $hp->error;
		$right = $hp->right;

		$sql = "SELECT ID, name, date, enddate, start, end, description, display, DATE_FORMAT(time, '%Y%m%dT%H%i%s') as time FROM `$dbprefix"."events` WHERE `level` = '0';";
		$erg = $hp->mysqlquery($sql);
		
		$data = array();
		
		while ($row = mysql_fetch_array($erg))
		{
			$subpages = explode(",", $row['display']);
			
			if (($subpage != null) && (!in_array($subpage, $subpages)))
			{
				continue;
			}
			
			$res = $this->getEventData($row);
		
			if ($res === null)
			{
				continue;
			}
			
			$data[] = $res;	
		}
		
		return $data;
	
	}
{'fraction_non_alphanumeric': 0.20275669196963644, 'fraction_numerical': 0.0011985617259288853, 'mean_word_length': 2.5063025210084033, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4789755', 'n_tokens_mistral': 2182, 'n_tokens_neox': 1801, 'n_words': 400}