mirror of
https://github.com/jimeh/dlist.git
synced 2026-02-18 23:46:39 +00:00
- added language selection support to simple template, and the backend for it in language.exc.php
only need to get thumbnails working, and make a fully featured web 2.0/6.3/whatever template and dList should be ready for its initial public release. git-svn-id: file:///Users/jimeh/Desktop/dlist/trunk@14 a5845835-ea0f-0410-a762-dd0bfe9bfde8
This commit is contained in:
@@ -27,12 +27,19 @@ $config = array(
|
||||
# show hidden files & folders who's names begin with . (dot)
|
||||
'show_hidden' => false,
|
||||
|
||||
# what info to show for each file/folder, valid values are:
|
||||
# name, size, mtime, perms, chmod, owner, ownerid, group, groupid, ext
|
||||
'fields' => 'name,size,mtime,perms,owner',
|
||||
|
||||
// Display settings
|
||||
|
||||
# if the corresponding language file can't be found
|
||||
# dList will default to english.
|
||||
'language' => 'english',
|
||||
|
||||
# name of the cookie dList will check for language settings per user
|
||||
'lang_cookie' => 'dList_language',
|
||||
|
||||
# Smart Date shows relative time stamps ("Yesterday, 09:34") when applicable
|
||||
'smartdate' => true,
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class Icon {
|
||||
|
||||
//>Section> get_url
|
||||
function get_url ($ext, $size, $type) {
|
||||
//TODO enable thumbnail support using phpThumbs
|
||||
global $config;
|
||||
if ( $size == 'large' || $size == 'big' ) {
|
||||
$size = $config->icons_large;
|
||||
|
||||
@@ -15,20 +15,36 @@ Author: Jim Myhrberg
|
||||
*/
|
||||
//_SCRIPT;
|
||||
|
||||
//==========================
|
||||
//>STAGE> functions
|
||||
//==========================
|
||||
|
||||
|
||||
function installed_languages () {
|
||||
$return = glob('languages/*.lang.php');
|
||||
foreach( $return as $key => $value ) {
|
||||
$return[$key] = preg_replace("/languages\/(.*)\.lang\.php/", "$1", $value);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
//==========================
|
||||
//>STAGE> init
|
||||
//==========================
|
||||
|
||||
|
||||
//>Section> init:10
|
||||
if ( empty($config->language) ) $config->language = 'english';
|
||||
if ( is_readable('languages/'.$config->language.'.lang.php') ) {
|
||||
include('languages/'.$config->language.'.lang.php');
|
||||
if ( !empty($_REQUEST[$config->lang_cookie]) && is_readable('languages/'.$_REQUEST[$config->lang_cookie].'.lang.php')) {
|
||||
$language = $_REQUEST[$config->lang_cookie];
|
||||
} elseif ( is_readable('languages/'.$config->language.'.lang.php') ) {
|
||||
$language = $config->language;
|
||||
} elseif ( is_readable('languages/'.$config->default_lang.'.lang.php') ) {
|
||||
include('languages/'.$config->default_lang.'.lang.php');
|
||||
$language = $config->default_lang;
|
||||
} else {
|
||||
die("ERROR: Can't open language file.");
|
||||
}
|
||||
include('languages/'.$language.'.lang.php');
|
||||
|
||||
|
||||
//>Section> create_object:10
|
||||
@@ -58,7 +74,6 @@ setlocale(LC_ALL, array_merge($lang->_locale, $config->default_locale));
|
||||
define('LANG', $lang->_language);
|
||||
define('LANG_VER', $lang->_version);
|
||||
|
||||
|
||||
//==========================
|
||||
//>STAGE> main
|
||||
//==========================
|
||||
|
||||
@@ -19,11 +19,32 @@ Author: Jim Myhrberg
|
||||
//>STAGE> functions
|
||||
//==========================
|
||||
|
||||
//>Section> class_path.start
|
||||
class Path {
|
||||
|
||||
//>Section> path.url2links
|
||||
function url2links ($path, $root='') {
|
||||
if ( !empty($path) ) {
|
||||
$return = '';
|
||||
$previous = '';
|
||||
$path = str_replace("\\", '/', $path);
|
||||
$path = explode('/', rtrim($path, '/'));
|
||||
$last = count($path)-1;
|
||||
foreach( $path as $key => $value ) {
|
||||
$return .= ($key != $last) ? '<a href="'.$root.$previous.$value.'/">'.$value.'/</a>' : $value.'/';
|
||||
$previous .= $value.'/';
|
||||
}
|
||||
return $return;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
//>Section> path_class.end
|
||||
}
|
||||
|
||||
//>Section> sort_class.start
|
||||
//>Section> class_sort.start
|
||||
class Sort {
|
||||
|
||||
//>Section> get_url
|
||||
//>Section> sort.get_url
|
||||
function get_url ($sortby) {
|
||||
global $config;
|
||||
$return = array();
|
||||
@@ -84,11 +105,22 @@ $is_root = ( DIR_URL != '' && DIR_URL != '/' ) ? false : true;
|
||||
//>Section> do_render:5
|
||||
if ( $do_render ) {
|
||||
|
||||
//>Section> set_parent:10
|
||||
//>Section> set_vars:10
|
||||
$parent = $dlist->parent;
|
||||
if ( !empty($_REQUEST['sort']) && !empty($dlist->sort_order[strtolower($_REQUEST['sort'])]) ) {
|
||||
$current_sort = $_REQUEST['sort'];
|
||||
} else {
|
||||
$current_sort = $config->default_sort;
|
||||
}
|
||||
//>Section> set_fields:10
|
||||
$fields = explode(',', $config->fields);
|
||||
//foreach( $fields as $key => $value ) $fields[$key] = trim($value);
|
||||
$fields = array_flip(array_filter($fields));
|
||||
|
||||
|
||||
//>Section> do_render.end:95
|
||||
}
|
||||
|
||||
|
||||
//_END;
|
||||
?>
|
||||
@@ -32,6 +32,8 @@ class lang {
|
||||
var $icons = 'Icons';
|
||||
var $details = 'Details';
|
||||
|
||||
var $powered_by = 'Powered by dList';
|
||||
|
||||
|
||||
// Smart Date
|
||||
var $sd_tomorrow = 'Tomorrow';
|
||||
|
||||
@@ -32,6 +32,8 @@ class lang {
|
||||
var $icons = 'Ikoner';
|
||||
var $details = 'Detaljer';
|
||||
|
||||
var $powered_by = 'Driven av dList';
|
||||
|
||||
|
||||
// Smart Date
|
||||
var $sd_tomorrow = 'Imorgon';
|
||||
|
||||
@@ -53,7 +53,7 @@ class dirList {
|
||||
// incase it might do something in the future...
|
||||
function dirlist() {
|
||||
// sorting orders
|
||||
$this->sort_order = array(
|
||||
$this->sort_order = array(
|
||||
'name' => 'name,mtime,size',
|
||||
'size' => 'size,name,mtime',
|
||||
'mtime' => 'mtime,name,size',
|
||||
|
||||
@@ -1,34 +1,26 @@
|
||||
<table border="0" cellspacing="1" cellpadding="0" id="list">
|
||||
<tr>
|
||||
<th class="icon"></th>
|
||||
<th class="name"><a href="<?=Sort::get_url('name')?>"><?=$lang->name?></a></th>
|
||||
<th class="size"><a href="<?=Sort::get_url('size')?>"><?=$lang->size?></a></th>
|
||||
<th class="mtime"><a href="<?=Sort::get_url('mtime')?>"><?=$lang->mtime?></a></th>
|
||||
<th class="perms"><a href="<?=Sort::get_url('perms')?>"><?=$lang->perms?></a></th>
|
||||
<th class="owner"><a href="<?=Sort::get_url('owner')?>"><?=$lang->owner?></a></th>
|
||||
<? foreach ($fields as $key => $value): ?><th class="<?=$key?>"><a href="<?=Sort::get_url($key)?>"><?=$lang->$key?></a></th>
|
||||
<? endforeach ?>
|
||||
</tr>
|
||||
<? if ( !$is_root ): ?>
|
||||
<tr>
|
||||
<td class="icon"><a href="../" title="<?=$lang->parent_dir?>"><img src="<?=Icon::get_parent($config->tpl_icon_size)?>" class="" alt="" /></a></td>
|
||||
<td class="name"><a href="../" title="<?=$lang->parent_dir?>">..</a></td>
|
||||
<td class="size">-</td>
|
||||
<td class="mtime">-</td>
|
||||
<td class="perms"><?=$parent['perms']?></td>
|
||||
<td class="owner"><?=$parent['owner']?></td>
|
||||
<? foreach ($fields as $key => $value):
|
||||
if ($key == 'name'):?><td class="name"><a href="../" title="<?=$lang->parent_dir?>">..</a></td>
|
||||
<? else: ?><td></td><? endif ?>
|
||||
<? endforeach ?>
|
||||
</tr>
|
||||
<? endif ?>
|
||||
<? foreach ($dlist->list as $key => $item): ?>
|
||||
<tr>
|
||||
<td class="icon">
|
||||
<a href="<?=DIR_URL.$item['name']?><? if($item['type'] == 'dir') echo '/'; ?>" title="<?=$item['name']?>">
|
||||
<img src="<?=Icon::get_url($item['ext'], 'small', $item['type'])?>" class="" alt="" />
|
||||
</a>
|
||||
<a href="<?=DIR_URL.$item['name']?><? if($item['type'] == 'dir') echo '/'; ?>" title="<?=$item['name']?>"><img src="<?=Icon::get_url($item['ext'], 'small', $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>
|
||||
<? foreach ($fields as $key => $value):
|
||||
if ($key == 'name'):?><td class="name"><a href="<?=DIR_URL.$item['name']?><? if($item['type'] == 'dir') echo '/'; ?>"><?=$item['name']?></a></td>
|
||||
<? else: ?><td class="<?=$key?>"><?=$item[$key]?></td><? endif ?><? endforeach ?>
|
||||
</tr>
|
||||
<? endforeach ?>
|
||||
</table>
|
||||
@@ -1,6 +1,8 @@
|
||||
<table border="0" cellspacing="0" cellpadding="0" id="icons"><tr><td>
|
||||
<div id="sort-nav">
|
||||
<a href="<?=Sort::get_url('name')?>"><?=$lang->name?></a> | <a href="<?=Sort::get_url('size')?>"><?=$lang->size?></a> | <a href="<?=Sort::get_url('mtime')?>"><?=$lang->mtime?></a>
|
||||
<a href="<?=Sort::get_url('name')?>"<? if($current_sort == 'name'): ?> class="current"<? endif ?>><?=$lang->name?></a> |
|
||||
<a href="<?=Sort::get_url('size')?>"<? if($current_sort == 'size'): ?> class="current"<? endif ?>><?=$lang->size?></a> |
|
||||
<a href="<?=Sort::get_url('mtime')?>"<? if($current_sort == 'mtime'): ?> class="current"<? endif ?>><?=$lang->mtime?></a>
|
||||
</div>
|
||||
<ul>
|
||||
<? if ( !$is_root ): ?>
|
||||
|
||||
@@ -13,17 +13,18 @@
|
||||
</head>
|
||||
<body id="index">
|
||||
<div id="header">
|
||||
<?=$lang->index_of.' '.DIR_URL?>
|
||||
<?=$lang->index_of.' '.Path::url2links(DIR_URL)?>
|
||||
</div>
|
||||
<div id="view-nav">
|
||||
<a href="javascript:;" onclick="set_view('icons')"><?=$lang->icons?></a> | <a href="javascript:;" onclick="set_view('details')"><?=$lang->details?></a>
|
||||
<a href="javascript:;" onclick="set_view('icons');"><?=$lang->icons?></a> | <a href="javascript:;" onclick="set_view('details');"><?=$lang->details?></a>
|
||||
</div>
|
||||
<div id="server-info"><?=SERVER_INFO?></div>
|
||||
<div id="files">
|
||||
<? include(TPL_PATH.$config->tpl_mode) ?>
|
||||
</div>
|
||||
<div id="stats">
|
||||
<div id="timer">Powered by dList. <?=$timer->end()?>.</div>
|
||||
<div id="timer"><?=$lang->powered_by?>. <?=$timer->end()?>.</div>
|
||||
<div id="lang-select"><? foreach ($installed_languages as $key => $value): ?><a href="javascript:;" onclick="set_lang('<?=$value?>')"><?=ucfirst($value)?></a><? if(count($installed_languages)-1 != $key) echo ' | '; endforeach ?></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -6,6 +6,13 @@ function set_view (view) {
|
||||
}
|
||||
}
|
||||
|
||||
function set_lang (lang) {
|
||||
if (lang != readCookie('dList_language')) {
|
||||
createCookie('dList_language', lang, 365);
|
||||
document.location.href = '';
|
||||
}
|
||||
}
|
||||
|
||||
/* Cookie Related Functions */
|
||||
function createCookie(name,value,days) {
|
||||
if (days) {
|
||||
|
||||
@@ -35,6 +35,11 @@ if ( !empty($_COOKIE['dList_simple_viewMode']) && !empty($config->tpl_modes[$_CO
|
||||
$config->tpl_mode = $config->tpl_modes[$config->tpl_mode];
|
||||
}
|
||||
|
||||
|
||||
//>Section> installed_languages
|
||||
$installed_languages = installed_languages();
|
||||
|
||||
|
||||
//>Section> include_phtml
|
||||
include(TPL_PATH.'index.phtml');
|
||||
|
||||
|
||||
@@ -10,6 +10,13 @@ BODY {
|
||||
font: 20px "Myriad Pro", "Trebuchet MS", Verdana, sans-serif;
|
||||
padding: 15px 15px 30px 30px;
|
||||
}
|
||||
#header A {
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
}
|
||||
#header A:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#files {
|
||||
|
||||
@@ -39,7 +46,7 @@ BODY {
|
||||
width: 75px;
|
||||
}
|
||||
#list TH.mtime {
|
||||
width: 175px;
|
||||
width: 170px;
|
||||
}
|
||||
#list TH.perms {
|
||||
width: 100px;
|
||||
@@ -48,8 +55,10 @@ BODY {
|
||||
width: 85px;
|
||||
}
|
||||
#list TH A {
|
||||
width: 100%;
|
||||
color: #000;
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* list cells */
|
||||
@@ -67,14 +76,22 @@ BODY {
|
||||
text-align: right;
|
||||
}
|
||||
#list TD.perms {
|
||||
|
||||
text-align: right;
|
||||
}
|
||||
#list TD.owner {
|
||||
|
||||
text-align: right;
|
||||
}
|
||||
#list TD.name A {
|
||||
width: 100%;
|
||||
color: #000;
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-decoration: none;
|
||||
}
|
||||
#list TD.name A:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#list TD.name A:visited {
|
||||
color: #555;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +103,7 @@ BODY {
|
||||
#icons UL {
|
||||
list-style: none;
|
||||
margin-top: 5px;
|
||||
padding: 10px;
|
||||
}
|
||||
#icons UL A {
|
||||
color: #000;
|
||||
@@ -113,12 +131,21 @@ BODY {
|
||||
font-size: 10px;
|
||||
margin: 0px;
|
||||
}
|
||||
#icons #sort-nav {
|
||||
#sort-nav {
|
||||
color: #999;
|
||||
text-align: center;
|
||||
margin: 20px 20px 0px 20px;
|
||||
}
|
||||
|
||||
|
||||
#sort-nav A {
|
||||
color: #777;
|
||||
text-decoration: none;
|
||||
}
|
||||
#sort-nav A:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#sort-nav A.current {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
/* misc. */
|
||||
@@ -156,4 +183,24 @@ BODY {
|
||||
font-style: italic;
|
||||
font-size: 9px;
|
||||
text-align: left;
|
||||
}
|
||||
float: left;
|
||||
}
|
||||
|
||||
#lang-select {
|
||||
color: #BBB;
|
||||
padding: 3px;
|
||||
font-style: italic;
|
||||
font-size: 9px;
|
||||
float: right;
|
||||
}
|
||||
#lang-select A {
|
||||
color: #BBB;
|
||||
text-decoration: none;
|
||||
}
|
||||
#lang-select A:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user