added basic code to show the template

This commit is contained in:
nilsding 2014-08-18 14:51:00 +02:00
parent a54b2d5a6c
commit 2dfe16ef36
5 changed files with 51 additions and 4 deletions

View File

@ -41,6 +41,10 @@ function crypt_password ($pass, $salt) {
// the
session_start();
if (!isset($_SESSION['logged_in'])) {
$_SESSION['logged_in'] = false;
}
if (!isset($notemplate)) {
require_once 'ext/rain.tpl.class.php';
@ -48,4 +52,24 @@ if (!isset($notemplate)) {
raintpl::configure("tpl_dir", "views/");
$tpl = new RainTPL;
// new words counter
$new_words_count = -1;
if ($_SESSION['logged_in'] === true) {
$res = $sql->query("SELECT `id` FROM `words` WHERE `new` = 1;");
$new_words_count = $res->num_rows;
}
// total words count
$res = $sql->query("SELECT `id` FROM `words`;");
$words_total_count = $res->num_rows * 3;
// site name
$res = $sql->query("SELECT `value` FROM `config` WHERE `key` = \"sitename\";")->fetch_assoc();
$site_name = htmlspecialchars($res['value']);
$tpl->assign("logged_in", $_SESSION['logged_in']);
$tpl->assign("site_name", $site_name);
$tpl->assign("words_total", $words_total_count);
$tpl->assign("inbox_count", $new_words_count);
}

View File

@ -0,0 +1,23 @@
<?php
/* This file is part of 3words
*
* (c) 2014 Leafcat Coding -- http://leafc.at
*
* License: AGPLv3, see LICENSE for full license text
*
* This file was touched by:
* - nilsding <nilsding@nilsding.org>
*
* Oh, and before I forget...
* ________ __________ __ ____ __ ______
* / ____/ / / / ____/ //_/ / __ \/ / / / __ \
* / /_ / / / / / / ,< / /_/ / /_/ / /_/ / with
* / __/ / /_/ / /___/ /| | / ____/ __ / ____/ a
* /_/ \____/\____/_/ |_| /_/ /_/ /_/_/ cactus!
*
* Thanks for listening.
*/
include_once 'config.php';
$tpl->draw("index");

View File

@ -1,7 +1,7 @@
{include="layout"}
{include="navbar"}
<div class="container">
<h1>{$site_title}!</h1>
<h1>{$site_name}!</h1>
<p>Want to tell them who you are? <input id="author" type="text" class="form-control" placeholder="Anonymous"></p>
<div class="row">
<div class="col-md-4">

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{$site_title}</title>
<title>{$site_name}</title>
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>

View File

@ -8,7 +8,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">{$site_title}</a>
<a class="navbar-brand" href="#">{$site_name}</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
@ -18,7 +18,7 @@
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{$user_name}<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="ucp.php">Inbox</a></li>
<li><a href="ucp.php">Inbox{if="$new_words_count > 0"}{$new_words_count}{/if}</a></li>
<li><a href="ucp.php?page=settings">Settings</a></li>
{else}
<li><a href="ucp.php?page=login">Login</a></li>