From 04d3251ef4fc6ffdd8df93fb6f71d305c7ba49a6 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 13 May 2021 16:15:06 +0200 Subject: [PATCH] document categorie may have a color --- op/op.Categories.php | 4 ++++ views/bootstrap/class.Categories.php | 9 +++++++++ views/bootstrap4/class.Bootstrap4.php | 6 ++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/op/op.Categories.php b/op/op.Categories.php index 5616028e8..40d355165 100644 --- a/op/op.Categories.php +++ b/op/op.Categories.php @@ -108,6 +108,10 @@ else if ($action == "editcategory") { UI::exitError(getMLText("admin_tools"),getMLText("error_occured")); } + $color = $_POST["color"]; + if (!$category->setColor($color)) { + UI::exitError(getMLText("admin_tools"),getMLText("error_occured")); + } $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_edit_category'))); add_log_line(".php&action=editcategory&categoryid=".$categoryid); } diff --git a/views/bootstrap/class.Categories.php b/views/bootstrap/class.Categories.php index 4ebf72eb0..d81e0d348 100644 --- a/views/bootstrap/class.Categories.php +++ b/views/bootstrap/class.Categories.php @@ -120,6 +120,15 @@ $(document).ready( function() { 'value'=>($category ? htmlspecialchars($category->getName()) : '') ) ); + $this->formField( + getMLText("color"), + array( + 'element'=>'input', + 'type'=>'text', + 'name'=>'color', + 'value'=>($category ? htmlspecialchars($category->getColor()) : '') + ) + ); $this->contentContainerEnd(); $this->formSubmit(" ".getMLText('save')); ?> diff --git a/views/bootstrap4/class.Bootstrap4.php b/views/bootstrap4/class.Bootstrap4.php index 4a64b7bdb..8ae5b007b 100644 --- a/views/bootstrap4/class.Bootstrap4.php +++ b/views/bootstrap4/class.Bootstrap4.php @@ -3659,10 +3659,8 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev) } if($categories = $document->getCategories()) { $content .= "
"; - foreach($categories as $category) { - $color = substr(md5($category->getName()), 0, 6); - $content .= "".htmlspecialchars($category->getName())." "; - } + foreach($categories as $category) + $content .= "getColor() ? ' style="background-color: #'.$category->getColor().' !important;"' : '').">".$category->getName()." "; } if(!empty($extracontent['bottom_title'])) $content .= $extracontent['bottom_title'];