Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen gezeigt.

Link zu dieser Vergleichsansicht

buecherliste [2012/06/02 10:05] (aktuell)
Zeile 1: Zeile 1:
 +====== Bücherliste ======
 +
 +~~NOCACHE~~
 +
 +<php>
 +
 +$SCHOOLSPAN = '<​span style="​margin:​5px;​padding:​2px;​color:​darkblue;​border:​ 2px solid darkblue;">';​
 +
 +  $filter = $_GET['​filter'​];​
 +  if (!isset($filter)) $filter = '​Alle';​
 +
 +  echo '<​form action="​http://​www.lichterkette2009.at/​buch/​doku.php"​ METHOD="​GET">'​.PHP_EOL;​
 +  echo '<​p><​input type="​hidden"​ name="​id"​ value="​buecherliste">';​
 +  ​
 +  $filtervals = array('​HLW',​ '​WIKU',​ '​Ortwein',​ '​Alle'​);​
 +  foreach ($filtervals as $val) {
 +    if (strcmp($val,​ $filter) == 0) {
 +      $checked = '​checked';​
 +    } else {
 +      $checked = '';​
 +    }
 +    echo '<​input type="​radio"​ '​.$checked.'​ name="​filter"​ value="'​.$val.'">​ '​.$SCHOOLSPAN.$val.'</​span>&​nbsp;&​nbsp;'​.PHP_EOL;​
 +  }
 +  echo '<​input type="​submit"​ value="​Filtern"​ style="​padding:​5px;">'​.PHP_EOL;​
 +  echo '</​p></​form><​p>&​nbsp;</​p><​p>&​nbsp;</​p>'​.PHP_EOL;​
 +    ​
 +
 +if ($filter == '​Alle'​) $filter = '';​
 +
 +$VORNAME = 2;
 +$NACHNAME = 3;
 +$BUCHTITEL = 9;
 +$IMGURL = 13;
 +$TITELNOTE = 16;
 +$BUEDO2010 = 17;
 +$BUEDO2011 = 18;
 +$DATUMSSEKTION = 20;
 +
 +$arrResult = array();
 +$row = 1;
 +$file = fopen("/​srv/​Kontaktliste2011.csv",​ "​r"​);​
 +if ($file) {
 +  while (($data = fgetcsv($file,​ 20000, ","​)) !== FALSE) {
 +    $num = count($data);​
 +    //echo "​Zeile"​.$row.":";​
 +    $row++;
 +    //if ($num > 0) echo $data[0];
 +    for ($c=1; $c < $num; $c++) {
 +      //echo ", "​.$data[$c];​
 +    }
 +    //echo "</​BR>​\n";​
 +    $arrResult[] = $data;
 +  }
 +  fclose($file);​
 +} else {
 +  echo "​Internal Error: Unable to open Data file!";​
 +}
 +
 +// parse schools and dates
 +$num = count($arrResult[0]);​
 +
 +$col = $DATUMSSEKTION;​
 +if (strcmp($arrResult[0][$col],​ '​HLW'​) != 0) {
 +  echo "​Internal Error: Expected HLW but found "​.$arrResult[0][$col];​
 +}
 +$schools = array();
 +while ($col < $num) {
 +  $schoolhtml = '';​
 +  $school = array();
 +  $school['​name'​] = $arrResult[0][$col];​
 +  $schoolhtml .= $SCHOOLSPAN.$school['​name'​].'</​span><​span style="​color:​ darkblue; font-size: 200%;">&​rarr;</​span>​ ';
 +  $oldcol = $col;
 +  $date = array();
 +  do {
 +    $date[] = $arrResult[1][$col];​
 +    $schoolhtml .= ' '​.$arrResult[1][$col].'​ ';
 +    $col++;
 +  } while ($col < $num && $arrResult[0][$col] == ''​);​
 +  $schoolhtml .='<​BR/>';​
 +  $school['​date'​] = $date;
 +  $school['​html'​] = $schoolhtml.PHP_EOL;​
 +  //echo $schoolhtml."</​table><​BR/>​\n";​
 +  $schools[] = $school;
 +}
 +
 +echo '<p style="​color:​red;">';​
 +//​var_dump($schools);​
 +echo "</​p>";​
 +
 +// parse book's names and dates they are on
 +
 +$books = array();
 +$row = 5;
 +while ($row < count($arrResult)) {
 +  $html = '';​
 +  $html2 = '';​
 +
 +  if ($arrResult[$row][$BUCHTITEL] != ''​) {
 +    $book = array();
 +    $relevant = false;
 +    $book['​name'​] = $arrResult[$row][$VORNAME].'​ '​.$arrResult[$row][$NACHNAME];​
 +    $book['​titel'​] = $arrResult[$row][$BUCHTITEL];​
 +    $book['​imgurl'​] = $arrResult[$row][$IMGURL];​
 +    //DBG $html = '<​!-- '​.$book['​imgurl'​].'​ -->';​
 +    if ($book['​imgurl'​] == ''​) {
 +      $book['​imgurl'​] = '​nopic.png';​
 +    }
 +    $book['​2010'​] = $arrResult[$row][$BUEDO2010];​
 +    $book['​2011'​] = $arrResult[$row][$BUEDO2011];​
 +    $book['​note'​] = $arrResult[$row][$TITELNOTE];​
 +    //DBG echo $book['​name'​]."​ : "​.$arrResult[$row][$BUEDO2011]."#";​
 +    $date = array();
 +    for ($col = $DATUMSSEKTION;​ $col < $num; $col++) {
 +      if (strcmp($arrResult[$row][$col],​ '​1'​) == 0) {
 +        $date[] = $arrResult[1][$col];​
 +      }
 +    }
 +    $html = '<​div style="​clear:​left;​color:​blue;​padding-bottom:​20px;​vertical-align:​top;">';​
 +    $html = $html.'<​A href="​http://​www.lichterkette2009.at/​buch/​doku.php?​id=buch'​.$row.'">';​
 +    $html = $html.'<​IMG SRC="/​img/​buedo/'​.$book['​imgurl'​].'"​ style="​float:​ left;​border:​ 0px;​width:​100px;​margin-right:​30px;​padding-bottom:​10px;​vertical-align:​bottom;"></​A>';​
 +    $html = $html.'<​table border="​0"><​tr><​td style="​vertical-align:​top;​width:​300px;">';​
 +    $html = $html.'<​A href="​http://​www.lichterkette2009.at/​buch/​doku.php?​id=buch'​.$row.'">';​
 +    $html = $html.'<​B style="​padding-right:​20px;">'​.$book['​titel'​].'</​B></​A><​BR/><​SMALL STYLE="​color:​gray;">​('​.$book['​name'​].'​)</​SMALL><​BR/>&​nbsp;<​BR/>';​
 +    if (!empty($book['​note'​])) {
 +      $html = $html.'<​SMALL STYLE="​color:​darkred;">​*) '​.$book['​note'​].'</​SMALL><​BR/>';​
 +    }    ​
 +    $html = $html.'&​nbsp;<​BR/>';​
 +
 +    $book['​dates'​] = $date;
 +    if (!empty($date)) {
 +      $visits = array();
 +      $dates = array();
 +      for ($dateidx = 0; $dateidx < count($date);​ $dateidx++) {
 +        for ($schoolidx = 0; $schoolidx < count($schools);​ $schoolidx++) {
 +          if (in_array($date[$dateidx],​ $schools[$schoolidx]['​date'​])) {
 +            if (!in_array($schools[$schoolidx]['​name'​],​ $visits)) {
 +              $visits[] = $schools[$schoolidx]['​name'​];​
 +              $relevant = true;
 +              $schoolidx = count($schools);​
 +            }
 +          }
 +        }
 +      }
 +      if (count($visits) > 0) {
 +        $book['​visits'​] = $visits;
 +      }
 +    }
 +    if (strcmp($book['​2011'​],'​1'​) == 0) {
 +      $relevant = true;
 +      $html = $html.'<​span style="​margin:​ 5px;​padding:​ 5px;​color:​white;​background:​ darkgreen;​width:​ 200px;">​B&​uuml;​DO2011</​span>';​
 +    }
 +    if (strcmp($book['​2010'​],'​1'​) == 0) {
 +      $relevant = true;
 +      $html = $html.'<​span style="​margin:​ 5px;​padding:​ 5px;​color:​white;​background:​ orange;​width:​ 200px;">​B&​uuml;​DO2010</​span>';​
 +    }
 +    $html = $html.'</​td><​td style="​vertical-align:​top;">';​
 +    foreach ($schools as $school) {
 +      if ($filter == ''​ || strcmp($filter,​ $school['​name'​]) == 0) {
 +      if (!empty($book['​visits'​]) && in_array($school['​name'​],​ $book['​visits'​])) {
 +        $schoolhtml = $school['​html'​];​
 +        for ($dateidx = 0; $dateidx < count($school['​date'​]);​ $dateidx++) {
 +          $color = '​darkgreen';​
 +          $txtcolor = '​white';​
 +          if (in_array($school['​date'​][$dateidx],​ $date)) {
 +            $schoolhtml = str_replace($school['​date'​][$dateidx],​ '<​span style="​line-height:​120%;​padding:​ 2px;​color:'​.$txtcolor.';​background:​ '​.$color.';">'​.$school['​date'​][$dateidx].'</​span>',​ $schoolhtml);​
 +          } else {
 +            $color = '#​e0e0e0';​
 +            $txtcolor = '​white';​
 +            $schoolhtml = str_replace($school['​date'​][$dateidx],​ '<​span style="​line-height:​120%;​padding:​ 2px;​color:'​.$txtcolor.';​background:​ '​.$color.';">​('​.$school['​date'​][$dateidx].'​)</​span>',​ $schoolhtml);​
 +          }
 +        }
 +        $html .= $schoolhtml;​
 +      }
 +      }
 +    }
 +    $html = $html.'</​td></​tr></​table>';​
 +    $html = $html."</​div>";​
 +
 +    if ($filter == ''​ || (!empty($book['​visits'​]) && in_array($filter,​ $book['​visits'​]))) {
 +      if ($relevant) echo $html;
 +    }
 +    $books[] = $book;
 +  }
 +  $row++;
 +}
 +
 +</​php>​
 +
  
/srv/lichterkette/buch/data/pages/buecherliste.txt · Zuletzt geändert 2012/06/02 10:05 von Thomas Eitzenberger
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki