00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00036 class ilSearchResultPresentationGUI
00037 {
00038 var $tpl;
00039 var $lng;
00040
00041 var $result = 0;
00042
00043 function ilSearchResultPresentationGUI(&$result)
00044 {
00045 global $tpl,$lng,$ilCtrl;
00046
00047 $this->lng =& $lng;
00048
00049 $this->result =& $result;
00050
00051 $this->type_ordering = array(
00052 "cat", "crs", "grp", "chat", "frm", "lres",
00053 "glo", "webr", "file", "exc",
00054 "tst", "svy", "mep", "qpl", "spl");
00055
00056 $this->ctrl =& $ilCtrl;
00057 }
00058
00059 function &showResults()
00060 {
00061
00062 $results = $this->result->getResultsForPresentation();
00063
00064 return $html =& $this->renderItemList($results);
00065
00066
00067 }
00068
00069 function &renderItemList(&$results)
00070 {
00071 global $objDefinition;
00072
00073 $html = '';
00074
00075 $cur_obj_type = "";
00076 $tpl =& $this->newBlockTemplate();
00077 $first = true;
00078
00079 foreach($this->type_ordering as $act_type)
00080 {
00081 $item_html = array();
00082
00083 if (is_array($results[$act_type]))
00084 {
00085 foreach($results[$act_type] as $key => $item)
00086 {
00087
00088 if ($cur_obj_type != $item["type"])
00089 {
00090 include_once 'Services/Search/classes/class.ilSearchObjectListFactory.php';
00091
00092 $item_list_gui = ilSearchObjectListFactory::_getInstance($item['type']);
00093 }
00094 $html = $item_list_gui->getListItemHTML(
00095 $item["ref_id"],
00096 $item["obj_id"],
00097 $item["title"],
00098 $item["description"]);
00099
00100 if($html)
00101 {
00102 $html = $this->__appendChildLinks($html,$item,$item_list_gui);
00103 $item_html[$item["ref_id"]] = $html;
00104 }
00105 }
00106
00107 if(count($item_html) > 0)
00108 {
00109
00110 if (!$first)
00111 {
00112 $this->addSeparatorRow($tpl);
00113 }
00114 $first = false;
00115
00116
00117 $this->addHeaderRow($tpl, $act_type);
00118 $this->resetRowType();
00119
00120
00121 foreach($item_html as $ref_id => $html)
00122 {
00123 $this->addStandardRow($tpl, $html, $ref_id);
00124 }
00125 }
00126 }
00127 }
00128
00129
00130 return $tpl->get();
00131 }
00132
00140 function addHeaderRow(&$a_tpl, $a_type)
00141 {
00142 if ($a_type != "lres")
00143 {
00144 $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
00145 $title = $this->lng->txt("objs_".$a_type);
00146 }
00147 else
00148 {
00149 $icon = ilUtil::getImagePath("icon_lm.gif");
00150 $title = $this->lng->txt("learning_resources");
00151 }
00152
00153 $a_tpl->setCurrentBlock("container_header_row_image");
00154 $a_tpl->setVariable("HEADER_IMG", $icon);
00155 $a_tpl->setVariable("HEADER_ALT", $title);
00156 $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
00157 $a_tpl->parseCurrentBlock();
00158
00159
00160 #$a_tpl->setCurrentBlock("container_header_row");
00161 #$a_tpl->parseCurrentBlock();
00162 #$a_tpl->touchBlock("container_row");
00163 }
00164
00165 function resetRowType()
00166 {
00167 $this->cur_row_type = "";
00168 }
00169
00177 function addStandardRow(&$a_tpl, $a_html,$a_ref_id)
00178 {
00179 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
00180 ? "row_type_2"
00181 : "row_type_1";
00182
00183 $a_tpl->touchBlock($this->cur_row_type);
00184 $a_tpl->setCurrentBlock("container_standard_row");
00185 $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
00186
00187
00188 $a_tpl->setVariable("BLOCK_ROW_CHECK",ilUtil::formCheckbox(0,'result[]',$a_ref_id));
00189 $a_tpl->setVariable("ITEM_ID",$a_ref_id);
00190 $a_tpl->parseCurrentBlock();
00191 $a_tpl->touchBlock("container_row");
00192 }
00193
00200 function &newBlockTemplate()
00201 {
00202 $tpl =& new ilTemplate ("tpl.container_list_block.html",true, true);
00203 $this->cur_row_type = "row_type_1";
00204
00205 return $tpl;
00206 }
00207
00208 function addSeparatorRow(&$a_tpl)
00209 {
00210 $a_tpl->touchBlock("separator_row");
00211 $a_tpl->touchBlock("container_row");
00212 }
00213
00214 function __appendChildLinks($html,$item,&$item_list_gui)
00215 {
00216 if(!count($item['child']))
00217 {
00218 return $html;
00219 }
00220 $tpl = new ilTemplate('tpl.detail_links.html',true,true,'Services/Search');
00221 $tpl->setVariable("HITS",$this->lng->txt('search_hits'));
00222
00223 switch($item['type'])
00224 {
00225 case 'lm':
00226 include_once 'content/classes/class.ilLMObject.php';
00227 foreach($item['child'] as $child)
00228 {
00229 $tpl->setCurrentBlock("link_row");
00230
00231 switch(ilLMObject::_lookupType($child))
00232 {
00233 case 'pg':
00234 $tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('obj_pg'));
00235 break;
00236 case 'st':
00237 $tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('obj_st'));
00238 break;
00239 }
00240 $item_list_gui->setChildId($child);
00241 $tpl->setVariable("SEPERATOR",' -> ');
00242 $tpl->setVariable("LINK",$item_list_gui->getCommandLink('page'));
00243 $tpl->setVariable("TARGET",$item_list_gui->getCommandFrame('page'));
00244 $tpl->setVariable("TITLE",ilLMObject::_lookupTitle($child));
00245 $tpl->parseCurrentBlock();
00246 }
00247 break;
00248
00249 case 'frm':
00250 include_once 'classes/class.ilObjForum.php';
00251
00252 foreach($item['child'] as $child)
00253 {
00254 $thread_post = explode('_',$child);
00255
00256 $tpl->setCurrentBlock("link_row");
00257 $tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('thread'));
00258
00259 $item_list_gui->setChildId($thread_post);
00260 $tpl->setVariable("SEPERATOR",': ');
00261 $tpl->setVariable("LINK",$item_list_gui->getCommandLink('posting'));
00262 $tpl->setVariable("TARGET",$item_list_gui->getCommandFrame(''));
00263 $tpl->setVariable("TITLE",ilObjForum::_lookupThreadSubject($thread_post[0]));
00264 $tpl->parseCurrentBlock();
00265 }
00266
00267 break;
00268
00269 default:
00270 ;
00271 }
00272 return $html . $tpl->get();
00273 }
00274
00275 }
00276
00277 ?>