Exemple #1
0
 $result = queryMySQLDatabase($queryUserData);
 // function 'queryMySQLDatabase()' is defined in 'include.inc.php'
 getUserGroups($tableUserData, $loginUserID);
 // update the 'userGroups' session variable (function 'getUserGroups()' is defined in 'include.inc.php')
 // Send EMAIL announcement:
 if ($sendEmailAnnouncements == "yes") {
     // first, build an appropriate author string:
     // Call the 'extractAuthorsLastName()' function (defined in 'include.inc.php') to extract the last name of a particular author (specified by position). Required Parameters:
     //   1. pattern describing delimiter that separates different authors
     //   2. pattern describing delimiter that separates author name & initials (within one author)
     //   3. position of the author whose last name shall be extracted (e.g., "1" will return the 1st author's last name)
     //   4. contents of the author field
     $authorString = extractAuthorsLastName("/ *; */", "/ *, */", 1, $authorName);
     if ($authorCount == "2") {
         $authorString .= " & ";
         $authorString .= extractAuthorsLastName("/ *; */", "/ *, */", 2, $authorName);
     }
     if ($authorCount == "3") {
         // at least three authors
         $authorString .= " et al";
     }
     // send a notification email to the mailing list email address '$mailingListEmail' (specified in 'ini.inc.php'):
     $emailRecipient = "Literature Database Announcement List <" . $mailingListEmail . ">";
     $emailSubject = "New entry: " . $authorString . " " . $yearNo;
     if (!empty($publicationName)) {
         $emailSubject .= " (" . $publicationName;
         if (!empty($volumeNo)) {
             $emailSubject .= " " . $volumeNo . ")";
         } else {
             $emailSubject .= ")";
         }
Exemple #2
0
function extractDetailsFromAuthors($authorString, $options)
{
    global $extractDetailsAuthorsDefault;
    // defined in 'ini.inc.php'
    $returnRawAuthorString = false;
    if (empty($options)) {
        // if '$options' is empty
        $options = $extractDetailsAuthorsDefault;
    }
    // load the default options
    if (preg_match("/^\\[-?\\d*\\|[^][|]*\\|[^][|]*\\]\$/i", $options)) {
        // extract the individual options:
        if (preg_match("/^\\[-?\\d+\\|/i", $options)) {
            $useMaxNoOfAuthors = preg_replace("/\\[(-?\\d+)\\|[^][|]*\\|[^][|]*\\]/i", "\\1", $options);
            // regex note: to include a literal closing bracket (']') in a negated character class ('[^...]') it must be positioned right after the caret character ('^') such as in: '[^]...]'
            if ($useMaxNoOfAuthors == 0) {
                // the special number '0' indicates that all authors shall be retrieved
                $useMaxNoOfAuthors = 250;
            } elseif ($useMaxNoOfAuthors < 0) {
                // negative numbers have currently no meaning and will be treated as if the corresponding positive number was given
                $useMaxNoOfAuthors = abs($useMaxNoOfAuthors);
            }
        } elseif (preg_match("/^\\[\\|/i", $options)) {
            // if the first option was left empty we assume that the raw author string shall be returned without any modification
            $returnRawAuthorString = true;
        }
        $authorConnectorString = preg_replace("/\\[-?\\d*\\|([^][|]*)\\|[^][|]*\\]/i", "\\1", $options);
        $etalIdentifierString = preg_replace("/\\[-?\\d*\\|[^][|]*\\|([^][|]*)\\]/i", "\\1", $options);
    } else {
        $useMaxNoOfAuthors = 2;
        $authorConnectorString = "+";
        $etalIdentifierString = "_etal";
    }
    if ($returnRawAuthorString) {
        $authorDetails = $authorString;
    } else {
        $authorDetails = "";
        // initialize variable which will hold the author identifier string
        // Add first author (plus additional authors if available up to the number of authors specified in '$useMaxNoOfAuthors');
        // but if more authors are present as in '$useMaxNoOfAuthors', add the contents of '$etalIdentifierString' after the first(!) author ignoring all other authors.
        // Example with '$extractDetailsAuthorsDefault = "[2|+|_etal]"':
        //   $authorString = "Steffens, M"                            -> $authorDetails = "Steffens"
        //   $authorString = "Steffens, M; Thomas, D"                 -> $authorDetails = "Steffens+Thomas"
        //   $authorString = "Steffens, M; Thomas, D; Dieckmann, GS"  -> $authorDetails = "Steffens_etal"
        // Example with '$extractDetailsAuthorsDefault = "[1|+|++]"':
        //   $authorString = "Steffens, M"                            -> $authorDetails = "Steffens"
        //   $authorString = "Steffens, M; Thomas, D"                 -> $authorDetails = "Steffens++"
        //   $authorString = "Steffens, M; Thomas, D; Dieckmann, GS"  -> $authorDetails = "Steffens++"
        for ($i = 1; $i <= $useMaxNoOfAuthors + 1; $i++) {
            if (preg_match("/^[^;]+(;[^;]+){" . ($i - 1) . "}/", $authorString)) {
                if ($i > 1) {
                    if (preg_match("/^[^;]+(;[^;]+){" . $useMaxNoOfAuthors . "}/", $authorString)) {
                        $authorDetails .= $etalIdentifierString;
                        break;
                    } else {
                        $authorDetails .= $authorConnectorString;
                    }
                }
                // Call the 'extractAuthorsLastName()' function to extract the last name of a particular author (specified by position):
                // (see function header for description of required parameters)
                $authorDetails .= extractAuthorsLastName("/ *; */", "/ *, */", $i, $authorString);
            } else {
                break;
            }
        }
    }
    return $authorDetails;
}
Exemple #3
0
function contextObject($row)
{
    global $databaseBaseURL;
    // defined in 'ini.inc.php'
    // The array '$transtab_refbase_ascii' contains search & replace patterns for
    // conversion from refbase markup to plain text
    global $transtab_refbase_ascii;
    // defined in 'transtab_refbase_ascii.inc.php'
    // Defines search & replace 'actions' that will be applied to all those
    // refbase fields that are listed in the corresponding 'fields' element:
    $plainTextSearchReplaceActionsArray = array(array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), 'actions' => $transtab_refbase_ascii));
    foreach ($row as $rowFieldName => $rowFieldValue) {
        // Apply search & replace 'actions' to all fields that are listed in the 'fields'
        // element of the arrays contained in '$plainTextSearchReplaceActionsArray':
        foreach ($plainTextSearchReplaceActionsArray as $fieldActionsArray) {
            if (in_array($rowFieldName, $fieldActionsArray['fields'])) {
                // function 'searchReplaceText()' is defined in 'include.inc.php'
                $row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true);
            }
        }
    }
    $co = array();
    // rfr_id
    $co["rfr_id"] = "info:sid/" . preg_replace("#http://#", "", $databaseBaseURL);
    // genre (type)
    if (isset($row['type'])) {
        if ($row['type'] == "Journal Article") {
            $co["rft.genre"] = "article";
        } elseif ($row['type'] == "Book Chapter") {
            $co["rft.genre"] = "bookitem";
        } elseif ($row['type'] == "Book Whole") {
            $co["rft.genre"] = "book";
        } elseif ($row['type'] == "Conference Article") {
            $co["rft.genre"] = "proceeding";
        } elseif ($row['type'] == "Conference Volume") {
            $co["rft.genre"] = "conference";
        } elseif ($row['type'] == "Journal") {
            $co["rft.genre"] = "journal";
        } elseif ($row['type'] == "Manuscript") {
            $co["rft.genre"] = "preprint";
        } elseif ($row['type'] == "Report") {
            $co["rft.genre"] = "report";
        }
        // "report" is only supported by OpenURL v1.0 (but not v0.1)
    }
    // atitle, btitle, title (title, publication)
    if ($row['type'] == "Journal Article" || $row['type'] == "Book Chapter") {
        if (!empty($row['title'])) {
            $co["rft.atitle"] = $row['title'];
        }
        if (!empty($row['publication'])) {
            $co["rft.title"] = $row['publication'];
            if ($row['type'] == "Book Chapter") {
                $co["rft.btitle"] = $row['publication'];
            }
        }
    } elseif (!empty($row['title'])) {
        $co["rft.title"] = $row['title'];
    }
    if ($row['type'] == "Book Whole" && !empty($row['title'])) {
        $co["rft.btitle"] = $row['title'];
    }
    // stitle (abbrev_journal)
    if (!empty($row['abbrev_journal'])) {
        $co["rft.stitle"] = $row['abbrev_journal'];
        if (empty($row['publication']) && !isset($co["rft.title"])) {
            // we duplicate the abbreviated journal name to 'rft.title' since the
            // CrossRef resolver seems to require 'rft.title' (otherwise it aborts
            // with an error: "No journal identifier supplied")
            $co["rft.title"] = $row['abbrev_journal'];
        }
    }
    // series (series_title)
    if (!empty($row['series_title'])) {
        $co["rft.series"] = $row['series_title'];
    }
    // issn
    if (!empty($row['issn'])) {
        $co["rft.issn"] = $row['issn'];
    }
    // isbn
    if (!empty($row['isbn'])) {
        $co["rft.isbn"] = $row['isbn'];
    }
    // date (year)
    if (!empty($row['year'])) {
        $co["rft.date"] = $row['year'];
    }
    // volume
    if (!empty($row['volume'])) {
        $co["rft.volume"] = $row['volume'];
    }
    // issue
    if (!empty($row['issue'])) {
        $co["rft.issue"] = $row['issue'];
    }
    // spage, epage, tpages (pages)
    // NOTE: lifted from modsxml.inc.php--should throw some into a new include file
    if (!empty($row['pages'])) {
        if (preg_match("/[0-9] *- *[0-9]/", $row['pages'])) {
            list($pagestart, $pageend) = preg_split('/\\s*[-]\\s*/', $row['pages']);
            if ($pagestart < $pageend) {
                $co["rft.spage"] = $pagestart;
                $co["rft.epage"] = $pageend;
            }
        } elseif ($row['type'] == "Book Whole") {
            $pagetotal = preg_replace('/^(\\d+)\\s*pp?\\.?$/', "\\1", $row['pages']);
            $co["rft.tpages"] = $pagetotal;
        } else {
            $co["rft.spage"] = $row['pages'];
        }
    }
    // aulast, aufirst, author (author)
    if (!empty($row['author'])) {
        $author = $row['author'];
        $aulast = extractAuthorsLastName("/ *; */", "/ *, */", 1, $author);
        $aufirst = extractAuthorsGivenName("/ *; */", "/ *, */", 1, $author);
        if (!empty($aulast)) {
            $co["rft.aulast"] = $aulast;
        }
        if (!empty($aufirst)) {
            $co["rft.aufirst"] = $aufirst;
        }
        // TODO: cleanup and put this function in include.inc.php?
        $authorcount = count(preg_split("/ *; */", $author));
        for ($i = 0; $i < $authorcount - 1; $i++) {
            $aul = extractAuthorsLastName("/ *; */", "/ *, */", $i + 2, $author);
            $auf = extractAuthorsGivenName("/ *; */", "/ *, */", $i + 2, $author);
            if (!empty($aul)) {
                $au = $aul;
                if (!empty($auf)) {
                    $au .= ", ";
                }
            }
            if (!empty($auf)) {
                $au .= $auf;
            }
            if (!empty($au)) {
                $co["rft.au" . $i] = $au;
            }
        }
    }
    // pub (publisher)
    if (!empty($row['publisher'])) {
        $co["rft.pub"] = $row['publisher'];
    }
    // place
    if (!empty($row['place'])) {
        $co["rft.place"] = $row['place'];
    }
    // id (doi, url)
    if (!empty($row['doi'])) {
        $co["rft_id"] = "info:doi/" . $row['doi'];
    } elseif (!empty($row['url'])) {
        $co["rft_id"] = $row['url'];
    }
    return $co;
}
Exemple #4
0
function renderRefbase($input, &$parser)
{
    $hostName = "localhost";
    $databaseName = "literature";
    $username = "******";
    $password = "******";
    $tableRefs = "refs";
    $databaseBaseURL = "http://" . $_SERVER['HTTP_HOST'] . "/refbase/";
    $transtab_refbase_html = array("/__(?!_)(.+?)__/" => "<u>\\1</u>", "/_(.+?)_/" => "<i>\\1</i>", "/\\*\\*(.+?)\\*\\*/" => "<b>\\1</b>", "/\\[super:(.+?)\\]/i" => "<sup>\\1</sup>", "/\\[sub:(.+?)\\]/i" => "<sub>\\1</sub>", "/\\[permil\\]/" => "&permil;", "/\\[infinity\\]/" => "&infin;", "/\\[alpha\\]/" => "&alpha;", "/\\[beta\\]/" => "&beta;", "/\\[gamma\\]/" => "&gamma;", "/\\[delta\\]/" => "&delta;", "/\\[epsilon\\]/" => "&epsilon;", "/\\[zeta\\]/" => "&zeta;", "/\\[eta\\]/" => "&eta;", "/\\[theta\\]/" => "&theta;", "/\\[iota\\]/" => "&iota;", "/\\[kappa\\]/" => "&kappa;", "/\\[lambda\\]/" => "&lambda;", "/\\[mu\\]/" => "&mu;", "/\\[nu\\]/" => "&nu;", "/\\[xi\\]/" => "&xi;", "/\\[omicron\\]/" => "&omicron;", "/\\[pi\\]/" => "&pi;", "/\\[rho\\]/" => "&rho;", "/\\[sigmaf\\]/" => "&sigmaf;", "/\\[sigma\\]/" => "&sigma;", "/\\[tau\\]/" => "&tau;", "/\\[upsilon\\]/" => "&upsilon;", "/\\[phi\\]/" => "&phi;", "/\\[chi\\]/" => "&chi;", "/\\[psi\\]/" => "&psi;", "/\\[omega\\]/" => "&omega;", "/\\[Alpha\\]/" => "&Alpha;", "/\\[Beta\\]/" => "&Beta;", "/\\[Gamma\\]/" => "&Gamma;", "/\\[Delta\\]/" => "&Delta;", "/\\[Epsilon\\]/" => "&Epsilon;", "/\\[Zeta\\]/" => "&Zeta;", "/\\[Eta\\]/" => "&Eta;", "/\\[Theta\\]/" => "&Theta;", "/\\[Iota\\]/" => "&Iota;", "/\\[Kappa\\]/" => "&Kappa;", "/\\[Lambda\\]/" => "&Lambda;", "/\\[Mu\\]/" => "&Mu;", "/\\[Nu\\]/" => "&Nu;", "/\\[Xi\\]/" => "&Xi;", "/\\[Omicron\\]/" => "&Omicron;", "/\\[Pi\\]/" => "&Pi;", "/\\[Rho\\]/" => "&Rho;", "/\\[Sigma\\]/" => "&Sigma;", "/\\[Tau\\]/" => "&Tau;", "/\\[Upsilon\\]/" => "&Upsilon;", "/\\[Phi\\]/" => "&Phi;", "/\\[Chi\\]/" => "&Chi;", "/\\[Psi\\]/" => "&Psi;", "/\\[Omega\\]/" => "&Omega;", "/(?:\"|&quot;)(.+?)(?:\"|&quot;)/" => "&ldquo;\\1&rdquo;", "/ +- +/" => " &#8211; ");
    $link = mysql_connect($hostName, $username, $password);
    if (!$link) {
        die("Couldn't connect to MySQL");
    }
    mysql_select_db($databaseName, $link) or die("Couldn't open {$db}: " . mysql_error());
    //select the new updated values
    $result = mysql_query("SELECT type, author, title, year, publication, volume, issue, pages, publisher, place, language, issn, doi FROM {$tableRefs} where serial={$input}") or die("SELECT Error: " . mysql_error());
    $cite = "";
    while ($row = mysql_fetch_array($result)) {
        if ($row["type"] == "Journal Article") {
            $cite .= "{{cite_journal|url={$databaseBaseURL}" . "show.php?record={$input}|";
            if (!empty($row["author"])) {
                $author = $row["author"];
                $aulast = extractAuthorsLastName(" *; *", " *, *", 1, $author);
                $aufirst = extractAuthorsGivenName(" *; *", " *, *", 1, $author);
                if (!empty($aulast)) {
                    $cite .= "last=" . $aulast . "|";
                }
                if (!empty($aufirst)) {
                    $cite .= "first=" . $aufirst . "|";
                    if (!empty($aulast)) {
                        $cite .= "authorlink={$aufirst} {$aulast}" . "|";
                    }
                }
                $authorcount = count(preg_split("/ *; */", $author));
                $au = "";
                for ($i = 0; $i < $authorcount - 1; $i++) {
                    $aul = extractAuthorsLastName(" *; *", " *, *", $i + 2, $author);
                    $auf = extractAuthorsGivenName(" *; *", " *, *", $i + 2, $author);
                    if (!empty($aul)) {
                        if (!empty($auf)) {
                            $au .= "[[{$auf} {$aul}|{$aul}, {$auf}]]; ";
                        }
                    }
                }
                if (!empty($au)) {
                    $cite .= "coauthors=" . trim($au, '; ') . "|";
                }
            }
            if (!empty($row["year"])) {
                $cite .= "year=" . $row['year'] . "|";
            }
            if (!empty($row["title"])) {
                $title = searchReplaceText($transtab_refbase_html, $row['title'], true);
                $cite .= "title=" . $title . "|";
            }
            if (!empty($row["language"])) {
                $cite .= "language=" . $row['language'] . "|";
            }
            if (!empty($row["publication"])) {
                $cite .= "journal=" . $row['publication'] . "|";
            }
            if (!empty($row["volume"])) {
                $cite .= "volume=" . $row['volume'] . "|";
            }
            if (!empty($row["issue"])) {
                $cite .= "issue=" . $row['issue'] . "|";
            }
            if (!empty($row["pages"])) {
                $cite .= "pages=" . $row['pages'] . "|";
            }
            if (!empty($row["place"])) {
                $cite .= "location=" . $row['place'] . "|";
            }
            if (!empty($row["publiser"])) {
                $cite .= "publisher=" . $row['publisher'] . "|";
            }
            if (!empty($row["issn"])) {
                $cite .= "issn=" . $row['issn'] . "|";
            }
            if (!empty($row["doi"])) {
                $cite .= "doi=" . $row['doi'] . "|";
            }
            $cite .= "}}";
        }
    }
    global $wgParser;
    $output = $wgParser->recursiveTagParse($cite);
    return $output;
}