first commit

This commit is contained in:
Gitea
2017-07-18 08:57:31 +02:00
commit 59ac39008d
240 changed files with 72442 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
<?php
namespace App\Paper;
use App\Paper\Interfaces\Cinema;
class CinemaMultikino implements Cinema
{
function fetchRepertorire($day, $cinemaId = null)
{
$moviePath = 'https://multikino.pl/data/filmswithshowings/' . $cinemaId;
$movieContent = file_get_contents($moviePath);
$movieJson = json_decode($movieContent, 0);
return $movieJson;
}
function parseRepertoire($day, $cinemaId = null)
{
$movieJson = $this->fetchRepertorire($day, $cinemaId);
$filmy = [];
foreach ($movieJson->films as $movie) {
$film = [];
$film['id'] = $movie->id;
$film['title'] = $movie->title;
$film['times'] = [];
$film['date'] = $day;
$film['runningtime'] = $movie->info_runningtime;
$film['genres'] = [];
$film['synopsis_short'] = str_replace(["\r\n", " "], [" "], $movie->synopsis_short);
if ($movie->original_s_count > 0 && $movie->show_showings) {
foreach ($movie->showings as $shoving) {
if ($shoving->date_time == $day) {
foreach ($shoving->times as $time) {
$film['times'][] = $time->time . " " . $time->screen_type;
}
}
}
}
foreach ($movie->genres->names as $genre) {
$film['genres'][] = $genre->name;
}
if (count($film['times'])) {
$filmy[] = $film;
}
}
return $filmy;
}
function convertToPrint($day, $cinemaId = null)
{
$filmy = $this->parseRepertoire($day, $cinemaId);
$text = '';
$text .= "Repertuar Multikino Gdańsk\n";
$text .= $day . "\n\n";
foreach ($filmy as $movie) {
$text .= $movie['title']. "\n";
$text .= '('.$movie['runningtime']. ")\n";
$text .= implode(', ', $movie['genres']) . "\n\n";
$text .= $movie['synopsis_short'] . "\n\n";
$text .= implode(', ', $movie['times']) . "\n";
$text .= "--------------------------------\n\n";
}
return $text;
}
}

28
app/Paper/HtmlToPos.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
namespace App\Paper;
class HtmlToPos
{
private function handleNewLine($text)
{
return str_replace(['<br>', '<br/>', '<br />'], "\n", $text);
}
public function convert($html)
{
$posText = $this->handleNewLine($html);
// print_r($posText);
// die();
return $posText;
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Paper\Interfaces;
/**
* Created by PhpStorm.
* User: k
* Date: 28.05.2017
* Time: 20:14
*/
interface Cinema
{
function fetchRepertorire($day, $cinemaId = null);
function parseRepertoire($day, $cinemaId = null);
function convertToPrint($day, $cinemaId = null);
}