+ List extraTables = new ArrayList();
+ extraTables.add("content_x_media cxm");
+ Iterator images = new EntityBrowser(
+ DatabaseImages.getInstance(), "i", extraTables,
+ "cxm.content_id=" + anArticle.getId() + "and cxm.media_id=i.id",
+ "i.id desc", 30, -1, 0);
+
+ String isHTML = anArticle.getFieldValue("is_html");
+ String theTitle = anArticle.getFieldValue("title");
+ String theCreator = anArticle.getFieldValue("creator");
+ String theDate = DateTimeRoutines.advancedDateFormat(
+ configuration.getString("RDF.Meta.DateFormat"),
+ StringUtil.convertMirInternalDateToDate(anArticle.getFieldValue("webdb_create")),
+ configuration.getString("Mir.DefaultTimezone"));
+
+
+ String theDescriptionRaw = anArticle.getFieldValue("description");
+ String theContentRaw = anArticle.getFieldValue("content_data");
+
+ MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance();
+ Map variables = GeneratorHelper.makeBasicGenerationData(new Locale[] {
+ aLocale ,new Locale(configuration.getString("Mir.Admin.FallbackLanguage", "en"), "")},
+ "bundles.open","bundles.open");
+
+ EntityAdapter article =
+ MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("content", anArticle);
+ variables.put("article", article);
+ String source = ParameterExpander.expandExpression(
+ variables,
+ configuration.getString("PDF.Source")
+ );
+ String theContent = "";
+ String theDescription = "";
+
+ if (isHTML.equals("1")) {
+
+
+ try {
+ RE nobackslashr = new RE("\r");
+ theContent = nobackslashr.substituteAll(theContentRaw, "");
+ theDescription = nobackslashr.substituteAll(theDescriptionRaw, "");
+
+ RE HxTag = new RE("</?h[1-6][^>]*>", RE.REG_ICASE);
+ theContent = HxTag.substituteAll(theContent, "\n\n");
+ theDescription = HxTag.substituteAll(theDescription, "\n\n");
+
+ RE ListItemTag = new RE("<li[^>]*>", RE.REG_ICASE);
+ theContent = ListItemTag.substituteAll(theContent, "\n * ");
+ theDescription = ListItemTag.substituteAll(theDescription, "\n * ");
+
+ RE ListTag = new RE("<(u|o)l[^>]*>", RE.REG_ICASE);
+ theContent = ListTag.substituteAll(theContent, "\n");
+ theDescription = ListTag.substituteAll(theDescription, "\n");
+
+ RE DivTag = new RE("</?div[^>]*>", RE.REG_ICASE);
+ theContent = DivTag.substituteAll(theContent, "\n");
+ theDescription = DivTag.substituteAll(theDescription, "\n");
+
+ RE PTag = new RE("<(p|P)([:space:]+[^>]*)?>");
+ theContent = PTag.substituteAll(theContent, "\n ");
+ theDescription = PTag.substituteAll(theDescription, "\n ");
+
+ RE PTagClose = new RE("</(p|P)([:space:]+[^>]*)?>");
+ theContent = PTagClose.substituteAll(theContent, "\n");
+ theDescription = PTagClose.substituteAll(theDescription, "\n");
+
+ RE BRTag = new RE("<(br|BR)([:space:]+[^>]*)?>");
+ theContent = BRTag.substituteAll(theContent, "\n");
+ theDescription = BRTag.substituteAll(theDescription, "\n");
+
+ RE ATagAll = new RE("<a[^>]*href=(?:\"|\')([^#\"\'][^\'\"]+)(?:\"|\')[^>]*>(.*?)</a>", RE.REG_ICASE);
+ REMatchEnumeration atags = ATagAll.getMatchEnumeration(theContent);
+ String theContentCopy = theContent;
+ while (atags.hasMoreMatches()) {
+ REMatch atag = atags.nextMatch();
+ String atagString = atag.toString();
+ String atagStringHref = atag.toString(1);
+ String atagStringText = atag.toString(2);
+ int begin = theContentCopy.indexOf(atagString);
+ theContentCopy = theContentCopy.substring(0, begin) + atagStringText + " [" + atagStringHref + "] " + theContentCopy.substring(begin + atagString.length());
+ }
+ theContent = theContentCopy;
+
+ REMatchEnumeration atags2 = ATagAll.getMatchEnumeration(theDescription);
+ String theDescriptionCopy = theDescription;
+ while (atags2.hasMoreMatches()) {
+ REMatch atag = atags2.nextMatch();
+ String atagString = atag.toString();
+ String atagStringHref = atag.toString(1);
+ String atagStringText = atag.toString(2);
+ int begin = theDescriptionCopy.indexOf(atagString);
+ theDescriptionCopy = theDescriptionCopy.substring(0, begin) + atagStringText + " [" + atagStringHref + "] " + theDescriptionCopy.substring(begin + atagString.length());
+ }
+ theDescription = theDescriptionCopy;
+
+
+ RE noTags = new RE("<[^>]*>");
+ theContent = noTags.substituteAll(theContent, " ");
+ theDescription = noTags.substituteAll(theDescription, " ");
+
+ theContent = HTMLRoutines.resolveHTMLEntites(theContent);
+ theDescription = HTMLRoutines.resolveHTMLEntites(theDescription);
+
+ RE re1 = new RE("\r?\n\r?\n");
+ String theDescription1 = re1.substituteAll(theDescription, "BREAKHERE");
+
+ RE re2 = new RE("\r?\n");
+ String theDescription2 = re2.substituteAll(theDescription1, " ");
+
+ RE re3 = new RE("BREAKHERE");
+ theDescription = re3.substituteAll(theDescription2, "\n ");
+
+
+ }
+ catch (REException ree) {
+ logger.error(ree.getMessage());
+ }
+ } else {
+ try {
+ RE re1 = new RE("\r?\n\r?\n");
+ String theContent1 = re1.substituteAll(theContentRaw, "BREAKHERE");
+ String theDescription1 = re1.substituteAll(theDescriptionRaw, "BREAKHERE");
+
+ RE re2 = new RE("\r?\n");
+ String theContent2 = re2.substituteAll(theContent1, " ");
+ String theDescription2 = re2.substituteAll(theDescription1, " ");
+
+ RE re3 = new RE("BREAKHERE");
+ theContent = " " + re3.substituteAll(theContent2, "\n ");
+ theDescription = re3.substituteAll(theDescription2, "\n ");
+
+ }
+ catch (REException ree) {
+ logger.error(ree.getMessage());
+ }