2 use CRM_Afform_ExtensionUtil
as E
;
4 class CRM_Afform_Page_AfformBase
extends CRM_Core_Page
{
6 public function run() {
7 // To avoid php complaints about the number of args passed to this function vs the base function
8 [$pagePath, $pageArgs] = func_get_args();
10 // The api will throw an exception if afform is not found (because of the index 0 param)
11 $afform = civicrm_api4('Afform', 'get', [
12 'where' => [['name', '=', $pageArgs['afform']]],
13 'select' => ['title', 'module_name', 'directive_name', 'type'],
16 $this->assign('directive', $afform['directive_name']);
18 (new \Civi\Angular\
AngularLoader())
19 ->setModules([$afform['module_name'], 'afformStandalone'])
22 // If the user has "access civicrm" append home breadcrumb
23 if (CRM_Core_Permission
::check('access CiviCRM')) {
24 CRM_Utils_System
::appendBreadCrumb([['title' => ts('CiviCRM'), 'url' => CRM_Utils_System
::url('civicrm')]]);
25 // If the user has "admin civicrm" & the admin extension is enabled
26 if (CRM_Core_Permission
::check('administer CiviCRM')) {
27 if (($pagePath[1] ??
NULL) === 'admin') {
28 CRM_Utils_System
::appendBreadCrumb([['title' => E
::ts('Admin'), 'url' => CRM_Utils_System
::url('civicrm/admin')]]);
30 if ($afform['type'] !== 'system' &&
31 \CRM_Extension_System
::singleton()->getMapper()->isActiveModule('afform_admin')
33 CRM_Utils_System
::appendBreadCrumb([['title' => E
::ts('Form Builder'), 'url' => CRM_Utils_System
::url('civicrm/admin/afform')]]);
34 CRM_Utils_System
::appendBreadCrumb([['title' => E
::ts('Edit Form'), 'url' => CRM_Utils_System
::url('civicrm/admin/afform', NULL, FALSE, '/edit/' . $pageArgs['afform'])]]);
39 if (!empty($afform['title'])) {
40 $title = strip_tags($afform['title']);
41 CRM_Utils_System
::setTitle($title);
42 CRM_Utils_System
::appendBreadCrumb([['title' => $title, 'url' => CRM_Utils_System
::url(implode('/', $pagePath)) . '#']]);