From 8a5565c990db910864023e790ea730b35dbd37eb Mon Sep 17 00:00:00 2001 From: jim Date: Wed, 5 Apr 2006 18:24:54 +0000 Subject: [PATCH] - 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 --- config.php | 7 +++ exec/icons.exc.php | 1 + exec/language.exc.php | 25 ++++++++-- exec/output.exc.php | 38 +++++++++++++-- languages/english.lang.php | 2 + languages/swedish.lang.php | 2 + libs/dirlist.lib.php | 2 +- templates/simple/_details.phtml | 28 ++++------- templates/simple/_icons.phtml | 4 +- templates/simple/index.phtml | 7 +-- templates/simple/javascripts/main.js | 7 +++ templates/simple/render.exc.php | 5 ++ templates/simple/stylesheets/screen.css | 65 +++++++++++++++++++++---- view.php | 2 +- 14 files changed, 154 insertions(+), 41 deletions(-) diff --git a/config.php b/config.php index 25b0252..cb9e483 100644 --- a/config.php +++ b/config.php @@ -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, diff --git a/exec/icons.exc.php b/exec/icons.exc.php index 674f99f..77ab0c8 100644 --- a/exec/icons.exc.php +++ b/exec/icons.exc.php @@ -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; diff --git a/exec/language.exc.php b/exec/language.exc.php index bcc3b16..e2b85bd 100644 --- a/exec/language.exc.php +++ b/exec/language.exc.php @@ -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 //========================== diff --git a/exec/output.exc.php b/exec/output.exc.php index 4f67fe7..878697f 100644 --- a/exec/output.exc.php +++ b/exec/output.exc.php @@ -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) ? ''.$value.'/' : $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; ?> \ No newline at end of file diff --git a/languages/english.lang.php b/languages/english.lang.php index 21d63d6..155ca57 100644 --- a/languages/english.lang.php +++ b/languages/english.lang.php @@ -32,6 +32,8 @@ class lang { var $icons = 'Icons'; var $details = 'Details'; + var $powered_by = 'Powered by dList'; + // Smart Date var $sd_tomorrow = 'Tomorrow'; diff --git a/languages/swedish.lang.php b/languages/swedish.lang.php index 6c05b0d..c5d1555 100644 --- a/languages/swedish.lang.php +++ b/languages/swedish.lang.php @@ -32,6 +32,8 @@ class lang { var $icons = 'Ikoner'; var $details = 'Detaljer'; + var $powered_by = 'Driven av dList'; + // Smart Date var $sd_tomorrow = 'Imorgon'; diff --git a/libs/dirlist.lib.php b/libs/dirlist.lib.php index e2faac5..dc8a042 100644 --- a/libs/dirlist.lib.php +++ b/libs/dirlist.lib.php @@ -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', diff --git a/templates/simple/_details.phtml b/templates/simple/_details.phtml index 6a6c814..d8edc3f 100644 --- a/templates/simple/_details.phtml +++ b/templates/simple/_details.phtml @@ -1,34 +1,26 @@ - - - - - + $value): ?> + - - - - - + $value): + if ($key == 'name'):?> + + list as $key => $item): ?> - - - - - + $value): + if ($key == 'name'):?> +
name?>size?>mtime?>perms?>owner?>$key?>
..--..
- - - +
\ No newline at end of file diff --git a/templates/simple/_icons.phtml b/templates/simple/_icons.phtml index 36406d6..ce3172b 100644 --- a/templates/simple/_icons.phtml +++ b/templates/simple/_icons.phtml @@ -1,6 +1,8 @@
    diff --git a/templates/simple/index.phtml b/templates/simple/index.phtml index 04331a9..739d5ff 100644 --- a/templates/simple/index.phtml +++ b/templates/simple/index.phtml @@ -13,17 +13,18 @@
    tpl_mode) ?>
    -
    Powered by dList. end()?>.
    +
    powered_by?>. end()?>.
    +
    $value): ?>
    \ No newline at end of file diff --git a/templates/simple/javascripts/main.js b/templates/simple/javascripts/main.js index 9ced2a8..925ee03 100644 --- a/templates/simple/javascripts/main.js +++ b/templates/simple/javascripts/main.js @@ -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) { diff --git a/templates/simple/render.exc.php b/templates/simple/render.exc.php index e6d9f90..919330c 100644 --- a/templates/simple/render.exc.php +++ b/templates/simple/render.exc.php @@ -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'); diff --git a/templates/simple/stylesheets/screen.css b/templates/simple/stylesheets/screen.css index 7368f45..756b10a 100644 --- a/templates/simple/stylesheets/screen.css +++ b/templates/simple/stylesheets/screen.css @@ -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; -} \ No newline at end of file + 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; +} + + + + diff --git a/view.php b/view.php index d4bd4f5..d89af13 100644 --- a/view.php +++ b/view.php @@ -2,7 +2,7 @@ /* - dList v2.1.2 beta + dList v2.1.3 beta Copyright © 2006 Jim Myhrberg. All rights reserved. zynode@gmail.com