static function updateUrlObjectLinks($contentObjectAttribute, $urlIDArray) { $objectAttributeID = $contentObjectAttribute->attribute('id'); $objectAttributeVersion = $contentObjectAttribute->attribute('version'); foreach ($urlIDArray as $urlID) { $linkObjectLink = eZURLObjectLink::fetch($urlID, $objectAttributeID, $objectAttributeVersion); if ($linkObjectLink == null) { $linkObjectLink = eZURLObjectLink::create($urlID, $objectAttributeID, $objectAttributeVersion); $linkObjectLink->store(); } } }
function postStore($objectAttribute) { // Update url-object link $urlValue = $objectAttribute->content(); if (trim($urlValue) != '') { $urlID = eZURL::registerURL($urlValue); $objectAttributeID = $objectAttribute->attribute('id'); $objectAttributeVersion = $objectAttribute->attribute('version'); $db = eZDB::instance(); $db->begin(); $objectLinkList = eZURLObjectLink::fetchLinkObjectList($objectAttributeID, $objectAttributeVersion); // In order not to have duplicated links, delete existing ones that have been created during the version creation process // and create a clean one (we can't update url_id since there's no primary key). This fixes EZP-20988 if (!empty($objectLinkList)) { eZURLObjectLink::removeURLlinkList($objectAttributeID, $objectAttributeVersion); } $linkObjectLink = eZURLObjectLink::create($urlID, $objectAttributeID, $objectAttributeVersion); $linkObjectLink->store(); $db->commit(); } }
function unserializeContentObjectAttribute($package, $objectAttribute, $attributeNode) { /* For all links found in the XML, do the following: * Search for url specified in 'href' link attribute (in ezurl table). * If the url not found then create a new one. * Then associate the found (or created) URL with the object attribute by creating new url-object link. * After that, remove "href" attribute, add new "id" attribute. * This new 'id' will always refer to the existing url object. */ $linkNodes = $attributeNode->getElementsByTagName('link'); foreach ($linkNodes as $linkNode) { $href = $linkNode->getAttribute('href'); if (!$href) { continue; } $urlObj = eZURL::urlByURL($href); if (!$urlObj) { $urlObj = eZURL::create($href); $urlObj->store(); } $linkNode->removeAttribute('href'); $linkNode->setAttribute('url_id', $urlObj->attribute('id')); $urlObjectLink = eZURLObjectLink::create($urlObj->attribute('id'), $objectAttribute->attribute('id'), $objectAttribute->attribute('version')); $urlObjectLink->store(); } foreach ($attributeNode->childNodes as $childNode) { if ($childNode->nodeType == XML_ELEMENT_NODE) { $xmlString = $childNode->ownerDocument->saveXML($childNode); $objectAttribute->setAttribute('data_text', $xmlString); break; } } }
function postStore( $objectAttribute ) { // Update url-object link $urlValue = $objectAttribute->content(); if ( trim( $urlValue ) != '' ) { $urlID = eZURL::registerURL( $urlValue ); //$urlID = $objectAttribute->attribute( 'data_int' );+ $objectAttributeID = $objectAttribute->attribute( 'id' ); $objectAttributeVersion = $objectAttribute->attribute( 'version' ); if ( !eZURLObjectLink::fetch( $urlID, $objectAttributeID, $objectAttributeVersion, false ) ) { $linkObjectLink = eZURLObjectLink::create( $urlID, $objectAttributeID, $objectAttributeVersion ); $linkObjectLink->store(); } } }