Welcome to Geeklog, Anonymous Sunday, November 24 2024 @ 07:58 am EST
Geeklog Forums
Template OverRide
Status: offline
kino
Forum User
Newbie
Registered: 06/14/06
Posts: 14
Location:Japan
This correction can reduce a file.
At first, Geeklog processes functions.php.
set $_BASE_TEMPLATE
And execute functions.php in $_BASE_TEMPLATE .
$_BASE_TEMPLATE = 'professional';
if(file_exists($_CONF['path_themes'] . $_BASE_TEMPLATE . '/functions.php'))
{
require_once( $_CONF['path_themes'] . $_BASE_TEMPLATE . '/functions.php' );
}
Next, when new of Template is executed, the following code is executed.
function Template($root = ".", $unknowns = "remove") {
global $_BASE_TEMPLATE;
$this->set_base($_BASE_TEMPLATE);
if ($this->debug & 4) {
echo "<p><b>Template:</b> root = $root, unknowns = $unknowns</p>\n";
}
$this->set_root($root);
$this->set_unknowns($unknowns);
}
function set_root($root) {
global $_CONF;
if ($this->debug & 4) {
echo "<p><b>set_root:</b> root = $root</p>\n";
}
if (substr ($root, -1) == '/') {
$root = substr ($root, 0, -1);
}
if (!is_dir($root)) {
$root = str_replace($_CONF['path_layout'],$this->base .'/',$root);
if (!is_dir($root)) {
$this->halt("set_root: $root is not a directory.");
return false;
}
}
$this->root = $root;
return true;
}
Next, when set_file of Template is executed, the following code is executed.
function filename($filename) {
if ($this->debug & 4) {
echo "<p><b>filename:</b> filename = $filename</p>\n";
}
if (substr($filename, 0, 1) != "/"){
if (file_exists($this->root."/".$filename)) {
$filename = $this->root."/".$filename;
} else {
if (file_exists($this->base."/".$filename)) {
$filename = $this->base."/".$filename;
}
}
}
if ($this->debug & 4) {
echo "<p><b>real filename:</b> filename = $filename</p>\n";
}
// if (substr($filename, 0, 1) != "/") {
// $filename = $this->root."/".$filename;
// }
// if (!file_exists($filename)) {
// $this->halt("filename: file $filename does not exist.");
// }
return $filename;
}
Was the following code better and this part is.
function filename($filename) {
if ($this->debug & 4) {
echo "<p><b>filename:</b> filename = $filename</p>\n";
}
if (substr($filename, 0, 1) != "/"){
if (file_exists($this->root."/".$filename)) {
$filename = $this->root."/".$filename;
} else {
if (file_exists($this->base."/".$filename)) {
$filename = $this->base."/".$filename;
}
}
}
if ($this->debug & 4) {
echo "<p><b>real filename:</b> filename = $filename</p>\n";
}
if (!file_exists($filename)) {
$this->halt("filename: file $filename does not exist.");
}
return $filename;
}
At first, Geeklog processes functions.php.
set $_BASE_TEMPLATE
And execute functions.php in $_BASE_TEMPLATE .
Text Formatted Code
$_BASE_TEMPLATE = 'professional';
if(file_exists($_CONF['path_themes'] . $_BASE_TEMPLATE . '/functions.php'))
{
require_once( $_CONF['path_themes'] . $_BASE_TEMPLATE . '/functions.php' );
}
Next, when new of Template is executed, the following code is executed.
Text Formatted Code
function Template($root = ".", $unknowns = "remove") {
global $_BASE_TEMPLATE;
$this->set_base($_BASE_TEMPLATE);
if ($this->debug & 4) {
echo "<p><b>Template:</b> root = $root, unknowns = $unknowns</p>\n";
}
$this->set_root($root);
$this->set_unknowns($unknowns);
}
function set_root($root) {
global $_CONF;
if ($this->debug & 4) {
echo "<p><b>set_root:</b> root = $root</p>\n";
}
if (substr ($root, -1) == '/') {
$root = substr ($root, 0, -1);
}
if (!is_dir($root)) {
$root = str_replace($_CONF['path_layout'],$this->base .'/',$root);
if (!is_dir($root)) {
$this->halt("set_root: $root is not a directory.");
return false;
}
}
$this->root = $root;
return true;
}
Next, when set_file of Template is executed, the following code is executed.
Text Formatted Code
function filename($filename) {
if ($this->debug & 4) {
echo "<p><b>filename:</b> filename = $filename</p>\n";
}
if (substr($filename, 0, 1) != "/"){
if (file_exists($this->root."/".$filename)) {
$filename = $this->root."/".$filename;
} else {
if (file_exists($this->base."/".$filename)) {
$filename = $this->base."/".$filename;
}
}
}
if ($this->debug & 4) {
echo "<p><b>real filename:</b> filename = $filename</p>\n";
}
// if (substr($filename, 0, 1) != "/") {
// $filename = $this->root."/".$filename;
// }
// if (!file_exists($filename)) {
// $this->halt("filename: file $filename does not exist.");
// }
return $filename;
}
Was the following code better and this part is.
Text Formatted Code
function filename($filename) {
if ($this->debug & 4) {
echo "<p><b>filename:</b> filename = $filename</p>\n";
}
if (substr($filename, 0, 1) != "/"){
if (file_exists($this->root."/".$filename)) {
$filename = $this->root."/".$filename;
} else {
if (file_exists($this->base."/".$filename)) {
$filename = $this->base."/".$filename;
}
}
}
if ($this->debug & 4) {
echo "<p><b>real filename:</b> filename = $filename</p>\n";
}
if (!file_exists($filename)) {
$this->halt("filename: file $filename does not exist.");
}
return $filename;
}
7
10
Quote
All times are EST. The time is now 07:58 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content