PageRenderTime 24ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/xfw/includes/plugins/tbs_plugin_syntaxes.php

http://xfw-xkid-framework.googlecode.com/
PHP | 150 lines | 36 code | 23 blank | 91 comment | 0 complexity | 4030dea790d8f62b9cbb1275108bb4cc MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /*
  3. ********************************************************
  4. TinyButStrong Plug-in: this is a template plug-in that shows syntaxes for all events
  5. Version 1.4 , on 2008-02-29, by Skrol29
  6. Version 1.5 , on 2010-02-16, by Skrol29: rename argument $HtmlCharSet into $Charset
  7. ********************************************************
  8. */
  9. // Name of the class is a keyword used for Plug-In authentication. So it's better to save it into a constant.
  10. define('TBS_THIS_PLUGIN','clsTbsThisPlugIn');
  11. // Put the name of the class into global variable array $_TBS_AutoInstallPlugIns to have it automatically installed for any new TBS instance.
  12. // Example :
  13. // $GLOBALS['_TBS_AutoInstallPlugIns'][] = TBS_THIS_PLUGIN;
  14. class clsTbsThisPlugIn {
  15. // Property $this->TBS is automatically set by TinyButStrong when the Plug-In is installed.
  16. // You can use it inside the following methods.
  17. function OnInstall() {
  18. // Executed when the current plug-in is installed automatically or manually.
  19. // You can define additional arguments to this method for the manual installation, but they should be optional in order to have the method compatible with automatic install.
  20. // This method must return the list of TBS reserved methods that you want to be activated.
  21. // Manual installation:
  22. // $TBS->PlugIn(TBS_INSTALL,TBS_PLUGIN_TEMPLATE);
  23. // or the first call of:
  24. // $TBS->PlugIn(TBS_THIS_PLUGIN);
  25. $this->Version = '1.00'; // Version can be displayed using [var..tbs_info] since TBS 3.2.0
  26. return array('OnCommand','BeforeLoadTemplate','AfterLoadTemplate','BeforeShow','AfterShow','OnData','OnFormat','OnOperation','BeforeMergeBlock','OnMergeSection','OnMergeGroup','AfterMergeBlock','OnSpecialVar','OnMergeField');
  27. }
  28. function OnCommand($x1,$x2) {
  29. // Executed when TBS method PlugIn() is called. Arguments are for your own needs.
  30. // You can use as many arguments as you want, but they have to be compatible with your PlugIn() calls.
  31. // Example: $TBS->PlugIn(TBS_THIS_PLUGIN,$x1,$x2);
  32. }
  33. function BeforeLoadTemplate(&$File,&$Charset) {
  34. // Executed before a template is loaded. Arguments are those passed to method LoadTemplate().
  35. // If you make this method to return value False, then the default LoadTemplate() process is not executed. But AfterLoadTemplate() is checked anyway.
  36. // You can define additional arguments to this method in order to extend the syntax of method LoadTemplate().
  37. }
  38. function AfterLoadTemplate(&$File,&$Charset) {
  39. // Executed after a template is loaded. Arguments are those passed to method LoadTemplate().
  40. // The value that you make this method to return is also returned by method LoadTemplate().
  41. // You can define additional arguments to this method in order to extend the syntax of method LoadTemplate().
  42. }
  43. function BeforeShow(&$Render) {
  44. // Executed when method Show() is called. Arguments are those passed to method Show().
  45. // If you make this method to return value False, then the default Show() process is not executed. But AfterShow() is checked anyway.
  46. // You can define additional arguments to this method in order to extend the syntax of method Show().
  47. }
  48. function AfterShow(&$Render) {
  49. // Executed at the end of method Show(). Arguments are those passed to method Show().
  50. // Output and exit are processed after this event but you can cancel any of them using the argument $Render.
  51. // The value that you make this method to return is also returned by method Show().
  52. // You can define additional arguments to this method in order to extend the syntax of method Show().
  53. }
  54. function OnData($BlockName,&$CurrRec,$RecNum,&$TBS) {
  55. // Executed during MergeBlock(), when TBS retrieve a record for merging.
  56. // This event has the same behavior as parameter "ondata", but coded in a plug-in.
  57. // Please note that this event is executed only once over the data source even they are several blocks to merge with it.
  58. // $BlockName: name of the block currently merged.
  59. // $CurrRec: (read/write) current record.
  60. // $RecNum: (read only) number of the current record (first is number 1).
  61. // $TBS: extra argument for coherence with parameter 'ondata'
  62. }
  63. function OnFormat($FieldName,&$Value,&$PrmLst,&$TBS) {
  64. // Executed each time an item value is merged to the template, so use it only if needed.
  65. // If you want to supply additional parameters to TBS, it's better to use the method OnOperation.
  66. // $FieldName: name of the field currently merged.
  67. // $Value: value about to be merged, before the string conversion if any.
  68. // $PrmLst: array of the field's parameters.
  69. // $TBS: extra argument for coherence with parameter 'onformat'
  70. }
  71. function OnOperation($FieldName,&$Value,&$PrmLst,&$Txt,$PosBeg,$PosEnd,&$Loc) {
  72. // If the function returns false, then the TBS default merging is canceled. This can be useful when you want to customize parameter 'ope' to proceed your own merging.
  73. // Executed each time a field contains parameter 'ope' with an unsupported keyword.
  74. // $FieldName: name of the field currently merged.
  75. // $Value: (read/write) value about to be merged, before the string conversion if any.
  76. // $PrmLst: the array of the field's parameters. We know that parameter 'ope' is set.
  77. // $Txt: optional, undocumented.
  78. // $PosBeg: optional, undocumented.
  79. // $PosEnd: optional, undocumented.
  80. // $Loc: optional, undocumented.
  81. }
  82. function BeforeMergeBlock(&$TplSource,&$BlockBeg,&$BlockEnd,$PrmLst,&$DataSrc,&$LocR) {
  83. // Executed each time a named block is found and ready for merging.
  84. // $TplSource: source of the current template.
  85. // $BlockBeg, $BlockEnd: positions of block's bound in the template's source.
  86. // $PrmLst: (Read only) the array of the block's parameters.
  87. // $DataSrc: optional, undocumented.
  88. // $LocR: optional, undocumented. (supported since TBS 3.0.5)
  89. }
  90. function OnMergeSection(&$Buffer,&$NewPart) {
  91. // Executed before a merged section is added to the block's buffer.
  92. }
  93. function OnMergeGroup(&$RecInfo,&$GrpDef,&$DataSrc,&$LocR) {
  94. // Excuted before a header, a footer or a splitter section is merged. (supported since TBS 3.3.0)
  95. // If the function returns False, then the section of the group is not merged.
  96. // $RecInfo: an object having properties CurrRec (current record read/write), RecNum and RecKey.
  97. // $GrpDef: an object having property Type and others undocumented.
  98. // $DataSrc: optional, undocumented.
  99. // $LocR: optional, undocumented.
  100. }
  101. function AfterMergeBlock(&$Buffer,&$DataSrc,&$LocR) {
  102. // Executed each time a named block is merged but not yet inserted to the template.
  103. // $Buffer: merged block contents to insert into the template.
  104. // $DataSrc: optional, undocumented. (supported since TBS 3.0.5)
  105. // $LocR: optional, undocumented. (supported since TBS 3.0.5)
  106. }
  107. function OnSpecialVar($Name,&$IsSupported,&$Value,&$PrmLst) {
  108. // Executed when an unsupported Special Var field ([var..*]) is met before TBS try to merge it.
  109. // This enables you define customized Special Var fields.
  110. // $Name: (Read only) the name of the current Special Var field.
  111. // $IsSupported: (Read/Write) set this argument to true to indicates that the plug-in supports the field, otherwise TBS will raise an error for unsupported Special Var field.
  112. // $Value: (Read/Write) value of the field (empty string by default).
  113. // $PrmLst: (Read/Write) the array of the field's parameters.
  114. /* Extended syntax:
  115. function OnSpecialVar($Name,&$IsSupported,&$Value,&$PrmLst,&$Source,&$PosBeg,&$PosEnd,&$Loc) {
  116. $Source: (Read/Write) current contents of the merged template;
  117. $PosBeg: (Read/Write) position of the first char of the current field in $Source. If this value is set to false, then TBS doesn't merge the field itself. In this case, $PosEnd must be set to the position where TBS must continue the merge.
  118. $PosEnd: (Read/Write) position of the last char of the current field in $Source.
  119. $Loc: optional, undocumented.
  120. }
  121. */
  122. function OnMergeField($AskedName,$SubName,&$Value,&$PrmLst,&$Source,&$PosBeg,&$PosEnd) {
  123. // Executed each time a field is merged using the MergeField() method.
  124. // If the function return False, then TBS won't merge the field assuming that it has been done by the current plug-in event
  125. }
  126. }
  127. ?>