aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-11-11 22:04:49 +0100
committervincent-peugnet <v.peugnet@free.fr>2018-11-11 22:04:49 +0100
commita64af357ff41a61f5248e2052274315b390e979c (patch)
treef08323727b1b2a1fc86f8290777cf847f9604334 /app
parentcea923a1e82a7e8ce696418c3a5a0f7703871101 (diff)
downloadwcms-a64af357ff41a61f5248e2052274315b390e979c.tar.gz
wcms-a64af357ff41a61f5248e2052274315b390e979c.zip
clean
Diffstat (limited to 'app')
-rw-r--r--app/class/backrouter.php8
-rw-r--r--app/class/controller.php9
-rw-r--r--app/class/controllerart.php38
-rw-r--r--app/class/model.php22
-rw-r--r--app/class/modelrender.php225
-rw-r--r--app/class/routes.php12
-rw-r--r--app/class/sleekdbw.php180
-rw-r--r--app/view/templates/body.php0
-rw-r--r--app/view/templates/confirmdelete.php (renamed from app/view/templates/delete.php)4
-rw-r--r--app/view/templates/connect.php2
-rw-r--r--app/view/templates/edit.php5
-rw-r--r--app/view/templates/editrightbar.php2
-rw-r--r--app/view/templates/edittopbar.php15
-rw-r--r--app/view/templates/home.php10
-rw-r--r--app/view/templates/layout.php2
-rw-r--r--app/view/templates/navart.php4
-rw-r--r--app/view/templates/read.php6
-rw-r--r--app/view/templates/readcreate.php5
18 files changed, 208 insertions, 341 deletions
diff --git a/app/class/backrouter.php b/app/class/backrouter.php
index bcd1202..356a021 100644
--- a/app/class/backrouter.php
+++ b/app/class/backrouter.php
@@ -4,6 +4,7 @@
class Backrouter
{
protected $route;
+ protected $altorouter;
const ROUTES = [
'art' => ['art', 'read'],
@@ -35,6 +36,11 @@ class Backrouter
'aff=co' => ['connect', 'desktop'],
];
+ public function __construct($router)
+ {
+ $this->altorouter = $router;
+ }
+
public function run() {
if($this->matchroute()) {
$this->callmethod();
@@ -57,7 +63,7 @@ class Backrouter
$class = 'controller' . $method[0];
$function = $method[1];
- $controller = new $class($this->route->id());
+ $controller = new $class($this->altorouter);
$params = array_slice($method, 2);
$controller->$function(...$params);
}
diff --git a/app/class/controller.php b/app/class/controller.php
index afeefb0..db13d5a 100644
--- a/app/class/controller.php
+++ b/app/class/controller.php
@@ -28,6 +28,9 @@ class Controller
$this->plates->registerFunction('url', function (string $string, array $vars = []) use ($router) {
return $router->generate($string, $vars);
});
+ $this->plates->registerFunction('uart', function (string $string, string $id) use ($router) {
+ return $router->generate($string, ['art' => $id]);
+ });
}
public function useriseditor()
@@ -57,6 +60,7 @@ class Controller
$commonsparams = [];
$commonsparams['router'] = $this->router;
$commonsparams['user'] = $this->user;
+ $commonsparams['css'] = Model::csspath();
return $commonsparams;
}
@@ -92,6 +96,11 @@ class Controller
header('Location: ' . $url);
}
+ public function routedirect(string $route, array $vars = [])
+ {
+ $this->redirect($this->router->generate($route, $vars));
+ }
+
}
diff --git a/app/class/controllerart.php b/app/class/controllerart.php
index 9143375..0010f33 100644
--- a/app/class/controllerart.php
+++ b/app/class/controllerart.php
@@ -86,7 +86,7 @@ class Controllerart extends Controller
$artlist = $this->artmanager->list();
- if(isset($_SESSION['workspace'])) {
+ if (isset($_SESSION['workspace'])) {
$showleftpanel = $_SESSION['workspace']['showleftpanel'];
$showrightpanel = $_SESSION['workspace']['showrightpanel'];
} else {
@@ -97,7 +97,7 @@ class Controllerart extends Controller
$this->showtemplate('edit', ['art' => $this->art, 'artexist' => true, 'tablist' => $tablist, 'artlist' => $artlist, 'showleftpanel' => $showleftpanel, 'showrightpanel' => $showrightpanel]);
} else {
- $this->redirect('?id=' . $this->art->id());
+ $this->routedirect('artread/', ['art' => $this->art->id()]);
}
}
@@ -112,25 +112,35 @@ class Controllerart extends Controller
public function add($id)
{
$this->setart($id);
- $this->art->reset();
- $this->artmanager->add($this->art);
- $this->redirect('?id=' . $this->art->id() . '&aff=edit');
+ if ($this->user->canedit() && !$this->importart()) {
+ $this->art->reset();
+ $this->artmanager->add($this->art);
+ $this->routedirect('artedit', ['art' => $this->art->id()]);
+ } else {
+ $this->routedirect('artread/', ['art' => $this->art->id()]);
+ }
}
- public function delete($id)
+ public function confirmdelete($id)
{
$this->setart($id);
if ($this->user->canedit() && $this->importart()) {
- if (isset($_POST['deleteconfirm']) && $_POST['deleteconfirm'] == true) {
- $this->artmanager->delete($this->art);
- $this->redirect('?id=' . $this->art->id());
- } else {
- $this->showtemplate('delete', ['art' => $this->art, 'artexist' => true]);
- }
+ $this->showtemplate('confirmdelete', ['art' => $this->art, 'artexist' => true]);
+
} else {
- $this->redirect('?id=' . $this->art->id());
+ $this->routedirect('artread/', ['art' => $this->art->id()]);
+ }
+ }
+
+ public function delete($id)
+ {
+ $this->setart($id);
+ if ($this->user->canedit() && $this->importart()) {
+
+ $this->artmanager->delete($this->art);
}
+ $this->routedirect('backrouter');
}
public function update($id)
@@ -146,7 +156,7 @@ class Controllerart extends Controller
}
- $this->redirect('?id=' . $this->art->id() . '&aff=edit');
+ $this->routedirect('artupdate', ['art' => $this->art->id()]);
diff --git a/app/class/model.php b/app/class/model.php
index 3f4be4a..d7f34da 100644
--- a/app/class/model.php
+++ b/app/class/model.php
@@ -3,16 +3,34 @@ class Model
{
const CONFIG_FILE = 'config.json';
- const GLOBAL_CSS_DIR = '.' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'global' . DIRECTORY_SEPARATOR . 'global.css';
+ const CSS_DIR = 'assets' . DIRECTORY_SEPARATOR .'css' . DIRECTORY_SEPARATOR;
const MEDIA_DIR = '.' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR;
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 RENDER_DIR = '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'];
const TEXT_ELEMENTS = ['header', 'nav', 'section', 'aside', 'footer'];
+ public static function renderpath()
+ {
+ $basepath = '';
+ if(!empty(Config::basepath())) {
+ $basepath = Config::basepath() . DIRECTORY_SEPARATOR ;
+ }
+ return DIRECTORY_SEPARATOR . $basepath . Model::RENDER_DIR;
+ }
+
+ public static function csspath()
+ {
+ $basepath = '';
+ if(!empty(Config::basepath())) {
+ $basepath = Config::basepath() . DIRECTORY_SEPARATOR ;
+ }
+ return DIRECTORY_SEPARATOR . $basepath . Model::CSS_DIR;
+ }
+
}
diff --git a/app/class/modelrender.php b/app/class/modelrender.php
index e2f6495..ed50893 100644
--- a/app/class/modelrender.php
+++ b/app/class/modelrender.php
@@ -12,7 +12,7 @@ class Modelrender extends Modelart
public function renderhead(Art2 $art)
{
-
+
$head = $this->gethead($art);
$this->write($art);
return $head;
@@ -39,7 +39,7 @@ class Modelrender extends Modelart
$text = $art->$element();
}
$elements[$element] = PHP_EOL . '<' . $element . '>' . PHP_EOL . $this->markdown($text) . PHP_EOL . '</' . $element . '>' . PHP_EOL;
-
+
}
return $elements;
@@ -59,7 +59,7 @@ class Modelrender extends Modelart
public function getbody(string $html, array $elements)
{
- $html = preg_replace_callback('~\%(SECTION|ASIDE|NAV|HEADER|FOOTER)\%~', function ($match) use ($elements) {
+ $html = preg_replace_callback('~\%(SECTION|ASIDE|NAV|HEADER|FOOTER)\%~', function ($match) use ($elements) {
return $elements[strtolower($match[1])];
}, $html);
return $html;
@@ -89,184 +89,187 @@ class Modelrender extends Modelart
}
+
+
public function gethead(Art2 $art)
{
$head = '';
$head .= '<meta charset="utf8" />' . PHP_EOL;
- $head .= '<title>'.$art->title() .'</title>' . PHP_EOL;
- $head .= '<meta name="description" content="'.$art->description() .'" />' . PHP_EOL;
+ $head .= '<title>' . $art->title() . '</title>' . PHP_EOL;
+ $head .= '<meta name="description" content="' . $art->description() . '" />' . PHP_EOL;
$head .= '<meta name="viewport" content="width=device-width" />' . PHP_EOL;
if (isset($art->template('array')['quickcss'])) {
$tempaltequickcssart = $art->template('array')['quickcss'];
- $head .= '<link href=".' . Model::RENDER_DIR . $tempaltequickcssart . '.quick.css" rel="stylesheet" />' . PHP_EOL;
+ $head .= '<link href="' . Model::renderpath() . $tempaltequickcssart . '.quick.css" rel="stylesheet" />' . PHP_EOL;
}
- $head .= '<link href=".' . Model::RENDER_DIR . $art->id() . '.quick.css" rel="stylesheet" />' . PHP_EOL;
+ $head .= '<link href="' . Model::renderpath() . $art->id() . '.quick.css" rel="stylesheet" />' . PHP_EOL;
+
if (isset($art->template('array')['css'])) {
$tempaltecssart = $art->template('array')['css'];
- $head .= '<link href=".' . Model::RENDER_DIR . $tempaltecssart . '.css" rel="stylesheet" />' . PHP_EOL;
+ $head .= '<link href="' . Model::renderpath() . $tempaltecssart . '.css" rel="stylesheet" />' . PHP_EOL;
}
- $head .= '<link href=".' . Model::RENDER_DIR . $art->id() . '.css" rel="stylesheet" />' . PHP_EOL;
-
+ $head .= '<link href="' . Model::renderpath() . $art->id() . '.css" rel="stylesheet" />' . PHP_EOL;
+
if (isset($art->template('array')['javascript'])) {
$templatejsart = $art->template('array')['javascript'];
- $head .= '<script src=".' . Model::RENDER_DIR . $templatejsart . '.js" async/></script>' . PHP_EOL;
+ $head .= '<script src="' . Model::renderpath() . $templatejsart . '.js" async/></script>' . PHP_EOL;
}
- $head .= '<script src=".' . Model::RENDER_DIR . $art->id() . '.js" async/></script>' . PHP_EOL;
+ $head .= '<script src="' . Model::renderpath() . $art->id() . '.js" async/></script>' . PHP_EOL;
return $head;
-}
+ }
-public function elementsrender(Art2 $art)
-{
- foreach ($this->getelements($art) as $element => $text) {
- if (in_array($element, self::TEXT_ELEMENTS)) {
- $elements[$element] = $this->markdown($text);
+ public function elementsrender(Art2 $art)
+ {
+ foreach ($this->getelements($art) as $element => $text) {
+ if (in_array($element, self::TEXT_ELEMENTS)) {
+ $elements[$element] = $this->markdown($text);
+ }
}
+ return $elements;
}
- return $elements;
-}
-public function parser(Art2 $art, string $text)
-{
- $text = str_replace('%TITLE%', $art->title(), $text);
- $text = str_replace('%DESCRIPTION%', $art->description(), $text);
+ public function parser(Art2 $art, string $text)
+ {
+ $text = str_replace('%TITLE%', $art->title(), $text);
+ $text = str_replace('%DESCRIPTION%', $art->description(), $text);
- $text = str_replace(self::SUMMARY, $this->sumparser($text), $text);
+ $text = str_replace(self::SUMMARY, $this->sumparser($text), $text);
- $text = str_replace('href="=', 'href="?id=', $text);
+ $text = str_replace('href="=', 'href="?id=', $text);
- $text = $this->tooltip($art->linkfrom('array'), $text);
+ $text = $this->tooltip($art->linkfrom('array'), $text);
- $text = str_replace('href="http', ' class="external" target="_blank" href="http', $text);
- $text = str_replace('<img src="/', '<img src="./media/', $text);
+ $text = str_replace('href="http', ' class="external" target="_blank" href="http', $text);
+ $text = str_replace('<img src="/', '<img src="./media/', $text);
- $text = $this->autourl($text);
+ $text = $this->autourl($text);
- return $text;
-}
+ return $text;
+ }
-public function autourl($text)
-{
- $text = preg_replace('#( |\R|>)(https?:\/\/((\S+)\.([^< ]+)))#', '$1<a href="$2" class="external" target="_blank">$3</a>', $text);
- return $text;
-}
+ public function autourl($text)
+ {
+ $text = preg_replace('#( |\R|>)(https?:\/\/((\S+)\.([^< ]+)))#', '$1<a href="$2" class="external" target="_blank">$3</a>', $text);
+ return $text;
+ }
-public function markdown($text)
-{
+ public function markdown($text)
+ {
//use Michelf\MarkdownExtra;
- $fortin = new Michelf\MarkdownExtra;
+ $fortin = new Michelf\MarkdownExtra;
// id in headers
- $fortin->header_id_func = function ($header) {
- return preg_replace('/[^\w]/', '', strtolower($header));
- };
- $fortin->hard_wrap = true;
- $text = $fortin->transform($text);
- return $text;
-}
+ $fortin->header_id_func = function ($header) {
+ return preg_replace('/[^\w]/', '', strtolower($header));
+ };
+ $fortin->hard_wrap = true;
+ $text = $fortin->transform($text);
+ return $text;
+ }
-public function tooltip(array $linkfrom, string $text)
-{
- $descriptions = [];
- $artlist = $this->getlisterid($linkfrom);
- foreach ($artlist as $art) {
- $descriptions[$art->id()] = $art->description();
- }
+ public function tooltip(array $linkfrom, string $text)
+ {
+ $descriptions = [];
+ $artlist = $this->getlisterid($linkfrom);
+ foreach ($artlist as $art) {
+ $descriptions[$art->id()] = $art->description();
+ }
- foreach ($linkfrom as $id) {
- if (isset($descriptions[$id])) {
- $linkfrom = 'href="?id=' . $id . '"';
- $titlelinkfrom = ' title="' . $descriptions[$id] . '" ' . $linkfrom;
- $text = str_replace($linkfrom, $titlelinkfrom, $text);
+ foreach ($linkfrom as $id) {
+ if (isset($descriptions[$id])) {
+ $linkfrom = 'href="?id=' . $id . '"';
+ $titlelinkfrom = ' title="' . $descriptions[$id] . '" ' . $linkfrom;
+ $text = str_replace($linkfrom, $titlelinkfrom, $text);
+ }
}
+ return $text;
}
- return $text;
-}
-function sumparser($text)
-{
- preg_match_all('#<h([1-6]) id="(\w+)">(.+)</h[1-6]>#iU', $text, $out);
+ function sumparser($text)
+ {
+ preg_match_all('#<h([1-6]) id="(\w+)">(.+)</h[1-6]>#iU', $text, $out);
- $sum = [];
- foreach ($out[2] as $key => $value) {
- $sum[$value][$out[1][$key]] = $out[3][$key];
- }
+ $sum = [];
+ foreach ($out[2] as $key => $value) {
+ $sum[$value][$out[1][$key]] = $out[3][$key];
+ }
- $sumstring = '';
- $last = 0;
- foreach ($sum as $title => $list) {
- foreach ($list as $h => $link) {
- if ($h > $last) {
- for ($i = 1; $i <= ($h - $last); $i++) {
- $sumstring .= '<ul>';
- }
- $sumstring .= '<li><a href="#' . $title . '">' . $link . '</a></li>';
- } elseif ($h < $last) {
- for ($i = 1; $i <= ($last - $h); $i++) {
- $sumstring .= '</ul>';
+ $sumstring = '';
+ $last = 0;
+ foreach ($sum as $title => $list) {
+ foreach ($list as $h => $link) {
+ if ($h > $last) {
+ for ($i = 1; $i <= ($h - $last); $i++) {
+ $sumstring .= '<ul>';
+ }
+ $sumstring .= '<li><a href="#' . $title . '">' . $link . '</a></li>';
+ } elseif ($h < $last) {
+ for ($i = 1; $i <= ($last - $h); $i++) {
+ $sumstring .= '</ul>';
+ }
+ $sumstring .= '<li><a href="#' . $title . '">' . $link . '</a></li>';
+ } elseif ($h = $last) {
+ $sumstring .= '<li><a href="#' . $title . '">' . $link . '</a></li>';
}
- $sumstring .= '<li><a href="#' . $title . '">' . $link . '</a></li>';
- } elseif ($h = $last) {
- $sumstring .= '<li><a href="#' . $title . '">' . $link . '</a></li>';
+ $last = $h;
}
- $last = $h;
}
+ for ($i = 1; $i <= ($last); $i++) {
+ $sumstring .= '</ul>';
+ }
+ return $sumstring;
}
- for ($i = 1; $i <= ($last); $i++) {
- $sumstring .= '</ul>';
- }
- return $sumstring;
-}
//tag auto menu
-public function autotaglist()
-{
- $pattern = "/%%(\w*)%%/";
- preg_match_all($pattern, $this->md(), $out);
- return $out[1];
+ public function autotaglist()
+ {
+ $pattern = "/%%(\w*)%%/";
+ preg_match_all($pattern, $this->md(), $out);
+ return $out[1];
-}
+ }
-public function autotaglistupdate($taglist)
-{
- foreach ($taglist as $tag => $artlist) {
- $replace = '<ul>';
- foreach ($artlist as $art) {
- $replace .= '<li><a href="?id=' . $art->id() . '" title="' . $art->description() . '">' . $art->title() . '</a></li>';
+ public function autotaglistupdate($taglist)
+ {
+ foreach ($taglist as $tag => $artlist) {
+ $replace = '<ul>';
+ foreach ($artlist as $art) {
+ $replace .= '<li><a href="?id=' . $art->id() . '" title="' . $art->description() . '">' . $art->title() . '</a></li>';
+ }
+ $replace .= '</ul>';
+ $text = str_replace('%%' . $tag . '%%', $replace, $text);
}
- $replace .= '</ul>';
- $text = str_replace('%%' . $tag . '%%', $replace, $text);
}
-}
-public function autotaglistcalc($taglist)
-{
- foreach ($taglist as $tag => $artlist) {
- foreach ($artlist as $art) {
- if (!in_array($art->id(), $this->linkfrom('array')) && $art->id() != $this->id()) {
- $this->linkfrom[] = $art->id();
+ public function autotaglistcalc($taglist)
+ {
+ foreach ($taglist as $tag => $artlist) {
+ foreach ($artlist as $art) {
+ if (!in_array($art->id(), $this->linkfrom('array')) && $art->id() != $this->id()) {
+ $this->linkfrom[] = $art->id();
+ }
}
}
}
-}
diff --git a/app/class/routes.php b/app/class/routes.php
index bd9fd71..89f82e6 100644
--- a/app/class/routes.php
+++ b/app/class/routes.php
@@ -9,11 +9,19 @@ class Routes
public function match()
{
$router = new AltoRouter();
- $router->setBasePath('/' . Config::basepath());
+ if(!empty(Config::basepath())) {
+ $router->setBasePath(DIRECTORY_SEPARATOR . Config::basepath());
+ }
$router->addRoutes([
['GET|POST', '/', 'Backrouter#run', 'backrouter'],
['GET', '/[a:art]/', 'Controllerart#read', 'artread/'],
- ['GET', '/[a:art]/edit/', 'Controllerart#edit', 'artedit/'],
+ ['GET', '/[a:art]', 'Controllerart#read', 'artread'],
+ ['GET', '/[a:art]/add', 'Controllerart#add', 'artadd'],
+ ['GET', '/[a:art]/edit', 'Controllerart#edit', 'artedit'],
+ ['GET', '/[a:art]/log', 'Controllerart#log', 'artlog'],
+ ['POST', '/[a:art]/edit', 'Controllerart#update', 'artupdate'],
+ ['GET', '/[a:art]/delete', 'Controllerart#confirmdelete', 'artconfirmdelete'],
+ ['POST', '/[a:art]/delete', 'Controllerart#delete', 'artdelete'],
]);
$match = $router->match();
diff --git a/app/class/sleekdbw.php b/app/class/sleekdbw.php
deleted file mode 100644
index dd77752..0000000
--- a/app/class/sleekdbw.php
+++ /dev/null
@@ -1,180 +0,0 @@
-<?php
-
-use SleekDB\SleekDB;
-
-
-class SleekDBw extends SleekDB
-{
-
- public function getStoreIdList()
- {
- $listPath = $this->storePath . 'data/';
- $lengh = strlen($listPath);
- $list = [];
- foreach (glob($listPath . '*.json') as $filename) {
- $list[] = substr(substr($filename, $lengh), 0, -5);
- }
- return $list;
- }
-
- public function getbyid($id)
- {
- return $this->getStoreDocumentById($id);
- }
-
- public function updatebyid($id, $data)
- {
- foreach ($data as $key => $value) {
- // Do not update the _id reserved index of a store.
- if ($key != '_id') {
- $data[$key] = $value;
- }
- }
- $storePath = $this->storePath . 'data/' . $id . '.json';
- if (file_exists($storePath)) {
- // Wait until it's unlocked, then update data.
- file_put_contents($storePath, json_encode($data), LOCK_EX);
- }
- // Check do we need to wipe the cache for this store.
- if ($this->deleteCacheOnCreate === true) $this->_emptyAllCache();
- return true;
- }
-
-
-
-
-
-
- // Writes an object in a store.
- protected function writeInStore($storeData)
- {
- // Cast to array
- $storeData = (array)$storeData;
- // Check if it has _id key
- if (empty($storeData['_id'])) throw new \Exception('Lack of id in this object');
- if (in_array($storeData['_id'], $this->getStoreIdList())) throw new \Exception('Id already used');
- // Add the system ID with the store data array.
- $id = $storeData['_id'];
- // Prepare storable data
- $storableJSON = json_encode($storeData);
- if ($storableJSON === false) throw new \Exception('Unable to encode the data array, please provide a valid PHP associative array');
- // Define the store path
- $storePath = $this->storePath . 'data/' . $id . '.json';
- if (!file_put_contents($storePath, $storableJSON)) {
- throw new \Exception("Unable to write the object file! Please check if PHP has write permission.");
- }
- return $storeData;
- }
-
-
- // Find store objects with conditions, sorting order, skip and limits.
- protected function findStoreDocuments()
- {
- $found = [];
- $storeIdList = $this->getStoreIdList();
- $searchRank = [];
- // Start collecting and filtering data.
- foreach ($storeIdList as $id) {
- // Collect data of current iteration.
- $data = $this->getStoreDocumentById($id);
- if (!empty($data)) {
- // Filter data found.
- if (empty($this->conditions)) {
- // Append all data of this store.
- $found[] = $data;
- } else {
- // Append only passed data from this store.
- $storePassed = true;
- // Iterate each conditions.
- foreach ($this->conditions as $condition) {
- // Check for valid data from data source.
- $validData = true;
- $fieldValue = '';
- try {
- $fieldValue = $this->getNestedProperty($condition['fieldName'], $data);
- } catch (\Exception $e) {
- $validData = false;
- $storePassed = false;
- }
- if ($validData === true) {
- // Check the type of rule.
- if ($condition['condition'] === '=') {
- // Check equal.
- if ($fieldValue != $condition['value']) $storePassed = false;
- } else if ($condition['condition'] === '!=') {
- // Check not equal.
- if ($fieldValue == $condition['value']) $storePassed = false;
- } else if ($condition['condition'] === '>') {
- // Check greater than.
- if ($fieldValue <= $condition['value']) $storePassed = false;
- } else if ($condition['condition'] === '>=') {
- // Check greater equal.
- if ($fieldValue < $condition['value']) $storePassed = false;
- } else if ($condition['condition'] === '<') {
- // Check less than.
- if ($fieldValue >= $condition['value']) $storePassed = false;
- } else if ($condition['condition'] === '<=') {
- // Check less equal.
- if ($fieldValue > $condition['value']) $storePassed = false;
- }
- }
- }
- // Check if current store is updatable or not.
- if ($storePassed === true) {
- // Append data to the found array.
- $found[] = $data;
- }
- }
- }
- }
- if (count($found) > 0) {
- // Check do we need to sort the data.
- if ($this->orderBy['order'] !== false) {
- // Start sorting on all data.
- $found = $this->sortArray($this->orderBy['field'], $found, $this->orderBy['order']);
- }
- // If there was text search then we would also sort the result by search ranking.
- if (!empty($this->searchKeyword)) {
- $found = $this->performSerach($found);
- }
- // Skip data
- if ($this->skip > 0) $found = array_slice($found, $this->skip);
- // Limit data.
- if ($this->limit > 0) $found = array_slice($found, 0, $this->limit);
- }
- return $found;
- }
-
-
-
- // Method to boot a store.
- protected function bootStore()
- {
- $store = trim($this->storeName);
- // Validate the store name.
- if (!$store || empty($store)) throw new \Exception('Invalid store name was found');
- // Prepare store name.
- if (substr($store, -1) !== '/') $store = $store . '/';
- // Store directory path.
- $this->storePath = $this->dataDirectory . $store;
- // Check if the store exists.
- if (!file_exists($this->storePath)) {
- // The directory was not found, create one with cache directory.
- if (!mkdir($this->storePath, 0777, true)) throw new \Exception('Unable to create the store path at ' . $this->storePath);
- // Create the cache directory.
- if (!mkdir($this->storePath . 'cache', 0777, true)) throw new \Exception('Unable to create the store\'s cache directory at ' . $this->storePath . 'cache');
- // Create the data directory.
- if (!mkdir($this->storePath . 'data', 0777, true)) throw new \Exception('Unable to create the store\'s data directory at ' . $this->storePath . 'data');
- // Check if PHP has write permission in that directory.
- if (!is_writable($this->storePath)) throw new \Exception('Store path is not writable at "' . $this->storePath . '." Please change store path permission.');
- // Finally check if the directory is readable by PHP.
- if (!is_readable($this->storePath)) throw new \Exception('Store path is not readable at "' . $this->storePath . '." Please change store path permission.');
- }
- }
-
-
-
-
-}
-
-?> \ No newline at end of file
diff --git a/app/view/templates/body.php b/app/view/templates/body.php
deleted file mode 100644
index e69de29..0000000
--- a/app/view/templates/body.php
+++ /dev/null
diff --git a/app/view/templates/delete.php b/app/view/templates/confirmdelete.php
index be54451..e05f6da 100644
--- a/app/view/templates/delete.php
+++ b/app/view/templates/confirmdelete.php
@@ -1,4 +1,4 @@
-<?php $this->layout('layout', ['title' => 'delete', 'description' => 'delete']) ?>
+<?php $this->layout('layout', ['title' => 'delete', 'description' => 'delete', 'css' => $css . 'delete.css']) ?>
<?php $this->start('page') ?>
@@ -34,7 +34,7 @@
</div>
-<form action="./?id=<?= $art->id() ?>&action=delete" method="post">
+<form action="<?= $this->uart('artdelete', $art->id()) ?>" method="post">
<input type="hidden" name="deleteconfirm" value="true">
<input type="submit" value="confirm delete">
</form>
diff --git a/app/view/templates/connect.php b/app/view/templates/connect.php
index 3e2aeba..a4d58e7 100644
--- a/app/view/templates/connect.php
+++ b/app/view/templates/connect.php
@@ -1,4 +1,4 @@
-<?php $this->layout('layout', ['title' => 'Connect', 'description' => 'connect']) ?>
+<?php $this->layout('layout', ['title' => 'Connect', 'description' => 'connect', 'css' => $css . 'connect.css']) ?>
diff --git a/app/view/templates/edit.php b/app/view/templates/edit.php
index 33d42f4..7379378 100644
--- a/app/view/templates/edit.php
+++ b/app/view/templates/edit.php
@@ -1,4 +1,4 @@
-<?php $this->layout('layout', ['title' => '✏ '.$art->title()]) ?>
+<?php $this->layout('layout', ['title' => '✏ '.$art->title(), 'css' => $css . 'edit.css']) ?>
@@ -24,9 +24,6 @@
</div>
-
-<input type="hidden" name="id" value="<?= $art->id() ?>">
-
</form>
</section>
diff --git a/app/view/templates/editrightbar.php b/app/view/templates/editrightbar.php
index 92d5f81..a6cc2a0 100644
--- a/app/view/templates/editrightbar.php
+++ b/app/view/templates/editrightbar.php
@@ -7,7 +7,7 @@
<?php
foreach ($artlist as $item ) {
?>
- <a href="?id=<?= $item ?>&aff=edit"><?= $item ?></a>
+ <a href="<?= $this->uart('artedit', $item) ?>"><?= $item ?></a>
<input type="text" value="[<?= $item ?>](=<?= $item ?>)">
<?php
}
diff --git a/app/view/templates/edittopbar.php b/app/view/templates/edittopbar.php
index 20c2d8b..b97db12 100644
--- a/app/view/templates/edittopbar.php
+++ b/app/view/templates/edittopbar.php
@@ -1,23 +1,22 @@
<div id="topbar">
- <form id="delete" action="./" method="get">
- <input type="hidden" name="id" value="<?= $art->id() ?>">
- </form>
- <form action="?id=<?= $art->id() ?>&action=update" method="post" id="update">
+
+ <form action="<?= $this->uart('artupdate', $art->id()) ?>" method="post" id="update">
<span>
- <input type="submit" name="action" value="update" accesskey="x" form="update">
+ <input type="submit" value="update" accesskey="x" form="update">
</span>
<span>
- <input type="submit" name="action" value="delete" form="delete">
+ <a href="<?= $this->uart('artconfirmdelete', $art->id()) ?>">βœ– delete</a>
</span>
<span>
- <a href="?id=<?= $art->id() ?>" target="_blank">πŸ‘</a>
- <a href="?id=<?= $art->id() ?>&aff=log" target="_blank">ΒΆ</a>
+ <a href="<?= $this->url('backrouter') ?>" >🏠</a>
+ <a href="<?= $this->uart('artread/', $art->id()) ?>" target="_blank">πŸ‘</a>
+ <a href="<?= $this->uart('artlog', $art->id()) ?>" target="_blank">ΒΆ</a>
</span>
<span id="headid"><?= $art->id() ?></span>
diff --git a/app/view/templates/home.php b/app/view/templates/home.php
index 2303f0f..5c3a007 100644
--- a/app/view/templates/home.php
+++ b/app/view/templates/home.php
@@ -1,4 +1,4 @@
-<?php $this->layout('layout', ['title' => 'home']) ?>
+<?php $this->layout('layout', ['title' => 'home', 'css' => $css . 'home.css']) ?>
@@ -80,10 +80,10 @@
<tr>
<td><input type="checkbox" name="id[]" value="<?= $item->id() ?>" id="<?= $item->id() ?>"></td>
<td><label title="<?= $item->title() ?>" for="<?= $item->id() ?>"><?= $item->id() ?></label></td>
- <td><a href="?id=<?= $item->id() ?>&aff=edit">✏</a></td>
- <td><a href="?id=<?= $item->id() ?>" target="_blank">πŸ‘</a></td>
- <td><a href="?id=<?= $item->id() ?>&action=delete" >πŸ—‘</a></td>
- <td><a href="?id=<?= $item->id() ?>&aff=log" target="_blank">ΒΆ</a></td>
+ <td><a href="<?= $this->uart('artedit', $item->id()) ?>">✏</a></td>
+ <td><a href="<?= $this->uart('artread/', $item->id()) ?>" target="_blank">πŸ‘</a></td>
+ <td><a href="<?= $this->uart('artdelete', $item->id()) ?>" >πŸ—‘</a></td>
+ <td><a href="<?= $this->uart('artlog', $item->id()) ?>" target="_blank">ΒΆ</a></td>
<td><?= $item->tag('sort') ?></td>
<td><?= $item->description() ?></td>
<td><?= $item->linkto('sort') ?></td>
diff --git a/app/view/templates/layout.php b/app/view/templates/layout.php
index 7439f48..c20264d 100644
--- a/app/view/templates/layout.php
+++ b/app/view/templates/layout.php
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width" />
<link rel="shortcut icon" href="./media/logo.png" type="image/x-icon">
<title><?= $title ?></title>
- <link rel="stylesheet" href="./../public/css/soft.css">
+ <link rel="stylesheet" href="<?= $css ?>">
<?=$this->section('customhead')?>
<?=$this->section('arthead')?>
diff --git a/app/view/templates/navart.php b/app/view/templates/navart.php
index 6f4388c..f747eca 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="<?= $this->url('artread/', ['art' => $art->id()]) ?>" target="_blank">display</a>
+ <a class="button" href="<?= $this->uart('artread/', $art->id()) ?>" target="_blank">display</a>
</li>
<li>
- <a class="button" href="<?= $this->url('artedit/', ['art' => $art->id()]) ?>" >edit</a>
+ <a class="button" href="<?= $this->uart('artedit', $art->id()) ?>" >edit</a>
</li>
<?php } ?>
diff --git a/app/view/templates/read.php b/app/view/templates/read.php
index 35b1e7d..1911cf6 100644
--- a/app/view/templates/read.php
+++ b/app/view/templates/read.php
@@ -53,8 +53,10 @@ $this->stop();
} else {
echo '<h1>' . $alertnotexist . '</h1>';
if ($cancreate) {
- $this->insert('readcreate', ['id' => $art->id()]);
- }
+ ?>
+ <a href="<?= $this->uart('artadd', $art->id()) ?>">⭐ Create</a>
+ <?php
+ }
}
diff --git a/app/view/templates/readcreate.php b/app/view/templates/readcreate.php
deleted file mode 100644
index dc36420..0000000
--- a/app/view/templates/readcreate.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<form action="./" method="get">
-<input type="hidden" name="id" value="<?= $id ?>">
-<input type="hidden" name="action" value="add">
-<input type="submit" value="create">
-</form> \ No newline at end of file