Changeset 18893 for trunk/www


Ignore:
Timestamp:
06/27/17 19:18:04 (7 years ago)
Author:
Daniela Dorner
Message:
implemented printing of authorlist in differen formats
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/dch/memberlist.php

    r18887 r18893  
    1 <html>
    2 <head>
    3   <meta name="Author" content="Daniela Dorner" />
    4   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    5   <title>FACT Project</title>
    6   <link rel="StyleSheet" type="text/css" href="../style.css" />
    7 </head>
    81<?php
    92
    10     echo (file_get_contents("../shifteval/header.html"));
     3function GetSup($style, $sup)
     4{
     5    switch($style)
     6    {
     7    case "html":
     8        return " &lt;sup&gt;".$sup."&lt;/sup&gt;";
     9        break;
     10    case "text":
     11        return " <sup>".$sup."</sup>";
     12        break;
     13    case "latex":
     14        return " $^".$sup."$";
     15        break;
     16    default:
     17        break;
     18    }
     19
     20}
     21
     22function GetBla($style, $text)
     23{
     24    switch($style)
     25    {
     26    case "html":
     27        return str_replace("'", "\'", str_replace("ä", '&amp;auml;', str_replace("ü", '&amp;uuml;', mb_convert_encoding($text, 'utf-8', 'iso-8859-1'))));
     28        break;
     29    case "text":
     30        return str_replace("'", "\'", str_replace("ä", '&auml;', str_replace("ü", '&uuml;', mb_convert_encoding($text, 'utf-8', 'iso-8859-1'))));
     31        break;
     32    case "latex":
     33        return str_replace("'", "\'", str_replace("ä", '{\"a}', str_replace("ü", '{\"u}', mb_convert_encoding($text, 'utf-8', 'iso-8859-1'))));
     34        break;
     35    default:
     36        break;
     37    }
     38}
     39
     40function GetEndl($style, $comma)
     41{
     42    switch($style)
     43    {
     44    case "latex":
     45        return $comma." &bsol;&bsol; <br>\n";
     46        break;
     47    case "html":
     48        return $comma." &lt;br&gt; <br>\n";
     49        break;
     50    case "text":
     51        return $comma." \n";
     52        break;
     53    default:
     54        return $comma." <br>\n";
     55        break;
     56    }
     57}
     58    echo "<html>\n";
     59    echo "<head>\n";
     60    echo "<meta name='Author' content='Daniela Dorner' />\n";
     61    echo "<meta http-equiv='content-type' content='text/html; charset=utf-8' />\n";
     62    echo "<title>FACT Project</title>\n";
     63    echo "<link rel='StyleSheet' type='text/css' href='../style.css' />\n";
     64    echo "</head>\n";
     65    echo "<body>\n";
     66    //echo (file_get_contents("../shifteval/header.html"));
    1167
    1268    if (!empty($_GET["date"]))
     
    1470    else
    1571        $date=date("Ymd");
     72
     73    if (!empty($_GET["listformat"]))
     74        $listformat=$_GET["listformat"];
     75    else
     76        $listformat="long";
     77
     78    if (!empty($_GET["textformat"]))
     79        $textformat=$_GET["textformat"];
     80    else
     81        $textformat="latex";
    1682
    1783    $starttimestamp = new DateTime($startdate);
     
    2086    date_add($stoptimestamp, date_interval_create_from_date_string("12 hours"));
    2187
    22     echo "<body>\n";
    2388    echo "<form action='memberlist.php' METHOD='GET'>\n";
    2489    echo "<b>FACT Collaboration</b> status of date ";
     
    37102    //members where not isnull(start) and not isnull(stop) group by username;
    38103
    39     $query="SELECT username, Date(start) AS 'from', if(stop='2020-12-31 23:59:59', 'unlimited', Date(stop)) AS 'until',";
    40     $query.=" DATE(ADDDATE(start, INTERVAL 6 MONTH)) AS 'author since', ";
    41     $query.=" IF(stop='2020-12-31 23:59:59', 'unlimited', DATE(ADDDATE(stop, INTERVAL 1 YEAR))) AS 'author until', ";
    42     $query.=" institutename, MID(username, LOCATE(' ', username)+1) AS surname, ";
    43     $query.=" MID(username, 1, LOCATE(' ', username)) AS firstname ";
    44     $query.=" FROM memberlist.members LEFT JOIN memberlist.institutes USING(instituteid) ";
    45     $query.=" WHERE NOT start='0000-00-00 00:00:00' AND NOT stop='0000-00-00 00:00:00' ";
    46     $querycurrent=$query." AND ADDDATE(start, INTERVAL 6 MONTH) < '".$date."' AND ADDDATE(stop, INTERVAL 1 YEAR) > '".$date."' ";
    47     $querycurrent=$querycurrent." ORDER BY surname";
    48     $queryall=$query." ORDER BY surname";
     104    $selectcurrent="SELECT userid, firstname, middlename, lastname, inst.institutename, also.institutefullname, inst.institutefullname, inst.instituteadresse ";
     105    $selectall="SELECT username, Date(start) AS 'from', if(stop='2020-12-31 23:59:59', 'unlimited', Date(stop)) AS 'until',";
     106    $selectall.=" DATE(ADDDATE(start, INTERVAL 6 MONTH)) AS 'author since', ";
     107    $selectall.=" IF(stop='2020-12-31 23:59:59', 'unlimited', DATE(ADDDATE(stop, INTERVAL 1 YEAR))) AS 'author until', ";
     108    $selectall.=" inst.institutename, MID(username, LOCATE(' ', username)+1) AS surname, ";
     109    $selectall.=" MID(username, 1, LOCATE(' ', username)) AS firstname, ";
     110    $selectall.=" firstname, middlename, lastname, also.institutefullname, inst.institutefullname, inst.instituteadresse ";
     111    $selectlist="SELECT ";
     112    if ($textformat=="latex")
     113        $sep="~";
     114    else
     115        $sep=" ";
     116    switch ($listformat)
     117    {
     118    case "long":
     119        $selectlist.="CONCAT(firstname, ' ', if (not isnull(middlename), middlename, ''), ' ', lastname), ";
     120        break;
     121    case "short":
     122        $selectlist.="CONCAT(LEFT(firstname, 1), '.', if (not isnull(middlename), CONCAT(LEFT(middlename, 1), '.".$sep."'), '".$sep."'), lastname), ";
     123        break;
     124    }
     125    $selectlist.="inst.institutename, also.institutefullname, inst.institutefullname, inst.instituteadresse  ";
     126    $from=" FROM memberlist.members ";
     127    $join=" LEFT JOIN memberlist.institutes inst USING(instituteid) ";
     128    $join.=" LEFT JOIN memberlist.institutes also ON also.instituteid=alsoat ";
     129    $where.=" WHERE NOT start='1970-01-01 00:00:00' AND NOT isnull(stop) ";
     130
     131    $corresponding="";
     132    foreach ($_GET as $key => $name)
     133    {
     134        if (strpos($key, 'corresponding') !== false)
     135        {
     136            if ($corresponding=="")
     137                $corresponding.=str_replace('corresponding', '', $key);
     138            else
     139                $corresponding.=", ".str_replace('corresponding', '', $key);
     140        }
     141    }
     142
     143
     144    $current=" AND ADDDATE(start, INTERVAL 6 MONTH) < '".$date."' AND ADDDATE(stop, INTERVAL 1 YEAR) > '".$date."' ";
     145    $order=" ORDER BY lastname";
     146    $querycurrent=$selectcurrent.$from.$join.$where.$current;
     147    $querycurrent=$querycurrent.$order;
     148    $queryall=$selectall.$from.$join.$where.$order.", start";
     149    if ($corresponding=="")
     150    {
     151        $querylist=$selectlist.$from.$join.$where.$current.$order;
     152    }
     153    else
     154    {
     155        $querylist=$selectlist.$from.$join.$where." AND userid IN (".$corresponding.") ".$current.$order;
     156        $querylist2=$selectlist.$from.$join.$where." AND userid NOT IN (".$corresponding.") ".$current.$order;
     157    }
    49158
    50159    echo "<br>\n<br>\n";
     160//    echo $querycurrent."<br>\n<br>\n";
     161//    echo $queryall."<br>\n<br>\n";
     162//    echo $querylist."<br>\n<br>\n";
     163    echo $_GET["corresponding"];
    51164    echo "<h3>Current Author List:</h3>\n";
    52165    echo "<table border='1'>\n";
    53     echo "<thead><tr><th>Surname</th><th>Firstname</th><th>institute</th></tr></thead>\n";
     166    echo "<thead><tr><th>*</th><th>First Middle Lastname</th><th>Institute (#)</th><th>also at</th></tr></thead>\n";
    54167    echo "<tbody>\n";
    55168    $result  = mysql_query($querycurrent);
     169    $counter=0;
     170    $letter=a;
     171    $institutes = [];
     172    $instnames = [];
     173    $instaddresses = [];
     174    $alsos = [];
    56175    while ($row = mysql_fetch_row($result))
    57         echo "<tr><td>".$row[6]."</td><td>".$row[7]."</td><td>".$row[5]."</td></tr>";
    58     echo "<tbody>\n";
     176    {
     177        echo "<tr>";
     178        if ($_GET["corresponding".$row[0]]=="yes")
     179            echo "<td><input type='checkbox' name='corresponding".$row[0]."' value='yes' checked='checked'></td>";
     180        else
     181            echo "<td><input type='checkbox' name='corresponding".$row[0]."' value='yes'></td>";
     182        echo "<td title='".$row[0]."'>".$row[1]." ".$row[2]." ".$row[3]."</td>";
     183        if (!in_array($row[4],$institutes))
     184        {
     185            $counter++;
     186            $institutes[$counter]=$row[4];
     187            $instnames[$counter]=$row[6];
     188            $instaddresses[$counter]=$row[7];
     189        }
     190        echo "<td>".mb_convert_encoding($row[4], 'utf-8', 'iso-8859-1')." (".array_search($row[4], $institutes).")</td>";
     191        if ($row[5])
     192        {
     193            if (!in_array($row[5], $alsos))
     194            {
     195                $alsos[$letter]=$row[5];
     196                $letter++;
     197            }
     198            echo "<td>".$row[5]." (".array_search($row[5], $alsos).") </td></tr>";
     199        }
     200        else
     201            echo "<td></td></tr>";
     202    }
     203    //print_r($institutes);
     204    //print_r($alsos);
     205    echo "</tbody>\n";
    59206    echo "</table>\n<br>\n";
    60207    mysql_free_result($result);
     208
     209
     210    echo "<h3>Institute List:</h3>\n";
     211    echo "<table border='1'>\n";
     212    echo "<thead><tr><th>#</th><th>Institute</th><th>Institute Adresse</th></tr></thead>\n";
     213    echo "<tbody>\n";
     214    for ($i = 1; $i <= $counter; $i++)
     215    {
     216        echo "<tr><td>".$i."</td><td>".mb_convert_encoding($instnames[$i], 'utf-8', 'iso-8859-1')."</td><td>".mb_convert_encoding($instaddresses[$i], 'utf-8', 'iso-8859-1')."</td></tr>";
     217    }
     218    echo "<tr><td></td><td></td><td></td></tr>";
     219    foreach ($alsos as $num => $name)
     220    {
     221        echo "<tr><td>".$num."</td><td>".mb_convert_encoding($name, 'utf-8', 'iso-8859-1')."</td><td></td></tr>";
     222    }
     223    echo "</tbody>\n";
     224    echo "</table>\n<br>\n";
    61225
    62226    echo "<br>\n<br>\n";
     
    72236    mysql_free_result($result);
    73237
     238
     239    echo "<form name='formular' action='memberlist.php' METHOD='GET'>\n";
     240    echo "<h3>Author List:</h3>\n";
     241    echo "Format: <br>\n";
     242    if ($_GET["listformat"]=="short")
     243        echo "<input type=radio name='listformat' value='short' checked='checked'> short &nbsp;";
     244    else
     245        echo "<input type=radio name='listformat' value='short'> short &nbsp;";
     246    if ($_GET["listformat"]=="long")
     247        echo "<input type=radio name='listformat' value='long' checked='checked'> long <br>";
     248    else
     249        echo "<input type=radio name='listformat' value='long'> long <br>";
     250    if ($_GET["textformat"]=="latex")
     251        echo "<input type=radio name='textformat' value='latex' checked='checked'> latex &nbsp;";
     252    else
     253        echo "<input type=radio name='textformat' value='latex'> latex &nbsp;";
     254    if ($_GET["textformat"]=="html")
     255        echo "<input type=radio name='textformat' value='html' checked='checked'> html ";
     256    else
     257        echo "<input type=radio name='textformat' value='html'> html ";
     258    if ($_GET["textformat"]=="text")
     259        echo "<input type=radio name='textformat' value='text' checked='checked'> text <br>";
     260    else
     261        echo "<input type=radio name='textformat' value='text'> text <br>";
     262    echo "<br><input type='submit' value='Get List'>\n";
     263    echo "</form>\n";
     264
     265    $counter=0;
     266    $letter=a;
     267    $institutes = [];
     268    $instnames = [];
     269    $instaddresses = [];
     270    $alsos = [];
     271    $result  = mysql_query($querylist);
     272    while ($row = mysql_fetch_row($result))
     273    {
     274        if (!in_array($row[1],$institutes))
     275        {
     276            $counter++;
     277            $institutes[$counter]=$row[1];
     278            $instnames[$counter]=$row[3];
     279            $instaddresses[$counter]=$row[4];
     280        }
     281        if ($corresponding=="" || $textformat!="latex")
     282            echo $row[0].GetSup($textformat, array_search($row[1], $institutes));
     283        else
     284            echo " \speaker{".$row[0]."} ".GetSup($textformat, array_search($row[1], $institutes));
     285        if ($row[2])
     286        {
     287            if (!in_array($row[2], $alsos))
     288            {
     289                $alsos[$letter]=$row[2];
     290                $letter++;
     291            }
     292        }
     293        if ($row[2])
     294            echo GetSup($textformat, array_search($row[2], $alsos));
     295        echo GetEndl($textformat, ",");
     296    }
     297    mysql_free_result($result);
     298    if ($querylist2)
     299    {
     300        $result  = mysql_query($querylist2);
     301        while ($row = mysql_fetch_row($result))
     302        {
     303            if (!in_array($row[1],$institutes))
     304            {
     305                $counter++;
     306                $institutes[$counter]=$row[1];
     307                $instnames[$counter]=$row[3];
     308                $instaddresses[$counter]=$row[4];
     309            }
     310            echo " ".$row[0]." ".GetSup($textformat, array_search($row[1], $institutes));
     311            if ($row[2])
     312            {
     313                if (!in_array($row[2], $alsos))
     314                {
     315                    $alsos[$letter]=$row[2];
     316                    $letter++;
     317                }
     318            }
     319            if ($row[2])
     320                echo GetSup($textformat, array_search($row[2], $alsos));
     321            echo GetEndl($textformat, ",");
     322        }
     323        mysql_free_result($result);
     324    }
     325    for ($i = 1; $i <= $counter; $i++)
     326        echo GetSup($textformat, $i)." ".GetBla($textformat, $instnames[$i]).", ".
     327            GetBla($textformat, $instaddresses[$i]).GetEndl($textformat, "");
     328    foreach ($alsos as $num => $name)
     329        echo GetSup($textformat, $num)." also at ".GetBla($textformat, $name).GetEndl($textformat, "");
     330
     331
     332
    74333    mysql_close($db_id);
    75334
     
    77336    echo "</body>\n";
    78337    echo "</html>\n";
    79 
    80338?>
Note: See TracChangeset for help on using the changeset viewer.