Skip to content
Snippets Groups Projects
Commit 2e81f3b3 authored by Tilman Vatteroth's avatar Tilman Vatteroth :robot:
Browse files

Merge branch 'dev' of bitbucket.org:FsInformatikDortmund/infoscreen into dev

parents eeefa6ef a90f50d4
Branches
No related tags found
No related merge requests found
{
"type":"xsplit",
"cut":35,
"left":
{
"type":"panel",
"name":"topListe"
},
"right":
{
"type" : "ysplit",
"cut" : 30,
"up" :
{
"type":"panel","name":"clock"
},
"down":
{
"type":"panel","name":"mensaPlan"
}
}
}
<?php
class GERICHT {
private $shortText = "";
private $originalText = "";
private $rind = false;
private $schwein = false;
private $gefluegel = false;
private $fisch = false;
private $vegetarisch = false;
private $vegan = false;
private $kinderteller = false;
private $image = "";
private $zusatzStoffe = array (
0 => false,
1 => false,
2 => false,
3 => false,
4 => false,
5 => false,
6 => false,
7 => false,
8 => false,
9 => false,
10 => false,
11 => false,
12 => false,
13 => false,
14 => false,
15 => false,
16 => false,
17 => false,
18 => false,
19 => false,
20 => false,
21 => false,
22 => false,
23 => false,
24 => false,
25 => false,
26 => false,
27 => false,
28 => false,
29 => false,
30 => false,
31 => false,
32 => false,
33 => false
);
private $date = "";
public function getShortText() {
return $this->shortText;
}
public function getOriginalText() {
return $this->originalText;
}
public function isRind() {
return $this->rind;
}
public function isSchwein() {
return $this->schwein;
}
public function isGefluegel() {
return $this->gefluegel;
}
public function isFisch() {
return $this->fisch;
}
public function isVegetarisch() {
return $this->vegetarisch;
}
public function isVegan() {
return $this->vegan;
}
public function isKinderteller() {
return $this->kinderteller;
}
public function getArtAsString($seperator = " ") {
$art = "";
$first = true;
if ($this->rind) {
$art .= "R";
$first = false;
}
if ($this->schwein) {
if (! $first) {
$art .= $seperator;
}
$art .= "S";
$first = false;
}
if ($this->gefluegel) {
if (! $first) {
$art .= $seperator;
}
$art .= "G";
$first = false;
}
if ($this->fisch) {
if (! $first) {
$art .= $seperator;
}
$art .= "F";
$first = false;
}
if ($this->vegetarisch) {
if (! $first) {
$art .= $seperator;
}
$art .= "V";
$first = false;
}
if ($this->vegan) {
if (! $first) {
$art .= $seperator;
}
$art .= "N";
$first = false;
}
if ($this->kinderteller) {
if (! $first) {
$art .= $seperator;
}
$art .= "K";
$first = false;
}
return $art;
}
public function getImage() {
return $this->image;
}
public function isZusatzstoff($id) {
return $this->zusatzStoffe [$id];
}
public function getZusatzstoffe() {
return $this->zusatzStoffe;
}
public function getZusatzstoffeAsString($seperator = " ") {
$stoffe = "";
$first = true;
for($i = 0; $i < count ( $this->zusatzStoffe ); $i ++) {
if ($this->zusatzStoffe [$i]) {
if (! $first) {
$stoffe .= $seperator . $i;
} else {
$stoffe .= $i;
$first = false;
}
}
}
return $stoffe;
}
public function getDate(){
return $this->date;
}
public function setShortText($shortText) {
$this->shortText = $shortText;
}
public function setOriginalText($originalText) {
$this->originalText = $originalText;
}
public function setRind($rind) {
$this->rind = $rind;
}
public function setSchwein($schwein) {
$this->schwein = $schwein;
}
public function setGefluegel($gefluegel) {
$this->gefluegel = $gefluegel;
}
public function setFisch($fisch) {
$this->fisch = $fisch;
}
public function setVegetarisch($vegetarisch) {
$this->vegetarisch = $vegetarisch;
}
public function setVegan($vegan) {
$this->vegan = $vegan;
}
public function setKinderteller($kinderteller) {
$this->kinderteller = $kinderteller;
}
public function setArt($in, $val) {
switch ($in) {
case "R" :
$this->rind = $val;
break;
case "S" :
$this->schwein = $val;
break;
case "G" :
$this->gefluegel = $val;
break;
case "F" :
$this->fisch = $val;
break;
case "V" :
$this->vegetarisch = $val;
break;
case "N" :
$this->vegan = $val;
break;
case "K" :
$this->kinderteller = $val;
break;
default :
echo "Angegebene Art '" . $in . "' nicht bekannt.";
}
}
public function setImage($image) {
$this->image = $image;
}
public function setZusatzstoff($in, $val) {
$this->zusatzStoffe [$in] = $val;
}
public function setZusatzstoffe($zusatzStoffe) {
$this->zusatzStoffe = $zusatzStoffe;
}
public function setDate($date){
$this->date = $date;
}
public function toggleRind() {
$this->rind = ! $this->rind;
}
public function toggleSchwein() {
$this->schwein = ! $this->schwein;
}
public function toggleGefluegel() {
$this->gefluegel = ! $this->gefluegel;
}
public function toggleFisch() {
$this->fisch = ! $this->fisch;
}
public function toggleVegetarisch() {
$this->vegetarisch = ! $this->vegetarisch;
}
public function toggleVegan() {
$this->vegan = ! $this->vegan;
}
public function toggleKinderteller() {
$this->kinderteller = ! $this->kinderteller;
}
public function toggleArt($in) {
switch ($in) {
case "R" :
$this->rind = ! $this->rind;
break;
case "S" :
$this->schwein = ! $this->schwein;
break;
case "G" :
$this->gefluegel = ! $this->gefluegel;
break;
case "F" :
$this->fisch = ! $this->fisch;
break;
case "V" :
$this->vegetarisch = ! $this->vegetarisch;
break;
case "N" :
$this->vegan = ! $this->vegan;
break;
case "K" :
$this->kinderteller = ! $this->kinderteller;
break;
default :
echo "Angegebene Art '" . $in . "' nicht bekannt.";
}
}
public function toggleZusatzstoff($in) {
$this->zusatzStoffe [$in] = ! $this->zusatzStoffe [$in];
}
public function __toString() {
for($i = 0; $i < count ( $this->zusatzStoffe ); $i ++) {
if ($this->zusatzStoffe [$i]) {
$stoffe = $stoffe . " " . $i;
}
}
return "Short Text: " . $this->shortText . ",\n" . "Original Text: " . $this->originalText . ",\n" . "Rind: " . booleanToString ( $this->rind ) . ",\n" . "Schwein: " . booleanToString ( $this->schwein ) . ",\n" . "Fisch: " . booleanToString ( $this->fisch ) . ",\n" . "Vegetarisch: " . booleanToString ( $this->vegetarisch ) . ",\n" . "Vegan: " . booleanToString ( $this->vegan ) . ",\n" . "Kinderteller: " . booleanToString ( $this->kinderteller ) . ",\n" . "Image: " . $this->image . ",\n" . "Zusatzstoffe: " . $stoffe . ",\n";
}
}
?>
\ No newline at end of file
<?php
$mysqli = new mysqli("ovanier.de", "info_reader", "7ELZqMyUwU8MaJba", "infoscreen");
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
if ($result = $mysqli->query("SELECT * FROM City")) {
$result->close();
}
$mysqli->close();
?>
\ No newline at end of file
<?php
function booleanToString($bool) {
if ($bool) {
return "True";
} else {
return "False";
}
}
?>
\ No newline at end of file
<?php
include 'simple_html_dom.php';
include 'helper.php';
include 'gericht.php';
$html = file_get_html ( 'http://www.stwdo.de/gastronomie/speiseplaene/hauptmensa/wochenansicht-hauptmensa/' );
function parsDay($html, $day, $gerichte) {
$date = substr ( $html->find ( 'a[href="#' . $day . '"]', 0 )->innertext, - 10, 10 );
$html = $html->find ( 'a.#' . $day, 0 );
$html = $html->first_child ()->children ( 1 );
$tr = $html->first_child ();
while ( $tr != null ) {
$current = new GERICHT ();
$td0 = $tr->find ( 'td', 0 );
$td1 = $tr->find ( 'td', 1 );
$td2 = $tr->find ( 'td', 2 );
// parse originalText shortText and Zusatzstoffe
if ($td0 != null) {
$current->setOriginalText ( $td0->innertext );
// prepare Zusatzstoffe
$zusatzstoffe = $td0->innertext;
preg_match_all ( '#\([\d+,]+\)#', $zusatzstoffe, $matches );
foreach ( $matches [0] as $match ) {
preg_match_all ( '#[\d+]+#', $match, $stoffe );
foreach ( $stoffe [0] as $stoff ) {
$current->setZusatzstoff ( $stoff, true );
}
}
// shorten Text
$shortText = $td0->innertext;
$shortText = preg_replace ( '#\([\d+,]+\)#', '', $shortText ); // remove zusatzstoffe
$shortText = preg_replace ( '#(\s,|,\s)#', ',', $shortText ); // fix Komma
$shortText = preg_replace ( '#,#', ', ', $shortText ); // fix Komma
$shortText = preg_replace ( '#\s+#', ' ', $shortText ); // fix double Whitespace
$shortText = preg_replace ( '#,\sdazu\s\d\sBeilagen\snach\sWahl#', '', $shortText ); // remove Beilagen
$shortText = preg_replace ( '#,\sdazu\s#', ' + ', $shortText ); // replace dazu
$shortText = preg_replace ( '#\sund\s#', ' & ', $shortText ); // replace und
$current->setShortText ( $shortText );
}
// parse Art
if ($td1 != null) {
$art = $td1->innertext;
$current->setRind ( substr_count ( $art, "R" ) );
$current->setSchwein ( substr_count ( $art, "S" ) );
$current->setGefluegel ( substr_count ( $art, "G" ) );
$current->setFisch ( substr_count ( $art, "F" ) );
$current->setVegetarisch ( substr_count ( $art, "V" ) );
$current->setVegan ( substr_count ( $art, "N" ) );
$current->setKinderteller ( substr_count ( $art, "K" ) );
}
// parse Image
if ($td2 != null) {
$img = $td2->find ( 'img', 0 );
if ($img != null) {
$current->setImage ( $img->src );
}
}
if ($current->getOriginalText () != "") { // remove empty Fields
$current->setDate( $date );
array_push ( $gerichte, $current );
}
$tr = $tr->next_sibling ();
}
return $gerichte;
}
$gerichte = array ();
$gerichte = parsDay ( $html, "montag", $gerichte );
$gerichte = parsDay ( $html, "dienstag", $gerichte );
$gerichte = parsDay ( $html, "mittwoch", $gerichte );
$gerichte = parsDay ( $html, "donnerstag", $gerichte );
$gerichte = parsDay ( $html, "freitag", $gerichte );
$mysqli = new mysqli ( "ovanier.de", "info_writer", "XAHQTZeGbqsnt8K6", "infoscreen" );
if ($mysqli->connect_errno) {
printf ( "Connect failed: %s\n", $mysqli->connect_error );
exit ();
}
$stmt = mysqli_prepare($mysqli, "INSERT INTO gerichte (originalText,shortText,rind,schwein,gefluegel,fisch,vegetarisch,vegan,kinderteller,image,date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
foreach ( $gerichte as $gericht ) {
printf ( mysqli_stmt_bind_param($stmt, "ssiiiiiiisi"
, $gericht->getOriginalText()
, $gericht->getShortText()
, $gericht->isRind()
, $gericht->isSchwein()
, $gericht->isGefluegel()
, $gericht->isFisch()
, $gericht->isVegetarisch()
, $gericht->isVegan()
, $gericht->isKinderteller()
, $gericht->getImage()
, $gericht->getDate()
));
$stmt->execute();
}
$stmt->close();
$mysqli->close ();
?>
\ No newline at end of file
This diff is collapsed.
this.loaded = function(panel, config) {
var $li = $("<li class='ui-state-default'/>").text("BLA");
$("#sortable").append($li);
$("#sortable").sortable('refresh');
}
<ul id="sortable">
<li class="ui-state-default">Item 1</li>
</ul>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment