/** * Generated all outputformats * * @param unknown_type $objectVersion * @return array */ function getAllOutputFormatTextByContentObjectVersion($objectVersion, $forceSettingImageIncludeTo = -1) { $outputFormatTextArray = array(); $dataMap = $objectVersion->attribute('data_map'); $editionAttribute = $dataMap['newsletter_edition']; $editionAttributeContent = $editionAttribute->attribute('content'); $listAttributeContent = $editionAttributeContent->attribute('list_attribute_content'); $outputFormatArray = $listAttributeContent->attribute('output_format_array'); $mainSiteAccess = $listAttributeContent->attribute('main_siteaccess'); $skinName = $listAttributeContent->attribute('skin_name'); $editionContentObjectId = $objectVersion->attribute('contentobject_id'); $versionId = $objectVersion->attribute('version'); $emailSender = $listAttributeContent->attribute('email_sender'); $emailSenderName = $listAttributeContent->attribute('email_sender_name'); $emailReplyTo = $listAttributeContent->attribute('email_reply_to'); $emailReturnPath = $listAttributeContent->attribute('email_return_path'); foreach ($outputFormatArray as $outputFormatId => $outputName) { $newsletterContentArray = CjwNewsletterEdition::getOutput($editionContentObjectId, $versionId, $outputFormatId, $mainSiteAccess, $skinName, $forceSettingImageIncludeTo); $newsletterContentArray['email_sender'] = $emailSender; $newsletterContentArray['email_sender_name'] = $emailSenderName; $newsletterContentArray['email_reply_to'] = $emailReplyTo; $newsletterContentArray['email_return_path'] = $emailReturnPath; $outputFormatTextArray[$outputName] = $newsletterContentArray; } return $outputFormatTextArray; }
/** * Almost identical with the one in extended class, just injects * call for uniqness validation method * * @param unknown_type $http * @param unknown_type $base * @param unknown_type $contentObjectAttribute * @return unknown */ function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute) { if ($http->hasPostVariable($base . "_ezurl_url_" . $contentObjectAttribute->attribute("id")) and $http->hasPostVariable($base . "_ezurl_text_" . $contentObjectAttribute->attribute("id"))) { $url = $http->PostVariable($base . "_ezurl_url_" . $contentObjectAttribute->attribute("id")); $text = $http->PostVariable($base . "_ezurl_text_" . $contentObjectAttribute->attribute("id")); if ($contentObjectAttribute->validateIsRequired()) { if ($url == "" or $text == "") { $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.')); return eZInputValidator::STATE_INVALID; } } return self::validateUniqueURLHTTPInput($url, $contentObjectAttribute); // Remove all url-object links to this attribute. eZURLObjectLink::removeURLlinkList($contentObjectAttribute->attribute("id"), $contentObjectAttribute->attribute('version')); } return eZInputValidator::STATE_ACCEPTED; }
/** * This method is almost identical with the one from extended class, * It simply adds a call to a method dedicated to uniqueness validation * * @param unknown_type $data * @param unknown_type $contentObjectAttribute * @param unknown_type $classAttribute * @return unknown */ function validateStringHTTPInput($data, $contentObjectAttribute, $classAttribute) { $maxLen = $classAttribute->attribute(self::MAX_LEN_FIELD); $textCodec = eZTextCodec::instance(false); if ($textCodec->strlen($data) > $maxLen && $maxLen > 0) { $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The input text is too long. The maximum number of characters allowed is %1.'), $maxLen); return eZInputValidator::STATE_INVALID; } return self::validateUniqueStringHTTPInput($data, $contentObjectAttribute); }
/** * Enter description here... * * @param unknown_type $oObject * @return unknown */ static function fetchTagsByContentObject($oObject, $view_parameters) { // Prevent from request on a non-existent object if (!$oObject instanceof eZContentObject) { return NULL; } $oIni = eZINI::instance("metatag.ini"); $oObjectClassIdentifier = $oObject->contentClassIdentifier(); $oObjectDataMap = $oObject->dataMap(); /* * Recherche des attribute mapping avec parameters */ $attributesMappings = MetatagFunctionCollection::getAttributesMappingWithViewParameters($oObjectClassIdentifier, $view_parameters); // $attributesMappings = MetatagFunctionCollection::getAttributesMapping( $oObjectClassIdentifier ); $nameAttributes = $attributesMappings['name']; $descriptionAttributes = $attributesMappings['description']; $keywordsAttributes = $attributesMappings['keywords']; $metaAttributes = $attributesMappings['meta']; $namePattern = $attributesMappings['namePattern']; $descriptionPattern = $attributesMappings['descriptionPattern']; $keywordsPattern = $attributesMappings['keywordsPattern']; $sizeLimit = $attributesMappings['sizeLimit']; $autowash = false; $metatagOnlyMapping = false; if (isset($view_parameters['offset']) && $view_parameters['offset'] != 0) { $namePattern .= ', page ' . $view_parameters['offset']; } $name = NULL; $description = NULL; $keywords = NULL; // We check that the attribute is defined if (!$oIni->hasVariable('AttributesMapping', 'MetatagAttributeIdentifier')) { eZDebug::writeError("Configuration is incomplete, MetatagAttributeIdentifier is not defined in metatag.ini", 'MetatagFunctionCollection::fetchTagsByContentObject'); return NULL; } // Checking preferences if ($oIni->hasVariable('MetatagSettings', 'Autowash') && $oIni->variable('MetatagSettings', 'Autowash') === 'enabled') { $autowash = true; } if ($oIni->hasVariable('AttributesMapping', "MetatagOnlyMapping") && in_array($oObjectClassIdentifier, $oIni->variable('AttributesMapping', "MetatagOnlyMapping"))) { $metatagOnlyMapping = true; } $metaAttribute = $oIni->variable('AttributesMapping', 'MetatagAttributeIdentifier'); $tag = NULL; $tagAttributeExists = array_key_exists($metaAttribute, $oObjectDataMap) && $oObjectDataMap[$metaAttribute] instanceof eZContentObjectAttribute; if ($tagAttributeExists) { $attribute = $oObjectDataMap[$metaAttribute]; $attributeResult = unserialize($attribute->toString()); if ($attributeResult['name'] != '') { return array('result' => $attributeResult); } else { $tagAttributeExists = false; } } else { eZDebug::writeNotice("Tag attribute '" . $metaAttribute . "' doesn't exist in object " . $oObject->attribute('id') . ", mapping is using cascading fallback instead.", "MetatagFunctionCollection::fetchTagsByContentObject"); } if ($tagAttributeExists === true && $tag->hasName() === true) { $name = $tag->getName(); } elseif (!$metatagOnlyMapping) { // We check for a pattern defined if (isset($namePattern)) { $name = MetatagFunctionCollection::extractPattern($namePattern, $oObjectDataMap, $sizeLimit); } else { foreach ($nameAttributes as $nameAttribute) { if (isset($oObjectDataMap[$nameAttribute]) && $oObjectDataMap[$nameAttribute]->hasContent()) { $name = eZMetaTag::getTextValueOfAttribute($oObjectDataMap[$nameAttribute]); break; } } } } if ($tagAttributeExists === true && $tag->hasDescription() === true) { $description = $tag->getDescription(); } elseif (!$metatagOnlyMapping) { if (isset($descriptionPattern)) { $description = MetatagFunctionCollection::extractPattern($descriptionPattern, $oObjectDataMap, $sizeLimit); } else { foreach ($descriptionAttributes as $descriptionAttribute) { if (isset($oObjectDataMap[$descriptionAttribute]) && $oObjectDataMap[$descriptionAttribute]->hasContent()) { $description = eZMetaTag::getTextValueOfAttribute($oObjectDataMap[$descriptionAttribute]); break; } } } } if ($tagAttributeExists === true && $tag->hasKeywords() === true) { $keywords = $tag->getKeywords(); } elseif (!$metatagOnlyMapping) { if (isset($keywordsPattern)) { $keywords = MetatagFunctionCollection::extractPattern($keywordsPattern, $oObjectDataMap, $sizeLimit); } else { foreach ($keywordsAttributes as $keywordsAttribute) { if (isset($oObjectDataMap[$keywordsAttribute]) && $oObjectDataMap[$keywordsAttribute]->hasContent()) { $keywords = eZMetaTag::getTextValueOfAttribute($oObjectDataMap[$keywordsAttribute]); break; } } } } if ($autowash === true) { if (!is_null($name)) { $name = htmlentities($name); } if (!is_null($description)) { $description = htmlentities($description); } if (!is_null($keywords)) { $keywords = htmlentities($keywords); } } $description = str_replace("\n", "", $description); $description = substr($description, 0, 290) . ' ... '; return array('result' => array('name' => $name, 'description' => $description, 'keywords' => $keywords)); }