示例#1
0
function generateCitations($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $nothingChecked, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
{
    global $contentTypeCharset;
    // these variables are defined in 'ini.inc.php'
    global $defaultCiteStyle;
    global $client;
    global $userOptionsArray;
    // get all user options for the current user:
    // (note that '$userOptionsArray' is made globally available)
    $userOptionsArray = getUserOptions($userID);
    // function 'getUserOptions()' is defined in 'include.inc.php'
    // if the query has results ...
    if ($rowsFound > 0) {
        // Save the current Citation view query to a session variable:
        //			saveSessionVariable("lastCitationViewQuery", $query);
        // fetch the name of the citation style file that's associated with the style given in '$citeStyle':
        $citeStyleFile = getStyleFile($citeStyle);
        // function 'getStyleFile()' is defined in 'include.inc.php'
        if (empty($citeStyleFile)) {
            $citeStyle = $defaultCiteStyle;
            // if the given cite style could not be found, we'll use the default cite style which is defined by the '$defaultCiteStyle' variable in 'ini.inc.php'
            $citeStyleFile = getStyleFile($citeStyle);
        }
        // include the found citation style file *once*:
        include_once "cite/" . $citeStyleFile;
        // fetch the name of the citation format file that's associated with the format given in '$citeType':
        $citeFormatFile = getFormatFile($citeType, "cite");
        // function 'getFormatFile()' is defined in 'include.inc.php()'
        if (empty($citeFormatFile)) {
            if (preg_match("/^cli/i", $client)) {
                // if the query originated from a command line client such as the refbase CLI clients ("cli-refbase-1.1", "cli-refbase_import-1.0")
                $citeType = "ASCII";
            } else {
                $citeType = "html";
            }
            $citeFormatFile = getFormatFile($citeType, "cite");
        }
        // include the found citation format file *once*:
        include_once "cite/" . $citeFormatFile;
        $citationData = citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType);
        if (preg_match("/^RTF\$/i", $citeType)) {
            $citeContentType = "application/rtf";
            $citeFileName = "citations.rtf";
        } elseif (preg_match("/^PDF\$/i", $citeType)) {
            $citeContentType = "application/pdf";
            $citeFileName = "citations.pdf";
        } elseif (preg_match("/^LaTeX\$/i", $citeType)) {
            $citeContentType = "application/x-latex";
            $citeFileName = "citations.tex";
        } elseif (preg_match("/^LaTeX \\.bbl\$/i", $citeType)) {
            $citeContentType = "application/x-latex";
            $citeFileName = "citations.bbl";
        } elseif (preg_match("/^Markdown\$/i", $citeType)) {
            $citeContentType = "text/plain";
            $citeFileName = "citations.txt";
        } elseif (preg_match("/^ASCII\$/i", $citeType)) {
            $citeContentType = "text/plain";
            $citeFileName = "citations.txt";
        } else {
            $citeContentType = "text/html";
            $citeFileName = "citations.html";
        }
        if (!preg_match("/^html\$/i", $citeType)) {
            // set the appropriate mimetype & set the character encoding to the one given in '$contentTypeCharset' (which is defined in 'ini.inc.php'):
            setHeaderContentType($citeContentType, $contentTypeCharset);
        }
        // function 'setHeaderContentType()' is defined in 'include.inc.php'
        if (preg_match("/^application/i", $citeContentType)) {
            // instruct the browser to download the resulting output as file:
            header('Content-Disposition: attachment; filename="' . $citeFileName . '"');
        }
        // Note that this doesn't seem to work with all browsers (notably not with Safari & OmniWeb on MacOSX Panther, but it does work with Mozilla & Camino as well as Safari on Tiger)
        echo $citationData;
    } else {
        $nothingFoundFeedback = nothingFound($nothingChecked);
        echo $nothingFoundFeedback;
    }
}
示例#2
0
    }
}
// --------------------------------------------------------------------
// PARSE SOURCE TEXT:
if (!empty($sourceText) and !empty($sourceFormat)) {
    // fetch the path/name of the import format file that's associated with the import format given in '$sourceFormat':
    $importFormatFile = getFormatFile($sourceFormat, "import");
    // function 'getFormatFile()' is defined in 'include.inc.php()'
    if (!empty($importFormatFile)) {
        // Get all cite keys specified by the current user and build an array of uniquified cite keys ('$citeKeysArray')
        // which is used to ensure uniqueness of generated cite keys among all imported records as well as the user's existing records:
        $userCiteKeysArray = getUserCiteKeys($loginUserID);
        // '$loginUserID' is provided as session variable on login; function 'getUserCiteKeys()' is defined in 'include.inc.php'
        // Get all user options for the current user (which is required by function 'generateCiteKey()'
        // that, in turn, is called below & from within the 'addRecords()' function):
        $userOptionsArray = getUserOptions($loginUserID);
        // function 'getUserOptions()' is defined in 'include.inc.php'
        // Include the found import format file *once*:
        include_once "import/" . $importFormatFile;
        // Parse records from the specified import format:
        // function 'importRecords()' is defined in the import format file given in '$importFormatFile' (which, in turn, must reside in the 'import' directory of the refbase root directory)
        // NOTE: see note above below the 'fetchDataFromArXiv()' function
        list($importDataArray, $recordsCount, $importRecordNumbersRecognizedFormatArray, $importRecordNumbersNotRecognizedFormatArray, $errors) = importRecords($sourceText, $importRecordsRadio, $importRecordNumbersArray);
    } else {
        $errors["sourceText"] = "Sorry, but the {$sourceFormat} importer is currently not available!";
    }
} else {
    $importDataArray = array();
    $recordsCount = 0;
    $importRecordNumbersRecognizedFormatArray = array();
    $importRecordNumbersNotRecognizedFormatArray = array();
示例#3
0
// (4) DISPLAY header:
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
displayHTMLhead(encodeHTML($officialDatabaseName) . " -- User Options", "noindex,nofollow", "User options offered by the " . encodeHTML($officialDatabaseName), "\n\t<meta http-equiv=\"expires\" content=\"0\">", true, "", $viewType, array());
showPageHeader($HeaderString);
// --------------------------------------------------------------------
if (empty($errors)) {
    // Reset the '$formVars' variable (since we're loading from the user tables):
    $formVars = array();
    // Reset the '$errors' variable:
    $errors = array();
    // Load all the form variables with user data & options:
    $formVars["language"] = $row["language"];
}
// Initialize variables which will set form elements according to the current user's options:
// Get all user options for the current user:
$userOptionsArray = getUserOptions($userID);
// function 'getUserOptions()' is defined in 'include.inc.php'
// Display Options:
if (!empty($userID)) {
    // Get all languages that were setup and enabled by the admin:
    $languagesArray = getLanguages("");
    // function 'getLanguages()' is defined in 'include.inc.php'
    $fieldDisabled = "";
} else {
    $languagesArray = array($defaultLanguage);
    // for a user who's not logged in, we fall back to the default language (defined in 'ini.inc.php')
    $fieldDisabled = " disabled";
    // disable some fields if the user isn't logged in (in which case the display language, no. of records per page, show auto-completions & the "main fields" search option will be taken from global variables in 'ini.inc.php')
}
$languageOptionTags = buildSelectMenuOptions($languagesArray, "/ *; */", "\t\t\t", false);
// build properly formatted <option> tag elements from language items returned by function 'getLanguages()'
示例#4
0
function getPrefAutoCompletions($userID)
{
    global $loginEmail;
    global $adminLoginEmail;
    // these variables are defined in 'ini.inc.php'
    global $autoCompleteUserInput;
    $userOptionsArray = array();
    // initialize array variable
    // Get all user options for the current user:
    // note that if the user isn't logged in (userID=0), we don't load the pref setting from option
    // 'show_auto_completions' in table 'user_options' (where 'user_id = 0'). Instead, we'll take
    // the setting from variable '$autoCompleteUserInput' in 'ini.inc.php'.
    if ($userID != 0) {
        $userOptionsArray = getUserOptions($userID);
    }
    // Extract the setting which defines whether auto-completions shall be displayed for text entered by the user:
    if (!empty($userOptionsArray) and !empty($userOptionsArray['show_auto_completions'])) {
        $showAutoCompletions = $userOptionsArray['show_auto_completions'];
    } else {
        $showAutoCompletions = $autoCompleteUserInput;
    }
    // by default, we take the pref setting from the global variable '$autoCompleteUserInput'
    // We'll only update the appropriate session variable if either a normal user is logged in -OR- the admin is logged in and views his own user options page
    if ($loginEmail != $adminLoginEmail or $loginEmail == $adminLoginEmail && $userID == getUserID($loginEmail)) {
        // Write results into a session variable:
        saveSessionVariable("userAutoCompletions", $showAutoCompletions);
    }
    return $showAutoCompletions;
}