<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task {
/**
- * build all the data structures needed to build the form
+ * Build all the data structures needed to build the form
*
* @return void
- * @access public
*/
- function preProcess() {
+ public function preProcess() {
$this->set('contactIds', $this->_contactIds);
parent::preProcess();
}
/**
- * Build the form
+ * Build the form object
*
- * @access public
*
* @return void
*/
- function buildQuickForm() {
+ public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Make Mailing Labels'));
//add select for label
}
/**
- * This function sets the default values for the form.
+ * Set default values for the form.
*
* @param null
*
* @return array array of default values
- * @access public
*/
- function setDefaultValues() {
+ public function setDefaultValues() {
$defaults = array();
$format = CRM_Core_BAO_LabelFormat::getDefaultValues();
$defaults['label_name'] = CRM_Utils_Array::value('name', $format);
}
/**
- * process the form after the input has been submitted and validated
+ * Process the form after the input has been submitted and validated
*
- * @access public
*
* @return void
*/
$mailingFormatProperties = array();
if ($mailingFormat) {
- $mailingFormatProperties = self::getReturnProperties($mailingFormat);
+ $mailingFormatProperties = CRM_Utils_Token::getReturnProperties($mailingFormat);
$returnProperties = array_merge($returnProperties, $mailingFormatProperties);
}
//we should not consider addressee for data exists, CRM-6025
continue;
}
+ $contact = array_merge($contact, $contact[$locName]);
unset($contact[$locName]);
if (!empty($contact['county_id'])) {
*
* @return bool
*/
- function tokenIsFound($contact, $mailingFormatProperties, $tokenFields) {
+ public function tokenIsFound($contact, $mailingFormatProperties, $tokenFields) {
foreach (array_merge($mailingFormatProperties, array_fill_keys($tokenFields, 1)) as $key => $dontCare) {
if (!empty($contact[$key])) {
return TRUE;
return FALSE;
}
/**
- * function to create labels (pdf)
+ * Create labels (pdf)
*
* @param array $contactRows assciated array of contact data
* @param string $format format in which labels needs to be printed
* @param string $fileName The name of the file to save the label in
*
* @return null
- * @access public
*/
- function createLabel(&$contactRows, &$format, $fileName = 'MailingLabels_CiviCRM.pdf') {
+ public function createLabel(&$contactRows, &$format, $fileName = 'MailingLabels_CiviCRM.pdf') {
$pdf = new CRM_Utils_PDF_Label($format, 'mm');
$pdf->Open();
$pdf->AddPage();
$pdf->Output($fileName, 'D');
}
- /**
- * function to create the array of returnProperties
- *
- * @param string $format format for which return properties build
- *
- * @return array of returnProperties
- * @access public
- */
- function getReturnProperties(&$format) {
- $returnProperties = array();
- $matches = array();
- preg_match_all('/(?<!\{|\\\\)\{(\w+\.\w+)\}(?!\})/',
- $format,
- $matches,
- PREG_PATTERN_ORDER
- );
- if ($matches[1]) {
- foreach ($matches[1] as $token) {
- list($type, $name) = preg_split('/\./', $token, 2);
- if ($name) {
- $returnProperties["{$name}"] = 1;
- }
- }
- }
-
- return $returnProperties;
- }
-
/**
* @param $rows
*/
- function mergeSameAddress(&$rows) {
+ public function mergeSameAddress(&$rows) {
$uniqueAddress = array();
foreach (array_keys($rows) as $rowID) {
// load complete address as array key
}
}
}
-