public static SelectOptions getSiteSelectOptionsStatic(CmsObject cms, String wpSite, Locale locale) {

        List<String> options = new ArrayList<String>();
        List<String> values = new ArrayList<String>();
        int selectedIndex = 0;

        List<CmsSite> sites = OpenCms.getSiteManager().getAvailableSites(
            cms,
            true,
            false,
            cms.getRequestContext().getOuFqn());
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(wpSite) && !wpSite.endsWith("/")) {
            wpSite += "/";
        }

        Iterator<CmsSite> i = sites.iterator();
        int pos = 0;
        while (i.hasNext()) {
            CmsSite site = i.next();
            String siteRoot = site.getSiteRoot();
            if (!siteRoot.endsWith("/")) {
                siteRoot += "/";
            }
            values.add(siteRoot);
            options.add(CmsWorkplace.substituteSiteTitleStatic(site.getTitle(), locale));
            if (siteRoot.equals(wpSite)) {
                // this is the user's currently chosen site
                selectedIndex = pos;
            }
            pos++;
        }

        if (sites.size() < 1) {
            // no site found, assure that at least the current site is shown in the selector
            String siteRoot = cms.getRequestContext().getSiteRoot();
            CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot);
            if (!siteRoot.endsWith("/")) {
                siteRoot += "/";
            }
            String title = "";
            if (site != null) {
                title = site.getTitle();
            }
            values.add(siteRoot);
            options.add(title);
        }
        SelectOptions selectOptions = new SelectOptions(options, values, selectedIndex);
        return selectOptions;
    }
public static SelectOptions getSiteSelectOptionsStatic ( CmsObject cms , String wpSite , Locale locale ) { List < String > options = new ArrayList < String > ( ) ; List < String > values = new ArrayList < String > ( ) ; int selectedIndex = 0 ; List < CmsSite > sites = OpenCms . getSiteManager ( ) . getAvailableSites ( cms , true , false , cms . getRequestContext ( ) . getOuFqn ( ) ) ; if ( CmsStringUtil . isNotEmptyOrWhitespaceOnly ( wpSite ) && ! wpSite . endsWith ( "/" ) ) { wpSite += "/" ; } Iterator < CmsSite > i = sites . iterator ( ) ; int pos = 0 ; while ( i . hasNext ( ) ) { CmsSite site = i . next ( ) ; String siteRoot = site . getSiteRoot ( ) ; if ( ! siteRoot . endsWith ( "/" ) ) { siteRoot += "/" ; } values . add ( siteRoot ) ; options . add ( CmsWorkplace . substituteSiteTitleStatic ( site . getTitle ( ) , locale ) ) ; if ( siteRoot . equals ( wpSite ) ) { selectedIndex = pos ; } pos ++ ; } if ( sites . size ( ) < 1 ) { String siteRoot = cms . getRequestContext ( ) . getSiteRoot ( ) ; CmsSite site = OpenCms . getSiteManager ( ) . getSiteForSiteRoot ( siteRoot ) ; if ( ! siteRoot . endsWith ( "/" ) ) { siteRoot += "/" ; } String title = "" ; if ( site != null ) { title = site . getTitle ( ) ; } values . add ( siteRoot ) ; options . add ( title ) ; } SelectOptions selectOptions = new SelectOptions ( options , values , selectedIndex ) ; return selectOptions ; }
Gets the options for the site selector.<p>

@param cms the CMS context
@param wpSite the selected site
@param locale the locale for the select options

@return the options for the site selector