<?php
# vim:et:ts=3:sts=3:sw=3:

// RLD Creative base functions
// Copyright (C) 2017 RLD Creative
//

/* ======================================================================
 * Function get_docroot()
 * Parameters: 
 * Returns: root document dir
 *
 * Get the root dir from the ccurrent webpage.
 * ====================================================================== */
function get_docroot() {
  $docroot = $_SERVER['SCRIPT_FILENAME'];
  $filename = $_SERVER['PHP_SELF'];

  //backslashes vervangen door forward slashes
  $docroot = str_replace("\\", "/", $docroot);
  
  //bepaal positie waar bestandsnaam start
  $positie = strpos( $docroot, $filename);
  
  //filenaam van docroot verwijderen en document root afleveren
  return substr( $docroot, 0, $positie);
} //get_docroot


//load configuration settings
include_once( get_docroot()."/include/config_inc.php");

/* Return the registered company name */
function get_company() {
  global $config;
	
  echo( $config["company"]);
}

/* return the configured page title */
function get_title() {
  global $config;
	
  echo( $config["title"]);
}

/* return home page url */
function get_homepage() {
  
  echo('/');  
}

/* return the configured page title */
function get_page_title() {
  global $page_title;
  
  $page = basename($_SERVER["SCRIPT_FILENAME"], '.php');
  
	if (empty($page_title[$page])) {
    echo( $page_title["index"]);
  } else {
    echo( $page_title[$page]); 
  }
}

//set actuele kleurschema
function set_kleurschema( $schema = 0) {
  global $config;
  
  $config["kleurschema"] = $schema;
}

function get_kleur( $index = 0, $hash = 1) {
 global $kleur_hexa, $config;
 
  $x = $config["kleurschema"];
  
  if ($index < 0) {$index = 0;}
  if ($index > 6) {$index = 6;}
  if ($index > 4) {$x = 0;}
  if ($hash != 0) { 
    echo( '#'.$kleur_hexa[$x][$index]);
  }
  else {
    echo( $kleur_hexa[$x][$index]);
  }
}

function get_kleur_a( $index = 0) {
 global $kleur_rgba, $config;

  $x = $config["kleurschema"];
  
  if ($index < 0) {$index = 0;}
  if ($index > 6) {$index = 6;}
  if ($index > 4) {$x = 0;}
  
  echo( $kleur_rgba[$x][$index]);
}

?>

  