code: private String export(GalleryMode galleryMode) throws Exception {
  
          CmsGalleryConfiguration conf = createGalleryConfigurationFromRequest(galleryMode);
          CmsGalleryDataBean data = CmsGalleryService.getInitialSettings(getRequest(), conf);
          CmsGallerySearchBean search = null;
          if (GalleryTabId.cms_tab_results.equals(data.getStartTab())) {
              search = CmsGalleryService.getSearch(getRequest(), data);
          }
          Set<String> folderFilter = data.getStartFolderFilter();
          if ((folderFilter != null) && !folderFilter.isEmpty()) {
              data.setVfsPreloadData(CmsGalleryService.generateVfsPreloadData(getCmsObject(), null, folderFilter));
          }
          if ((search != null) && (search.getScope() != null) && (search.getScope() != data.getScope())) {
              // default selected scope option should be the one for which the search has been actually performed
              data.setScope(search.getScope());
          } else if ((search != null) && (search.getScope() == null)) {
              data.setScope(OpenCms.getWorkplaceManager().getGalleryDefaultScope());
          }
  
          StringBuffer sb = new StringBuffer();
          sb.append(
              exportDictionary(
                  CmsGalleryDataBean.DICT_NAME,
                  I_CmsGalleryService.class.getMethod("getInitialSettings", CmsGalleryConfiguration.class),
                  data));
          sb.append(
              exportDictionary(
                  CmsGallerySearchBean.DICT_NAME,
                  I_CmsGalleryService.class.getMethod("getSearch", CmsGalleryDataBean.class),
                  search));
          return sb.toString();
      }
docs: Returns the serialized initial data for gallery dialog depending on the given mode.<p>
  
  @param galleryMode the gallery mode
  
  @return the data
  
  @throws Exception if something goes wrong