<?php

namespace FOPRouter;

class Figures {
  
  

  
  

    // --- Statische Methoden ---
  
  public static function getFiguresGraphURL($monthoffset = 0 , $monthoffset2 = 0 , $params = [] ) { 
    
    
    // --- BLOCK: checktypemonthoffset ---
    
    // --- BLOCK: checktypemonthoffset2 ---
    
    // --- BLOCK: main ---
    
		$params['monthoffset'] = $monthoffset;$params['monthoffset2'] = $monthoffset2;
		return self::getFiguresGraphURL2($params);
	
    
  }

  public static function getFiguresGraphURL2($params) { 
    
    
    // --- BLOCK: main ---
    
		// Default-URL - kann durch rewrite-Regeln abgeändert werden
		
		if (!isset($url)) {
			$url = 'FOP/Figures/getFiguresGraph';
			$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 == 'getFiguresGraph')  ) {
		try {
			$result = \FOP\Figures::getFiguresGraphAction(isset($_GET['monthoffset']) ? $_GET['monthoffset'] : 0, isset($_GET['monthoffset2']) ? $_GET['monthoffset2'] : 0);
		} 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 getFiguresGraphAccess($monthoffset = 0 , $monthoffset2 = 0 ) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getIsLoggedIn())))) return false;
    // --- BLOCK: main ---
    return true;
    
  }


  
  

  
  
}



