You are here

function PARSEENTRIES::extractEntries in Bibliography Module 5

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

File

bibtexParse/PARSEENTRIES.php, line 437

Class

PARSEENTRIES

Code

function extractEntries() {
  $inside = $possibleEntryStart = FALSE;
  $entry = "";
  while ($line = $this
    ->getLine()) {
    if ($possibleEntryStart) {
      $line = $possibleEntryStart . $line;
    }
    if (!$inside && strchr($line, "@")) {

      // throw all characters before the '@'
      $line = strstr($line, '@');
      if (!strchr($line, "{") && !strchr($line, "(")) {
        $possibleEntryStart = $line;
      }
      elseif (preg_match("/@.*([{(])/U", preg_quote($line), $matches)) {
        $inside = TRUE;
        if ($matches[1] == '{') {
          $delimitEnd = '}';
        }
        else {
          $delimitEnd = ')';
        }
        $possibleEntryStart = FALSE;
      }
    }
    if ($inside) {
      $entry .= " " . $line;
      if ($j = $this
        ->closingDelimiter($entry, $delimitEnd)) {

        // all characters after the delimiter are thrown but the remaining
        // characters must be kept since they may start the next entry !!!
        $lastLine = substr($entry, $j + 1);
        $entry = substr($entry, 0, $j + 1);

        // Strip excess whitespaces from the entry
        $entry = preg_replace('/\\s\\s+/', ' ', $entry);
        $this
          ->parseEntry($entry);
        $entry = strchr($lastLine, "@");
        if ($entry) {
          $inside = TRUE;
        }
        else {
          $inside = FALSE;
        }
      }
    }
  }
}