Example #1
0
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
    global $alnum, $alpha, $cntrl, $dash, $digit, $graph, $lower, $print, $punct, $space, $upper, $word, $patternModifiers;
    // defined in 'transtab_unicode_charset.inc.php' and 'transtab_latin1_charset.inc.php'
    static $uspsStateAbbreviations;
    // Official USPS state abbreviations:
    // see <http://www.usps.com/ncsc/lookups/usps_abbreviations.htm>
    $uspsStateAbbreviations = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|" . "NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY";
    $record = "";
    // make sure that our buffer variable is empty
    // --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
    if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)\$/", $row['type'])) {
        if (!empty($row['author'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $author = reArrangeAuthorContents($row['author'], true, "/ *; */", ", ", ", ", "/ *, */", " ", " ", "", false, false, true, "6", "6", ", et al.", $encodeHTML);
            if (!preg_match("/\\. *\$/", $author)) {
                $record .= $author . ".";
            } else {
                $record .= $author;
            }
        }
        if (!empty($row['title'])) {
            if (!empty($row['author'])) {
                $record .= " ";
            }
            $record .= $row['title'];
        }
        // From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
        // if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
        if (!preg_match("/[?!.] *\$/", $record)) {
            $record .= ".";
        }
        if (!empty($row['abbrev_journal'])) {
            // abbreviated journal name
            $record .= " " . preg_replace("/\\./", "", $row['abbrev_journal']);
        } elseif (!empty($row['publication'])) {
            // publication (= journal) name
            $record .= " " . $row['publication'];
        }
        if ($row['online_publication'] == "yes") {
            // this record refers to an online publication
            $record .= " [Internet]";
        }
        // NOTE: some of the above mentioned resources use "[serial online]", "[serial on the Internet]" or just "[online]" instead
        // NOTE: the formatting of year/volume/issue is meant for journal articles (TODO: newspaper/magazine articles)
        if (!empty($row['year'])) {
            // year
            $record .= ". " . $row['year'];
        }
        if ($row['online_publication'] == "yes") {
            // append the current date if this record refers to an online publication
            $record .= " [cited " . date("Y M j") . "]";
        }
        if (!empty($row['volume']) || !empty($row['issue'])) {
            $record .= ";";
        }
        if (!empty($row['volume'])) {
            // volume (=month)
            $record .= $row['volume'];
        }
        if (!empty($row['issue'])) {
            // issue (=day)
            $record .= "(" . $row['issue'] . ")";
        }
        if (!empty($row['pages'])) {
            if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) {
                // only add ": " if either year, volume, issue, abbrev_journal or publication isn't empty
                $record .= ":";
            }
            $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "", "", "", "", "", "", true);
            // function 'formatPageInfo()' is defined in 'cite.inc.php'
        }
        if ($row['online_publication'] == "yes") {
            // append an optional string (given in 'online_citation') plus the DOI (or URL):
            if (!empty($row['online_citation'])) {
                if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) {
                    if (empty($row['pages'])) {
                        $record .= ":";
                    } else {
                        $record .= ";";
                    }
                    // append to pages (TODO: not sure whether this is correct)
                }
                $record .= $row['online_citation'];
            }
            if (!empty($row['doi']) || !empty($row['url'])) {
                if (!empty($row['online_citation']) or empty($row['online_citation']) and !empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) {
                    // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty
                    $record .= ".";
                }
                $record .= " Available from: " . $markupPatternsArray["underline-prefix"];
                // NOTE: some of the above mentioned resources use "Available from: URL:http://..." instead
                if (!empty($row['doi'])) {
                    // doi
                    $uri = "http://dx.doi.org/" . $row['doi'];
                } else {
                    // url
                    $uri = $row['url'];
                }
                if ($encodeHTML) {
                    $record .= encodeHTML($uri);
                } else {
                    $record .= $uri;
                }
                $record .= $markupPatternsArray["underline-suffix"];
            }
        }
        if (!preg_match("/\\. *\$/", $record) and $row['online_publication'] != "yes") {
            $record .= ".";
        }
        // NOTE: the examples in the above mentioned resources differ wildly w.r.t. whether the closing period should be omitted for online publications
    } elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)\$/", $row['type'])) {
        if (!empty($row['author'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $author = reArrangeAuthorContents($row['author'], true, "/ *; */", ", ", ", ", "/ *, */", " ", " ", "", false, false, true, "6", "6", ", et al.", $encodeHTML);
            if (!preg_match("/\\. *\$/", $author)) {
                $record .= $author . ".";
            } else {
                $record .= $author;
            }
        }
        if (!empty($row['title'])) {
            if (!empty($row['author'])) {
                $record .= " ";
            }
            $record .= $row['title'];
        }
        if ($row['type'] == "Abstract") {
            // for abstracts, add "[abstract]" label
            $record .= " [abstract]";
        }
        // From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
        // if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
        if (!empty($row['editor'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $editor = reArrangeAuthorContents($row['editor'], true, "/ *; */", ", ", ", ", "/ *, */", " ", " ", "", false, false, true, "6", "6", ", et al.", $encodeHTML);
            if (!preg_match("/[?!.] *\$/", $record)) {
                $record .= ".";
            }
            $record .= " In: " . $editor . ", ";
            if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+\$/", $row['editor'])) {
                // there are at least two editors (separated by ';')
                $record .= "editors";
            } else {
                // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
                $record .= "editor";
            }
        }
        $publication = preg_replace("/[ \r\n]*\\(Eds?:[^\\)\r\n]*\\)/i", "", $row['publication']);
        if (!empty($publication)) {
            if (!preg_match("/[?!.] *\$/", $record)) {
                $record .= ".";
            }
            if (empty($row['editor'])) {
                $record .= " In:";
            }
            $record .= " " . $publication;
        }
        if (!empty($row['volume'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            $record .= " Vol " . $row['volume'];
            // TODO: not sure whether this is correct
        }
        if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $row['edition'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            if (preg_match("/^\\d{1,3}\$/", $row['edition'])) {
                if ($row['edition'] == "2") {
                    $editionSuffix = "nd";
                } elseif ($row['edition'] == "3") {
                    $editionSuffix = "rd";
                } else {
                    $editionSuffix = "th";
                }
            } else {
                $editionSuffix = "";
            }
            if (!preg_match("/( ed\\.?| edition)\$/i", $row['edition'])) {
                $editionSuffix .= " ed.";
            }
            $record .= " " . $row['edition'] . $editionSuffix;
        }
        if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
            $record .= ".";
        }
        if (!empty($row['place'])) {
            // for places in the USA, format any two-letter postal code for the state (i.e. ensure upper case & wrap in parens, eg. "Boca Raton (FL)"):
            if (preg_match("/(.+?)[{$punct}{$space}]+({$uspsStateAbbreviations})[{$punct}{$space}]*\$/i{$patternModifiers}", $row['place'])) {
                $record .= " " . preg_replace("/(.+?)[{$punct}{$space}]+({$uspsStateAbbreviations})[{$punct}{$space}]*\$/ie{$patternModifiers}", "'\\1 ('.strtoupper('\\2').')'", $row['place']);
            } else {
                $record .= " " . $row['place'];
            }
        }
        if (!empty($row['publisher'])) {
            if (!empty($row['place'])) {
                $record .= ":";
            }
            $record .= " " . $row['publisher'];
        }
        if (!empty($row['year'])) {
            // year
            $record .= "; " . $row['year'];
        }
        if (!empty($row['pages'])) {
            // pages
            $record .= ". " . formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "p. ", "", "", "", "", true);
        }
        // function 'formatPageInfo()' is defined in 'cite.inc.php'
        if (!empty($row['abbrev_series_title']) or !empty($row['series_title'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            $record .= " (";
            if (!empty($row['abbrev_series_title'])) {
                // abbreviated series title
                $record .= preg_replace("/\\./", "", $row['abbrev_series_title']);
            } elseif (!empty($row['series_title'])) {
                // full series title
                $record .= $row['series_title'];
            }
            if (!empty($row['series_volume']) || !empty($row['series_issue'])) {
                $record .= "; ";
            }
            if (!empty($row['series_volume'])) {
                // series volume
                $record .= "vol " . $row['series_volume'];
            }
            if (!empty($row['series_volume']) && !empty($row['series_issue'])) {
                $record .= "; ";
            }
            // TODO: not sure whether this is correct
            if (!empty($row['series_issue'])) {
                // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
                $record .= "no " . $row['series_issue'];
            }
            // since a series volume should be prefixed with "vol", is it correct to prefix series issues with "no"?
            $record .= ")";
        }
        if (!preg_match("/\\. *\$/", $record)) {
            $record .= ".";
        }
    } else {
        if (!empty($row['author'])) {
            $author = preg_replace("/[ \r\n]*\\(eds?\\)/i", "", $row['author']);
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $author = reArrangeAuthorContents($author, true, "/ *; */", ", ", ", ", "/ *, */", " ", " ", "", false, false, true, "6", "6", ", et al.", $encodeHTML);
            // if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
            // [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
            //  so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
            if (preg_match("/[ \r\n]*\\(ed\\)/", $row['author'])) {
                // single editor
                $author = $author . ", editor";
            } elseif (preg_match("/[ \r\n]*\\(eds\\)/", $row['author'])) {
                // multiple editors
                $author = $author . ", editors";
            }
            if (!preg_match("/\\. *\$/", $author)) {
                $record .= $author . ".";
            } else {
                $record .= $author;
            }
        }
        if (!empty($row['title'])) {
            if (!empty($row['author'])) {
                $record .= " ";
            }
            $record .= $row['title'];
        }
        if ($row['type'] == "Software") {
            // for software, add software label
            $record .= " [computer program]";
        }
        if ($row['online_publication'] == "yes" and empty($row['thesis'])) {
            // this record refers to an online publication (online theses will be handled further down below)
            $record .= " [Internet]";
        }
        // NOTE: some of the above mentioned resources use "[monograph online]", "[monograph on the Internet]" or just "[online]" instead
        if (!empty($row['volume']) and $row['type'] != "Software") {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            $record .= " Vol " . $row['volume'];
            // TODO: not sure whether this is correct
        }
        if (!empty($row['edition'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            if ($row['type'] == "Software") {
                $record .= " Version " . $row['edition'];
            } elseif (!preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $row['edition'])) {
                if (preg_match("/^\\d{1,3}\$/", $row['edition'])) {
                    if ($row['edition'] == "2") {
                        $editionSuffix = "nd";
                    } elseif ($row['edition'] == "3") {
                        $editionSuffix = "rd";
                    } else {
                        $editionSuffix = "th";
                    }
                } else {
                    $editionSuffix = "";
                }
                if (!preg_match("/( ed\\.?| edition)\$/i", $row['edition'])) {
                    $editionSuffix .= " ed.";
                }
                $record .= " " . $row['edition'] . $editionSuffix;
            }
        }
        if (!empty($row['editor']) && !preg_match("/[ \r\n]*\\(eds?\\)/", $row['author'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $editor = reArrangeAuthorContents($row['editor'], true, "/ *; */", ", ", ", ", "/ *, */", " ", " ", "", false, false, true, "6", "6", ", et al.", $encodeHTML);
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            $record .= " " . $editor;
            if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+\$/", $row['editor'])) {
                // there are at least two editors (separated by ';')
                $record .= ", editors";
            } else {
                // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
                $record .= ", editor";
            }
        }
        if (!empty($row['thesis'])) {
            // TODO: do we need to use the term "[dissertation]" instead of "[Ph.D. thesis]", etc? What about other thesis types then?
            $record .= " [" . $row['thesis'];
            if ($row['online_publication'] == "yes") {
                // this record refers to an online thesis
                $record .= " on the Internet]";
            } else {
                $record .= "]";
            }
        }
        if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
            $record .= ".";
        }
        if (!empty($row['place'])) {
            // for places in the USA, format any two-letter postal code for the state (i.e. ensure upper case & wrap in parentheses, eg. "Boca Raton (FL)"):
            if (preg_match("/(.+?)[{$punct}{$space}]+({$uspsStateAbbreviations})[{$punct}{$space}]*\$/i{$patternModifiers}", $row['place'])) {
                $record .= " " . preg_replace("/(.+?)[{$punct}{$space}]+({$uspsStateAbbreviations})[{$punct}{$space}]*\$/ie{$patternModifiers}", "'\\1 ('.strtoupper('\\2').')'", $row['place']);
            } else {
                $record .= " " . $row['place'];
            }
        }
        if (!empty($row['publisher'])) {
            if (!empty($row['place'])) {
                $record .= ":";
            }
            $record .= " " . $row['publisher'];
        }
        $record .= ";";
        if (!empty($row['year'])) {
            // year
            $record .= " " . $row['year'];
        }
        if ($row['type'] == "Software") {
            if (!empty($row['volume'])) {
                // volume (=month)
                $record .= " " . $row['volume'];
            }
            if (!empty($row['issue'])) {
                // issue (=day)
                $record .= " " . $row['issue'];
            }
        }
        if ($row['online_publication'] == "yes") {
            // append the current date if this record refers to an online publication
            $record .= " [cited " . date("Y M j") . "]";
        }
        if (!empty($row['abbrev_series_title']) or !empty($row['series_title'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            $record .= " (";
            if (!empty($row['abbrev_series_title'])) {
                // abbreviated series title
                $record .= preg_replace("/\\./", "", $row['abbrev_series_title']);
            } elseif (!empty($row['series_title'])) {
                // full series title
                $record .= $row['series_title'];
            }
            if (!empty($row['series_volume']) || !empty($row['series_issue'])) {
                $record .= "; ";
            }
            if (!empty($row['series_volume'])) {
                // series volume
                $record .= "vol " . $row['series_volume'];
            }
            if (!empty($row['series_volume']) && !empty($row['series_issue'])) {
                $record .= "; ";
            }
            // TODO: not sure whether this is correct
            if (!empty($row['series_issue'])) {
                // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
                $record .= "no " . $row['series_issue'];
            }
            // since a series volume should be prefixed with "vol", is it correct to prefix series issues with "no"?
            $record .= ")";
        }
        if ($row['online_publication'] == "yes" || $row['type'] == "Software") {
            // append an optional string (given in 'online_citation') plus the DOI (or URL):
            if (!empty($row['online_citation'])) {
                if (!preg_match("/\\. *\$/", $record)) {
                    $record .= ".";
                }
                $record .= $row['online_citation'];
            }
            if (!empty($row['doi']) || !empty($row['url'])) {
                if (!preg_match("/\\. *\$/", $record)) {
                    $record .= ".";
                }
                $record .= " Available from: " . $markupPatternsArray["underline-prefix"];
                // NOTE: some of the above mentioned resources use "Available from: URL:http://..." instead
                if (!empty($row['doi'])) {
                    // doi
                    $uri = "http://dx.doi.org/" . $row['doi'];
                } else {
                    // url
                    $uri = $row['url'];
                }
                if ($encodeHTML) {
                    $record .= encodeHTML($uri);
                } else {
                    $record .= $uri;
                }
                $record .= $markupPatternsArray["underline-suffix"];
            }
        }
        if (!preg_match("/\\. *\$/", $record) and $row['online_publication'] != "yes" and $row['type'] != "Software") {
            $record .= ".";
        }
        // NOTE: the examples in the above mentioned resources differ wildly w.r.t. whether the closing period should be omitted for online publications
    }
    // --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
    // do some further cleanup:
    $record = trim($record);
    // remove any preceding or trailing whitespace
    return $record;
}
Example #2
0
function showQueryPage($operation, $viewType, $showRows, $rowOffset)
{
    global $officialDatabaseName;
    // defined in 'ini.inc.php'
    global $displayType;
    global $loc;
    // defined in 'locales/core.php'
    global $client;
    // If there's no stored message available:
    if (!isset($_SESSION['HeaderString'])) {
        $HeaderString = $loc["SearchDB"] . ":";
    } else {
        $HeaderString = $_SESSION['HeaderString'];
        // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
        // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
        deleteSessionVariable("HeaderString");
        // function 'deleteSessionVariable()' is defined in 'include.inc.php'
    }
    // For HTML output, we'll need to reset the value of the '$displayType' variable
    // (which, by default, is set to "Export"; see above); otherwise, the 'originalDisplayType'
    // parameter in the 'quickSearch' form of the page header would be incorrectly set to "Export"
    $displayType = "";
    // if '$displayType' is empty, 'show.php' will use the default view that's given in session variable 'userDefaultView'
    // Show the login status:
    showLogin();
    // (function 'showLogin()' is defined in 'include.inc.php')
    // DISPLAY header:
    // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
    displayHTMLhead(encodeHTML($officialDatabaseName) . " -- " . $loc["Search"], "index,follow", "Search the " . encodeHTML($officialDatabaseName), "", true, "", $viewType, array());
    if (!preg_match("/^Mobile\$/i", $viewType) and !preg_match("/^inc/i", $client)) {
        // Note: we omit the visible header in mobile view ('viewType=Mobile') and for include mechanisms!
        showPageHeader($HeaderString);
    }
    // Define variables holding common drop-down elements, i.e. build properly formatted <option> tag elements:
    $dropDownConditionals1Array = array("contains" => $loc["contains"], "does not contain" => $loc["contains not"], "is equal to" => $loc["equal to"], "is not equal to" => $loc["equal to not"], "starts with" => $loc["starts with"], "ends with" => $loc["ends with"]);
    $dropDownItems1 = buildSelectMenuOptions($dropDownConditionals1Array, "//", "\t\t\t", true);
    // function 'buildSelectMenuOptions()' is defined in 'include.inc.php'
    $dropDownConditionals2Array = array("is greater than" => $loc["is greater than"], "is less than" => $loc["is less than"], "is within range" => $loc["is within range"], "is within list" => $loc["is within list"]);
    $dropDownItems2 = buildSelectMenuOptions($dropDownConditionals2Array, "//", "\t\t\t", true);
    $dropDownFieldNames1Array = array("author" => $loc["DropDownFieldName_Author"], "address" => $loc["DropDownFieldName_Address"], "corporate_author" => $loc["DropDownFieldName_CorporateAuthor"], "thesis" => $loc["DropDownFieldName_Thesis"], "", "title" => $loc["DropDownFieldName_Title"], "orig_title" => $loc["DropDownFieldName_OrigTitle"], "", "year" => $loc["DropDownFieldName_Year"], "publication" => $loc["DropDownFieldName_Publication"], "abbrev_journal" => $loc["DropDownFieldName_AbbrevJournal"], "editor" => $loc["DropDownFieldName_Editor"], "", "volume_numeric" => $loc["DropDownFieldName_Volume"], "issue" => $loc["DropDownFieldName_Issue"], "pages" => $loc["DropDownFieldName_Pages"], "", "series_title" => $loc["DropDownFieldName_SeriesTitle"], "abbrev_series_title" => $loc["DropDownFieldName_AbbrevSeriesTitle"], "series_editor" => $loc["DropDownFieldName_SeriesEditor"], "series_volume_numeric" => $loc["DropDownFieldName_SeriesVolume"], "series_issue" => $loc["DropDownFieldName_SeriesIssue"], "", "publisher" => $loc["DropDownFieldName_Publisher"], "place" => $loc["DropDownFieldName_Place"], "", "edition" => $loc["DropDownFieldName_Edition"], "medium" => $loc["DropDownFieldName_Medium"], "issn" => $loc["DropDownFieldName_Issn"], "isbn" => $loc["DropDownFieldName_Isbn"], "", "language" => $loc["DropDownFieldName_Language"], "summary_language" => $loc["DropDownFieldName_SummaryLanguage"], "", "keywords" => $loc["DropDownFieldName_Keywords"], "abstract" => $loc["DropDownFieldName_Abstract"], "", "area" => $loc["DropDownFieldName_Area"], "expedition" => $loc["DropDownFieldName_Expedition"], "conference" => $loc["DropDownFieldName_Conference"], "", "doi" => $loc["DropDownFieldName_Doi"], "url" => $loc["DropDownFieldName_Url"]);
    if (isset($_SESSION['loginEmail'])) {
        // we only include the 'file' field if the user is logged in
        $dropDownFieldNames1Array["file"] = $loc["DropDownFieldName_File"];
    }
    $dropDownFieldNames1Array[] = "";
    $dropDownFieldNames1Array["notes"] = $loc["DropDownFieldName_Notes"];
    if (isset($_SESSION['loginEmail'])) {
        // we only include the 'location' field if the user is logged in
        $dropDownFieldNames1Array["location"] = $loc["DropDownFieldName_Location"];
    }
    $dropDownFieldNames2Array = array("call_number" => $loc["DropDownFieldName_CallNumber"], "", "serial" => $loc["DropDownFieldName_Serial"], "type" => $loc["DropDownFieldName_Type"], "approved" => $loc["DropDownFieldName_Approved"], "", "created_date" => $loc["DropDownFieldName_CreatedDate"], "created_time" => $loc["DropDownFieldName_CreatedTime"]);
    if (isset($_SESSION['loginEmail'])) {
        // we only include the 'created_by' field if the user is logged in
        $dropDownFieldNames2Array["created_by"] = $loc["DropDownFieldName_CreatedBy"];
    }
    $dropDownFieldNames2Array[] = "";
    $dropDownFieldNames2Array["modified_date"] = $loc["DropDownFieldName_ModifiedDate"];
    $dropDownFieldNames2Array["modified_time"] = $loc["DropDownFieldName_ModifiedTime"];
    if (isset($_SESSION['loginEmail'])) {
        // we only include the 'modified_by' field if the user is logged in
        $dropDownFieldNames2Array["modified_by"] = $loc["DropDownFieldName_ModifiedBy"];
    }
    $dropDownItems3 = buildSelectMenuOptions(array_merge($dropDownFieldNames1Array, $dropDownFieldNames2Array), "//", "\t\t\t", true);
    $dropDownConditionals3Array = array("html" => "html", "atom" => "Atom XML", "rss" => "RSS XML", "srw_dc" => "SRW_DC XML", "srw_mods" => "SRW_MODS XML");
    $dropDownItems4 = buildSelectMenuOptions($dropDownConditionals3Array, "//", "\t\t\t", true);
    // Map CQL indexes to refbase field names:
    $indexNamesArray = mapCQLIndexes();
    // function 'mapCQLIndexes()' is defined in 'webservice.inc.php'
    // --------------------------------------------------------------------
    // TODO: when the simple CQL Query Builder interface is done, a call to 'opensearch.php' (or 'opensearch.php?operation=simple')
    //       should activate that simple GUI-based interface (currently, it activates the advanced interface that you'd normally only
    //       get via 'opensearch.php?operation=cql' or 'opensearch.php?operation=advanced')
    //		if (preg_match("/^(advanced|CQL)$/i", $operation))
    showQueryFormAdvanced($dropDownItems1, $dropDownItems2, $dropDownItems3, $dropDownItems4, $showRows, $rowOffset, $indexNamesArray, $viewType);
    // let's you enter a standard CQL query directly
    //		else
    //			showQueryFormSimple($dropDownItems1, $dropDownItems2, $dropDownItems3, $dropDownItems4, $showRows, $rowOffset, $indexNamesArray, $viewType); // let's you build a CQL query via dropdown menues
    // --------------------------------------------------------------------
    // DISPLAY THE HTML FOOTER:
    // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
    if (!preg_match("/^Mobile\$/i", $viewType) and !preg_match("/^inc/i", $client)) {
        // Note: we omit the visible footer in mobile view ('viewType=Mobile') and for include mechanisms!
        showPageFooter($HeaderString);
    }
    displayHTMLfoot();
}
Example #3
0
<form method="post" action="default_toolbar2.php" id="Form1">

  <textarea id="txtContent" name="txtContent" rows=4 cols=30>
  <?php 
function encodeHTML($sHTML)
{
    $sHTML = ereg_replace("&", "&amp;", $sHTML);
    $sHTML = ereg_replace("<", "&lt;", $sHTML);
    $sHTML = ereg_replace(">", "&gt;", $sHTML);
    return $sHTML;
}
if (isset($_POST["txtContent"])) {
    $sContent = stripslashes($_POST['txtContent']);
    /*** remove (/) slashes ***/
    echo encodeHTML($sContent);
}
?>
  </textarea>

  <script>
    var oEdit1 = new InnovaEditor("oEdit1");

    oEdit1.width=700;
    oEdit1.height=450;

    /***************************************************
    ADDING CUSTOM BUTTONS
    ***************************************************/

    oEdit1.arrCustomButtons = [["CustomName1","alert('Command 1 here.')","Caption 1 here","btnCustom1.gif"],
Example #4
0
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
    $record = "";
    // make sure that our buffer variable is empty
    // --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
    if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)\$/", $row['type'])) {
        if (!empty($row['author'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $author = reArrangeAuthorContents($row['author'], true, "/ *; */", ", ", ", and ", "/ *, */", ", ", " ", ". ", false, true, false, "3", "1", ", et al.", $encodeHTML);
            // 16.
            if (!preg_match("/\\. *\$/", $author)) {
                $record .= $author . ".";
            } else {
                $record .= $author;
            }
        }
        if (!empty($row['title'])) {
            if (!empty($row['author'])) {
                $record .= " ";
            }
            $record .= '"' . $row['title'];
            if (!preg_match("/[?!.]\$/", $row['title'])) {
                $record .= ".";
            }
            $record .= '"';
        }
        // From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
        // if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
        if (!empty($row['abbrev_journal'])) {
            // abbreviated journal name
            $record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
        } elseif (!empty($row['publication'])) {
            // publication (= journal) name
            $record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
        }
        if (!empty($row['volume'])) {
            if (!empty($row['abbrev_journal']) || !empty($row['publication'])) {
                $record .= ".";
            }
            $record .= " " . $row['volume'];
        }
        if (!empty($row['issue'])) {
            // issue
            $record .= "." . $row['issue'];
        }
        if (!empty($row['year'])) {
            $record .= " (" . $row['year'] . ")";
        }
        if ($row['online_publication'] == "yes") {
            // instead of any pages info (which normally doesn't exist for online publications) we append
            // an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
            $today = date("j M. Y");
            if (!empty($row['online_citation'])) {
                if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) {
                    // only add ":" if either volume, issue, abbrev_journal or publication isn't empty
                    $record .= ":";
                }
                $record .= " " . $row['online_citation'];
            }
            if (!empty($row['doi'])) {
                if (!empty($row['online_citation']) or empty($row['online_citation']) and !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) {
                    // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
                    $record .= ".";
                }
                if ($encodeHTML) {
                    $record .= " " . $today . encodeHTML(" <http://dx.doi.org/" . $row['doi'] . ">");
                } else {
                    $record .= " " . $today . " <http://dx.doi.org/" . $row['doi'] . ">";
                }
            } elseif (!empty($row['url'])) {
                if (!empty($row['online_citation']) or empty($row['online_citation']) and !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) {
                    // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
                    $record .= ".";
                }
                if ($encodeHTML) {
                    $record .= " " . $today . encodeHTML(" <" . $row['url'] . ">");
                } else {
                    $record .= " " . $today . " <" . $row['url'] . ">";
                }
            }
        } else {
            if (!empty($row['pages'])) {
                if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) {
                    // only add ": " if either volume, issue, abbrev_journal or publication isn't empty
                    $record .= ": ";
                }
                $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]);
                // function 'formatPageInfo()' is defined in 'cite.inc.php'
            }
        }
        if (!preg_match("/\\. *\$/", $record)) {
            $record .= ".";
        }
    } elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)\$/", $row['type'])) {
        if (!empty($row['author'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $author = reArrangeAuthorContents($row['author'], true, "/ *; */", ", ", ", and ", "/ *, */", ", ", " ", ". ", false, true, false, "3", "1", ", et al.", $encodeHTML);
            // 16.
            if (!preg_match("/\\. *\$/", $author)) {
                $record .= $author . ".";
            } else {
                $record .= $author;
            }
        }
        if (!empty($row['title'])) {
            if (!empty($row['author'])) {
                $record .= " ";
            }
            $record .= '"' . $row['title'];
            if (!preg_match("/[?!.]\$/", $row['title'])) {
                $record .= ".";
            }
            $record .= '"';
        }
        $publication = preg_replace("/[ \r\n]*\\(Eds?:[^\\)\r\n]*\\)/i", "", $row['publication']);
        if (!empty($publication)) {
            // publication
            $record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"];
        }
        // From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
        // if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
        if (!empty($row['editor'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $editor = reArrangeAuthorContents($row['editor'], true, "/ *; */", ", ", ", and ", "/ *, */", " ", " ", ". ", true, true, false, "3", "1", ", et al.", $encodeHTML);
            // 16.
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+\$/", $row['editor'])) {
                // there are at least two editors (separated by ';')
                $record .= " Eds. " . $editor;
            } else {
                // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
                $record .= " Ed. " . $editor;
            }
        }
        if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $row['edition'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            if (preg_match("/^\\d{1,3}\$/", $row['edition'])) {
                if ($row['edition'] == "2") {
                    $editionSuffix = "nd";
                } elseif ($row['edition'] == "3") {
                    $editionSuffix = "rd";
                } else {
                    $editionSuffix = "th";
                }
            } else {
                $editionSuffix = "";
            }
            if (preg_match("/^(Rev\\.?|Revised)( ed\\.?| edition)?\$/i", $row['edition'])) {
                $row['edition'] = "Rev.";
            } elseif (preg_match("/^(Abr\\.?|Abridged)( ed\\.?| edition)?\$/i", $row['edition'])) {
                $row['edition'] = "Abr.";
            }
            if (!preg_match("/( ed\\.?| edition)\$/i", $row['edition'])) {
                $editionSuffix .= " ed.";
            }
            $record .= " " . $row['edition'] . $editionSuffix;
        }
        if (!empty($row['volume'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            $record .= " Vol. " . $row['volume'];
        }
        if (!empty($row['abbrev_series_title']) or !empty($row['series_title'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            $record .= " ";
            if (!empty($row['abbrev_series_title'])) {
                $record .= $row['abbrev_series_title'];
            } elseif (!empty($row['series_title'])) {
                $record .= $row['series_title'];
            }
            // full series title
            if (!empty($row['series_volume']) || !empty($row['series_issue'])) {
                $record .= ", ";
            }
            if (!empty($row['series_volume'])) {
                // series volume
                $record .= $row['series_volume'];
            }
            if (!empty($row['series_issue'])) {
                // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
                $record .= "." . $row['series_issue'];
            }
            // is it correct to format series issues similar to journal article issues?
        }
        if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
            $record .= ".";
        }
        if (!empty($row['place'])) {
            // place
            $record .= " " . $row['place'];
        }
        if (!empty($row['publisher'])) {
            if (!empty($row['place'])) {
                $record .= ":";
            }
            $record .= " " . $row['publisher'];
        }
        if (!empty($row['year'])) {
            $record .= ", " . $row['year'];
        }
        if (!empty($row['pages'])) {
            // pages
            $record .= ". " . formatPageInfo($row['pages'], $markupPatternsArray["endash"]);
        }
        // function 'formatPageInfo()' is defined in 'cite.inc.php'
        if (!preg_match("/\\. *\$/", $record)) {
            $record .= ".";
        }
    } else {
        if (!empty($row['author'])) {
            $author = preg_replace("/[ \r\n]*\\(eds?\\)/i", "", $row['author']);
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $author = reArrangeAuthorContents($author, true, "/ *; */", ", ", ", and ", "/ *, */", ", ", " ", ". ", false, true, false, "3", "1", ", et al.", $encodeHTML);
            // 16.
            // if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
            // [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
            //  so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
            if (preg_match("/[ \r\n]*\\(ed\\)/", $row['author'])) {
                // single editor
                $author = $author . ", " . "ed";
            } elseif (preg_match("/[ \r\n]*\\(eds\\)/", $row['author'])) {
                // multiple editors
                $author = $author . ", " . "eds";
            }
            if (!preg_match("/\\. *\$/", $author)) {
                $record .= $author . ".";
            } else {
                $record .= $author;
            }
        }
        if (!empty($row['title'])) {
            if (!empty($row['author'])) {
                $record .= " ";
            }
            if (!empty($row['thesis'])) {
                $record .= '"' . $row['title'];
                if (!preg_match("/[?!.]\$/", $row['title'])) {
                    $record .= ".";
                }
                $record .= '"';
            } else {
                // not a thesis
                $record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
            }
        }
        if (!empty($row['editor']) && !preg_match("/[ \r\n]*\\(eds?\\)/", $row['author'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $editor = reArrangeAuthorContents($row['editor'], true, "/ *; */", ", ", ", and ", "/ *, */", " ", " ", ". ", true, true, false, "3", "1", ", et al.", $encodeHTML);
            // 16.
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+\$/", $row['editor'])) {
                // there are at least two editors (separated by ';')
                $record .= " Eds. " . $editor;
            } else {
                // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
                $record .= " Ed. " . $editor;
            }
        }
        if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $row['edition'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            if (preg_match("/^\\d{1,3}\$/", $row['edition'])) {
                if ($row['edition'] == "2") {
                    $editionSuffix = "nd";
                } elseif ($row['edition'] == "3") {
                    $editionSuffix = "rd";
                } else {
                    $editionSuffix = "th";
                }
            } else {
                $editionSuffix = "";
            }
            if (preg_match("/^(Rev\\.?|Revised)( ed\\.?| edition)?\$/i", $row['edition'])) {
                $row['edition'] = "Rev.";
            } elseif (preg_match("/^(Abr\\.?|Abridged)( ed\\.?| edition)?\$/i", $row['edition'])) {
                $row['edition'] = "Abr.";
            }
            if (!preg_match("/( ed\\.?| edition)\$/i", $row['edition'])) {
                $editionSuffix .= " ed.";
            }
            $record .= " " . $row['edition'] . $editionSuffix;
        }
        if (!empty($row['volume'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            $record .= " Vol. " . $row['volume'];
        }
        if (!empty($row['abbrev_series_title']) or !empty($row['series_title'])) {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            $record .= " ";
            if (!empty($row['abbrev_series_title'])) {
                $record .= $row['abbrev_series_title'];
            } elseif (!empty($row['series_title'])) {
                $record .= $row['series_title'];
            }
            // full series title
            if (!empty($row['series_volume']) || !empty($row['series_issue'])) {
                $record .= ", ";
            }
            if (!empty($row['series_volume'])) {
                // series volume
                $record .= $row['series_volume'];
            }
            if (!empty($row['series_issue'])) {
                // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
                $record .= "." . $row['series_issue'];
            }
            // is it correct to format series issues similar to journal article issues?
        }
        if (!empty($row['thesis'])) {
            // TODO: a published dissertation needs to be formatted differently!
            //       see e.g. example at: <http://web.csustan.edu/english/reuben/pal/append/AXI.HTML>
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            // TODO: I've also seen MLA examples that separate thesis name, name of institution and year by dots. ?:-|
            //       Also, do we need to use the abbreviation "Diss." instead of "Ph.D. thesis"? What about other thesis types then?
            //       see e.g. <http://www.english.uiuc.edu/cws/wworkshop/writer_resources/citation_styles/mla/unpublished_diss.htm>
            $record .= " " . $row['thesis'];
            $record .= ", " . $row['publisher'];
        } else {
            if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$@", $record)) {
                $record .= ".";
            }
            if (!empty($row['place'])) {
                // place
                $record .= " " . $row['place'];
            }
            if (!empty($row['publisher'])) {
                if (!empty($row['place'])) {
                    $record .= ":";
                }
                $record .= " " . $row['publisher'];
            }
        }
        if (!empty($row['year'])) {
            // year
            $record .= ", " . $row['year'];
        }
        if ($row['online_publication'] == "yes") {
            $today = date("j M. Y");
            if (!empty($row['online_citation'])) {
                if (!preg_match("/\\. *\$/", $record)) {
                    $record .= ".";
                }
                $record .= " " . $row['online_citation'];
            }
            if (!empty($row['doi'])) {
                if (!preg_match("/\\. *\$/", $record)) {
                    $record .= ".";
                }
                if ($encodeHTML) {
                    $record .= " " . $today . encodeHTML(" <http://dx.doi.org/" . $row['doi'] . ">");
                } else {
                    $record .= " " . $today . " <http://dx.doi.org/" . $row['doi'] . ">";
                }
            } elseif (!empty($row['url'])) {
                if (!preg_match("/\\. *\$/", $record)) {
                    $record .= ".";
                }
                if ($encodeHTML) {
                    $record .= " " . $today . encodeHTML(" <" . $row['url'] . ">");
                } else {
                    $record .= " " . $today . " <" . $row['url'] . ">";
                }
            }
        }
        if (!preg_match("/\\. *\$/", $record)) {
            $record .= ".";
        }
    }
    // --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
    // do some further cleanup:
    $record = trim($record);
    // remove any preceding or trailing whitespace
    return $record;
}
Example #5
0
    } else {
        $skipBadRecords = "";
    }
} else {
    $sourceText = "";
    $showSource = "1";
    $importRecordsRadio = "only";
    $importRecords = "1";
    $skipBadRecords = "";
}
// Show the login status:
showLogin();
// (function 'showLogin()' is defined in 'include.inc.php')
// (2a) Display header:
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
displayHTMLhead(encodeHTML($officialDatabaseName) . $pageTitle, "index,follow", "Search the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
showPageHeader($HeaderString);
// (2b) Start <form> and <table> holding the form elements:
echo "\n<form action=\"import_csa_modify.php\" method=\"POST\">";
echo "\n<input type=\"hidden\" name=\"formType\" value=\"importCSA\">" . "\n<input type=\"hidden\" name=\"submit\" value=\"Import\">" . "\n<input type=\"hidden\" name=\"showLinks\" value=\"1\">";
// embed '$showLinks=1' so that links get displayed on any 'display details' page
if (isset($errors['badRecords'])) {
    if ($errors['badRecords'] == "all") {
        if (!empty($errors['skipBadRecords'])) {
            $skipBadRecordsInput = "<br>" . fieldError("skipBadRecords", $errors);
        } else {
            $skipBadRecordsInput = "";
        }
    } elseif ($errors['badRecords'] == "some") {
        if (!empty($skipBadRecords)) {
            $skipBadRecordsCheckBoxIsChecked = " checked";
Example #6
0
function showPageFooter($HeaderString)
{
    global $officialDatabaseName;
    // usage example: <a href="index.php">[? echo encodeHTML($officialDatabaseName); ?]</a>
    global $adminLoginEmail;
    global $hostInstitutionAbbrevName;
    // usage example: <a href="[? echo $hostInstitutionURL; ?]">[? echo encodeHTML($hostInstitutionAbbrevName); ?] Home</a>
    global $hostInstitutionName;
    // (note: in the examples above, square brackets must be replaced by their respective angle brackets)
    global $hostInstitutionURL;
    global $helpResourcesURL;
    global $librarySearchPattern;
    global $loginWelcomeMsg;
    // these variables are globally defined in function 'showLogin()' in 'include.inc.php'
    global $loginStatus;
    global $loginLinks;
    global $loginEmail;
    global $loc;
    // '$loc' is made globally available in 'core.php'
    ?>

<table class="pagefooter" align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds the footer">
<tr>
	<td class="small" width="105"><a href="index.php"<?php 
    echo addAccessKey("attribute", "home");
    ?>
 title="<?php 
    echo $loc["LinkTitle_Home"] . addAccessKey("title", "home");
    ?>
"><?php 
    echo $loc["Home"];
    ?>
</a></td>
	<td class="small" align="center"><?php 
    // -------------------------------------------------------
    // ... include a link to 'opensearch.php':
    ?>

		<a href="opensearch.php"<?php 
    echo addAccessKey("attribute", "cql_search");
    ?>
 title="<?php 
    echo $loc["LinkTitle_CQLSearch"] . addAccessKey("title", "cql_search");
    ?>
"><?php 
    echo $loc["CQLSearch"];
    ?>
</a><?php 
    // -------------------------------------------------------
    if (isset($_SESSION['user_permissions']) and preg_match("/allow_sql_search/", $_SESSION['user_permissions'])) {
        // ... include a link to 'sql_search.php':
        ?>

		&nbsp;|&nbsp;
		<a href="sql_search.php"<?php 
        echo addAccessKey("attribute", "sql_search");
        ?>
 title="<?php 
        echo $loc["LinkTitle_SQLSearch"] . addAccessKey("title", "sql_search");
        ?>
"><?php 
        echo $loc["SQLSearch"];
        ?>
</a><?php 
    }
    // -------------------------------------------------------
    if (!empty($librarySearchPattern)) {
        // ... include a link to 'library_search.php':
        ?>

		&nbsp;|&nbsp;
		<a href="library_search.php"<?php 
        echo addAccessKey("attribute", "lib_search");
        ?>
 title="<?php 
        echo $loc["LinkTitle_LibrarySearch_Prefix"] . encodeHTML($hostInstitutionName) . $loc["LinkTitle_LibrarySearch_Suffix"] . addAccessKey("title", "lib_search");
        ?>
"><?php 
        echo $loc["LibrarySearch"];
        ?>
</a><?php 
    }
    // -------------------------------------------------------
    if (isset($_SESSION['user_permissions']) and preg_match("/allow_details_view/", $_SESSION['user_permissions'])) {
        // ... include a link to 'show.php':
        ?>

		&nbsp;|&nbsp;
		<a href="show.php"<?php 
        echo addAccessKey("attribute", "show_rec");
        ?>
 title="<?php 
        echo $loc["LinkTitle_ShowRecord"] . addAccessKey("title", "show_rec");
        ?>
"><?php 
        echo $loc["ShowRecord"];
        ?>
</a><?php 
    }
    // -------------------------------------------------------
    if (isset($_SESSION['user_permissions']) and preg_match("/allow_cite/", $_SESSION['user_permissions'])) {
        // ... include a link to 'extract.php':
        ?>

		&nbsp;|&nbsp;
		<a href="extract.php"<?php 
        echo addAccessKey("attribute", "extract");
        ?>
 title="<?php 
        echo $loc["LinkTitle_ExtractCitations"] . addAccessKey("title", "extract");
        ?>
"><?php 
        echo $loc["ExtractCitations"];
        ?>
</a><?php 
    }
    // -------------------------------------------------------
    if (isset($_SESSION['loginEmail']) && $loginEmail == $adminLoginEmail) {
        // ... include a link to 'duplicate_manager.php':
        ?>

		&nbsp;|&nbsp;
		<a href="duplicate_manager.php" title="<?php 
        echo $loc["LinkTitle_ManageDuplicates"];
        ?>
"><?php 
        echo $loc["ManageDuplicates"];
        ?>
</a><?php 
    }
    // -------------------------------------------------------
    ?>
        <?php 
    if (!empty($helpResourcesURL)) {
        ?>
            &nbsp;|&nbsp;
            <a href="<?php 
        echo $helpResourcesURL;
        ?>
" title="<?php 
        echo $loc["LinkTitle_Help"];
        ?>
"><?php 
        echo $loc["Help"];
        ?>
</a>
        <?php 
    }
    ?>
	</td>
    <td class="refbase-credit" align="right" width="15%">
        <a href="http://www.refbase.net/"><img src="img/refbase_credit.gif" alt="powered by refbase" width="142" height="51" hspace="0" border="0"></a>
    </td>
</tr>
</table><?php 
}
Example #7
0
function showUsers($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $showMaxRow, $viewType, $displayType)
{
    global $connection;
    global $HeaderString;
    global $loginWelcomeMsg;
    global $loginStatus;
    global $loginLinks;
    global $loginEmail;
    global $adminLoginEmail;
    global $defaultCiteStyle;
    global $maximumBrowseLinks;
    global $loc;
    // '$loc' is made globally available in 'core.php'
    if ($rowsFound > 0) {
        // BEGIN RESULTS HEADER --------------------
        // 1) First, initialize some variables that we'll need later on
        // Note: In contrast to 'search.php', we don't hide any columns but the user_id column (see below)
        //       However, in order to maintain a similar code structure to 'search.php' we define $CounterMax here as well & simply set it to 0:
        $CounterMax = "0";
        // count the number of fields
        $fieldsFound = mysql_num_fields($result);
        // hide those last columns that were added by the script and not by the user
        $fieldsToDisplay = $fieldsFound - (1 + $CounterMax);
        // (1+$CounterMax) -> $CounterMax is increased by 1 in order to hide the user_id column (which was added to make the checkbox work)
        // Calculate the number of all visible columns (which is needed as colspan value inside some TD tags)
        if ($showLinks == "1") {
            $NoColumns = 1 + $fieldsToDisplay + 1;
        } else {
            $NoColumns = 1 + $fieldsToDisplay;
        }
        // add checkbox column
        // Note: we omit the results header in print/mobile view! ('viewType=Print' or 'viewType=Mobile')
        if (!preg_match("/^(Print|Mobile)\$/i", $viewType)) {
            // Specify which colums are available in the popup menus of the results header:
            $dropDownFieldsArray = array("first_name" => "first_name", "last_name" => "last_name", "title" => "title", "institution" => "institution", "abbrev_institution" => "abbrev_institution", "corporate_institution" => "corporate_institution", "address_line_1" => "address_line_1", "address_line_2" => "address_line_2", "address_line_3" => "address_line_3", "zip_code" => "zip_code", "city" => "city", "state" => "state", "country" => "country", "phone" => "phone", "email" => "email", "url" => "url", "language" => "language", "keywords" => "keywords", "notes" => "notes", "marked" => "marked", "last_login" => "last_login", "logins" => "logins", "user_id" => "user_id", "user_groups" => "user_groups", "created_date" => "created_date", "created_time" => "created_time", "created_by" => "created_by", "modified_date" => "modified_date", "modified_time" => "modified_time", "modified_by" => "modified_by");
            // Extract the first field from the 'WHERE' clause:
            if (preg_match("/ WHERE [ ()]*(\\w+)/i", $query)) {
                $selectedField = preg_replace("/.+ WHERE [ ()]*(\\w+).*/i", "\\1", $query);
            } else {
                $selectedField = "last_name";
            }
            // in the 'Search within Results" form, we'll select the 'last_name' field by default
            // Build a TABLE with forms containing options to show the user groups, refine the search results or change the displayed columns:
            //    - Build a FORM with a popup containing the user groups:
            $formElementsGroup = buildGroupSearchElements("users.php", $queryURL, $query, $showQuery, $showLinks, $showRows, $defaultCiteStyle, "", $displayType);
            // function 'buildGroupSearchElements()' is defined in 'include.inc.php'
            //    - Build a FORM containing options to refine the search results:
            //      Call the 'buildRefineSearchElements()' function (defined in 'include.inc.php') which does the actual work:
            $formElementsRefine = buildRefineSearchElements("users.php", $queryURL, $showQuery, $showLinks, $showRows, $defaultCiteStyle, "", $dropDownFieldsArray, $selectedField, $displayType);
            //    - Build a FORM containing display options (show/hide columns or change the number of records displayed per page):
            //      Call the 'buildDisplayOptionsElements()' function (defined in 'include.inc.php') which does the actual work:
            $formElementsDisplayOptions = buildDisplayOptionsElements("users.php", $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $defaultCiteStyle, "", $dropDownFieldsArray, $selectedField, $fieldsToDisplay, $displayType, "");
            echo displayResultsHeader("users.php", $formElementsGroup, $formElementsRefine, $formElementsDisplayOptions, $displayType);
            // function 'displayResultsHeader()' is defined in 'results_header.inc.php'
        }
        // and insert a divider line (which separates the results header from the browse links & results data below):
        if (!preg_match("/^(Print|Mobile)\$/i", $viewType)) {
            // Note: we omit the divider line in print/mobile view! ('viewType=Print' or 'viewType=Mobile')
            echo "\n<hr class=\"resultsheader\" align=\"center\" width=\"93%\">";
        }
        // Build a TABLE with links for "previous" & "next" browsing, as well as links to intermediate pages
        // call the 'buildBrowseLinks()' function (defined in 'include.inc.php'):
        $BrowseLinks = buildBrowseLinks("users.php", $query, $NoColumns, $rowsFound, $showQuery, $showLinks, $showRows, $rowOffset, $previousOffset, $nextOffset, "1", $maximumBrowseLinks, "sqlSearch", $displayType, $defaultCiteStyle, "", "", "", $viewType);
        // Note: we set the last 3 fields ('$citeOrder', '$orderBy' & $headerMsg') to "" since they aren't (yet) required here
        echo $BrowseLinks;
        // Start a FORM
        echo "\n<form action=\"users.php\" method=\"GET\" name=\"queryResults\">" . "\n<input type=\"hidden\" name=\"formType\" value=\"queryResults\">" . "\n<input type=\"hidden\" name=\"submit\" value=\"Add\">" . "\n<input type=\"hidden\" name=\"showRows\" value=\"{$showRows}\">" . "\n<input type=\"hidden\" name=\"rowOffset\" value=\"{$rowOffset}\">" . "\n<input type=\"hidden\" name=\"sqlQuery\" value=\"{$queryURL}\">";
        // And start a TABLE
        echo "\n<table id=\"columns\" class=\"results\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"95%\" summary=\"This table displays users of this database\">";
        // For the column headers, start another TABLE ROW ...
        echo "\n<tr>";
        // ... print a marker ('x') column (which will hold the checkboxes within the results part)
        if (!preg_match("/^(Print|Mobile)\$/i", $viewType)) {
            // Note: we omit the marker column in print/mobile view! ('viewType=Print' or 'viewType=Mobile')
            echo "\n\t<th align=\"left\" valign=\"top\">&nbsp;</th>";
        }
        // for each of the attributes in the result set...
        for ($i = 0; $i < $fieldsToDisplay; $i++) {
            // ...print out each of the attribute names
            // in that row as a separate TH (Table Header)...
            $HTMLbeforeLink = "\n\t<th align=\"left\" valign=\"top\">";
            // start the table header tag
            $HTMLafterLink = "</th>";
            // close the table header tag
            // call the 'buildFieldNameLinks()' function (defined in 'include.inc.php'), which will return a properly formatted table header tag holding the current field's name
            // as well as the URL encoded query with the appropriate ORDER clause:
            $tableHeaderLink = buildFieldNameLinks("users.php", $query, "", $result, $i, $showQuery, $showLinks, $rowOffset, $showRows, "1", $defaultCiteStyle, $HTMLbeforeLink, $HTMLafterLink, "sqlSearch", $displayType, "", "", "", $viewType);
            echo $tableHeaderLink;
            // print the attribute name as link
        }
        if ($showLinks == "1") {
            $newORDER = "ORDER BY user_id";
            // Build the appropriate ORDER BY clause to facilitate sorting by Links column
            $HTMLbeforeLink = "\n\t<th align=\"left\" valign=\"top\">";
            // start the table header tag
            $HTMLafterLink = "</th>";
            // close the table header tag
            // call the 'buildFieldNameLinks()' function (defined in 'include.inc.php'), which will return a properly formatted table header tag holding the current field's name
            // as well as the URL encoded query with the appropriate ORDER clause:
            $tableHeaderLink = buildFieldNameLinks("users.php", $query, $newORDER, $result, $i, $showQuery, $showLinks, $rowOffset, $showRows, "1", $defaultCiteStyle, $HTMLbeforeLink, $HTMLafterLink, "sqlSearch", $displayType, $loc["Links"], "user_id", "", $viewType);
            echo $tableHeaderLink;
            // print the attribute name as link
        }
        // Finish the row
        echo "\n</tr>";
        // END RESULTS HEADER ----------------------
        // display default user
        echo "<tr class=\"odd\">";
        echo "<td align=\"left\" valign=\"top\" width=\"10\"><input DISABLED type=\"checkbox\"</td>";
        echo "<td valign=\"top\"colspan=2>Account options for anyone who isn't logged in</td>";
        echo "<td valign=\"top\">-</td><td valign=\"top\">-</td><td valign=\"top\">-</td><td valign=\"top\">-</td>";
        echo "<td><a href=\"user_options.php?userID=0" . "\"><img src=\"img/options.gif\" alt=\"" . $loc["options"] . "\" title=\"" . $loc["LinkTitle_EditOptions"] . "\" width=\"11\" height=\"17\" hspace=\"0\" border=\"0\"></a></td>";
        echo "</tr>";
        // BEGIN RESULTS DATA COLUMNS --------------
        for ($rowCounter = 0; $rowCounter < $showRows && ($row = @mysql_fetch_array($result)); $rowCounter++) {
            if (is_integer($rowCounter / 2)) {
                // if we currently are at an even number of rows
                $rowClass = "even";
            } else {
                $rowClass = "odd";
            }
            // ... start a TABLE ROW ...
            echo "\n<tr class=\"" . $rowClass . "\">";
            // ... print a column with a checkbox
            if (!preg_match("/^(Print|Mobile)\$/i", $viewType)) {
                // Note: we omit the marker column in print/mobile view! ('viewType=Print' or 'viewType=Mobile')
                echo "\n\t<td align=\"left\" valign=\"top\" width=\"10\"><input type=\"checkbox\" name=\"marked[]\" value=\"" . $row["user_id"] . "\"></td>";
            }
            // ... and print out each of the attributes
            // in that row as a separate TD (Table Data)
            for ($i = 0; $i < $fieldsToDisplay; $i++) {
                // fetch the current attribute name:
                $orig_fieldname = getMySQLFieldInfo($result, $i, "name");
                // function 'getMySQLFieldInfo()' is defined in 'include.inc.php'
                if (preg_match("/^email\$/", $orig_fieldname)) {
                    echo "\n\t<td valign=\"top\"><a href=\"mailto:" . $row["email"] . "\">" . $row["email"] . "</a></td>";
                } elseif (preg_match("/^url\$/", $orig_fieldname) and !empty($row["url"])) {
                    echo "\n\t<td valign=\"top\"><a href=\"" . $row["url"] . "\">" . $row["url"] . "</a></td>";
                } else {
                    echo "\n\t<td valign=\"top\">" . encodeHTML($row[$i]) . "</td>";
                }
            }
            // embed appropriate links (if available):
            if ($showLinks == "1") {
                echo "\n\t<td valign=\"top\">";
                echo "\n\t\t<a href=\"user_receipt.php?userID=" . $row["user_id"] . "\"><img src=\"img/details.gif\" alt=\"" . $loc["details"] . "\" title=\"" . $loc["LinkTitle_ShowDetailsAndOptions"] . "\" width=\"9\" height=\"17\" hspace=\"0\" border=\"0\"></a>&nbsp;&nbsp;";
                echo "\n\t\t<a href=\"user_details.php?userID=" . $row["user_id"] . "\"><img src=\"img/edit.gif\" alt=\"" . $loc["edit"] . "\" title=\"" . $loc["LinkTitle_EditDetails"] . "\" width=\"11\" height=\"17\" hspace=\"0\" border=\"0\"></a>&nbsp;&nbsp;";
                echo "\n\t\t<a href=\"user_options.php?userID=" . $row["user_id"] . "\"><img src=\"img/options.gif\" alt=\"" . $loc["options"] . "\" title=\"" . $loc["LinkTitle_EditOptions"] . "\" width=\"11\" height=\"17\" hspace=\"0\" border=\"0\"></a>&nbsp;&nbsp;";
                $adminUserID = getUserID($adminLoginEmail);
                // ...get the admin's 'user_id' using his/her 'adminLoginEmail' (function 'getUserID()' is defined in 'include.inc.php')
                if ($row["user_id"] != $adminUserID) {
                    // we only provide a delete link if this user isn't the admin:
                    echo "\n\t\t<a href=\"user_receipt.php?userID=" . $row["user_id"] . "&amp;userAction=Delete" . "\"><img src=\"img/delete.gif\" alt=\"" . $loc["delete"] . "\" title=\"" . $loc["LinkTitle_DeleteUser"] . "\" width=\"11\" height=\"17\" hspace=\"0\" border=\"0\"></a>";
                }
                echo "\n\t</td>";
            }
            // Finish the row
            echo "\n</tr>";
        }
        // Then, finish the table
        echo "\n</table>";
        // END RESULTS DATA COLUMNS ----------------
        // BEGIN RESULTS FOOTER --------------------
        // Note: we omit the results footer in print/mobile view! ('viewType=Print' or 'viewType=Mobile')
        if (!preg_match("/^(Print|Mobile)\$/i", $viewType)) {
            // Again, insert the (already constructed) BROWSE LINKS
            // (i.e., a TABLE with links for "previous" & "next" browsing, as well as links to intermediate pages)
            echo $BrowseLinks;
            // Insert a divider line (which separates the results data from the results footer):
            echo "\n<hr class=\"resultsfooter\" align=\"center\" width=\"93%\">";
            // Build a TABLE containing rows with buttons which will trigger actions that act on the selected users
            // Call the 'buildUserResultsFooter()' function (which does the actual work):
            $userResultsFooter = buildUserResultsFooter($NoColumns);
            echo $userResultsFooter;
        }
        // END RESULTS FOOTER ----------------------
        // Finally, finish the form
        echo "\n</form>";
    } else {
        // Report that nothing was found:
        echo "\n<table id=\"error\" class=\"results\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\" summary=\"This table displays users of this database\">" . "\n<tr>" . "\n\t<td valign=\"top\">Sorry, but your query didn't produce any results!&nbsp;&nbsp;<a href=\"javascript:history.back()\">Go Back</a></td>" . "\n</tr>" . "\n</table>";
    }
    // end if $rowsFound body
}
Example #8
0
echo "\n<tr>" . "\n\t<td width=\"74\" class=\"otherfieldsbg\">&nbsp;</td>" . "\n\t<td colspan=\"3\" class=\"otherfieldsbg\">\n\t\t<input type=\"checkbox\" id=\"onlinePublicationCheckBox\" name=\"onlinePublicationCheckBox\" value=\"1\"{$onlinePublicationCheckBoxIsChecked} title=\"" . $loc["DescriptionOnlinePublicationCheckbox"] . "\">&nbsp;" . "\n\t\t" . $loc["Online publication. Cite with this text:"] . "&nbsp;" . "\n\t\t<input type=\"text\" id=\"onlineCitationName\" name=\"onlineCitationName\" value=\"{$onlineCitationName}\" size=\"7\" title=\"" . $loc["DescriptionOnlinePublicationCitation"] . "\">" . $onlineCitationSuggestElements . "\n\t</td>";
if (isset($loginEmail)) {
    // ...we'll show a checkbox where the user can state that the current publication stems form his own institution
    if ($contributionIDCheckBox == "1" or preg_match("/{$abbrevInstitution}/", $contributionID)) {
        // if the '$contributionIDCheckBox' variable is set to 1 -OR- if the currrent user's abbreviated institution name is listed within the 'contribution_id' field
        $contributionIDCheckBoxIsChecked = " checked";
    } else {
        $contributionIDCheckBoxIsChecked = "";
    }
    if ($origRecord > 0) {
        // if the current record has been identified as duplicate entry...
        $contributionIDCheckBoxLock = " disabled";
    } else {
        $contributionIDCheckBoxLock = "";
    }
    echo "\n\t<td colspan=\"2\" class=\"otherfieldsbg\">\n\t\t<input type=\"checkbox\" id=\"contributionIDCheckBox\" name=\"contributionIDCheckBox\" value=\"1\"{$contributionIDCheckBoxIsChecked} title=\"" . $loc["DescriptionOwnPublication"] . "\"{$contributionIDCheckBoxLock}>&nbsp;" . "\n\t\t" . encodeHTML($abbrevInstitution) . " " . $loc["publication"] . "\n\t</td>";
    // we make use of the session variable '$abbrevInstitution' here
} else {
    echo "\n\t<td colspan=\"2\" class=\"otherfieldsbg\">&nbsp;</td>";
}
echo "\n</tr>" . "\n<tr>" . "\n\t<td width=\"74\">&nbsp;</td>" . "\n\t<td colspan=\"5\">&nbsp;</td>" . "\n</tr>";
echo "\n<tr>" . "\n\t<td width=\"74\">" . $loc["Location Field"] . ":</td>";
$locationSelector = "\n\t<td colspan=\"3\">\n\t\t<select id=\"locationSelectorName\" name=\"locationSelectorName\" title=\"" . $loc["DescriptionLocationSelector"] . "\">\n\t\t\t<option value=\"don't touch\">" . $loc["don't touch"] . "</option>\n\t\t\t<option value=\"add\">" . $loc["add"] . "</option>\n\t\t\t<option value=\"remove\">" . $loc["remove"] . "</option>\n\t\t</select>&nbsp;&nbsp;\n\t\t" . $loc["my name & email address"] . "\n\t</td>";
if ($recordAction == "edit" and !empty($locationSelectorName)) {
    $locationSelector = preg_replace("/<option(.*?)>" . $loc[$locationSelectorName] . "/", "<option\\1 selected>" . $loc[$locationSelectorName], $locationSelector);
} elseif ($recordAction == "add") {
    $locationSelector = preg_replace("/<option(.*?)>" . $loc["add"] . "/", "<option\\1 selected>" . $loc["add"], $locationSelector);
    // select the appropriate menu entry ...
    if (!isset($loginEmail) or isset($loginEmail) and $loginEmail != $adminLoginEmail) {
        // ... and if the user isn't logged in -OR- any normal user is logged in (not the admin) ...
        $locationSelector = preg_replace("/<select/i", "<select disabled", $locationSelector);
Example #9
0
    displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Query History", "noindex,nofollow", "Displays links to previous search results", "", false, "", $viewType, array());
    if (!preg_match("/^(Print|Mobile)\$/i", $viewType)) {
        // Note: we omit the visible header in print/mobile view ('viewType=Print' or 'viewType=Mobile')
        showPageHeader($HeaderString);
    }
    echo "\n";
}
// (4b) DISPLAY results:
echo "<div id=\"queryhistory\">";
// Print a link to the current query:
if (!empty($oldQuery)) {
    echo "\n\t<div id=\"currentquery\">" . "\n\t\t<h5>Current Query</h5>";
    // Extract the 'WHERE' clause from the current SQL query:
    $queryWhereClause = extractWHEREclause($oldQuery["sqlQuery"]);
    // function 'extractWHEREclause()' is defined in 'include.inc.php'
    $queryTitle = encodeHTML(explainSQLQuery($queryWhereClause));
    // functions 'encodeHTML()' and 'explainSQLQuery()' are defined in 'include.inc.php'
    // Generate a 'search.php' URL that points to the current query:
    $queryURL = generateURL("search.php", "html", $oldQuery, true);
    // function 'generateURL()' is defined in 'include.inc.php'
    echo "\n\t\t<div class=\"even\">" . "\n\t\t\t<a href=\"" . $queryURL . "\">" . $queryTitle . "</a>" . "\n\t\t</div>" . "\n\t</div>";
}
// Print links to any previous search results:
if (!empty($queryHistory)) {
    echo "\n\t<div id=\"previousqueries\">" . "\n\t\t<h5>Previous Queries</h5>";
    $queryHistory = array_reverse($queryHistory);
    // Display links to previous search results:
    for ($i = 0; $i < count($queryHistory); $i++) {
        if (is_integer($i / 2)) {
            // if we currently are at an even number of rows
            $rowClass = "even";
Example #10
0
// (function 'showLogin()' is defined in 'include.inc.php')
// (4a) DISPLAY header:
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Error", "noindex,nofollow", "Feedback page that shows any error that occurred while using the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
showPageHeader($HeaderString);
// Generate a 'search.php' URL that points to the formerly displayed results page:
if (!empty($oldQuery)) {
    $oldQueryURL = generateURL("search.php", "html", $oldQuery, true);
}
// function 'generateURL()' is defined in 'include.inc.php'
// Build appropriate links:
$links = "\n<tr>" . "\n\t<td>" . "\n\t\tChoose how to proceed:&nbsp;&nbsp;";
// - provide a 'go back' link (the following would only work with javascript: <a href=\"javascript:history.back()\">Go Back</a>")
$links .= "\n\t\t<a href=\"" . str_replace('&', '&amp;', $referer) . "\">Go Back</a>";
// variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php'
// - provide a link to any previous search results:
if (!empty($oldQuery)) {
    $links .= "\n\t\t&nbsp;&nbsp;-OR-&nbsp;&nbsp;" . "\n\t\t<a href=\"" . $oldQueryURL . "\">Display previous search results</a>";
}
// - we also include a link to the home page here:
$links .= "\n\t\t&nbsp;&nbsp;-OR-&nbsp;&nbsp;" . "\n\t\t<a href=\"index.php\">Goto " . encodeHTML($officialDatabaseName) . " Home</a>" . "\n\t</td>" . "\n</tr>";
// SHOW ERROR MESSAGE:
echo "\n<table class=\"error\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\">\n<tr>\n\t<td valign=\"top\"> Error " . $errorNo . " : <b>" . encodeHTML($errorMsg) . "</b>" . "</td>\n</tr>" . $links . "\n</table>";
// --------------------------------------------------------------------
// DISPLAY THE HTML FOOTER:
// call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
showPageFooter($HeaderString);
displayHTMLfoot();
// --------------------------------------------------------------------
exit;
// die
Example #11
0
// Repository: $HeadURL: http://svn.code.sf.net/p/refbase/code/trunk/locales/core.php $
// Author(s):  Jochen Wendebaum <mailto:wendebaum@users.sourceforge.net>
//
// Created:    01-Oct-04, 12:00
// Modified:   $Date: 2007-02-16 17:10:14 -0800 (Fri, 16 Feb 2007) $
//             $Author: msteffens $
//             $Revision: 894 $
// Get filename:
if ($contentTypeCharset == "UTF-8") {
    // variable '$contentTypeCharset' is defined in 'ini.inc.php'
    $f = "locales/" . $locale . "/common_utf8.inc";
} else {
    $f = "locales/" . $locale . "/common.inc";
}
// Get locales:
ob_start();
readfile($f);
// read the file contents
$s = "\$loc=array(" . ob_get_contents() . ");";
eval($s);
// ...and store everything into $loc
ob_end_clean();
// HTML encode higher ASCII characters in locales:
foreach ($loc as $locKey => $locValue) {
    $loc[$locKey] = encodeHTML($locValue);
    // function 'encodeHTML()' is defined in 'include.inc.php'
    if (preg_match("/&lt;a href=&quot;.+?&quot;&gt;.+?&lt;\\/a&gt;/", $loc[$locKey])) {
        // dirty hack to allow URLs within (otherwise HTML encoded) locales
        $loc[$locKey] = preg_replace("/&lt;a href=&quot;(.+?)&quot;&gt;(.+?)&lt;\\/a&gt;/", "<a href=\"\\1\">\\2</a>", $loc[$locKey]);
    }
}
Example #12
0
function encodeField($fieldName, $fieldValue, $localSearchReplaceActionsArray = array(), $encodingExceptionsArray = array(), $encode = true, $targetFormat = "HTML")
{
    global $contentTypeCharset;
    // these variables are defined in 'ini.inc.php'
    global $convertExportDataToUTF8;
    global $searchReplaceActionsArray;
    if ($encode and !in_array($fieldName, $encodingExceptionsArray)) {
        if ($targetFormat == "HTML") {
            // Encode non-ASCII chars as HTML entities:
            $fieldValue = encodeHTML($fieldValue);
        } elseif ($targetFormat == "XML") {
            // Only convert those special chars to entities which are supported by XML:
            $fieldValue = encodeHTMLspecialchars($fieldValue);
            // Convert field data to UTF-8:
            if ($convertExportDataToUTF8 == "yes" and $contentTypeCharset != "UTF-8") {
                $fieldValue = convertToCharacterEncoding("UTF-8", "IGNORE", $fieldValue);
            }
        }
    }
    // Apply *locally* defined search & replace 'actions' to all fields that are listed
    // in the 'fields' element of the arrays contained in '$localSearchReplaceActionsArray':
    foreach ($localSearchReplaceActionsArray as $fieldActionsArray) {
        if (in_array($fieldName, $fieldActionsArray['fields'])) {
            $fieldValue = searchReplaceText($fieldActionsArray['actions'], $fieldValue, true);
        }
    }
    if ($targetFormat == "HTML") {
        // Apply *globally* defined search & replace 'actions' to all fields that are listed
        // in the 'fields' element of the arrays contained in '$searchReplaceActionsArray':
        foreach ($searchReplaceActionsArray as $fieldActionsArray) {
            if (in_array($fieldName, $fieldActionsArray['fields'])) {
                $fieldValue = searchReplaceText($fieldActionsArray['actions'], $fieldValue, true);
            }
        }
    }
    return $fieldValue;
}
Example #13
0
" size="10" title="enter the serial number of the original (master) record">
	</td>
</tr>
<tr>
	<td width="120">
		<div class="sect"><?php 
echo $loc["Duplicates"];
?>
:</div>
	</td>
	<td><?php 
echo fieldError("dupRecords", $errors);
?>

		<input type="text" name="dupRecords" value="<?php 
echo encodeHTML($dupRecords);
?>
" size="50" title="enter the serial number(s) of all records that are duplicate entries of the above specified record; separate multiple serials with any non-digit characters">
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td>
		<input type="submit" name="submit" value="Flag Duplicates" title="mark the given records as original/duplicate entries">
	</td>
</tr>
</table>
<table class="showhide" align="center" border="0" cellpadding="0" cellspacing="10" width="95%">
<tr>
	<td class="small" width="120" valign="top">
		<a href="javascript:toggleVisibility('helptxt','helpToggleimg','helpToggletxt','<?php 
Example #14
0
    exit;
    // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
} else {
    connectToMySQLDatabase();
    // function 'connectToMySQLDatabase()' is defined in 'include.inc.php'
    // CONSTRUCT SQL QUERY:
    // Fetch all saved settings for the user's query from the 'queries' table:
    $query = "SELECT query_id, display_type, view_type, query, show_query, show_links, show_rows, cite_style_selector, cite_order FROM {$tableQueries} WHERE user_id = " . quote_smart($loginUserID) . " AND query_name = " . quote_smart($querySearchSelector);
    // the global variable '$loginUserID' gets set in function 'start_session()' within 'include.inc.php'
    $result = queryMySQLDatabase($query);
    // RUN the query on the database through the connection (function 'queryMySQLDatabase()' is defined in 'include.inc.php')
    $rowsFound = @mysql_num_rows($result);
    if ($rowsFound == 1) {
        $row = mysql_fetch_array($result);
        // redirect the browser to 'query_manager.php':
        if (encodeHTML($submitAction) == $loc["ButtonTitle_Edit"]) {
            header("Location: query_manager.php?queryAction=edit&queryID=" . $row['query_id']);
            exit;
            // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        }
    } else {
        if ($rowsFound > 1) {
            // if there were more than one row found ...
            $HeaderString = "<b><span class=\"warning\">There's more than one saved query matching your query title!</span></b>";
        } else {
            // if ($rowsFound == 0) // nothing found
            $HeaderString = "<b><span class=\"warning\">Your saved query couldn't be found!</span></b>";
        }
        // update the 'userQueries' session variable:
        getUserQueries($loginUserID);
        // function 'getUserQueries()' is defined in 'include.inc.php'
Example #15
0
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
    $record = "";
    // make sure that our buffer variable is empty
    // --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
    if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)\$/", $row['type'])) {
        if (!empty($row['author'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $author = reArrangeAuthorContents($row['author'], true, "/ *; */", ", ", " " . $markupPatternsArray["ampersand"] . " ", "/ *, */", ", ", ", ", ".", false, false, true, "4", "1", " et al", $encodeHTML);
            // 16.
            $record .= $author;
        }
        if (!empty($row['year'])) {
            if (!empty($row['author'])) {
                $record .= ", ";
            }
            if (!empty($row['year'])) {
                $record .= $row['year'];
            }
        }
        if (!empty($row['title'])) {
            if (!empty($row['author']) || !empty($row['year'])) {
                $record .= ". ";
            }
            $record .= $row['title'];
            $record .= ",";
        }
        // From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
        if (!empty($row['publication'])) {
            // publication (= journal) name
            $record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
        } elseif (!empty($row['abbrev_journal'])) {
            // abbreviated journal name
            $record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
        }
        if ((!empty($row['abbrev_journal']) || !empty($row['publication'])) && (!empty($row['volume']) || !empty($row['issue']))) {
            $record .= ",";
        }
        // NOTE: for newspaper articles, the above mentioned guide uses a dot instead of a comma ("The Times, 3 Sep. p.4-5.") but this seems incorrect/inconsistent to me
        if ($row['online_publication'] == "yes") {
            // this record refers to an online publication
            $record .= " [Online]";
        }
        if ($row['type'] == "Journal Article") {
            if (!empty($row['volume'])) {
                // volume
                $record .= " " . $row['volume'];
            }
            if (!empty($row['issue'])) {
                if (!empty($row['volume'])) {
                    $record .= " ";
                }
                $record .= "(" . $row['issue'] . ")";
            }
        } elseif (preg_match("/^(Newspaper Article|Magazine Article)\$/", $row['type'])) {
            if (!empty($row['issue'])) {
                // issue (=day)
                $record .= " " . $row['issue'];
            }
            if (!empty($row['volume'])) {
                // volume (=month)
                $record .= " " . $row['volume'];
            }
        }
        if (!empty($row['pages'])) {
            if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) {
                // only add ", " if either volume, issue, abbrev_journal or publication isn't empty
                $record .= ", ";
            }
            $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "p. ");
            // function 'formatPageInfo()' is defined in 'cite.inc.php' (NOTE: from the examples in the above mentioned guide it's unclear whether "p." should be followed by a space or not)
        }
        if ($row['online_publication'] == "yes") {
            // append an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
            if (!empty($row['online_citation'])) {
                if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) {
                    // only add "," if either volume, issue, abbrev_journal or publication isn't empty
                    $record .= ",";
                }
                $record .= " " . $row['online_citation'];
            }
            if (!empty($row['doi']) || !empty($row['url'])) {
                if (!empty($row['online_citation']) or empty($row['online_citation']) and !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) {
                    // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
                    $record .= ".";
                }
                $today = date("j F Y");
                $record .= " Available at: " . $markupPatternsArray["underline-prefix"];
                if (!empty($row['doi'])) {
                    // doi
                    $uri = "http://dx.doi.org/" . $row['doi'];
                } else {
                    // url
                    $uri = $row['url'];
                }
                if ($encodeHTML) {
                    $record .= encodeHTML($uri);
                } else {
                    $record .= $uri;
                }
                $record .= $markupPatternsArray["underline-suffix"];
                $record .= " [accessed " . $today . "]";
            }
        }
        if (!preg_match("/\\. *\$/", $record)) {
            // if the string doesn't end with a period
            $record .= ".";
        }
    } elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)\$/", $row['type'])) {
        if (!empty($row['author'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $author = reArrangeAuthorContents($row['author'], true, "/ *; */", ", ", " " . $markupPatternsArray["ampersand"] . " ", "/ *, */", ", ", ", ", ".", false, false, true, "4", "1", " et al", $encodeHTML);
            // 16.
            $record .= $author;
        }
        if (!empty($row['year'])) {
            if (!empty($row['author'])) {
                $record .= ", ";
            }
            $record .= $row['year'];
        }
        if (!empty($row['title'])) {
            if (!empty($row['author']) || !empty($row['year'])) {
                $record .= ". ";
            }
            $record .= $row['title'];
            $record .= ".";
        }
        // From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
        // if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
        if (!empty($row['editor'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $editor = reArrangeAuthorContents($row['editor'], true, "/ *; */", ", ", " " . $markupPatternsArray["ampersand"] . " ", "/ *, */", " ", " ", ".", true, true, true, "4", "1", " et al", $encodeHTML);
            // 16.
            $record .= " In " . $editor . ", ";
            if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+\$/", $row['editor'])) {
                // there are at least two editors (separated by ';')
                $record .= "eds.";
            } else {
                // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
                $record .= "ed.";
            }
        }
        $publication = preg_replace("/[ \r\n]*\\(Eds?:[^\\)\r\n]*\\)/i", "", $row['publication']);
        if (!empty($publication)) {
            if (empty($row['editor'])) {
                $record .= " In";
            }
            $record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"];
        }
        if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $row['edition']) || !empty($row['volume'])) {
            $record .= ". ";
            if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $row['edition'])) {
                if (preg_match("/^\\d{1,3}\$/", $row['edition'])) {
                    if ($row['edition'] == "2") {
                        $editionSuffix = "nd";
                    } elseif ($row['edition'] == "3") {
                        $editionSuffix = "rd";
                    } else {
                        $editionSuffix = "th";
                    }
                } else {
                    $editionSuffix = "";
                }
                if (!empty($row['edition']) && !preg_match("/( ed\\.?| edition)\$/i", $row['edition'])) {
                    $editionSuffix .= " ed.";
                }
                $record .= $row['edition'] . $editionSuffix;
            }
            if (!empty($row['volume'])) {
                if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $row['edition'])) {
                    $record .= ", ";
                }
                $record .= "vol. " . $row['volume'];
                // TODO: not sure whether this is correct
            }
        }
        if (!empty($row['abbrev_series_title']) or !empty($row['series_title'])) {
            $record .= ". ";
            if (!empty($row['series_title'])) {
                $record .= $row['series_title'];
            } elseif (!empty($row['abbrev_series_title'])) {
                $record .= $row['abbrev_series_title'];
            }
            // abbreviated series title
            if (!empty($row['series_volume']) || !empty($row['series_issue'])) {
                $record .= ", ";
            }
            if (!empty($row['series_volume'])) {
                // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here)
                $record .= "vol. " . $row['series_volume'];
            }
            // TODO: not sure whether this is correct
            if (!empty($row['series_issue'])) {
                if (!empty($row['series_volume'])) {
                    $record .= ", ";
                }
                $record .= "no. " . $row['series_issue'];
                // TODO: not sure whether this is correct
            }
        }
        if (!preg_match("/\\. *\$/", $record)) {
            $record .= ".";
        }
        if (!empty($row['place'])) {
            // place
            $record .= " " . $row['place'];
        }
        if (!empty($row['publisher'])) {
            if (!empty($row['place'])) {
                $record .= ":";
            }
            $record .= " " . $row['publisher'];
        }
        if (!empty($row['pages'])) {
            if (!empty($row['publisher']) || !empty($row['place'])) {
                $record .= ", ";
            }
            $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "p. ");
            // function 'formatPageInfo()' is defined in 'cite.inc.php' (NOTE: from the examples in the above mentioned guide it's unclear whether "p." should be followed by a space or not)
        }
        if (!preg_match("/\\. *\$/", $record)) {
            $record .= ".";
        }
    } else {
        if (!empty($row['author'])) {
            $author = preg_replace("/[ \r\n]*\\(eds?\\)/i", "", $row['author']);
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $author = reArrangeAuthorContents($author, true, "/ *; */", ", ", " " . $markupPatternsArray["ampersand"] . " ", "/ *, */", ", ", ", ", ".", false, false, true, "4", "1", " et al", $encodeHTML);
            // 16.
            // if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
            // [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
            //  so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
            if (preg_match("/[ \r\n]*\\(ed\\)/", $row['author'])) {
                // single editor
                $author = $author . " ed.";
            } elseif (preg_match("/[ \r\n]*\\(eds\\)/", $row['author'])) {
                // multiple editors
                $author = $author . " eds.";
            }
            $record .= $author;
        }
        if (!empty($row['year'])) {
            if (!empty($row['author'])) {
                $record .= ", ";
            }
            $record .= $row['year'];
        }
        if (!empty($row['title'])) {
            if (!empty($row['author']) || !empty($row['year'])) {
                $record .= ". ";
            }
            $record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
        }
        if ($row['online_publication'] == "yes") {
            // this record refers to an online publication
            $record .= ". [Online]";
        }
        // TODO: this may not be entirely correct, since, according to the above mentioned guide, the actual type should be used: e.g. "[e-book]" or "[CD-ROM]"
        if (!empty($row['editor']) && !preg_match("/[ \r\n]*\\(eds?\\)/", $row['author'])) {
            // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
            //   1. input:  contents of the author field
            //   2. input:  boolean value that specifies whether the author's family name comes first (within one author) in the source string
            //              ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
            //
            //   3. input:  pattern describing old delimiter that separates different authors
            //   4. output: for all authors except the last author: new delimiter that separates different authors
            //   5. output: for the last author: new delimiter that separates the last author from all other authors
            //
            //   6. input:  pattern describing old delimiter that separates author name & initials (within one author)
            //   7. output: for the first author: new delimiter that separates author name & initials (within one author)
            //   8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
            //   9. output: new delimiter that separates multiple initials (within one author)
            //  10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
            //  12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
            //
            //  13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
            //  14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
            //  15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
            //
            //  16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
            $editor = reArrangeAuthorContents($row['editor'], true, "/ *; */", ", ", " " . $markupPatternsArray["ampersand"] . " ", "/ *, */", " ", " ", ".", true, true, true, "4", "1", " et al", $encodeHTML);
            // 16.
            if (!empty($row['author']) || !empty($row['year']) || !empty($row['title'])) {
                $record .= " ";
            }
            $record .= " (" . $editor . ", ";
            if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+\$/", $row['editor'])) {
                // there are at least two editors (separated by ';')
                $record .= "eds.";
            } else {
                // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
                $record .= "ed.";
            }
            $record .= ")";
        }
        if (!empty($row['edition']) || !empty($row['volume'])) {
            if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']) || !empty($row['editor']) && !preg_match("/[ \r\n]*\\(eds?\\)/", $row['author'])) {
                $record .= ". ";
            }
            if ($row['type'] == "Software") {
                if (!empty($row['edition'])) {
                    $record .= "Version " . $row['edition'];
                    if (!empty($row['volume']) || !empty($row['issue'])) {
                        $record .= ", ";
                    }
                }
                if (!empty($row['issue'])) {
                    // issue (=day)
                    $record .= " " . $row['issue'];
                }
                if (!empty($row['volume'])) {
                    // volume (=month)
                    $record .= " " . $row['volume'];
                }
            } elseif (!preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $row['edition'])) {
                if (preg_match("/^\\d{1,3}\$/", $row['edition'])) {
                    if ($row['edition'] == "2") {
                        $editionSuffix = "nd";
                    } elseif ($row['edition'] == "3") {
                        $editionSuffix = "rd";
                    } else {
                        $editionSuffix = "th";
                    }
                } else {
                    $editionSuffix = "";
                }
                if (!empty($row['edition']) && !preg_match("/( ed\\.?| edition)\$/i", $row['edition'])) {
                    $editionSuffix .= " ed.";
                }
                $record .= $row['edition'] . $editionSuffix;
                if (!empty($row['volume'])) {
                    if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $row['edition'])) {
                        $record .= ", ";
                    }
                    $record .= "vol. " . $row['volume'];
                    // TODO: not sure whether this is correct
                }
            }
        }
        if ($row['type'] == "Software") {
            $record .= ", computer software.";
        } else {
            if (!preg_match("/\\. *\$/", $record)) {
                $record .= ".";
            }
            if (!empty($row['abbrev_series_title']) or !empty($row['series_title'])) {
                $record .= " ";
                if (!empty($row['series_title'])) {
                    $record .= $row['series_title'];
                } elseif (!empty($row['abbrev_series_title'])) {
                    $record .= $row['abbrev_series_title'];
                }
                // abbreviated series title
                if (!empty($row['series_volume']) || !empty($row['series_issue'])) {
                    $record .= ", ";
                }
                if (!empty($row['series_volume'])) {
                    // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here)
                    $record .= "vol. " . $row['series_volume'];
                }
                // TODO: not sure whether this is correct
                if (!empty($row['series_issue'])) {
                    if (!empty($row['series_volume'])) {
                        $record .= ", ";
                    }
                    $record .= "no. " . $row['series_issue'];
                    // TODO: not sure whether this is correct
                }
                $record .= ".";
            }
        }
        if (!empty($row['thesis'])) {
            // thesis
            $record .= " " . $row['thesis'];
        }
        if (!empty($row['place']) || !empty($row['publisher'])) {
            if (!empty($row['thesis'])) {
                $record .= ".";
            }
            if (!empty($row['place'])) {
                // place (NOTE: should we omit the place of publication for theses?)
                $record .= " " . $row['place'];
            }
            if (!empty($row['publisher'])) {
                if (!empty($row['place'])) {
                    $record .= ":";
                }
                $record .= " " . $row['publisher'];
            }
        }
        if ($row['online_publication'] == "yes" || $row['type'] == "Software") {
            if (!empty($row['online_citation'])) {
                if (!preg_match("/\\. *\$/", $record)) {
                    $record .= ".";
                }
                $record .= " " . $row['online_citation'];
            }
            if (!empty($row['doi']) || !empty($row['url'])) {
                if (!preg_match("/\\. *\$/", $record)) {
                    $record .= ".";
                }
                $today = date("j F Y");
                $record .= " Available at: " . $markupPatternsArray["underline-prefix"];
                if (!empty($row['doi'])) {
                    // doi
                    $uri = "http://dx.doi.org/" . $row['doi'];
                } else {
                    // url
                    $uri = $row['url'];
                }
                if ($encodeHTML) {
                    $record .= encodeHTML($uri);
                } else {
                    $record .= $uri;
                }
                $record .= $markupPatternsArray["underline-suffix"];
                $record .= " [accessed " . $today . "]";
            }
        }
        if (!preg_match("/\\. *\$/", $record)) {
            // if the string doesn't end with a period
            $record .= ".";
        }
    }
    // --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
    // do some further cleanup:
    $record = trim($record);
    // remove any preceding or trailing whitespace
    return $record;
}
Example #16
0
    }
    // remove any existing editor info from the 'author' string, i.e., kill any trailing " (ed)" or " (eds)"
    if ($authorName == $editorName) {
        // if the 'Author' field contents equal the 'Editor' field contents...
        $editorName = "";
    }
    // ...clear contents of 'editor' field (that is, we assume that the user did uncheck the 'is Editor' checkbox, which was previously marked)
}
// Assign correct values to the calculation fields 'first_author', 'author_count', 'first_page', 'volume_numeric' and 'series_volume_numeric':
// function 'generateCalculationFieldContent()' is defined in 'include.inc.php'
// NOTE: this function call won't be necessary anymore when we've also moved database INSERTs and DELETEs to dedicated functions (which would take care of calculation fields then) -> compare with 'addRecords()' function
list($firstAuthor, $authorCount, $firstPage, $volumeNumericNo, $seriesVolumeNumericNo) = generateCalculationFieldContent($authorName, $pagesNo, $volumeNo, $seriesVolumeNo);
// manage 'location' field data:
if (($locationSelectorName == "add" or $locationSelectorName == "") and !preg_match("/{$loginEmail}/", $locationName)) {
    // if the 'location' field is either completely empty -OR- does only contain the information string (that shows up on 'add' for normal users):
    if (preg_match("/^(" . $loc["your name & email address will be filled in automatically"] . ")?\$/", encodeHTML($locationName))) {
        // note that we need to HTML encode '$locationName' for comparison with the HTML encoded locales
        $locationName = preg_replace("/^.*\$/i", "{$currentUser}", $locationName);
    } else {
        // if the 'location' field does already contain some user content:
        $locationName = preg_replace("/^(.+)\$/i", "\\1; {$currentUser}", $locationName);
    }
} elseif ($locationSelectorName == "remove") {
    // the only pattern that's really unique is the users email address, the user's name may change (since it can be modified by the user). This is why we dont use '$currentUser' here:
    $locationName = preg_replace("/^[^;]*\\( *{$loginEmail} *\\) *; */i", "", $locationName);
    // the current user is listed at the very beginning of the 'location' field
    $locationName = preg_replace("/ *;[^;]*\\( *{$loginEmail} *\\) */i", "", $locationName);
    // the current user occurs after some other user within the 'location' field
    $locationName = preg_replace("/^[^;]*\\( *{$loginEmail} *\\) *\$/i", "", $locationName);
    // the current user is the only one listed within the 'location' field
}
Example #17
0
function showPageHeader($HeaderString)
{
    global $officialDatabaseName;
    // these variables are defined in 'ini.inc.php'
    global $hostInstitutionAbbrevName;
    global $hostInstitutionName;
    global $hostInstitutionURL;
    global $helpResourcesURL;
    global $logoImageURL;
    global $logoImageWidth;
    global $logoImageHeight;
    global $loginWelcomeMsg;
    // these variables are globally defined in function 'showLogin()' in 'include.inc.php'
    global $loginStatus;
    global $loginLinks;
    global $displayType;
    global $query;
    global $queryURL;
    global $showQuery;
    global $showLinks;
    global $showRows;
    global $citeStyle;
    global $citeOrder;
    global $loc;
    // '$loc' is made globally available in 'core.php'
    ?>

<table class="pageheader" align="center" width="95%" summary="This holds the title logo and info">
<tr>
	<td rowspan="2" align="left" width="<?php 
    echo $logoImageWidth + 26;
    ?>
"><a href="<?php 
    echo $hostInstitutionURL;
    ?>
"><img src="<?php 
    echo $logoImageURL;
    ?>
" border="0" alt="<?php 
    echo encodeHTML($hostInstitutionAbbrevName);
    ?>
 Home" title="<?php 
    echo encodeHTML($hostInstitutionName);
    ?>
" width="<?php 
    echo $logoImageWidth;
    ?>
" height="<?php 
    echo $logoImageHeight;
    ?>
"></a></td>
	<td width="60%">
		<h4><?php 
    echo encodeHTML($officialDatabaseName);
    ?>
</h4>
        <p><?php 
    echo $HeaderString;
    ?>
</p>
		<span class="smallup">
			<a href="index.php"<?php 
    echo addAccessKey("attribute", "home");
    ?>
 title="<?php 
    echo $loc["LinkTitle_Home"] . addAccessKey("title", "home");
    ?>
"><?php 
    echo $loc["Home"];
    ?>
</a>&nbsp;|&nbsp;
			<a href="show.php?records=all"<?php 
    echo addAccessKey("attribute", "show_all");
    ?>
 title="<?php 
    echo $loc["LinkTitle_ShowAll"] . addAccessKey("title", "show_all");
    ?>
"><?php 
    echo $loc["ShowAll"];
    ?>
</a>&nbsp;|&nbsp;
			<a href="simple_search.php"<?php 
    echo addAccessKey("attribute", "search");
    ?>
 title="<?php 
    echo $loc["LinkTitle_SimpleSearch"] . addAccessKey("title", "search");
    ?>
"><?php 
    echo $loc["SimpleSearch"];
    ?>
</a>&nbsp;|&nbsp;
			<a href="advanced_search.php"<?php 
    echo addAccessKey("attribute", "adv_search");
    ?>
 title="<?php 
    echo $loc["LinkTitle_AdvancedSearch"] . addAccessKey("title", "adv_search");
    ?>
"><?php 
    echo $loc["AdvancedSearch"];
    ?>
</a><?php 
    // -------------------------------------------------------
    if (isset($_SESSION['user_permissions']) and preg_match("/allow_add/", $_SESSION['user_permissions'])) {
        // ... include a link to 'record.php?recordAction=add...':
        ?>

			&nbsp;|&nbsp;<a href="record.php?recordAction=add"<?php 
        echo addAccessKey("attribute", "add");
        ?>
 title="<?php 
        echo $loc["LinkTitle_AddRecord"] . addAccessKey("title", "add");
        ?>
"><?php 
        echo $loc["AddRecord"];
        ?>
</a><?php 
    }
    // -------------------------------------------------------
    if (isset($_SESSION['user_permissions']) and preg_match("/allow_import|allow_batch_import/", $_SESSION['user_permissions'])) {
        // ... include a link to 'import.php':
        ?>

			&nbsp;|&nbsp;<a href="import.php"<?php 
        echo addAccessKey("attribute", "import");
        ?>
 title="<?php 
        echo $loc["LinkTitle_Import"] . addAccessKey("title", "import");
        ?>
"><?php 
        echo $loc["Import"];
        ?>
</a><?php 
    }
    // -------------------------------------------------------
    ?>

		</span>
	</td>
	<td class="small" rowspan="2" align="right">
		<div id="loginInfo" style="text-align: right">
            <div id="loginStatus" style="margin: 5px 0">
                <?php 
    echo $loginStatus;
    ?>
 <?php 
    echo $loginWelcomeMsg ? ' - ' . $loginWelcomeMsg : '';
    ?>
            </div>
			<div id="loginLinks" style="margin: 5px 0">
                <?php 
    echo $loginLinks;
    ?>
            </div>
            <?php 
    if (!isset($_SESSION['loginEmail'])) {
        // Display Options:
        // Get all languages that were setup and enabled by the admin:
        $languagesArray = getLanguages("");
        // function 'getLanguages()' is defined in 'include.inc.php'
        $languageOptionTags = buildSelectMenuOptions($languagesArray, "/ *; */", "\t\t\t", true);
        // build properly formatted <option> tag elements from language items returned by function 'getLanguages()'
        ?>
                <div id="language" style="margin: 5px 0">
                    <form action="select_language.php" method="post">
                        <div class="row collapse">
                            <div class="small-10 columns">
                                <select name="language_id">
                                    <option value="">-- Language --</option>
                                    <?php 
        echo $languageOptionTags;
        ?>
                                </select>
                            </div>
                            <div class="small-2 columns">
                                <button type="submit" class="button secondary tiny">Select</button>
                            </div>
                        </div>
                    </form>
                </div>
            <?php 
    }
    ?>
		</div>
		<div id="queryrefs">
            <?php 
    echo buildQuickSearchElements($query, $queryURL, $showQuery, $showLinks, $showRows, $citeStyle, $citeOrder, $displayType);
    ?>
		</div>
	</td>
</tr>
</table>
<?php 
}
Example #18
0
	</td>
</tr>
<tr>
	<td align="left"></td>
	<td colspan="2">
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="use_custom_cite_key_format" value="yes"<?php 
echo $useCustomCiteKeyFormatChecked;
?>
>&nbsp;&nbsp;Use custom format for auto-generated cite keys:
	</td>
</tr>
<tr>
	<td align="left"></td>
	<td colspan="2">
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="cite_key_format" value="<?php 
echo encodeHTML($citeKeyFormat);
?>
" size="46">
	</td>
</tr>
<tr>
	<td align="left"></td>
	<td colspan="2">
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="use_custom_handling_of_nonascii_chars_in_cite_keys" value="yes"<?php 
echo $useCustomHandlingOfNonASCIICharsInCiteKeysChecked;
?>
>&nbsp;&nbsp;Use custom handling of non-ASCII characters in cite keys:
	</td>
</tr>
<tr>
	<td align="left"></td>
Example #19
0
<body>

<h4>Editing a File (PHP example) - <a href="../default.htm">Back</a></h4>

<form method="post" action="default.php" id="Form1">

  <textarea id="txtContent" name="txtContent" rows=4 cols=30>
  <?php 
function encodeHTML($sHTML)
{
    $sHTML = preg_replace('/&/i', '&amp;', $sHTML);
    $sHTML = preg_replace('/</i', '&lt;', $sHTML);
    $sHTML = preg_replace('/>/i', '&gt;', $sHTML);
    return $sHTML;
}
echo encodeHTML(file_get_contents($file));
?>
  </textarea>

  <script>
    var oEdit1 = new InnovaEditor("oEdit1");

        oEdit1.btnStyles=true;
    oEdit1.mode="HTML";
    oEdit1.REPLACE("txtContent");
  </script>

  <input type="submit" value="Save">
  <input type="button" value="view file" onclick="window.open('content.htm')">
</form>
Example #20
0
    deleteSessionVariable("HeaderString");
    // function 'deleteSessionVariable()' is defined in 'include.inc.php'
}
// Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
// ('' will produce the default 'Web' output style)
if (isset($_REQUEST['viewType'])) {
    $viewType = $_REQUEST['viewType'];
} else {
    $viewType = "";
}
// Show the login status:
showLogin();
// (function 'showLogin()' is defined in 'include.inc.php')
// (2a) Display header:
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Extract Citations", "index,follow", "Search the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
showPageHeader($HeaderString);
// (2b) Start <form> and <table> holding the form elements:
echo "\n<form action=\"search.php\" method=\"POST\">";
echo "\n<input type=\"hidden\" name=\"formType\" value=\"extractSearch\">" . "\n<input type=\"hidden\" name=\"submit\" value=\"Cite\">";
// provide a default value for the 'submit' form tag. Otherwise, some browsers may not recognize the correct output format when a user hits <enter> within a form field (instead of clicking the "Cite" button)
if (!isset($_SESSION['user_styles'])) {
    $citeStyleDisabled = " disabled";
} else {
    $citeStyleDisabled = "";
}
if (!isset($_SESSION['user_cite_formats'])) {
    $citeFormatDisabled = " disabled";
} else {
    $citeFormatDisabled = "";
}
Example #21
0
function printLinks($showLinkTypes, $row, $showQuery, $showLinks, $wrapResults, $userID, $viewType, $orderBy)
{
    global $databaseBaseURL;
    // these variables are defined in 'ini.inc.php'
    global $filesBaseURL;
    global $fileVisibility;
    global $fileVisibilityException;
    global $openURLResolver;
    global $isbnURLFormat;
    global $tableRefs, $tableUserData;
    // defined in 'db.inc.php'
    global $loc;
    // '$loc' is made globally available in 'core.php'
    global $client;
    // Note: for proper placement of links within the Links column we don't use the 'mergeLinks()' function here (as is done for Details view),
    //       since spacing before links is handled individually for each link type
    $links = "";
    // make sure that our buffer variable is empty
    // count the number of available link elements:
    $linkElementCounterLoggedOut = 0;
    // if the 'user_permissions' session variable contains 'allow_details_view'...
    if (in_array("details", $showLinkTypes) and isset($_SESSION['user_permissions']) and preg_match("/allow_details_view/", $_SESSION['user_permissions'])) {
        $linkElementCounterLoggedOut = $linkElementCounterLoggedOut + 1;
    }
    // if the 'user_permissions' session variable contains 'allow_edit'...
    if (in_array("edit", $showLinkTypes) and isset($_SESSION['user_permissions']) and preg_match("/allow_edit/", $_SESSION['user_permissions'])) {
        $linkElementCounterLoggedOut = $linkElementCounterLoggedOut + 1;
    }
    // if either the URL or the DOI field contain something
    if (in_array("url", $showLinkTypes) and !empty($row["url"]) or in_array("doi", $showLinkTypes) and !empty($row["doi"])) {
        $linkElementCounterLoggedOut = $linkElementCounterLoggedOut + 1;
    } elseif (in_array("isbn", $showLinkTypes) and !empty($isbnURLFormat) and !empty($row["isbn"])) {
        // provide a link to an ISBN resolver
        $linkElementCounterLoggedOut = $linkElementCounterLoggedOut + 1;
    } elseif (in_array("xref", $showLinkTypes) and !empty($openURLResolver)) {
        $linkElementCounterLoggedOut = $linkElementCounterLoggedOut + 1;
    }
    $linkElementCounterLoggedIn = $linkElementCounterLoggedOut;
    // if a user is logged in and a FILE is associated with the current record
    if (in_array("file", $showLinkTypes) and ($fileVisibility == "everyone" or $fileVisibility == "login" and isset($_SESSION['loginEmail']) or $fileVisibility == "user-specific" and (isset($_SESSION['user_permissions']) and preg_match("/allow_download/", $_SESSION['user_permissions'])) or !empty($fileVisibilityException) and preg_match($fileVisibilityException[1], $row[$fileVisibilityException[0]]))) {
        if (!empty($row["file"])) {
            // if the 'file' field is NOT empty
            $linkElementCounterLoggedIn = $linkElementCounterLoggedIn + 1;
        }
    }
    if (preg_match("/^inc/i", $client)) {
        // we open links in a new browser window if refbase data are included somewhere else:
        $target = " target=\"_blank\"";
    } else {
        $target = "";
    }
    if (preg_match("/^(cli|inc)/i", $client) or $wrapResults == "0") {
        // we use absolute links for CLI clients, for include mechanisms, or when returning only a partial document structure
        $baseURL = $databaseBaseURL;
    } else {
        $baseURL = "";
    }
    if (in_array("details", $showLinkTypes) and isset($_SESSION['user_permissions']) and preg_match("/allow_details_view/", $_SESSION['user_permissions'])) {
        // display a link that opens the Details view for this record:
        // NOTE: we use a 'show.php' URL here since it is much shorter and easier to bookmark as a permanent link; however,
        //       this means one additional redirect; the old code that directly generates a 'search.php' URL is commented out below
        // TODO: verify that the time lag introduced by the redirect action is generally acceptable!
        $queryParametersArray = array("record" => $row["serial"]);
        // we only add further parameters to the 'show.php' URL if their current value differs from the defaults used by 'show.php' or 'search.php':
        if (!empty($viewType) and !preg_match("/^Web\$/i", $viewType)) {
            $queryParametersArray["viewType"] = $viewType;
        }
        if ($showQuery == "1") {
            $queryParametersArray["showQuery"] = $showQuery;
        }
        if ($showLinks == "0") {
            // this is kinda superfluous since, for '$showLinks=0', the link isn't shown in the first place
            $queryParametersArray["showLinks"] = $showLinks;
        }
        $links .= "\n\t\t<a href=\"" . $baseURL . generateURL("show.php", "html", $queryParametersArray, true) . "\"" . $target . ">" . "<i class=\"fa fa-search\"></i></a>";
        // Old code that directly generates a 'search.php' URL which points to Details view for this record:
        //			// Construct the SQL query:
        //			// TODO: build the complete SQL query first (using functions 'buildFROMclause()' and 'buildORDERclause()'), then rawurlencode and add to link
        //			$showDetailsQuery = buildSELECTclause("Display", $showLinks, "", false, false); // function 'buildSELECTclause()' is defined in 'include.inc.php'
        //
        //			// ... display a link that opens the Details view for this record:
        //			if (isset($_SESSION['loginEmail'])) // if a user is logged in, show user specific fields:
        //				$links .= "\n\t\t<a href=\"" . $baseURL . "search.php"
        //				        . "?sqlQuery=" . rawurlencode($showDetailsQuery) . "%20FROM%20" . $tableRefs . "%20LEFT%20JOIN%20" . $tableUserData . "%20ON%20serial%20%3D%20record_id%20AND%20user_id%20%3D%20" . $userID . "%20";
        //			else // if NO user logged in, don't display any user specific fields and hide the 'location' field:
        //				$links .= "\n\t\t<a href=\"" . $baseURL . "search.php"
        //				        . "?sqlQuery=" . rawurlencode($showDetailsQuery) . "%20FROM%20" . $tableRefs . "%20";
        //
        //			$links .= "WHERE%20serial%20RLIKE%20%22%5E%28" . $row["serial"]
        //			        . "%29%24%22%20ORDER%20BY%20" . rawurlencode($orderBy)
        //			        . "&amp;formType=sqlSearch"
        //			        . "&amp;showQuery=" . $showQuery
        //			        . "&amp;showLinks=" . $showLinks
        //			        . "&amp;submit=Display"
        //			        . "&amp;viewType=" . $viewType
        //			        . "\"" . $target . ">"
        //			        . "<img src=\"" . $baseURL . "img/details.gif\" alt=\"" . $loc["details"] . "\" title=\"" . $loc["LinkTitle_ShowDetails"] . "\" width=\"9\" height=\"17\" hspace=\"0\" border=\"0\"></a>";
    }
    if (($linkElementCounterLoggedOut > 0 or isset($_SESSION['loginEmail']) and $linkElementCounterLoggedIn > 0) and (in_array("details", $showLinkTypes) and isset($_SESSION['user_permissions']) and preg_match("/allow_details_view/", $_SESSION['user_permissions']))) {
        $links .= "&nbsp;&nbsp;";
    }
    if (in_array("edit", $showLinkTypes) and isset($_SESSION['user_permissions']) and preg_match("/allow_edit/", $_SESSION['user_permissions'])) {
        // if the 'user_permissions' session variable contains 'allow_edit'...
        // ... display a link that opens the edit form for this record:
        $links .= "\n\t\t<a href=\"" . $baseURL . "record.php" . "?serialNo=" . $row["serial"] . "&amp;recordAction=edit" . "\"" . $target . ">" . "<i class=\"fa fa-pencil\"></i></a>";
    }
    if (($linkElementCounterLoggedOut > 1 or isset($_SESSION['loginEmail']) and $linkElementCounterLoggedIn > 1) and (in_array("edit", $showLinkTypes) and isset($_SESSION['user_permissions']) and preg_match("/allow_edit/", $_SESSION['user_permissions']))) {
        if (in_array("details", $showLinkTypes) and isset($_SESSION['user_permissions']) and preg_match("/allow_details_view/", $_SESSION['user_permissions'])) {
            $links .= "\n\t\t";
        } else {
            $links .= "&nbsp;&nbsp;";
        }
    }
    // show a link to any corresponding file if one of the following conditions is met:
    // - the variable '$fileVisibility' (defined in 'ini.inc.php') is set to 'everyone'
    // - the variable '$fileVisibility' is set to 'login' AND the user is logged in
    // - the variable '$fileVisibility' is set to 'user-specific' AND the 'user_permissions' session variable contains 'allow_download'
    // - the array variable '$fileVisibilityException' (defined in 'ini.inc.php') contains a pattern (in array element 1) that matches the contents of the field given (in array element 0)
    if (in_array("file", $showLinkTypes) and ($fileVisibility == "everyone" or $fileVisibility == "login" and isset($_SESSION['loginEmail']) or $fileVisibility == "user-specific" and (isset($_SESSION['user_permissions']) and preg_match("/allow_download/", $_SESSION['user_permissions'])) or !empty($fileVisibilityException) and preg_match($fileVisibilityException[1], $row[$fileVisibilityException[0]]))) {
        if (!empty($row["file"])) {
            if (preg_match("#^(https?|ftp|file)://#i", $row["file"])) {
                // if the 'file' field contains a full URL (starting with "http://", "https://", "ftp://" or "file://")
                $URLprefix = "";
            } else {
                // use the base URL of the standard files directory as prefix:
                if (preg_match('#^/#', $filesBaseURL)) {
                    if (preg_match("/^(cli|inc)/i", $client) or $wrapResults == "0") {
                        // we use absolute links for CLI clients, for include mechanisms, or when returning only a partial document structure
                        $URLprefix = 'http://' . $_SERVER['HTTP_HOST'] . $filesBaseURL;
                    } else {
                        $URLprefix = $filesBaseURL;
                    }
                } else {
                    // relative path -> file dir is located within refbase root dir
                    $URLprefix = $baseURL . $filesBaseURL;
                }
            }
            if (preg_match("/\\.pdf\$/i", $row["file"])) {
                // if the 'file' field contains a link to a PDF file
                $links .= "\n\t\t<a href=\"" . $URLprefix . $row["file"] . "\"" . $target . "><img src=\"" . $baseURL . "img/file_PDF.gif\" alt=\"" . $loc["pdf"] . "\" title=\"" . $loc["LinkTitle_DownloadPDFFile"] . "\" width=\"17\" height=\"17\" hspace=\"0\" border=\"0\"></a>";
            } else {
                $links .= "\n\t\t<a href=\"" . $URLprefix . $row["file"] . "\"" . $target . "><img src=\"" . $baseURL . "img/file.gif\" alt=\"" . $loc["file"] . "\" title=\"" . $loc["LinkTitle_DownloadFile"] . "\" width=\"11\" height=\"15\" hspace=\"0\" border=\"0\"></a>";
            }
            // display a generic file icon as download link
        }
    }
    // if a DOI number exists for this record, we'll prefer it as link, otherwise we use the URL (if available):
    // (note, that in List view, we'll use the same icon, no matter if the DOI or the URL is used for the link)
    if (in_array("doi", $showLinkTypes) and !empty($row["doi"])) {
        $links .= "\n\t\t<a href=\"http://dx.doi.org/" . rawurlencode($row["doi"]) . "\"" . $target . "><img src=\"" . $baseURL . "img/link.gif\" alt=\"" . $loc["doi"] . "\" title=\"" . $loc["LinkTitle_GotoWebPageViaDOI"] . "\" width=\"11\" height=\"8\" hspace=\"0\" border=\"0\"></a>";
    } elseif (in_array("url", $showLinkTypes) and !empty($row["url"])) {
        // 'htmlentities()' is used to convert any '&' into '&amp;'
        $links .= "\n\t\t<a href=\"" . encodeHTML($row["url"]) . "\"" . $target . "><img src=\"" . $baseURL . "img/link.gif\" alt=\"" . $loc["url"] . "\" title=\"" . $loc["LinkTitle_GotoWebPage"] . "\" width=\"11\" height=\"8\" hspace=\"0\" border=\"0\"></a>";
    } elseif (in_array("isbn", $showLinkTypes) and !empty($isbnURLFormat) and !empty($row["isbn"])) {
        // this is a stupid hack that maps the names of the '$row' array keys to those used
        // by the '$formVars' array (which is required by function 'parsePlaceholderString()')
        // (eventually, the '$formVars' array should use the MySQL field names as names for its array keys)
        $formVars = buildFormVarsArray($row);
        // function 'buildFormVarsArray()' is defined in 'include.inc.php'
        // auto-generate an ISBN link according to the naming scheme given in '$isbnURLFormat' (in 'ini.inc.php'):
        $isbnURL = parsePlaceholderString($formVars, $isbnURLFormat, "");
        // function 'parsePlaceholderString()' is defined in 'include.inc.php'
        $encodedURL = encodeHTML($isbnURL);
        // 'htmlentities()' is used to convert higher ASCII chars into its entities and any '&' into '&amp;'
        $encodedURL = str_replace(" ", "%20", $encodedURL);
        // ensure that any spaces are also properly urlencoded
        if (!empty($isbnURL)) {
            $links .= "\n\t\t<a href=\"" . $encodedURL . "\"" . $target . "><i class=\"fa fa-external-link\"></i></a>";
        }
    } elseif (in_array("xref", $showLinkTypes) and !empty($openURLResolver)) {
        $openURL = openURL($row);
        // function 'openURL()' is defined in 'openurl.inc.php'
        $links .= "\n\t\t<a href=\"" . $openURL . "\"" . " target=\"_blank\"><i class=\"fa fa-external-link\"></i></a>";
    }
    // insert COinS (ContextObjects in Spans):
    $links .= "\n\t\t" . coins($row);
    // function 'coins()' is defined in 'openurl.inc.php'
    return $links;
}
Example #22
0
function showPageHeader($HeaderString)
{
    global $officialDatabaseName;
    // these variables are defined in 'ini.inc.php'
    global $hostInstitutionAbbrevName;
    global $hostInstitutionName;
    global $hostInstitutionURL;
    global $helpResourcesURL;
    global $loginWelcomeMsg;
    // these variables are globally defined in function 'showLogin()' in 'include.inc.php'
    global $loginStatus;
    global $loginLinks;
    global $loc;
    // '$loc' is made globally available in 'core.php'
    ?>

<div id="globalWrapper">

      <div id="column-content">
	<div id="content">
	  <a name="top" id="contentTop"></a>
	  	  <h1 class="firstHeading"><?php 
    echo encodeHTML($officialDatabaseName);
    ?>
</h1>
	  <div id="bodyContent">
	    <h3 id="siteSub">From NUCAPT</h3>

	    <div id="contentSub"></div>
	    	    	    <!-- start content -->
            <h2><?php 
    echo $HeaderString;
    ?>
</h2>


<?php 
}
Example #23
0
?>
">
<table align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds forms that enable you to manage your custom queries">
<tr>
	<td width="120" valign="middle">
		<div class="sect"><?php 
echo $loc["QueryName"];
?>
:</div>
	</td>
	<td><?php 
echo fieldError("queryName", $errors);
?>

		<input type="text" name="queryName" value="<?php 
echo encodeHTML($queryName);
?>
" size="62">
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td>
		<input type="submit" name="submit" value="<?php 
echo $pageTitle;
?>
"><?php 
if ($queryAction == "edit") {
    ?>

			&nbsp;&nbsp;&nbsp;<input type="submit" name="submit" value="Delete Query"><?php 
Example #24
0
 case 'OXP_SORTFILES':
     $iTennantId = str_replace('\'', '\'\'', $_POST['TennantId']);
     $sSortArray = str_replace('\'', '\'\'', $_POST['SortArray']);
     $iSortType = str_replace('\'', '\'\'', $_POST['xf_SortType']);
     $SQL = 'call spDAOrderFileEntity (\'' . $iTennantId . '\',\'' . $iSortType . '\',\'' . $sSortArray . '\');';
     $result = mysql_query($SQL);
     //header ('Location: /OXP_PAGELIST?m=_103');
     break;
 case 'OXP_SITEDETAILS':
     $iTennantId = str_replace('\'', '\'\'', $_POST['TennantId']);
     $SiteTitle = str_replace('\'', '\'\'', $_POST['SiteTitle']);
     $sXURL = str_replace('\'', '\'\'', $_POST['XURL']);
     $sFavicon = str_replace('\'', '\'\'', $_POST['Favicon']);
     $sPageImageURL = str_replace('\'', '\'\'', $_POST['PageImageURL']);
     $sTrackingCode = stripslashes($_POST['TrackingCode']);
     $sTrackingCode = str_replace('\'', '\'\'', encodeHTML($sTrackingCode));
     $sTrackingCode = preg_replace("/\\s+/", " ", $sTrackingCode);
     $bPublicSite = str_replace('\'', '\'\'', $_POST['PublicSite']);
     $sShortDesc = str_replace('\'', '\'\'', $_POST['ShortDesc']);
     $iSiteType = str_replace('\'', '\'\'', $_POST['SiteType']);
     if (strlen($bPublicSite) < 1) {
         $bPublicSite = '1';
     }
     $SQL = 'call spDAInsUpdSiteDetails (\'' . $iTennantId . '\',\'' . $Persist_UserId . '\',\'' . $SiteTitle . '\',\'' . $sShortDesc . '\',\'' . $sFavicon . '\',\'' . $sTrackingCode . '\',\'' . $bPublicSite . '\',\'' . $sXURL . '\',\'' . $sPageImageURL . '\',\'' . $iSiteType . '\');';
     $result = mysql_query($SQL);
     break;
 case 'TENNANTSIGNOUT':
     break;
 case 'OXP':
     $sXURL = $_GET['XURL'];
     if (strlen($sXURL) > 0) {
Example #25
0
// Generate a 'search.php' URL that points to the formerly displayed results page:
if (!empty($oldMultiRecordQuery)) {
    $oldMultiRecordQueryURL = generateURL("search.php", "html", $oldMultiRecordQuery, true);
}
// function 'generateURL()' is defined in 'include.inc.php'
// Build a TABLE, containing one ROW and DATA tag:
echo "\n<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\" summary=\"This table holds links to the added/edited records as well as to the previously displayed search results page\">" . "\n<tr>" . "\n\t<td valign=\"top\">" . "\n\t\tChoose how to proceed:&nbsp;&nbsp;";
if (isset($_SESSION['user_permissions']) and preg_match("/allow_details_view/", $_SESSION['user_permissions'])) {
    if ($recordAction != "delet") {
        echo "\n\t\t<a href=\"search.php?sqlQuery=" . $sqlQuery . "&amp;showQuery=0&amp;showLinks=1&amp;formType=sqlSearch&amp;submit=Display\">Show " . $recordAction . "ed record</a>";
    }
    if ($recordAction != "delet" && !empty($oldMultiRecordQuery)) {
        echo "\n\t\t&nbsp;&nbsp;-OR-&nbsp;&nbsp;";
    }
}
if (!empty($oldMultiRecordQuery)) {
    // only provide a link to any previous search results if '$oldMultiRecordQuery' isn't empty
    echo "\n\t\t<a href=\"" . $oldMultiRecordQueryURL . "\">Display previous search results</a>";
}
if ((isset($_SESSION['user_permissions']) and preg_match("/allow_details_view/", $_SESSION['user_permissions']) and $recordAction != "delet") || !empty($oldMultiRecordQuery)) {
    echo "\n\t\t&nbsp;&nbsp;-OR-&nbsp;&nbsp;";
}
echo "\n\t\t<a href=\"index.php\">Goto " . encodeHTML($officialDatabaseName) . " Home</a>";
// we include the link to the home page here so that "Choose how to proceed:" never stands without any link to go
echo "\n\t</td>" . "\n</tr>" . "\n</table>";
// --------------------------------------------------------------------
// DISPLAY THE HTML FOOTER:
// call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
showPageFooter($HeaderString);
displayHTMLfoot();
// --------------------------------------------------------------------
Example #26
0
  <style>
    body{font:11px verdana,arial,sans-serif;}
    a{color:#0000cc;font-size:xx-small;}
  </style>

  <!-- STEP 1: Include the Editor js file -->
  <script language=JavaScript src='../scripts/innovaeditor.js'></script>

</head>
<body>

<?php 
if ($_POST["UpdInd"] = "1" && isset($_POST["txtContent"])) {
    $sContent = stripslashes($_POST['txtContent']);
    /*** remove (/) slashes ***/
    $sContent = encodeHTML($sContent);
}
?>

<form method="post" action="default.php" id="Form1">
    <input type="hidden" name="UpdInd" id="UpdInd"/>
    <div class="StdRow">
        <span class="StdLabel">Name</span>
        <span class="StdInput"><input type="text" name="Name" id="Name"/>
        <br class="ClearFloat"/>    
    </div>
    <div class="StdRow">
        <span class="StdLabel">Title</span>
        <span class="StdInput"><input type="Title" name="Title" id="Title"/>
        <br class="ClearFloat"/>    
    </div>    
Example #27
0
										?>
											<textarea name="article" id="article" rows=8 cols=30 style="width: 100%"><?php echo $sContent; ?></textarea>										
										<?php
											} else {
										?>										
										<script language=JavaScript src='./scripts/innovaeditor.js'></script>
										<textarea name="article" id="article" rows=4 cols=30>
										<?
										function encodeHTML($sHTML)
										{
										$sHTML=ereg_replace("&","&amp;",$sHTML);
										$sHTML=ereg_replace("<","&lt;",$sHTML);
										$sHTML=ereg_replace(">","&gt;",$sHTML);
										return $sHTML;
										}
										if(isset($sContent)) echo encodeHTML($sContent);
										?>
										</textarea>
										<script>
										var oEdit1 = new InnovaEditor("oEdit1");
										oEdit1.initialRefresh=true;
										oEdit1.REPLACE("article");
										</script>
										<?php
											}
										?>
									</td>
								</tr>
								<? } else { ?>
								<tr>
									<td bgcolor="#5E85CA" class="data_box">
Example #28
0
 // If there's no stored message available:
 if (!isset($_SESSION['HeaderString'])) {
     $HeaderString = "Display details for a particular record by entering its record identifier:";
 } else {
     $HeaderString = $_SESSION['HeaderString'];
     // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
     // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
     deleteSessionVariable("HeaderString");
     // function 'deleteSessionVariable()' is defined in 'include.inc.php'
 }
 // Show the login status:
 showLogin();
 // (function 'showLogin()' is defined in 'include.inc.php')
 // DISPLAY header:
 // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
 displayHTMLhead(encodeHTML($officialDatabaseName) . " -- " . $loc["ShowRecord"], "index,follow", "Search the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
 showPageHeader($HeaderString);
 // Define variables holding drop-down elements, i.e. build properly formatted <option> tag elements:
 $dropDownConditionalsArray = array("is equal to" => $loc["equal to"], "contains" => $loc["contains"], "is within list" => $loc["is within list"]);
 $dropDownItems1 = buildSelectMenuOptions($dropDownConditionalsArray, "//", "\t\t\t", true);
 // function 'buildSelectMenuOptions()' is defined in 'include.inc.php'
 $dropDownFieldNameArray = array("serial" => $loc["DropDownFieldName_Serial"]);
 if (isset($_SESSION['loginEmail'])) {
     // add drop down items for user-specific record identifiers:
     $dropDownFieldNameArray["call_number"] = $loc["DropDownFieldName_MyCallNumber"];
     $dropDownFieldNameArray["cite_key"] = $loc["DropDownFieldName_MyCiteKey"];
     // adjust the width of the table cell holding the drop down:
     $recordIDCellWidth = "140";
 } else {
     $recordIDCellWidth = "85";
 }
Example #29
0
showLogin();
// (function 'showLogin()' is defined in 'include.inc.php')
// (4) DISPLAY header:
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
displayHTMLhead(encodeHTML($officialDatabaseName) . " -- " . $loc["Home"], "index,follow", "Search the " . encodeHTML($officialDatabaseName), "", true, "", $viewType, $rssURLArray);
showPageHeader($HeaderString);
// Define variables holding common drop-down elements, i.e. build properly formatted <option> tag elements:
// - "Browse My Refs" form:
$dropDownFieldNameArray2 = array("author" => $loc["DropDownFieldName_Author"], "year" => $loc["DropDownFieldName_Year"], "publication" => $loc["DropDownFieldName_Publication"], "keywords" => $loc["DropDownFieldName_Keywords"], "user_keys" => $loc["DropDownFieldName_UserKeys"]);
$dropDownItems2 = buildSelectMenuOptions($dropDownFieldNameArray2, "//", "\t\t\t\t\t", true);
// function 'buildSelectMenuOptions()' is defined in 'include.inc.php'
// --------------------------------------------------------------------
?>

<table align="center" width="95%" summary="This table explains features, goals and usage of the <?php 
echo encodeHTML($officialDatabaseName);
?>
">
	<tr>
		<td colspan="2"><h3><?php 
echo $loc["RecentChanges"];
?>
</h3></td>
		<td width="<?php 
echo $rightColumnWidth;
?>
" valign="bottom" rowspan="2">
<?php 
if (!isset($_SESSION['loginEmail'])) {
    ?>
		<?php 
Example #30
0
										<textarea name="article" id="article" rows=4 cols=30>
										<?
										if(isset($sContent)) echo encodeHTML($sContent);
										?>
										</textarea>
										<script>
										var oEdit1 = new InnovaEditor("oEdit1");
										oEdit1.REPLACE("article");
										</script>
									</td>
								</tr>
								<tr>
										<td bgcolor="#5E85CA" class="data_box"><b>INFO:</b> (For My Info page and can be seen only by this member)<br>
										<textarea name="info" id="info" rows=4 cols=30>
										<?
										if(isset($sContent_info)) echo encodeHTML($sContent_info);
										?>
										</textarea>
										<script>
										var oEdit2 = new InnovaEditor("oEdit2");
										oEdit2.REPLACE("info");
										</script>
										<?php
											}
										?>
										</td>
								</tr>
								<? } else { ?>
								<tr>
									<td bgcolor="#5E85CA" class="data_box">
										<b>Notes</b><br>