Code: Select all
ageM != ageC
dateM != dateC
prop:{Modified} != prop:{Created}
prop:{#3} != prop:{#4}Code: Select all
ageM != ageC
dateM != dateC
prop:{Modified} != prop:{Created}
prop:{#3} != prop:{#4}Code: Select all
"ICF: Created == Modified"
// The colors to use.
$backColor = 'AA2211';
$foreColor = '';
// Date pattern to compare - this allows you to control the precision.
$pattern = 'yyyymmddhhnnss';
// Get the information for all items in the list.
$ret = Report("{Created $pattern}|{Modified $pattern}|{Fullname}<crlf>", 0);
// It might be better to limit it to the selection,
// or retrieve the dates within the loop; I'm not sure.
// List of items that qualify for free healt.. er highlighting.
$matchList = '';
foreach ($item, $ret, "<crlf>") {
if ($item == '') { continue; }
$c = GetToken($item, 1, '|');
$m = GetToken($item, 2, '|');
if ($c == $m) {
if ($matchList != '') { $matchList = $matchList . ';'; }
$matchList = $matchList . GetToken($item, 3, '|');
}
}
if ($matchList != '') {
// Color the matching items.
// With heredoc you can insert other ICFs you want to also apply.
colorfilter(<<<#ICF
"Created == Modified" $matchList>$foreColor,$backColor
#ICF
, "<crlf>");
}Code: Select all
// Permanent Variable - On/Off Switch
// Set either permanent variable to true to abort early.
// This is useful for temporarily disabling one or all custom columns.
if ($P_CC_DISABLE_ALL || $P_CC_DISABLE_CISM) {
return 'off';
}
// ---------- Settings
// Date pattern to compare - this allows you to control the precision.
$pattern = 'yyyymmddhhnnss';
// Tag for items with matching date patterns.
$tagValue = 'datesMatch';
// ----------
// Item we're working on.
$item = <cc_item>;
// Create a small 'script' to compare the dates.
$ret = report("'{Created $pattern}' == '{Modified $pattern}'", $item);
if (eval($ret)) {
// If Dates match - tag item.
tag $tagValue, $item, 1, 0;
return '==';
} elseif ((', ' . property('#tags', $item) . ',') LikeI "*, $tagValue,*") {
// If item was previously tagged - remove it now.
tag $tagValue, $item, 1, 2;
}
return '!=';Code: Select all
Snip: CustomColumn 1
XYplorer 14.80.0004, 1/8/2015 9:43:12 AM
Action
ConfigureColumn
Caption
C is M
Type
3
Definition
// Permanent Variable - On/Off Switch
// Set either permanent variable to true to abort early.
// This is useful for temporarily disabling one or all custom columns.
if ($P_CC_DISABLE_ALL || $P_CC_DISABLE_CISM) {
return 'off';
}
// ---------- Settings
// Date pattern to compare - this allows you to control the precision.
$pattern = 'yyyymmddhhnnss';
// Tag for items with matching date patterns.
$tagValue = 'datesMatch';
// ----------
// Item we're working on.
$item = <cc_item>;
// Create a small 'script' to compare the dates.
$ret = report("'{Created $pattern}' == '{Modified $pattern}'", $item);
if (eval($ret)) {
// If Dates match - tag item.
tag $tagValue, $item, 1, 0;
return '==';
} elseif ((', ' . property('#tags', $item) . ',') LikeI "*, $tagValue,*") {
// If item was previously tagged - remove it now.
tag $tagValue, $item, 1, 2;
}
return '!=';
Format
0
Trigger
1
Item Type
0
Item Filter
Code: Select all
prop:#tags:*datesMatch*Odd... It should have worked for folders already.Enternal wrote:it does not seem to fully work with some files (and I want it to work with folders as well)
Code: Select all
"ICF: Created == Modified"
// ===== SETTINGS ============================================================
// Caption for this instant color filter.
$caption = 'Created == Modified';
// The colors to use for matching items.
$textColor = '';
$backColor = 'AA2211';
// Date pattern to compare - this allows you to control the precision.
$pattern = 'yyyymmddhhnnss';
// Persist any other currently active instant color filters.
$keepOthers = true;
// Toggle between highlighting matching items and not.
// Setting this to false removes and re-applies the highlighting.
$toggle = true;
// ===========================================================================
// ----- VALIDATION ----------------------------------------------------------
// Validate the caption.
if ($caption UnLike '"*"') {
End $caption Like '*"*', 'Caption cannot contain quotes.';
End $caption Like "*<crlf>*", 'Caption cannot contain line breaks.';
$caption = Quote($caption);
}
// Validate colors.
End $textColor != '' && RegexReplace($textColor, '^[0-9a-f]{6}$') != '', 'Text color must be a hex color.';
End $backColor != '' && RegexReplace($backColor, '^[0-9a-f]{6}$') != '', 'Background color must be a hex color.';
// TODO: Validate date pattern.
// ---------------------------------------------------------------------------
// ----- HANDLE TOGGLING -----------------------------------------------------
// Get current instant color filters.
$icfs = Replace(colorfilter(),'||',"<crlf>");
// Are we already enabled?
$present = GetTokenIndex("$caption *", $icfs, "<crlf>", 'w') != 0;
// If keeping others remove ourselves, else remove all.
$icfs = $keepOthers ? formatlist($icfs, 'deft', "<crlf>", "!$caption *") : '';
// If already present and toggling, update filters and end.
if ($toggle && $present) {
colorfilter($icfs, "<crlf>");
Status 'Disabled highlighting.',, 'ready';
End true;
}
Unset $keepOthers, $toggle, $present;
// ----- GENERATE LIST OF ITEMS TO HIGHLIGHT ---------------------------------
/* TODO: We should be able to separate this from the outer sections so that we
** have a more generic script that makes applying and toggling any instant
** color filter generated via script easier.
*/
// Get the information for all items in the list.
$ret = Report("{Created $pattern}|{Modified $pattern}|{Fullname}<crlf>", 0);
if ($ret == '') {
Status 'No items in list.',, 'stop';
End true;
}
// Escape any wildcards that are in the item names.
$ret = RegexReplace($ret, '([?*#[])','[$1]');
// List of items that qualify for highlighting.
$matchList = '';
foreach ($item, $ret, "<crlf>") {
// Skip empty lines - shouldn't happen but for sanity.
if ($item == '') { continue; }
// Extract our dates.
$c = GetToken($item, 1, '|');
$m = GetToken($item, 2, '|');
// If the date patterns match.
if ($c == $m) {
// Append a ';' before adding another match.
if ($matchList != '') {
$matchList = $matchList . ';';
}
// Append the match to the list.
// We preceed each match with '*' to fool XY's auto-wildcarding, which
// should be okay since nothing extra should match before the full path.
$matchList = $matchList . '*' . GetToken($item, 3, '|');
}
}
Unset $pattern, $ret, $item, $c, $m;
// Clean up match list.
$matchList = FormatList($matchList, 'dents', ';');
// End if nothing matched.
if ($matchList == '') {
Status 'No items to highlight.',, 'ready';
End true;
}
// ----- GENERATE INSTANT COLOR FILTER FOR ITEM LIST -------------------------
// Create color filter list.
$icfs = <<<ICF
$caption $matchList>$textColor,$backColor
$icfs
ICF;
Unset $caption, $textColor, $backColor;
// Clean up color filter list.
$icfs = FormatList($icfs, 'det', "<crlf>");
// If the new filter is already active, do not deactivate it.
if ($icfs == Replace(colorfilter(),'||',"<crlf>")) {
Status 'Items are already highlighted.',, 'ready';
} else {
// Apply instant color filter.
colorfilter($icfs, "<crlf>");
$cnt = GetToken($matchList, 'count', ';');
Status 'Highlighted ' . $cnt . ' item' . ($cnt == 1 ? '' : 's') . '.',, 'ready';
}
Unset $icfs, $matchList, $cnt;