ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
32 
33  $lng = $DIC['lng'];
34  $ilCtrl = $DIC['ilCtrl'];
35 
36  $this->ref_id = $a_ref_id;
37  $this->lng = $lng;
38 
39  $this->ctrl = $ilCtrl;
40 
41 
42  include_once './Services/Object/classes/class.ilObjectFactory.php';
43  $factory = new ilObjectFactory();
44  $this->object = $factory->getInstanceByRefId($this->getRefId(), false);
45 
46  $this->parent_obj = $a_parent_obj;
47  $this->parent_cmd = $a_parent_cmd;
48  }
49 
55  public static function getSearchBlockHTML($a_title)
56  {
57  include_once './Services/Search/classes/class.ilRepositoryObjectSearchBlockGUI.php';
58  $block = new ilRepositoryObjectSearchBlockGUI($a_title);
59  return $block->getHTML();
60  }
61 
65  public function executeCommand()
66  {
67  if (!$GLOBALS['DIC']['ilAccess']->checkAccess('read', '', $this->getObject()->getRefId())) {
68  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
69  $this->getCtrl()->returnToParent($this->getParentGUI());
70  }
71 
72  $next_class = $this->getCtrl()->getNextClass();
73  $cmd = $this->getCtrl()->getCmd();
74 
75 
76  switch ($next_class) {
77  default:
78  $this->$cmd();
79  break;
80  }
81  }
82 
87  public function getLang()
88  {
89  return $this->lng;
90  }
91 
96  public function getCtrl()
97  {
98  return $this->ctrl;
99  }
100 
101 
102  public function getRefId()
103  {
104  return $this->ref_id;
105  }
106 
111  public function getObject()
112  {
113  return $this->object;
114  }
115 
119  public function getParentGUI()
120  {
121  return $this->parent_obj;
122  }
123 
127  public function getParentCmd()
128  {
129  return $this->parent_cmd;
130  }
131 
135  protected function performSearch()
136  {
137  include_once './Services/Search/classes/class.ilRepositoryObjectDetailSearch.php';
138 
139  try {
141  $search->setQueryString(ilUtil::stripSlashes($_POST['search_term']));
142  $result = $search->performSearch();
143  } catch (Exception $e) {
144  ilUtil::sendFailure($e->getMessage(), true);
145  $this->getCtrl()->returnToParent($this);
146  return false;
147  }
148  // @todo: add a factory to allow overwriting of search result presentation
149  $result_table = $this->getResultTableInstance();
150  $result_table->setSearchTerm(ilUtil::stripSlashes($_POST['search_term']));
151  $result_table->setResults($result);
152 
153  $result_table->init();
154  $result_table->parse();
155 
156  $GLOBALS['DIC']['tpl']->setContent($result_table->getHTML());
157  }
158 
164  public function getResultTableInstance()
165  {
166  global $DIC;
167 
168  $objDefinition = $DIC['objDefinition'];
169 
170 
171  $class = $objDefinition->getClassName($this->getObject()->getType());
172  $location = $objDefinition->getLocation($this->getObject()->getType());
173  $full_class = "ilObj" . $class . "SearchResultTableGUI";
174 
175  if (include_once($location . "/class." . $full_class . ".php")) {
176  return new $full_class(
177  $this,
178  'performSearch',
179  $this->getRefId()
180  );
181  }
182  }
183 }
Class ilObjectFactory.
$result
global $DIC
Definition: saml.php:7
$location
Definition: buildRTE.php:44
$factory
Definition: metadata.php:43
__construct($a_ref_id, $a_parent_obj, $a_parent_cmd)
Constructor.
global $ilCtrl
Definition: ilias.php:18
performSearch()
Perform search lucene or direct search.
static _lookupObjId($a_id)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getResultTableInstance()
Get result table instance type $objDefinition.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getSearchBlockHTML($a_title)
Get standar search block html.
$_POST["username"]
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.