Changeset 19312 for gsdl/trunk
- Timestamp:
- 2009-05-03T16:53:02+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/runtime-src/src/recpt/formattools.cpp
r19311 r19312 875 875 876 876 877 static text_t spanwrap_metatext(const text_t& metatext, const text_t& OID, 878 const text_t metaname, int metapos=-1) 879 { 880 881 text_t tag_type = (metaname == "Text") ? "div" : "span"; 882 text_t editable_type = (metaname == "Text") ? "text" : "metadata"; 883 884 text_t wrapped_metatext = "<" + tag_type + " "; 885 wrapped_metatext += "class=\"editable-" + editable_type + "\" "; 886 887 wrapped_metatext += "docoid=\"" + OID + "\" "; 888 wrapped_metatext += "metaname=\"" + metaname + "\""; 889 890 if (metapos>=0) { 891 text_t metapos_str = metapos; 892 wrapped_metatext += " metapos=\"" + metapos_str + "\""; 893 } 894 895 wrapped_metatext += ">" + metatext + "</" + tag_type + ">"; 896 897 return wrapped_metatext; 898 } 899 900 901 877 902 bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr, 878 903 text_tset &metadata, bool &getParents) { … … 886 911 // position -1 for all, -2 for the last, 0 for the first, or x for a particular piece 887 912 // metainfo has all the values for the metadata, meta has the request metadata name and options, position tells which values to get 888 static text_t get_formatted_meta_text(MetadataInfo_t &metainfo, const metadata_t &meta, int position, bool no_cgisafe = false) 913 914 static text_t get_formatted_meta_text(const text_t& OID, MetadataInfo_t &metainfo, const metadata_t &meta, int position, bool no_cgisafe = false) 889 915 { 890 916 text_t no_ns_metaname = remove_namespace(meta.metaname); … … 910 936 911 937 if (metadata_spanwrap) { 912 fresh_metatext = "<span class=\"editable-metadata\" metaname=\"" + meta.metaname + "\" metapos=\"" + i + "\">" + fresh_metatext + "</span>";938 fresh_metatext = spanwrap_metatext(fresh_metatext,OID,meta.metaname,i); 913 939 } 914 940 formatted_metatext += fresh_metatext; … … 935 961 936 962 if (metadata_spanwrap) { 937 fresh_metatext = "<span class=\"editable-metadata\" metaname=\"" + meta.metaname + "\" metapos=\"" + position + "\">" + fresh_metatext + "</span>";963 fresh_metatext = spanwrap_metatext(fresh_metatext,OID,meta.metaname,position); 938 964 } 939 965 … … 949 975 950 976 MetadataInfo_t *parent = docinfo.metadata[meta.metaname].parent; 977 951 978 switch (meta.mqualifier.parent) { 952 979 case pNone: … … 956 983 case pImmediate: 957 984 if (parent != NULL) { 958 return get_formatted_meta_text(*parent, meta, siblings_values); 985 text_t parent_oid = get_parent(docinfo.OID); 986 return get_formatted_meta_text(parent_oid,*parent, meta, siblings_values); 959 987 } 960 988 break; … … 962 990 case pTop: 963 991 if (parent != NULL) { 964 while (parent->parent != NULL) parent = parent->parent; 965 return get_formatted_meta_text(*parent, meta, siblings_values); 992 text_t parent_oid = get_parent(docinfo.OID); 993 994 while (parent->parent != NULL) { 995 parent = parent->parent; 996 parent_oid = get_parent(parent_oid); 997 } 998 return get_formatted_meta_text(parent_oid,*parent, meta, siblings_values); 966 999 } 967 1000 break; … … 970 1003 MetadataInfo_t *parent = docinfo.metadata[meta.metaname].parent; 971 1004 if (parent != NULL) { 1005 text_t parent_oid = get_parent(docinfo.OID); 1006 972 1007 text_tarray tmparray; 973 1008 while (parent != NULL) { 974 tmparray.push_back (get_formatted_meta_text( *parent, meta, siblings_values, true)); // set no_cgisafe to true, as we'll do it once we have all the metadata1009 tmparray.push_back (get_formatted_meta_text(parent_oid,*parent, meta, siblings_values, true)); // set no_cgisafe to true, as we'll do it once we have all the metadata 975 1010 parent = parent->parent; 1011 parent_oid = get_parent(parent_oid); 1012 976 1013 } 977 1014 // now join them up - use teh parent separator … … 1021 1058 MetadataInfo_t& metaname_rec = child_docinfo.metadata[child_metaname]; 1022 1059 1023 text_t child_metavalue = get_formatted_meta_text(metaname_rec,meta,siblings_values); 1060 text_t child_metavalue 1061 = get_formatted_meta_text(child_docinfo.OID,metaname_rec,meta,siblings_values); 1024 1062 return expand_metadata(child_metavalue,collection,collectproto, 1025 1063 child_docinfo,disp,options,logout); … … 1073 1111 MetadataInfo_t& metaname_rec = child_docinfo.metadata[child_metaname]; 1074 1112 1075 text_t child_metavalue = get_formatted_meta_text(metaname_rec,meta,siblings_values); 1113 text_t child_metavalue 1114 = get_formatted_meta_text(child_docinfo.OID,metaname_rec,meta,siblings_values); 1076 1115 if (!first) result += child_field; 1077 1116 first = false; … … 1111 1150 else if (meta.metacommand & mSibling) { // only siblings 1112 1151 MetadataInfo_t& metaname_rec = docinfo.metadata[meta.metaname]; 1113 return get_formatted_meta_text(docinfo. metadata[meta.metaname],meta, siblings_values);1152 return get_formatted_meta_text(docinfo.OID,docinfo.metadata[meta.metaname],meta, siblings_values); 1114 1153 } 1115 1154 else { … … 1120 1159 int metaname_index 1121 1160 = (classifier_metaname == meta.metaname) ? docinfo.classifier_metadata_offset : 0; 1122 return get_formatted_meta_text(docinfo. metadata[meta.metaname], meta, metaname_index);1161 return get_formatted_meta_text(docinfo.OID,docinfo.metadata[meta.metaname], meta, metaname_index); 1123 1162 } 1124 1163 … … 1591 1630 1592 1631 case comSummary: 1593 { 1594 text_t summary = format_summary(collection, collectproto, docinfo, disp, options, logout); 1595 if (metadata_spanwrap) { 1596 summary = "<span class=\"editable-metadata\" metaname=\"Summary\">"+summary+"</span>"; 1597 } 1598 return summary; 1599 } 1632 return format_summary(collection, collectproto, docinfo, disp, options, logout); 1600 1633 1601 1634 case comMeta: … … 1689 1722 1690 1723 if (metadata_spanwrap) { 1691 text = "<div class=\"editable-text\" metaname=\"Text\">"+text+"</div>";1724 text = spanwrap_metatext(text,docinfo.OID,"Text"); 1692 1725 } 1693 1726 … … 1707 1740 // the text of the document, processed via the methods in 1708 1741 // summarise.cpp 1742 1743 text_t summary; 1744 1709 1745 if (docinfo.metadata.count("Summary") > 0 && 1710 1746 docinfo.metadata["Summary"].values.size() > 0) { 1711 return docinfo.metadata["Summary"].values[0]; 1712 } 1713 1714 text_t textToSummarise, query; 1715 if(options["text"].empty()) { // get document text 1716 DocumentRequest_t docrequest; 1717 DocumentResponse_t docresponse; 1718 comerror_t err; 1719 docrequest.OID = docinfo.OID; 1720 collectproto->get_document (collection, docrequest, docresponse, err, logout); 1721 textToSummarise = docresponse.doc; 1722 } 1747 summary = docinfo.metadata["Summary"].values[0]; 1748 } 1723 1749 else { 1724 // in practice, this would not happen, because text is only 1725 // loaded with the [Text] command 1750 1751 text_t textToSummarise, query; 1752 1753 if(options["text"].empty()) { // get document text 1754 DocumentRequest_t docrequest; 1755 DocumentResponse_t docresponse; 1756 comerror_t err; 1757 docrequest.OID = docinfo.OID; 1758 collectproto->get_document (collection, docrequest, docresponse, err, logout); 1759 textToSummarise = docresponse.doc; 1760 } 1761 else { 1762 // in practice, this would not happen, because text is only 1763 // loaded with the [Text] command 1726 1764 textToSummarise = options["text"]; 1727 } 1728 1729 disp.expandstring("_cgiargq_",query); 1730 return summarise(textToSummarise,query,80); 1731 } 1765 } 1766 1767 disp.expandstring("_cgiargq_",query); 1768 summary = summarise(textToSummarise,query,80); 1769 } 1770 1771 if (metadata_spanwrap) { 1772 summary = spanwrap_metatext(summary,docinfo.OID,"Summary"); 1773 } 1774 1775 return summary; 1776 }
Note:
See TracChangeset
for help on using the changeset viewer.