Browse Source

double slashes // support

master
filesite 3 years ago
parent
commit
45d8a86a19
  1. 12
      controller/Controller.php
  2. 5
      views/layout/main.php

12
controller/Controller.php

@ -25,8 +25,20 @@ Class Controller {
//render view //render view
protected function render($viewName, $viewData = array(), $pageTitle = '') { protected function render($viewName, $viewData = array(), $pageTitle = '') {
$layoutFile = __DIR__ . '/../views/layout/' . $this->layout . '.php'; $layoutFile = __DIR__ . '/../views/layout/' . $this->layout . '.php';
$viewFile = __DIR__ . '/../views/' . FSC::$app['controller'] . '/' . $viewName . '.php';
//双斜杠//开头的共享视图支持
if (preg_match('/^\/\//', $viewName)) {
$viewFile = __DIR__ . '/../views/' . str_replace('//', '/', $viewName) . '.php';
}
if (!empty(FSC::$app['config']['theme'])) { if (!empty(FSC::$app['config']['theme'])) {
$layoutFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/layout/' . $this->layout . '.php'; $layoutFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/layout/' . $this->layout . '.php';
$viewFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/' . FSC::$app['controller'] . '/' . $viewName . '.php';
//双斜杠//开头的共享视图支持
if (preg_match('/^\/\//', $viewName)) {
$viewFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/' .
str_replace('//', '/', $viewName) . '.php';
}
} }
//include layout and view //include layout and view

5
views/layout/main.php

@ -12,8 +12,9 @@
<?php <?php
//### Render view file //### Render view file
$viewFile = __DIR__ . '/../' . FSC::$app['controller'] . '/' . $viewName . '.php'; if (!empty($viewFile) && file_exists($viewFile)) {
include_once $viewFile; include_once $viewFile;
}
?> ?>
<div class="footer"> <div class="footer">

Loading…
Cancel
Save