mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
add ext example for custom smart syntax
This commit is contained in:
parent
0a52e3a5f7
commit
d66a656733
3 changed files with 48 additions and 0 deletions
1
src/ext/_examples/CustomSmartSyntax/.htaccess
Normal file
1
src/ext/_examples/CustomSmartSyntax/.htaccess
Normal file
|
|
@ -0,0 +1 @@
|
|||
deny from all
|
||||
6
src/ext/_examples/CustomSmartSyntax/extension.json
Normal file
6
src/ext/_examples/CustomSmartSyntax/extension.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"bundleId": "CustomSmartSyntax",
|
||||
"name": "Custom Smart Syntax",
|
||||
"version": "1.0",
|
||||
"description": "Prototype to write you own smart syntax parser"
|
||||
}
|
||||
41
src/ext/_examples/CustomSmartSyntax/loader.php
Normal file
41
src/ext/_examples/CustomSmartSyntax/loader.php
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue