Esempio n. 1
0
 function getPpmWithMetadata($max = 0)
 {
     //if (!isset($GLOBALS["preprintsClass"]) || !is_object($GLOBALS["preprintsClass"])) {
     //  require_once PATH_CLASSES . "/fromdb/preprints.php";
     //  $GLOBALS["preprintsClass"] = new fromdb_preprints();
     //}
     preprint::loadClass(PREPRINT_DATA_SOURCE_DB);
     // --> $GLOBALS["preprintClass"]
     $ppData = $GLOBALS["preprintClass"]->getRecentPreprints("bygroup", $max);
     $ppMetadata = $this->getPpmMetadata();
     foreach ($ppData as $wid => $p) {
         $p["ppn"] = str_pad($p["ppn"], 3, "0", STR_PAD_LEFT);
         $ppData[$wid]["norppn"] = $p["year"] . "-" . $p["ppn"];
     }
     foreach ($ppData as $wid => $p) {
         $ppData[$wid]["norcat"] = isset($p["norppn"]) && isset($ppMetadata[$p["norppn"]]) && $ppMetadata[$p["norppn"]]["label"] !== "-" ? $ppMetadata[$p["norppn"]]["label"] : "";
         $ppData[$wid]["noryear"] = isset($p["norppn"]) && isset($ppMetadata[$p["norppn"]]["year"]) ? $ppMetadata[$p["norppn"]]["year"] : "";
     }
     return $ppData;
 }
Esempio n. 2
0
 public static function drawPreprints()
 {
     $stdout = "";
     // -----------------------------------------------------------
     // -- Obtain preprint numbers
     // -----------------------------------------------------------
     self::initiateNewsClass();
     $issue_id = $GLOBALS["newsClass"]->getCurrentIssueId();
     $pn = $GLOBALS["newsClass"]->getPreprintNumbers($issue_id);
     if (empty($pn)) {
         return "";
     }
     // -----------------------------------------------------------
     // -- Obtain preprint data
     // -----------------------------------------------------------
     //if (!isset($dbPreprints) || !is_object($dbPreprints)) {
     //  require_once PATH_CLASSES . "/fromdb/preprints.php";
     //  $dbPreprints = new fromdb_preprints();
     //}
     preprint::loadClass(PREPRINT_DATA_SOURCE_DB);
     // --> $GLOBALS["preprintClass"]
     $preprints_row = $GLOBALS["preprintClass"]->getRecentPreprints("byid", 3, false, $pn["0"], $pn["1"]);
     array_shift($preprints_row);
     // -----------------------------------------------------------
     // -- Output
     // -----------------------------------------------------------
     $stdout .= "<h2 class='bottommargin'>NORDITA PREPRINTS</h2>\r\n" . "<p style='margin-bottom:-0.5em' class='only_online'>&rarr; See All Preprints: <a href='preprints/index.php' rel='nofollow'><strong>www.nordita.org/preprints</strong></a></p>\r\n" . "<p style='margin-bottom:2em'><em>The following preprints have been posted to the Nordita on-line preprint archive since the last newsletter issue:</em></p>\r\n";
     foreach ($preprints_row as $row) {
         $stdout .= "<dl>\r\n" . " <dt><strong>" . (!empty($row["location"]) ? "<a href='" . $row["location"] . "'>" . $row["serial"] . "</a>" : $row["serial"]) . "</strong></dt>\r\n" . " <dd>&quot;<strong>" . $row["title"] . "</strong>&quot;</dd>\r\n" . " <dd>" . $row["authors"] . "</dd>\r\n" . " <dd><em>" . $row["journal"] . "</em></dd>\r\n" . "</dl>\r\n";
     }
     // -----------------------------------------------------------
     return $stdout;
 }
Esempio n. 3
0
 static function OutputStatisticsPreprints($max)
 {
     $stdout = "";
     $theform = "";
     $htmllist = "";
     $wordlist = "";
     $textlist = "";
     $founderror = 0;
     functions::gpc_declare_input("statistics_select", false, true);
     functions::gpc_declare_input("yearfrom", VM_START_YEAR, false);
     functions::gpc_declare_input("yearto", date("Y"), false);
     functions::gpc_declare_input("output_type", "html", false);
     // --------------------------------------
     // LOAD CLASS
     // --------------------------------------
     if (!isset($GLOBALS["ppmClass"])) {
         if (!class_exists("fromdb_preprintsmeta", FALSE)) {
             require_once PATH_CLASSES . "/fromdb/preprintsmeta.php";
         }
         $GLOBALS["metadataClass"] = new fromdb_preprintsmeta();
     }
     //if (!isset($GLOBALS["preprintsClass"]) || !is_object($GLOBALS["preprintsClass"])) {
     //  require_once PATH_CLASSES . "/fromdb/preprints.php";
     //  $GLOBALS["preprintsClass"] = new fromdb_preprints();
     //}
     preprint::loadClass(PREPRINT_DATA_SOURCE_DB);
     // --> $GLOBALS["preprintClass"]
     // --------------------------------------
     // COLLECT DATA
     // --------------------------------------
     $ppCategories = $GLOBALS["metadataClass"]->getPpmCategories();
     $i = 1;
     foreach ($ppCategories as $label => $slask) {
         $ppSort[$label] = $i++;
     }
     $ppSort["0"] = "99";
     /*
     "R" => "1",
     "C" => "2",
     "B" => "3",
     "X" => "4",
     "D" => "5",
     "P" => "6",
     "S" => "7",
     "t" => "8",
     "n" => "9",
     "0" => "99"
     */
     $ppRsort = array_flip($ppSort);
     $ppData = $GLOBALS["metadataClass"]->getPpmWithMetadata($max);
     // ---------------------------------------------------------------------------
     // The preprints list
     // ---------------------------------------------------------------------------
     $preprints_row = $GLOBALS["preprintClass"]->getRecentPreprints("bygroup", $max);
     //debug::rr($preprints_row);
     /*
     if (false) {
         // --------------------------
         // Raw Data list
         // --------------------------
     
         foreach ($preprints_row as $p) {
           if (
                //($p["year"]<2007) ||
                ($GLOBALS["yearto"]>=$p["year"])
               )
           $htmllist .=
             "              <p>" .
             "{<em>" . $p["field"] . "</em>}&nbsp;".
             "[<a href='" . $p["location"] . "'>" . $p["serial"] . "</a>]" .
             " <strong>" . $p["title"] . "</strong>" .
             " by " . $p["authors"] .
             ( (!empty($p["journal"])) ?
               " (" . ucfirst($p["journal"]) . ")"
               : "" ) .
             "</p>\r\n";
         }
         return (!empty($htmllist)) ?
           "            <div>\r\n" .
           "              <p class='seealso'>" .
           $htmllist .
           "            </div>\r\n" .
           "\r\n"
           : "";
     } // end if (false)
     */
     // --------------------------
     $ppmax = array();
     foreach ($preprints_row as $wid => $p) {
         $p["ppn"] = str_pad($p["ppn"], 3, "0", STR_PAD_LEFT);
         $preprints_row[$wid]["norppn"] = $p["year"] . "-" . $p["ppn"];
         if (!isset($ppmax[$p["year"]]) || $ppmax[$p["year"]] < $p["ppn"]) {
             $ppmax[$p["year"]] = "['" . $p["year"] . "'," . (int) $p["ppn"] . "]";
         }
     }
     ksort($ppmax);
     /*
         include PATH_DATA."/statistics_preprints/classification.inc.php";
     */
     /*
         $ppList = array();
         foreach ($preprints_row as $wid => $p) {
           if (isset($p["norppn"])
               && isset($ppYear[$p["norppn"]])
               && isset($ppHead[$p["norppn"]])
               && ($ppHead[$p["norppn"]]!=="-")
               && ($GLOBALS["yearfrom"]<=$ppYear[$p["norppn"]])
               && ($ppYear[$p["norppn"]]<=$GLOBALS["yearto"])
             ) {
             $ppList[$ppSort[$ppHead[$p["norppn"]]]][$ppYear[$p["norppn"]]][$p["norppn"]] = $p;
           }
         }
     */
     foreach ($ppData as $data) {
         if (!empty($data["norcat"]) && !empty($data["noryear"]) && $data["norcat"] !== "-" && $GLOBALS["yearfrom"] <= $data["noryear"] && $data["noryear"] <= $GLOBALS["yearto"]) {
             $ppList[$ppSort[$data["norcat"]]][$data["noryear"]][$data["serial"]] = $data;
         }
     }
     foreach ($ppList as $norppn => $p1) {
         krsort($p1);
         $ppList[$norppn] = $p1;
         foreach ($p1 as $year => $p2) {
             krsort($p2);
             $ppList[$norppn][$year] = $p2;
         }
         unset($ppList[$year][""]);
     }
     $ppList[$ppSort["D"]][1] = array("code" => "The Pencil-Code", "desc" => "A high-order finite-difference code for compressible hydrodynamic flows with magnetic fields.", "url" => "http://pencil-code.googlecode.com");
     if ($GLOBALS["yearfrom"] <= 2012 && 2010 <= $GLOBALS["yearto"]) {
         // CK
         $ppList[$ppSort["D"]][] = array("code" => "G-Pen", "desc" => "Reimplementing the pencil-code for GPU using CUDA so we call it G-Pen.", "url" => "http://nas-fermi.albanova.se/cgit.cgi/gpen");
     }
     if ($GLOBALS["yearfrom"] <= 2011 && 2009 <= $GLOBALS["yearto"]) {
         // Niccolò
         $ppList[$ppSort["D"]][] = array("code" => "XNS", "desc" => "A code for axisymmetric equilibrium configurations of differentially rotating Neutron Stars with toroidal magnetic field.", "url" => "http://sites.google.com/site/niccolobucciantini/xns");
     }
     ksort($ppList);
     //echo "<h1>ppData</h1>";debug::rr($ppData);
     //echo "<h1>ppList</h1>";debug::rr($ppList);
     //echo "<h1>ppSort</h1>";debug::rr($ppSort);
     //echo "<h1>ppRsort</h1>";debug::rr($ppRsort);
     // ---------------------------------------------------------------------------
     // Form for list preferences
     // ---------------------------------------------------------------------------
     $sortby = 0;
     $theform .= "              <form id='selectmenu' action='" . $_SERVER["PHP_SELF"] . "' method='post' class='only_online'>\r\n" . "                <div class='input shadow-whiteinset'>\r\n" . "                  <span>List preprints from:</span> &nbsp; \r\n" . "                  <select name='yearfrom'>\r\n";
     for ($year = VM_START_YEAR; $year <= date("Y"); $year++) {
         $theform .= "                    <option value='" . $year . "'" . ($GLOBALS["yearfrom"] == $year ? " selected='selected'" : "") . ">" . $year . "</option>\r\n";
     }
     $theform .= "                  </select>\r\n" . "                  &nbsp; <span>to:</span> &nbsp; \r\n" . "                  <select name='yearto'>\r\n";
     for ($year = VM_START_YEAR; $year <= date("Y"); $year++) {
         $theform .= "                    <option value='" . $year . "'" . ($GLOBALS["yearto"] == $year ? " selected='selected'" : "") . ">" . $year . "</option>\r\n";
     }
     $theform .= "                  </select>\r\n" . "                </div>\r\n" . "                <div class='input shadow-whiteinset'><span>Display as:</span>\r\n" . "                  <input type='radio' name='output_type' value='html'" . ($GLOBALS["output_type"] == "html" ? " checked" : "") . "> web page\r\n" . "                  <input type='radio' name='output_type' value='word'" . ($GLOBALS["output_type"] == "word" ? " checked" : "") . "> word-ready\r\n" . "                  <input type='radio' name='output_type' value='text'" . ($GLOBALS["output_type"] == "text" ? " checked" : "") . "> plaintext\r\n" . "                </div>\r\n" . "                <div class=''>\r\n" . "                  <input type='submit' value='Select'>\r\n" . "                  <input type='hidden' name='statistics_select' value='1'>\r\n" . "                </div>\r\n" . "              <p style='font-size:smaller;margin-left:3em'><em>NB. When selecting options 'word-ready' or plaintext', use the <strong>browser back button</strong> to get back to this page</em></p>\r\n" . "              </form>\r\n" . "\r\n";
     $formdata = "";
     $showform = 1;
     if ($GLOBALS["statistics_select"]) {
         $errormessage = "";
         $founderror = 0;
         if ($GLOBALS["yearfrom"] > $GLOBALS["yearto"]) {
             $founderror = 1;
             $errormessage .= "          <p class='red bold'>&#187; The year interval seems to be a bit strange.</p>\r\n\r\n";
         }
         if (!is_numeric($GLOBALS["yearfrom"]) || $GLOBALS["yearfrom"] < VM_START_YEAR) {
             $founderror = 1;
             $errormessage .= "          <p class='red bold'>&#187; The start year seems to be a bit strange.</p>\r\n\r\n";
         }
         if (!is_numeric($GLOBALS["yearto"]) || date("Y") < $GLOBALS["yearto"]) {
             $founderror = 1;
             $errormessage .= "          <p class='red bold'>&#187; The end year seems to be a bit strange.</p>\r\n\r\n";
         }
         if (!in_array($GLOBALS["output_type"], array("html", "xstext"))) {
             $founderror = 1;
             $errormessage .= "          <p class='red bold'>&#187; The output type seems to be a bit strange.</p>\r\n\r\n";
         }
         if ($founderror) {
             $formdata .= $errormessage;
             $showform = 1;
         } else {
             //        $userdata = self::getDoorlabelData();
             //        $stdout .= self::outputDoorlabelImage($userdata);
             //        $showform = 0;
         }
         // end if ($noerror)
     } else {
         // leave vertical space for error messages
         //$formdata .= "          <p>&nbsp;</p>\r\n\r\n";
     }
     // end if (statistics_select)
     if ($showform) {
         $formdata .= $theform;
         /*
               unset($GLOBALS["statistics_select"]);
               $userdata = self::doorlabelData();
               if (empty($userdata)) {
                 $formdata .= BLURB_SORRY_PEOPLE_SEARCH;
               } else {
                 $formdata .= "FORM";
               }
         */
     }
     // --------------------------
     // Sorted list - html
     // --------------------------
     foreach ($ppList as $norppn => $p1) {
         if ($norppn < 8) {
             $htmllist .= (isset($ppCategories[$ppRsort[$norppn]]) ? "              <h2 id='" . $ppRsort[$norppn] . "'>" . $ppCategories[$ppRsort[$norppn]] . "</h2>\r\n" : "") . "\r\n";
             if ($norppn == 5) {
                 $i = 1;
                 $htmllist .= "              <table class='item'>\r\n";
                 foreach ($p1 as $wid => $p) {
                     $zclass = " class='b_zebra" . ($i % 2 + 1) . "'";
                     $htmllist .= "              <tr>\r\n" . "                <td" . $zclass . ">[" . $i++ . "]</td>\r\n" . "                <td" . $zclass . ">\r\n" . (isset($p["code"]) ? "<strong>" . $p["code"] . "</strong>" : "") . (isset($p["desc"]) ? "\r\n              <br>" . str_replace("\"", "'", $p["desc"]) . "" : "") . ($norppn != 7 && !empty($p["url"]) ? "\r\n              <br><span style='display:block;padding-left:2em;' class='monospace'>" . $p["url"] . "</span>" : "") . "</td>\r\n" . "              </tr>\r\n";
                 }
                 $htmllist .= "              </table>\r\n" . "\r\n";
             } else {
                 $i = 1;
                 foreach ($p1 as $year => $p2) {
                     if ($norppn < 8 || $GLOBALS["yearfrom"] < $year) {
                         $htmllist .= "              <h4>" . $year . "</h4>\r\n" . "\r\n" . "              <table class='item'>\r\n";
                         foreach ($p2 as $wid => $p) {
                             $zclass = " class='b_zebra" . (($i - 1) % 2 + 1) . "'";
                             $htmllist .= "              <tr>\r\n" . "                <td" . $zclass . ">[" . $i++ . "]</td>\r\n" . "                <td" . $zclass . ">\r\n" . (isset($p["authors"]) ? "                <p>" . str_replace("&", " and ", $p["authors"]) . "</p>" : "") . (isset($p["title"]) ? "\r\n                <p>&quot;<strong>" . str_replace("\"", "'", $p["title"]) . "</strong>&quot;</p>" : "") . ($norppn != 7 && !empty($p["journal"]) ? "\r\n                <p>" . ucfirst(str_replace("not to be published", "", $p["journal"])) . "</p>" : "") . "</td>\r\n" . "              </tr>\r\n";
                         }
                         $htmllist .= "              </table>\r\n" . "\r\n";
                     }
                 }
             }
         }
     }
     // --------------------------
     // Sorted list - word
     // --------------------------
     foreach ($ppList as $norppn => $p1) {
         if ($norppn < 8 && $norppn != 5) {
             if (isset($ppCategories[$ppRsort[$norppn]])) {
                 $wordlist .= "              <h2>" . $ppCategories[$ppRsort[$norppn]] . "</h2>\r\n\r\n";
             }
             $i = 1;
             foreach ($p1 as $year => $p2) {
                 if ($norppn < 8 || $GLOBALS["yearfrom"] < $year) {
                     $wordlist .= "              <h4>" . $year . "</h4>\r\n" . "\r\n";
                     foreach ($p2 as $wid => $p) {
                         $wordlist .= "<p>[" . $i++ . "] " . (isset($p["authors"]) ? str_replace("&", " and ", $p["authors"]) : "") . (isset($p["title"]) ? " &quot;<strong>" . str_replace("\"", "'", $p["title"]) . "</strong>&quot;" : "") . ($norppn != 7 && !empty($p["journal"]) ? "; " . ucfirst(str_replace("not to be published", "", $p["journal"])) : "") . "</p>\r\n";
                     }
                     $wordlist .= "\r\n";
                 }
             }
         }
     }
     // --------------------------
     // Sorted list - text
     // --------------------------
     foreach ($ppList as $norppn => $p1) {
         if ($norppn < 8 && $norppn != 5) {
             if (isset($ppCategories[$ppRsort[$norppn]])) {
                 $textlist .= $ppCategories[$ppRsort[$norppn]] . "\r\n\r\n";
             }
             $i = 1;
             foreach ($p1 as $year => $p2) {
                 if ($norppn < 8 || $GLOBALS["yearfrom"] < $year) {
                     $textlist .= $year . "\r\n" . "\r\n";
                     foreach ($p2 as $wid => $p) {
                         $textlist .= "[" . $i++ . "] " . (isset($p["authors"]) ? str_replace("&", " and ", $p["authors"]) : "") . (isset($p["title"]) ? ", '" . str_replace("\"", "'", $p["title"]) . "'" : "") . ($norppn != 7 && !empty($p["journal"]) ? "; " . ucfirst(str_replace("not to be published", "", $p["journal"])) : "") . "\r\n";
                     }
                     $textlist .= "\r\n";
                 }
             }
         }
     }
     // ---------------------------------------------------------------------------
     // Output
     // ---------------------------------------------------------------------------
     if (empty($htmllist)) {
         return "";
     }
     if ($GLOBALS["yearfrom"] == $GLOBALS["yearto"]) {
         $yearinterval = $GLOBALS["yearfrom"];
     } else {
         $yearinterval = $GLOBALS["yearfrom"] . "-" . $GLOBALS["yearto"];
     }
     switch ($GLOBALS["output_type"]) {
         case "html":
             $stdout .= "            <style type='text/css'>\r\n" . "              table.item {width:100%;}\r\n" . "              table.item td:first-child {width:2em}\r\n" . "              table.item td {padding:0 1em 0 1em;}\r\n" . "              table.item p {margin-bottom:0em;}\r\n" . "              h4 {margin-bottom: 1em;}\r\n" . "            </style>\r\n" . "            <div>\r\n" . "              <div>\r\n" . self::outputColumnchart("preprints", $ppmax, "Nordita Preprints 1995-" . date("Y"), "700", "300", array(""), "{slantedText:true}", "{baseline:0, gridlines:{count:7}}") . "              </div>\r\n" . "\r\n" . $formdata;
             if (!$founderror) {
                 $stdout .= "              <hr>\r\n" . "              <h4>" . "From the <a href='preprints/index.php' rel='nofollow'>" . "Nordita preprint archive</a> " . $yearinterval . ":</h4>\r\n" . "              <div class='col-content-left'>\r\n" . "              <ul>\r\n" . "                <li class='bold'><a href='" . $_SERVER["PHP_SELF"] . "#R'>Refereed Papers</a></li>\r\n" . "                <li class='bold'><a href='" . $_SERVER["PHP_SELF"] . "#C'>Refereed conference contributions</a></li>\r\n" . "                <li class='bold'><a href='" . $_SERVER["PHP_SELF"] . "#B'>Review articles, book chapters, books</a></li>\r\n" . "              </ul>\r\n" . "              </div><div class='col-content-right'>\r\n" . "              <ul>\r\n" . "                <li class='bold'><a href='" . $_SERVER["PHP_SELF"] . "#D'>Open Source Computer Software</a></li>\r\n" . "                <li class='bold'><a href='" . $_SERVER["PHP_SELF"] . "#P'>Popular science articles or presentations</a></li>\r\n" . "                <li class='bold'><a href='" . $_SERVER["PHP_SELF"] . "#S'>Submitted papers and conference contributions</a></li>\r\n" . "              </ul>\r\n" . "              </div><div style='clear:both'><br></div>\r\n" . "\r\n" . "              <div id='prepweb'>\r\n" . "              " . PAGE_BREAK . "              </div>\r\n" . $htmllist;
             }
             $stdout .= "            </div>\r\n" . "\r\n";
             break;
         case "word":
             $stdout .= "            <style type='text/css'>\r\n" . "              p {margin-bottom:-1em}\r\n" . "              h1,h2,h3,h4 {font-size:1em;}\r\n" . "              h1, h2 {text-transform: uppercase}\r\n" . "              h4 {margin-bottom: 1em;}\r\n" . "              p+h2, p+h4 {margin-top: 2em;}\r\n" . "            </style>\r\n" . "            <div id='prepword'>\r\n" . "\r\n" . "              <h1>FROM THE NORDITA PREPRINT ARCHIVE " . $yearinterval . "</h1>\r\n" . "\r\n" . $wordlist . "\r\n" . "            </div>\r\n" . "";
             break;
         case "text":
             // assumed to be configured as "contenttype" => "plain"
             $stdout .= "FROM THE NORDITA PREPRINT ARCHIVE " . $yearinterval . "\r\n" . "\r\n" . $textlist . "";
             break;
     }
     // end switch
     return $stdout;
 }