ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilRepositoryObjectSearchGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
16{
17 private $lng = null;
18 private $ctrl = null;
19 private $ref_id = 0;
20 private $object = null;
21 private $parent_obj;
22 private $parent_cmd;
23
24
25
29 public function __construct($a_ref_id, $a_parent_obj, $a_parent_cmd)
30 {
31 global $lng, $ilCtrl;
32
33 $this->ref_id = $a_ref_id;
34 $this->lng = $lng;
35
36 $this->ctrl = $ilCtrl;
37
38
39 include_once './Services/Object/classes/class.ilObjectFactory.php';
41 $this->object = $factory->getInstanceByRefId($this->getRefId(), false);
42
43 $this->parent_obj = $a_parent_obj;
44 $this->parent_cmd = $a_parent_cmd;
45 }
46
52 public static function getSearchBlockHTML($a_title)
53 {
54 include_once './Services/Search/classes/class.ilRepositoryObjectSearchBlockGUI.php';
55 $block = new ilRepositoryObjectSearchBlockGUI($a_title);
56 return $block->getHTML();
57 }
58
62 public function executeCommand()
63 {
64 if (!$GLOBALS['ilAccess']->checkAccess('read', '', $this->getObject()->getRefId())) {
65 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
66 $this->getCtrl()->returnToParent($this->getParentGUI());
67 }
68
69 $next_class = $this->getCtrl()->getNextClass();
70 $cmd = $this->getCtrl()->getCmd();
71
72
73 switch ($next_class) {
74 default:
75 $this->$cmd();
76 break;
77 }
78 }
79
84 public function getLang()
85 {
86 return $this->lng;
87 }
88
93 public function getCtrl()
94 {
95 return $this->ctrl;
96 }
97
98
99 public function getRefId()
100 {
101 return $this->ref_id;
102 }
103
108 public function getObject()
109 {
110 return $this->object;
111 }
112
116 public function getParentGUI()
117 {
118 return $this->parent_obj;
119 }
120
124 public function getParentCmd()
125 {
126 return $this->parent_cmd;
127 }
128
132 protected function performSearch()
133 {
134 include_once './Services/Search/classes/class.ilRepositoryObjectDetailSearch.php';
135
136 try {
138 $search->setQueryString(ilUtil::stripSlashes($_POST['search_term']));
139 $result = $search->performSearch();
140 } catch (Exception $e) {
141 ilUtil::sendFailure($e->getMessage(), true);
142 $this->getCtrl()->returnToParent($this);
143 return false;
144 }
145 // @todo: add a factory to allow overwriting of search result presentation
146 $result_table = $this->getResultTableInstance();
147 $result_table->setSearchTerm(ilUtil::stripSlashes($_POST['search_term']));
148 $result_table->setResults($result);
149
150 $result_table->init();
151 $result_table->parse();
152
153 $GLOBALS['tpl']->setContent($result_table->getHTML());
154 }
155
161 public function getResultTableInstance()
162 {
163 global $objDefinition;
164
165
166 $class = $objDefinition->getClassName($this->getObject()->getType());
167 $location = $objDefinition->getLocation($this->getObject()->getType());
168 $full_class = "ilObj" . $class . "SearchResultTableGUI";
169
170 if (include_once($location . "/class." . $full_class . ".php")) {
171 return new $full_class(
172 $this,
173 'performSearch',
174 $this->getRefId()
175 );
176 }
177 }
178}
$result
$factory
Definition: metadata.php:47
$location
Definition: buildRTE.php:44
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Class ilObjectFactory.
static _lookupObjId($a_id)
static getSearchBlockHTML($a_title)
Get standar search block html.
performSearch()
Perform search lucene or direct search.
__construct($a_ref_id, $a_parent_obj, $a_parent_cmd)
Constructor.
getResultTableInstance()
Get result table instance @global type $objDefinition.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18