Skip to content

Instantly share code, notes, and snippets.

@valous
Created March 22, 2013 19:37
Show Gist options
  • Save valous/5224113 to your computer and use it in GitHub Desktop.
Save valous/5224113 to your computer and use it in GitHub Desktop.
Vše
<?php
/**
* @author Valenta David <david.valenta96@gmail.com>
* @version 1.0.0
* Web školních novin
*/
/**
* function Autoload
* @version 1.0.0
*/
function AutoLoad($class) {
$file = "./class/" . $class . ".php";
if(isset($class)) {
if(file_exists($file)) {
require_once $file;
}
}
}
/**
* Volání funkce AutoLoad
*/
spl_autoload_register("AutoLoad");
require_once './view/index.php';
?>
<div id='kontejner'>
<div id='pruh'>
</div>
<a href='/index.php'>
<div id='logo'>
</div>
</a>
<div id='pruh'>
</div>
<div id='navhore'>
<?php
$kontrola->instance("Menu");
$kontrola->metoda("nactiPolozky","kategoriehore","1");
$kontrola->metoda("posliPolozky","","");
$kontrola->view("menuHorni");
?>
</div>
<div id='rubrika'>
<h1>RUBRIKA</h1>
</div>
<div id='blok'>
<?php
?>
</div>
<div id='bok'>
<div id='bokneco'>
<h1>Pod-kategorie</h1>
</div>
<div id='boknecodole'>
<br />
<?php
$kontrola->instance("Menu");
$kontrola->metoda("nactiPolozky","kategorie","kde='" . $_GET['kategorie'] . "'");
$kontrola->metoda("posliPolozky","","");
$kontrola->view("menuBocni");
?>
</div>
<div id='bokneco'>
<h1>Přihlášení</h1>
</div>
<div id='boknecodole'>
<?php
$login = new Log;
$login->form("login");
?>
</div>
</div>
</div>
<div id='pata'>
<hr />
<p><small> © Valenta David | 2013-2103 | Projekt: web školních novin</small></p>
</div>
<?php
/**
* Třída Kontroleru!!!
* @version 1.0.0
*/
class Kontroler {
private $class;
private $metoda;
public function instance($class) {
$this->class = new $class();
}
public function metoda($metoda,$param1,$param2) {
$this->metoda = $this->class->$metoda($param1,$param2);
}
public function view($sablona) {
require_once './view/sablony/' . $sablona . '.php';
}
}
?>
<?php
/**
* Třída pro Menu
* @version 1.0.0
*/
class menu {
private $info;
private $volani;
private $data;
private $polozka = array();
/**
* Funkce pro Načtení položek
*/
public function nactiPolozky($kde,$upresni) {
$this->volani = new Mysql();
$this->info = $this->volani->select($kde, $upresni);
while($this->data = mysql_fetch_array($this->info)) {
$this->polozka[$this->data['nazev']] = $this->data['vykonat'];
}
}
/**
* Funkce pro Odeslání položek
*/
public function posliPolozky() {
return $this->polozka;
}
}
?>
<?php
foreach ($this->metoda as $nazev => $vykonat) {
print("<a class='buttonbok' href='" . $vykonat . "'>" . $nazev . "</a><br />\n");
}
?>
<?php
foreach ($this->metoda as $nazev => $vykonat) {
print("<a class='button' href='" . $vykonat . "'>" . $nazev . "</a>");
}
?>
<?php
/**
* třída pro připojení k Mysql
* @version 1.0.0
*/
class mysql {
private $dotaz;
/**
* @var string server
*/
private $server = "localhost";
/**
* @var string login
*/
private $login = "root";
/**
* @var string pass
*/
private $pass = "";
/**
* @var string db
*/
private $db = "casopis";
/**
* Připojení k DB
*/
public function __construct() {
mysql_connect($this->server, $this->login, $this->pass) or die(mysql_error());
mysql_select_db($this->db) or die(mysql_error());
}
/**
* SELECT z DB
*/
public function select($from,$where) {
if(isset($where)) {
$this->dotaz = mysql_query("SELECT * FROM `$from` WHERE $where") or die(mysql_error());
} else {
$this->dotaz = mysql_query("SELECT * FROM `$from`") or die(mysql_error());
}
return $this->dotaz;
}
}
?>
<!DOCTYPE html>
<html lang="cs-cz">
<head>
<title></title>
<meta charset="UTF-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<link rel='stylesheet' href='./view/css/css.css' type='text/css' />
</head>
<body>
<?php
/**
* Include Hlavní šablony
*/
$kontrola = new Kontroler();
require_once 'indexes.php';
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment