I made some changes and it seem to work great
/**
* author GRAFX -
www.grafxsoftware.com,since 1.1.3
* Pattern Assign
*
* Pattern Assign - when variables or constants are the same as the
* template keys, these functions may be used as they are. Using
* these functions, can help you reduce the number of
* the assign functions in the php files
*
* Useful for language files where all variables or constants have
* the same prefix.i.e. <i>$LANG_SOME_VAR</i> or <i>LANG_SOME_CONST</i><br>
* The $pattern is <i>LANG</i> in this case.
*
* MOD Dec 18, 2007 rr1024 at yahoo added foreach loop for auto assing r
* of Lang arrays it uses the last fou string elements per $LangKey so auto
* assign visitor pages key will end _AV admin auto assign will be _AA
* and Moderators will be _AM. Make sure you add VAR LANG_ARR_MULTI_ASS = FALSE; to fast template var list.
* Usage:
* $TE->LANG_ARR_MULTI_ASS = TRUE;
* $TE->multiple_assign( $Lang , '_AV' );
* Where $Lang['My_AutoAssign_AV']
*/
Note this also allows you in your script to have different groups of auto assign langs in one lang files. You may not want to have all the admin langs automatically assigned in a visitor page. waste of time
FUNCTION multiple_assign( $pattern, $LangKey )
{
IF ( !$this->LANG_ARR_MULTI_ASS ){
WHILE ( list( $key, $value ) = each( $GLOBALS ) ) {
IF ( substr($key,0,strlen($pattern))==$pattern) {
$this->assign(strtoupper($key),$value);
}
}
reset($GLOBALS);
}ELSE{
FOREACH( $pattern AS $Key => $Value) {
//echo "Key: $key; Value: $value<br />\n";
IF ( substr( $Key, -3 ) == $LangKey ){
$this->assign(strtoupper( $Key ), $Value );
}
//$sub .= "SubStr = " .substr( $Key, -3).'|||Key = '.$Key.'<br />';
}
//$this->error("<strong>[TE ERROR]</strong> langkey = $LangKey <br />$sub",0);
}
} // multiple_assign