Changeset 6050
- Timestamp:
- 11/14/11 11:57:16 (6 months ago)
- Location:
- trunk/pustefix-core/src/main
- Files:
-
- 2 added
- 9 modified
-
java/de/schlund/pfixcore/util/TransformerCallback.java (modified) (2 diffs)
-
java/de/schlund/pfixcore/workflow/Context.java (modified) (1 diff)
-
java/de/schlund/pfixcore/workflow/ContextImpl.java (modified) (1 diff)
-
java/de/schlund/pfixcore/workflow/SiteMap.java (modified) (10 diffs)
-
java/de/schlund/pfixcore/workflow/context/RequestContextImpl.java (modified) (1 diff)
-
java/org/pustefixframework/config/project/parser/SiteMapRequestHandlerParsingHandler.java (added)
-
java/org/pustefixframework/http/SiteMapRequestHandler.java (added)
-
java/org/pustefixframework/test/MockContext.java (modified) (2 diffs)
-
resources/META-INF/org/pustefixframework/config/project/parser/project-config.xml (modified) (2 diffs)
-
resources/PUSTEFIX-INF/xsl/functions.xsl (modified) (1 diff)
-
resources/PUSTEFIX-INF/xsl/navigation.xsl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pustefix-core/src/main/java/de/schlund/pfixcore/util/TransformerCallback.java
r5955 r6050 409 409 } 410 410 411 public static String omitPage(RequestContextImpl requestContext, TargetGenerator gen, String pageName, String lang ) throws Exception {411 public static String omitPage(RequestContextImpl requestContext, TargetGenerator gen, String pageName, String lang, String altKey) throws Exception { 412 412 try { 413 413 ContextImpl context = requestContext.getParentContext(); … … 423 423 return langPrefix; 424 424 } else { 425 String alias = gen.getSiteMap().getAlias(pageName, lang );425 String alias = gen.getSiteMap().getAlias(pageName, lang, altKey); 426 426 if(langPrefix.length() > 0) { 427 427 alias = langPrefix + "/" + alias; -
trunk/pustefix-core/src/main/java/de/schlund/pfixcore/workflow/Context.java
r5888 r6050 78 78 79 79 void setPageAlternative(String key); 80 String getPageAlternative(); 80 81 81 82 void addCookie(Cookie cookie); -
trunk/pustefix-core/src/main/java/de/schlund/pfixcore/workflow/ContextImpl.java
r5888 r6050 218 218 } 219 219 220 public String getPageAlternative() { 221 return getRequestContextForCurrentThreadWithError().getPageAlternative(); 222 } 223 220 224 public void setVariant(Variant variant) { 221 225 getRequestContextForCurrentThreadWithError().setVariantForThisRequestOnly(variant); -
trunk/pustefix-core/src/main/java/de/schlund/pfixcore/workflow/SiteMap.java
r5896 r6050 19 19 package de.schlund.pfixcore.workflow; 20 20 21 import java.io.File; 21 22 import java.io.IOException; 22 23 import java.io.StringReader; … … 62 63 private Set<Resource> fileDependencies = new HashSet<Resource>(); 63 64 private Map<String, Document> langToDoc = new HashMap<String, Document>(); 64 private List<Page> pageList ;65 private Map<String, Page> pageNameToPage ;66 private Map<String, Map<String, String>> aliasMaps ;67 private Map<String, Map<String, String>> pageMaps ;68 private Map<String, Page> pageAlternativeToPage ;69 private Map<String, Page> pageAliasToPage ;65 private List<Page> pageList = new ArrayList<Page>(); 66 private Map<String, Page> pageNameToPage = new LinkedHashMap<String, Page>(); 67 private Map<String, Map<String, String>> aliasMaps = new HashMap<String, Map<String, String>>(); 68 private Map<String, Map<String, String>> pageMaps = new HashMap<String, Map<String, String>>(); 69 private Map<String, Page> pageAlternativeToPage = new HashMap<String, Page>(); 70 private Map<String, Page> pageAliasToPage = new HashMap<String, Page>(); 70 71 private boolean provided; 72 73 public SiteMap(File siteMapFile, File[] siteMapAliasFiles) throws IOException, SAXException { 74 if(siteMapFile.exists()) { 75 Document siteMapDoc = Xml.parseMutable(siteMapFile); 76 readSiteMap(siteMapDoc.getDocumentElement()); 77 for(File siteMapAliasFile: siteMapAliasFiles) { 78 readSiteMapAliases(Xml.parseMutable(siteMapAliasFile)); 79 } 80 provided = true; 81 } 82 } 71 83 72 84 public SiteMap(Resource siteMapFile) throws IOException, SAXException, XMLException { … … 76 88 if(uriStr.endsWith("depend.xml")) uriStr = uriStr.substring(0, uriStr.length() -10) + "sitemap.xml"; 77 89 siteMapFile = ResourceUtil.getResource(uriStr); 78 79 pageList = new ArrayList<Page>();80 pageNameToPage = new HashMap<String, Page>();81 pageAlternativeToPage = new HashMap<String, Page>();82 pageAliasToPage = new HashMap<String, Page>();83 90 84 91 if(siteMapFile.exists()) { … … 133 140 readSiteMap(siteMapDoc.getDocumentElement()); 134 141 135 aliasMaps = new HashMap<String, Map<String, String>>();136 pageMaps = new HashMap<String, Map<String, String>>();137 138 142 Resource res = ResourceUtil.getResource("/WEB-INF/sitemap-aliases.xml"); 139 143 if(res.exists()) { … … 155 159 156 160 } 157 161 158 162 public boolean isProvided() { 159 163 return provided; … … 171 175 String name = pageElem.getAttribute("name").trim(); 172 176 Page page = new Page(name); 177 String internal = pageElem.getAttribute("internal").trim(); 178 if(internal.length() > 0) { 179 page.internal = Boolean.valueOf(internal); 180 } 173 181 pageNameToPage.put(page.name, page); 174 182 String alias = pageElem.getAttribute("alias").trim(); … … 236 244 } 237 245 238 public String getAlias(String name, String lang) { 239 String alias = null; 246 public List<String> getPageNames(boolean excludeInternal) { 247 List<String> pageNames = new ArrayList<String>(); 248 for(Page page: pageList) { 249 getPageNames(page, excludeInternal, pageNames); 250 } 251 return pageNames; 252 } 253 254 private void getPageNames(Page page, boolean excludeInternal, List<String> pageNames) { 255 if(!excludeInternal || !page.internal) { 256 pageNames.add(page.name); 257 for(Page child: page.pages) { 258 getPageNames(child, excludeInternal, pageNames); 259 } 260 } 261 } 262 263 public String getAlias(final String name, final String lang) { 264 String aliasName = name; 265 if(pageNameToPage != null) { 266 Page page = pageNameToPage.get(name); 267 if(page != null && page.alias != null) { 268 aliasName = page.alias; 269 } 270 } 271 String aliasTranslated = null; 240 272 if(lang != null) { 241 273 if(aliasMaps != null) { 242 274 Map<String, String> aliases = aliasMaps.get(lang); 243 275 if(aliases != null) { 244 alias = aliases.get(name);245 } 246 if(alias == null) {276 aliasTranslated = aliases.get(aliasName); 277 } 278 if(aliasTranslated == null) { 247 279 int ind = lang.indexOf('_'); 248 280 if(ind > -1) { 249 lang = lang.substring(0, ind);250 aliases = aliasMaps.get( lang);281 String mainLang = lang.substring(0, ind); 282 aliases = aliasMaps.get(mainLang); 251 283 if(aliases != null) { 252 alias = aliases.get(name);284 aliasTranslated = aliases.get(aliasName); 253 285 } 254 286 } … … 256 288 } 257 289 } 258 if(alias == null) { 259 if(pageNameToPage != null) { 260 Page page = pageNameToPage.get(name); 261 if(page != null && page.alias != null) { 262 alias = page.alias; 263 } 264 } 265 } 266 if(alias != null) { 267 return alias; 290 if(aliasTranslated != null) { 291 return aliasTranslated; 268 292 } else { 269 return name;293 return aliasName; 270 294 } 271 295 } 272 296 273 297 public String getAlias(String name, String lang, String pageAlternativeKey) { 274 if(pageAlternativeKey == null ) {298 if(pageAlternativeKey == null || pageAlternativeKey.equals("")) { 275 299 return getAlias(name, lang); 276 300 } else { … … 330 354 } 331 355 } 356 if(page != null) { 357 if(pageAliasToPage != null) { 358 Page p = pageAliasToPage.get(page); 359 if(p != null) page = p.name; 360 } 361 } 332 362 } 333 363 if(page == null) { … … 362 392 } 363 393 364 365 class Page { 394 395 396 public class Page { 366 397 367 398 String name; 399 boolean internal; 400 Map<String, String> customAttributes = new HashMap<String, String>(); 368 401 String alias; 369 402 List<Page> pages = new ArrayList<Page>(); -
trunk/pustefix-core/src/main/java/de/schlund/pfixcore/workflow/context/RequestContextImpl.java
r5872 r6050 252 252 public void setPageAlternative(String key) { 253 253 pageAlternativeKey = key; 254 } 255 256 public String getPageAlternative() { 257 return pageAlternativeKey; 254 258 } 255 259 -
trunk/pustefix-core/src/main/java/org/pustefixframework/test/MockContext.java
r5915 r6050 82 82 private Set<String> pageNeedsDataSet = new HashSet<String>(); 83 83 private Set<String> pageAccessibleSet = new HashSet<String>(); 84 84 private String pageAltKey; 85 85 86 86 public void addCookie(Cookie cookie) { … … 331 331 332 332 public void setPageAlternative(String key) { 333 this.pageAltKey = key; 334 } 335 336 public String getPageAlternative() { 337 return pageAltKey; 333 338 } 334 339 -
trunk/pustefix-core/src/main/resources/META-INF/org/pustefixframework/config/project/parser/project-config.xml
r6035 r6050 40 40 41 41 <!-- Creates request handler for search engine sitemaps --> 42 <!--43 42 <handler class="org.pustefixframework.config.project.parser.SiteMapRequestHandlerParsingHandler"> 44 <match>/p:project-config/p: application/p:sitemaps-protocol-generator</match>43 <match>/p:project-config/p:searchengine-sitemap</match> 45 44 </handler> 46 -->45 47 46 <handler class="org.pustefixframework.config.project.parser.StaticPathParsingHandler"> 48 47 <match>/p:project-config/p:application/p:static//p:path</match> … … 72 71 </handler> 73 72 74 <!-- Adds Statistics bean -->75 <!--76 <handler class="org.pustefixframework.config.project.parser.StatisticsParsingHandler">77 <match>/p:project-config/p:application</match>78 </handler>79 -->80 73 <!-- Reads path to depend.xml file --> 81 74 <handler class="org.pustefixframework.config.project.parser.XMLGeneratorInfoParsingHandler"> -
trunk/pustefix-core/src/main/resources/PUSTEFIX-INF/xsl/functions.xsl
r5849 r6050 123 123 <xsl:param name="pageName"/> 124 124 <xsl:param name="language"><xsl:value-of select="$lang"/></xsl:param> 125 <func:result select="callback:omitPage($__context__,$__target_gen,$pageName,$language)"/> 125 <xsl:param name="altKey"/> 126 <func:result select="callback:omitPage($__context__,$__target_gen,$pageName,$language,$altKey)"/> 126 127 </func:function> 127 128 -
trunk/pustefix-core/src/main/resources/PUSTEFIX-INF/xsl/navigation.xsl
r5750 r6050 12 12 <xsl:template match="pfx:normal"/> 13 13 <xsl:template match="pfx:argument"/> 14 <xsl:template match="pfx:altkey"/> 14 15 15 16 <xsl:template match="pfx:command"> … … 157 158 <xsl:with-param name="popupfeatures" select="@popupfeatures"/> 158 159 <xsl:with-param name="popupid" select="@popupid"/> 160 <xsl:with-param name="altkey"> 161 <xsl:choose> 162 <xsl:when test="./pfx:altkey"> 163 <xsl:apply-templates select="./pfx:altkey/node()"> 164 <xsl:with-param name="thepagename" select="@page"/> 165 </xsl:apply-templates> 166 </xsl:when> 167 <xsl:when test="@altkey"> 168 <xsl:value-of select="@altkey"/> 169 </xsl:when> 170 </xsl:choose> 171 </xsl:with-param> 159 172 </xsl:call-template> 160 173 </xsl:template> … … 207 220 <xsl:param name="popupfeatures"/> 208 221 <xsl:param name="popupid"/> 222 <xsl:param name="altkey"/> 209 223 <xsl:param name="nodata"/> 210 224 <xsl:param name="args"/> … … 245 259 </xsl:variable> 246 260 <xsl:variable name="fulllink"> 247 <ixsl:value-of select="$__contextpath"/>/<ixsl:value-of select="pfx:__omitPage({$mypage})"/><ixsl:value-of select="$__sessionIdPath"/> 261 <ixsl:variable name="tmpaltkey"> 262 <xsl:if test="$altkey"><xsl:copy-of select="$altkey"/></xsl:if> 263 </ixsl:variable> 264 <ixsl:value-of select="$__contextpath"/>/<ixsl:value-of select="pfx:__omitPage({$mypage}, $lang, $tmpaltkey)"/><ixsl:value-of select="$__sessionIdPath"/> 248 265 <ixsl:variable name="params"> 249 266 <xsl:if test="not($frame_impl='')">__frame=<xsl:value-of select="$frame_impl"/></xsl:if>
