mirror of
https://github.com/jimeh/dlist.git
synced 2026-02-19 07:56:41 +00:00
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:
@@ -29,7 +29,7 @@ $config = array(
|
|||||||
|
|
||||||
// dList internal path settings
|
// dList internal path settings
|
||||||
|
|
||||||
'path_plugins' => array('plugins/*'),
|
'path_plugins' => array('plugins'),
|
||||||
'path_cache' => 'cache',
|
'path_cache' => 'cache',
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,52 @@ Author: Jim Myhrberg
|
|||||||
*/
|
*/
|
||||||
//_SCRIPT;
|
//_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
|
//>STAGE> init
|
||||||
//==========================
|
//==========================
|
||||||
@@ -27,40 +73,6 @@ define('ICONS_URL', DLIST_URL.ICONS_PATH);
|
|||||||
//>Section> load_config:35
|
//>Section> load_config:35
|
||||||
$config->parse(ICONS_PATH.'config.ini', true, 'icons_');
|
$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;
|
//_END;
|
||||||
?>
|
?>
|
||||||
@@ -26,6 +26,10 @@ Author: Jim Myhrberg
|
|||||||
|
|
||||||
//>Section> do_render:5
|
//>Section> do_render:5
|
||||||
if ( $do_render ) {
|
if ( $do_render ) {
|
||||||
|
|
||||||
|
//>Section> set_parent:10
|
||||||
|
$parent = $dlist->parent;
|
||||||
|
|
||||||
//>Section> do_render.end:95
|
//>Section> do_render.end:95
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ class dirList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ==============================================
|
// ==============================================
|
||||||
// ----- [ Internal Functions ] -----------------
|
// ----- [ Internal Functions ] -----------------
|
||||||
// ==============================================
|
// ==============================================
|
||||||
@@ -150,10 +149,9 @@ class dirList {
|
|||||||
$types = array('bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
|
$types = array('bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
|
||||||
for($n = 0; $bytes >= 1024; $n++) $bytes = $bytes / 1024;
|
for($n = 0; $bytes >= 1024; $n++) $bytes = $bytes / 1024;
|
||||||
$bytes = number_format($bytes, 2);
|
$bytes = number_format($bytes, 2);
|
||||||
if ( !empty($bytes[1]) ) {
|
if ( preg_match("/([0-9]+)\.([0-9]+)/", $bytes, $bytes) ) {
|
||||||
$bytes = explode('.', $bytes);
|
$bytes[2] = rtrim($bytes[2], '0');
|
||||||
$bytes[1] = rtrim($bytes[1], '0');
|
$bytes = ( !empty($bytes[2]) ) ? $bytes[1].'.'.$bytes[2] : $bytes[1] ;
|
||||||
$bytes = ( $bytes[1] != '' ) ? $bytes[0].'.'.$bytes[1] : $bytes[0] ;
|
|
||||||
}
|
}
|
||||||
return $bytes.' '.$types[$n];
|
return $bytes.' '.$types[$n];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
Copyright © 2006 Jim Myhrberg. All rights reserved.
|
||||||
zynode@gmail.com
|
zynode@gmail.com
|
||||||
@@ -31,17 +31,19 @@ class execHandler {
|
|||||||
// Execution Stage Priority
|
// Execution Stage Priority
|
||||||
|
|
||||||
var $default_stages = array(
|
var $default_stages = array(
|
||||||
'init' => 10,
|
'functions' => 5,
|
||||||
'query' => 20,
|
'init' => 10,
|
||||||
'main' => 50,
|
'query' => 20,
|
||||||
'render' => 80,
|
'main' => 50,
|
||||||
'term' => 90,
|
'render' => 80,
|
||||||
|
'term' => 90,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Debug?
|
// Debug?
|
||||||
|
|
||||||
var $debug = false;
|
var $debug = false;
|
||||||
|
var $show_debug_msg = true;
|
||||||
|
|
||||||
|
|
||||||
// Misc. Settings
|
// Misc. Settings
|
||||||
@@ -110,7 +112,7 @@ class execHandler {
|
|||||||
|
|
||||||
function cache ($force=false) {
|
function cache ($force=false) {
|
||||||
if ( $force || $this->debug || !$this->check_cache() ) {
|
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->loadFile($this->files_to_load);
|
||||||
$this->compile();
|
$this->compile();
|
||||||
$this->save_cache();
|
$this->save_cache();
|
||||||
@@ -124,9 +126,11 @@ class execHandler {
|
|||||||
} elseif( is_string($input) ) {
|
} elseif( is_string($input) ) {
|
||||||
$result = glob($input);
|
$result = glob($input);
|
||||||
}
|
}
|
||||||
$result = array_filter($result);
|
if ( !empty($result) ) {
|
||||||
if ( is_array($result) ) $result = array_unique($result);
|
$result = array_filter($result);
|
||||||
$this->files_to_load = array_merge($this->files_to_load, $result);
|
if ( is_array($result) ) $result = array_unique($result);
|
||||||
|
$this->files_to_load = array_merge($this->files_to_load, $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFile ($input) {
|
function loadFile ($input) {
|
||||||
|
|||||||
@@ -3,44 +3,48 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
<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">
|
<style type="text/css" media="screen">
|
||||||
/* <![CDATA[ */
|
/* <![CDATA[ */
|
||||||
|
<? include(TPL_PATH.'stylesheets/screen.css') ?>
|
||||||
<? include(TPL_PATH.'stylesheets/media.css') ?>
|
|
||||||
|
|
||||||
/* ]]> */
|
/* ]]> */
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body id="index">
|
<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>
|
<tr>
|
||||||
<th></th>
|
<th class="icon"></th>
|
||||||
<th>Name</th>
|
<th class="name">Name</th>
|
||||||
<th>Size</th>
|
<th class="size">Size</th>
|
||||||
<th>Date Modified</th>
|
<th class="mtime">Date Modified</th>
|
||||||
<th>Permissions</th>
|
<th class="perms">Permissions</th>
|
||||||
<th>Owner</th>
|
<th class="owner">Owner</th>
|
||||||
</tr>
|
</tr>
|
||||||
<? if (!empty($dlist->parent) || $dlist->parent != '/'): $parent = $dlist->parent; ?>
|
<? if (!empty($parent['name']) || $parent['name'] != '/'): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="<?=icons_get_parent('large')?>" class="" alt="" /></td>
|
<td class="icon"><a href="../" title="Parent Directory"><img src="<?=Icon::get_parent($config->tpl_icon_size)?>" class="" alt="" /></a></td>
|
||||||
<td><a href="../"><?=$parent['name']?></a></td>
|
<td class="name"><a href="../" title="Parent Directory">..</a></td>
|
||||||
<td><?=$parent['size']?></td>
|
<td class="size"><?=$parent['size']?></td>
|
||||||
<td><?=$parent['mtime']?></td>
|
<td class="mtime"><?=$parent['mtime']?></td>
|
||||||
<td><?=$parent['perms']?></td>
|
<td class="perms"><?=$parent['perms']?></td>
|
||||||
<td><?=$parent['owner']?></td>
|
<td class="owner"><?=$parent['owner']?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<? endif ?>
|
<? endif ?>
|
||||||
<? foreach ($dlist->list as $key => $item): ?>
|
<? foreach ($dlist->list as $key => $item): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="<?=icons_get_url($item['ext'], 'large', $item['type'])?>" class="" alt="" /></td>
|
<td class="icon">
|
||||||
<td><a href="<?=DIR_URL.$item['name']?><? if($item['type'] == 'dir') echo '/'; ?>"><?=$item['name']?></a></td>
|
<a href="<?=DIR_URL.$item['name']?><? if($item['type'] == 'dir') echo '/'; ?>" title="<?=$item['name']?>">
|
||||||
<td><?=$item['size']?></td>
|
<img src="<?=Icon::get_url($item['ext'], $config->tpl_icon_size, $item['type'])?>" class="" alt="" />
|
||||||
<td><?=$item['mtime']?></td>
|
</a>
|
||||||
<td><?=$item['perms']?></td>
|
</td>
|
||||||
<td><?=$item['owner']?></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>
|
</tr>
|
||||||
<? endforeach ?>
|
<? endforeach ?>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Author: Jim Myhrberg
|
|||||||
|
|
||||||
|
|
||||||
//>After> core.define_constants
|
//>After> core.define_constants
|
||||||
$config->parse(TPL_PATH.'settings.php');
|
$config->parse(TPL_PATH.'settings.php', true, 'tpl_');
|
||||||
|
|
||||||
|
|
||||||
//==========================
|
//==========================
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = array(
|
$config = array(
|
||||||
// 'key' => 'value
|
'icon_size' => 'small',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
BODY {
|
|
||||||
background-color: #FFF;
|
|
||||||
}
|
|
||||||
#list {
|
|
||||||
background-color: #666;
|
|
||||||
}
|
|
||||||
#list TH, #list TD {
|
|
||||||
background-color: #FFF;
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
74
templates/simple/stylesheets/screen.css
Normal file
74
templates/simple/stylesheets/screen.css
Normal 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;
|
||||||
|
}
|
||||||
5
view.php
5
view.php
@@ -30,6 +30,7 @@ if ($config->debug) $debug_timer = new speedometer();
|
|||||||
// initialize execHandler and main scripts
|
// initialize execHandler and main scripts
|
||||||
$exec = new execHandler();
|
$exec = new execHandler();
|
||||||
$exec->update_frequency = 0;
|
$exec->update_frequency = 0;
|
||||||
|
$exec->show_debug_msg = false;
|
||||||
|
|
||||||
|
|
||||||
// configure cache dir for compiled code
|
// configure cache dir for compiled code
|
||||||
@@ -46,7 +47,9 @@ $exec->addPath(
|
|||||||
'templates/'.$config->template.'/*.exc.php',
|
'templates/'.$config->template.'/*.exc.php',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$exec->addPath($config->path_plugins);
|
foreach( $config->path_plugins as $key => $value ) {
|
||||||
|
$exec->addPath($value.'/*.exc.php');
|
||||||
|
}
|
||||||
$exec->cache();
|
$exec->cache();
|
||||||
include($exec->include_file);
|
include($exec->include_file);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user