Adding jquery tooltip css globally
Adding jquery tooltip css globally

<?php <?php
/** Main HTML Output generation /** Main HTML Output generation
* *
* Copyright (C) 2012 B Tasker * Copyright (C) 2012 B Tasker
* Released under GNU GPL V2 * Released under GNU GPL V2
* See LICENSE * See LICENSE
* *
*/ */
   
defined('_CREDLOCK') or die; defined('_CREDLOCK') or die;
   
   
   
class genOutput{ class genOutput{
   
/** Will be overhauled at some point, will most likely move the actual page content into the template /** Will be overhauled at some point, will most likely move the actual page content into the template
* *
*/ */
function genDefaultPage(){ function genDefaultPage(){
global $notifications; global $notifications;
$notifications->setPageTitle("Home"); $notifications->setPageTitle("Home");
   
$str = "<span class='basic-content default-page'>"; $str = "<span class='basic-content default-page'>";
if (BTMain::getUser()->name){ if (BTMain::getUser()->name){
   
$str .= 'Welcome to the cred handling system. Please use the menus to proceed'; $str .= 'Welcome to the cred handling system. Please use the menus to proceed';
   
}else{ }else{
   
$str .= 'Please log-in to continue'; $str .= 'Please log-in to continue';
   
   
} }
   
return $str . "</span>\n"; return $str . "</span>\n";
   
} }
   
   
   
   
   
/** Call the relevant template /** Call the relevant template
* *
*/ */
function callTemplate(){ function callTemplate(){
// Load the config so we know which template to call // Load the config so we know which template to call
   
$template = BTMain::getConf()->template; $template = BTMain::getConf()->template;
require "templates/$template/index.php"; require "templates/$template/index.php";
   
} }
   
   
/** Load a view and return the output /** Load a view and return the output
* *
* @arg view string * @arg view string
*/ */
function loadView($view){ function loadView($view){
   
ob_start; ob_start;
$template = BTMain::getConf()->template; $template = BTMain::getConf()->template;
$view = str_replace(".","/",$view); $view = str_replace(".","/",$view);
// Check for template level override // Check for template level override
if (file_exists("templates/". $template . "html/views/" . $view . ".php")){ if (file_exists("templates/". $template . "html/views/" . $view . ".php")){
require "templates/". $template . "html/views/" . $view . ".php"; require "templates/". $template . "html/views/" . $view . ".php";
}else{ }else{
require "views/" . $view . ".php"; require "views/" . $view . ".php";
   
} }
return ob_get_clean(); return ob_get_clean();
} }
   
   
/** Output the Breadcrumbs /** Output the Breadcrumbs
* *
*/ */
function BreadCrumbs(){ function BreadCrumbs(){
?> ?>
<ul class="breadcrumb"> <ul class="breadcrumb">
<li> <li>
<a href="index.php">Home</a> <a href="index.php">Home</a>
</li> </li>
<?php foreach ($GLOBALS['BREADCRUMB'] as $crumb){?> <?php foreach ($GLOBALS['BREADCRUMB'] as $crumb){?>
<li> <li>
<span class="divider">/</span> <span class="divider">/</span>
<a href="<?php echo $crumb['url']; ?>"><?php echo $crumb['name']; ?></a> <a href="<?php echo $crumb['url']; ?>"><?php echo $crumb['name']; ?></a>
</li> </li>
   
<?php }?> <?php }?>
</ul> </ul>
<?php <?php
   
} }
   
   
   
/** Generate the HTML for any relevant Notifications /** Generate the HTML for any relevant Notifications
* *
*/ */
function Notifications(){ function Notifications(){
   
global $notifications; global $notifications;
$nots = $notifications->getNotifications(); $nots = $notifications->getNotifications();
   
if ($notifications){ if ($notifications){
foreach ($nots as $not){ foreach ($nots as $not){
$id=''; $id='';
   
if (!empty($not->id)){ if (!empty($not->id)){
$id = " id='{$not->id}'"; $id = " id='{$not->id}'";
} }
   
$str[] = "<div class='{$not->className}'$id>{$not->text}</div>"; $str[] = "<div class='{$not->className}'$id>{$not->text}</div>";
   
} }
   
   
} }
   
return implode("\n",$str); return implode("\n",$str);
   
} }
   
   
   
/** Push the required headers /** Push the required headers
* *
*/ */
function headContents(){ function headContents(){
   
global $notifications; global $notifications;
$page = $notifications->getPageInfo(); $page = $notifications->getPageInfo();
$conf = BTMain::getConf(); $conf = BTMain::getConf();
?> ?>
<title><?php echo $conf->ProgName;?> - <?php echo htmlentities($page->title);?></title> <title><?php echo $conf->ProgName;?> - <?php echo htmlentities($page->title);?></title>
<link rel="stylesheet" type="text/css" href="Resources/jquery.tooltip<?php echo $conf->JSMinName;?>.css" /> <link rel="stylesheet" type="text/css" href="Resources/jquery.tooltip<?php echo $conf->JSMinName;?>.css" />
<link rel="stylesheet" type="text/css" href="Resources/bootstrap/css/bootstrap<?php echo $conf->JSMinName;?>.css" /> <link rel="stylesheet" type="text/css" href="Resources/bootstrap/css/bootstrap<?php echo $conf->JSMinName;?>.css" />
<link rel="stylesheet" type="text/css" href="Resources/bootstrap/css/bootstrap-responsive<?php echo $conf->JSMinName;?>.css" /> <link rel="stylesheet" type="text/css" href="Resources/bootstrap/css/bootstrap-responsive<?php echo $conf->JSMinName;?>.css" />
  <link rel="stylesheet" type="text/css" href="Resources/jquery.tooltip<?php echo $conf->JSMinName;?>.css" />
   
<?php foreach ($page->css as $css):?> <?php foreach ($page->css as $css):?>
<link rel="stylesheet" type="text/css" href='Resources/<?php echo $css;?>.css'/> <link rel="stylesheet" type="text/css" href='Resources/<?php echo $css;?>.css'/>
<?php endforeach;?> <?php endforeach;?>
   
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="Resources/bootstrap/js/bootstrap<?php echo $conf->JSMinName;?>.js"></script> <script type="text/javascript" src="Resources/bootstrap/js/bootstrap<?php echo $conf->JSMinName;?>.js"></script>
<script type="text/javascript" src="Resources/jquery.tooltip.min.js"></script> <script type="text/javascript" src="Resources/jquery.tooltip.min.js"></script>
<script id='kFile' src="Resources/info.php?<?php echo md5(session_id().$_SERVER['REMOTE_ADDR']); ?>" type="text/javascript"></script> <script id='kFile' src="Resources/info.php?<?php echo md5(session_id().$_SERVER['REMOTE_ADDR']); ?>" type="text/javascript"></script>
<script src="Resources/main<?php echo $conf->JSMinName;?>.js" type="text/javascript"></script> <script src="Resources/main<?php echo $conf->JSMinName;?>.js" type="text/javascript"></script>
<script src="Resources/base64<?php echo $conf->JSMinName;?>.js" type="text/javascript"></script> <script src="Resources/base64<?php echo $conf->JSMinName;?>.js" type="text/javascript"></script>
   
<?php foreach ($page->reqscripts as $script):?> <?php foreach ($page->reqscripts as $script):?>
<script src="Resources/<?php echo $script;?><?php echo $conf->JSMinName;?>.js" type="text/javascript"></script> <script src="Resources/<?php echo $script;?><?php echo $conf->JSMinName;?>.js" type="text/javascript"></script>
<?php endforeach; if (!empty($page->custJS[0])):?> <?php endforeach; if (!empty($page->custJS[0])):?>
   
<script type="text/javascript"> <script type="text/javascript">
<?php echo implode("\n",$page->custJS);?> <?php echo implode("\n",$page->custJS);?>
</script> </script>
   
<?php endif; ?> <?php endif; ?>
   
<!-- Fire the default scripts when the browser reports document ready --> <!-- Fire the default scripts when the browser reports document ready -->
<script type="text/javascript"> <script type="text/javascript">
var sesscheck; jQuery(document).ready(function() { checkKeyAvailable(); var sesscheck; jQuery(document).ready(function() { checkKeyAvailable();
<?php if (BTMain::getUser()->name):?>sesscheck = setInterval("checkSession()",120000);<?php endif;?>}); <?php if (BTMain::getUser()->name):?>sesscheck = setInterval("checkSession()",120000);<?php endif;?>});
</script> </script>
   
<?php <?php
} }
   
   
   
   
/** Load a module by name /** Load a module by name
* *
* @arg module - string * @arg module - string
* *
*/ */
function loadModule($module){ function loadModule($module){
   
$template = BTMain::getConf()->template; $template = BTMain::getConf()->template;
   
   
// Check for template override // Check for template override
if (file_exists("templates/$template/html/modules/$module/$module.php")){ if (file_exists("templates/$template/html/modules/$module/$module.php")){
require "templates/$template/html/modules/$module/$module.php"; require "templates/$template/html/modules/$module/$module.php";
}else{ }else{
require "modules/$module/$module.php"; require "modules/$module/$module.php";
} }
   
   
   
} }
   
   
   
   
}/** Gen Output Class Ends **/ }/** Gen Output Class Ends **/
   
   
   
   
   
   
   
   
/** Notifications class **/ /** Notifications class **/
class notifications{ class notifications{
   
   
   
   
/** Return an object containing any notification items that have been set (or at least those suited for embedding in the head) /** Return an object containing any notification items that have been set (or at least those suited for embedding in the head)
* *
* @return object * @return object
* *
*/ */
function getPageInfo(){ function getPageInfo(){
   
$page->title = ''; $page->title = '';
$page->css = array(); $page->css = array();
$page->reqscripts = array(); $page->reqscripts = array();
$page->custJS = array(); $page->custJS = array();
   
if (isset($this->pagetitle)){ if (isset($this->pagetitle)){
$page->title = $this->pagetitle; $page->title = $this->pagetitle;
} }
   
if (is_array($this->css)){ if (is_array($this->css)){
$page->css = $this->css; $page->css = $this->css;
} }
   
if (is_array($this->requiredscripts)){ if (is_array($this->requiredscripts)){
$page->reqscripts = $this->requiredscripts; $page->reqscripts = $this->requiredscripts;
} }
   
if (is_array($this->customJS)){ if (is_array($this->customJS)){
$page->custJS = $this->customJS; $page->custJS = $this->customJS;
} }
   
return $page; return $page;
} }
   
   
/** Set the page title /** Set the page title
* *
* @arg title * @arg title
* *
*/ */
function setPageTitle($title){ function setPageTitle($title){
$this->pagetitle = $title; $this->pagetitle = $title;
} }
   
   
   
/** Get any notifications that have been triggered /** Get any notifications that have been triggered
* *
* @return object (or false if no notifications) * @return object (or false if no notifications)
* *
*/ */
function getNotifications(){ function getNotifications(){
   
$notif = BTMain::getVar('notif'); $notif = BTMain::getVar('notif');
$triggernotifs = is_array($this->notifications); $triggernotifs = is_array($this->notifications);
   
   
// Check whether there are any notifications to push // Check whether there are any notifications to push
if (!$notif && !$triggernotifs){ if (!$notif && !$triggernotifs){
return false; return false;
} }
   
   
$nots = new stdClass(); $nots = new stdClass();
include 'conf/notifications.php'; include 'conf/notifications.php';
   
// Check for notifications triggered by views // Check for notifications triggered by views
if ($triggernotifs){ if ($triggernotifs){
   
foreach ($this->notifications as $msg){ foreach ($this->notifications as $msg){
$nots->$msg = $notifs->$msg; $nots->$msg = $notifs->$msg;
} }
   
} }
   
   
// Check for notifications triggered by the request // Check for notifications triggered by the request
if ($notif){ if ($notif){
$nots->$notif = $notifs->$notif; $nots->$notif = $notifs->$notif;
} }
   
   
return $nots; return $nots;
} }
   
   
/** Set a notification to display when getNotifications is called /** Set a notification to display when getNotifications is called
* *
* @arg notification - string containing notification name * @arg notification - string containing notification name
* *
*/ */
function setNotification($notification){ function setNotification($notification){
$this->notifications[] = $notification; $this->notifications[] = $notification;
} }
   
   
/** Trigger the inclusion of a CSS file in the document head /** Trigger the inclusion of a CSS file in the document head
* *
* @arg file - filename (Will be automatically prefixed with Resources/ and appended with .css) * @arg file - filename (Will be automatically prefixed with Resources/ and appended with .css)
* *
*/ */
function RequireCSS($file){ function RequireCSS($file){
$this->css[] = $file; $this->css[] = $file;
} }
   
   
/** Trigger the inclusion of a JS file in the document head /** Trigger the inclusion of a JS file in the document head
* *
* @arg file - filename (Will be automatically prefixed with Resources/ and appended with .js) * @arg file - filename (Will be automatically prefixed with Resources/ and appended with .js)
* *
*/ */
function RequireScript($script){ function RequireScript($script){
$this->requiredscripts[] = $script; $this->requiredscripts[] = $script;
} }
   
   
/** Set the breadcrumb path /** Set the breadcrumb path
* *
* @arg path - array * @arg path - array
* *
* Exact schema of the array is dictated by class genOutput but at time of writing, * Exact schema of the array is dictated by class genOutput but at time of writing,
* each breadcrumb item should be an array containing elements name and url * each breadcrumb item should be an array containing elements name and url
* *
*/ */
function setBreadcrumb($path){ function setBreadcrumb($path){
   
$GLOBALS['BREADCRUMB'] = $path; $GLOBALS['BREADCRUMB'] = $path;
   
} }
   
   
/** Embed a JS string into the document head, will automatically be placed between script tags /** Embed a JS string into the document head, will automatically be placed between script tags
* *
* @arg js - string * @arg js - string
* *
*/ */
function setCustomJS($js){ function setCustomJS($js){
$this->customJS[] = "$js"; $this->customJS[] = "$js";
} }
   
   
} }
   
   
   
   
   
?> ?>