From: Maggie Date: Wed, 30 Apr 2014 21:16:58 +0000 (-0400) Subject: Removed center option and fit width of text for first three rows if user sets show... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=609df1edc4c196675e846ae3210911b54a42c3fd;p=civicrm-core.git Removed center option and fit width of text for first three rows if user sets show participant image to yes, cleaned up code and variable names --- diff --git a/CRM/Badge/BAO/Badge.php b/CRM/Badge/BAO/Badge.php index 640be3f146..0a4b105b14 100644 --- a/CRM/Badge/BAO/Badge.php +++ b/CRM/Badge/BAO/Badge.php @@ -125,8 +125,9 @@ class CRM_Badge_BAO_Badge { if (!empty($layout['data']['height_image_2'])) { $formattedRow['height_image_2'] = $layout['data']['height_image_2']; } - if (!empty($row['participant_image_URL'])) { - $formattedRow['participant_image'] = $row['participant_image_URL']; + if (!empty($row['image_URL']) && $layout['data']['show_participant_image']) + { + $formattedRow['participant_image'] = $row['image_URL']; } if (!empty($layout['data']['width_participant_image'])) { $formattedRow['width_participant_image'] = $layout['data']['width_participant_image']; @@ -199,9 +200,6 @@ class CRM_Badge_BAO_Badge { case 'L': $xAlign = 10; break; - case 'C': - $xAlign = 35; - break; default: break; } @@ -226,12 +224,18 @@ class CRM_Badge_BAO_Badge { if ($formattedRow['token'][$i]['token'] != 'spacer') { $value = $formattedRow['token'][$i]['value']; } - + + $rowWidth = $this->pdf->width; + $offsetRows = array(1, 2, 3); + if (!empty($formattedRow['participant_image']) && !empty($formattedRow['participant_image_width']) && in_array($i, $offsetRows)) + { + $rowWidth = $this->pdf->width - $formattedRow['participant_image_width']; + } $offset = $this->pdf->getY() + $startOffset + $cellspacing; $this->pdf->SetFont($formattedRow['token'][$i]['font_name'], $formattedRow['token'][$i]['font_style'], $formattedRow['token'][$i]['font_size']); - $this->pdf->MultiCell($this->pdf->width, 0, $value, + $this->pdf->MultiCell($rowWidth, 0, $value, $this->border, $formattedRow['token'][$i]['text_alignment'], 0, 1, $x, $offset); // set this to zero so that it is added only for first element @@ -376,15 +380,6 @@ class CRM_Badge_BAO_Badge { $layoutInfo = CRM_Badge_BAO_Layout::buildLayout($params); // spit / get actual field names from tokeni and individual contact image URLs - $participant_image_URLs = array(); - if (CRM_Utils_Array::value('participant_image', $layoutInfo['data'])){ - $layoutInfo['data']['participant_image_URL'] = ''; - $queryString = "SELECT civicrm_participant.id as participant_id, civicrm_contact.image_URL FROM civicrm_contact LEFT JOIN civicrm_participant ON civicrm_contact.id = civicrm_participant.contact_id WHERE {$form->_componentClause};"; - $dao = CRM_Core_DAO::executeQuery($queryString); - while ($dao->fetch()){ - $participant_image_URLs[$dao->participant_id] = $dao->image_URL; - } - } $returnProperties = array(); if (!empty($layoutInfo['data']['token'])) { foreach ($layoutInfo['data']['token'] as $index => $value) { @@ -415,7 +410,7 @@ class CRM_Badge_BAO_Badge { } // add additional required fields for query execution - $additionalFields = array('participant_register_date', 'participant_id', 'event_id', 'contact_id'); + $additionalFields = array('participant_register_date', 'participant_id', 'event_id', 'contact_id', 'image_URL'); foreach ($additionalFields as $field) { $returnProperties[$field] = 1; } @@ -456,9 +451,7 @@ class CRM_Badge_BAO_Badge { $rows[$dao->participant_id][$key] = isset($dao->$key) ? $dao->$key : NULL; } } - foreach ($participant_image_URLs as $participantId => $participant_image_URL) { - $rows[$participantId]['participant_image_URL'] = $participant_image_URL; - } + $eventBadgeClass = new CRM_Badge_BAO_Badge(); $eventBadgeClass->createLabels($rows, $layoutInfo); } diff --git a/CRM/Badge/Form/Layout.php b/CRM/Badge/Form/Layout.php index c3e6f064a0..66ba783d69 100644 --- a/CRM/Badge/Form/Layout.php +++ b/CRM/Badge/Form/Layout.php @@ -89,6 +89,8 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form { $fontStyles = CRM_Core_BAO_LabelFormat::getFontStyles(); $fontNames = CRM_Core_BAO_LabelFormat::getFontNames('name_badge'); $textAlignment = CRM_Core_BAO_LabelFormat::getTextAlignments(); + $imageAlignment = $textAlignment; + unset($imageAlignment['C']); $rowCount = self::FIELD_ROWCOUNT; for ( $i =1; $i <= $rowCount; $i++ ) { @@ -119,10 +121,10 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form { $this->add('text', 'height_image_2', ts('Height (mm)'), array('size' => 6)); - $this->add('checkbox', 'participant_image', ts('Use Participant Image?')); + $this->add('checkbox', 'show_participant_image', ts('Use Participant Image?')); $this->add('text', 'width_participant_image', ts('Width (mm)'), array('size' => 6)); $this->add('text', 'height_participant_image', ts('Height (mm)'), array('size' => 6)); - $this->add('select', "alignment_participant_image", ts('Image Alignment'), $textAlignment); + $this->add('select', "alignment_participant_image", ts('Image Alignment'), $imageAlignment); $this->add('checkbox', 'is_default', ts('Default?')); $this->add('checkbox', 'is_active', ts('Enabled?')); diff --git a/templates/CRM/Badge/Form/Layout.tpl b/templates/CRM/Badge/Form/Layout.tpl index dcdb7e2065..3570b66611 100644 --- a/templates/CRM/Badge/Form/Layout.tpl +++ b/templates/CRM/Badge/Form/Layout.tpl @@ -87,11 +87,11 @@ - {$form.participant_image.label} + {$form.show_participant_image.label} -
{$form.participant_image.html} + {$form.show_participant_image.html}
{ts}Select this option if you want to use a contact's image on their name badge.{/ts}