PKPString::concatTitleFields PHP Method

concatTitleFields() static public method

Joins two title string fragments (in $fields) either with a space or a colon.
static public concatTitleFields ( $fields ) : string
$fields array
return string the joined string
    static function concatTitleFields($fields)
    {
        // Set the characters that will avoid the use of
        // a semicolon between title and subtitle.
        $avoidColonChars = array('?', '!', '/', '&');
        // if the first field ends in a character in $avoidColonChars,
        // concat with a space, otherwise use a colon.
        // Check for any of these characters in
        // the last position of current full title value.
        if (in_array(substr($fields[0], -1, 1), $avoidColonChars)) {
            $fullTitle = join(' ', $fields);
        } else {
            $fullTitle = join(': ', $fields);
        }
        return $fullTitle;
    }

Usage Example

Esempio n. 1
0
 /**
  * Get the chapter full title (with title and subtitle).
  * @return string
  */
 function getLocalizedFullTitle()
 {
     $fullTitle = $this->getLocalizedTitle();
     if ($subtitle = $this->getLocalizedSubtitle()) {
         $fullTitle = PKPString::concatTitleFields(array($fullTitle, $subtitle));
     }
     return $fullTitle;
 }
All Usage Examples Of PKPString::concatTitleFields