001/* 002 * Copyright 2010 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.web.source; 017 018import java.util.ArrayList; 019import java.util.List; 020 021import org.ametys.cms.source.ContentView; 022import org.ametys.cms.source.DefaultContentView; 023 024/** 025 * This implementation of a {@link ContentView} looks first in the directory skin://stylesheets/content/[cType]/[cType]-[view].xsl then skin://stylesheets/content/[cType]/[cType].xsl then defaults to {@link DefaultContentView}. 026 */ 027public class WebContentView extends DefaultContentView 028{ 029 @Override 030 protected List<String> _getSourceURIs(String location, String contentType, String view, String format, String pluginName) 031 { 032 // for article in html, look for article.xsl 033 // for article in pdf, look for article2pdf.xsl 034 String f = "html".equals(format) ? "" : "2" + format; 035 036 ArrayList<String> result = new ArrayList<>(); 037 038 result.add("skin://stylesheets/content/" + contentType + "/" + contentType + f + "-" + view + ".xsl"); 039 result.add("skin://stylesheets/content/" + contentType + "/" + contentType + f + ".xsl"); 040 result.addAll(super._getSourceURIs(location, contentType, view, format, pluginName)); 041 042 return result; 043 } 044}