public static function prepareData($item, $mysqli)
 {
     // page title
     $data["title"] = "Alois Sečkár - Blog";
     include_once getcwd() . '/web/scripts/page-data/elrh_data_helper.php';
     if (empty($item)) {
         // if no item selected = show list of all blog entries
         $data["entries"] = ELRHDataHelper::retrieveArray($mysqli, "SELECT id, title, date, categories FROM elrh_blog ORDER BY date DESC");
     } else {
         // still have to determine between blog-id and category-filter
         if (is_numeric($item)) {
             // notify content renderer, there will be only one blog entry
             $data["single"] = true;
             // try to find particular blog item
             $data["entry"] = ELRHDataHelper::retrieveRow($mysqli, "SELECT id, title, date, time, content FROM elrh_blog WHERE id='" . mysqli_real_escape_string($mysqli, $item) . "'");
             if (!empty($data["entry"])) {
                 // page title adjustment
                 $data["title"] .= ": " . $data["entry"]["title"];
                 // notify content renderer, article exists
                 $data["exists"] = true;
             }
         } else {
             // notify content renderer, filter is active
             $data["filter"] = $item;
             // category filter is set-up = show list of filtered blog entries
             $data["entries"] = ELRHDataHelper::retrieveArray($mysqli, "SELECT id, title, date, categories FROM elrh_blog WHERE categories LIKE '%" . mysqli_real_escape_string($mysqli, $item) . "%' ORDER BY date DESC");
         }
     }
     // save prepared data for renderer
     return $data;
 }
 public static function prepareData($item, $mysqli)
 {
     // page title
     $data["title"] = "Alois Sečkár - Politika online";
     include_once getcwd() . '/web/scripts/page-data/elrh_data_helper.php';
     // deal with admin input, if any
     if (isset($_SESSION["user"])) {
         if (isset($_POST["admin_online"]) && isset($_POST["admin_content"])) {
             $data["admin_content"] = $_POST["admin_content"];
             $result = $mysqli->query("INSERT INTO elrh_onlines_content (online, date, content) VALUES (" . mysqli_real_escape_string($mysqli, $_POST["online"]) . ", now(), '" . mysqli_real_escape_string($mysqli, $_POST["content"]) . "');");
             if ($result) {
                 $data["admin_message"] = '<span style="color: green;">Vložen nový záznam</span>';
             } else {
                 $data["admin_message"] = '<span style="color: red;">Vložení selhalo</span>';
             }
         }
     }
     //
     // get list of all existing onlines
     $data["onlines"] = ELRHDataHelper::retrieveArray($mysqli, "SELECT id, date, name, thumb, status FROM elrh_onlines ORDER BY date DESC");
     //
     if (!empty($item)) {
         // notify content renderer, there will be only one entry
         $data["single"] = true;
         // find one particular entry and its details
         $data["entry"] = ELRHDataHelper::retrieveRow($mysqli, "SELECT id, date, name, dscr, thumb, status FROM elrh_onlines WHERE id='" . mysqli_real_escape_string($mysqli, $item) . "'");
         //
         if (!empty($data["entry"])) {
             // page title adjustment
             // too long...
             // $data["title"] .= ": ".$data["entry"]["name"];
             // notify content renderer, article exists
             $data["exists"] = true;
         }
         // find all content relative to selected online
         $data["contents"] = ELRHDataHelper::retrieveArray($mysqli, "SELECT date, content FROM elrh_onlines_content WHERE online='" . mysqli_real_escape_string($mysqli, $item) . "' ORDER BY date DESC");
         //
         if (!empty($data["contents"])) {
             // notify content renderer, there are contents for this online
             $data["full"] = true;
         }
         // memo FOR FUTRE USE when there will be admin-form for inserting
         //if (is_numeric($item)) {
         //} else {
         //}
     }
     // save prepared data for renderer
     return $data;
 }
 public static function prepareData($item, $mysqli)
 {
     // page title
     $data["title"] = "Alois Sečkár - Glosy";
     // deal with admin input, if any
     if (isset($_SESSION["user"])) {
         if (isset($_POST["admin_quote"]) && isset($_POST["admin_topic"])) {
             // prepare values
             $data["admin_input"]["quote"] = $_POST["admin_quote"];
             $data["admin_input"]["topic"] = $_POST["admin_topic"];
             $data["admin_input"]["link"] = "null";
             if (isset($_POST["admin_link"]) && $_POST["admin_link"] != "") {
                 $data["admin_input"]["link"] = $_POST["admin_link"];
             }
             // insert into db
             $result = $mysqli->query("INSERT INTO elrh_quotes (date, content, topic, link) VALUES (now(), '" . mysqli_real_escape_string($mysqli, $data["admin_input"]["quote"]) . "', '" . mysqli_real_escape_string($mysqli, $data["admin_input"]["topic"]) . "', '" . mysqli_real_escape_string($mysqli, $data["admin_input"]["link"]) . "');");
             if ($result) {
                 $mysqli->query("UPDATE elrh_main SET value=now() WHERE var='last_quote'");
                 $data["admin_message"] = '<span style="color: green;">Vložen nový záznam</span>';
             } else {
                 $data["admin_message"] = '<span style="color: red;">Vložení selhalo</span>';
             }
         }
     }
     //
     // get quotes
     include_once getcwd() . '/web/scripts/page-data/elrh_data_helper.php';
     // default amount is 25
     // user can load more by clicking
     if (is_numeric($item)) {
         $data["limit"] = $item;
     } else {
         $data["limit"] = 25;
     }
     // last quote inserted
     $data["last"] = ELRHDataHelper::retrieveRow($mysqli, "SELECT value FROM elrh_main WHERE var='last_quote'");
     // get desired amount of quotes sorted by date inserted
     $data["quotes"] = ELRHDataHelper::retrieveArray($mysqli, "SELECT date, content, topic, link FROM elrh_quotes ORDER BY date DESC LIMIT " . $data["limit"]);
     // get total amount of quotes
     $data["total"] = ELRHDataHelper::retrieveRow($mysqli, "SELECT count(id) AS entries FROM elrh_quotes");
     // save prepared data for renderer
     return $data;
 }