<?php

namespace TypesRouter;

class AufgabeType {
  
  

  
  

    // --- Statische Methoden ---
  
  public static function descriptionURL($id, $params = [] ) { 
    
    
    // --- BLOCK: main ---
    
		$params['id'] = $id;
		return self::descriptionURL2($params);
	
    
  }

  public static function descriptionURL2($params) { 
    
    
    // --- BLOCK: main ---
    
		// Default-URL - kann durch rewrite-Regeln abgeändert werden
		
		if (!isset($url)) {
			$url = 'Types/AufgabeType/description';
			$isFirst = true;
		}
		foreach ($params AS $k => $v) {
			if (!is_null($v)) {
				$url .= ($isFirst ? '?' : '&') . urlencode($k) . '=' . \FOP\Util::urlencode($v);
				$isFirst = false;
			}
		}
		if (\FOP\Configuration::getFOPUtilEnableRewrite() == 'true' || \FOP\Configuration::getFOPUtilEnableRewrite() == 1) {
			return \FOP\Util::getCurrentBaseurl() . $url;
		} else {
			return \FOP\Util::getCurrentBaseurl() . 'fop-router.php?q=' . urlencode($url);
		}
	
    
  }

  public static function route($q) { 
    
    
    // --- BLOCK: main ---
    
	if (($q == 'description') && isset($_GET['id'])  ) {
		try {
			$result = \Types\AufgabeType::descriptionAction($_GET['id']);
		} catch(\FOP\AccessDeniedException $e){
			\Ajax\Errors::render($e->getMessage() ?: 'accessdenied');
			die();
		}
		if (isset($result)) {
			header('Content-Type: application/json'); 
			die(json_encode($result));
		} else {
			die('');
		}
	}

	header('HTTP/1.0 404 Not found');
	\Ajax\Errors::render('Die angeforderte Funktion wurde nicht gefunden.');
	die();
    
  }

  public static function descriptionAccess($id) { 
    
    
    // --- BLOCK: access ---
    if(!((!\FOP\User::getIsGuest()))) return false;
    // --- BLOCK: main ---
    return true;
    
  }


  
  

  
  
}



