Changeset 19312

Show
Ignore:
Timestamp:
03.05.2009 16:53:02 (10 years ago)
Author:
davidb
Message:

DocOID is now stored in the span-wrap tag to help with set-metadata call

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/runtime-src/src/recpt/formattools.cpp

    r19311 r19312  
    875875 
    876876 
     877static 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 
    877902bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr,  
    878903             text_tset &metadata, bool &getParents) { 
     
    886911// position -1 for all, -2 for the last, 0 for the first, or x for a particular piece 
    887912// 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 
     914static text_t get_formatted_meta_text(const text_t& OID, MetadataInfo_t &metainfo, const metadata_t &meta, int position, bool no_cgisafe = false)  
    889915{ 
    890916  text_t no_ns_metaname = remove_namespace(meta.metaname); 
     
    910936 
    911937      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); 
    913939      } 
    914940      formatted_metatext += fresh_metatext; 
     
    935961 
    936962    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); 
    938964    } 
    939965 
     
    949975   
    950976  MetadataInfo_t *parent = docinfo.metadata[meta.metaname].parent; 
     977 
    951978  switch (meta.mqualifier.parent) { 
    952979  case pNone: 
     
    956983  case pImmediate: 
    957984    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); 
    959987    } 
    960988    break; 
     
    962990  case pTop: 
    963991    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); 
    966999    } 
    9671000    break; 
     
    9701003    MetadataInfo_t *parent = docinfo.metadata[meta.metaname].parent; 
    9711004    if (parent != NULL) { 
     1005      text_t parent_oid = get_parent(docinfo.OID); 
     1006 
    9721007      text_tarray tmparray; 
    9731008      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 metadata 
     1009    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 
    9751010    parent = parent->parent; 
     1011    parent_oid = get_parent(parent_oid); 
     1012 
    9761013      } 
    9771014      // now join them up - use teh parent separator 
     
    10211058      MetadataInfo_t& metaname_rec = child_docinfo.metadata[child_metaname]; 
    10221059   
    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); 
    10241062      return expand_metadata(child_metavalue,collection,collectproto, 
    10251063             child_docinfo,disp,options,logout); 
     
    10731111    MetadataInfo_t& metaname_rec = child_docinfo.metadata[child_metaname]; 
    10741112     
    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); 
    10761115    if (!first) result += child_field; 
    10771116    first = false; 
     
    11111150  else if (meta.metacommand & mSibling) { // only siblings 
    11121151    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); 
    11141153  } 
    11151154  else { 
     
    11201159    int metaname_index  
    11211160      = (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); 
    11231162  } 
    11241163   
     
    15911630 
    15921631     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); 
    16001633 
    16011634     case comMeta: 
     
    16891722 
    16901723  if (metadata_spanwrap) { 
    1691     text = "<div class=\"editable-text\" metaname=\"Text\">"+text+"</div>"; 
     1724    text = spanwrap_metatext(text,docinfo.OID,"Text"); 
    16921725  } 
    16931726 
     
    17071740  //      the text of the document, processed via the methods in 
    17081741  //      summarise.cpp 
     1742 
     1743  text_t summary; 
     1744 
    17091745  if (docinfo.metadata.count("Summary") > 0 && 
    17101746      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  } 
    17231749  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 
    17261764    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}