• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Search/classes/class.ilSearchResultPresentationGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once('classes/class.ilLink.php');
00025 
00037 class ilSearchResultPresentationGUI
00038 {
00039         protected $search_cache = null;
00040 
00041         var $tpl;
00042         var $lng;
00043 
00044         var $result = 0;
00045 
00046         function ilSearchResultPresentationGUI(&$result)
00047         {
00048                 global $tpl,$lng,$ilCtrl,$ilUser;
00049 
00050                 $this->lng =& $lng;
00051                 
00052                 $this->result =& $result;
00053 
00054                 $this->type_ordering = array(
00055                         "cat", "crs", "grp", "chat", "frm", "lres",
00056                         "glo", "webr", "file",'mcst', "exc",
00057                         "tst", "svy", "mep", "qpl", "spl");
00058 
00059                 $this->ctrl =& $ilCtrl;
00060                 
00061                 include_once('Services/Search/classes/class.ilUserSearchCache.php');
00062                 $this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
00063         }
00064 
00065         function &showResults()
00066         {
00067                 // Get results
00068                 $results = $this->result->getResultsForPresentation();
00069 
00070                 return $html =& $this->renderItemList($results);
00071 
00072 
00073         }
00074 
00075         function &renderItemList(&$results)
00076         {
00077                 global $objDefinition;
00078 
00079                 $html = '';
00080 
00081                 $cur_obj_type = "";
00082                 $tpl =& $this->newBlockTemplate();
00083                 $first = true;
00084                 
00085                 foreach($this->type_ordering as $act_type)
00086                 {
00087                         $item_html = array();
00088 
00089                         if (is_array($results[$act_type]))
00090                         {
00091                                 foreach($results[$act_type] as $key => $item)
00092                                 {
00093                                         // get list gui class for each object type
00094                                         if ($cur_obj_type != $item["type"])
00095                                         {
00096                                                 include_once 'Services/Search/classes/class.ilSearchObjectListFactory.php';
00097 
00098                                                 $item_list_gui = ilSearchObjectListFactory::_getInstance($item['type']);
00099                                         }
00100                                         $html = $item_list_gui->getListItemHTML(
00101                                                 $item["ref_id"],
00102                                                 $item["obj_id"], 
00103                                                 $item["title"], 
00104                                                 $item["description"]);
00105 
00106                                         if($html)
00107                                         {
00108                                                 $html = $this->__appendChildLinks($html,$item,$item_list_gui);
00109                                                 $item_html[$item["ref_id"]] = $html;
00110                                         }
00111                                 }
00112                                 // output block for resource type
00113                                 if(count($item_html) > 0)
00114                                 {
00115                                         // separator row
00116                                         if (!$first)
00117                                         {
00118                                                 $this->addSeparatorRow($tpl);
00119                                         }
00120                                         $first = false;
00121                                                 
00122                                         // add a header for each resource type
00123                                         $this->addHeaderRow($tpl, $act_type);
00124                                         $this->resetRowType();
00125                                                 
00126                                         // content row
00127                                         foreach($item_html as $ref_id => $html)
00128                                         {
00129                                                 $this->addStandardRow($tpl, $html, $ref_id);
00130                                         }
00131                                 }
00132                         }
00133                 }
00134 
00135                 
00136                 return $tpl->get();
00137         }
00138 
00146         function addHeaderRow(&$a_tpl, $a_type)
00147         {
00148                 if ($a_type != "lres")
00149                 {
00150                         $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
00151                         $title = $this->lng->txt("objs_".$a_type);
00152                 }
00153                 else
00154                 {
00155                         $icon = ilUtil::getImagePath("icon_lm.gif");
00156                         $title = $this->lng->txt("learning_resources");
00157                 }
00158 
00159                 $a_tpl->setCurrentBlock("container_header_row_image");
00160                 $a_tpl->setVariable("HEADER_IMG", $icon);
00161                 $a_tpl->setVariable("HEADER_ALT", $title);
00162                 $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
00163                 $a_tpl->parseCurrentBlock();
00164 
00165 
00166                 #$a_tpl->setCurrentBlock("container_header_row");
00167                 #$a_tpl->parseCurrentBlock();
00168                 #$a_tpl->touchBlock("container_row");
00169         }
00170 
00171         function resetRowType()
00172         {
00173                 $this->cur_row_type = "";
00174         }
00175 
00183         function addStandardRow(&$a_tpl, $a_html,$a_ref_id)
00184         {
00185                 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
00186                         ? "row_type_2"
00187                         : "row_type_1";
00188 
00189                 $a_tpl->touchBlock($this->cur_row_type);
00190                 $a_tpl->setCurrentBlock("container_standard_row");
00191                 $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
00192                 
00193                 // add checkbox for saving results
00194                 $a_tpl->setVariable("BLOCK_ROW_CHECK",ilUtil::formCheckbox(0,'result[]',$a_ref_id));
00195                 $a_tpl->setVariable("ITEM_ID",$a_ref_id);
00196                 $a_tpl->parseCurrentBlock();
00197                 $a_tpl->touchBlock("container_row");
00198         }
00199 
00206         function &newBlockTemplate()
00207         {
00208                 $tpl =& new ilTemplate ("tpl.container_list_block.html",true, true);
00209                 $this->cur_row_type = "row_type_1";
00210 
00211                 return $tpl;
00212         }
00213 
00214         function addSeparatorRow(&$a_tpl)
00215         {
00216                 $a_tpl->touchBlock("separator_row");
00217                 $a_tpl->touchBlock("container_row");
00218         }
00219 
00220         function __appendChildLinks($html,$item,&$item_list_gui)
00221         {
00222                 if(!count($item['child']))
00223                 {
00224                         return $html;
00225                 }
00226                 $tpl = new ilTemplate('tpl.detail_links.html',true,true,'Services/Search');
00227                 $tpl->setVariable("HITS",$this->lng->txt('search_hits'));
00228                 
00229                 switch($item['type'])
00230                 {
00231                         case 'lm':
00232                                 include_once 'Modules/LearningModule/classes/class.ilLMObject.php';
00233                                 foreach($item['child'] as $child)
00234                                 {
00235                                         $tpl->setCurrentBlock("link_row");
00236                                         
00237                                         switch(ilLMObject::_lookupType($child))
00238                                         {
00239                                                 case 'pg':
00240                                                         $tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('obj_pg'));
00241                                                         break;
00242                                                 case 'st':
00243                                                         $tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('obj_st'));
00244                                                         break;
00245                                         }
00246                                         $item_list_gui->setChildId($child);
00247                                         $tpl->setVariable("SEPERATOR",' -> ');
00248                                         $tpl->setVariable("LINK",$item_list_gui->getCommandLink('page'));
00249                                         $tpl->setVariable("TARGET",$item_list_gui->getCommandFrame('page'));
00250                                         $tpl->setVariable("TITLE",ilLMObject::_lookupTitle($child));
00251                                         $tpl->parseCurrentBlock();
00252                                 }
00253                                 break;
00254 
00255                         case 'frm':
00256                                 include_once './Modules/Forum/classes/class.ilObjForum.php';
00257                                 
00258                                 foreach($item['child'] as $child)
00259                                 {
00260                                         $thread_post = explode('_',$child);
00261 
00262                                         $tpl->setCurrentBlock("link_row");
00263                                         $tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('thread'));
00264 
00265                                         $item_list_gui->setChildId($thread_post);
00266                                         $tpl->setVariable("SEPERATOR",': ');
00267                                         $tpl->setVariable("LINK",$item_list_gui->getCommandLink('posting'));
00268                                         $tpl->setVariable("TARGET",$item_list_gui->getCommandFrame(''));
00269                                         $tpl->setVariable("TITLE",ilObjForum::_lookupThreadSubject($thread_post[0]));
00270                                         $tpl->parseCurrentBlock();
00271                                 }
00272                                 break;
00273                                 
00274                         case 'glo':
00275                                 include_once './Modules/Glossary/classes/class.ilGlossaryTerm.php';
00276 
00277                                 $this->lng->loadLanguageModule('content');
00278                                 foreach($item['child'] as $child)
00279                                 {
00280                                         $tpl->setCurrentBlock("link_row");
00281                                         $tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('cont_term'));
00282                                         $tpl->setVariable("SEPERATOR",': ');
00283                                         $tpl->setVariable("LINK",ilLink::_getLink($item['ref_id'],'git',array('target' => 'git_'.$child.'_'.$item['ref_id'])));
00284                                         $tpl->setVariable("TITLE",ilGlossaryTerm::_lookGlossaryTerm($child));
00285                                         $tpl->parseCurrentBlock();
00286                                 }
00287                                 break;
00288 
00289                         case 'mcst':
00290                                 include_once("./Services/News/classes/class.ilNewsItem.php");
00291                         
00292                                 foreach($item['child'] as $child)
00293                                 {
00294                                         $tpl->setCurrentBlock("link_row");
00295                                         //$tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('item'));
00296 
00297                                         $item_list_gui->setChildId($child);
00298                                         //$tpl->setVariable("SEPERATOR",': ');
00299                                         $tpl->setVariable("LINK", $item_list_gui->getCommandLink('listItems'));
00300                                         $tpl->setVariable("TARGET", $item_list_gui->getCommandFrame(''));
00301                                         $tpl->setVariable("TITLE", ilNewsItem::_lookupTitle($child));
00302                                         $tpl->parseCurrentBlock();
00303                                 }
00304                                 break;
00305 
00306                         default:
00307                                 ;
00308                 }
00309                 return $html . $tpl->get();
00310         }
00311         
00312 
00313 }
00314 
00315 ?>

Generated on Fri Dec 13 2013 17:57:01 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1