X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FPage.php;h=e8908fea50f1852ed4e70d1ad15e9859db3bc4e4;hb=358a1864ba3c5a3fc3ff65f03b3db045ea2199a8;hp=4167e81023662aa9cc69b70955be211cf9233706;hpb=d0fcf9dfefc3d387ebcc155521c727de22a7a718;p=civicrm-core.git diff --git a/CRM/Core/Page.php b/CRM/Core/Page.php index 4167e81023..e8908fea50 100644 --- a/CRM/Core/Page.php +++ b/CRM/Core/Page.php @@ -1,9 +1,9 @@ _print = CRM_Core_Smarty::PRINT_NOFORM; } // Support 'json' as well as legacy value '6' - elseif (in_array($_REQUEST['snippet'], array(CRM_Core_Smarty::PRINT_JSON, 6))) { + elseif (in_array($_REQUEST['snippet'], [CRM_Core_Smarty::PRINT_JSON, 6])) { $this->_print = CRM_Core_Smarty::PRINT_JSON; } else { @@ -177,12 +177,12 @@ class CRM_Core_Page { CRM_Utils_Hook::pageRun($this); if ($this->_print) { - if (in_array($this->_print, array( + if (in_array($this->_print, [ CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON, - ))) { + ])) { $content = self::$_template->fetch('CRM/common/snippet.tpl'); } else { @@ -199,7 +199,7 @@ class CRM_Core_Page { if ($this->_print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, - array('paper_size' => 'a3', 'orientation' => 'landscape') + ['paper_size' => 'a3', 'orientation' => 'landscape'] ); } elseif ($this->_print == CRM_Core_Smarty::PRINT_JSON) { @@ -317,10 +317,10 @@ class CRM_Core_Page { public function getTemplateFileName() { return strtr( CRM_Utils_System::getClassName($this), - array( + [ '_' => DIRECTORY_SEPARATOR, '\\' => DIRECTORY_SEPARATOR, - ) + ] ) . '.tpl'; } @@ -406,4 +406,28 @@ class CRM_Core_Page { $this->$name = $value; } + /** + * Assign metadata about fields to the template. + * + * In order to allow the template to format fields we assign information about them to the template. + * + * At this stage only date field metadata is assigned as that is the only use-case in play and + * we don't want to assign a lot of unneeded data. + * + * @param string $entity + * The entity being queried. + * + * @throws \CiviCRM_API3_Exception + */ + protected function assignFieldMetadataToTemplate($entity) { + $fields = civicrm_api3($entity, 'getfields', ['action' => 'get']); + $dateFields = []; + foreach ($fields['values'] as $fieldName => $fieldMetaData) { + if (isset($fieldMetaData['html']) && CRM_Utils_Array::value('type', $fieldMetaData['html']) == 'Select Date') { + $dateFields[$fieldName] = CRM_Utils_Date::addDateMetadataToField($fieldMetaData, $fieldMetaData); + } + } + $this->assign('fields', $dateFields); + } + }