The Inx_Api_Property_FormatChoicePropertyFormatter is used for converting the mail format property to and from the internal string representation.
The Inx_Api_Property_FormatChoicePropertyFormatter is used for converting the mail format property to and from the internal string representation. For this property, there is no dedicated value holder like the Inx_Api_Property_ApprovalPropertyValue. Instead, the formatter itself contains all relevant data:
<strong>Note:</strong> When using the ATTRIBUTE_STRATEGY it is recommended to create multipart mailings only. However, it is still possible to create plain or HTML text mailings. Be aware that in such a case, all recipients will receive the mailing in the same format (which is plain or HTML text).
The attribute strategy requires an attribute id, a default mail format and attribute value patterns that determine which mail format to use. If the value of an attribute matches the pattern, the format associated to this pattern will be chosen. If the value matches none of the specified patterns, the default format will be used. The pattern of the default format is automatically set to null.
The patterns are <strong>not</strong> patterns in the ordinary sense. No operators or wildcards are allowed and the value is case sensitive and without quotes. Let's say we use the following patterns:
The following snippet shows how to retrieve and parse the mail format property of the specified list:
$oListContext = $oSession->getListContextManager()->findByName("Desired list"); $oProperty = $oListContext->findProperty(Inx_Api_Property_PropertyNames::MAIL_FORMAT_CHOICE); $oFormatChoicePropertyFormatter = Inx_Api_Property_FormatChoicePropertyFormatter::parse($oProperty); echo "Format strategy: ".$oFormatChoicePropertyFormatter->getChoiceStategy()."<br>"; echo "Default format: ".$oFormatChoicePropertyFormatter->getDefaultFormat()."<br>"; echo "Attribute id: ".$oFormatChoicePropertyFormatter->getAttributeId()."<br>"; echo "HTML pattern: ".$oFormatChoicePropertyFormatter->getPattern( Inx_Api_Property_FormatChoicePropertyFormatter::HTML_TEXT_FORMAT)."<br>";
To give the editor free choice to use any mail format she or he considers appropriate, use the formatMailingChoice() method. The following snippet shows how this can be achieved:
$oListContext = $oSession->getListContextManager()->findByName( "Desired list" ); $oProperty = $oListContext->findProperty( Inx_Api_Property_PropertyNames::MAIL_FORMAT_CHOICE ); $oProperty->updateInternalValue( Inx_Api_Property_FormatChoicePropertyFormatter::formatMailingChoice() ); $oProperty->commitUpdate();
The opposite strategy is to restrict all mailings of a list to a certain mail format. The following snippet shows how to restrict the mailing format of the specified list to the multipart format:
$oListContext = $oSession->getListContextManager()->findByName( "Desired list" ); $oProperty = $oListContext->findProperty( Inx_Api_Property_PropertyNames::MAIL_FORMAT_CHOICE ); $oProperty->updateInternalValue( Inx_Api_Property_FormatChoicePropertyFormatter::formatFixedChoice( Inx_Api_Property_FormatChoicePropertyFormatter::MULTIPART_FORMAT ) ); $oProperty->commitUpdate();
The final strategy is to choose the mailing format based on the value of a recipient attribute. The following snippet shows how to send HTML mailings to recipients with the attribute value html, plain text mailings to recipients with the attribute value plain and multipart mailings to all other recipients:
$oListContext = $oSession->getListContextManager()->findByName( "Desired list" ); $oRecipientMetaData = $oSession->createRecipientContext()->getMetaData(); $oProperty = $oListContext->findProperty( Inx_Api_Property_PropertyNames::MAIL_FORMAT_CHOICE ); $iAttributeId = $oRecipientMetaData->getUserAttribute( "format" )->getId(); $sPlainTextPattern = "plain"; $sHtmlTextPattern = "html"; $sStrategy = Inx_Api_Property_FormatChoicePropertyFormatter::formatAttributeChoice( $iAttributeId, Inx_Api_Property_FormatChoicePropertyFormatter::MULTIPART_FORMAT, $sPlainTextPattern, $sHtmlTextPattern, null ); $oProperty->updateInternalValue( $sStrategy ); $oProperty->commitUpdate();
For more information on properties in general, see the Inx_Api_Property_Property documentation.
Located in /Api/Property/FormatChoicePropertyFormatter.php (line 128)
The attribute that controls which format to choose.
The attribute that controls which format to choose.
The strategy used to choose the mailing format.
The strategy used to choose the mailing format.
The default mailing format.
The default mailing format.
The HTML text pattern.
The HTML text pattern.
The multipart pattern.
The multipart pattern.
The plain text pattern.
The plain text pattern.
Creates the internal string value for the ATTRIBUTE_STRATEGY using the given recipient attribute id, default mailing format and patterns.
Creates the internal string value for the ATTRIBUTE_STRATEGY using the given recipient attribute id, default mailing format and patterns. For a description of the pattern syntax, see the documentation of this class. The default mailing attribute may be one of:
Creates the internal string value for the FIXED_STRATEGY using the given default mailing format.
Creates the internal string value for the FIXED_STRATEGY using the given default mailing format. The default format may be one of:
Creates the internal string value for the MAILING_FORMAT_STRATEGY.
Creates the internal string value for the MAILING_FORMAT_STRATEGY.
Parses the given property and extracts the format choice policy into a new Inx_Api_Property_FormatChoicePropertyFormatter for easy retrieval.
Parses the given property and extracts the format choice policy into a new Inx_Api_Property_FormatChoicePropertyFormatter for easy retrieval. Only the Inx_Api_Property_PropertyNames::MAIL_FORMAT_CHOICE property is allowed. Using any other property will trigger an Inx_Api_IllegalArgumentException.
Default constructor which may only be used by derived classes.
Default constructor which may only be used by derived classes.
Returns the id of the recipient attribute used to determine the mailing format.
Returns the id of the recipient attribute used to determine the mailing format. If the choice strategy is not ATTRIBUTE_STRATEGY, 0 will be returned.
Returns the formatting (choice) strategy.
Returns the formatting (choice) strategy. May be one of:
Returns the default mailing format.
Returns the default mailing format. The default format is only used by the choice strategies FIXED_STRATEGY and ATTRIBUTE_STRATEGY.
Returns the pattern for the given mailing format.
Returns the pattern for the given mailing format. Patterns are only used by the choice strategy ATTRIBUTE_STRATEGY.
Strategy constant which is used to determine the mail format based on the value of a recipient attribute.
Strategy constant which is used to determine the mail format based on the value of a recipient attribute.
Strategy constant which restricts the mail format to exactly one specified format.
Strategy constant which restricts the mail format to exactly one specified format.
Constant for the HTML text pattern.
Constant for the HTML text pattern.
Strategy constant which lets the editor freely choose the appropriate mail format.
Strategy constant which lets the editor freely choose the appropriate mail format.
Constant for the multipart pattern.
Constant for the multipart pattern.
Constant for the plain text pattern.
Constant for the plain text pattern.
Documentation generated on Thu, 17 Sep 2015 14:27:24 +0200 by phpDocumentor 1.3.2