From cc7ad5299f1bd14155d4c01af3a4ece28f85c20c Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Thu, 10 Jan 2019 22:44:39 +0100 Subject: bug fixies --- app/class/art2.php | 10 +++++++--- app/class/controller.php | 3 +++ app/class/modelrender.php | 2 +- app/fn/fn.php | 6 +++++- app/view/templates/editleftbar.php | 2 +- app/view/templates/home.php | 2 +- assets/css/home.css | 2 +- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/class/art2.php b/app/class/art2.php index cb4949d..a378bd4 100644 --- a/app/class/art2.php +++ b/app/class/art2.php @@ -152,7 +152,11 @@ class Art2 public function description($type = 'string') { - return $this->description; + if($type == 'short' && strlen($this->description) > 15 ) { + return substr($this->description, 0, 15) . '.'; + } else { + return $this->description; + } } public function tag($option = 'array') @@ -441,7 +445,7 @@ class Art2 public function setid($id) { - if (strlen($id) < Model::MAX_ID_LENGTH and is_string($id)) { + if (strlen($id) <= Model::MAX_ID_LENGTH and is_string($id)) { $this->id = strip_tags(strtolower(str_replace(" ", "", $id))); } } @@ -687,7 +691,7 @@ class Art2 public function settemplateoptions($templateoptions) { if(is_array($templateoptions)) { - $this->templateoptions = array_filter($templateoptions); + $this->templateoptions = array_values(array_filter($templateoptions)); } } diff --git a/app/class/controller.php b/app/class/controller.php index eef6967..65d61c3 100644 --- a/app/class/controller.php +++ b/app/class/controller.php @@ -6,6 +6,9 @@ class Controller * @var User */ protected $user; + /** + * @var Routes + */ protected $router; /** * @var Modeluser diff --git a/app/class/modelrender.php b/app/class/modelrender.php index d1a924c..413b8de 100644 --- a/app/class/modelrender.php +++ b/app/class/modelrender.php @@ -255,7 +255,7 @@ class Modelrender extends Modelart public function media(string $text) : string { - $text = preg_replace('%(src|href)="(\/?[\w-_]+\.[a-z0-9]{1,5})"%', '$1="' . Model::mediapath() . '$2" target="_blank" class="media"', $text); + $text = preg_replace('%(src|href)="([\w-_]+(\/([\w-_])+)*\.[a-z0-9]{1,5})"%', '$1="' . Model::mediapath() . '$2" target="_blank" class="media"', $text); if (!is_string($text)) { throw new Exception('Rendering error -> media module'); } diff --git a/app/fn/fn.php b/app/fn/fn.php index dfee01d..fd609c1 100644 --- a/app/fn/fn.php +++ b/app/fn/fn.php @@ -77,7 +77,11 @@ function idclean(string $input) $replace = ['e', 'a', 'e', 'c', 'u', 'i', 'i', '-']; $input = str_replace($search, $replace, $input); - return preg_replace('%[^a-z0-9-_+]%', '', strtolower(trim($input))); + $input = preg_replace('%[^a-z0-9-_+]%', '', strtolower(trim($input))); + + $input = substr($input, 0, Model::MAX_ID_LENGTH); + + return $input; } diff --git a/app/view/templates/editleftbar.php b/app/view/templates/editleftbar.php index 7a2a40b..8da25c3 100644 --- a/app/view/templates/editleftbar.php +++ b/app/view/templates/editleftbar.php @@ -106,7 +106,7 @@ templateoptions() as $option) { - if($option != 'externalsavascript') { + if($option != 'externaljavascript') { echo ''; } } diff --git a/app/view/templates/home.php b/app/view/templates/home.php index a59fddf..70474c1 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -74,7 +74,7 @@ tag('sort') ?> - description() ?> + description('short') ?> linkto('sort') ?> linkfrom('sort') ?> datemodif('hrdi') ?> diff --git a/assets/css/home.css b/assets/css/home.css index 4b6bbf0..9d1c5a7 100644 --- a/assets/css/home.css +++ b/assets/css/home.css @@ -15,6 +15,7 @@ div#options { div#main { overflow: auto; + width: 100%; } body { @@ -73,7 +74,6 @@ th { } main { - margin: 0 0.5%; flex: 1; overflow-y: auto; } -- cgit v1.2.3