common.php 3.89 KB
Newer Older
nextime's avatar
nextime committed
1
<?
2 3
//$GUIDEBUG=FALSE;
$GUIDEBUG=TRUE;
4

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

function getBaseGuiPath()
{
   return str_replace("/index.php","",$_SERVER['PHP_SELF']);
}

function getFSPath()
{
   return realpath(dirname(__FILE__)."/..");
}


function getGuiPath()
{
   return str_replace(getBaseGuiPath(),'',explode('?',$_SERVER['REQUEST_URI'])[0]);
}



function getSection($path=false)
{
   if($path)
      $sectar=explode("/", $path);
   else
      $sectar=explode("/", getGuiPath());
   $GUISECTION="index"; 
   if(count($sectar)>1 and $sectar[1]!="")
      $GUISECTION=$sectar[1];
   return $GUISECTION;
}

function getSubsection($path=false)
{
   if($path)
      $sectar=explode("/", $path);
   else
      $sectar=explode("/", getGuiPath());
   $GUISUBSECTION="";
   if(count($sectar)>2)
      $GUISUBSECTION=$sectar[2];
   return $GUISUBSECTION;
}

function getSubsectionOpt($path=false)
{
   if($path)
      $sectar=explode("/", $path);
   else
      $sectar=explode("/", getGuiPath());
   $GUISUBSECTIONOPT="";
   if(count($sectar)>3)
      $GUISUBSECTIONOPT=$sectar[3];
   return $GUISUBSECTIONOPT;
}
$BASEGUIPATH=getBaseGuiPath();
$FSPATH=getFSPath();
$GUIPATH=getGuiPath();
$GUISECTION=getSection();
$GUISUBSECTION=getSubsection();
$GUISUBSECTIONOPT=getSubsectionOpt();
nextime's avatar
nextime committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

$left=FALSE;
$right=FALSE;
if(file_exists("$FSPATH/left/$GUISECTION.php"))
{
   $left=TRUE;
}
if(file_exists("$FSPATH/right/$GUISECTION.php"))
   $right=TRUE;

$dmcolors=array(
   'green' => 'success',
   'orange' => 'warning',
   'blue' => 'primary',
   'azure' => 'info',
   'red' => 'danger',
   'gray' => 'gray'
);

include_once("common_includes.php");
@include_once("config.php");
include_once("translations.php");
nextime's avatar
nextime committed
87 88 89

//print_r($_DOMOTIKA);

90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
switch($_DOMOTIKA['left_bar'])
{
   case 'all': $LBAR=array('small','medium','big'); break;
   case 'visible-sm': $LBAR=array('small'); break;
   case 'visible-md': $LBAR=array('medium'); break;
   case 'visible-lg': $LBAR=array('big'); break;
   case 'hidden-sm': $LBAR=array('medium','big'); break;
   case 'hidden-md': $LBAR=array('small','big'); break;
   case 'hidden-lg': $LBAR=array('small','medium'); break;
   case 'none': $LBAR=array(); break;
   default: $LBAR=array('medium','big'); 
}
switch($_DOMOTIKA['right_bar'])
{
   case 'all': $RBAR=array('small','medium','big'); break;
   case 'visible-sm': $RBAR=array('small'); break;
   case 'visible-md': $RBAR=array('medium'); break;
   case 'visible-lg': $RBAR=array('big'); break;
   case 'hidden-sm': $RBAR=array('medium','big'); break;
   case 'hidden-md': $RBAR=array('small','big'); break;
   case 'hidden-lg': $RBAR=array('small','medium'); break;
   case 'none': $RBAR=array(); break;
   default: $RBAR=array('medium','big'); 
}  


nextime's avatar
nextime committed
116

nextime's avatar
nextime committed
117 118 119 120 121 122 123 124 125
$lang=$_DOMOTIKA['language'];
$tr = new Translations($lang);
$img = new Translations("icons");
$PAGE_BUFFER = array();
$PAGE_ADDHEAD = "";
$PAGE_ADDFOOTJS = "";
$PAGE_ADDLEFT = "";
$PAGE_ADDRIGHT = "";

126 127
$SHOW_EMPTY_PANELS=TRUE;

nextime's avatar
nextime committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
function addFootJS($file)
{
   ob_start();
   include_once($file);
   $GLOBALS['PAGE_ADDFOOTJS'].=ob_get_clean();
}
function addHead($file)
{
   ob_start();
   include_once($file);
   $GLOBALS['PAGE_ADDHEAD'].=ob_get_clean();
}

function addLeft($file, $sobstitute=false)
{
   ob_start();
   include($file);
   $GLOBALS['PAGE_ADDLEFT'].=ob_get_clean();
   if($sobstitute)
      $GLOBALS['PAGE_BUFFER']['left_drawer']="";

}

function addRight($file, $sobstitute=false)
{
   ob_start();
   include($file);
   $GLOBALS['PAGE_ADDRIGHT'].=ob_get_clean();
   if($sobstitute)
      $GLOBALS['PAGE_BUFFER']['right_drawer']="";
}

160
function notifyListItem($addclass='')
nextime's avatar
nextime committed
161
{
162
   $ret='<a class="list-group-item notify-swipe-deletable '.$addclass.'" id="notifyid-[NID]" href="#">';
nextime's avatar
nextime committed
163 164 165 166 167 168 169 170 171
   $ret.='  <h4 class="list-group-item-heading">From: [NSOURCE]<i class="glyphicon glyphicon-remove pull-right notify-deletable"></i></h4>';
   $ret.='  <p class="list-group-item-text">[NDATE]</p>';
   $ret.='  <p class="list-group-item-text">[TXT]</p>';
   $ret.='</a>';
   return $ret;
}


?>