예제 #1
0
 public static function parsePhrase($phraseName)
 {
     global $vbphrase;
     $arg_list = func_get_args();
     if (isset($vbphrase[$phraseName])) {
         $arg_list[0] = $vbphrase[$phraseName];
         return construct_phrase_from_array($arg_list);
     }
     $phraseArr = vB_Api::instanceInternal('phrase')->fetch(array($phraseName));
     if (isset($phraseArr[$phraseName])) {
         $phrase = $phraseArr[$phraseName];
         $arg_list[0] = $phrase;
         return construct_phrase_from_array($arg_list);
     } else {
         // Should we do something else here if phrase wasn't found?
         return '';
     }
 }
예제 #2
0
/**
* Construct Phrase
*
* this function is actually just a wrapper for sprintf but makes identification of phrase code easier
* and will not error if there are no additional arguments. The first parameter is the phrase text, and
* the (unlimited number of) following parameters are the variables to be parsed into that phrase.
*
* @param	string	Text of the phrase
* @param	mixed	First variable to be inserted
* ..		..		..
* @param	mixed	Nth variable to be inserted
*
* @return	string	The parsed phrase
*/
function construct_phrase()
{
	$args = func_get_args();
	$numargs = sizeof($args);

	// FAIL SAFE: check if only parameter is an array,
	// if so we should have called construct_phrase_from_array instead
	if ($numargs == 1 AND is_array($args[0]))
	{
		return construct_phrase_from_array($args[0]);
	}

	// if this function was called with the phrase as the first argument, and an array
	// of paramters as the second, combine into single array for construct_phrase_from_array
	else if ($numargs == 2 AND is_string($args[0]) AND is_array($args[1]))
	{
		array_unshift($args[1], $args[0]);
		return construct_phrase_from_array($args[1]);
	}

	// otherwise just package arguments up as an array
	// and call the array version of this func
	else
	{
		return construct_phrase_from_array($args);
	}
}
예제 #3
0
파일: functions.php 프로젝트: Kheros/MMOver
/**
* Construct Phrase
*
* this function is actually just a wrapper for sprintf but makes identification of phrase code easier
* and will not error if there are no additional arguments. The first parameter is the phrase text, and
* the (unlimited number of) following parameters are the variables to be parsed into that phrase.
*
* @param	string	Text of the phrase
* @param	mixed	First variable to be inserted
* ..		..		..
* @param	mixed	Nth variable to be inserted
*
* @return	string	The parsed phrase
*/
function construct_phrase()
{
    $args = func_get_args();
    $numargs = sizeof($args);
    // FAIL SAFE: check if only parameter is an array,
    // if so we should have called construct_phrase_from_array instead
    if ($numargs == 1 and is_array($args[0])) {
        return construct_phrase_from_array($args[0]);
    } else {
        if ($numargs == 2 and is_string($args[0]) and is_array($args[1])) {
            array_unshift($args[1], $args[0]);
            return construct_phrase_from_array($args[1]);
        } else {
            return construct_phrase_from_array($args);
        }
    }
}
예제 #4
0
 public static function parsePhrase($phraseName)
 {
     global $vbphrase;
     $arg_list = func_get_args();
     $arg_list[0] = $vbphrase[$phraseName];
     return construct_phrase_from_array($arg_list);
 }