View Javadoc
1   /*
2    * Copyright (C) 2003-2008 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.ecm.webui.core.fckconfig;
18  
19  import java.util.Collection;
20  
21  import org.exoplatform.portal.resource.SkinConfig;
22  import org.exoplatform.portal.resource.SkinService;
23  import org.exoplatform.services.wcm.utils.WCMCoreUtils;
24  import org.exoplatform.webui.form.wysiwyg.FCKEditorConfig;
25  
26  /**
27   * Created by The eXo Platform SAS
28   * Author : Phan Le Thanh Chuong
29   * chuong_phan@exoplatform.com, phan.le.thanh.chuong@gmail.com
30   * Aug 28, 2008
31   */
32  public class FCKDynamicSkinPlugin extends FCKConfigPlugin {
33  
34    /*
35     * (non-Javadoc)
36     * @see
37     * org.exoplatform.services.ecm.fckconfig.FCKConfigPlugin#addParameters(org
38     * .exoplatform.webui.form.wysiwyg.FCKEditorConfig,
39     * org.exoplatform.services.ecm.fckconfig.FCKEditorContext)
40     */
41    public void addParameters(FCKEditorConfig editorConfig, FCKEditorContext editorContext) throws Exception {
42      StringBuffer cssMergedBuffer = new StringBuffer();
43      SkinService skinService = WCMCoreUtils.getService(SkinService.class);
44      Collection<SkinConfig> collecionSkin = skinService.getPortalSkins(editorContext.getSkinName());
45      for (SkinConfig skinConfig : collecionSkin) {
46        cssMergedBuffer = cssMergedBuffer.append(skinConfig.getCSSPath()).append(",");
47      }
48      SkinConfig skinConfig = skinService.getSkin(editorContext.getPortalName(), editorContext.getSkinName());
49      if (skinConfig != null) {
50        cssMergedBuffer = cssMergedBuffer.append(skinConfig.getCSSPath());
51      }
52      String cssMerged = cssMergedBuffer.toString();
53      if (cssMerged.endsWith(","))
54        cssMerged = cssMerged.substring(0, cssMerged.length() - 1);
55  
56      editorConfig.put("EditorAreaCSS", cssMerged);
57    }
58  }