macros.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCoreSamples Samples
  7. * @{
  8. */
  9. /**
  10. * @page samples
  11. * @section macros Macros list
  12. */
  13. /**
  14. * This sample shows list of all available macros with links to the documentation
  15. */
  16. require_once('./../inc/header.inc.php');
  17. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  18. $oTemplate = BxDolTemplate::getInstance();
  19. $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
  20. $oTemplate->setPageHeader ("Macros List");
  21. $oTemplate->setPageContent ('page_main_code', PageCompMainCode());
  22. $oTemplate->getPageCode();
  23. /**
  24. * page code function
  25. */
  26. function PageCompMainCode()
  27. {
  28. ob_start();
  29. $aBaseClasses = array(
  30. 'BxBaseModGeneralModule' => 'bx_base_general',
  31. 'BxBaseServices' => 'bx_system_general',
  32. 'BxBaseServiceAccount' => 'bx_system_general',
  33. 'BxBaseServiceCategory' => 'bx_system_general',
  34. 'BxBaseServiceLogin' => 'bx_system_general',
  35. 'BxBaseServiceMetatags' => 'bx_system_general',
  36. 'BxBaseServiceProfiles' => 'bx_system_general',
  37. 'BxBaseChartServices' => 'bx_system_general',
  38. 'BxBasePaymentsServices' => 'bx_system_general',
  39. );
  40. $o = BxDolModuleQuery::getInstance();
  41. $aModules = $o->getModules();
  42. foreach ($aModules as $aModule) {
  43. $oModule = BxDolModule::getInstance($aModule['name']);
  44. if (!$oModule)
  45. continue;
  46. $oModuleReflection = new ReflectionClass(get_class($oModule));
  47. $a = bx_srv($aModule['name'], 'get_safe_services');
  48. if (!$a)
  49. continue;
  50. echo '<h3>' . $aModule['title'] . '</h3>';
  51. echo '<p>';
  52. foreach ($a as $sService => $sClass) {
  53. if ($sClass) {
  54. if (0 === strncmp('BxPayment', $sClass, 9))
  55. bx_import(substr($sClass, 9), 'bx_payment');
  56. $oModuleReflection = new ReflectionClass($sClass);
  57. }
  58. $oMethodReflection = $oModuleReflection->getMethod('service' . $sService);
  59. $sDeclaringClass = $oMethodReflection->getDeclaringClass()->getName();
  60. $sService = trim(preg_replace_callback('/[A-Z]/', function ($aMatches) {
  61. return '_' . strtolower($aMatches[0]);
  62. }, $sService), '_');
  63. $sModule = isset($aBaseClasses[$sDeclaringClass]) ? $aBaseClasses[$sDeclaringClass] : $aModule['name'];
  64. echo '<a href="https://ci.una.io/docs/service.html#' . $sModule . '-' . $sService . '">';
  65. echo '{{~' . $aModule['name'] . ':' . $sService . '[...]~}}';
  66. echo '</a><br />';
  67. }
  68. echo '</p>';
  69. }
  70. $s = ob_get_clean();
  71. return DesignBoxContent("Macros List", $s, BX_DB_PADDING_DEF);
  72. }
  73. /** @} */