aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-11-11 18:37:36 +0100
committervincent-peugnet <v.peugnet@free.fr>2018-11-11 18:37:36 +0100
commit45903fe3960b65d63f70188640630c895dbbe222 (patch)
treeba0b0f9ba0615cd46214eeab236031c062664d6d /app
parentd7f3313ff4514e38c9f53439cd1a1287e56e45f7 (diff)
downloadwcms-45903fe3960b65d63f70188640630c895dbbe222.tar.gz
wcms-45903fe3960b65d63f70188640630c895dbbe222.zip
cleaning
Diffstat (limited to 'app')
-rw-r--r--app/class/application.php8
-rw-r--r--app/class/config.php16
-rw-r--r--app/class/configtest.php22
-rw-r--r--app/class/controller.php7
-rw-r--r--app/class/controlleradmin.php7
-rw-r--r--app/class/controllerart.php6
-rw-r--r--app/class/controllerdb.php45
-rw-r--r--app/class/controllerhome.php6
-rw-r--r--app/class/controllermedia.php4
-rw-r--r--app/class/launcher.php20
-rw-r--r--app/class/model.php7
-rw-r--r--app/class/modeldb.php2
-rw-r--r--app/class/modelrender.php12
-rw-r--r--app/class/routes.php6
-rw-r--r--app/fn/fn.php43
-rw-r--r--app/view/templates/navart.php4
-rw-r--r--app/view/templates/readart.php25
17 files changed, 44 insertions, 196 deletions
diff --git a/app/class/application.php b/app/class/application.php
index 2872695..79e9563 100644
--- a/app/class/application.php
+++ b/app/class/application.php
@@ -19,9 +19,9 @@ class Application
}
} else {
if(Config::readconfig()) {
- if(!Config::checkcmspath() || empty(Config::admin()) || empty(Config::arttable())) {
+ if(!Config::checkbasepath() || empty(Config::admin()) || empty(Config::arttable())) {
echo '<ul>';
- if(!Config::checkcmspath()) {
+ if(!Config::checkbasepath()) {
echo '<li>Wrong path</li>';
}
if(empty(Config::admin())) {
@@ -49,9 +49,9 @@ class Application
<form action="" method="post">
<div>
<h2>
- <label for="cmspath">Path to W-CMS</label>
+ <label for="basepath">Path to W-CMS</label>
</h2>
- <input type="text" name="configinit[cmspath]" value="<?= Config::cmspath() ?>" id="cmspath">
+ <input type="text" name="configinit[basepath]" value="<?= Config::basepath() ?>" id="basepath">
<p><i>Leave it empty if W-CMS is in your root folder, otherwise, indicate the subfolder(s) in witch you installed the CMS</i></p>
</div>
<div>
diff --git a/app/class/config.php b/app/class/config.php
index 7f18166..495c008 100644
--- a/app/class/config.php
+++ b/app/class/config.php
@@ -11,8 +11,8 @@ abstract class Config
protected static $invite;
protected static $read;
protected static $color4;
- protected static $fontsize = 6;
- protected static $cmspath = '';
+ protected static $fontsize = 15;
+ protected static $basepath = '';
// _______________________________________ F U N _______________________________________
@@ -61,9 +61,9 @@ abstract class Config
return $json;
}
- public static function checkcmspath()
+ public static function checkbasepath()
{
- $path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . self::cmspath() . 'w' . DIRECTORY_SEPARATOR . 'w.config.json';
+ $path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . self::basepath() . Model::CONFIG_FILE;
return (file_exists($path));
}
@@ -109,9 +109,9 @@ abstract class Config
return self::$fontsize;
}
- public static function cmspath()
+ public static function basepath()
{
- return self::$cmspath;
+ return self::$basepath;
}
@@ -165,9 +165,9 @@ abstract class Config
}
}
- public static function setcmspath($cmspath)
+ public static function setbasepath($basepath)
{
- self::$cmspath = strip_tags($cmspath);
+ self::$basepath = strip_tags($basepath);
}
diff --git a/app/class/configtest.php b/app/class/configtest.php
deleted file mode 100644
index cd72753..0000000
--- a/app/class/configtest.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-abstract class Configtest
-{
- protected static $info;
-
- public static function setinfo($info)
- {
- self::$info = $info;
- }
-
- public static function info()
- {
- return self::$info;
- }
-}
-
-
-
-
-
-?> \ No newline at end of file
diff --git a/app/class/controller.php b/app/class/controller.php
index c97c99f..c8c620e 100644
--- a/app/class/controller.php
+++ b/app/class/controller.php
@@ -4,11 +4,13 @@ class Controller
{
protected $user;
+ protected $router;
protected $usermanager;
protected $plates;
- public function __construct() {
- $this->setuser();
+ public function __construct($router) {
+ $this->setuser();
+ $this->router = $router;
$this->initplates();
$this->initconfig();
}
@@ -49,6 +51,7 @@ class Controller
public function commonsparams()
{
$commonsparams = [];
+ $commonsparams['router'] = $this->router;
$commonsparams['user'] = $this->user;
return $commonsparams;
}
diff --git a/app/class/controlleradmin.php b/app/class/controlleradmin.php
index 42a0f65..62c8fba 100644
--- a/app/class/controlleradmin.php
+++ b/app/class/controlleradmin.php
@@ -1,6 +1,6 @@
<?php
-class Controlleradmin extends Controllerdb
+class Controlleradmin extends Controller
{
public function desktop()
@@ -13,12 +13,7 @@ class Controlleradmin extends Controllerdb
}
-
- public function duplicatetable()
- {
-
- }
}
diff --git a/app/class/controllerart.php b/app/class/controllerart.php
index 334f550..9143375 100644
--- a/app/class/controllerart.php
+++ b/app/class/controllerart.php
@@ -1,15 +1,15 @@
<?php
-class Controllerart extends Controllerdb
+class Controllerart extends Controller
{
/** @var Art2 */
protected $art;
protected $artmanager;
protected $renderengine;
- public function __construct()
+ public function __construct($router)
{
- parent::__construct();
+ parent::__construct($router);
$this->artmanager = new Modelart();
$this->renderengine = new Modelrender();
diff --git a/app/class/controllerdb.php b/app/class/controllerdb.php
deleted file mode 100644
index 54a9de1..0000000
--- a/app/class/controllerdb.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-class Controllerdb extends Controller
-{
-
- protected $artmanager;
- protected $database;
- protected $artstore;
-
-
- public function __construct()
- {
- parent::__construct();
-
-
- }
-
-
-
-
- // if (isset($_POST['actiondb'])) {
- // $app->setbdd($config);
-
- // switch ($_POST['actiondb']) {
-
- // case 'addtable':
- // if (isset($_POST['tablename'])) {
- // $message = Modeldb::addtable($config->dbname(), $_POST['tablename']);
- // header('Location: ./?aff=admin&message=' . $message);
- // }
- // break;
-
- // case 'duplicatetable':
- // $message = Modeldb::tableduplicate($config->dbname(), $_POST['arttable'], $_POST['tablename']);
- // header('Location: ./?aff=admin&message=' . $message);
- // break;
-
- // }
- // }
-}
-
-
-
-
-?> \ No newline at end of file
diff --git a/app/class/controllerhome.php b/app/class/controllerhome.php
index 31d27c3..4d5feb8 100644
--- a/app/class/controllerhome.php
+++ b/app/class/controllerhome.php
@@ -1,13 +1,13 @@
<?php
-class Controllerhome extends Controllerdb
+class Controllerhome extends Controller
{
protected $modelhome;
protected $opt;
- public function __construct() {
- parent::__construct();
+ public function __construct($render) {
+ parent::__construct($render);
$this->modelhome = new Modelhome;
}
diff --git a/app/class/controllermedia.php b/app/class/controllermedia.php
index 6bd22cd..75540e2 100644
--- a/app/class/controllermedia.php
+++ b/app/class/controllermedia.php
@@ -5,8 +5,8 @@ class Controllermedia extends Controller
protected $medialist;
protected $mediamanager;
- public function __construct() {
- parent::__construct();
+ public function __construct($render) {
+ parent::__construct($render);
$this->mediamanager = new Modelmedia;
diff --git a/app/class/launcher.php b/app/class/launcher.php
deleted file mode 100644
index de97462..0000000
--- a/app/class/launcher.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-class Launcher
-{
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-?> \ No newline at end of file
diff --git a/app/class/model.php b/app/class/model.php
index d037aba..3f4be4a 100644
--- a/app/class/model.php
+++ b/app/class/model.php
@@ -2,11 +2,12 @@
class Model
{
- const CONFIG_FILE = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'w.config.json';
+ const CONFIG_FILE = 'config.json';
const GLOBAL_CSS_DIR = '.' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'global' . DIRECTORY_SEPARATOR . 'global.css';
const MEDIA_DIR = '.' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR;
- const TEMPLATES_DIR = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'templates';
- const RENDER_DIR = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '/w_render/';
+ const TEMPLATES_DIR = '.'. DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
+ const RENDER_DIR = '.'. DIRECTORY_SEPARATOR . 'assets'. DIRECTORY_SEPARATOR . 'render' . DIRECTORY_SEPARATOR;
+ const DATABASE_DIR = '.' . DIRECTORY_SEPARATOR . 'database' . DIRECTORY_SEPARATOR;
const MEDIA_EXTENSIONS = array('jpeg', 'jpg', 'JPG', 'png', 'gif', 'mp3', 'mp4', 'mov', 'wav', 'flac', 'pdf');
const MEDIA_TYPES = ['image', 'video', 'sound', 'other'];
diff --git a/app/class/modeldb.php b/app/class/modeldb.php
index a5ebf6f..94ed084 100644
--- a/app/class/modeldb.php
+++ b/app/class/modeldb.php
@@ -16,7 +16,7 @@ class Modeldb extends Model
public function dbinit()
{
- $this->database = new \JamesMoss\Flywheel\Config(__DIR__ .'/../../w_database');
+ $this->database = new \JamesMoss\Flywheel\Config(Model::DATABASE_DIR);
$this->artstore = new \JamesMoss\Flywheel\Repository(Config::arttable(), $this->database);
}
diff --git a/app/class/modelrender.php b/app/class/modelrender.php
index 238bc85..e2f6495 100644
--- a/app/class/modelrender.php
+++ b/app/class/modelrender.php
@@ -101,20 +101,20 @@ class Modelrender extends Modelart
if (isset($art->template('array')['quickcss'])) {
$tempaltequickcssart = $art->template('array')['quickcss'];
- $head .= '<link href="' . Config::renderpath() . $tempaltequickcssart . '.quick.css" rel="stylesheet" />' . PHP_EOL;
+ $head .= '<link href=".' . Model::RENDER_DIR . $tempaltequickcssart . '.quick.css" rel="stylesheet" />' . PHP_EOL;
}
- $head .= '<link href="' . Config::renderpath() . $art->id() . '.quick.css" rel="stylesheet" />' . PHP_EOL;
+ $head .= '<link href=".' . Model::RENDER_DIR . $art->id() . '.quick.css" rel="stylesheet" />' . PHP_EOL;
if (isset($art->template('array')['css'])) {
$tempaltecssart = $art->template('array')['css'];
- $head .= '<link href="' . Config::renderpath() . $tempaltecssart . '.css" rel="stylesheet" />' . PHP_EOL;
+ $head .= '<link href=".' . Model::RENDER_DIR . $tempaltecssart . '.css" rel="stylesheet" />' . PHP_EOL;
}
- $head .= '<link href="' . Config::renderpath() . $art->id() . '.css" rel="stylesheet" />' . PHP_EOL;
+ $head .= '<link href=".' . Model::RENDER_DIR . $art->id() . '.css" rel="stylesheet" />' . PHP_EOL;
if (isset($art->template('array')['javascript'])) {
$templatejsart = $art->template('array')['javascript'];
- $head .= '<script src="' . Config::renderpath() . $templatejsart . '.js" async/></script>' . PHP_EOL;
+ $head .= '<script src=".' . Model::RENDER_DIR . $templatejsart . '.js" async/></script>' . PHP_EOL;
}
- $head .= '<script src="' . Config::renderpath() . $art->id() . '.js" async/></script>' . PHP_EOL;
+ $head .= '<script src=".' . Model::RENDER_DIR . $art->id() . '.js" async/></script>' . PHP_EOL;
return $head;
}
diff --git a/app/class/routes.php b/app/class/routes.php
index 6f37b93..f24492b 100644
--- a/app/class/routes.php
+++ b/app/class/routes.php
@@ -1,5 +1,6 @@
<?php
+
class Routes
{
/**
@@ -8,11 +9,10 @@ class Routes
public function match()
{
$router = new AltoRouter();
+ $router->setBasePath(Config::basepath());
$router->addRoutes([
['GET|POST', '/', 'Backrouter#run', 'backrouter'],
['GET', '/[a:art]/', 'Controllerart#read', 'artread/'],
- ['GET', '/[a:art]', 'Controllerart#read', 'artread'],
- ['GET', '/[a:art]/edit', 'Controllerart#edit', 'artedit'],
['GET', '/[a:art]/edit/', 'Controllerart#edit', 'artedit/'],
]);
@@ -22,7 +22,7 @@ class Routes
$controllerName = $callableParts[0];
$methodName = $callableParts[1];
- $controller = new $controllerName();
+ $controller = new $controllerName($router);
call_user_func_array(array($controller, $methodName), $match['params']);
}
diff --git a/app/fn/fn.php b/app/fn/fn.php
index 8bfdee8..029e9d3 100644
--- a/app/fn/fn.php
+++ b/app/fn/fn.php
@@ -1,52 +1,13 @@
<?php
-function bddconnect($host, $bdname, $user, $password)
-{
- try {
- $bdd = new PDO('mysql:host=' . $host . ';dbname=' . $dbname . ';charset=utf8', $user, $password);
- } catch (Exeption $e) {
- die('Erreur : ' . $e->getMessage());
- }
- return $bdd;
-}
-function secure()
+function class_autoloader($class)
{
- if (!isset($_SESSION['id'])) {
- header("location: ./");
- }
+ require('.'. DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . strtolower($class) . '.php');
}
-function head($title)
-{
- ?>
- <head>
- <meta charset="utf8" />
- <meta name="viexport" content="width=device-width" />
- <link href="./css/style.css" rel="stylesheet" />
- <title><?= $title ?></title>
- </head>
- <?php
-}
-function search($haystack, $debut, $fin)
-{
- $list = [];
-
- $indexdebut = strpos($haystack, $debut);
- if ($indexdebut !== false) {
- $indexdebut += strlen($debut);
- $indexfin = strpos($haystack, $fin, $indexdebut);
- if ($indexfin !== false) {
- array_push($list, substr($haystack, $indexdebut, $indexfin - $indexdebut));
- $haystack = substr($haystack, $indexfin);
- $list = array_merge($list, search($haystack, $debut, $fin));
- }
- }
- return $list;
-
-}
function readablesize($bytes)
{
diff --git a/app/view/templates/navart.php b/app/view/templates/navart.php
index b6a7219..469139d 100644
--- a/app/view/templates/navart.php
+++ b/app/view/templates/navart.php
@@ -53,10 +53,10 @@ div#dropmenu {
<?php if($user->canedit() && $artexist) { ?>
<li>
- <a class="button" href="?id=<?=$art->id() ?>" target="_blank">display</a>
+ <a class="button" href="<?= $router->generate('artread/', ['art' => $art->id()]) ?>" target="_blank">display</a>
</li>
<li>
- <a class="button" href="?id=<?=$art->id() ?>&aff=edit" >edit</a>
+ <a class="button" href="<?= $router->generate('artedit/', ['art' => $art->id()]) ?>" >edit</a>
</li>
<?php } ?>
diff --git a/app/view/templates/readart.php b/app/view/templates/readart.php
deleted file mode 100644
index e44877d..0000000
--- a/app/view/templates/readart.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<script>
-<?=$art->javascript() ?>
-</script>
-
-<body>
-
-<header>
-<?=$art->header()?>
-</header>
-
-<nav>
-<?=$art->nav()?>
-</nav>
-
-<aside>
-<?=$art->aside()?>
-</aside>
-
-<section>
-<?=$art->section()?>
-</section>
-
-<footer>
-<?=$art->footer()?>
-</footer>