color modified date as files app does it
[grauphel.git] / controller / guicontroller.php
index 6fffcb2f7377db128d076d395e94d10156661c5b..127daafb1ada681d6b5f4f94c95c5c0b602a27f3 100644 (file)
@@ -157,6 +157,17 @@ class GuiController extends Controller
             }
         );
 
+        foreach ($notes as &$note) {
+            $diffInDays = intval(
+                (time() - strtotime($note['last-change-date'])) / 86400
+            );
+            $value = 0 + $diffInDays;
+            if ($value > 160) {
+                $value = 160;
+            }
+            $note['dateColor'] = '#' . str_repeat(sprintf('%02X', $value), 3);
+        }
+
         $res = new TemplateResponse('grauphel', 'tag');
         $res->setParams(
             array(