ACC SHELL
<?php
/**
* @author Filip Štencl
* @since 30. 01. 2017
*/
class aktuality extends base {
const TABLE_NAME = 'aktuality';
private $id = null;
private $caszalozeni = null;
private $caszmeny = null;
private $nazev = null;
private $datum = null;
private $anotace = null;
private $detail = null;
private $zobrazit = null;
private $mr_url = null;
private $soubor = null;
private $chyba = null;
public function __construct($id = null) {
if (!is_null($id) && intval($id) != 0) { // Pokud již položka existuje, zpřístupní její vlastnosti
$sql = '
SELECT
A.*
FROM ['.self::TABLE_NAME.'] A
WHERE A.id=%i
';
$result = dibi::query($sql,intval($id));
if($result->count() > 0) {
$row = $result->fetch();
$this->id = $row->id;
$this->caszalozeni = $row->caszalozeni;
$this->caszmeny = $row->caszmeny;
$this->nazev = $row->nazev;
$this->datum = $row->datum;
$this->anotace = $row->anotace;
$this->detail = $row->detail;
$this->mr_url = $row->mr_url;
$this->zobrazit = $row->zobrazit;
} else { set404(); }
}
}
public function getId() { return $this->id; }
public function getCaszalozeni() { return $this->caszalozeni; }
public function getCaszmeny() { return $this->caszmeny; }
public function getNazev() { return $this->nazev; }
public function getDatum() { return $this->datum; }
public function getAnotace() { return $this->anotace; }
public function getDetail() { return $this->detail; }
public function getMr_url() { return $this->mr_url; }
public function getZobrazit() { return $this->zobrazit; }
public function getSoubor() { return $this->soubor; }
public function setId($id) { $this->id = $id; }
protected function getChyba() { return $this->chyba; }
protected function checkData($data) {
if(array_key_exists("id",$data)) {if(intval($data['id']) > 0) { $this->id = intval($data['id']); } else { $this->chyba .= "ID je v nesprávném formátu<br />"; return false; }}
return true;
}
public static function vypis() {
$dnes = new DateTime('');
$dnes->format('Y-m-d');
$result = dibi::query("SELECT caszalozeni, nazev, datum, anotace, mr_url FROM [aktuality] WHERE DATE_FORMAT(caszalozeni, '%Y-%m-%d') <= %d AND DATE_FORMAT(caszalozeni, '%Y-%m-%d') >= %d AND zobrazit = 1 ORDER BY id DESC",$dnes,date("Y-m-d", strtotime("-30 day")))->fetchAll();
$pom = '';
foreach ($result as $row) {
$pom .= '
<li>
<h2><a href="/rychlovky/'.$row->mr_url.'">'.$row->nazev.'</a> <span>'.cesky_den(datum($row->caszalozeni,'N')).' '.datum($row->caszalozeni,'j. n. Y').'</span></h2>
'.str_replace('</p>','',$row->anotace).' <a href="/rychlovky/'.$row->mr_url.'">»</a></p>
</li>
';
}
return $pom;
}
public static function vypisHp() {
$dnes = new DateTime('');
$dnes->format('Y-m-d');
$result = dibi::query("SELECT caszalozeni, nazev, datum, anotace, mr_url FROM [aktuality] WHERE DATE_FORMAT(caszalozeni, '%Y-%m-%d') <= %d AND zobrazit = 1 ORDER BY id DESC LIMIT 0,4",$dnes)->fetchAll();
$pom = '';
foreach ($result as $row) {
$pom .= '
<li>
<a href="/rychlovky/'.$row->mr_url.'"><strong>'.$row->nazev.'</strong></a><br><span>'.cesky_den(datum($row->caszalozeni,'N')).' '.datum($row->caszalozeni,'j. n. Y').'</span><br>
'.str_replace('</p>','',$row->anotace).' <a href="/rychlovky/'.$row->mr_url.'">»</a></p>
</li>
';
}
return $pom;
}
}
ACC SHELL 2018