class_XSLPHPLinkGenerator.inc.php 12.7 KB
<?php
/**
 * @file	XSLPHPLinkGenerator.inc.php
 * @category freeSN
 * @mailto	code [at] netz.coop
 * @version 0.4.200901
 * @link http://netz.coop
 * 
 *  @copyright Copyright by netz.coop e.G. 2015
 *  
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
/**
 *	In dieser Klasse stehen die PHP Funktionen drinn, die aus dem XSL Script ausgerufen werden
 *	-	Im speziellen sind hier die Funktionen die für die Linkgenerierung zuständig sind
 *
 *	@version 		0.2.080320
 *	@author 		dev [at] mensch [dot] coop
 */
class XSLPHPLinkGenerator {

	private static function getIndex($param_url){
		$var =  strrchr ($param_url, "[");
		$var =  substr ($var, 1, strpos($var,"]")-1);
		if($var==""){
			$var = -1;
		}
		$var = (int)trim($var);
		return $var;
	}

	/**
	 * return a part of a link
	 * @param string param_url (string || '0')
	 * @param string param_kind (kind of BasisClipboard)
	 */
	public static function getLinkBasisClipboard($param_url, $param_kind){
		if($param_url=="0"){
			$var_Index = -1;
			$param_url = "?";
		} else {
			$param_url .= "&";
			$var_Index = XSLPHPLinkGenerator::getIndex($param_url);
		}
		$var_Link = $param_url.CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		//		$var_Link .= CONSTKindOf::getLinkBasisClipboard($param_kind);
		if($param_kind) {
			$var_Link .= CONFIG::getLinkForBC($param_kind);
		}

		return $var_Link;
	}

	public static function getLinkShowAll($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_SHOWALL;
		return $var_Link;
	}
	public static function getLinkMakeNew($param_url, $param_kind){

		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_MAKENEW;

		return $var_Link;
	}
	public static function getLinkEdit($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);

		if($param_kind){
			$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		}
		$var_Link .= CONSTKindOf::LINK_EDIT;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";

		return $var_Link;
	}
	public static function getLinkEditSB($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		$var_Link .= CONSTKindOf::LINK_EDIT;
		return $var_Link;
	}
	public static function getLinkShowSingle($param_url, $param_kind=false){
		if($param_kind){
			$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
			$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		}
		else {
			$var_Link = $param_url;
			$var_Index = XSLPHPLinkGenerator::getIndex($param_url);
		}

		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_SHOWSINGLE;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}

	public static function getMultimediaTextBasisClipboard($param_url, $param_kind){
		//		D::li("public static function getMultimediaTextBasisClipboard($param_url, $param_kind){");
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		return $var_Link;
	}



	public static function getLinkTagContentList($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		if($param_kind){
			$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		}
		$var_Link .= CONSTKindOf::LINK_SHOWLIST;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}
	public static function getLinkAddElementTo($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ADDELEMENTTO;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}


	public static function getLinkShowAllParents($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_SHOWALLPARENTS;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}
	public static function getLinkShowAllChildren($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_SHOWALLCHILDREN;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}

	public static function getLinkShowWriteMembers($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_SHOWWRITEMEMBERS;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}
	public static function getLinkShowLinkList($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_SHOWLINKLIST;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}

	public static function getLinkAddToLinkList($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ADDTOLINKLIST;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}

	public static function getLinkRemoveFromLinkList($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		//  $var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_REMOVEFROMLINKLIST;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}

	public static function getLinkConfirmAspirant($param_url, $param_kind){
		$var_Link = $param_url;
		$var_Index = XSLPHPLinkGenerator::getIndex($param_url);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_CONFIRMASPIRANT;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}

	public static function getLinkDenyAspirant($param_url, $param_kind){
		$var_Link = $param_url;
		$var_Index = XSLPHPLinkGenerator::getIndex($param_url);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_DENYASPIRANT;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}
	//
	public static function getLinkShowAspirant($param_url, $param_kind){
		if($param_kind){
			$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
			$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		}else {
			$var_Link = $param_url;
			$var_Index = XSLPHPLinkGenerator::getIndex($param_url);
		}

		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_SHOWASPIRANT;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}

	public static function getLinkRequestAspirant($param_url, $param_kind){
		if($param_kind){
			$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
			$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		}else {
			$var_Link = $param_url;
			$var_Index = XSLPHPLinkGenerator::getIndex($param_url);
		}

		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_REQUESTASPIRANT;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}

	public static function getLinkID($param_url, $param_kind){
		$var_Link = $param_url;
		$var_Index = XSLPHPLinkGenerator::getIndex($param_url);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}
	/**@todo wird die funktion überhaupt noch genutzt? @um*/
	public static function getDate($param_url, $param_kind, $param_time, $param_day){
		$var_Link = 'index.php'.$param_url;
		// $var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		if($param_time!=0){
			$var_Link .= "&".CONSTKindOf::GET_POST."[time]=";
			$var_Link .= $param_time;
		}
		if($param_day!=0){
			$var_Link .= "&".CONSTKindOf::GET_POST."[day]=";
			$var_Link .= $param_day;
		}
		return $var_Link;
	}


	//	public static function getLinkListNavigator($param_url, $param_start, $param_limit) {
	//		$var_Link = $param_url;
	//		$var_Index = XSLPHPLinkGenerator::getIndex($param_url);
	//		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
	//		$var_Link .= CONSTKindOf::LINK_LISTNAVIGATOR_START;
	//		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
	//		$var_Link .= $param_start;
	//		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
	//		$var_Link .= CONSTKindOf::LINK_LISTNAVIGATOR_LIMIT;
	//		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
	//		$var_Link .= $param_limit;
	//		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
	//		$var_Link .= CONSTKindOf::LINK_LISTNAVIGATOR_DIRECTION;
	//		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
	//		return $var_Link;
	//	}

	/**	besondere Funktionen */

	public static function getLinkChangePassword($param_url, $param_kind){
		$var_Link = XSLPHPLinkGenerator::getLinkBasisClipboard($param_url, $param_kind);
		$var_Index = XSLPHPLinkGenerator::getIndex($var_Link);
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_CHANGEPASSWORD;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		$var_Link .= CONSTKindOf::LINK_ID;
		$var_Link .= "&".CONSTKindOf::GET_PARAM."[".++$var_Index."]=";
		return $var_Link;
	}
}