Merge pull request #22873 from civicrm/5.47
[civicrm-core.git] / CRM / Core / Page.php
index eea1f96170ec4e36204979f2f951cf72e2268e49..4194e9bda745fc8723da13dbe115797fd587c827 100644 (file)
@@ -59,7 +59,9 @@ class CRM_Core_Page {
    * Are we in print mode? if so we need to modify the display
    * functionality to do a minimal display :)
    *
-   * @var bool
+   * @var int|string
+   *   Should match a CRM_Core_Smarty::PRINT_* constant,
+   *   or equal 0 if not in print mode
    */
   protected $_print = FALSE;
 
@@ -106,8 +108,6 @@ class CRM_Core_Page {
    * @var string[]
    */
   public $expectedSmartyVariables = [
-    'breadcrumb',
-    'pageTitle',
     'isForm',
     'hookContent',
     'hookContentPlacement',
@@ -121,6 +121,17 @@ class CRM_Core_Page {
     // required for Summary.tpl (contact summary) but seems
     // likely to be used more broadly to warrant inclusion here.
     'context',
+    // for CMSPrint.tpl
+    'urlIsPublic',
+    'breadcrumb',
+    'pageTitle',
+    'isDeleted',
+    // Required for footer.tpl,
+    // See ExampleHookTest:testPageOutput.
+    'footer_status_severity',
+    // in 'body.tpl
+    'suppressForm',
+    'beginHookFormElements',
   ];
 
   /**
@@ -212,12 +223,10 @@ class CRM_Core_Page {
       //its time to call the hook.
       CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
 
-      if ($this->_print == CRM_Core_Smarty::PRINT_PDF) {
-        CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE,
-          ['paper_size' => 'a3', 'orientation' => 'landscape']
-        );
+      if ($this->_print === CRM_Core_Smarty::PRINT_PDF) {
+        CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE);
       }
-      elseif ($this->_print == CRM_Core_Smarty::PRINT_JSON) {
+      elseif ($this->_print === CRM_Core_Smarty::PRINT_JSON) {
         $this->ajaxResponse['content'] = $content;
         CRM_Core_Page_AJAX::returnJsonResponse($this->ajaxResponse);
       }
@@ -385,7 +394,11 @@ class CRM_Core_Page {
   /**
    * Setter for print.
    *
-   * @param bool $print
+   * @param int|string $print
+   *   Should match a CRM_Core_Smarty::PRINT_* constant,
+   *   or equal 0 if not in print mode
+   *
+   * @return void
    */
   public function setPrint($print) {
     $this->_print = $print;
@@ -394,8 +407,9 @@ class CRM_Core_Page {
   /**
    * Getter for print.
    *
-   * @return bool
-   *   return the print value
+   * @return int|string
+   *   Value matching a CRM_Core_Smarty::PRINT_* constant,
+   *   or 0 if not in print mode
    */
   public function getPrint() {
     return $this->_print;