├── AssetLoader.php ├── LICENSE ├── README.md └── composer.json /AssetLoader.php: -------------------------------------------------------------------------------- 1 | 'vendor/fortawesome/font-awesome/webfonts', 7 | 'asset/css' => 'vendor/fortawesome/font-awesome/css/fontawesome.css' 8 | ]; 9 | 10 | public static function update(Composer\Script\Event $event) 11 | { 12 | $copy = in_array('copy-assets', $event->getArguments(), true); 13 | 14 | if (is_dir('asset')) { 15 | // Check for removed files 16 | $fs = new Composer\Util\Filesystem(); 17 | $assets = new RecursiveIteratorIterator(new RecursiveDirectoryIterator( 18 | 'asset', 19 | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS 20 | ), RecursiveIteratorIterator::CHILD_FIRST); 21 | foreach ($assets as $asset) { 22 | /** @var SplFileInfo $asset */ 23 | if ($asset->isDir()) { 24 | if ($fs->isDirEmpty($asset->getPathname())) { 25 | rmdir($asset); 26 | } 27 | } elseif (! $asset->isReadable()) { 28 | unlink($asset); 29 | } 30 | } 31 | } 32 | 33 | // Check for new files 34 | $vendorLibs = new FilesystemIterator('vendor/ipl'); 35 | foreach ($vendorLibs as $vendorLib) { 36 | /** @var SplFileInfo $vendorLib */ 37 | $assetDir = join(DIRECTORY_SEPARATOR, [$vendorLib->getRealPath(), 'asset']); 38 | if (is_readable($assetDir) && is_dir($assetDir)) { 39 | $libAssets = new RecursiveIteratorIterator(new RecursiveDirectoryIterator( 40 | $assetDir, 41 | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS 42 | ), RecursiveIteratorIterator::SELF_FIRST); 43 | foreach ($libAssets as $asset) { 44 | /** @var SplFileInfo $asset */ 45 | $relativePath = ltrim(substr($asset->getPathname(), strlen($vendorLib->getRealPath())), '/\\'); 46 | if (file_exists($relativePath)) { 47 | continue; 48 | } 49 | 50 | if ($asset->isDir()) { 51 | mkdir($relativePath, 0755, true); 52 | } elseif ($asset->isFile()) { 53 | if ($copy) { 54 | copy($asset->getPathname(), $relativePath); 55 | } else { 56 | symlink($asset->getPathname(), $relativePath); 57 | } 58 | } 59 | } 60 | } 61 | } 62 | 63 | // Register font-awesome files as assets 64 | foreach (static::$awesomeVendorFiles as $targetPath => $sourcePath) { 65 | $sourcePath = realpath($sourcePath); 66 | if (! $sourcePath) { 67 | continue; 68 | } 69 | 70 | if (is_dir($sourcePath)) { 71 | if (! is_dir($targetPath)) { 72 | mkdir($targetPath, 0755, true); 73 | } 74 | 75 | $awesomeFiles = new FilesystemIterator($sourcePath); 76 | } else { // is_file($sourcePath) 77 | $awesomeFiles = [new SplFileInfo($sourcePath)]; 78 | $sourcePath = $awesomeFiles[0]->getPath(); 79 | } 80 | 81 | foreach ($awesomeFiles as $awesomeFile) { 82 | /** @var SplFileInfo $awesomeFile */ 83 | $relativePath = join(DIRECTORY_SEPARATOR, [$targetPath, ltrim( 84 | substr($awesomeFile->getPathname(), strlen($sourcePath)), 85 | '/\\' 86 | )]); 87 | if (! file_exists($relativePath) && $awesomeFile->isFile()) { 88 | if ($copy) { 89 | copy($awesomeFile->getPathname(), $relativePath); 90 | } else { 91 | symlink($awesomeFile->getPathname(), $relativePath); 92 | } 93 | } 94 | } 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2018 Icinga GmbH https://www.icinga.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Icinga PHP Library - IPL 2 | 3 | This project bundles all Icinga PHP libraries into one piece and can be integrated as library into Icinga Web 2. 4 | 5 | ## Requirements 6 | 7 | * [Icinga Web 2](https://github.com/Icinga/icingaweb2) (>= 2.9) 8 | * PHP (>= 8.2) 9 | 10 | ## Bundled Parts 11 | 12 | * [ipl-html](https://github.com/Icinga/ipl-html) 13 | * [ipl-i18n](https://github.com/Icinga/ipl-i18n) 14 | * [ipl-orm](https://github.com/Icinga/ipl-orm) 15 | * [ipl-scheduler](https://github.com/Icinga/ipl-scheduler) 16 | * [ipl-sql](https://github.com/Icinga/ipl-sql) 17 | * [ipl-stdlib](https://github.com/Icinga/ipl-stdlib) 18 | * [ipl-validator](https://github.com/Icinga/ipl-validator) 19 | * [ipl-web](https://github.com/Icinga/ipl-web) 20 | 21 | ## Installation 22 | 23 | Please download the latest release and install it in one of your configured library paths. The default library 24 | path for Icinga Web 2 installations is: `/usr/share/icinga-php` 25 | 26 | Download or clone this repository there (e.g. `/usr/share/icinga-php/ipl`) and you're done. 27 | 28 | > **Note**: Do NOT use the default branch, it will not work! Checking out a 29 | > branch like `stable/0.16.0` or a tag like `v0.16.0` is fine. 30 | 31 | ### Examples 32 | 33 | **Sample Tarball installation** 34 | 35 | ```sh 36 | INSTALL_PATH="/usr/share/icinga-php/ipl" 37 | INSTALL_VERSION="v0.16.0" 38 | mkdir "$INSTALL_PATH" \ 39 | && wget -q "https://github.com/Icinga/icinga-php-library/archive/$INSTALL_VERSION.tar.gz" -O - \ 40 | | tar xfz - -C "$INSTALL_PATH" --strip-components 1 41 | ``` 42 | 43 | **Sample GIT installation** 44 | 45 | ``` 46 | INSTALL_PATH="/usr/share/icinga-php/ipl" 47 | INSTALL_VERSION="stable/0.16.0" 48 | git clone https://github.com/Icinga/icinga-php-library.git "$INSTALL_PATH" --branch "$INSTALL_VERSION" 49 | ``` 50 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "icinga/icinga-php-library", 3 | "type": "project", 4 | "description": "Icinga Web 2 - bundled Icinga PHP libraries", 5 | "homepage": "https://github.com/Icinga/icinga-php-library", 6 | "license": "MIT", 7 | "config": { 8 | "sort-packages": true, 9 | "platform": { 10 | "php": "8.2" 11 | } 12 | }, 13 | "require": { 14 | "php": ">=8.2", 15 | "ipl/html": "^0.8.0", 16 | "ipl/i18n": "^0.2.0", 17 | "ipl/orm": "^0.6.0", 18 | "ipl/scheduler": "^0.1.0", 19 | "ipl/sql": "^0.7.0", 20 | "ipl/stdlib": "^0.14.0", 21 | "ipl/validator": "^0.5.0", 22 | "ipl/web": "^0.11.0" 23 | }, 24 | "require-dev": { 25 | }, 26 | "autoload": { 27 | "psr-0": { "AssetLoader": "" } 28 | }, 29 | "scripts": { 30 | "post-update-cmd": [ 31 | "AssetLoader::update" 32 | ] 33 | } 34 | } 35 | --------------------------------------------------------------------------------