-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpnuserapi.php
829 lines (707 loc) · 25.2 KB
/
pnuserapi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
<?php
/**
* FEproc - Mail template backend module for FormExpress for
* Zikula Content Management System
*
* @copyrightt (C) 2002 by Jason Judge, 2011 Chris Candreva
* @Version $Id: $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package FEproc
*
*
* LICENSE
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License (GPL)
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* To read the license please visit http://www.gnu.org/copyleft/gpl.html
* ----------------------------------------------------------------------
* Original Author of file: Jason Judge.
* Based on template by Jim MacDonald.
* Current Maintainer of file: Chris Candreva <chris@westnet.com>
* ----------------------------------------------------------------------
*
*/
/**
* Count the number of workflow sets available.
* @returns int
* @return number of sets available.
*/
function feproc_userapi_countsets()
{
// Early security check.
if (!SecurityUtil::checkPermission ('FEproc::', '::', ACCESS_READ)) {
return LogUtil::registerPermissionError();
}
$pntable = pnDBGetTables();
$wfColumn = $pntable['feproc_workflow_column'];
$where = "$wfColumn[type] = 'set'";
return DBUtil::selectObjectCount('feproc_workflow', $where, 'id', '');
}
/**
* Count the number of workflow sets available.
* @returns int
* @return number of sets available.
*/
function feproc_userapi_countstages($args)
{
// Early security check.
if (!SecurityUtil::checkPermission ('FEproc::', '::', ACCESS_READ)) {
return LogUtil::registerPermissionError();
}
if (isset($args['setid']) && is_numeric($args['setid']))
{
$setid = $args['setid'];
} else {
$setid = 0;
}
$table = pnDBGetTables();
$wfColumn = $table['feproc_workflow_column'];
$where = "$wfColumn[type] = 'set'";
$where = "$wfColumn[type] != 'set' AND $wfColumn[setid] = $setid";
return DBUtil::selectObjectCount('feproc_workflow', $where, 'id', '');
}
/**
* Get summary of all sets.
* @returns associative array
* (setid,name,description,startstageid,startstagename)
* @return set specification
*/
function feproc_userapi_getallsets($args)
{
// Early security check.
if (!SecurityUtil::checkPermission ('FEproc::', '::', ACCESS_READ)) {
return LogUtil::registerPermissionError();
}
// Get arguments from argument array.
extract($args);
// Argument check
if (!isset($startnum))
{
$startnum = 0;
} else {
--$startnum;
}
if (!isset($numitems))
{
$numitems = 999999;
}
$sets = array();
// Get datbase setup
$table = pnDBGetTables();
$wfTable = $table['feproc_workflow'];
$wfColumn = $table['feproc_workflow_column'];
$where = "tbl.$wfColumn[type] = 'set'";
// Join to get name of start stage.
$joinInfo = array();
$joinInfo[] = array(
'join_table' => 'feproc_workflow',
'join_field' => 'name',
'object_field_name' => 'startstagename',
'compare_field_table' => 'successid',
'compare_field_join' => 'id',
);
$sets = DBUtil::selectExpandedObjectArray('feproc_workflow', $joinInfo, $where, 'name', $startnum, $numitems );
// Rename successid to startstageid
foreach ($sets as &$set)
{
$set['startstageid'] = $set['successid'];
}
return $sets;
}
/**
* Get a single set.
* @returns associative array
* (setid,name,description,startstageid,startstagename)
* @return set specification
*/
function feproc_userapi_getset($args)
{
// Early security check.
if (!SecurityUtil::checkPermission ('FEproc::', '::', ACCESS_READ)) {
return LogUtil::registerPermissionError();
}
// Get arguments from argument array.
extract($args);
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', "::", ACCESS_READ))
{
return false;
}
if (!isset($setid) || !is_numeric($setid))
{
return false;
}
// Get datbase setup
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$wfTable = $pntable['feproc_workflow'];
$wfColumn = $pntable['feproc_workflow_column'];
$set = DBUtil::selectObjectByID('feproc_workflow', $setid);
// Get the name of the start stage.
if ($set['successid'])
{
$startstage = pnModAPIFunc('feproc', 'user', 'getstage',
array('stageid' => $set['successid']));
$set['startstage'] = $startstage['name'];
$set['startstageid'] = $set['successid'];
} else {
$set['startstage'] = null;
}
// Handle legacy name
$set['setid'] = $set['id'];
return $set;
}
/**
* Get stage specification
* The input parameters 'tid' and 'tname' are mutualy exclusive - use only
* one of them (either id or name).
* @param args['tid'] template id
* @param args['tname'] template name
* @returns associative array
* (id,name,description,subject,fromaddress,template)
* @return template specification
*/
function feproc_userapi_getstage($args)
{
// Get arguments from argument array.
extract($args);
$pntable = pnDBGetTables();
$wfColumn = $pntable['feproc_workflow_column'];
$where = ' 1=1';
if (isset($stageid) && is_numeric($stageid))
{
$where = $where . " AND $wfColumn[id] = $stageid";
}
if (isset($setid) && is_numeric($setid))
{
$where = $where . " AND $wfColumn[setid] = $setid";
}
if (isset($handlerid) && is_numeric($handlerid))
{
$where = $where . " AND $wfColumn[handlerid] = $handlerid";
}
if (isset($name))
{
$where = $where . " AND $wfColumn[name] = '$name'";
}
if (isset($set))
{
// Calling function has asked for sets.
$where = $where . " AND $wfColumn[type] = 'set' ";
}
if (isset($start))
{
// Calling function has asked for starting stages.
// Get the list of starting stages from the list of sets.
// o If a stage id has been passed in, then limit to that stage only.
// o If no stage id has been passed in, then just get default
// starting stages.
// All starting stages will have the starting stage flag set.
$where = $where . " AND $wfColumn[startstage] > 0 ";
// TODO: this next bit may be best solved by getting the set and
// then checking the 'default start stage' attribute for that set.
if (!isset($stageid))
{
// We have just been given the set to look at:
// get default starting stages for each set.
$startstages = DBUtil::selectFieldArray('feproc_workflow','successid',
"$wfColumn[type] = 'set' AND $wfColumn[successid] > 0");
if (!empty($startstages))
{
$where = $where . " AND $wfColumn[id] IN(" . implode(',', $startstages) . ") ";
}
}
}
$stages = DBUtil::selectObjectArray('feproc_workflow', $where);
$stage = $stages[0];
$stage['stageid'] = $stage['id'];
$stage['attributes'] = unserialize($stage['attributes']);
return $stage;
}
/**
* Get summary of all stages.
* @returns associative array
* (setid,name,description,type,handlerid,handlername,successid,successname,failureid,failurename,setid)
* @return set specification
*/
function feproc_userapi_getallstages($args)
{
// Early security check.
if (!SecurityUtil::checkPermission ('FEproc::', '::', ACCESS_READ)) {
return LogUtil::registerPermissionError();
}
// Get arguments from argument array.
extract($args);
// Argument check
if (!isset($startnum))
{
$startnum = 0;
} else {
--$startnum;
}
if (!isset($numitems))
{
$numitems = 999999;
}
$table = pnDBGetTables();
$wfColumn = $table['feproc_workflow_column'];
$where = " tbl.$wfColumn[type] != 'set' ";
if ($setid && is_numeric($setid))
{
$where .= " AND tbl.$wfColumn[setid] = $setid";
}
$joinInfo = array();
$joinInfo[] = array(
'join_table' => 'feproc_workflow',
'join_field' => 'name',
'object_field_name' => 'startstagename',
'compare_field_table' => 'successid',
'compare_field_join' => 'id',
);
$joinInfo = array(
array(
'join_table' => 'feproc_workflow',
'join_field' => 'name',
'object_field_name' => 'successname',
'compare_field_table' => 'successid',
'compare_field_join' => 'id',
),
array(
'join_table' => 'feproc_workflow',
'join_field' => 'name',
'object_field_name' => 'failurename',
'compare_field_table' => 'failureid',
'compare_field_join' => 'id',
),
);
$stages = DBUtil::selectExpandedObjectArray('feproc_workflow', $joinInfo, $where, 'id', $startnum, $numitems );
foreach ($stages as &$stage) {
$stage['stageid'] = $stage['id'];
}
unset($stage);
return $stages;
}
/**
* Return a URL to invoke the specified stage.
* @returns url or false if none could be determined.
* @return the url to invoke the stage.
* @param 'stageid' the ID of the current stage, where known.
* @param 'reset' indicates if the set is to be reset before running the stage.
*/
function feproc_userapi_stageurl($args)
{
extract($args);
if (empty($stageid) && empty($setid))
{
return false;
}
// Search array to fetch the stage.
$findstage = array();
// Get the stage details for the set.
if (!empty($setid))
{
$findstage['setid'] = $setid;
}
if (!empty($stageid))
{
$findstage['stageid'] = $stageid;
}
if ($reset || empty($stageid))
{
// If reseting the set or just running a set, then we must
// be going to a starting stage.
$findstage['start'] = true;
}
$stage = pnModAPIFunc('feproc', 'user', 'getstage', $findstage);
if (!$stage)
{
// Could not find any stage to match.
return false;
}
$url = false;
// Jump straight to the FormExpress module - but only if
// we don't want to reset the set first.
if ($stage['type'] == 'formexpress' && !$reset)
{
$url = pnModURL(
'FormExpress', 'user', 'display_form',
Array('form_id' => $stage['handlerid'])
);
} else {
// Jump to the FEproc process stage.
// Query parameters on the final URL.
$querystring = array();
// Pass 'reset' to the URL if we want to reset the set when running.
if ($reset)
{
$querystring['reset'] = '1';
}
$querystring['stageid'] = $stage['stageid'];
$url = pnModURL('feproc', 'user', 'process', $querystring);
}
// Now switch between secure and non-secure modes if needed.
// This relies on the fact that pnModURL does not attempt to
// change the current protocol: it returns a full URL with the
// current protocol intact.
if (preg_match('/^http:/i', $url) && $stage['secure'])
{
// Needs to be secure but is not yet.
$url = preg_replace('/^http:/i', 'https:', $url);
}
elseif (preg_match('/^https:/i', $url) && !$stage['secure'])
{
// Is secure but no need for it.
$url = preg_replace('/^https:/i', 'http:', $url);
}
return $url;
}
/**
* Get the next user stage. Will pass through as many non-user stages
* as necessary to get there.
* @returns array('action', 'url', 'text', 'complete')
* @return the next stage to be executed in the current set.
* @param 'type' the type of the current stage (start, display, formexpress, form, etc.)
* @param 'formid' the ID of the form (regardless whether FormExpress or a standard form)
* @param 'setid' the ID of the current set, where known.
* @param 'stageid' the ID of the current stage, where known.
* @param 'success' the result of the current stage (success or failure - boolean)
*/
function feproc_userapi_nextstage($args)
{
// Get arguments from argument array.
extract($args);
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', '::', ACCESS_READ))
{
return false;
}
// Default return array.
$nextstage = Array(
'action' => false, // Action (redirect or display)
'url' => false, // Redirection URL (for redirect action)
'text' => false, // Text to show (for display action)
'complete' => false // Flag indicates this is the last stage
);
// Get the current feproc session so we can validate the stage we just came from.
$sessiondata = new feprocSession();
// Validation is as follows:
// TODO: validation as per design matrix.
// Now process as many stages as needed before handing
// control back to the user.
$stagesprocessed = Array();
while (true)
{
$stage = pnModAPIFunc(
'feproc', 'user', 'getstage',
array('stageid' => $stageid)
);
if (!$stage['successid'] && !$stage['failureid'])
{
$complete = true;
} else {
$complete = false;
}
// Error if the stage details could not be fetched.
// TODO: use templates for errors.
if (! $stage)
{
$nextstage = Array(
'action' => 'error',
'url' => false,
'text' => "The current stage $stageid (set $setid, handler $handlerid) does not exist.",
'complete' => true
);
break;
}
// Check that we have not processed this stage too many times.
if (! $stagesprocessed[$stageid])
{
$stagesprocessed[$stageid] = 1;
} else {
$stagesprocessed[$stageid] += 1;
if ($stagesprocessed[$stageid] > 5) // TODO: configurable.
{
// TODO: better error message.
$nextstage = Array(
'action' => 'error',
'url' => false,
'text' => 'Stage is being processed too many times (infinite loop?).',
'complete' => true
);
break;
}
}
// If the stage is a user stage then return control to the user now.
// If it is not then execute it.
// Next stage is a user stage.
if ($stage['type'] == 'formexpress' || $stage['type'] == 'form'
|| $stage['type'] == 'display' || $stage['type'] == 'redirect')
{
$url = pnModAPIFunc(
'feproc', 'user', 'stageurl',
array('stageid' => $stageid)
);
$nextstage = Array(
'action' => $stage['type'],
'url' => $url,
'text' => false,
'stageid' => $stageid,
'stage' => $stage,
'complete' => $complete
);
$sessiondata->putStageID($stageid);
break;
}
$result = false;
// Next stage is an internal handler.
if ($stage['type'] == 'transmit' || $stage['type'] == 'transform' || $stage['type'] == 'validate')
{
// TODO: get the template details and expand the template, then pass in
// to the transmit API function, along with some other details.
// This will be similar to the 'display' handler type in that templates
// need expanding.
// Get the template-substituted handler data.
$handlerdata = pnModAPIFunc(
'feproc', 'user', 'handlerdata',
array('stageid' => $stageid)
);
// Get the handler details.
$handler = pnModAPIFunc(
'feproc', 'handleruser', 'gethandler',
array('hid' => $stage['handlerid'])
);
// The handler may not exist.
if (!$handler)
{
$nextstage = Array(
'action' => 'error',
'url' => false,
'text' => "Handler does not exist (hid=$stage[handlerid]).",
'complete' => true
);
break;
}
// Call the handler processing function.
$handlerReturn = pnModAPIFunc(
$handler['modulename'], $handler['apiname'], $handler['apifunc'],
array('action' => 'execute', 'info' => $handlerdata)
);
// Set the handler status (success/fail) and loop back for next stage.
if ($handlerReturn['result'])
{
$result = true;
} else {
$result = false;
}
// Log a stack message.
// TODO: limit the size of the stack so it cannot be made to overflow.
if (pnModGetVar('FEproc', 'tracestack'))
{
$sessiondata->setMessages(Array('stack' => "$stageid: $stage[type] result: " . ($handlerReturn[result] ? "success":"failure")), true);
}
}
if ($stage['type'] == 'transform' && $result)
{
// A successful transform stage was done.
// Store the values transformed in the form array.
if (is_array($handlerReturn['form']))
{
foreach($handlerReturn['form'] as $tkey => $tvalue)
{
$sessiondata->addFormData(array($tkey => $tvalue));
}
}
}
// Any handler can return messages. Pick up the messages if any were returned.
if (is_array($handlerReturn['messages']))
{
$sessiondata->setMessages($handlerReturn['messages']);
}
// Get the ID for the next stage.
if ($result)
{
$nextstageid = $stage['successid'];
} else {
$nextstageid = $stage['failureid'];
}
if (! $nextstageid)
{
// There is not a next stage defined for this stage.
// Raise an error as we should not have been able to get
// here if there was nowhere to go after.
// TODO: templated error message.
$nextstage = Array(
'action' => 'error',
'url' => false,
'text' => 'The set has ended unexpectedly. The stage result has nowhere to go.',
'complete' => true
);
break;
}
// The next stage is now the current stage.
// Loop around and process the new stage.
$stageid = $nextstageid;
$sessiondata->putStageID($stageid);
}
return $nextstage;
}
/**
* Create handler information with template field substritions where relevant.
* one of them (either id or name).
* @param args['$stageid'] current stage id
* @param args['$successid'] success stage id
* @param args['$failureid'] failure stage id
* @returns associative array
* @return data for handler with template field substitutions.
*/
function feproc_userapi_handlerdata($args)
{
extract($args);
$handlerinfo = Array();
// Form data.
$sessiondata = new feprocSession();
$handlerinfo['form'] = $sessiondata->getFormData();
// Current stage details.
$stage = pnModAPIFunc(
'feproc', 'user', 'getstage',
array('stageid' => $stageid)
);
if (!$stage)
{
return false;
}
// Messages.
$handlerinfo['messages'] = $sessiondata->getMessages();
// Links. The links are the success, failure and back URLs.
// TODO: since we call this function so many times, allow a pointer
// to the stage array to be passed in so save on database queries.
//
// Link names are:-
//
// successurl - success stage
// resetsuccessurl - success stage, reset set first, must be starting stage
// failureurl - failure stage
// resetfailureurl - failure stage, reset set first, must be starting stage
// seturl - go to set default start stage
// reseturl - go to set default start stage, reset set first
// starturl - go to starting stage that started this stage instance
// (allows for starting again with a multiple entry-point
// set
// restarturl - go to starting stage that started this stage instance,
// reset set first
//
if ($stage['successid'])
{
// Get the success stage url.
$handlerinfo['links']['successurl'] = pnModAPIFunc(
'feproc', 'user', 'stageurl',
array('stageid' => $stage['successid'])
);
$handlerinfo['links']['resetsuccessurl'] = pnModAPIFunc(
'feproc', 'user', 'stageurl',
array('stageid' => $stage['successid'], 'reset' => '1')
);
}
if ($stage['failureid'])
{
$handlerinfo['links']['failureurl'] = pnModAPIFunc(
'feproc', 'user', 'stageurl',
array('stageid' => $stage['failureid'])
);
$handlerinfo['links']['resetfailureurl'] = pnModAPIFunc(
'feproc', 'user', 'stageurl',
array('stageid' => $stage['failureid'], 'reset' => '1')
);
}
// Set and reset goes back to the default start stage in the set
// (if there is one).
// TODO: check there is a default start stage.
if ($stage['setid'])
{
$handlerinfo['links']['seturl'] = pnModAPIFunc(
'feproc', 'user', 'stageurl',
array('setid' => $stage['setid'])
);
$handlerinfo['links']['reseturl'] = pnModAPIFunc(
'feproc', 'user', 'stageurl',
array('setid' => $stage['setid'], 'reset' => '1')
);
}
// Start goes back to the default actual start stage in the set.
if ($sessiondata->getStartStageID())
{
$handlerinfo['links']['starturl'] = pnModAPIFunc(
'feproc', 'user', 'stageurl',
array('stageid' => $sessiondata->getStartStageID())
);
// Restart clears down the session then goes back to the actual
// start stage in the set.
$handlerinfo['links']['restarturl'] = pnModAPIFunc(
'feproc', 'user', 'stageurl',
array('stageid' => $sessiondata->getStartStageID(), 'reset' => '1')
);
}
// System variables.
$handlerinfo['system'] = Array(
'setid' => $stage['setid'],
'stageid' => $stageid,
'type' => $stage['type'],
'complete' => (!$stage['successid'] && !$stage['failureid'] ? 1 : 0),
'transaction' => $sessiondata->getTRXid(),
'adminmail' => pnConfigGetvar('adminmail'),
'sitename' => pnConfigGetvar('sitename'),
'slogan' => pnConfigGetvar('slogan')
);
// Attributes from the stage (the template, parameters etc.)
$handlerinfo['attributes'] = $stage['attributes'];
// Substitute form and other values in the attributes. Do all the attributes.
// Loop for each attribute that may need changing.
foreach ($handlerinfo['attributes'] as $attrName => $attrValue)
{
foreach (array('form', 'system', 'links', 'messages') as $type) {
// Do string replacements from the various data types.
if (is_array($handlerinfo[$type]))
{
foreach ($handlerinfo[$type] as $itemName => $itemValue)
{
$attrValue = str_ireplace('${' . $type . ':' . $itemName. '}', $itemValue, $attrValue);
}
}
}
$handlerinfo['attributes'][$attrName] = $attrValue;
} // foreach ($handlerinfo['attributes'] as $attrName => $attrValue)
$removeunmatched = pnModGetVar('FEproc', 'removeunmatched');
// Now do the same between the attributes so they can reference each other.
if (is_array($handlerinfo['attributes']))
{
foreach ($handlerinfo['attributes'] as $attrName => $attrValue)
{
// Do string replacements on the form data.
foreach ($handlerinfo['attributes'] as $itemName => $itemValue)
{
// Suppress self-referencing loops.
if ($attrName != $itemName)
{
$attrValue = str_ireplace('${attribute:' . $itemName. '}', $itemValue, $attrValue);
if ($removeunmatched)
{
// Finally remove any fields that have not matched anything.
// TODO: visit this preg and make it strictor (form|attribute|...)
$attrValue = preg_replace('/\${[^:]+:[^}]+}/', '', $attrValue);
}
}
}
$handlerinfo['attributes'][$attrName] = $attrValue;
}
}
return $handlerinfo;
}
?>