Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. <cfset siteID = "en">
  2. <cfset remoteSiteID = "nl">
  3. <cfset $ = application.serviceFactory.getBean('$').init(siteID)>
  4. <cfset pluginConfig = $.getBean('pluginManager').getConfig('MuraTranslations')>
  5. <cfset translationManager = createObject("component", "plugins.#pluginConfig.getDirectory()#.cfcs.translationManager").init($.getBean('configBean'), pluginConfig)>
  6.  
  7. <cfif not structKeyExists(session, "rs")>
  8. <cfquery name="rs">
  9. select distinct contentID, siteID from tcontentrelated where siteID = <cfqueryparam cfsqltype="cf_sql_varchar" value="#siteID#">
  10. </cfquery>
  11. <cfset session.rs = rs>
  12. </cfif>
  13.  
  14. <cfset it = $.getBean("contentIterator")>
  15. <cfset it.setQuery(session.rs, 20)>
  16.  
  17. <cfif isNumeric($.event('start'))>
  18. <cfset it.setPage($.event('start'))>
  19. </cfif>
  20.  
  21. <cfloop condition="#it.hasNext()#">
  22. <cfset source = it.next()>
  23. <cfset translation = translationManager.getTranslation()>
  24. <cfset translation.setRemoteSiteID(remoteSiteID)>
  25. <cfset translation.setLocalSiteID(siteID)>
  26. <cfset translation.setLocalID(source.getContentID())>
  27. <cfset parentMapping = translation.getLocal()>
  28. <cfif len(parentMapping.getRemoteID())>
  29. <cfset mappedRelatedContentIDs = "">
  30. <cfset sourceRCIT = source.getRelatedContentIterator()>
  31. <cfif sourceRCIT.hasNext()>
  32. <cfloop condition="#sourceRCIT.hasNext()#">
  33. <cfset sourceRCNode = sourceRCIT.next()>
  34. <!--- find peer, add to rc list --->
  35. <cfset translation = translationManager.getTranslation()>
  36. <cfset translation.setRemoteSiteID(remoteSiteID)>
  37. <cfset translation.setLocalSiteID(siteID)>
  38. <cfset translation.setLocalID(sourceRCNode.getContentID())>
  39. <cfset RCMapping = translation.getLocal()>
  40. <cfif len(RCMapping.getRemoteID())>
  41. <cfset mappedRelatedContentIDs = listAppend(mappedRelatedContentIDs, RCMapping.getRemoteID())>
  42. </cfif>
  43. </cfloop>
  44. <cfif listLen(mappedRelatedContentIDs)>
  45. <cfset destination = $.getBean('content').loadBy(contentID=parentMapping.getRemoteID(), siteID=remoteSiteID)>
  46. <cfif not destination.getIsNew()>
  47. <cfset destination.setRelatedContentID(mappedRelatedContentIDs)>
  48. <cfset output = structNew()>
  49. <cfset output.mappedRelatedContentIDs = mappedRelatedContentIDs>
  50. <cfset output.sourceTitle = source.getTitle()>
  51. <cfset output.sourceContentID = source.getContentID()>
  52. <cfset output.sourceContentHistID = source.getContentHistID()>
  53. <cfset output.destinationTitle = destination.getTitle()>
  54. <cfset output.destinationContentID = destination.getContentID()>
  55. <cfset output.destinationContentHistID = destination.getContentHistID()>
  56. <cfdump var="#output#">
  57. <cfset destination.save()>
  58. </cfif>
  59. </cfif>
  60. </cfif>
  61. </cfif>
  62. </cfloop>
  63.  
  64. <cfoutput>
  65. <cfloop from="1" to="#it.pageCount()#" index="i">
  66. <a href="?start=#i#">#i#</a>&nbsp;
  67. </cfloop>
  68. </cfoutput>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement