00001 #include "page_control.hpp" 00002 /* 00003 00004 Search Control: 00005 ============= 00006 control tags 00007 00008 search_form - a template section for the search 00009 ----------- 00010 attr: 00011 ----- 00012 item := the template section 00013 00014 The form must reflect back to the current page and have a search input named 'q' 00015 form will have replacement $q$ to re-display last search value 00016 00017 results - a template section for listing results of the search 00018 ------ 00019 attr: 00020 ----- 00021 item := the template section 00022 no_results := section to show if no results encountered 00023 words := number of words for summary 00024 -------- 00025 results will have replacements on 00026 00027 $title$ - the page title 00028 $location$ - the page url 00029 $content$ - a sample of the page content as summary, posssibly around find 00030 00031 */ 00032 00033 00034 class form_functor: public base_functor 00035 { 00036 cgiScript & script; 00037 public: 00038 00039 form_functor(page & ipg,cgiScript & script):base_functor(ipg),script(script){;} 00040 virtual ~form_functor(){;} 00041 00042 virtual bool operator()( xmlNode & node ) 00043 { 00044 bool bRet = false; 00045 string item; 00046 00047 node_attr::iterator x = node.attr.find("item"); // detail for what slide? 00048 if( x!=node.attr.end() ) item = x->second; 00049 x = node.attr.find("item"); // new default suppresses show on admin pane 00050 if( x!=node.attr.end() ) 00051 { 00052 item=x->second; 00053 ocString frm = pg.paragraph_string( item ); 00054 // get the last search for replacement of 00055 script << pg.paragraph_string( item ); 00056 } 00057 else 00058 { 00059 script << "no content items" << endl; 00060 } 00061 00062 return bRet; 00063 } 00064 }; 00065 00066 00067 class results_functor: public base_functor 00068 { 00069 cgiScript & script; 00070 public: 00071 results_functor(page & ipg,cgiScript & script):base_functor(ipg),script(script){;} 00072 virtual ~results_functor(){;} 00073 00074 show_page & showpg(void) { return dynamic_cast<show_page &>(this->pg); } 00075 00076 bool shouldShow(xmlNode & node ) 00077 { 00078 bool ret=true; // assume we should 00079 if( isMutex(node) ) 00080 { 00081 if( script.ClientArguments().count("s") ) 00082 ret=false; // since we're mutually exclusive, and we have a detail, don't show 00083 } 00084 return ret; 00085 } 00086 00087 virtual bool operator()( xmlNode & node ) 00088 { 00089 bool bRet = false; 00090 00091 if( shouldShow( node ) ) 00092 { 00093 00094 string items, replace_tag; 00095 node_attr::iterator x = node.attr.find("items"); 00096 if( x!=node.attr.end() ) 00097 { 00098 00099 items=x->second; 00100 x = node.attr.find("replace_tag"); // preferred 00101 if( x==node.attr.end() ) x = node.attr.find("replace-tag"); // backward compat 00102 if( x!=node.attr.end()) 00103 { 00104 replace_tag=x->second; 00105 bRet = showpg().emitSlides( items, replace_tag ); 00106 } 00107 else 00108 { 00109 cout << "no content replace tag" << endl; 00110 } 00111 } 00112 else 00113 { 00114 cout << "no content items" << endl; 00115 } 00116 } 00117 return bRet; 00118 } 00119 };
1.5.5