Project

General

Profile

« Previous | Next » 

Revision 587

Added by doc almost 17 years ago

Added multi-lingual Admin tool description. Moved Admin tool language text from global language file to module language files. Added function get_variable_content to allow extraction of variable without including files.

View differences:

functions.php
825 825
	}
826 826
}
827 827

  
828
// extracts the content of a string variable from a string (save alternative to including files)
829
if(!function_exists('get_variable_content')) {
830
	function get_variable_content($search, $data, $striptags=true, $convert_to_entities=true) {
831
		$match = '';
832
		// search for $variable followed by 0-n whitespace then by = then by 0-n whitespace
833
		// then either " or ' then 0-n characters then either " or ' followed by 0-n whitespace and ;
834
		// the variable name is returned in $match[1], the content in $match[3]
835
		if (preg_match('/(\$' .$search .')\s*=\s*("|\')(.*)\2\s*;/', $data, $match)) {
836
			if(strip_tags(trim($match[1])) == '$' .$search) {
837
				// variable name matches, return it?s value
838
				$match[3] = ($striptags == true) ? strip_tags($match[3]) : $match[3];
839
				$match[3] = ($convert_to_entities == true) ? htmlentities($match[3]) : $match[3];
840
				return $match[3];
841
			}
842
		}
843
		return false;
844
	}
845
}
846

  
828 847
?>

Also available in: Unified diff