예제 #1
0
 static function OutputRecentPreprints($wid = "recentpreprints", $divclass = "", $subclass = "", $headerInsideDiv = FALSE, $selectByGroup = TRUE, $max = 1)
 {
     $stdout = "";
     $preprintsRaw = $preprintsSorted = array();
     if ($max < 1) {
         $max = 1;
     }
     if (IS_ENTRANCE) {
         $max = 3;
     }
     // ----------------------------
     // OBTAIN DATA
     // ----------------------------
     //if (!isset($dbPreprints) || !is_object($dbPreprints)) {
     //  require_once PATH_CLASSES . "/fromdb/preprints.php";
     //  $dbPreprints = new fromdb_preprints();
     //}
     self::loadClass(PREPRINT_DATA_SOURCE_DB);
     // --> $GLOBALS["preprintClass"]
     $preprintsRaw = $selectByGroup ? $GLOBALS["preprintClass"]->getRecentPreprints("bygroup", $max) : $GLOBALS["preprintClass"]->getRecentPreprints("", $max);
     foreach ($preprintsRaw as $p) {
         $label = $selectByGroup ? $p["field"] : "0";
         $preprintsSorted[$label][] = $p;
     }
     // ----------------------------
     // OUTPUT DATA
     // ----------------------------
     foreach ($preprintsSorted as $label => $data) {
         if ($selectByGroup) {
             $stdout .= "                <p class='field'>In " . functions::getResearchGroup($label) . ":</p>\r\n";
         }
         foreach ($data as $p) {
             if ($selectByGroup == FALSE && $max == 1) {
                 $stdout .= "                <p>[<a href='" . $p["location"] . "'>" . $p["serial"] . "</a>]</p>\r\n" . "                <p class='title'>" . $p["title"] . "</p>\r\n" . "                <p>by <span class='author'>" . $p["authors"] . "</span></p>\r\n" . (!empty($p["journal"]) ? "                <p class='journal'>" . ucfirst($p["journal"]) . "</p>\r\n" : "");
             } else {
                 $stdout .= "                <p" . ($subclass ? " class='" . $subclass . "'" : "") . ">[<a href='" . $p["location"] . "'>" . $p["serial"] . "</a>]" . " <span class='title'>" . $p["title"] . "</span>" . " by <span class='author'>" . $p["authors"] . "</span>" . (!empty($p["journal"]) ? "<br>\r\n" . "                <span class='journal'>" . ucfirst($p["journal"]) . "</span>" : "") . "</p>\r\n";
             }
         }
     }
     if (empty($stdout)) {
         $stdout = "                <p class='red'>[<em>Could not fetch any preprints at this time</em>]</p>\r\n";
     } else {
         $stdout .= "                <p class='seealso dots'>" . "<a href='" . (USE_SECURE_SITE_FOR_PREPRINTS ? "https://secure.albanova.se/preprints/index.php" : "preprints/index.php") . "?group=all&amp;pp_period=all'>See list of all " . ($max > 1 ? "Nordita " : "") . "preprints</a>" . "</p>\r\n";
     }
     // -- for accordion effect:
     //if (!IS_ENTRANCE) $stdout = "                <div>\r\n" . $stdout . "                </div>\r\n";
     $hdr = $max == 1 ? "Latest Preprint" : "Latest Preprints";
     return empty($stdout) ? "" : widget::WoutputBoxOrWidget($wid, $divclass, $hdr, $stdout, $headerInsideDiv);
 }