From 330523e2b08287fe5e2ccbd18d2c95b5b5e8bb33 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Sun, 1 Jun 2014 18:24:50 +0200 Subject: [PATCH] Semantics. Refactorings. Make it PHP 5.3 compatible. --- src/_h5ai/client/js/inc/view/items.js | 8 ++--- src/_h5ai/conf/options.json | 44 +++++++++++++------------- src/_h5ai/server/php/inc/class-app.php | 17 +++++----- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/_h5ai/client/js/inc/view/items.js b/src/_h5ai/client/js/inc/view/items.js index 7d572c91..9fe17f10 100644 --- a/src/_h5ai/client/js/inc/view/items.js +++ b/src/_h5ai/client/js/inc/view/items.js @@ -2,10 +2,10 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core/format', 'core/event', 'core/location'], function (_, $, allsettings, resource, format, event, location) { var settings = _.extend({ - setParentFolderLabels: false, - hideParentFolderLinks: false, + binaryPrefix: false, hideFolders: false, - binaryPrefix: false + hideParentFolder: false, + setParentFolderLabels: false }, allsettings.view), itemTemplate = '
  • ' + @@ -96,7 +96,7 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core $items.find('.item').remove(); - if (item.parent && !settings.hideParentFolderLinks) { + if (item.parent && !settings.hideParentFolder) { $items.append(update(item.parent, true)); } diff --git a/src/_h5ai/conf/options.json b/src/_h5ai/conf/options.json index 1d1e0f1b..22e13cf0 100644 --- a/src/_h5ai/conf/options.json +++ b/src/_h5ai/conf/options.json @@ -10,55 +10,55 @@ Options Spacing of the main content. Left and right will be added to a minimum of 30px. Top and bottom - are calculated relative to the top and bottom bar heights. + are added to the top and bottom bar heights. */ "spacing": { - "maxWidth": 960, - "top": 50, - "right": "auto", "bottom": 50, - "left": "auto" + "left": "auto", + "maxWidth": 960, + "right": "auto", + "top": 50 }, /* General view options. + - binaryPrefix: set to true uses 1024B=1KiB when formatting file sizes (see http://en.wikipedia.org/wiki/Binary_prefix) + - extInNewWindow: open non-h5ai links in new window/tab + - hidden: don't list items matching these regular expressions + - hideFolders: hide all folders in the main view + - hideIf403: hide files and folders that are not readable by the server + - hideParentFolder: hide parent folder links in the main view + - indexFiles: consider folder with those files as non {{pkg.name}} folders - modes: array, subset of ["details", "grid", "icons"] the first value indicates the default view mode. If only one value is given the view mode is fixed and the selector buttons are hidden. The user selected view mode is also stored local in modern browsers so that it will be persistent. + - setParentFolderLabels: set parent folder labels to real folder names - sizes: array, subset of [16, 24, 32, 48, 64, 96, 128, 192, 256, 384] the first value indicates the default view mode. If only one value is given the view mode is fixed and the selector buttons are hidden. The user selected view mode is also stored local in modern browsers so that it will be persistent. - - setParentFolderLabels: set parent folder labels to real folder names - - hideParentFolderLinks: hide parent folder links in the main view - - hideFolders: hide all folders in the main view - - binaryPrefix: set to true uses 1024B=1KiB when formatting file sizes (see http://en.wikipedia.org/wiki/Binary_prefix) - - indexFiles: consider folder with those files as non {{pkg.name}} folders - - ignore: don't list items matching these regular expressions - smartBrowsing: use History API if available (no need to reload the whole page) - - extInNewWindow: open non-h5ai links in new window/tab - - hideIf403: hide files and folders that are not readable by the server - theme: name of one of the folders in "_h5ai/client/themes", defaults to "fallback" */ "view": { - "modes": ["details", "grid", "icons"], - "sizes": [48, 24, 96], - "setParentFolderLabels": true, - "hideParentFolderLinks": false, - "hideFolders": false, "binaryPrefix": false, - "indexFiles": ["index.html", "index.htm", "index.php"], - "ignore": ["^\\.", "^_{{pkg.name}}"], - "smartBrowsing": true, "extInNewWindow": false, + "hidden": ["^\\.", "^_{{pkg.name}}"], + "hideFolders": false, "hideIf403": true, - // "theme": "fallback" + "hideParentFolder": false, + "indexFiles": ["index.html", "index.htm", "index.php"], + "modes": ["details", "grid", "icons"], + "setParentFolderLabels": true, + "sizes": [48, 24, 96], + "smartBrowsing": true, "theme": "evolvere" // "theme": "faenza" + // "theme": "fallback" }, diff --git a/src/_h5ai/server/php/inc/class-app.php b/src/_h5ai/server/php/inc/class-app.php index 77376eb1..c6bee860 100644 --- a/src/_h5ai/server/php/inc/class-app.php +++ b/src/_h5ai/server/php/inc/class-app.php @@ -23,9 +23,10 @@ class App { public function get_setup() { - $consts = get_defined_constants(true)["user"]; - $consts["PHP_VERSION"] = PHP_VERSION; - return $consts; + $consts = get_defined_constants(true); + $consts_user = $consts["user"]; + $consts_user["PHP_VERSION"] = PHP_VERSION; + return $consts_user; } @@ -89,14 +90,14 @@ class App { } - public function is_ignored($name) { + public function is_hidden($name) { - // always ignore + // always hide if ($name === "." || $name === "..") { return true; } - foreach ($this->options["view"]["ignore"] as $re) { + foreach ($this->options["view"]["hidden"] as $re) { $re = App::$RE_DELIMITER . str_replace(App::$RE_DELIMITER, '\\' . App::$RE_DELIMITER, $re) . App::$RE_DELIMITER; if (preg_match($re, $name)) { return true; @@ -114,8 +115,8 @@ class App { if ($dir = opendir($path)) { while (($name = readdir($dir)) !== false) { if ( - $this->is_ignored($name) - || $this->is_ignored($this->to_url($path) . $name) + $this->is_hidden($name) + || $this->is_hidden($this->to_url($path) . $name) || (!is_readable($path .'/'. $name) && $this->options["view"]["hideIf403"]) ) { continue;