Browse Source

Added ability to specify type of url to generate. Added dev_env config variable. Changed header and footer to use new url generator.

pull/24/head
Teknikode 8 years ago
parent
commit
2700fb20db
  1. 44
      includes/common.php
  2. 12
      includes/config.php.default
  3. 2
      templates/default/footer.php
  4. 40
      templates/default/header.php

44
includes/common.php

@ -1,4 +1,24 @@ @@ -1,4 +1,24 @@
<?php
function get_page_url($page, $CONF, $full = true)
{
$full_url = get_http($CONF).$CONF['host'];
switch ($CONF['url_type'])
{
case 'sub':
if ($page == $CONF['default_page'])
{
$page = 'www';
}
$full_url = get_subdomain_full_url($page, $CONF);
break;
case 'page':
$cur_sub = get_subdomain();
$full_url = get_http($CONF).$cur_sub.".".$CONF['host']."/".$page;
break;
}
return $full_url;
}
function get_subdomain_full_url($sub_part, $CONF)
{
$url = get_http($CONF).$sub_part.".".$CONF['host'];
@ -35,6 +55,17 @@ function get_subdomain() @@ -35,6 +55,17 @@ function get_subdomain()
return $sub;
}
function get_page()
{
$full_page = $_SERVER['REQUEST_URI'];
$parts = explode("/", $full_page);
if (count($parts) > 0)
{
return $parts[0];
}
return "";
}
function get_http($CONF)
{
if ($CONF['https'] != "on")
@ -50,8 +81,17 @@ function get_http($CONF) @@ -50,8 +81,17 @@ function get_http($CONF)
function get_active($page)
{
$sub = get_subdomain();
if ($sub == $page)
$cur_page = '';
switch ($CONF['url_type'])
{
case 'sub':
$cur_page = get_subdomain();
break;
case 'page':
$cur_page = get_page();
break;
}
if ($cur_page == $page)
{
return 'active';
}

12
includes/config.php.default

@ -19,6 +19,9 @@ require_once('Minifier.php'); @@ -19,6 +19,9 @@ require_once('Minifier.php');
$CONF=array();
// Determines whether the current website is the development server or not
$CONF['dev_env'] = FALSE;
// Database Information
$CONF['db_name'] = 'name';
$CONF['db_user'] = 'user';
@ -41,6 +44,15 @@ $CONF['siteowner'] = "Example Owner"; @@ -41,6 +44,15 @@ $CONF['siteowner'] = "Example Owner";
// Site Host
$CONF['host'] = 'example.com';
// Default Page - The page used for the www and default site.
$CONF['default_page'] = 'home';
// The method to use for generating the url's for the site
// --OPTIONS--
// sub => Each service is a subdomain. ie: /about/ is about.$CONF['host']
// page => Each service is a page in the url. ie: /about/ is $CONF['host']/about/
$CONF['url_type'] = 'sub';
$CONF['https'] = $_SERVER['HTTPS'];
// What is the name of the template you want to use for the frontend (the folder name as displayed in /templates/)

2
templates/default/footer.php

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
</div>
<footer id="footer" class="footer navbar navbar-default">
<div class="container">
<p class="text-muted">&copy; Teknik 2013-2014 | <a href="<?php echo get_subdomain_full_url("privacy", $CONF); ?>">Privacy</a> | <a href="<?php echo get_subdomain_full_url("transparency", $CONF); ?>">Transparency</a> | <a href="<?php echo get_subdomain_full_url("stats", $CONF); ?>">Stats</a></p>
<p class="text-muted">&copy; Teknik 2013-2014 | <a href="<?php echo get_page_url("privacy", $CONF); ?>">Privacy</a> | <a href="<?php echo get_page_url("transparency", $CONF); ?>">Transparency</a> | <a href="<?php echo get_page_url("stats", $CONF); ?>">Stats</a></p>
</div>
</footer>
</body>

40
templates/default/header.php

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
<meta name="description" content="<?php echo $CONF['sitedescription']; ?>" />
<meta name="author" content="<?php echo $CONF['siteowner']; ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/favicon.ico" type="image/x-icon" />
<?php
$cssFiles = array();
@ -201,16 +201,16 @@ @@ -201,16 +201,16 @@
foreach ($cssFiles as $file)
{
?>
<link href="<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/css/<?php echo $file; ?>" rel="stylesheet" />
<link href="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/css/<?php echo $file; ?>" rel="stylesheet" />
<?php
}
?>
<!--<link href="<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/cache/css/<?php echo $CONF['sub']; ?>.teknik.min.css" rel="stylesheet" />-->
<script src="<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/cache/js/<?php echo $CONF['sub']; ?>.teknik.min.js"></script>
<!--<link href="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/cache/css/<?php echo $CONF['sub']; ?>.teknik.min.css" rel="stylesheet" />-->
<script src="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/cache/js/<?php echo $CONF['sub']; ?>.teknik.min.js"></script>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/js/html5/html5.js"></script>
<script src="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/js/html5/html5.js"></script>
<![endif]-->
</head>
<?php flush(); ?>
@ -224,30 +224,30 @@ @@ -224,30 +224,30 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo get_subdomain_full_url("www", $CONF); ?>">Teknik</a>
<a class="navbar-brand" href="<?php echo get_page_url("home", $CONF); ?>">Teknik</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="<?php echo get_active("www"); echo get_active(""); ?>"><a href="<?php echo get_subdomain_full_url("www", $CONF); ?>">Home</a></li>
<li class="<?php echo get_active("about"); ?>"><a href="<?php echo get_subdomain_full_url("about", $CONF); ?>">About</a></li>
<li class="<?php echo get_active("blog"); ?>"><a href="<?php echo get_subdomain_full_url("blog", $CONF); ?>">Blog</a></li>
<li class="<?php echo get_active("podcast"); echo get_active("pod"); ?>"><a href="<?php echo get_subdomain_full_url("podcast", $CONF); ?>">Podcast</a></li>
<li class="<?php echo get_active("home"); echo get_active(""); ?>"><a href="<?php echo get_page_url("home", $CONF); ?>">Home</a></li>
<li class="<?php echo get_active("about"); ?>"><a href="<?php echo get_page_url("about", $CONF); ?>">About</a></li>
<li class="<?php echo get_active("blog"); ?>"><a href="<?php echo get_page_url("blog", $CONF); ?>">Blog</a></li>
<li class="<?php echo get_active("podcast"); echo get_active("pod"); ?>"><a href="<?php echo get_page_url("podcast", $CONF); ?>">Podcast</a></li>
<li class="divider-vertical"></li>
<li class="dropdown">
<a href="#" id="services_menu" class="dropdown-toggle" data-toggle="dropdown">Services <strong class="caret"></strong></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="services_menu">
<li>
<a href="<?php echo get_subdomain_full_url("upload", $CONF); ?>">Upload</a>
<a href="<?php echo get_page_url("upload", $CONF); ?>">Upload</a>
</li>
<li>
<a href="<?php echo get_subdomain_full_url("paste", $CONF); ?>">Paste</a>
<a href="<?php echo get_page_url("paste", $CONF); ?>">Paste</a>
</li>
<li>
<a href="<?php echo get_subdomain_full_url("git", $CONF); ?>">Git</a>
<a href="<?php echo get_page_url("git", $CONF); ?>">Git</a>
</li>
<li>
<a href="<?php echo get_subdomain_full_url("mail", $CONF); ?>" target="_blank">Mail</a>
<a href="<?php echo get_page_url("mail", $CONF); ?>" target="_blank">Mail</a>
</li>
<li>
<a href="mumble://mumble.<?php echo $CONF['host']; ?>:64738/?version=1.2.5" target="_blank">Mumble</a>
@ -255,16 +255,16 @@ @@ -255,16 +255,16 @@
<!--
<li class="divider"></li>
<li>
<a href="<?php echo get_subdomain_full_url("ricehalla", $CONF); ?>">Ricehalla</a>
<a href="<?php echo get_page_url("ricehalla", $CONF); ?>">Ricehalla</a>
</li>
-->
</ul>
</li>
<li class="<?php echo get_active("contact"); ?>">
<a href="<?php echo get_subdomain_full_url("contact", $CONF); ?>">Contact</a>
<a href="<?php echo get_page_url("contact", $CONF); ?>">Contact</a>
</li>
<li class="<?php echo get_active("help"); ?>">
<a href="<?php echo get_subdomain_full_url("help", $CONF); ?>">Help</a>
<a href="<?php echo get_page_url("help", $CONF); ?>">Help</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
@ -277,17 +277,17 @@ @@ -277,17 +277,17 @@
<a href="#" id="user_menu" class="dropdown-toggle" data-toggle="dropdown"><?php echo $user->username; ?> <strong class="caret"></strong></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="user_menu">
<li>
<a href="<?php echo get_subdomain_full_url("www", $CONF); ?>/<?php echo $user->username; ?>">Profile</a>
<a href="<?php echo get_page_url("home", $CONF); ?>/<?php echo $user->username; ?>">Profile</a>
</li>
<li>
<a href="<?php echo get_subdomain_full_url("blog", $CONF); ?>/<?php echo $user->username; ?>">Blog</a>
<a href="<?php echo get_page_url("blog", $CONF); ?>/<?php echo $user->username; ?>">Blog</a>
</li>
<?php
if ($user->group == "Founder" || $user->group == "Admin" || $user->group == "Moderator")
{
?>
<li>
<a href="<?php echo get_subdomain_full_url("admin", $CONF); ?>">Administration</a>
<a href="<?php echo get_page_url("admin", $CONF); ?>">Administration</a>
</li>
<?php
}

Loading…
Cancel
Save