Пример #1
0
	public function fromSubscriptionToProvider(Interspire_EmailIntegration_Field $field, $value)
	{
		if ($field instanceof Interspire_EmailIntegration_Field_StringInterface) {
			return $field->valueToString($value);
		}

		return '';
	}
Пример #2
0
	public function fromSubscriptionToProvider (Interspire_EmailIntegration_Field $field, $value)
	{
		if ($field instanceof Interspire_EmailIntegration_Field_StringInterface) {
			return $field->valueToString($value);
		}

		// other complex field that does not map to a basic string
		return '';
	}
Пример #3
0
	public function fromSubscriptionToProvider(Interspire_EmailIntegration_Field $field, $value)
	{
		if ($field instanceof Interspire_EmailIntegration_Field_Address) {
			// if the field is an address type, the data should already be formatted
			return $value;
		}

		if ($field instanceof Interspire_EmailIntegration_Field_StringInterface) {
			// cast to string if field supports it
			return $field->valueToString($value);
		}

		// other complex value that won't map properly
		return '';
	}
Пример #4
0
	public function fromSubscriptionToProvider(Interspire_EmailIntegration_Field $field, $value)
	{
		if ($field instanceof Interspire_EmailIntegration_Field_NumberInterface) {
			// anything here supports a ToNumber conversion
			return $field->valueToNumber($value);
		}

		if ($field instanceof Interspire_EmailIntegration_Field_StringInterface) {
			// anything else that can boil down to a string should be sent as is; mailchimp will handle conversion and rounding
			return $field->valueToString($value);
		}

		// other complex fields that won't map
		return '';
	}
Пример #5
0
	public function fromSubscriptionToProvider(Interspire_EmailIntegration_Field $field, $value)
	{
		if ($field instanceof Interspire_EmailIntegration_Field_Date) {
			// for dates, the value /should/ be convertable to a timestamp, so we can date() it and send it through as mailchimp requires
			// note: if I sent a date formatted using isc_date_tz to mailchimp, they would convert it to local time (so 2010-04-28 became 2010-04-27) *even if the mailchimp account was set to +10* - so, I'm sending it through without a tz indicator and it seems to make more sense -ge
			return isc_date('Y-m-d H:i:s', $field->valueToNumber($value));
		}

		if ($field instanceof Interspire_EmailIntegration_Field_StringInterface) {
			// for other string-compatible fields, try sending that through and let mailchimp sort it out
			return $field->valueToString($value);
		}

		// other field types that won't map
		return '';
	}
Пример #6
0
	public function fromSubscriptionToProvider (Interspire_EmailIntegration_Field $field, $value)
	{
		if ($field instanceof Interspire_EmailIntegration_Field_Date) {
			$timestamp = $field->valueToNumber($value);

			// the d/m/y order is defined in the Key returned by IEM when querying custom fields
			$format = 'j/n/Y'; // default/fallback
			if (isset($this->_settings['Key']) && count($this->_settings['Key']) >= 3) { // basic validation
				$key = $this->_settings['Key'];
				$format = $this->dateSettingToFormat($key[0]) . '/' . $this->dateSettingToFormat($key[1]) . '/' . $this->dateSettingToFormat($key[2]);
			}

			return date($format, $timestamp);
		}

		if ($field instanceof Interspire_EmailIntegration_Field_StringInterface) {
			// for other string-compatible fields, try sending that through and let IEM sort it out
			return $field->valueToString($value);
		}

		// other field types that won't map
		return '';
	}
Пример #7
0
	/**
	* This method takes a piece of data from a subscription and translates it into a suitable value for sending to {provider} based on the type of local and remote fields being mapped
	*
	* This method essentially automates a call to Interspire_EmailIntegration_{provider}_Field_{provider_field_type}->fromSubscriptionToProvider({subcription_field_type}, {subscription_field_value})
	*
	* @param Interspire_EmailIntegration_Field $subscriptionField
	* @param array $providerField A record from email_provider_list_fields
	* @param mixed $subscriptionValue The individual piece of data to be translated
	* @param array $subscriptionData The full subscription data (as some translations require access to other fields to work properly, such as order value formatting w/ correct exchange rates)
	*/
	public function translateMergeField(Interspire_EmailIntegration_Field $subscriptionField, $providerField, $subscriptionValue, $subscriptionData)
	{
		$baseClassName = $this->getProviderLibClassName();

		$providerFieldClassName = 'Interspire_EmailIntegration_' . $baseClassName . '_Field_' . ucfirst($providerField['type']);

		if (!class_exists($providerFieldClassName)) {
			$GLOBALS['ISC_CLASS_LOG']->LogSystemNotice(array('emailintegration', $this->GetName()), GetLang('EmailIntegration_Log_UnableToTranslateField', array(
				'provider' => $this->GetName(),
				'field_type' => $providerField['type'],
				'field_name' => $providerField['name'],
				'class_name' => $providerFieldClassName,
				'subscription_field_name' => $subscriptionField->description,
			)));

			if ($subscriptionField instanceof Interspire_EmailIntegration_Field_StringInterface) {
				return $subscriptionField->valueToString($value);
			}

			return '';
		}

		/** @var Interspire_EmailIntegration_ProviderField */
		$providerFieldClass = new $providerFieldClassName($providerField);
		$translation = $providerFieldClass->fromSubscriptionToProvider($subscriptionField, $subscriptionValue);

		if ($translation === null) {
			return '';
		}

		return $translation;
	}