From e162c033928b122117089fccc695e4687d3e21ce Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Thu, 16 Nov 2017 23:22:55 +0100 Subject: [PATCH] improves on filesystem class --- .../admin/themes/default/css/default.css | 21 +++++-- bl-kernel/boot/init.php | 3 + bl-kernel/helpers/date.class.php | 2 +- bl-kernel/helpers/filesystem.class.php | 57 +++++++++++++++++-- bl-plugins/discovery/languages/de_CH.json | 11 ---- bl-plugins/discovery/languages/de_DE.json | 11 ---- bl-plugins/discovery/languages/es.json | 11 ---- bl-plugins/discovery/languages/fr_FR.json | 11 ---- bl-plugins/discovery/languages/ru_RU.json | 11 ---- 9 files changed, 71 insertions(+), 67 deletions(-) delete mode 100644 bl-plugins/discovery/languages/de_CH.json delete mode 100644 bl-plugins/discovery/languages/de_DE.json delete mode 100644 bl-plugins/discovery/languages/es.json delete mode 100644 bl-plugins/discovery/languages/fr_FR.json delete mode 100644 bl-plugins/discovery/languages/ru_RU.json diff --git a/bl-kernel/admin/themes/default/css/default.css b/bl-kernel/admin/themes/default/css/default.css index 4b987ab7..543c274a 100644 --- a/bl-kernel/admin/themes/default/css/default.css +++ b/bl-kernel/admin/themes/default/css/default.css @@ -687,12 +687,19 @@ div.plugin-links > span.separator { margin-left: 200px; border-radius: 2px; padding: 1px 20px; - border: 0; - box-shadow: inset 0 0 5px rgba(0,0,0,.05); - text-shadow: 0 -1px 0 rgba(0,0,0,.1); + border: 1px solid rgba(0,0,0,.06); + line-height: 28px; + min-height: 30px; + cursor: pointer; +} + +#jsformplugin button[type=submit].left { + margin: 0 5px 0 0; + border-radius: 2px; + padding: 1px 20px; + border: 1px solid rgba(0,0,0,.06); line-height: 28px; min-height: 30px; - font-size: 1rem; cursor: pointer; } @@ -704,7 +711,11 @@ div.plugin-links > span.separator { #jsformplugin button[type=submit].small { font-size: 0.9em; min-height: 20px; - background: #E6E6E6; + background: #f5f5f5; +} + +#jsformplugin button[type=submit].small:hover { + background: #f2f2f2; } #jsformplugin > div > label, diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 3f441c1a..dc9f4c0d 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -269,6 +269,7 @@ define('HTML_PATH_ADMIN_THEME_CSS', HTML_PATH_ADMIN_THEME.'css/'); define('HTML_PATH_ADMIN_THEME_IMG', HTML_PATH_ADMIN_THEME.'img/'); define('HTML_PATH_CORE_JS', HTML_PATH_ROOT.'bl-kernel/js/'); define('HTML_PATH_CORE_CSS', HTML_PATH_ROOT.'bl-kernel/css/'); +define('HTML_PATH_CONTENT', HTML_PATH_ROOT.'bl-content/'); define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'bl-content/uploads/'); define('HTML_PATH_UPLOADS_PROFILES', HTML_PATH_UPLOADS.'profiles/'); define('HTML_PATH_UPLOADS_THUMBNAILS', HTML_PATH_UPLOADS.'thumbnails/'); @@ -318,6 +319,8 @@ define('DOMAIN_THEME_IMG', DOMAIN.HTML_PATH_THEME_IMG); define('DOMAIN_UPLOADS', DOMAIN.HTML_PATH_UPLOADS); define('DOMAIN_UPLOADS_PROFILES', DOMAIN.HTML_PATH_UPLOADS_PROFILES); define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS); +define('DOMAIN_PLUGINS', DOMAIN.HTML_PATH_PLUGINS); +define('DOMAIN_CONTENT', DOMAIN.HTML_PATH_CONTENT); define('DOMAIN_ADMIN', DOMAIN_BASE.ADMIN_URI_FILTER); diff --git a/bl-kernel/helpers/date.class.php b/bl-kernel/helpers/date.class.php index b817c5c7..8d91ff62 100644 --- a/bl-kernel/helpers/date.class.php +++ b/bl-kernel/helpers/date.class.php @@ -28,7 +28,7 @@ class Date { // Returns a new DateTime instance or FALSE on failure. $Date = DateTime::createFromFormat($currentFormat, $date); - if($Date!==false) { + if ($Date!==false) { return $Date->format($outputFormat); } diff --git a/bl-kernel/helpers/filesystem.class.php b/bl-kernel/helpers/filesystem.class.php index 0913db35..3b2ecbad 100644 --- a/bl-kernel/helpers/filesystem.class.php +++ b/bl-kernel/helpers/filesystem.class.php @@ -22,11 +22,11 @@ class Filesystem { { $files = glob($path.$regex.'.'.$extension); - if(empty($files)) { + if (empty($files)) { return array(); } - if($sortByDate) { + if ($sortByDate) { usort($files, create_function('$a,$b', 'return filemtime($b) - filemtime($a);')); } @@ -64,26 +64,43 @@ class Filesystem { return file_exists($path); } + // Copy recursive a directory to another + // If the destination directory not exists is created + // $source = /home/diego/example or /home/diego/example/ + // $destination = /home/diego/newplace or /home/diego/newplace/ public static function copyRecursive($source, $destination) { + $source = rtrim($source, DS); + $destination = rtrim($destination, DS); + + // Check $source directory if exists if (!self::directoryExists($source)) { return false; } - $destination = rtrim($destination, '/'); + // Check $destionation directory if exists + if (!self::directoryExists($destination)) { + // Create the $destination directory + if (!mkdir($destination, 0755, true)) { + return false; + } + } - foreach($iterator = new RecursiveIteratorIterator( + foreach ($iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item) { - if($item->isDir()) { + if ($item->isDir()) { @mkdir($destination.DS.$iterator->getSubPathName()); } else { copy($item, $destination.DS.$iterator->getSubPathName()); } } + return true; } + // Delete a file or directory recursive + // The directory is delete public static function deleteRecursive($source) { if (!self::directoryExists($source)) { @@ -103,9 +120,16 @@ class Filesystem { return rmdir($source); } + // Compress a file or directory + // $source = /home/diego/example + // $destionation = /tmp/example.zip public static function zip($source, $destination) { - if (!extension_loaded('zip') || !file_exists($source)) { + if (!extension_loaded('zip')) { + return false; + } + + if (!file_exists($source)) { return false; } @@ -134,4 +158,25 @@ class Filesystem { return $zip->close(); } + // Uncompress a zip file + // $source = /home/diego/example.zip + // $destionation = /home/diego/content + public static function unzip($source, $destination) + { + if (!extension_loaded('zip')) { + return false; + } + + if (!file_exists($source)) { + return false; + } + + $zip = new ZipArchive(); + if (!$zip->open($source)) { + return false; + } + + $zip->extractTo($destination); + return $zip->close(); + } } \ No newline at end of file diff --git a/bl-plugins/discovery/languages/de_CH.json b/bl-plugins/discovery/languages/de_CH.json deleted file mode 100644 index 99b71854..00000000 --- a/bl-plugins/discovery/languages/de_CH.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugin-data": - { - "name": "API", - "description": "Schnittstelle, für den Datenaustausch mit Bludit über das HTTP-Protokoll. Informationen zur Verwendung des Plugins unter API Introduction." - }, - "api-token": "API-Token", - "amount-of-pages": "Anzahl Seiten", - "this-is-the-maximum-of-pages-to-return-when-you-call-to": "Maximum der Seiten bei einem Aufruf /api/pages.", - "this-token-is-for-read-only-and-is-regenerated-every-time-you-install-the-plugin": "Der Token kann für Leserechte verwendet werden. Er wird bei bei einer Neuinstallation des Plugins erneuert." -} diff --git a/bl-plugins/discovery/languages/de_DE.json b/bl-plugins/discovery/languages/de_DE.json deleted file mode 100644 index 99b71854..00000000 --- a/bl-plugins/discovery/languages/de_DE.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugin-data": - { - "name": "API", - "description": "Schnittstelle, für den Datenaustausch mit Bludit über das HTTP-Protokoll. Informationen zur Verwendung des Plugins unter API Introduction." - }, - "api-token": "API-Token", - "amount-of-pages": "Anzahl Seiten", - "this-is-the-maximum-of-pages-to-return-when-you-call-to": "Maximum der Seiten bei einem Aufruf /api/pages.", - "this-token-is-for-read-only-and-is-regenerated-every-time-you-install-the-plugin": "Der Token kann für Leserechte verwendet werden. Er wird bei bei einer Neuinstallation des Plugins erneuert." -} diff --git a/bl-plugins/discovery/languages/es.json b/bl-plugins/discovery/languages/es.json deleted file mode 100644 index 0bcb5085..00000000 --- a/bl-plugins/discovery/languages/es.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugin-data": - { - "name": "API", - "description": "Interfaz para interactuar con Bludit mediante el protocolo HTTP.
Leer más sobre este plugin en API introducción." - }, - "api-token": "API Token", - "amount-of-pages": "Cantidad de paginas", - "this-is-the-maximum-of-pages-to-return-when-you-call-to": "Este es el máximo de páginas a devolver cuando llame a /api/pages.", - "this-token-is-for-read-only-and-is-regenerated-every-time-you-install-the-plugin": "Este token es para sólo lectura y se regenera cada vez que se instala el plugin." -} \ No newline at end of file diff --git a/bl-plugins/discovery/languages/fr_FR.json b/bl-plugins/discovery/languages/fr_FR.json deleted file mode 100644 index eb8c7568..00000000 --- a/bl-plugins/discovery/languages/fr_FR.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugin-data": - { - "name": "API", - "description": "Interface pour interagir avec Bludit en utilisant le protocole HTTP.
En savoir plus sur ce plugin, en lisant l’introduction sur l’API." - }, - "api-token": "Jeton de l’API", - "amount-of-pages": "Nombre de pages", - "this-is-the-maximum-of-pages-to-return-when-you-call-to": "C’est le nombre maximal de pages à renvoyer lorsque vous appelez l’api par pages.", - "this-token-is-for-read-only-and-is-regenerated-every-time-you-install-the-plugin": "Ce jeton est en lecture seule et est régénéré à chaque fois que vous installez le plugin." -} \ No newline at end of file diff --git a/bl-plugins/discovery/languages/ru_RU.json b/bl-plugins/discovery/languages/ru_RU.json deleted file mode 100644 index 819ba33f..00000000 --- a/bl-plugins/discovery/languages/ru_RU.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugin-data": - { - "name": "API", - "description": "Интерфейс для взаимодействия с Bludit по HTTP-протоколу.
Узнать больше про этот плагин API Introduction." - }, - "api-token": "API Tтокен", - "amount-of-pages": "Количество страниц", - "this-is-the-maximum-of-pages-to-return-when-you-call-to": "Максимальное количество возвращаемых страниц при обращении к /api/pages", - "this-token-is-for-read-only-and-is-regenerated-every-time-you-install-the-plugin": "Данные токен используется только для чтения, он обновляется при каждой переустановке плагина" -}