Prechádzať zdrojové kódy

Fixed the page editor after recent page list gen changes

This part of the plugin hadn't been setup to handle the new paths that were being generated.
Belle Aerni 2 rokov pred
rodič
commit
a3039f10ed
1 zmenil súbory, kde vykonal 12 pridanie a 5 odobranie
  1. 12 5
      src/Plugins/Admin/AdminPlugin.php

+ 12 - 5
src/Plugins/Admin/AdminPlugin.php

@@ -150,18 +150,25 @@ class AdminPlugin extends AntPlugin
                 if (!isset($_POST['newpage'])) {
                 if (!isset($_POST['newpage'])) {
                     array_shift($route);
                     array_shift($route);
                     $pagePath = implode('/', $route);
                     $pagePath = implode('/', $route);
-                    $page = file_get_contents(antContentPath . '/' . $pagePath);
+                    $pagePath = AntTools::repairFilePath(antContentPath . '/' . $pagePath);
+
+                    if (empty($pagePath) || is_dir($pagePath)) {
+                        $pagePath .= '/index.md';
+                    }
+                    $pagePath = (file_exists($pagePath)) ? $pagePath : $pagePath . '.md';
+                    $pagePath = AntTools::repairFilePath($pagePath);
+
+                    $page = file_get_contents($pagePath);
                 } else {
                 } else {
                     $pagePath = '/' . $_POST['newpage'];
                     $pagePath = '/' . $_POST['newpage'];
+
                     if (!str_ends_with($pagePath, ".md")) {
                     if (!str_ends_with($pagePath, ".md")) {
                         $pagePath .= '.md';
                         $pagePath .= '.md';
                     }
                     }
-
+                    $pagePath = AntTools::repairFilePath($pagePath);
                     $page = "--AntCMS--\nTitle: New Page Title\nAuthor: Author\nDescription: Description of this page.\nKeywords: Keywords\n--AntCMS--\n";
                     $page = "--AntCMS--\nTitle: New Page Title\nAuthor: Author\nDescription: Description of this page.\nKeywords: Keywords\n--AntCMS--\n";
                 }
                 }
 
 
-                $pagePath = AntTools::repairFilePath($pagePath);
-
                 $HTMLTemplate = str_replace('<!--AntCMS-ActionURL-->', '//' . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/save/{$pagePath}", $HTMLTemplate);
                 $HTMLTemplate = str_replace('<!--AntCMS-ActionURL-->', '//' . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/save/{$pagePath}", $HTMLTemplate);
                 $HTMLTemplate = str_replace('<!--AntCMS-TextAreaContent-->', htmlspecialchars($page), $HTMLTemplate);
                 $HTMLTemplate = str_replace('<!--AntCMS-TextAreaContent-->', htmlspecialchars($page), $HTMLTemplate);
                 break;
                 break;
@@ -235,7 +242,7 @@ class AdminPlugin extends AntPlugin
                     $HTMLTemplate .= "<ul>\n";
                     $HTMLTemplate .= "<ul>\n";
                     $HTMLTemplate .= "<li>Full page path: " . $page['fullPagePath'] . "</li>\n";
                     $HTMLTemplate .= "<li>Full page path: " . $page['fullPagePath'] . "</li>\n";
                     $HTMLTemplate .= "<li>Functional page path: " . $page['functionalPagePath'] . "</li>\n";
                     $HTMLTemplate .= "<li>Functional page path: " . $page['functionalPagePath'] . "</li>\n";
-                    $HTMLTemplate .= "<li>Show in navbar: <a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/togglevisibility" . $page['functionalPagePath'] . "'>". $this->boolToWord($page['showInNav']) . "</a></li><br>\n";
+                    $HTMLTemplate .= "<li>Show in navbar: <a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/togglevisibility" . $page['functionalPagePath'] . "'>" . $this->boolToWord($page['showInNav']) . "</a></li><br>\n";
                     $HTMLTemplate .= "</ul>\n";
                     $HTMLTemplate .= "</ul>\n";
                     $HTMLTemplate .= "</li>\n";
                     $HTMLTemplate .= "</li>\n";
                 }
                 }