Lines Matching defs:entry

135      * Array with the "allowed" entry types
277 $entry = false;
294 if ((0 == $open) && ('@' == $char)) { //The beginning of an entry
295 $entry = true;
296 } elseif ($entry && ('{' == $char) && ('\\' != $lastchar)) { //Inside an entry and non quoted brace is opening
303 } elseif ($entry && ('}' == $char) && ('\\' != $lastchar)) { //Inside an entry and non quoted brace is closing
314 if (0 == $open) { //End of entry
315 $entry = false;
325 if ($entry) { //Inside entry
357 foreach ($this->data as $entry) {
358 $cites[] = $entry['cite'];
393 $entry = false;
407 if ((0 == $open) && ('@' == $char)) { //The beginning of an entry
408 $entry = true;
409 } elseif ($entry && ('{' == $char) && ('\\' != $lastchar)) { //Inside an entry and non quoted brace is opening
411 } elseif ($entry && ('}' == $char) && ('\\' != $lastchar)) { //Inside an entry and non quoted brace is closing
416 if (0 == $open) { //End of entry
417 $entry = false;
429 if ($entry) { //Inside entry
453 foreach ($this->data as $entry) {
454 $cites[] = $entry['cite'];
476 * Split entry in key and actual contents, call stringCallback for @string entries and bibItemCallback for all other entries.
478 * @param string $entry BibTeX entry, starting with @ and ending BEFORE the closing brace of the entry
480 * @param callable $bibItemCallback Will be called with two arguments (key, full entry as string) for all non-@string entries
482 private function _storeBibTeXEntry($entry, $stringCallback, $bibItemCallback)
484 if ('@string' == strtolower(substr($entry, 0, 7))) {
486 preg_match('/^@\w+\{(.+)/', $entry, $matches);
490 $entry = substr(trim($m[1]), 1, -1);
491 call_user_func($stringCallback, $string, $entry);
495 $entry = $entry.'}';
498 preg_match('/^@(\w+)\{(.+),/', $entry, $matches);
502 call_user_func($bibItemCallback, $key, $entry);
506 throw new InvalidArgumentException('Could not parse entry "'.$entry.'"');
510 * Store given entry in this object's members
512 * @param string $entry BibTeX entry, starting with @ and ending BEFORE the closing brace of the entry
514 private function _storeEntryInClass($entry)
518 $this->_storeBibTeXEntry($entry, $stringCallback, $bibItemCallback);
522 * Add/update entry in SQLite DB (immediately)
524 private function _addEntryToSQLiteDB($entry)
526 $stringCallback = fn($key, $value) => $this->sqlite->query("INSERT OR REPLACE INTO strings (string, entry) VALUES (?,?)", $key, $value);
527 $bibItemCallback = fn($key, $value) => $this->sqlite->query("INSERT OR REPLACE INTO bibtex (key, entry) VALUES (?,?)", $key, $value);
528 $this->_storeBibTeXEntry($entry, $stringCallback, $bibItemCallback);
532 * Prepare an SQL statement to insert/update $entry in the DB.
534 private function _prepareSqlStatement($entry)
536 $stringCallback = fn($key, $value) => $this->_sqlStatements[] = array("INSERT OR REPLACE INTO strings (string, entry) VALUES (?,?)", array($key, $value));
537 $bibItemCallback = fn($key, $value) => $this->_sqlStatements[] = array("INSERT OR REPLACE INTO bibtex (key, entry) VALUES (?,?)", array($key, $value));
538 $this->_storeBibTeXEntry($entry, $stringCallback, $bibItemCallback);
571 * Extracting the data of one bibtex entry
574 * Then every entry is parsed by this function.
575 * It parses the entry backwards.
577 * A copy is made of the entry if warnings should be generated. This takes quite
581 * Again the entry is shortened.
587 * @param string $entry The entry
588 * @return array The representation of the entry or false if there is a problem
590 private function _parseEntry($entry)
594 $entrycopy = $entry; //We need a copy for printing the warnings
596 $ret = array('bibtex' => $entry.'}');
597 if ('@string' == strtolower(substr($entry, 0, 7))) {
599 preg_match('/^@\w+\{(.+)/' ,$entry, $matches);
605 } elseif ('@preamble' == strtolower(substr($entry, 0, 9))) {
608 $this->_generateWarning('PREAMBLE_ENTRY_NOT_YET_SUPPORTED', '', $entry.'}');
613 preg_match('/^@\w+\{([\w\d]+),/' ,$entry, $matches);
620 while (strrpos($entry,'=') !== false) {
621 $position = strrpos($entry, '=');
624 if (substr($entry, $position-1, 1) == '\\') {
628 $proceed = $this->_checkEqualSign($entry, $position);
631 $substring = substr($entry, 0, $position);
634 if (substr($entry, $position-1, 1) == '\\') {
638 $proceed = $this->_checkEqualSign($entry, $position);
642 $value = trim(substr($entry, $position+1));
643 $entry = substr($entry, 0, $position);
656 $stringReplacement = $this->sqlite->res2arr($this->sqlite->query("SELECT entry FROM strings WHERE string = ?",$value));
658 $value = $stringReplacement[0]['entry'];
679 $position = strrpos($entry, ',');
680 $field = strtolower(trim(substr($entry, $position+1)));
682 $entry = substr($entry, 0, $position);
684 //Parsing cite and entry type
685 $arr = explode('{', $entry);
693 $this->_generateWarning('WARNING_NOT_ALLOWED_ENTRY_TYPE', $ret['entrytype'], $entry.'}');
736 private function _replaceLatex($entry) {
738 $entry = preg_replace('/\\\emph\{([^\}]+)\}/', '<em>$1</em>', $entry);
740 $entry = preg_replace('/\\\textbf\{([^\}]+)\}/', '<strong>$1</strong>', $entry);
742 $entry = str_replace("``","&quot;",$entry);
743 $entry = str_replace("''","&quot;",$entry);
745 $entry = str_replace("\&","&amp;",$entry);
747 $entry = str_replace("\%","%;",$entry);
749 $entry = str_replace("\ "," ",$entry);
751 $entry = str_replace("---","&mdash;",$entry);
753 $entry = str_replace("--","-",$entry);
755 $entry = preg_replace("/\\\url\{([^\}]+)\}/",'<a href="\\1">\\1</a>',$entry);
757 $entry = preg_replace('/\\\"\{([aeiouyAEIOU])\}/',"&\\1uml;",$entry);
758 $entry = preg_replace('/\\\"([aeiouyAEIOU])/',"&\\1uml;",$entry);
759 $entry = str_replace("\ss","&szlig;",$entry);
760 $entry = str_replace('"s',"&szlig;",$entry);
763 $entry = str_replace("\'c","&#x107;",$entry);
764 $entry = preg_replace("/\\\'(.?)/","&\\1acute;",$entry);
766 $entry = preg_replace("/\\\`(.?)/","&\\1grave;",$entry);
768 $entry = preg_replace("/\\\(\^)(.?)/","&\\2circ;",$entry);
770 $entry = str_replace('\v{z}',"&#x17E;",$entry);
771 $entry = str_replace('\v{c}',"&#x10D;",$entry);
773 $entry = preg_replace("/\\\c\{(.?)\}/","\\1&#x0327;",$entry);
775 $entry = preg_replace("/\\\~(.?)/","&\\1tilde;",$entry);
777 $entry = preg_replace('/\\\([aoAO]{1}[eE]{1})/',"&\\1lig;",$entry);
779 $entry = str_replace("\i","&#305;",$entry);
781 $entry = str_replace("\={u}","&#363;",$entry);
783 $entry = str_replace("\l","&#322;",$entry);
784 $entry = str_replace("\L","&#321;",$entry);
787 $entry = preg_replace('/\\\([oO]{1})/',"&\\1slash;",$entry);
789 $entry = preg_replace('/\\\([aA]{1})([aA]{1})/',"&\\1ring;",$entry);
791 $entry = str_replace("~","&nbsp;",$entry);
793 preg_match('/\$([^$]+)\$/' ,$entry, $matches);
797 $entry = preg_replace("/\^\{([^\}]+)\}/","<sup>\\1</sup>",$entry);
798 $entry = preg_replace("/_\{([^\}]+)\}/","<sub>\\1</sub>",$entry);
799 $entry = preg_replace("/\^([\\\]{1}\w+)/","<sup>\\1</sup>",$entry);
800 $entry = preg_replace("/_([\\\]{1}\w+)/","<sub>\\1</sub>",$entry);
801 $entry = preg_replace("/\^([^\\\]{1})/","<sup>\\1</sup>",$entry);
802 $entry = preg_replace("/_([^\\\]{1})/","<sub>\\1</sub>",$entry);
805 $entry = str_replace($orig,$repl,$entry);
813 $entry = str_replace($upLatex,$upHtml,$entry);
814 $entry = str_replace($loLatex,$loHtml,$entry);
818 $entry = str_replace("$","",$entry);
820 return $entry;
826 * Sometimes there is a problem if a '=' is used inside an entry (for example abstract).
831 * @param string $entry The text of the whole remaining entry
835 private function _checkEqualSign($entry, $position)
841 $length = strlen($entry);
844 $precedingchar = substr($entry, $i-1, 1);
845 $char = substr($entry, $i, 1);
856 //There is still the posibility that the entry is delimited by double quotes.
859 $entrycopy = trim($entry);
867 //Remember we begin to search the entry backwards so the " has to show up twice - ending and beginning delimiter
871 $precedingchar = substr($entry, $i-1, 1);
872 $char = substr($entry, $i, 1);
887 * Checking if the entry type is allowed
890 * @param string $entry The entry to check
893 private function _checkAllowedEntryType($entry)
895 return in_array($entry, $this->allowedEntryTypes);
899 * Checking whether an at is outside an entry
901 * Sometimes an entry misses an entry brace. Then the at of the next entry seems to be
902 * inside an entry. This is checked here. When it is most likely that the at is an opening
903 * at of the next entry this method returns true.
906 * @param string $entry The text of the entry until the at
907 * @return bool true if the at is correct, false if the at is likely to begin the next entry.
909 private function _checkAt($entry)
915 if (strrpos($entry,'=') !== false) {
916 $position = strrpos($entry, '=');
918 if (substr($entry, $position-1, 1) == '\\') {
922 $substring = substr($entry, 0, $position);
925 if (substr($entry, $position-1, 1) == '\\') {
929 $value = trim(substr($entry, $position+1));
942 //if open is grater zero were are inside an entry
954 * @param string $entry The entry where the Delimiter should be stripped from
955 * @return string Stripped entry
957 private function _stripDelimiter($entry)
960 $length = strlen($entry);
961 $firstchar = substr($entry, 0, 1);
962 $lastchar = substr($entry, -1, 1);
965 $entry = substr($entry, 1, -1);
969 $firstchar = substr($entry, 0, 1);
970 $lastchar = substr($entry, -1, 1);
972 return $entry;
976 * Unwrapping entry
979 * @param string $entry The entry to unwrap
980 * @return string unwrapped entry
982 private function _unwrap($entry)
984 $entry = preg_replace('/\s+/', ' ', $entry);
985 return trim($entry);
989 * Wordwrap an entry
992 * @param string $entry The entry to wrap
993 * @return string wrapped entry
995 private function _wordwrap($entry)
997 if ( (''!=$entry) && (is_string($entry)) ) {
998 $entry = wordwrap($entry, $this->_options['wordWrapWidth'], $this->_options['wordWrapBreak'], $this->_options['wordWrapCut']);
1000 return $entry;
1007 * @param string $entry The entry with the authors
1010 private function _extractAuthors($entry) {
1011 $entry = $this->_unwrap($entry);
1013 $entry = str_replace(' AND ',' and ',$entry);
1015 $authorarray = explode(' and ', $entry);
1075 //The last entry is always the last!
1081 //The first entry must contain von and last
1085 if (1==$size) { //Only one entry->got to be the last
1119 //Everything in the last entry is first
1183 * @param string $entry The entry aka one line which which should be validated
1187 private function _validateValue($entry, $wholeentry)
1189 //There is no @ allowed if the entry is enclosed by braces
1190 if (preg_match('/^{.*@.*}$/', $entry)) {
1191 $this->_generateWarning('WARNING_AT_IN_BRACES', $entry, $wholeentry);
1193 //No escaped " allowed if the entry is enclosed by double quotes
1194 if (preg_match('/^\".*\\".*\"$/', $entry)) {
1195 $this->_generateWarning('WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES', $entry, $wholeentry);
1201 for ($i = 0; $i < strlen($entry); $i++) {
1202 $char = substr($entry, $i, 1);
1212 $this->_generateWarning('WARNING_UNBALANCED_AMOUNT_OF_BRACES', $entry, $wholeentry);
1217 * Remove curly braces from entry
1254 * @param string $entry The line of the entry where the warning occurred
1255 * @param string $wholeentry OPTIONAL The whole entry where the warning occurred
1257 private function _generateWarning($type, $entry, $wholeentry='')
1260 $warning['entry'] = $entry;