add ext example for custom smart syntax

This commit is contained in:
maxpozdeev 2023-09-10 22:45:08 +03:00
parent 0a52e3a5f7
commit d66a656733
3 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1 @@
deny from all

View file

@ -0,0 +1,6 @@
{
"bundleId": "CustomSmartSyntax",
"name": "Custom Smart Syntax",
"version": "1.0",
"description": "Prototype to write you own smart syntax parser"
}

View file

@ -0,0 +1,41 @@
<?php declare(strict_types=1);
/*
This file is a part of myTinyTodo.
(C) Copyright 2023 Max Pozdeev <maxpozdeev@gmail.com>
Licensed under the GNU GPL version 2 or any later. See file COPYRIGHT for details.
*/
if (!defined('MTTPATH')) {
die("Unexpected usage.");
}
function mtt_ext_customsmartsyntax_instance(): MTTExtension
{
return new CustomSmartSyntaxExtension();
}
class CustomSmartSyntaxExtension extends MTTExtension implements MTTFilterInterface
{
//the same as dir name
const bundleId = 'CustomSmartSyntax';
function init() {
\MTTFilterCenter::addFilterForAction('parseSmartSyntax', $this);
}
// parseSmartSyntax
function filter($title, &$out)
{
$a = [
'prio' => 0, // int: -1 .. 2
'title' => $title, // string
'tags' => '', // string: "tag1, tag2, tag3,..."
'duedate' => null, // string: "Y-m-d" format
];
// This filter just overwrites results of default parser
$out = $a;
}
}