001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.taglib.util;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.kernel.servlet.DirectRequestDispatcherFactoryUtil;
019    import com.liferay.portal.kernel.servlet.JSPSupportServlet;
020    import com.liferay.portal.kernel.template.Template;
021    import com.liferay.portal.kernel.template.TemplateConstants;
022    import com.liferay.portal.kernel.util.HttpUtil;
023    import com.liferay.portal.kernel.util.WebKeys;
024    import com.liferay.portal.model.Layout;
025    import com.liferay.portal.model.LayoutConstants;
026    import com.liferay.portal.model.Portlet;
027    import com.liferay.portal.theme.ThemeDisplay;
028    import com.liferay.taglib.TagSupport;
029    import com.liferay.taglib.aui.ColumnTag;
030    import com.liferay.taglib.aui.LayoutTag;
031    import com.liferay.taglib.portlet.ActionURLTag;
032    import com.liferay.taglib.portletext.IconBackTag;
033    import com.liferay.taglib.portletext.IconCloseTag;
034    import com.liferay.taglib.portletext.IconConfigurationTag;
035    import com.liferay.taglib.portletext.IconEditDefaultsTag;
036    import com.liferay.taglib.portletext.IconEditGuestTag;
037    import com.liferay.taglib.portletext.IconEditTag;
038    import com.liferay.taglib.portletext.IconHelpTag;
039    import com.liferay.taglib.portletext.IconMaximizeTag;
040    import com.liferay.taglib.portletext.IconMinimizeTag;
041    import com.liferay.taglib.portletext.IconOptionsTag;
042    import com.liferay.taglib.portletext.IconPortletCssTag;
043    import com.liferay.taglib.portletext.IconPortletTag;
044    import com.liferay.taglib.portletext.IconPrintTag;
045    import com.liferay.taglib.portletext.IconRefreshTag;
046    import com.liferay.taglib.portletext.RuntimeTag;
047    import com.liferay.taglib.security.DoAsURLTag;
048    import com.liferay.taglib.security.PermissionsURLTag;
049    import com.liferay.taglib.servlet.PipingPageContext;
050    import com.liferay.taglib.theme.LayoutIconTag;
051    import com.liferay.taglib.theme.MetaTagsTag;
052    import com.liferay.taglib.theme.WrapPortletTag;
053    import com.liferay.taglib.ui.AssetCategoriesSummaryTag;
054    import com.liferay.taglib.ui.AssetLinksTag;
055    import com.liferay.taglib.ui.AssetTagsSummaryTag;
056    import com.liferay.taglib.ui.BreadcrumbTag;
057    import com.liferay.taglib.ui.DiscussionTag;
058    import com.liferay.taglib.ui.FlagsTag;
059    import com.liferay.taglib.ui.IconTag;
060    import com.liferay.taglib.ui.JournalArticleTag;
061    import com.liferay.taglib.ui.JournalContentSearchTag;
062    import com.liferay.taglib.ui.LanguageTag;
063    import com.liferay.taglib.ui.MySitesTag;
064    import com.liferay.taglib.ui.PngImageTag;
065    import com.liferay.taglib.ui.QuickAccessTag;
066    import com.liferay.taglib.ui.RatingsTag;
067    import com.liferay.taglib.ui.SearchTag;
068    import com.liferay.taglib.ui.SitesDirectoryTag;
069    import com.liferay.taglib.ui.SocialBookmarksTag;
070    import com.liferay.taglib.ui.ToggleTag;
071    
072    import java.io.Writer;
073    
074    import java.util.Map;
075    import java.util.Set;
076    
077    import javax.portlet.PortletMode;
078    import javax.portlet.PortletRequest;
079    import javax.portlet.PortletURL;
080    import javax.portlet.WindowState;
081    
082    import javax.servlet.RequestDispatcher;
083    import javax.servlet.ServletContext;
084    import javax.servlet.http.HttpServletRequest;
085    import javax.servlet.http.HttpServletResponse;
086    import javax.servlet.jsp.JspFactory;
087    import javax.servlet.jsp.PageContext;
088    
089    /**
090     * @author Brian Wing Shun Chan
091     * @author Shuyang Zhou
092     */
093    public class VelocityTaglibImpl implements VelocityTaglib {
094    
095            public VelocityTaglibImpl() {
096            }
097    
098            public VelocityTaglibImpl(
099                    ServletContext servletContext, HttpServletRequest request,
100                    HttpServletResponse response, Template template) {
101    
102                    init(servletContext, request, response, template);
103            }
104    
105            @Override
106            public String actionURL(long plid, String portletName, String queryString)
107                    throws Exception {
108    
109                    String windowState = WindowState.NORMAL.toString();
110                    String portletMode = PortletMode.VIEW.toString();
111    
112                    return actionURL(
113                            windowState, portletMode, plid, portletName, queryString);
114            }
115    
116            @Override
117            public String actionURL(String portletName, String queryString)
118                    throws Exception {
119    
120                    return actionURL(
121                            LayoutConstants.DEFAULT_PLID, portletName, queryString);
122            }
123    
124            /**
125             * @deprecated As of 6.2.0, replaced by {@link #actionURL(String, String,
126             *             Boolean, Boolean, Boolean, String, long, long, String,
127             *             Boolean, Boolean, long, long, Boolean, String)}
128             */
129            @Deprecated
130            @Override
131            public String actionURL(
132                            String windowState, String portletMode, Boolean secure,
133                            Boolean copyCurrentRenderParameters, Boolean escapeXml, String name,
134                            long plid, long refererPlid, String portletName, Boolean anchor,
135                            Boolean encrypt, long doAsUserId, Boolean portletConfiguration,
136                            String queryString)
137                    throws Exception {
138    
139                    return actionURL(
140                            windowState, portletMode, secure, copyCurrentRenderParameters,
141                            escapeXml, name, plid, refererPlid, portletName, anchor, encrypt, 0,
142                            doAsUserId, portletConfiguration, queryString);
143            }
144    
145            @Override
146            public String actionURL(
147                            String windowState, String portletMode, Boolean secure,
148                            Boolean copyCurrentRenderParameters, Boolean escapeXml, String name,
149                            long plid, long refererPlid, String portletName, Boolean anchor,
150                            Boolean encrypt, long doAsGroupId, long doAsUserId,
151                            Boolean portletConfiguration, String queryString)
152                    throws Exception {
153    
154                    String resourceID = null;
155                    String cacheability = null;
156                    Map<String, String[]> parameterMap = HttpUtil.parameterMapFromString(
157                            queryString);
158                    Set<String> removedParameterNames = null;
159    
160                    PortletURL portletURL = ActionURLTag.doTag(
161                            PortletRequest.ACTION_PHASE, windowState, portletMode, secure,
162                            copyCurrentRenderParameters, escapeXml, name, resourceID,
163                            cacheability, plid, refererPlid, portletName, anchor, encrypt,
164                            doAsGroupId, doAsUserId, portletConfiguration, parameterMap,
165                            removedParameterNames, _request);
166    
167                    return portletURL.toString();
168            }
169    
170            @Override
171            public String actionURL(
172                            String windowState, String portletMode, long plid,
173                            String portletName, String queryString)
174                    throws Exception {
175    
176                    Boolean secure = null;
177                    Boolean copyCurrentRenderParameters = null;
178                    Boolean escapeXml = null;
179                    long refererPlid = LayoutConstants.DEFAULT_PLID;
180                    String name = null;
181                    Boolean anchor = null;
182                    Boolean encrypt = null;
183                    long doAsGroupId = 0;
184                    long doAsUserId = 0;
185                    Boolean portletConfiguration = null;
186    
187                    return actionURL(
188                            windowState, portletMode, secure, copyCurrentRenderParameters,
189                            escapeXml, name, plid, refererPlid, portletName, anchor, encrypt,
190                            doAsGroupId, doAsUserId, portletConfiguration, queryString);
191            }
192    
193            @Override
194            public String actionURL(
195                            String windowState, String portletMode, String portletName,
196                            String queryString)
197                    throws Exception {
198    
199                    return actionURL(
200                            windowState, portletMode, LayoutConstants.DEFAULT_PLID, portletName,
201                            queryString);
202            }
203    
204            @Override
205            public void assetCategoriesSummary(
206                            String className, long classPK, String message,
207                            PortletURL portletURL)
208                    throws Exception {
209    
210                    AssetCategoriesSummaryTag assetCategorySummaryTag =
211                            new AssetCategoriesSummaryTag();
212    
213                    setUp(assetCategorySummaryTag);
214    
215                    assetCategorySummaryTag.setClassName(className);
216                    assetCategorySummaryTag.setClassPK(classPK);
217                    assetCategorySummaryTag.setMessage(message);
218                    assetCategorySummaryTag.setPortletURL(portletURL);
219    
220                    assetCategorySummaryTag.runTag();
221            }
222    
223            @Override
224            public void assetLinks(long assetEntryId, String className, long classPK)
225                    throws Exception {
226    
227                    AssetLinksTag assetLinksTag = new AssetLinksTag();
228    
229                    setUp(assetLinksTag);
230    
231                    assetLinksTag.setAssetEntryId(assetEntryId);
232                    assetLinksTag.setClassName(className);
233                    assetLinksTag.setClassPK(classPK);
234    
235                    assetLinksTag.runTag();
236            }
237    
238            @Override
239            public void assetTagsSummary(
240                            String className, long classPK, String message,
241                            String assetTagNames, PortletURL portletURL)
242                    throws Exception {
243    
244                    AssetTagsSummaryTag assetTagsSummaryTag = new AssetTagsSummaryTag();
245    
246                    setUp(assetTagsSummaryTag);
247    
248                    assetTagsSummaryTag.setClassName(className);
249                    assetTagsSummaryTag.setClassPK(classPK);
250                    assetTagsSummaryTag.setMessage(message);
251                    assetTagsSummaryTag.setPortletURL(portletURL);
252                    assetTagsSummaryTag.setAssetTagNames(assetTagNames);
253    
254                    assetTagsSummaryTag.runTag();
255            }
256    
257            @Override
258            public void breadcrumb() throws Exception {
259                    BreadcrumbTag breadcrumbTag = new BreadcrumbTag();
260    
261                    setUp(breadcrumbTag);
262    
263                    breadcrumbTag.runTag();
264            }
265    
266            @Override
267            public void breadcrumb(
268                            String displayStyle, boolean showGuestGroup,
269                            boolean showParentGroups, boolean showLayout,
270                            boolean showPortletBreadcrumb)
271                    throws Exception {
272    
273                    BreadcrumbTag breadcrumbTag = new BreadcrumbTag();
274    
275                    setUp(breadcrumbTag);
276    
277                    breadcrumbTag.setDisplayStyle(displayStyle);
278                    breadcrumbTag.setShowGuestGroup(showGuestGroup);
279                    breadcrumbTag.setShowLayout(showLayout);
280                    breadcrumbTag.setShowParentGroups(showParentGroups);
281                    breadcrumbTag.setShowPortletBreadcrumb(showPortletBreadcrumb);
282    
283                    breadcrumbTag.runTag();
284            }
285    
286            @Override
287            public void discussion(
288                            String className, long classPK, String formAction, String formName,
289                            boolean hideControls, boolean ratingsEnabled, String redirect,
290                            long userId)
291                    throws Exception {
292    
293                    DiscussionTag discussionTag = new DiscussionTag();
294    
295                    setUp(discussionTag);
296    
297                    discussionTag.setClassName(className);
298                    discussionTag.setClassPK(classPK);
299                    discussionTag.setFormAction(formAction);
300                    discussionTag.setFormName(formName);
301                    discussionTag.setHideControls(hideControls);
302                    discussionTag.setRatingsEnabled(ratingsEnabled);
303                    discussionTag.setRedirect(redirect);
304                    discussionTag.setUserId(userId);
305    
306                    discussionTag.runTag();
307            }
308    
309            /**
310             * @deprecated As of 6.2.0, replaced by {@link #discussion(String, long,
311             *             String, String, boolean, boolean, String, long)})}
312             */
313            @Deprecated
314            @Override
315            public void discussion(
316                            String className, long classPK, String formAction, String formName,
317                            boolean hideControls, boolean ratingsEnabled, String redirect,
318                            String subject, long userId)
319                    throws Exception {
320    
321                    discussion(
322                            className, classPK, formAction, formName, hideControls,
323                            ratingsEnabled, redirect, userId);
324            }
325    
326            @Override
327            public void doAsURL(long doAsUserId) throws Exception {
328                    DoAsURLTag.doTag(doAsUserId, _request);
329            }
330    
331            @Override
332            public void flags(
333                            String className, long classPK, String contentTitle, boolean label,
334                            String message, long reportedUserId)
335                    throws Exception {
336    
337                    FlagsTag flagsTag = new FlagsTag();
338    
339                    setUp(flagsTag);
340    
341                    flagsTag.setClassName(className);
342                    flagsTag.setClassPK(classPK);
343                    flagsTag.setContentTitle(contentTitle);
344                    flagsTag.setLabel(label);
345                    flagsTag.setMessage(message);
346                    flagsTag.setReportedUserId(reportedUserId);
347    
348                    flagsTag.runTag();
349            }
350    
351            @Override
352            public AssetCategoriesSummaryTag getAssetCategoriesSummaryTag()
353                    throws Exception {
354    
355                    AssetCategoriesSummaryTag assetCategoriesSummaryTag =
356                            new AssetCategoriesSummaryTag();
357    
358                    setUp(assetCategoriesSummaryTag);
359    
360                    return assetCategoriesSummaryTag;
361            }
362    
363            @Override
364            public AssetLinksTag getAssetLinksTag() throws Exception {
365                    AssetLinksTag assetLinksTag = new AssetLinksTag();
366    
367                    setUp(assetLinksTag);
368    
369                    return assetLinksTag;
370            }
371    
372            @Override
373            public AssetTagsSummaryTag getAssetTagsSummaryTag() throws Exception {
374                    AssetTagsSummaryTag assetTagsSummaryTag = new AssetTagsSummaryTag();
375    
376                    setUp(assetTagsSummaryTag);
377    
378                    return assetTagsSummaryTag;
379            }
380    
381            @Override
382            public BreadcrumbTag getBreadcrumbTag() throws Exception {
383                    BreadcrumbTag breadcrumbTag = new BreadcrumbTag();
384    
385                    setUp(breadcrumbTag);
386    
387                    return breadcrumbTag;
388            }
389    
390            @Override
391            public ColumnTag getColumnTag() throws Exception {
392                    ColumnTag columnTag = new ColumnTag();
393    
394                    setUp(columnTag);
395    
396                    return columnTag;
397            }
398    
399            @Override
400            public DiscussionTag getDiscussionTag() throws Exception {
401                    DiscussionTag discussionTag = new DiscussionTag();
402    
403                    setUp(discussionTag);
404    
405                    return discussionTag;
406            }
407    
408            @Override
409            public FlagsTag getFlagsTag() throws Exception {
410                    FlagsTag flagsTag = new FlagsTag();
411    
412                    setUp(flagsTag);
413    
414                    return flagsTag;
415            }
416    
417            @Override
418            public IconTag getIconTag() throws Exception {
419                    IconTag iconTag = new IconTag();
420    
421                    setUp(iconTag);
422    
423                    return iconTag;
424            }
425    
426            @Override
427            public JournalArticleTag getJournalArticleTag() throws Exception {
428                    JournalArticleTag journalArticleTag = new JournalArticleTag();
429    
430                    setUp(journalArticleTag);
431    
432                    return journalArticleTag;
433            }
434    
435            @Override
436            public LayoutTag getLayoutTag() throws Exception {
437                    LayoutTag layoutTag = new LayoutTag();
438    
439                    setUp(layoutTag);
440    
441                    return layoutTag;
442            }
443    
444            @Override
445            public MySitesTag getMySitesTag() throws Exception {
446                    MySitesTag mySitesTag = new MySitesTag();
447    
448                    setUp(mySitesTag);
449    
450                    return mySitesTag;
451            }
452    
453            @Override
454            public PageContext getPageContext() {
455                    return _pageContext;
456            }
457    
458            @Override
459            public PngImageTag getPngImageTag() throws Exception {
460                    PngImageTag pngImageTag = new PngImageTag();
461    
462                    setUp(pngImageTag);
463    
464                    return pngImageTag;
465            }
466    
467            @Override
468            public QuickAccessTag getQuickAccessTag() throws Exception {
469                    QuickAccessTag quickAccessTag = new QuickAccessTag();
470    
471                    setUp(quickAccessTag);
472    
473                    return quickAccessTag;
474            }
475    
476            @Override
477            public RatingsTag getRatingsTag() throws Exception {
478                    RatingsTag ratingsTag = new RatingsTag();
479    
480                    setUp(ratingsTag);
481    
482                    return ratingsTag;
483            }
484    
485            @Override
486            public String getSetting(String name) {
487                    ThemeDisplay themeDisplay = (ThemeDisplay)_request.getAttribute(
488                            WebKeys.THEME_DISPLAY);
489    
490                    return themeDisplay.getThemeSetting(name);
491            }
492    
493            @Override
494            public WindowState getWindowState(String windowState) {
495                    return new WindowState(windowState);
496            }
497    
498            @Override
499            public void icon(String image, boolean label, String message, String url)
500                    throws Exception {
501    
502                    IconTag iconTag = new IconTag();
503    
504                    setUp(iconTag);
505    
506                    iconTag.setImage(image);
507                    iconTag.setLabel(label);
508                    iconTag.setMessage(message);
509                    iconTag.setUrl(url);
510    
511                    iconTag.runTag();
512            }
513    
514            /**
515             * @deprecated As of 6.2.0, replaced by {@link #iconBack}
516             */
517            @Deprecated
518            @Override
519            public void iconBack() throws Exception {
520                    portletIconBack();
521            }
522    
523            /**
524             * @deprecated As of 6.2.0, replaced by {@link #portletIconClose}
525             */
526            @Deprecated
527            @Override
528            public void iconClose() throws Exception {
529                    portletIconClose();
530            }
531    
532            /**
533             * @deprecated As of 6.2.0, replaced by {@link #portletIconConfiguration}
534             */
535            @Deprecated
536            @Override
537            public void iconConfiguration() throws Exception {
538                    portletIconConfiguration();
539            }
540    
541            /**
542             * @deprecated As of 6.2.0, replaced by {@link #portletIconEdit}
543             */
544            @Deprecated
545            @Override
546            public void iconEdit() throws Exception {
547                    portletIconEdit();
548            }
549    
550            /**
551             * @deprecated As of 6.2.0, replaced by {@link #portletIconEditDefaults}
552             */
553            @Deprecated
554            @Override
555            public void iconEditDefaults() throws Exception {
556                    portletIconEditDefaults();
557            }
558    
559            /**
560             * @deprecated As of 6.2.0, replaced by {@link #portletIconEditGuest}
561             */
562            @Deprecated
563            @Override
564            public void iconEditGuest() throws Exception {
565                    portletIconEditGuest();
566            }
567    
568            /**
569             * @deprecated As of 6.2.0, replaced by {@link #portletIconHelp}
570             */
571            @Deprecated
572            @Override
573            public void iconHelp() throws Exception {
574                    portletIconHelp();
575            }
576    
577            @Override
578            public void iconHelp(String message) throws Exception {
579                    com.liferay.taglib.ui.IconHelpTag iconHelpTag =
580                            new com.liferay.taglib.ui.IconHelpTag();
581    
582                    setUp(iconHelpTag);
583    
584                    iconHelpTag.setMessage(message);
585    
586                    iconHelpTag.runTag();
587            }
588    
589            /**
590             * @deprecated As of 6.2.0, replaced by {@link #portletIconMaximize}
591             */
592            @Deprecated
593            @Override
594            public void iconMaximize() throws Exception {
595                    portletIconMaximize();
596            }
597    
598            /**
599             * @deprecated As of 6.2.0, replaced by {@link #portletIconMinimize}
600             */
601            @Deprecated
602            @Override
603            public void iconMinimize() throws Exception {
604                    portletIconMinimize();
605            }
606    
607            /**
608             * @deprecated As of 6.2.0, replaced by {@link #portletIconOptions}
609             */
610            @Deprecated
611            @Override
612            public void iconOptions() throws Exception {
613                    portletIconOptions();
614            }
615    
616            /**
617             * @deprecated As of 6.2.0, replaced by {@link #portletIconPortlet}
618             */
619            @Deprecated
620            @Override
621            public void iconPortlet() throws Exception {
622                    portletIconPortlet();
623            }
624    
625            /**
626             * @deprecated As of 6.2.0, replaced by {@link #portletIconPortlet(Portlet)}
627             */
628            @Deprecated
629            @Override
630            public void iconPortlet(Portlet portlet) throws Exception {
631                    portletIconPortlet();
632            }
633    
634            /**
635             * @deprecated As of 6.2.0, replaced by {@link #portletIconPortletCss}
636             */
637            @Deprecated
638            @Override
639            public void iconPortletCss() throws Exception {
640                    portletIconPortletCss();
641            }
642    
643            /**
644             * @deprecated As of 6.2.0, replaced by {@link #portletIconPrint}
645             */
646            @Deprecated
647            @Override
648            public void iconPrint() throws Exception {
649                    portletIconPrint();
650            }
651    
652            /**
653             * @deprecated As of 6.2.0, replaced by {@link #portletIconRefresh}
654             */
655            @Deprecated
656            @Override
657            public void iconRefresh() throws Exception {
658                    portletIconRefresh();
659            }
660    
661            @Override
662            public void include(ServletContext servletContext, String page)
663                    throws Exception {
664    
665                    RequestDispatcher requestDispatcher =
666                            servletContext.getRequestDispatcher(page);
667    
668                    requestDispatcher.include(_request, _response);
669            }
670    
671            @Override
672            public void include(String page) throws Exception {
673                    RequestDispatcher requestDispatcher =
674                            DirectRequestDispatcherFactoryUtil.getRequestDispatcher(
675                                    _servletContext, page);
676    
677                    requestDispatcher.include(_request, _response);
678            }
679    
680            @Override
681            public void journalArticle(
682                            String articleId, long groupId, String ddmTemplateKey)
683                    throws Exception {
684    
685                    JournalArticleTag journalArticleTag = new JournalArticleTag();
686    
687                    setUp(journalArticleTag);
688    
689                    journalArticleTag.setArticleId(articleId);
690                    journalArticleTag.setGroupId(groupId);
691                    journalArticleTag.setLanguageId(LanguageUtil.getLanguageId(_request));
692                    journalArticleTag.setDDMTemplateKey(ddmTemplateKey);
693    
694                    journalArticleTag.runTag();
695            }
696    
697            @Override
698            public void journalContentSearch() throws Exception {
699                    journalContentSearch(true, null, null);
700            }
701    
702            @Override
703            public void journalContentSearch(
704                            boolean showListed, String targetPortletId, String type)
705                    throws Exception {
706    
707                    JournalContentSearchTag journalContentSearchTag =
708                            new JournalContentSearchTag();
709    
710                    setUp(journalContentSearchTag);
711    
712                    journalContentSearchTag.setShowListed(showListed);
713                    journalContentSearchTag.setTargetPortletId(targetPortletId);
714                    journalContentSearchTag.setType(type);
715    
716                    journalContentSearchTag.runTag();
717            }
718    
719            @Override
720            public void language() throws Exception {
721                    LanguageTag languageTag = new LanguageTag();
722    
723                    setUp(languageTag);
724    
725                    languageTag.runTag();
726            }
727    
728            @Override
729            public void language(
730                            String formName, String formAction, String name,
731                            String displayStyle)
732                    throws Exception {
733    
734                    LanguageTag languageTag = new LanguageTag();
735    
736                    setUp(languageTag);
737    
738                    languageTag.setDisplayStyle(displayStyle);
739                    languageTag.setFormAction(formAction);
740                    languageTag.setFormName(formName);
741                    languageTag.setName(name);
742    
743                    languageTag.runTag();
744            }
745    
746            @Override
747            public void language(
748                            String formName, String formAction, String name,
749                            String[] languageIds, String displayStyle)
750                    throws Exception {
751    
752                    LanguageTag languageTag = new LanguageTag();
753    
754                    setUp(languageTag);
755    
756                    languageTag.setDisplayStyle(displayStyle);
757                    languageTag.setFormAction(formAction);
758                    languageTag.setFormName(formName);
759                    languageTag.setLanguageIds(languageIds);
760                    languageTag.setName(name);
761    
762                    languageTag.runTag();
763            }
764    
765            @Override
766            public void layoutIcon(Layout layout) throws Exception {
767                    LayoutIconTag.doTag(layout, _servletContext, _request, _response);
768            }
769    
770            @Override
771            public void metaTags() throws Exception {
772                    MetaTagsTag.doTag(_servletContext, _request, _response);
773            }
774    
775            /**
776             * @deprecated As of 6.2.0, replaced by {@link #mySites}
777             */
778            @Deprecated
779            @Override
780            public void myPlaces() throws Exception {
781                    mySites();
782            }
783    
784            /**
785             * @deprecated As of 6.2.0, replaced by {@link #mySites(int)}
786             */
787            @Deprecated
788            @Override
789            public void myPlaces(int max) throws Exception {
790                    mySites(max);
791            }
792    
793            @Override
794            public void mySites() throws Exception {
795                    MySitesTag mySitesTag = new MySitesTag();
796    
797                    setUp(mySitesTag);
798    
799                    mySitesTag.runTag();
800            }
801    
802            @Override
803            public void mySites(int max) throws Exception {
804                    MySitesTag mySitesTag = new MySitesTag();
805    
806                    setUp(mySitesTag);
807    
808                    mySitesTag.setMax(max);
809    
810                    mySitesTag.runTag();
811            }
812    
813            @Override
814            public String permissionsURL(
815                            String redirect, String modelResource,
816                            String modelResourceDescription, Object resourceGroupId,
817                            String resourcePrimKey, String windowState, int[] roleTypes)
818                    throws Exception {
819    
820                    return PermissionsURLTag.doTag(
821                            redirect, modelResource, modelResourceDescription, resourceGroupId,
822                            resourcePrimKey, windowState, roleTypes, _request);
823            }
824    
825            /**
826             * @deprecated As of 6.2.0, replaced by {@link #permissionsURL(String,
827             *             String, String, Object, String, String, int[])}
828             */
829            @Deprecated
830            @Override
831            public String permissionsURL(
832                            String redirect, String modelResource,
833                            String modelResourceDescription, String resourcePrimKey,
834                            String windowState, int[] roleTypes)
835                    throws Exception {
836    
837                    return permissionsURL(
838                            redirect, modelResourceDescription, modelResourceDescription, null,
839                            resourcePrimKey, windowState, roleTypes);
840            }
841    
842            @Override
843            public void portletIconBack() throws Exception {
844                    IconBackTag iconBackTag = new IconBackTag();
845    
846                    setUp(iconBackTag);
847    
848                    iconBackTag.runTag();
849            }
850    
851            @Override
852            public void portletIconClose() throws Exception {
853                    IconCloseTag iconCloseTag = new IconCloseTag();
854    
855                    setUp(iconCloseTag);
856    
857                    iconCloseTag.runTag();
858            }
859    
860            @Override
861            public void portletIconConfiguration() throws Exception {
862                    IconConfigurationTag iconConfigurationTag = new IconConfigurationTag();
863    
864                    setUp(iconConfigurationTag);
865    
866                    iconConfigurationTag.runTag();
867            }
868    
869            @Override
870            public void portletIconEdit() throws Exception {
871                    IconEditTag iconEditTag = new IconEditTag();
872    
873                    setUp(iconEditTag);
874    
875                    iconEditTag.runTag();
876            }
877    
878            @Override
879            public void portletIconEditDefaults() throws Exception {
880                    IconEditDefaultsTag iconEditDefaultsTag = new IconEditDefaultsTag();
881    
882                    setUp(iconEditDefaultsTag);
883    
884                    iconEditDefaultsTag.runTag();
885            }
886    
887            @Override
888            public void portletIconEditGuest() throws Exception {
889                    IconEditGuestTag iconEditGuestTag = new IconEditGuestTag();
890    
891                    setUp(iconEditGuestTag);
892    
893                    iconEditGuestTag.runTag();
894            }
895    
896            @Override
897            public void portletIconHelp() throws Exception {
898                    IconHelpTag iconHelpTag = new IconHelpTag();
899    
900                    setUp(iconHelpTag);
901    
902                    iconHelpTag.runTag();
903            }
904    
905            @Override
906            public void portletIconMaximize() throws Exception {
907                    IconMaximizeTag iconMaximizeTag = new IconMaximizeTag();
908    
909                    setUp(iconMaximizeTag);
910    
911                    iconMaximizeTag.runTag();
912            }
913    
914            @Override
915            public void portletIconMinimize() throws Exception {
916                    IconMinimizeTag iconMinimizeTag = new IconMinimizeTag();
917    
918                    setUp(iconMinimizeTag);
919    
920                    iconMinimizeTag.runTag();
921            }
922    
923            @Override
924            public void portletIconOptions() throws Exception {
925                    IconOptionsTag iconOptionsTag = new IconOptionsTag();
926    
927                    setUp(iconOptionsTag);
928    
929                    iconOptionsTag.runTag();
930            }
931    
932            @Override
933            public void portletIconPortlet() throws Exception {
934                    IconPortletTag iconPortletTag = new IconPortletTag();
935    
936                    setUp(iconPortletTag);
937    
938                    iconPortletTag.runTag();
939            }
940    
941            @Override
942            public void portletIconPortlet(Portlet portlet) throws Exception {
943                    IconPortletTag iconPortletTag = new IconPortletTag();
944    
945                    setUp(iconPortletTag);
946    
947                    iconPortletTag.setPortlet(portlet);
948    
949                    iconPortletTag.runTag();
950            }
951    
952            @Override
953            public void portletIconPortletCss() throws Exception {
954                    IconPortletCssTag iconPortletCssTag = new IconPortletCssTag();
955    
956                    setUp(iconPortletCssTag);
957    
958                    iconPortletCssTag.runTag();
959            }
960    
961            @Override
962            public void portletIconPrint() throws Exception {
963                    IconPrintTag iconPrintTag = new IconPrintTag();
964    
965                    setUp(iconPrintTag);
966    
967                    iconPrintTag.runTag();
968            }
969    
970            @Override
971            public void portletIconRefresh() throws Exception {
972                    IconRefreshTag iconRefreshTag = new IconRefreshTag();
973    
974                    setUp(iconRefreshTag);
975    
976                    iconRefreshTag.runTag();
977            }
978    
979            @Override
980            public void quickAccess() throws Exception {
981                    QuickAccessTag quickAccessTag = new QuickAccessTag();
982    
983                    setUp(quickAccessTag);
984    
985                    quickAccessTag.runTag();
986            }
987    
988            @Override
989            public void quickAccess(String contentId) throws Exception {
990                    QuickAccessTag quickAccessTag = new QuickAccessTag();
991    
992                    setUp(quickAccessTag);
993    
994                    quickAccessTag.setContentId(contentId);
995    
996                    quickAccessTag.runTag();
997            }
998    
999            @Override
1000            public void ratings(
1001                            String className, long classPK, int numberOfStars, String type,
1002                            String url)
1003                    throws Exception {
1004    
1005                    RatingsTag ratingsTag = new RatingsTag();
1006    
1007                    setUp(ratingsTag);
1008    
1009                    ratingsTag.setClassName(className);
1010                    ratingsTag.setClassPK(classPK);
1011                    ratingsTag.setNumberOfStars(numberOfStars);
1012                    ratingsTag.setType(type);
1013                    ratingsTag.setUrl(url);
1014    
1015                    ratingsTag.runTag();
1016            }
1017    
1018            @Override
1019            public String renderURL(long plid, String portletName, String queryString)
1020                    throws Exception {
1021    
1022                    String windowState = WindowState.NORMAL.toString();
1023                    String portletMode = PortletMode.VIEW.toString();
1024    
1025                    return renderURL(
1026                            windowState, portletMode, plid, portletName, queryString);
1027            }
1028    
1029            @Override
1030            public String renderURL(String portletName, String queryString)
1031                    throws Exception {
1032    
1033                    return renderURL(
1034                            LayoutConstants.DEFAULT_PLID, portletName, queryString);
1035            }
1036    
1037            @Override
1038            public String renderURL(
1039                            String windowState, String portletMode, Boolean secure,
1040                            Boolean copyCurrentRenderParameters, Boolean escapeXml, long plid,
1041                            long refererPlid, String portletName, Boolean anchor,
1042                            Boolean encrypt, long doAsGroupId, long doAsUserId,
1043                            Boolean portletConfiguration, String queryString)
1044                    throws Exception {
1045    
1046                    String name = null;
1047                    String resourceID = null;
1048                    String cacheability = null;
1049                    Map<String, String[]> parameterMap = HttpUtil.parameterMapFromString(
1050                            queryString);
1051                    Set<String> removedParameterNames = null;
1052    
1053                    PortletURL portletURL = ActionURLTag.doTag(
1054                            PortletRequest.RENDER_PHASE, windowState, portletMode, secure,
1055                            copyCurrentRenderParameters, escapeXml, name, resourceID,
1056                            cacheability, plid, refererPlid, portletName, anchor, encrypt,
1057                            doAsGroupId, doAsUserId, portletConfiguration, parameterMap,
1058                            removedParameterNames, _request);
1059    
1060                    return portletURL.toString();
1061            }
1062    
1063            /**
1064             * @deprecated As of 6.2.0, replaced by {@link #renderURL(String, String,
1065             *             Boolean, Boolean, Boolean, long, long, String, Boolean,
1066             *             Boolean, long, long, Boolean, String)}
1067             */
1068            @Deprecated
1069            @Override
1070            public String renderURL(
1071                            String windowState, String portletMode, Boolean secure,
1072                            Boolean copyCurrentRenderParameters, Boolean escapeXml, long plid,
1073                            String portletName, Boolean anchor, Boolean encrypt,
1074                            long doAsUserId, Boolean portletConfiguration, String queryString)
1075                    throws Exception {
1076    
1077                    long refererPlid = LayoutConstants.DEFAULT_PLID;
1078    
1079                    return renderURL(
1080                            windowState, portletMode, secure, copyCurrentRenderParameters,
1081                            escapeXml, plid, refererPlid, portletName, anchor, encrypt, 0,
1082                            doAsUserId, portletConfiguration, queryString);
1083            }
1084    
1085            @Override
1086            public String renderURL(
1087                            String windowState, String portletMode, long plid,
1088                            String portletName, String queryString)
1089                    throws Exception {
1090    
1091                    Boolean secure = null;
1092                    Boolean copyCurrentRenderParameters = null;
1093                    Boolean escapeXml = null;
1094                    long referPlid = LayoutConstants.DEFAULT_PLID;
1095                    Boolean anchor = null;
1096                    Boolean encrypt = null;
1097                    long doAsGroupId = 0;
1098                    long doAsUserId = 0;
1099                    Boolean portletConfiguration = null;
1100    
1101                    return renderURL(
1102                            windowState, portletMode, secure, copyCurrentRenderParameters,
1103                            escapeXml, plid, referPlid, portletName, anchor, encrypt,
1104                            doAsGroupId, doAsUserId, portletConfiguration, queryString);
1105            }
1106    
1107            @Override
1108            public String renderURL(
1109                            String windowState, String portletMode, String portletName,
1110                            String queryString)
1111                    throws Exception {
1112    
1113                    return renderURL(
1114                            windowState, portletMode, LayoutConstants.DEFAULT_PLID, portletName,
1115                            queryString);
1116            }
1117    
1118            @Override
1119            public void runtime(String portletName) throws Exception {
1120                    runtime(portletName, null);
1121            }
1122    
1123            @Override
1124            public void runtime(String portletName, String queryString)
1125                    throws Exception {
1126    
1127                    RuntimeTag.doTag(portletName, queryString, null, _request, _response);
1128            }
1129    
1130            @Override
1131            public void runtime(
1132                            String portletName, String queryString, String defaultPreferences)
1133                    throws Exception {
1134    
1135                    RuntimeTag.doTag(
1136                            portletName, queryString, defaultPreferences, null, _request,
1137                            _response);
1138            }
1139    
1140            @Override
1141            public void search() throws Exception {
1142                    SearchTag searchTag = new SearchTag();
1143    
1144                    setUp(searchTag);
1145    
1146                    searchTag.runTag();
1147            }
1148    
1149            @Override
1150            public void setTemplate(Template template) {
1151                    _template = template;
1152            }
1153    
1154            @Override
1155            public void sitesDirectory() throws Exception {
1156                    SitesDirectoryTag sitesDirectoryTag = new SitesDirectoryTag();
1157    
1158                    setUp(sitesDirectoryTag);
1159    
1160                    sitesDirectoryTag.runTag();
1161            }
1162    
1163            @Override
1164            public void sitesDirectory(String displayStyle, String sites)
1165                    throws Exception {
1166    
1167                    SitesDirectoryTag sitesDirectoryTag = new SitesDirectoryTag();
1168    
1169                    setUp(sitesDirectoryTag);
1170    
1171                    sitesDirectoryTag.setDisplayStyle(displayStyle);
1172                    sitesDirectoryTag.setSites(sites);
1173    
1174                    sitesDirectoryTag.runTag();
1175            }
1176    
1177            @Override
1178            public void socialBookmarks(
1179                            String displayStyle, String target, String types, String title,
1180                            String url)
1181                    throws Exception {
1182    
1183                    SocialBookmarksTag socialBookmarksTag = new SocialBookmarksTag();
1184    
1185                    setUp(socialBookmarksTag);
1186    
1187                    socialBookmarksTag.setDisplayStyle(displayStyle);
1188                    socialBookmarksTag.setTarget(target);
1189                    socialBookmarksTag.setTypes(types);
1190                    socialBookmarksTag.setTitle(title);
1191                    socialBookmarksTag.setUrl(url);
1192    
1193                    socialBookmarksTag.runTag();
1194            }
1195    
1196            /**
1197             * @deprecated As of 7.0.0, with no direct replacement
1198             */
1199            @Deprecated
1200            @Override
1201            public void staging() throws Exception {
1202            }
1203    
1204            @Override
1205            public void toggle(
1206                            String id, String showImage, String hideImage, String showMessage,
1207                            String hideMessage, boolean defaultShowContent)
1208                    throws Exception {
1209    
1210                    ToggleTag.doTag(
1211                            id, showImage, hideImage, showMessage, hideMessage,
1212                            defaultShowContent, null, _servletContext, _request, _response);
1213            }
1214    
1215            @Override
1216            public String wrapPortlet(String wrapPage, String portletPage)
1217                    throws Exception {
1218    
1219                    return WrapPortletTag.doTag(
1220                            wrapPage, portletPage, _servletContext, _request, _response);
1221            }
1222    
1223            protected VelocityTaglibImpl init(
1224                    ServletContext servletContext, HttpServletRequest request,
1225                    HttpServletResponse response, Template template) {
1226    
1227                    _servletContext = servletContext;
1228                    _request = request;
1229                    _response = response;
1230                    _template = template;
1231    
1232                    JspFactory jspFactory = JspFactory.getDefaultFactory();
1233    
1234                    _pageContext = jspFactory.getPageContext(
1235                            new JSPSupportServlet(_servletContext), _request, _response, null,
1236                            false, 0, false);
1237    
1238                    return this;
1239            }
1240    
1241            protected void setUp(TagSupport tagSupport) throws Exception {
1242                    Writer writer = null;
1243    
1244                    if (_template != null) {
1245                            writer = (Writer)_template.get(TemplateConstants.WRITER);
1246                    }
1247    
1248                    if (writer == null) {
1249                            writer = _response.getWriter();
1250                    }
1251    
1252                    tagSupport.setPageContext(new PipingPageContext(_pageContext, writer));
1253            }
1254    
1255            private PageContext _pageContext;
1256            private HttpServletRequest _request;
1257            private HttpServletResponse _response;
1258            private ServletContext _servletContext;
1259            private Template _template;
1260    
1261    }