/** * Returns data for the attribute * * @return string */ public function getData() { return trim($this->ContentObjectAttribute->attribute('data_text')); } /** * Returns part of the data for the attribute * * @param string $dataMember * * @return string */ public function getDataMember($dataMember) { return $this->getData(); } /** * @var eZContentObjectAttribute */ public $ContentObjectAttribute; /** * @var eZINI */ static $ogIni; } ngOpenGraphBase::$ogIni = eZINI::instance('ngopengraph.ini');
/** * Processes Open Graph metadata from object attributes * * @param eZContentObject $contentObject * @param array $returnArray * * @return array */ function processObject($contentObject, $returnArray) { if ($this->ogIni->hasVariable($contentObject->contentClassIdentifier(), 'LiteralMap')) { $literalValues = $this->ogIni->variable($contentObject->contentClassIdentifier(), 'LiteralMap'); if ($this->debug) { eZDebug::writeDebug($literalValues, 'LiteralMap'); } if ($literalValues) { foreach ($literalValues as $key => $value) { if (!empty($value)) { $returnArray[$key] = $value; } } } } if ($this->ogIni->hasVariable($contentObject->contentClassIdentifier(), 'AttributeMap')) { $attributeValues = $this->ogIni->variableArray($contentObject->contentClassIdentifier(), 'AttributeMap'); if ($this->debug) { eZDebug::writeDebug($attributeValues, 'AttributeMap'); } if ($attributeValues) { foreach ($attributeValues as $key => $value) { $contentObjectAttributeArray = $contentObject->fetchAttributesByIdentifier(array($value[0])); if (!is_array($contentObjectAttributeArray)) { continue; } $contentObjectAttributeArray = array_values($contentObjectAttributeArray); $contentObjectAttribute = $contentObjectAttributeArray[0]; if ($contentObjectAttribute instanceof eZContentObjectAttribute) { $openGraphHandler = ngOpenGraphBase::getInstance($contentObjectAttribute); if (count($value) == 1) { $data = $openGraphHandler->getData(); } else { if (count($value) == 2) { $data = $openGraphHandler->getDataMember($value[1]); } else { $data = ""; } } if (!empty($data)) { $returnArray[$key] = $data; } } } } } return $returnArray; }