class_mcInputHandler.inc.php 1.53 KB
<?php
/** 
 * @copyright (c) 2014, netz.coop eG
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class mcInputHandler {

	public static $ARRAY_PATTERN = '_#_';

	private static $action = false;

	private static $POST = array();

	private static $GET ;

	public static function handleGET(array $param_GET) {
		if(array_key_exists('action', $param_GET)) {
			mcInputHandler::$action = $param_GET['action'];
		}

		mcInputHandler::$GET = $param_GET;
		
	}

	public static function handlePOST(array &$param_POST) {
		mcArray::transformArrayWithStringKeyToNormalKey($param_POST, mcInputHandler::$ARRAY_PATTERN);
		mcInputHandler::$POST = &$param_POST;
	}

	public static function &getPOST() {
		return mcInputHandler::$POST;
	}
	public static function getGET() {
		return mcInputHandler::$GET;
	}

	public static function getAction() {
		return mcInputHandler::$action;
	}

	public static function getActionID() {
		if(array_key_exists('ID', mcInputHandler::$GET)) {
			return mcInputHandler::$GET['ID'];
		} 
	}	
	
	public static function getActionMenuLink($param_action, $param_ID=''){
		if($param_ID) {
			$ID = '&ID='.$param_ID;
		} else {
			$ID = '';
		}
		return '?action='.$param_action.$ID;
	}
	
	/**
	 *
	 * @param type $param_label
	 * @param type $param_action
	 * @param type $param_ID
	 * @return type 
	 */
	public static function getHrefActionMenuLink($param_label, $param_action, $param_ID=''){
		return '<a href="'.self::getActionMenuLink($param_action, $param_ID).'">'.$param_label.'</a>';
	}
}
?>