| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- class FoldersConfig {
- function getNfsOsPath() {
- if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mac')) {
- return 'afp:';
- }
- return 'file:';
- }
- public static function getRawData() {
- static $_data;
- if (!is_array($_data)) {
- $_data = array();
- $_data = Config::getConfFile('folders');
- }
- return $_data;
- }
- public static function getRootPoints() {
- $data = self::getRawData();
- $rootData = V::get('root_points', null, $data);
- if (!$rootData) {
- error_log('Error: Brak konfiguracji FOLDERS! (root_points)');
- die('Error: Brak konfiguracji FOLDERS! (root_points)');
- }
- return $rootData;
- }
- public static function getRootPoint($key) {
- $data = self::getRawData();
- $rootData = V::get('root_points', null, $data);
- if (!$rootData) {
- error_log('Error: Brak konfiguracji FOLDERS! (root_point)');
- die('Error: Brak konfiguracji FOLDERS! (root_point)');
- }
- $rootValue = V::get($key, '', $rootData);
- return $rootValue;
- }
- public static function get($col_name, $key) {
- $retValue = array();
- $data = self::getRawData();
- $colData = V::get($col_name, null, $data);
- if (!$colData) {
- error_log('Error: Brak konfiguracji FOLDERS! ('.$col_name.')');
- die('Error: Brak konfiguracji FOLDERS! ('.$col_name.')');
- }
- $retValue = V::get($key, '', $colData);
- if (substr($key, -6) == '_point') {
- $rootData = V::get('root_points', null, $data);
- if (!$rootData) {
- error_log('Error: Brak konfiguracji FOLDERS! (root_points)');
- die('Error: Brak konfiguracji FOLDERS! (root_points)');
- }
- if (substr($retValue, 0, 1) != '/') {// relative path
- $rootValue = V::get($key, '', $rootData);
- if (!empty($rootValue)) {
- $retValue = rtrim($rootValue, '/') . '/' . ltrim($retValue, '/');
- }
- }
- }
- return $retValue;
- }
- public static function hasConfig($col_name) {
- $data = self::getRawData();
- $colData = V::get($col_name, null, $data);
- if (!$colData) {
- return false;
- }
- return true;
- }
- public static function getAll($col_name) {
- $colData = array();
- $data = self::getRawData();
- $colData = V::get($col_name, null, $data);
- if (!$colData) {
- error_log('Error: Brak konfiguracji FOLDERS! ('.$col_name.')');
- die('Error: Brak konfiguracji FOLDERS! ('.$col_name.')');
- }
- $rootData = V::get('root_points', null, $data);
- if (!$rootData) {
- die('Error: Brak konfiguracji FOLDERS! (root_points)');
- }
- foreach ($rootData as $key => $val) {
- if (array_key_exists($key, $colData)) {
- if (substr($colData[$key], 0, 1) != '/') {// relative path
- if (!empty($val)) {
- $colData[$key] = rtrim($val, '/') . '/' . ltrim($colData[$key], '/');
- }
- }
- }
- }
- return $colData;
- }
- }
|