Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfset siteID = "en">
- <cfset remoteSiteID = "nl">
- <cfset $ = application.serviceFactory.getBean('$').init(siteID)>
- <cfset pluginConfig = $.getBean('pluginManager').getConfig('MuraTranslations')>
- <cfset translationManager = createObject("component", "plugins.#pluginConfig.getDirectory()#.cfcs.translationManager").init($.getBean('configBean'), pluginConfig)>
- <cfif not structKeyExists(session, "rs")>
- <cfquery name="rs">
- select distinct contentID, siteID from tcontentrelated where siteID = <cfqueryparam cfsqltype="cf_sql_varchar" value="#siteID#">
- </cfquery>
- <cfset session.rs = rs>
- </cfif>
- <cfset it = $.getBean("contentIterator")>
- <cfset it.setQuery(session.rs, 20)>
- <cfif isNumeric($.event('start'))>
- <cfset it.setPage($.event('start'))>
- </cfif>
- <cfloop condition="#it.hasNext()#">
- <cfset source = it.next()>
- <cfset translation = translationManager.getTranslation()>
- <cfset translation.setRemoteSiteID(remoteSiteID)>
- <cfset translation.setLocalSiteID(siteID)>
- <cfset translation.setLocalID(source.getContentID())>
- <cfset parentMapping = translation.getLocal()>
- <cfif len(parentMapping.getRemoteID())>
- <cfset mappedRelatedContentIDs = "">
- <cfset sourceRCIT = source.getRelatedContentIterator()>
- <cfif sourceRCIT.hasNext()>
- <cfloop condition="#sourceRCIT.hasNext()#">
- <cfset sourceRCNode = sourceRCIT.next()>
- <!--- find peer, add to rc list --->
- <cfset translation = translationManager.getTranslation()>
- <cfset translation.setRemoteSiteID(remoteSiteID)>
- <cfset translation.setLocalSiteID(siteID)>
- <cfset translation.setLocalID(sourceRCNode.getContentID())>
- <cfset RCMapping = translation.getLocal()>
- <cfif len(RCMapping.getRemoteID())>
- <cfset mappedRelatedContentIDs = listAppend(mappedRelatedContentIDs, RCMapping.getRemoteID())>
- </cfif>
- </cfloop>
- <cfif listLen(mappedRelatedContentIDs)>
- <cfset destination = $.getBean('content').loadBy(contentID=parentMapping.getRemoteID(), siteID=remoteSiteID)>
- <cfif not destination.getIsNew()>
- <cfset destination.setRelatedContentID(mappedRelatedContentIDs)>
- <cfset output = structNew()>
- <cfset output.mappedRelatedContentIDs = mappedRelatedContentIDs>
- <cfset output.sourceTitle = source.getTitle()>
- <cfset output.sourceContentID = source.getContentID()>
- <cfset output.sourceContentHistID = source.getContentHistID()>
- <cfset output.destinationTitle = destination.getTitle()>
- <cfset output.destinationContentID = destination.getContentID()>
- <cfset output.destinationContentHistID = destination.getContentHistID()>
- <cfdump var="#output#">
- <cfset destination.save()>
- </cfif>
- </cfif>
- </cfif>
- </cfif>
- </cfloop>
- <cfoutput>
- <cfloop from="1" to="#it.pageCount()#" index="i">
- <a href="?start=#i#">#i#</a>
- </cfloop>
- </cfoutput>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement