class_RegExpHelper.inc.php 3.42 KB
<?php
/**
 * @file	RegExpHelper.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/>.
 * 
 */

class RegExpHelper extends STAssertHelper {

	/**	Funktion wird aufgerufen um zu überprüfen ob für leseberechtigte die vollständigen generierten daten im CUrl output stehen
	 *
	 */

	public function searchRegExpInArray($param_site,$param_search_array,$param_rtn,$param_output = null) {
		$ary_search = $this->prepareRegSearch($param_site,$param_search_array,$param_rtn);
		$this->assertRegExpTests($ary_search,$param_rtn,null,$param_output);
		return $param_rtn;
	}

	/**	Funktion wird aufgerufen um zu überprüfen ob für nicht leseberechtigte die vollständigen generierten daten im CUrl output stehen
	 *
	 */

	public function searchForbiddenRegExpInArray($param_site,$param_search_array,$param_rtn,$param_output=null) {
		$ary_search = $this->prepareRegSearch($param_site,$param_search_array,$param_rtn,TRUE);
		$this->assertRegExpTests($ary_search,$param_rtn,'1',$param_output);
		return $param_rtn;
	}

	/**	Funktion bereitet die Suche vor um Fehleranfällige Angaben von den Tests auszuschließen und gibt den den Search Array zurück
	 *
	 */

	private function prepareRegSearch($param_site,$param_search_array,$param_rtn,$param_Forbidden = false) {
		$ary_search = array();
		if($param_Forbidden === false) {
			unset($param_search_array['WritePrivate']);
			unset($param_search_array['Submit']);
			unset($param_search_array['addToLinkList']);
			unset($param_search_array['Url']);
			unset($param_search_array['Avatar']);
                        if(isset($param_testarray['PartOfID'])){
                            unset($param_testarray['PartOfID']);
                        }
			$param_search_array['TagName'] = $param_rtn[$param_rtn['cur']['MCase']][$param_rtn['cur']['BC']][$param_rtn['cur']['MT']]['TagName'];
		}

		foreach($param_search_array as $var_key => $var_value) {
			if($var_value != null && !is_int($var_value) && !is_array($var_value) ) {
				$ary_search[$var_key][$var_value][] = RegExpTools::newsearchTextOutput($param_site,$var_value);
			}
		}
		return $ary_search;
	}

	public function searchRegExpInTagCategory($param_site,$param_search_array,$param_rtn=null) {
		$ary_search = $this->prepareRegSearchTagCategory($param_site,$param_search_array,$param_rtn=null);
		return $ary_search;
	}

	private function prepareRegSearchTagCategory($param_site,$param_search_array,$param_rtn = null) {
		$ary_search = array();
		foreach($param_search_array as $var_key => $var_value) {
			if($var_value != null && !is_int($var_value) && !is_array($var_value) ) {
				$ary_search[$var_key][$var_value][] = RegExpTools::newsearchTextOutput($param_site,$var_value);
			}
		}
		return $ary_search;
	}


}
?>