I’m trying to make a template that I can use for every website.
Is there any way I can get this cleaner?
Or is this done correctly?
<?php
$config = array();
// Put this in 'config.inc.php'
$config['lang'] = "en";
$config['en']['title'] = "Website Title";
$config['en']['description'] = "Website Description";
$config['en']['keywords'] = "Website 1, Website 2";
$config['en']['author'] = "Name ([email protected])";
$config['sp']['title'] = "Título De La Página";
$config['sp']['description'] = "Descripcion del Sitio Web";
$config['sp']['keywords'] = "Sitio Web 1, Sitio Web 2";
$config['sp']['author'] = "Nombre ([email protected])";
$config['ar']['title'] = "عنوان الموقع";
$config['ar']['description'] = "وصف الموقع";
$config['ar']['keywords'] = "موقع الكتروني 1, موقع الكتروني 2";
$config['ar']['author'] = "اسم ([email protected])";
$config['ch']['title'] = "网站标题";
$config['ch']['description'] = "网站说明";
$config['ch']['keywords'] = "网站1, 网站2";
$config['ch']['author'] = "姓名 ([email protected])";
// Put this in 'CowPocalypse.class.php'
class CowPocalypse {
private function getConfig($q){
global $config;
$l = $config['lang'];
$x = $config[$l][$q];
return $x;
}
public function config($q){
return $this->getConfig($q);
}
public function xCSSJS($d,$f,$t){
$dirs = $d;
$file = $f;
if (file_exists($dirs) === true){
if(is_dir($dirs)){
$data = true;
}else{
$data = false;
}
}
else{
$data = false;
}
if (!$data){
mkdir($dirs, 0777);
}
switch($t){
case "a":
$return = " <!-- Loading CSS Files -->\r\n";
break;
case "b":
$return = " <!-- Loading JS Files -->\r\n";
break;
}
$files = scandir($dirs, SCANDIR_SORT_ASCENDING);
foreach ($files as $x){
if (strpos($x, $file) !== false){
switch ($t){
case "a":
$return .= " <link href=\"".$x."\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" />\r\n";
break;
case "b":
$return .= " <script type=\"application/javascript\" language=\"javascript\" src=\"".$x."\"></script>\r\n";
break;
}
}
}
unset($x); unset($dirs); unset($files); unset($data);
if (!$return){
$return = " <!-- No Files Loaded -->\r\n";
}
return $return;
}
}
// 'index.php' file
$cow = new CowPocalypse();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$cow->config("title");?></title>
<meta name="description" content="<?=$cow->config("description");?>" />
<meta name="keywords" content="<?=$cow->config("keywords");?>" />
<meta name="author" content="<?=$cow->config("author");?>" />
<?php
echo $cow->xCSSJS("css", "css", "a");
echo $cow->xCSSJS("js", "js", "b");
?>
</head>
<body>
Something
</body>
</html>