diff --git a/_diag_licenses.php b/_diag_licenses.php deleted file mode 100644 index d8f6d90..0000000 --- a/_diag_licenses.php +++ /dev/null @@ -1,49 +0,0 @@ - 'mysql', - 'database_name' => $database['name'], - 'server' => $database['host'], - 'username' => $database['user'], - 'password' => $database['password'], - 'charset' => 'utf8' -]); - -spl_autoload_register(function($classname) { - $q = explode('\\', $classname); - $c = array_pop($q); - $f = '../autoload/' . implode('/', $q) . '/class.' . $c . '.php'; - if (file_exists($f)) { require_once($f); return; } - $f = '../autoload/' . implode('/', $q) . '/' . $c . '.php'; - if (file_exists($f)) require_once($f); -}); - -// Render view (exactly like admin does) -$html = \admin\view\Releases::main_view(); - -// Find licenses table section in rendered HTML -$start = strpos($html, 'tab-licenses'); -$end = strpos($html, '', $start) + 8; -$section = substr($html, $start - 50, $end - $start + 50 + 100); - -header('Content-Type: text/plain'); -echo "=== FULL HTML SIZE: " . strlen($html) . " bytes ===\n\n"; -echo "=== LICENSES SECTION ===\n"; -echo $section . "\n\n"; - -// Count in licenses part -$lic_start = strpos($html, 'id="tab-licenses"'); -$lic_end = strpos($html, '', $lic_start + 100); -$lic_html = substr($html, $lic_start, $lic_end - $lic_start); -$tr_count = substr_count($lic_html, ''); -echo "=== TR COUNT in #tab-licenses: $tr_count ===\n"; -echo "=== TAB-LICENSES SNIPPET (first 500 chars) ===\n"; -echo substr($lic_html, 0, 500) . "\n"; diff --git a/admin/templates/releases/main-view.php b/admin/templates/releases/main-view.php index 27de6e6..fe29d08 100644 --- a/admin/templates/releases/main-view.php +++ b/admin/templates/releases/main-view.php @@ -26,6 +26,14 @@ ob_start();
+
+
+ +
+
@@ -298,6 +306,7 @@ $grid->gdb_opt = $gdb; $grid->include_plugins = true; $grid->title = 'Releases & Licencje'; $grid->default_buttons = false; +$grid->form = false; $grid->external_code = $out; echo $grid->draw(); ?> diff --git a/autoload/Shared/Tpl/Tpl.php b/autoload/Shared/Tpl/Tpl.php index 9d5109d..fca6415 100644 --- a/autoload/Shared/Tpl/Tpl.php +++ b/autoload/Shared/Tpl/Tpl.php @@ -68,6 +68,11 @@ class Tpl $this->vars[ $name ] = $value; } + public function __isset( $name ) + { + return isset( $this->vars[ $name ] ); + } + public function __get( $name ) { return $this->vars[ $name ]; diff --git a/autoload/admin/controls/class.Releases.php b/autoload/admin/controls/class.Releases.php index 7bda90e..46460f1 100644 --- a/autoload/admin/controls/class.Releases.php +++ b/autoload/admin/controls/class.Releases.php @@ -26,11 +26,19 @@ class Releases exit; } + public static function discover_versions(): void + { + $added = \admin\factory\Releases::discover_versions(); + \S::set_message("Wykryto i dodano {$added} nowych wersji jako stable."); + header('Location: /admin/releases/main_view/'); + exit; + } + public static function save_license(): void { \admin\factory\Releases::save_license($_POST); \S::set_message('Licencja została zapisana.'); - header('Location: /admin/releases/main_view/'); + header('Location: /admin/releases/main_view/#licenses'); exit; } @@ -39,7 +47,7 @@ class Releases $id = (int)\S::get('id'); if ($id) \admin\factory\Releases::delete_license($id); - header('Location: /admin/releases/main_view/'); + header('Location: /admin/releases/main_view/#licenses'); exit; } @@ -48,7 +56,7 @@ class Releases $id = (int)\S::get('id'); if ($id) \admin\factory\Releases::toggle_beta($id); - header('Location: /admin/releases/main_view/'); + header('Location: /admin/releases/main_view/#licenses'); exit; } } diff --git a/autoload/admin/factory/class.Releases.php b/autoload/admin/factory/class.Releases.php index 84dd6f2..950c473 100644 --- a/autoload/admin/factory/class.Releases.php +++ b/autoload/admin/factory/class.Releases.php @@ -31,6 +31,28 @@ class Releases ); } + public static function discover_versions(): int + { + global $mdb; + $known = array_flip($mdb->select('pp_update_versions', 'version', []) ?: []); + $zips = glob('../updates/*/ver_*.zip') ?: []; + $added = 0; + foreach ($zips as $path) { + preg_match('/ver_([0-9.]+)\.zip$/', $path, $m); + if (!$m) continue; + $ver = $m[1]; + if (isset($known[$ver])) continue; + $mdb->insert('pp_update_versions', [ + 'version' => $ver, + 'channel' => 'beta', + 'created_at' => date('Y-m-d H:i:s'), + ]); + $known[$ver] = true; + $added++; + } + return $added; + } + public static function get_licenses(): array { global $mdb;