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_b.gif");
00150 $title = $this->lng->txt("learning_resources");
00151 }
00152 $a_tpl->setCurrentBlock("container_header_row");
00153 $a_tpl->setVariable("HEADER_IMG", $icon);
00154 $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
00155 $a_tpl->parseCurrentBlock();
00156 $a_tpl->touchBlock("container_row");
00157 }
00158
00159 function resetRowType()
00160 {
00161 $this->cur_row_type = "";
00162 }
00163
00171 function addStandardRow(&$a_tpl, $a_html,$a_ref_id)
00172 {
00173 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
00174 ? "row_type_2"
00175 : "row_type_1";
00176
00177 $a_tpl->touchBlock($this->cur_row_type);
00178 $a_tpl->setCurrentBlock("container_standard_row");
00179 $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
00180
00181
00182 $a_tpl->setVariable("BLOCK_ROW_CHECK",ilUtil::formCheckbox(0,'result[]',$a_ref_id));
00183 $a_tpl->setVariable("ITEM_ID",$a_ref_id);
00184 $a_tpl->parseCurrentBlock();
00185 $a_tpl->touchBlock("container_row");
00186 }
00187
00194 function &newBlockTemplate()
00195 {
00196 $tpl =& new ilTemplate ("tpl.container_list_block.html",true, true);
00197 $this->cur_row_type = "row_type_1";
00198
00199 return $tpl;
00200 }
00201
00202 function addSeparatorRow(&$a_tpl)
00203 {
00204 $a_tpl->touchBlock("separator_row");
00205 $a_tpl->touchBlock("container_row");
00206 }
00207
00208 function __appendChildLinks($html,$item,&$item_list_gui)
00209 {
00210 if(!count($item['child']) or $item['type'] != 'lm')
00211 {
00212 return $html;
00213 }
00214 include_once 'content/classes/class.ilLMObject.php';
00215
00216 $tpl = new ilTemplate('tpl.detail_links.html',true,true,'Services/Search');
00217
00218 $tpl->setVariable("HITS",$this->lng->txt('search_hits'));
00219 foreach($item['child'] as $child)
00220 {
00221 $tpl->setCurrentBlock("link_row");
00222
00223 switch(ilLMObject::_lookupType($child))
00224 {
00225 case 'pg':
00226 $tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('obj_pg'));
00227 break;
00228 case 'st':
00229 $tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('obj_st'));
00230 break;
00231 }
00232 $item_list_gui->setChildId($child);
00233 $tpl->setVariable("LINK",$item_list_gui->getCommandLink('list'));
00234 $tpl->setVariable("TARGET",$item_list_gui->getCommandFrame('list'));
00235 $tpl->setVariable("TITLE",ilLMObject::_lookupTitle($child));
00236 $tpl->parseCurrentBlock();
00237 }
00238 return $html . $tpl->get();
00239 }
00240
00241 }
00242
00243 ?>