ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilShopGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once 'Services/Payment/classes/class.ilShopBaseGUI.php';
5include_once 'Services/Payment/classes/class.ilPaymentSettings.php';
6include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
7include_once './Services/Payment/classes/class.ilShopRepositoryExplorer.php';
8
9include_once './Services/Payment/classes/class.ilShopSearchResult.php';
10
20{
21 const SHOP_PAGE_EDITOR_PAGE_ID = 99999999;
22
23 private $sort_type_topics = '';
25 private $sort_field = '';
26 private $sort_direction = '';
27 private $string = '';
28 private $type = '';
29 private $topic_id = 0;
30
31 public $settings = null;
32
33 public $cur_ref_id = null;
34
38 protected $ilShopSearchResult = null;
39
40 public function __construct()
41 {
42 parent::__construct();
43
44 global $ilCtrl;
45
46 if(isset($_POST['cmd']) && $_POST['cmd'] == 'setFilter')
47 {
48 $this->cmd = 'setFilter';
49 }
50 else
51 {
52 $this->cmd = $ilCtrl->getCmd();
53 }
54
55 $this->cur_ref_id = (int)$_GET['ref_id'];
56 $this->settings = ilPaymentSettings::_getInstance();
57
59
60 // set filter settings
61 $this->setType($_SESSION['shop_content']['type']);
62 $this->setString($_SESSION['shop_content']['text']);
63 $this->setTopicId($_POST['filter_topic_id']);
64
65 // set sorting
66 $this->setSortingTypeTopics($_SESSION['shop_content']['order_topics_sorting_type']);
67 $this->setSortingDirectionTopics($_SESSION['shop_content']['shop_topics_sorting_direction']);
68 $this->setSortField($_POST['order_field']);
69 $this->setSortDirection($_SESSION['shop_content']['shop_order_direction']);
70 }
71
72 function executeCommand()
73 {
74 $next_class = $this->ctrl->getNextClass($this);
75 if(isset($_GET['ref_id']))
76 {
77 $this->cmd = 'showTree';
78 }
79
80 switch($next_class)
81 {
82 case 'ilshoppagegui':
83 $this->prepareOutput();
84
85 $ret = $this->forwardToPageObject();
86 if($ret != '')
87 {
88 $this->tpl->setContent($ret);
89 }
90 break;
91
92 default:
93 switch($this->cmd)
94 {
95 case 'firstpage':
96 $this->clearFilter();
97
98 if($this->settings->get('use_shop_specials') == true)
99 {
100 //@todo ... continue
102
103 $cmd = 'showSpecialContent';
104 }
105 else
106 {
107 $cmd = 'performSearch';
108 }
109 break;
110 case 'showTree':
111 $obj_type = ilObject::_lookupType(ilObject::_lookupObjId($this->cur_ref_id));
112 $container = array("root", "cat", 'catr', "grp", "crs", 'crsr', 'rcrs');
113
114 if(in_array($obj_type, $container))
115 {
116 //@todo ... continue
118 $cmd = 'showContainerContent';
119 }
120 else
121 {
122 $cmd = 'performSearch';
123 }
124 break;
125 case 'resetFilter':
126 $cmd = 'resetFilter';
127 break;
128 case 'setFilter':
129 $cmd = 'setFilter';
130 break;
131 default:
132 $cmd = 'performSearch';
133 break;
134 }
135
136 $this->prepareOutput();
137 $this->$cmd();
138 break;
139 }
140
141 return true;
142 }
143
144
145 public function showFilters()
146 {
147 $show_general_filter = $this->settings->get('show_general_filter');
148 $show_topics_filter = $this->settings->get('show_topics_filter');
149 $topics_enabled = $this->settings->get('enable_topics');
150 $show_shop_explorer = $this->settings->get('show_shop_explorer');
151
152 if($show_general_filter)
153 {
154 $g_filter_html = $this->showGeneralFilter();
155 $this->tpl->setCurrentBlock('show_general_filter');
156 $this->tpl->setVariable('FORM', $g_filter_html);
157 $this->tpl->parseCurrentBlock();
158 }
159
160 if($show_topics_filter && $topics_enabled)
161 {
162 $this->showTopicsFilter();
163 }
164 if($show_shop_explorer)
165 {
166 $this->showShopExplorer();
167 }
168 }
169
170
171 public function clearFilter()
172 {
173 $this->setString('');
174 $this->setType('');
175 $this->setTopicId(0);
176
177 #return $this->performSearch();
178 }
179
180 public function getPageHTML()
181 {
182 // page object
183 include_once 'Services/Payment/classes/class.ilShopPage.php';
184 include_once 'Services/Payment/classes/class.ilShopPageGUI.php';
185
186 // if page does not exist, return nothing
187 if(!ilShopPage::_exists('shop', self::SHOP_PAGE_EDITOR_PAGE_ID))
188 {
189 return '';
190 }
191
192 include_once 'Services/Style/classes/class.ilObjStyleSheet.php';
193 $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
194
195 // get page object
196 $page_gui = new ilShopPageGUI(self::SHOP_PAGE_EDITOR_PAGE_ID);
197
198 return $page_gui->showPage();
199 }
200
201 public function forwardToPageObject()
202 {
203 global $lng, $ilTabs;
204
205 $ilTabs->clearTargets();
206 $ilTabs->setBackTarget($lng->txt('back'), $this->ctrl->getLinkTarget($this), '_top');
207
208 // page object
209 include_once 'Services/Payment/classes/class.ilShopPage.php';
210 include_once 'Services/Payment/classes/class.ilShopPageGUI.php';
211
212 $lng->loadLanguageModule('content');
213
214 include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
215 $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
216
217 if(!ilShopPage::_exists('shop', self::SHOP_PAGE_EDITOR_PAGE_ID))
218 {
219 // doesn't exist -> create new one
220 $new_page_object = new ilShopPage();
221 $new_page_object->setParentId(0);
222 $new_page_object->setId(self::SHOP_PAGE_EDITOR_PAGE_ID);
223 $new_page_object->createFromXML();
224 }
225
226 $this->ctrl->setReturnByClass('ilshoppagegui', 'edit');
227
228 $page_gui = new ilShopPageGUI(self::SHOP_PAGE_EDITOR_PAGE_ID);
229
230 return $this->ctrl->forwardCommand($page_gui);
231 }
232
233 public function setFilter()
234 {
235 $_SESSION['content_filter']['updateView'] = $_POST['updateView'];
236 $_SESSION['content_filter']['show_filter'] = $_POST['show_filter'];
237 $_SESSION['content_filter']['sel_filter_type'] = $_POST['sel_filter_type'];
238 $_SESSION['content_filter']['filter_text'] = $_POST['filter_text'];
239 $_SESSION['content_filter']['filter_topic_id'] = $_POST['filter_topic_id'];
240
241 $_SESSION['content_filter']['order_field'] = $_POST['order_field'];
242 $_SESSION['content_filter']['order_direction'] = $_POST['order_direction'];
243
244 $_SESSION['content_filter']['topics_sorting_type'] = $_POST['topics_sorting_type'];
245 $_SESSION['content_filter']['topics_sorting_direction'] = $_POST['topics_sorting_direction'];
246
247 $this->setString($_POST['filter_text']);
248 $this->setType($_POST['sel_filter_type']);
249 $this->setTopicId($_POST['filter_topic_id']);
250
251 $this->setSortingTypeTopics($_POST['topics_sorting_type']);
252 $this->setSortingDirectionTopics($_POST['topics_sorting_direction']);
253 $this->setSortField($_POST['order_field']);
254 $this->setSortDirection('asc');
255
256 $this->performSearch();
257 return;
258 }
259
260 public function showShopExplorer()
261 {
262 global $ilCtrl, $tree, $lng, $tpl;
263
264 $ilCtrl->setParameter($this, "active_node", $_GET["active_node"]);
265 $tpl->addCss('Services/Payment/css/shop_explorer.css');
266
267 include_once ("./Services/Payment/classes/class.ilShopRepositoryExplorer.php");
268
269 $active_node = ($_GET["active_node"] >= 1)
270 ? $_GET["active_node"]
271 : ($_GET["ref_id"] >= 1)
272 ? $_GET["ref_id"]
273 : 0;
274
275 $top_node = 0;
276
277 $exp = new ilShopRepositoryExplorer("ilias.php", $top_node);
278 $exp->setUseStandardFrame(false);
279 $exp->setExpandTarget("ilias.php?baseClass=ilshopcontroller&ref_id=1&cmd=showTree");
280
281 $exp->setFrameUpdater("tree", "updater");
282 $exp->setTargetGet("ref_id");
283
284 if($_GET["repexpand"] == "")
285 {
286 $expanded = $tree->readRootId();
287 }
288 else
289 {
290 $expanded = $_GET["repexpand"];
291 }
292
293 $exp->setExpand($expanded);
294
295 if($active_node > 0)
296 {
297 $path = $tree->getPathId($active_node);
298 if($top_node > 0)
299 {
300 $exp->setForceOpenPath($path);
301 $exp->setExpand($expanded);
302 }
303 else
304 {
305 $exp->setForceOpenPath($path + array($top_node));
306 }
307 $exp->highlightNode($active_node);
308 }
309
310 // build html-output
311 if($top_node > 0)
312 {
313 $head_tpl = new ilTemplate("tpl.cont_tree_head.html", true, true,
314 "Services/Repository");
315 $path = ilObject::_getIcon(ROOT_FOLDER_ID, "tiny", "root");
316 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
317 $title = $nd["title"];
318 if($title == "ILIAS")
319 {
320 $title = $lng->txt("repository");
321 }
322 $head_tpl->setVariable("IMG_SRC", $path);
323 $head_tpl->setVariable("ALT_IMG", $lng->txt("icon") . " " . $title);
324 $head_tpl->setVariable("LINK_TXT", $title);
325 $head_tpl->setVariable("LINK_HREF", "ilias.php?baseClass=ilshopcontroller&ref_id=1");
326 $exp->setTreeLead($head_tpl->get());
327
328 $exp->initItemCounter(1);
329 $exp->setOutput($tree->getParentId($top_node), 1,
330 ilObject::_lookupObjId($tree->getParentId($top_node)));
331 }
332 else
333 {
334 $exp->setOutput(0);
335 }
336 $output = $exp->getOutput(true);
337
338 // asynchronous output
339 if($ilCtrl->isAsynch())
340 {
341 echo $output;
342 exit;
343 }
344
345 $ilCtrl->setParameter($this, "repexpand", $_GET["repexpand"]);
346 $tpl->setLeftContent($output);
347 }
348
349 public function performSearch($oResult = null)
350 {
351 if(!is_object($oResult))
352 {
354 if((bool)$this->settings->get('topics_allow_custom_sorting'))
355 {
356 ilShopTopics::_getInstance()->setIdFilter((int)$this->getTopicId());
357 ilShopTopics::_getInstance()->enableCustomSorting(true);
358 ilShopTopics::_getInstance()->setSortingType((int)$this->getSortingTypeTopics());
359 ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->getSortingDirectionTopics()));
361 }
362 else
363 {
364 ilShopTopics::_getInstance()->setIdFilter((int)$this->getTopicId());
365 ilShopTopics::_getInstance()->enableCustomSorting(false);
366 ilShopTopics::_getInstance()->setSortingType((int)$this->settings->get('topics_sorting_type'));
367 ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->settings->get('topics_sorting_direction')));
369 }
370
371 $topics = ilShopTopics::_getInstance()->getTopics();
372
373 $oResult->setTopics($topics);
374 $oResult->setResultPageNumber((int)$_GET['page_number']);
375 }
376
377 // query parser
378 include_once 'Services/Search/classes/class.ilQueryParser.php';
379 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->getString()));
380 $query_parser->setMinWordLength(0);
381 $query_parser->setCombination(QP_COMBINATION_AND);
382 $query_parser->parse();
383 if(!$query_parser->validate())
384 {
385 ilUtil::sendInfo($query_parser->getMessage());
386 }
387
388 // search
389 $types = array('crs', 'lm', 'sahs', 'htlm', 'file', 'tst', 'exc', 'glo');
390 if($this->getType() == '' || $this->getType() == 'title' ||
391 $query_parser->getQueryString() == ''
392 )
393 {
394 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
395 $object_search = ilObjectSearchFactory::_getShopObjectSearchInstance($query_parser);
396 $object_search->setFields(array('title'));
397 $object_search->setFilter($types);
398 $object_search->setCustomSearchResultObject($oResult);
399 $object_search->setFilterShopTopicId((int)$this->getTopicId());
400 $res = $object_search->performSearch();
401 }
402 else if($this->getType() == 'author')
403 {
404 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
405 $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
406 $meta_search->setMode('contribute');
407 $meta_search->setFilter($types);
408 $meta_search->setFilterShopTopicId((int)$this->getTopicId());
409 $meta_search->setCustomSearchResultObject($oResult);
410 $res = $meta_search->performSearch();
411 }
412 else
413 {
414 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
415 $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
416 $meta_search->setMode('title');
417 $meta_search->setFilter($types);
418 $meta_search->setCustomSearchResultObject($oResult);
419 $meta_search->setFilterShopTopicId((int)$this->getTopicId());
420 $res = $meta_search->performSearch();
421
422 $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
423 $meta_search->setMode('keyword');
424 $meta_search->setFilter($types);
425 $meta_search->setCustomSearchResultObject($oResult);
426 $meta_search->setFilterShopTopicId((int)$this->getTopicId());
427 $res->mergeEntries($meta_search->performSearch());
428 }
429
430 $res->filter(ROOT_FOLDER_ID, true);
431 $res->save();
432
433 if(!count($res->getResults()))
434 {
435 ilUtil::sendInfo($this->lng->txt('payment_shop_not_objects_found'));
436 }
437
438 $this->showTopicsContent($res);
439 $this->addPager($res);
440 return;
441 }
442
443 public function resetFilter()
444 {
445 unset($_SESSION['content_filter']);
446 unset($_POST['sel_filter_type']);
447 unset($_POST['filter_text']);
448 unset($_POST['filter_topic_id']);
449 unset($_POST['order_field']);
450 unset($_POST['order_direction']);
451 unset($_POST['topics_sorting_type']);
452 unset($_POST['topics_sorting_direction']);
453 unset($_POST['updateView']);
454 unset($_POST['show_filter']);
455
456 ilUtil::sendInfo($this->lng->txt('paya_filter_reseted'));
457 $this->setString('');
458 $this->setType('');
459 $this->setTopicId(0);
460
461 $this->performSearch();
462 return;
463 }
464
465 //showSpecialContent
466 public function showSpecialContent()
467 {
468 global $ilUser, $rbacreview, $ilToolbar;
469
470 if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
471 {
472 $ilToolbar->addButton($this->lng->txt('edit_page'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit'));
473 }
474
475 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.shop_content.html', 'Services/Payment');
476 $this->tpl->setVariable('PAGE_CONTENT', $this->getPageHTML());
477
478 include_once './Services/Payment/classes/class.ilPaymentObject.php';
479
481 if(count($pobjects))
482 {
483 foreach($pobjects as $result)
484 {
485 $obj_id = ilObject::_lookupObjId($result['ref_id']);
486 $title = ilObject::_lookupTitle($obj_id);
487 $description = ilObject::_lookupDescription($obj_id);
488 $type = ilObject::_lookupType($obj_id);
489
490 $presentation_results[(int)$result['pt_topic_fk']][$type][] =
491 array(
492 'ref_id' => $result['ref_id'],
493 'title' => $title,
494 'description' => $description,
495 'type' => $type,
496 'obj_id' => $obj_id,
497 'topic_id' => (int)$result['pt_topic_fk'],
498 'child' => $result['child']
499 );
500 }
501 $this->tpl->setVariable('PAGE_CONTENT', $this->getPageHTML());
502 }
503 else
504 {
505 $this->tpl->setVariable('PAGE_CONTENT', $this->lng->txt('please_choose_category'));
506 }
507
508 include_once 'Services/Payment/classes/class.ilShopResultPresentationGUI.php';
509 $search_result_presentation = new ilShopResultPresentationGUI($presentation_results);
510 $search_result_presentation->setSortField(strtolower(trim($this->getSortField())));
511 $search_result_presentation->setSortDirection(trim($this->getSortDirection()));
512
513 $html = $search_result_presentation->showSpecials();
514
515 $this->tpl->setVariable('RESULTS', $html);
516 $this->showFilters();
517 }
518
519 public function showTopicsContent($oResult)
520 {
521 global $ilUser, $rbacreview, $ilToolbar;
522
523 if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
524 {
525 $ilToolbar->addButton($this->lng->txt('edit_page'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit'));
526 }
527
528 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.shop_content.html', 'Services/Payment');
529 if(!count($oResult->getResults()))
530 {
531 $this->tpl->setVariable('ERROR',ilUtil::sendInfo($this->lng->txt('payment_shop_not_objects_found')));
532 }
533
534 include_once './Services/Payment/classes/class.ilPaymentObject.php';
535 $filter_topics_id = NULL;
536 if($_SESSION['content_filter']['filter_topic_id'] != NULL)
537 {
538 $filter_topics_id = (int)$_SESSION['content_filter']['filter_topic_id'];
539 $pobjects = ilPaymentObject::_getTopicsObjects($filter_topics_id);
540 if(count($pobjects))
541 {
542 foreach($pobjects as $result)
543 {
544 $obj_id = ilObject::_lookupObjId($result['ref_id']);
545 $title = ilObject::_lookupTitle($obj_id);
546 $description = ilObject::_lookupDescription($obj_id);
547 $type = ilObject::_lookupType($obj_id);
548
549 $presentation_results[(int)$result['pt_topic_fk']][$type][] = array(
550 'ref_id' => $result['ref_id'], 'title' => $title, 'description' => $description, 'type' => $type, 'obj_id' => $obj_id, 'topic_id' => (int)$result['pt_topic_fk'], 'child' => $result['child']
551 );
552 }
553 $this->tpl->setVariable('PAGE_CONTENT', $this->getPageHTML());
554 }
555 else
556 {
557 $this->tpl->setVariable('PAGE_CONTENT', $this->lng->txt('please_choose_category'));
558 }
559
560 include_once 'Services/Payment/classes/class.ilShopResultPresentationGUI.php';
561 $search_result_presentation = new ilShopResultPresentationGUI($presentation_results);
562 $search_result_presentation->setSortField(strtolower(trim($this->getSortField())));
563 $search_result_presentation->setSortDirection(trim($this->getSortDirection()));
564
565 $html = $search_result_presentation->showTopics();
566 }
567 else
568 {
569 foreach($oResult->getResults() as $result)
570 {
571
572 $obj_id = ilObject::_lookupObjId($result['ref_id']);
573 $title = ilObject::_lookupTitle($obj_id);
574 $description = ilObject::_lookupDescription($obj_id);
575 $tmp_res = array('ref_id' => $result['ref_id'], 'title' => $title, 'description' => $description,
576 'type' => $result['type'], 'obj_id' => $obj_id, 'topic_id' => 0, 'child' => 0);
577
578 $presentation_results[0][$result['type']][] = $tmp_res;
579 }
580
581 include_once 'Services/Payment/classes/class.ilShopResultPresentationGUI.php';
582 $search_result_presentation = new ilShopResultPresentationGUI($presentation_results);
583 $search_result_presentation->setSortField(strtolower(trim($this->getSortField())));
584 $search_result_presentation->setSortDirection(trim($this->getSortDirection()));
585
586 $html = $search_result_presentation->showTopics();
587 }
588 $this->tpl->setVariable('RESULTS', $html);
589 $this->showFilters();
590 }
591
592 /*
593 * show buyable "sub"-objects of containers (cat, catr, crs, grp, ...)
594 */
595 public function showContainerContent()
596 {
597 global $ilUser, $rbacreview, $ilToolbar, $tpl;
598
599 if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
600 {
601 $ilToolbar->addButton($this->lng->txt('edit_page'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit'));
602 }
603
604 include_once './Services/Payment/classes/class.ilPaymentObject.php';
605
606 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.shop_content.html', 'Services/Payment');
607 $this->tpl->setVariable('PAGE_CONTENT', $this->getPageHTML());
608
609 $is_buyable = ilPaymentObject::_isBuyable($this->cur_ref_id);
610
611 if($is_buyable)
612 {
614
615 $obj_id = ilObject::_lookupObjId($this->cur_ref_id);
616 $title = ilObject::_lookupTitle($obj_id);
617 $description = ilObject::_lookupDescription($obj_id);
618 $type = ilObject::_lookupType($obj_id);
619
620 $presentation_results[$pobjects['pt_topic_fk']][$type][] =
621 array(
622 'ref_id' => $pobjects['ref_id'],
623 'title' => $title,
624 'description' => $description,
625 'type' => $type,
626 'obj_id' => $obj_id,
627 'topic_id' => $pobjects['pt_topic_fk'],
628 'child' => $pobjects['child']
629 );
630 }
631 else
632 {
633 $pobjects = ilPaymentObject::_getContainerObjects($this->cur_ref_id);
634
635 if(count($pobjects) >= 1)
636 {
637 foreach($pobjects as $result)
638 {
639 $obj_id = $result['obj_id'];
640 $title = $result['title'];
641 $description = $result['description'];
642 $type = $result['type'];
643
644 $presentation_results[$result['pt_topic_fk']][$type][] =
645 array(
646 'ref_id' => $result['ref_id'],
647 'title' => $title,
648 'description' => $description,
649 'type' => $type,
650 'obj_id' => $obj_id,
651 'topic_id' => $result['pt_topic_fk'],
652 'child' => $result['child']
653 );
654 }
655 }
656 }
657
658 include_once 'Services/Payment/classes/class.ilShopResultPresentationGUI.php';
659 $search_result_presentation = new ilShopResultPresentationGUI($presentation_results);
660 $search_result_presentation->setSortField(strtolower(trim($this->getSortField())));
661 $search_result_presentation->setSortDirection(trim($this->getSortDirection()));
662
663 if(!$presentation_results)
664 {
665 $this->tpl->setVariable('RESULTS', $this->lng->txt('payment_shop_not_objects_found'));
666 }
667 else
668 {
669 $html = $search_result_presentation->showSpecials();
670 $this->tpl->setVariable('RESULTS', $html);
671 }
672 $this->showFilters();
673 }
674
675 public function showGeneralFilter($a_count_result = 0)
676 {
677 include_once 'Services/Payment/classes/class.ilShopFilterGUI.php';
678 $filterGUI = new ilShopFilterGUI($this, 'setCmd');
679 $filterGUI->initFilter();
680 if($this->cmd == 'setFilter')
681 {
682 $filterGUI->writeFilterToSession();
683 }
684 else
685 {
686 $filterGUI->resetFilter();
687 }
688 return $filterGUI->getHtml();
689 }
690
691 public function showTopicsFilter($a_count_result = 0)
692 {
693 global $ilUser;
694
695 $this->tpl->setCurrentBlock('show_topics_filter');
696
697 ilShopTopics::_getInstance()->setIdFilter(false);
699
700 if(count(ilShopTopics::_getInstance()->getTopics()))
701 {
702 $this->tpl->setVariable('PAGE_CONTENT', $this->getPageHTML());
703 $this->tpl->setVariable('SORTING_FORM_ACTION', $this->ctrl->getFormAction($this, 'setFilter'));
704
705 $this->tpl->setVariable('SET_FILTER_VAL', $this->lng->txt('pay_update_view'));
706
707 $this->tpl->setCurrentBlock('topics_option');
708 $this->tpl->setVariable('SORT_TOPICS', $this->lng->txt('topic'));
709
710 $this->tpl->setVariable('FILTER_TOPIC_ID', 'no_selection');
711 $this->tpl->setVariable('FILTER_TOPIC_TEXT', '------------');
712 if($_POST['cmd'] == 'firstpage')
713 $this->tpl->setVariable('FILTER_TOPIC_SELECTED', 'selected');
714 $this->tpl->parseCurrentBlock('topics_option');
715
716 $this->tpl->setVariable('FILTER_TOPIC_ID', 'all');
717 $this->tpl->setVariable('FILTER_TOPIC_TEXT', $this->lng->txt('all'));
718 if($_POST['filter_topic_id'] == 'all')
719 $this->tpl->setVariable('FILTER_TOPIC_SELECTED', 'selected');
720 $this->tpl->parseCurrentBlock('topics_option');
721
722 $oTopics = array();
723 $oTopics = ilShopTopics::_getInstance()->getTopics();
724 foreach($oTopics as $oTopic)
725 {
726 $this->tpl->setVariable('FILTER_TOPIC_ID', $oTopic->getId());
727 $this->tpl->setVariable('FILTER_TOPIC_TEXT', $oTopic->getTitle());
728 if($_POST['filter_topic_id'] == $oTopic->getId())
729 $this->tpl->setVariable('FILTER_TOPIC_SELECTED', 'selected');
730 $this->tpl->parseCurrentBlock('topics_option');
731 }
732 }
733
734 if($a_count_result)
735 {
736 $objects = (bool)$this->settings->get('objects_allow_custom_sorting');
737 if($objects)
738 {
739 // sorting form
740 $allow_objects_option = array(
741 'title' => $this->lng->txt('title'),
742 'author' => $this->lng->txt('author'),
743 'price' => $this->lng->txt('price_a')
744 );
745 $this->tpl->setCurrentBlock('order_field');
746 $this->tpl->setVariable('SORT_BY_TEXT', $this->lng->txt('sort_by'));
747
748 foreach($allow_objects_option as $key=> $value)
749 {
750 $this->tpl->setVariable('ORDER_FIELD_VALUE', $key);
751 $this->tpl->setVariable('ORDER_FIELD_TEXT', $value);
752 if($_POST['order_field'] == $key)
753 $this->tpl->setVariable('ORDER_FIELD_SELECTED', 'selected');
754 $this->tpl->parseCurrentBlock('order_field');
755 }
756 }
757
758 $topics = (bool)$this->settings->get('topics_allow_custom_sorting');
759
760 if($topics)
761 {
762 // sorting form
763 $allow_topics_option = array(
764 ilShopTopics::TOPICS_SORT_BY_TITLE => $this->lng->txt('sort_topics_by_title'),
765 ilShopTopics::TOPICS_SORT_BY_CREATEDATE => $this->lng->txt('sort_topics_by_date')
766 );
767 if(ANONYMOUS_USER_ID != $ilUser->getId())
768 {
769 $allow_topics_option[ilShopTopics::TOPICS_SORT_MANUALLY] = $this->lng->txt('sort_topics_manually');
770 }
771 }
772 }
773 }
774
775 public function setTopicId($a_topic_id)
776 {
777 $this->topic_id = $a_topic_id;
778 }
779
780 public function getTopicId()
781 {
782 return $this->topic_id;
783 }
784
785 public function setString($a_str)
786 {
787 $this->string = $a_str;
788 }
789
790 public function getString()
791 {
792 return $this->string;
793 }
794
795 public function setType($a_type)
796 {
797 $this->type = $a_type;
798 }
799
800 public function getType()
801 {
802 return $this->type;
803 }
804
805 public function setSortDirection($a_sort_direction)
806 {
807 $this->sort_direction = $a_sort_direction;
808 }
809
810 public function getSortDirection()
811 {
813 }
814
815 public function setSortField($a_field)
816 {
817 $this->sort_field = $a_field;
818 }
819
820 public function getSortField()
821 {
822 return $this->sort_field;
823 }
824
825 public function setSortingTypeTopics($a_field)
826 {
827 global $ilUser;
828
829 if(ANONYMOUS_USER_ID == $ilUser->getId() &&
831 )
832 {
834 }
835
836 $this->sort_type_topics = $a_field;
837 }
838
839 public function getSortingTypeTopics()
840 {
841 global $ilUser;
842
843 if(ANONYMOUS_USER_ID == $ilUser->getId() &&
844 $this->sort_type_topics == ilShopTopics::TOPICS_SORT_MANUALLY
845 )
846 {
847 $this->sort_type_topics = ilShopTopics::TOPICS_SORT_BY_TITLE;
848 }
849
851 }
852
853 public function setSortingDirectionTopics($a_sort_direction)
854 {
855 $_SESSION['shop_content']['shop_topics_sorting_direction'] = $this->sort_direction_topics = $a_sort_direction;
856 }
857
859 {
861 }
862
863 protected function prepareOutput()
864 {
865 global $ilTabs;
866
867 parent::prepareOutput();
868 $ilTabs->setTabActive('content');
869 }
870}
$result
$_GET["client_id"]
$_SESSION["AccountId"]
const QP_COMBINATION_AND
const SHOP_CONTENT
getContentStylePath($a_style_id)
get content style path
static _getShopMetaDataSearchInstance($query_parser)
get reference of LikeShopMetaDataSearch.
static _getShopObjectSearchInstance($query_parser)
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static _getObjectData($a_id)
static _getContainerObjects($a_ref_id)
static _getTopicsObjects($topic_id=NULL)
static _isBuyable($a_ref_id, $a_subtype='')
static _lookupPobjectId($a_ref_id)
Class ilShopBaseGUI.
Class ilShopFilterGUI.
Class ilShopGUI.
showTopicsFilter($a_count_result=0)
setSortingDirectionTopics($a_sort_direction)
setSortField($a_field)
setSortDirection($a_sort_direction)
setString($a_str)
showGeneralFilter($a_count_result=0)
showTopicsContent($oResult)
setTopicId($a_topic_id)
const SHOP_PAGE_EDITOR_PAGE_ID
getSortingDirectionTopics()
performSearch($oResult=null)
setSortingTypeTopics($a_field)
setType($a_type)
Shop page GUI class.
Shop page object.
Class ilShopRepositoryExplorer.
Class ilShopResultPresentationGUI.
searchResult stores all result of a search query.
const TOPICS_SORT_BY_CREATEDATE
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST['username']
Definition: cron.php:12
$nd
Definition: error.php:11
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
$cmd
Definition: sahs_server.php:35
$path
Definition: index.php:22
global $ilUser
Definition: imgupload.php:15