ACC SHELL
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Your_Home extends Home {
public function __construct(){
parent::__construct();
Image::$placeholder_img_src = "/views/" . $this->data['settings']['name'] . "/www/img/placeholder.png";
}
public function site ($idr) {
// search redirect
if(!empty($_POST['q'])){
$q = str_replace(array("'",'"',"\\","\/"),"",$_POST['q']);
$this->uri->redirect($this->uri->sef_tag("search")."?q=".$q);
}
$this->default_view = false;
parent::site($idr);
$n = $this->data['settings']['name']."/";
// HOMEPAGE (index) || produkty
if($this->sites->has_tag("hp") || $this->sites->has_tag("produkty")){
$this->data['hlavni'] = $this->sites->new_one()->tag("kategorie")->set_limit(4)->childrens(1);
$this->data['hp'] = true; // upravuje layout
$this->data['view_render'] = $n."templates/hp";
}
// sekce kategorií
elseif($this->sites->has_tag("kategorie",1,1)){
$this->data['items'] = $this->sites->new_one()->childrens(1);
$vyrobky_view = true;
foreach($this->data['items'] as $s){
if($s->children_count()){
$vyrobky_view = false;
break;
}
}
if(empty($this->data['items'])){
$this->data['items'][0] = $this->sites;
}
// kategorie výpis
if(!$vyrobky_view){
$this->data['view_render'] = $n."templates/kategorie";
}
// vyrobky
else{
$this->contact_form();
if(!empty($_POST['firm'])){
$_SESSION['post'] = $_POST; // přenesení postu do kontaktů
$this->uri->redirect($this->uri->sef_tag("kontakty")); // redirect při erroru
}
// set realizace link
if($this->sites->has_tag("k1",1)) $this->data['realizace_link'] = $this->uri->sef_tag("r1");
elseif($this->sites->has_tag("k2",1)) $this->data['realizace_link'] = $this->uri->sef_tag("r2");
elseif($this->sites->has_tag("k3",1)) $this->data['realizace_link'] = $this->uri->sef_tag("r3");
elseif($this->sites->has_tag("k4",1)) $this->data['realizace_link'] = $this->uri->sef_tag("r4");
else $this->data['realizace_link'] = $this->uri->sef_tag("realizace"); // default
$this->data['realizace_link'] = $this->uri->sef_tag("realizace") . "#" . substr($this->data['realizace_link'],1);
$this->data['view_render'] = $n."templates/vyrobky";
}
}
// kontakty
elseif($this->sites->has_tag("kontakty")){
if(!empty($_SESSION['post'])){
$_POST = $_SESSION['post'];
unset($_SESSION['post']);
}
$this->contact_form();
$this->data['view_render'] = $n."templates/kontakty";
}
// seznam aktualit
elseif($this->sites->has_tag("aktuality")){
$this->data['items'] = $this->sites->pagination(15)->childrens(1);
$this->data['pagination'] = $this->sites->get_pagination();
$this->data['view_render'] = $n."templates/aktuality";
}
// seznam článků
elseif($this->sites->has_tag("clanky")){
$this->data['items'] = $this->sites->pagination(15)->childrens(1);
$this->data['pagination'] = $this->sites->get_pagination();
$this->data['view_render'] = $n."templates/clanky";
}
// realizace
elseif($this->sites->has_tag("realizace",1)){
$r=15;
$this->data['categories'] = $this->sites->new_one()->tag('realizace')->childrens(1);
$this->data['title_suffix']=false;
$this->data['title_prefix']=false;
/*
// vypis hlavni strany realizaci
if($this->sites->has_tag("realizace")){
$this->data['items'] = $this->sites->tag('realizace')->pagination($r)->set_offset(2)->set_range(1)->tree(1);
$this->data['title_suffix']=' - vše';
}
// vypsani konkretni strany realizaci
else{
$this->data['items'] = $this->sites->pagination($r)->childrens(1);
$this->data['title_prefix']='Realizace - ';
}
$this->data['pagination'] = $this->sites->get_pagination();*/
// sablona
$this->data['view_render'] = $n."templates/realizace";
}
// search
elseif($this->sites->has_tag("search")){
$_GET['q'] = htmlspecialchars($_GET['q']);
$this->data['sites'] = $this->sites->search($_GET['q']);
$this->data['view_render'] = $n."templates/search";
}
// pod čarou
elseif($this->sites->has_tag("pod_carou",1)){
$this->data['sites'] = $this->sites->new_one()->tag("pod_carou")->childrens();
$this->data['view_render'] = $n."templates/pod-carou";
}
// konkretni aktualita, clanek, ...
else{
$this->data['view_render'] = $n."templates/clanek";
}
$this->load->view($n."layout",$this->data);
}
private function contact_form(){
$f = new Form("contact",array("captcha"=>false));
if($f->ready()){
$d = $f->get_data();
$m = "";
$m.='<strong>jméno: </strong>'.$d['name'].'<br>';
$m.='<strong>email: </strong>'.$d['email'].'<br>';
$m.='<strong>telefon: </strong>'.(trim($d['phone']) ? trim($d['phone']) : '—').'<br>';
$m.='<strong>firma: </strong>'.(trim($d['firm']) ? trim($d['firm']) : '—').'<br>';
$m.='<strong>téma: </strong>'.(trim($d['theme']) ? trim($d['theme']) : '—').'<br>';
$m.='<br><strong>zpráva: </strong><br>'.$d['message'];
$this->load->library('email');
$this->email->from($d['email'], $d['name']);
$this->email->to('agroing@agroing.cz');
$this->email->subject('Odesláno z '.$_SERVER['SERVER_NAME']);
$this->email->message($m);
if(!$this->email->send()){
Tools::critical('Nepodařilo se odeslat ze serveru. ' . $this->email->print_debugger());
}else{
Tools::succ("Zpráva byla úspěšně odeslána");
}
$this->uri->redirect($this->sites->url());
}
$this->data['f'] = $f;
}
public function sitemap_xml(){
header ("Content-Type:text/xml");
// header("Content-type: text/plain");
echo '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
$this->sites->idr = Settings_model::$root_relation['id'];
foreach($this->sites->set_zero_sitemap(false)->tree() as $s){
if(count($s->childrens()) || $s->has_tag("clanky",1) ||
$s->has_tag("o_nas") || $s->has_tag("hp") || $s->has_tag("kontakty")){
echo "<url><loc>http://".$_SERVER['SERVER_NAME'].$this->uri->sef_site($s->idr)."</loc></url>\n";
}
}
echo '</urlset>';
}
}
ACC SHELL 2018