ACC SHELL
<?php
/**
* Třída pro seznam českých svátků
*
* @author Filip Štencl
* @since 26.11.2013
*/
class svatky extends base {
const TABLE_NAME = 'svatky';
private $id = null;
private $den = null;
private $mesic = null;
private $jmeno = null;
private $zobrazit = null;
private $chyba = null;
public function __construct($id = null) {
if(!is_null($id) && intval($id) != 0) { // Pokud již položka existuje, zpřístupni její vlastnosti
$result = dibi::query('SELECT * FROM ['.self::TABLE_NAME.'] WHERE id=%i',intval($id));
if($result->count() > 0) {
$row = $result->fetch();
$this->id = $row->id;
$this->den = $row->den;
$this->mesic = $row->mesic;
$this->jmeno = $row->jmeno;
$this->zobrazit = $row->zobrazit;
} else {
notification::infoBox_error("Požadovaná položka nebyla nalezena");
redirect("./index.php");
}
}
}
public function getId() { return $this->id; }
public function getDen() { return $this->den; }
public function getMesic() { return $this->mesic; }
public function getJmeno() { return $this->jmeno; }
public function getZobrazit() { return $this->zobrazit; }
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($den = 0, $mesic = 0) {
$pom = "";
//
// $memcache = new Memcache;
// $memcache->addserver('127.0.0.1');
// $memcache->connect('127.0.0.1');
$result = null;
if(!$result) {
$result = dibi::query("SELECT jmeno, zobrazit FROM [svatky] WHERE den = %i AND mesic = %i AND zobrazit = 1",$den,$mesic)->fetch();
// $memcache->set("dnesni_svatek",$result,MEMCACHE_COMPRESSED,300);
}
if (!empty($result) && $result->zobrazit == 1 || !empty($result->jmeno)) {
$pom = "<div id=\"svatek\">svátek má <strong>".$result->jmeno."</strong></div>";
}
return $pom;
}
}
ACC SHELL 2018