You are here

public function PARSEENTRIES::removeDelimitersAndExpand in Bibliography Module 7

Same name and namespace in other branches
  1. 5 bibtexParse/PARSEENTRIES.php \PARSEENTRIES::removeDelimitersAndExpand()
  2. 6.2 modules/bibtexParse/PARSEENTRIES.php \PARSEENTRIES::removeDelimitersAndExpand()
  3. 6 bibtexParse/PARSEENTRIES.php \PARSEENTRIES::removeDelimitersAndExpand()
  4. 7.3 plugins/biblio_style/bibtex/PARSEENTRIES.php \PARSEENTRIES::removeDelimitersAndExpand()
  5. 7.2 modules/bibtexParse/PARSEENTRIES.php \PARSEENTRIES::removeDelimitersAndExpand()

Remove enclosures around entry field values. Additionally, expand macros if flag set.

3 calls to PARSEENTRIES::removeDelimitersAndExpand()
PARSEENTRIES::extractStringValue in modules/bibtexParse/PARSEENTRIES.php
Extract value part of @string field enclosed by double-quotes or braces. The string may be expanded with previously-defined strings.
PARSEENTRIES::getEntries in modules/bibtexParse/PARSEENTRIES.php
PARSEENTRIES::returnArrays in modules/bibtexParse/PARSEENTRIES.php
Return arrays of entries etc. to the calling process.

File

modules/bibtexParse/PARSEENTRIES.php, line 470

Class

PARSEENTRIES
// Parse a file $parse = NEW PARSEENTRIES(); $parse->expandMacro = TRUE; // $array = array("RMP" =>"Rev., Mod. Phys."); // $parse->loadStringMacro($array); // $parse->removeDelimit = FALSE; // …

Code

public function removeDelimitersAndExpand($string, $inpreamble = FALSE) {

  // Only expand the macro if flag set, if strings defined and not in preamble.
  if (!$this->expandMacro || empty($this->strings) || $inpreamble) {
    $string = $this
      ->removeDelimiters($string);
  }
  else {
    $stringlist = $this
      ->explodeString($string);
    $string = "";
    foreach ($stringlist as $str) {

      // Trim the string since usually # is enclosed by spaces.
      $str = trim($str);

      // Replace the string if macro is already defined
      // strtolower is used since macros are case insensitive.
      if (isset($this->strings[strtolower($str)])) {
        $string .= $this->strings[strtolower($str)];
      }
      else {
        $string .= $this
          ->removeDelimiters(trim($str));
      }
    }
  }
  return $string;
}