1 2 3 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 65 66 67 68 69 70
|
<?php
$skinGeneralPath = "gfx/skin";
////////////////////////////////////////////////////////////
// Find the selected skin in already "loaded skin table", //
// and retrun it's index. Return -1 if not found //
////////////////////////////////////////////////////////////
function getSkinIndex($skinName){
global $skinTable;
$nbrLoaded = sizeof($skinTable);
for($i=0;$i<$nbrLoaded;$i++){
$curSkin = &$skinTable[$i];
if($curSkin["skinName"] == $skinName){
return $i;
}
}
return -1;
}
$skinCssString = "";
////////////////////////////////////////////////////////////
// Skin one content and retrun the resulting html element //
////////////////////////////////////////////////////////////
function skin($skinpath,$content,$title){
global $skinTable;
global $skinGeneralPath;
global $skinCssString;
if($skinpath == "") $skinpath = "green";
// If skin function not allready in memory
$skinIndex = getSkinIndex($skinpath);
if($skinIndex == -1){
$isSkinOk = false;
// Include the php file containing the code
if(!file_exists("$skinGeneralPath/$skinpath/skin.php")) die("Skin $skinpath not found !!!");
include("$skinGeneralPath/$skinpath/skin.php");
$skinIndex = getSkinIndex($skinpath);
if($skinIndex == -1) die("Cannot find included skin $skinpath");
}else{
$isSkinOk = true;
}
// Find (or create if 1st load) the skin function
$mySkin = &$skinTable[$skinIndex];
$functionCode = &$mySkin["functionCode"];
if($isSkinOk == false){
$functionName = create_function('$skinpath,$content,$title,$skinGeneralPath',$functionCode);
$mySkin["functionName"] = $functionName;
if($mySkin["skinCss"] != ""){
$cssFile = "$skinGeneralPath/".$mySkin["skinName"]."/".$mySkin["skinCss"];
$skinCssString .= "<link rel=\"stylesheet\" href=\"$cssFile\" type=\"text/css\">\n";
}
}else{
$functionName = $mySkin["functionName"];
}
// Call it
return $functionName($skinpath,$content,$title,$skinGeneralPath);
}
if(file_exists("$dtcshared_path/$skinGeneralPath/$conf_skin/layout.php")){
require("$dtcshared_path/$skinGeneralPath/$conf_skin/layout.php");
}
if(file_exists("$dtcshared_path/$skinGeneralPath/$conf_skin/gfx_defaults.php")){
require("$dtcshared_path/$skinGeneralPath/$conf_skin/gfx_defaults.php");
}
?>
|