implemented a functional template system, and a simple WORKING template, and other smaller things and fixes...

git-svn-id: file:///Users/jimeh/Desktop/dlist/trunk@10 a5845835-ea0f-0410-a762-dd0bfe9bfde8
This commit is contained in:
jim
2006-03-31 22:53:26 +00:00
parent f3a2a9e5b9
commit 05fc88b1d9
11 changed files with 178 additions and 89 deletions

View File

@@ -29,7 +29,7 @@ $config = array(
// dList internal path settings
'path_plugins' => array('plugins/*'),
'path_plugins' => array('plugins'),
'path_cache' => 'cache',

View File

@@ -15,6 +15,52 @@ Author: Jim Myhrberg
*/
//_SCRIPT;
//==========================
//>STAGE> functions
//==========================
//>Section> class.start
class Icon {
//>Section> get_url
function get_url ($ext, $size, $type) {
global $config;
if ( $size == 'large' || $size == 'big' ) {
$size = $config->icons_large;
} else {
$size = $config->icons_small;
}
$icons_path = ICONS_PATH.$size.'/';
$icons_url = ICONS_URL.$size.'/';
if ( $type == 'file' ) {
if ( file_exists($icons_path.$ext.$config->icons_ext) ) {
return $icons_url.$ext.$config->icons_ext;
} else {
return $icons_url.'_file'.$config->icons_ext;
}
} elseif ( $type == 'dir' || $type == 'folder' ) {
if ( file_exists($icons_path.'_folder.'.$ext.$config->icons_ext) ) {
return $icons_url.'_folder.'.$ext.$config->icons_ext;
} else {
return $icons_url.'_folder'.$config->icons_ext;
}
}
}
//>Section> get_parent
function get_parent ($size) {
global $config;
if ( $size == 'large' || $size == 'big' ) {
$size = $config->icons_large;
} else {
$size = $config->icons_small;
}
return ICONS_URL.$size.'/_parent'.$config->icons_ext;
}
//> class.end
}
//==========================
//>STAGE> init
//==========================
@@ -27,40 +73,6 @@ define('ICONS_URL', DLIST_URL.ICONS_PATH);
//>Section> load_config:35
$config->parse(ICONS_PATH.'config.ini', true, 'icons_');
//>Section> functions
function icons_get_url ($ext, $size, $type) {
global $config;
if ( $size == 'large' || $size == 'big' ) {
$size = $config->icons_large;
} else {
$size = $config->icons_small;
}
$icons_path = ICONS_PATH.$size.'/';
$icons_url = ICONS_URL.$size.'/';
if ( $type == 'file' ) {
if ( file_exists($icons_path.$ext.$config->icons_ext) ) {
return $icons_url.$ext.$config->icons_ext;
} else {
return $icons_url.'_file'.$config->icons_ext;
}
} elseif ( $type == 'dir' || $type == 'folder' ) {
if ( file_exists($icons_path.'_folder.'.$ext.$config->icons_ext) ) {
return $icons_url.'_folder.'.$ext.$config->icons_ext;
} else {
return $icons_url.'_folder'.$config->icons_ext;
}
}
}
function icons_get_parent ($size) {
global $config;
if ( $size == 'large' || $size == 'big' ) {
$size = $config->icons_large;
} else {
$size = $config->icons_small;
}
return ICONS_URL.$size.'/_parent'.$config->icons_ext;
}
//_END;
?>

View File

@@ -26,6 +26,10 @@ Author: Jim Myhrberg
//>Section> do_render:5
if ( $do_render ) {
//>Section> set_parent:10
$parent = $dlist->parent;
//>Section> do_render.end:95
}

View File

@@ -89,7 +89,6 @@ class dirList {
}
// ==============================================
// ----- [ Internal Functions ] -----------------
// ==============================================
@@ -150,10 +149,9 @@ class dirList {
$types = array('bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
for($n = 0; $bytes >= 1024; $n++) $bytes = $bytes / 1024;
$bytes = number_format($bytes, 2);
if ( !empty($bytes[1]) ) {
$bytes = explode('.', $bytes);
$bytes[1] = rtrim($bytes[1], '0');
$bytes = ( $bytes[1] != '' ) ? $bytes[0].'.'.$bytes[1] : $bytes[0] ;
if ( preg_match("/([0-9]+)\.([0-9]+)/", $bytes, $bytes) ) {
$bytes[2] = rtrim($bytes[2], '0');
$bytes = ( !empty($bytes[2]) ) ? $bytes[1].'.'.$bytes[2] : $bytes[1] ;
}
return $bytes.' '.$types[$n];
}

View File

@@ -4,7 +4,7 @@ class execHandler {
/*
Class: execHandler v0.7.3 beta
Class: execHandler v0.7.4 beta
Copyright © 2006 Jim Myhrberg. All rights reserved.
zynode@gmail.com
@@ -31,17 +31,19 @@ class execHandler {
// Execution Stage Priority
var $default_stages = array(
'init' => 10,
'query' => 20,
'main' => 50,
'render' => 80,
'term' => 90,
'functions' => 5,
'init' => 10,
'query' => 20,
'main' => 50,
'render' => 80,
'term' => 90,
);
// Debug?
var $debug = false;
var $debug = false;
var $show_debug_msg = true;
// Misc. Settings
@@ -110,7 +112,7 @@ class execHandler {
function cache ($force=false) {
if ( $force || $this->debug || !$this->check_cache() ) {
if ( $this->debug ) echo "reloading\n";
if ( $this->debug && $this->show_debug_msg ) echo "reloading\n";
$this->loadFile($this->files_to_load);
$this->compile();
$this->save_cache();
@@ -124,9 +126,11 @@ class execHandler {
} elseif( is_string($input) ) {
$result = glob($input);
}
$result = array_filter($result);
if ( is_array($result) ) $result = array_unique($result);
$this->files_to_load = array_merge($this->files_to_load, $result);
if ( !empty($result) ) {
$result = array_filter($result);
if ( is_array($result) ) $result = array_unique($result);
$this->files_to_load = array_merge($this->files_to_load, $result);
}
}
function loadFile ($input) {

View File

@@ -3,44 +3,48 @@
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Index of <?= DIR_URL ?></title>
<title>Index of <?=DIR_URL?></title>
<style type="text/css" media="screen">
/* <![CDATA[ */
<? include(TPL_PATH.'stylesheets/media.css') ?>
<? include(TPL_PATH.'stylesheets/screen.css') ?>
/* ]]> */
</style>
</head>
<body id="index">
<table border="0" cellspacing="1" cellpadding="3" id="list">
<div id="header">
Index of <?=DIR_URL?>
</div>
<table border="0" cellspacing="1" cellpadding="0" id="list">
<tr>
<th></th>
<th>Name</th>
<th>Size</th>
<th>Date Modified</th>
<th>Permissions</th>
<th>Owner</th>
<th class="icon"></th>
<th class="name">Name</th>
<th class="size">Size</th>
<th class="mtime">Date Modified</th>
<th class="perms">Permissions</th>
<th class="owner">Owner</th>
</tr>
<? if (!empty($dlist->parent) || $dlist->parent != '/'): $parent = $dlist->parent; ?>
<? if (!empty($parent['name']) || $parent['name'] != '/'): ?>
<tr>
<td><img src="<?=icons_get_parent('large')?>" class="" alt="" /></td>
<td><a href="../"><?=$parent['name']?></a></td>
<td><?=$parent['size']?></td>
<td><?=$parent['mtime']?></td>
<td><?=$parent['perms']?></td>
<td><?=$parent['owner']?></td>
<td class="icon"><a href="../" title="Parent Directory"><img src="<?=Icon::get_parent($config->tpl_icon_size)?>" class="" alt="" /></a></td>
<td class="name"><a href="../" title="Parent Directory">..</a></td>
<td class="size"><?=$parent['size']?></td>
<td class="mtime"><?=$parent['mtime']?></td>
<td class="perms"><?=$parent['perms']?></td>
<td class="owner"><?=$parent['owner']?></td>
</tr>
<? endif ?>
<? foreach ($dlist->list as $key => $item): ?>
<tr>
<td><img src="<?=icons_get_url($item['ext'], 'large', $item['type'])?>" class="" alt="" /></td>
<td><a href="<?=DIR_URL.$item['name']?><? if($item['type'] == 'dir') echo '/'; ?>"><?=$item['name']?></a></td>
<td><?=$item['size']?></td>
<td><?=$item['mtime']?></td>
<td><?=$item['perms']?></td>
<td><?=$item['owner']?></td>
<td class="icon">
<a href="<?=DIR_URL.$item['name']?><? if($item['type'] == 'dir') echo '/'; ?>" title="<?=$item['name']?>">
<img src="<?=Icon::get_url($item['ext'], $config->tpl_icon_size, $item['type'])?>" class="" alt="" />
</a>
</td>
<td class="name"><a href="<?=DIR_URL.$item['name']?><? if($item['type'] == 'dir') echo '/'; ?>"><?=$item['name']?></a></td>
<td class="size"><?=$item['size']?></td>
<td class="mtime"><?=$item['mtime']?></td>
<td class="perms"><?=$item['perms']?></td>
<td class="owner"><?=$item['owner']?></td>
</tr>
<? endforeach ?>
</table>

View File

@@ -21,7 +21,7 @@ Author: Jim Myhrberg
//>After> core.define_constants
$config->parse(TPL_PATH.'settings.php');
$config->parse(TPL_PATH.'settings.php', true, 'tpl_');
//==========================

View File

@@ -1,7 +1,7 @@
<?php
$config = array(
// 'key' => 'value
'icon_size' => 'small',
);
?>

View File

@@ -1,10 +0,0 @@
BODY {
background-color: #FFF;
}
#list {
background-color: #666;
}
#list TH, #list TD {
background-color: #FFF;
padding: 5px;
}

View File

@@ -0,0 +1,74 @@
BODY {
background-color: #FFF;
color: #000;
font: 11px "Lucida Grande", Tahoma, Verdana, sans-serif;
margin: 0xp;
padding: 18px;
}
#header {
font: 20px "Myriad Pro", "Trebuchet MS", Verdana, sans-serif;
padding: 15px 15px 20px 35px;
}
#list {
background-color: #777;
width: 100%;
}
/* List Headers */
#list TH {
background-color: #CCC;
padding: 2px 5px 2px 5px;
}
#list TH.name {
text-align: left;
}
#list TH.icon {
padding: 2px;
height: 16px;
width: 16px;
}
#list TH.size {
width: 75px;
}
#list TH.mtime {
width: 175px;
}
#list TH.perms {
width: 100px;
}
#list TH.owner {
width: 85px;
}
/* List Cells */
#list TD {
background-color: #FFF;
padding: 2px 5px 2px 5px;
}
#list TD.icon {
padding: 2px;
}
#list TD.size {
text-align: right;
}
#list TD.mtime {
text-align: right;
}
#list TD.perms {
}
#list TD.owner {
}
#list TD.name A {
width: 100%;
display: block;
}
#stats {
text-align: center;
padding: 10px;
}

View File

@@ -30,6 +30,7 @@ if ($config->debug) $debug_timer = new speedometer();
// initialize execHandler and main scripts
$exec = new execHandler();
$exec->update_frequency = 0;
$exec->show_debug_msg = false;
// configure cache dir for compiled code
@@ -46,7 +47,9 @@ $exec->addPath(
'templates/'.$config->template.'/*.exc.php',
)
);
$exec->addPath($config->path_plugins);
foreach( $config->path_plugins as $key => $value ) {
$exec->addPath($value.'/*.exc.php');
}
$exec->cache();
include($exec->include_file);