<?php if (!defined('PmWiki')) exit();
# vim: set ts=4 sw=4 et:
##
##        File: EditMX.php
##     Version: 2023-01-30
##      Status: alpha
##      Author: Peter Bowers
## Create Date: May 4, 2008
## Update to PHP 5.6: HansB
##   Copyright: 2008, Peter Bowers
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License, Version 2, as
## published by the Free Software Foundation.
## http://www.gnu.org/copyleft/gpl.html
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##

## EditMX update HansB 2023-01-30
## Updated 2023-08-23 by Petko pmwiki.org/petko
$RecipeInfo['EditMX']['Version'] = '20230823';

SDV($ROSPatterns['/\\{ROS(\\(\\w+\\b.*?\\))\\}/'], "EditMX");
SDV($ROEPatterns['/\\{ROE(\\(\\w+\\b.*?\\))\\}/'], "EditMX");
Markup('{edit(', '<{$var}',
  '/\\{edit(\\(\\w+\\b.*?\\))\\}/',
  "EditMX");

# The setting of $MXWhileEditing is designed to help MX recipes that are
# sensitive to $action=='edit' to recognize that it's OK for them to execute.
# (particularly this is necessary for WikiSh compatability)
function EditMX($m) {
    global $MXWhileEditing;
    $pagename = isset($GLOBALS['MarkupToHTML'])
      ? $GLOBALS['MarkupToHTML']['pagename']
      : $GLOBALS['pagename'];
    $MXWhileEditing = true;
    $rtn = MarkupExpression($pagename, $m[1]);
    $MXWhileEditing = false;
    return($rtn);
}