diff --git a/CHANGELOG b/CHANGELOG
index b61854294..62dc2b85a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -254,6 +254,7 @@
- conversion from pdf to png replaces alpha channel with white
- add list of conversion services in debug menu of admin tool
- use chosen select for custom attributes
+- color category (use first 6 chars of md5(category name) as hex color)
--------------------------------------------------------------------------------
Changes in version 5.1.29
diff --git a/inc/inc.ClassViewCommon.php b/inc/inc.ClassViewCommon.php
index 5f6b0d95b..aad119238 100644
--- a/inc/inc.ClassViewCommon.php
+++ b/inc/inc.ClassViewCommon.php
@@ -357,4 +357,12 @@ class SeedDMS_View_Common {
}
echo "};\n";
} /* }}} */
+
+ public static function getContrastColor($hexcolor) { /* {{{ */
+ $r = hexdec(substr($hexcolor, 1, 2));
+ $g = hexdec(substr($hexcolor, 3, 2));
+ $b = hexdec(substr($hexcolor, 5, 2));
+ $yiq = (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
+ return ($yiq >= 148) ? '000000' : 'ffffff';
+ } /* }}} */
}
diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php
index 2c49a9fd5..75d6fd3e4 100644
--- a/views/bootstrap/class.Bootstrap.php
+++ b/views/bootstrap/class.Bootstrap.php
@@ -3291,8 +3291,10 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
}
if($categories = $document->getCategories()) {
$content .= "
";
- foreach($categories as $category)
- $content .= "".$category->getName()." ";
+ foreach($categories as $category) {
+ $color = substr(md5($category->getName()), 0, 6);
+ $content .= "".$category->getName()." ";
+ }
}
if(!empty($extracontent['bottom_title']))
$content .= $extracontent['bottom_title'];
diff --git a/views/bootstrap/class.Categories.php b/views/bootstrap/class.Categories.php
index 356ed03db..53d4fa377 100644
--- a/views/bootstrap/class.Categories.php
+++ b/views/bootstrap/class.Categories.php
@@ -150,7 +150,8 @@ $(document).ready( function() {
$options[] = array("-1", getMLText("choose_category"));
$options[] = array("0", getMLText("new_document_category"));
foreach ($categories as $category) {
- $options[] = array($category->getID(), htmlspecialchars($category->getName()), $selcat && $category->getID()==$selcat->getID(), array(array('data-subtitle', $category->countDocumentsByCategory().' '.getMLText('documents'))));
+ $color = substr(md5($category->getName()), 0, 6);
+ $options[] = array($category->getID(), htmlspecialchars($category->getName()), $selcat && $category->getID()==$selcat->getID(), array(array('data-before-title', " "), array('data-subtitle', $category->countDocumentsByCategory().' '.getMLText('documents'))));
}
$this->formField(
null, //getMLText("selection"),
diff --git a/views/bootstrap/styles/application.js b/views/bootstrap/styles/application.js
index 23ef17802..1eb3d2243 100644
--- a/views/bootstrap/styles/application.js
+++ b/views/bootstrap/styles/application.js
@@ -12,6 +12,8 @@ chzn_template_func = function (state) {
if($(state.element).data('warning'))
warning = $(state.element).data('warning')+''; /* make sure it is a string */
var html = '';
+ if($(state.element).data('before-title'))
+ html += $(state.element).data('before-title')+'';
if($(state.element).data('icon-before'))
html += ' ';
html += state.text.replace(/getCategories()) {
$content .= "
";
- foreach($categories as $category)
- $content .= "".$category->getName()." ";
+ foreach($categories as $category) {
+ $color = substr(md5($category->getName()), 0, 6);
+ $content .= "".$category->getName()." ";
+ }
}
if(!empty($extracontent['bottom_title']))
$content .= $extracontent['bottom_title'];
diff --git a/views/bootstrap4/styles/application.js b/views/bootstrap4/styles/application.js
index a6a46ad5c..419a92731 100644
--- a/views/bootstrap4/styles/application.js
+++ b/views/bootstrap4/styles/application.js
@@ -12,6 +12,8 @@ chzn_template_func = function (state) {
if($(state.element).data('warning'))
warning = $(state.element).data('warning')+''; /* make sure it is a string */
var html = '';
+ if($(state.element).data('before-title'))
+ html += $(state.element).data('before-title')+'';
if($(state.element).data('icon-before'))
html += ' ';
html += state.text.replace(/