1<?php 2/** 3 * Distribution Creator for Delete Page Guard Plugin 4 * 5 * Creates a distribution directory for DokuWiki plugin installation. 6 * You can manually ZIP this directory later for upload. 7 * 8 * @license GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) 9 * @author Johann Duscher <jonny.dee@posteo.net> 10 */ 11 12// Change to project root directory 13chdir(__DIR__ . '/..'); 14 15// Load version information 16$version_info = include 'version.php'; 17$version = $version_info['version']; 18$distDir = 'dist/deletepageguard-' . $version; 19$pluginDirName = 'deletepageguard'; // Must match 'base' in plugin.info.txt 20 21echo "Creating distribution package for version $version...\n"; 22 23// Files and directories to include 24$files = [ 25 'action.php', 26 'admin.php', 27 'plugin.info.txt', 28 'LICENSE.md', 29 'README.md', 30 'CHANGELOG.md', 31 'conf/', 32 'lang/' 33]; 34 35// Create dist directory structure 36$targetDir = $distDir . '/' . $pluginDirName; 37if (!is_dir($targetDir)) { 38 mkdir($targetDir, 0755, true); 39} 40 41// Copy files to distribution directory 42function copyFileOrDir($source, $dest) { 43 // Normalize paths for Windows 44 $source = rtrim(str_replace('\\', '/', $source), '/'); 45 $dest = rtrim(str_replace('\\', '/', $dest), '/'); 46 47 if (is_file($source)) { 48 $destDir = dirname($dest); 49 if (!is_dir($destDir)) { 50 mkdir($destDir, 0755, true); 51 } 52 copy($source, $dest); 53 return true; 54 } elseif (is_dir($source)) { 55 if (!is_dir($dest)) { 56 mkdir($dest, 0755, true); 57 } 58 59 $sourceLen = strlen($source); 60 $iterator = new RecursiveIteratorIterator( 61 new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), 62 RecursiveIteratorIterator::SELF_FIRST 63 ); 64 65 foreach ($iterator as $fileObj) { 66 // Normalize and get relative path 67 $currentPath = str_replace('\\', '/', $fileObj->getPathname()); 68 $relativePath = substr($currentPath, $sourceLen + 1); 69 $destPath = $dest . '/' . $relativePath; 70 71 if ($fileObj->isDir()) { 72 if (!is_dir($destPath)) { 73 mkdir($destPath, 0755, true); 74 } 75 } elseif ($fileObj->isFile()) { 76 $destDir = dirname($destPath); 77 if (!is_dir($destDir)) { 78 mkdir($destDir, 0755, true); 79 } 80 copy($currentPath, $destPath); 81 } 82 } 83 return true; 84 } 85 return false; 86} 87 88// Copy all files 89$fileCount = 0; 90foreach ($files as $file) { 91 if (!file_exists($file)) { 92 echo "⚠ Warning: File not found: $file\n"; 93 continue; 94 } 95 96 $destPath = $targetDir . '/' . $file; 97 if (copyFileOrDir($file, $destPath)) { 98 echo "✓ Copied: $file\n"; 99 $fileCount++; 100 } 101} 102 103echo "\n✅ Successfully created distribution directory!\n"; 104echo " Location: $distDir/\n"; 105echo " Plugin directory: $pluginDirName/\n"; 106echo " Files copied: $fileCount\n"; 107 108echo "\n Next steps:\n"; 109echo " 1. Review the contents in: $distDir/\n"; 110echo " 2. Create ZIP file manually:\n"; 111echo " cd dist && zip -r deletepageguard-$version.zip deletepageguard-$version/\n"; 112echo " 3. Upload to GitHub Release or DokuWiki Extension Manager\n"; 113