Если вы являетесь разработчиком и хотите расширить функции Колорайзера.
На данный момент единственная функция в Колорайзере, которую вы можете расширить - это состояние, например «пусто», «равно», «меньше», но именно это вам и нужно.
в директории modules/Colorizer/extends/functions/ вы увидите файл, названный core.inc.php.
Здесь вы найдете определение оригинальных условий и структуру, которая нужна вам, чтобы создать свою собственную функцию.
Если вы хотите создать ваше собственное условие, то лучшим решением для этого будет создать в этой директории файл *.inc.php.
Даже при обновлении модуля система этот файл не удалит.
$formatCondition["<condition_key>"] = array("function" => " Javascript function, which does the condition. returns: true/false if the condition is true or false.", "title" => "<label in dropdown>", "description" => "<description>", "blockType" => array("<don't show this condition for this input types>"), "parameter" => array("<labelParameter1>", "<labelParameter2>"...) );
Значение параметра должно быть числовым, тогда параметр не выведет никакой подписи.
JavaScript функция возврата параметра:
Доступные значения для blockType: логическое значение, строка, список выбора
$formatCondition["is_empty"] = array("function" => " if(key == 'resultField' && (value == '0' || !value || 0 === value.length || value == '0000-00-00')) return true; else return false; ", "title" => "is empty", "description" => "Colorize if field is empty", "blockType" => array("boolean"), "parameter" => 0 ); $formatCondition["is_not_empty"] = array("function" => " if(key == 'resultField' && value != null && value != '' && value != '0' && 0 !== value.length) return true; else return false; ", "title" => "is not empty", "description" => "Colorize if field is not empty", "blockType" => array("boolean"), "parameter" => 0 ); $formatCondition["is_bigger"] = array("function" => " if(jQuery.isNumeric(value)) value = Number(value); if(key == 'resultField' && value > parameter[0]) return true; else return false; ", "title" => "is bigger", "blockType" => array("boolean"), "description" => "Colorize if field is bigger", "parameter" => array("bigger then") ); $formatCondition["is_lower"] = array("function" => " if(jQuery.isNumeric(value)) value = Number(value); if(key == 'resultField' && value < parameter[0]) return true; else return false; ", "title" => "is lower", "blockType" => array("boolean"), "description" => "Colorize if field is lower", "parameter" => array("lower then") ); $formatCondition["is_equal"] = array("function" => " if(key == 'resultField' && value == parameter[0]) return true; else return false; ", "title" => "is equal", "blockType" => array("boolean"), "description" => "Colorize if field is equal to the first parameter", "parameter" => array("Equal to")); $formatCondition["is_not_equal"] = array("function" => " if(key == 'resultField' && value != parameter[0]) return true; else return false; ", "title" => "is not equal", "blockType" => array("boolean"), "description" => "Colorize if field is not equal to the first parameter", "parameter" => array("Not equal to")); $formatCondition["within_x_days"] = array("function" => " if(value == null) return false; if(/[0-9]{4}-[0-9]{2}-[0-9]{2}/.test(value)) { var start = new Date(value); } else { if(value.indexOf(' ') != -1) { value = value.split(' ')[0]; } if((dynamic != undefined && dynamic == true) || (listView != undefined && listView == true)) { var valParts = splitDateVal(value); var start = new Date(valParts[2],valParts[1] - 1,valParts[0]); } else { var start = new Date(value); } } var end = new Date(); var diff = new Date(start - end); var days = diff / 1000 / 60 / 60 / 24; if(days < parameter[0] && days > -1) { return true; } else { return false; } ", "title" => "is within X days", "blockType" => array("boolean"), "description" => "Colorize if the date is within ... days", "parameter" => array("within the next X days")); $formatCondition["within_last_x_days"] = array("function" => " if(value == null) return false; if(/[0-9]{4}-[0-9]{2}-[0-9]{2}/.test(value)) { var start = new Date(value); } else { if(value.indexOf(' ') != -1) { value = value.split(' ')[0]; } if((dynamic != undefined && dynamic == true) || (listView != undefined && listView == true)) { var valParts = splitDateVal(value); var start = new Date(valParts[2],valParts[1] - 1,valParts[0]); } else { var start = new Date(value); } } var end = new Date(); var diff = new Date(start - end); var days = diff / 1000 / 60 / 60 / 24; if(days > -1 * parameter[0] && days < -1) { return true; } else { return false; } ", "blockType" => array("boolean"), "title" => "is within last X days", "description" => "Colorize if the date is within last ... days", "parameter" => array("within the last X days")); $formatCondition["is_futuredate"] = array("function" => " if(value == null) return false; if(/[0-9]{4}-[0-9]{2}-[0-9]{2}/.test(value)) { var start = new Date(value); } else { if(value.indexOf(' ') != -1) { value = value.split(' ')[0]; } if((dynamic != undefined && dynamic == true) || (listView != undefined && listView == true)) { var valParts = splitDateVal(value); var start = new Date(valParts[2],valParts[1] - 1,valParts[0]); } else { var start = new Date(value); } } var end = new Date(); if(start > end) { return true; } else { return false; } ", "title" => "is date in future", "blockType" => array("boolean"), "description" => "Colorize if the date in in the future", "parameter" => 0); $formatCondition["is_checked"] = array("function" => " if(value == 1) return true; return false; ", "title" => "is checked", "blockType" => array("picklist", "string"), "description" => "Check if Checkbox is checked", "parameter" => 0); $formatCondition["contains"] = array("function" => " if(value.indexOf(parameter[0]) > -1) return true; else return false; ", "title" => "contains", "blockType" => array("boolean"), "description" => "colorize if String contains value", "parameter" => 1); /* Example for own own functions */ /* // Parameters will be numbered from 1 till n $colorCondition["is_equal"] = array("function" => " console.log(parameter[0]); console.log(value); if(key == 'resultField' && value == parameter[0]) return true; else return false; ", "description" => "Colorize if field is equal to the first parameter", "parameter" => 1); // Parameters will be named by description ("Equal to:") $colorCondition["is_equal2"] = array("function" => " if(key == 'resultField' && value == parameter[0]) return true; else return false; ", "description" => "Colorize if field is equal to the first parameter", "parameter" => array("Equal to")); */