1 /* 2 * Copyright (c) 2002-2014, Mairie de Paris 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice 10 * and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice 13 * and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * License 1.0 33 */ 34 package fr.paris.lutece.portal.web.xpages; 35 36 import fr.paris.lutece.util.ReferenceItem; 37 import fr.paris.lutece.util.ReferenceList; 38 import fr.paris.lutece.util.xml.XmlUtil; 39 40 41 /** 42 * This class represents XPage object 43 * 44 */ 45 public class XPage 46 { 47 private static final String TAG_PAGE_LINK = "page_link"; 48 private static final String TAG_PAGE_NAME = "page-name"; 49 private static final String TAG_PAGE_URL = "page-url"; 50 private String _strContent; 51 private String _strTitle; 52 private String _strKeyword; 53 private String _strPathLabel; 54 private String _strXmlExtendedPathLabel; 55 private boolean _bStandalone; 56 57 /** 58 * 59 * @return The content of the page 60 */ 61 public String getContent( ) 62 { 63 return _strContent; 64 } 65 66 /** 67 * 68 * @return The keyword of the page 69 */ 70 public String getKeyword( ) 71 { 72 return _strKeyword; 73 } 74 75 /** 76 * 77 * @return The title of the page 78 */ 79 public String getTitle( ) 80 { 81 return _strTitle; 82 } 83 84 /** 85 * 86 * @return The path label of the page 87 */ 88 public String getPathLabel( ) 89 { 90 return _strPathLabel; 91 } 92 93 /** 94 * 95 * @param strContent The content of the page 96 */ 97 public void setContent( String strContent ) 98 { 99 _strContent = strContent; 100 } 101 102 /** 103 * 104 * @param strKeyword The keyword of the page 105 */ 106 public void setKeyword( String strKeyword ) 107 { 108 _strKeyword = strKeyword; 109 } 110 111 /** 112 * 113 * @param strTitle The title of the page 114 */ 115 public void setTitle( String strTitle ) 116 { 117 _strTitle = strTitle; 118 } 119 120 /** 121 * 122 * @param strPathLabel The path label of the page 123 */ 124 public void setPathLabel( String strPathLabel ) 125 { 126 _strPathLabel = strPathLabel; 127 } 128 129 /** 130 * Get the extended path label, which is given as a Xml code 131 * @return Returns the Extended Path Label 132 */ 133 public String getXmlExtendedPathLabel( ) 134 { 135 return _strXmlExtendedPathLabel; 136 } 137 138 /** 139 * Set the Extended Path Label from a xml string 140 * @param strXmlExtendedPathLabel the Extended Path Label to set 141 */ 142 public void setXmlExtendedPathLabel( String strXmlExtendedPathLabel ) 143 { 144 _strXmlExtendedPathLabel = strXmlExtendedPathLabel; 145 } 146 147 /** 148 * Build a path from a referencelist. Each item of the list is an element of the path 149 * The item's code is the label, the item's name is used for the URL of the link. 150 * @param listPathItem The items of the path. 151 */ 152 public void setExtendedPathLabel( ReferenceList listPathItem ) 153 { 154 StringBuffer sbXml = new StringBuffer( ); 155 156 for ( ReferenceItem item : listPathItem ) 157 { 158 XmlUtil.beginElement( sbXml, TAG_PAGE_LINK ); 159 XmlUtil.addElement( sbXml, TAG_PAGE_NAME, item.getCode( ) ); 160 XmlUtil.addElement( sbXml, TAG_PAGE_URL, item.getName( ) ); 161 XmlUtil.endElement( sbXml, TAG_PAGE_LINK ); 162 } 163 164 _strXmlExtendedPathLabel = sbXml.toString( ); 165 } 166 167 /** 168 * Indicates if the content is standalone and should not be encapsulated in other 169 * content, such as portal headers and footers 170 * @return <code>true</code> is the content is standalone 171 * @since 5.1.0 172 */ 173 public boolean isStandalone( ) 174 { 175 return _bStandalone; 176 } 177 178 /** 179 * Indicates if the content is standalone and should not be encapsulated in other 180 * content, such as portal headers and footers 181 * @param standalone <code>true</code> is the content is standalone 182 * @since 5.1.0 183 */ 184 public void setStandalone( boolean standalone ) 185 { 186 _bStandalone = standalone; 187 } 188 }