ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilShopResultPresentationGUI Class Reference

Class ilShopResultPresentationGUI. More...

+ Collaboration diagram for ilShopResultPresentationGUI:

Public Member Functions

 ilShopResultPresentationGUI ($result)
 
 showResults ()
 
 showSpecials ()
 
 showTopics ()
 
 setTypeOrdering ($a_type_ordering_array)
 
 getTypeOrdering ()
 
 setSortField ($a_sort_field)
 
 getSortField ()
 
 setSortDirection ($a_sort_direction)
 
 getSortDirection ()
 
 sortResult ($result)
 
 renderItemList ($results)
 
 addStandardRow ($a_tpl, $a_html)
 
 newBlockTemplate ()
 returns a new list block template More...
 
 resetRowType ()
 
 showAdvancedSearchResults ()
 

Data Fields

 $tpl
 
 $lng
 
 $result = 0
 

Protected Attributes

 $search_cache = null
 

Private Member Functions

 renderItems ($oContainerTpl, $results, $topic)
 
 getObjectListItem ($cur_obj_type, $item)
 

Private Attributes

 $sort_field = ''
 
 $sort_direction = ''
 

Detailed Description

Member Function Documentation

◆ addStandardRow()

ilShopResultPresentationGUI::addStandardRow (   $a_tpl,
  $a_html 
)
Parameters
$a_tpl
$a_html
$a_ref_id

Definition at line 291 of file class.ilShopResultPresentationGUI.php.

292 {
293 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
294 ? "row_type_2"
295 : "row_type_1";
296
297 $a_tpl->touchBlock($this->cur_row_type);
298 $a_tpl->setCurrentBlock("container_standard_row");
299 $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
300
301 $a_tpl->parseCurrentBlock();
302 $a_tpl->touchBlock("container_row");
303 }

Referenced by renderItems().

+ Here is the caller graph for this function:

◆ getObjectListItem()

ilShopResultPresentationGUI::getObjectListItem (   $cur_obj_type,
  $item 
)
private
Parameters
$cur_obj_type
$item
Returns
array

Definition at line 449 of file class.ilShopResultPresentationGUI.php.

450 {
451 if($cur_obj_type != $item['type'])
452 {
453 include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
454 $item_list_gui = ilObjectListGUIFactory::_getListGUIByType($item['type']);
455 }
456 $item_list_gui->initItem($item['ref_id'], $item['obj_id'], $item['title'], $item['description'], ilObjectListGUI::CONTEXT_SHOP);
457 $item_list_gui->enableDelete(false);
458 $item_list_gui->enableCut(false);
459 $item_list_gui->enableCopy(false);
460 $item_list_gui->enableLink(false);
461 $item_list_gui->enableSubscribe(false);
462
463 $item_list_gui->enablePayment(true);
464 $item_list_gui->enableCommands(true);
465 $item_list_gui->enablePath(false);
466 $item_list_gui->insertCommands();
467
468 $item_list_gui->enableInfoScreen(false);
469 $item_list_gui->enableSubstitutions(false);
470 $item_list_gui->enableNoticeProperties(false);
471 $item_list_gui->enablePreconditions(false);
472 $item_list_gui->enableProperties(false);
473 $item_list_gui->setBoldTitle(true);
474
475 if(ilPaymentObject::_hasAccess($item['ref_id']))
476 {
477 $item_list_gui->enableInfoScreen(true);
478 $item_list_gui->enableCommands(true);
479 }
480// else
481// {
482 switch($item['type'])
483 {
484 case 'sahs':
485 $demo_link = 'ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=' . $item['ref_id'] . '&purchasetype=demo';
486 break;
487
488 case 'lm':
489 $demo_link = 'ilias.php?baseClass=ilLMPresentationGUI&ref_id=' . $item['ref_id'] . '&purchasetype=demo';
490 break;
491
492 case 'exc':
493 $demo_link = $this->ctrl->getLinkTargetByClass('ilshoppurchasegui', 'showDemoVersion') . '&purchasetype=demo&ref_id=' . $item["ref_id"];
494 break;
495
496 default:
497 $demo_link = $this->ctrl->getLinkTargetByClass('ilshoppurchasegui', 'showDemoVersion') . '&purchasetype=demo&ref_id=' . $item["ref_id"];
498 break;
499 }
500
501 $item['title'] = '<a href="' . $demo_link . '">' . $item["title"] . '</a>';
502// }
503
504 $tpl_pinfo = new ilTemplate ('tpl.shop_item_info.html', true, true, 'Services/Payment');
505 if($item['price_string'] != '')
506 {
507 $tpl_pinfo->setCurrentBlock('ploop');
508 $tpl_pinfo->setVariable('PROPERTY', $this->lng->txt('price_a'));
509 $tpl_pinfo->setVariable('VALUE', $item['price_string']);
510 $tpl_pinfo->parseCurrentBlock();
511 }
512 if($item['author'] != '')
513 {
514 $tpl_pinfo->setCurrentBlock('ploop');
515 $tpl_pinfo->setVariable('PROPERTY', $this->lng->txt('author'));
516 $tpl_pinfo->setVariable('VALUE', $item['author']);
517 $tpl_pinfo->parseCurrentBlock();
518 }
519 $oFile = new ilFileDataShop(ilPaymentObject::_lookupPobjectId($item['ref_id']));
520 if(($webpath_file = $oFile->getCurrentImageWebPath()) !== false)
521 {
522 $tpl_pinfo->setCurrentBlock('image');
523 $tpl_pinfo->setVariable('SRC', $webpath_file);
524 $tpl_pinfo->setVariable('ALT', strip_tags($item['title']));
525 $tpl_pinfo->parseCurrentBlock();
526 }
527
528 $item_list_gui->addSubItemHTML($tpl_pinfo->get());
529
530 $html = $item_list_gui->getListItemHTML($item['ref_id'], $item['obj_id'], $item['title'], $item['description'], false, false, "", ilObjectListGUI::CONTEXT_SHOP);
531 return array($item, $html);
532 }
This class handles all operations on files in directory data/shop.
static _hasAccess($a_ref_id, $a_transaction=0, $a_subtype='')
static _lookupPobjectId($a_ref_id)
special template class to simplify handling of ITX/PEAR
$html
Definition: example_001.php:87

References $html, ilObjectListGUIFactory\_getListGUIByType(), ilPaymentObject\_hasAccess(), ilPaymentObject\_lookupPobjectId(), and ilObjectListGUI\CONTEXT_SHOP.

Referenced by renderItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSortDirection()

ilShopResultPresentationGUI::getSortDirection ( )

◆ getSortField()

ilShopResultPresentationGUI::getSortField ( )

◆ getTypeOrdering()

ilShopResultPresentationGUI::getTypeOrdering ( )

Definition at line 115 of file class.ilShopResultPresentationGUI.php.

116 {
117 return $this->type_ordering;
118 }

◆ ilShopResultPresentationGUI()

ilShopResultPresentationGUI::ilShopResultPresentationGUI (   $result)

Definition at line 31 of file class.ilShopResultPresentationGUI.php.

32 {
33 global $lng, $ilCtrl, $ilUser;
34
35 $this->lng = $lng;
36 $this->result = $result;
37
38 $this->type_ordering = array(
39 "cat", "crs", "grp", "chat", "frm", "wiki", "lres",
40 "glo", "webr", "lm", "sahs", "htlm", "file",'mcst', "exc",
41 "tst", "svy", "sess","mep", "qpl", "spl");
42
43 $this->ctrl = $ilCtrl;
44
45 include_once('Services/Search/classes/class.ilUserSearchCache.php');
46 $this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
47 }
static _getInstance($a_usr_id)
Get singleton instance.
global $ilCtrl
Definition: ilias.php:18
global $ilUser
Definition: imgupload.php:15

References $ilCtrl, $ilUser, $lng, $result, and ilUserSearchCache\_getInstance().

+ Here is the call graph for this function:

◆ newBlockTemplate()

ilShopResultPresentationGUI::newBlockTemplate ( )

returns a new list block template

@access private

Returns
object block template

Definition at line 311 of file class.ilShopResultPresentationGUI.php.

312 {
313 $tpl = new ilTemplate ("tpl.container_list_block.html",true, true, "Services/Container");
314 $this->cur_row_type = "row_type_1";
315
316 return $tpl;
317 }

References $tpl.

Referenced by renderItems().

+ Here is the caller graph for this function:

◆ renderItemList()

ilShopResultPresentationGUI::renderItemList (   $results)

Definition at line 273 of file class.ilShopResultPresentationGUI.php.

274 {
275 $oContainerTpl = new ilTemplate ('tpl.shop_container.html', true, true, 'Services/Payment');
276
277 foreach($this->result->getTopics() as $oTopic)
278 {
279 $this->renderItems($oContainerTpl, $results, array('id' => $oTopic->getId(), 'title' => $oTopic->getTitle()));
280 }
281 $this->renderItems($oContainerTpl, $results, array('id' => 0, 'title' => $this->lng->txt('payment_no_topic')));
282
283 return $oContainerTpl->get();
284 }
renderItems($oContainerTpl, $results, $topic)
$results

References $results, and renderItems().

+ Here is the call graph for this function:

◆ renderItems()

ilShopResultPresentationGUI::renderItems (   $oContainerTpl,
  $results,
  $topic 
)
private

Definition at line 156 of file class.ilShopResultPresentationGUI.php.

157 {
158 // main shop_content
159 global $ilUser;
160
161 $items_counter = 0;
162
163 $cur_obj_type = '';
164 $tpl = $this->newBlockTemplate();
165
166 foreach($this->type_ordering as $act_type)
167 {
168 $item_html = array();
169
170 if(count($results[(int)$topic['id']][$act_type]))
171 {
172 foreach($results[$topic['id']][$act_type] as $key => $item)
173 {
174 // price presentation
175 $oPaymentObject = new ilPaymentObject($ilUser, ilPaymentObject::_lookupPobjectId($item['ref_id']));
176 $oPrice = new ilPaymentPrices((int)$oPaymentObject->getPobjectId());
177 $lowest_price = $oPrice->getLowestPrice();
178
179 $special_icon = ' ';
180 if($oPaymentObject->getSpecial() == '1')
181 {
182 $special_icon = ilShopUtils::_getSpecialObjectSymbol();
183 }
184 $results[$topic['id']][$act_type][$key]['title'] = $item['title'].' '.
185 $results[$topic['id']][$act_type][$key]['special_icon'] = $special_icon;
186
187 $results[$topic['id']][$act_type][$key]['price'] = $lowest_price['price'];
188
189 $paymethod_icon = ilShopUtils::_getPaymethodSymbol($oPaymentObject->getPayMethod());
190 $shoppingcart_icon = ilShopUtils::_addToShoppingCartSymbol($item['ref_id']);
191
192 $results[$topic['id']][$act_type][$key]['price_string'] =
193 ($oPrice->getNumberOfPrices() > 1 ? $this->lng->txt('price_from').' ' : '').
194 ilPaymentPrices::_formatPriceToString($lowest_price['price']).' '.
195
196 //shoppingcart icon
197 $results[$topic['id']][$act_type][$key]['shoppingcart_icon'] = $shoppingcart_icon.' '.
198 // paymethod icon
199 $results[$topic['id']][$act_type][$key]['paymethod_icon'] = $paymethod_icon;
200
201 // authors
202 include_once 'Services/MetaData/classes/class.ilMD.php';
203 $md_obj = new ilMD($item['obj_id'], 0, $item['type']);
204 if(is_object($md_section = $md_obj->getLifecycle()))
205 {
206 $sep = $ent_str = "";
207 foreach(($ids = $md_section->getContributeIds()) as $con_id)
208 {
209 $md_con = $md_section->getContribute($con_id);
210 if ($md_con->getRole() == "Author")
211 {
212 foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
213 {
214 $md_ent = $md_con->getEntity($ent_id);
215 $ent_str = $ent_str.$sep.$md_ent->getEntity();
216 $sep = ", ";
217 }
218 }
219 }
220 $results[$topic['id']][$act_type][$key]['author'] = $ent_str;
221 }
222 }
223
224 $results[$topic['id']][$act_type] = $this->sortResult($results[$topic['id']][$act_type]);
225
226 foreach($results[$topic['id']][$act_type] as $key => $item)
227 {
228 // get list gui class for each object type
229 list($item, $html) = $this->getObjectListItem($cur_obj_type, $item);
230
231 if($html)
232 {
233 $item_html[$item['ref_id']] = $html;
234 }
235 }
236
237 // output block for resource type
238 if(count($item_html) > 0)
239 {
240 // add a header for each resource type
241 $tpl->setCurrentBlock("container_header_row_image");
242 $tpl->setVariable("HEADER_IMG", ilObject::_getIcon('','', $act_type));
243 $tpl->setVariable("HEADER_ALT", $this->lng->txt("objs_".$act_type));
244 $tpl->setVariable("BLOCK_HEADER_CONTENT", $this->lng->txt("objs_".$act_type));
245
246 $this->resetRowType();
247 // content row
248 foreach($item_html as $ref_id => $html)
249 {
250 $this->addStandardRow($tpl, $html);
251 }
252
253 ++$items_counter;
254 }
255 }
256 }
257 if($items_counter > 0)
258 {
259 $oContainerTpl->setCurrentBlock('loop_item');
260 $oContainerTpl->setCurrentBlock('topic_title');
261 $oContainerTpl->setVariable('TOPIC_TITLE', $topic['title']);
262 $oContainerTpl->parseCurrentBlock('topic_title');
263
264 $oContainerTpl->setVariable('CONTAINER_LIST_BLOCK', $html);
265 $oContainerTpl->parseCurrentBlock('loop_item');
266 $tpl->setContent($oContainerTpl->get());
267 $container_html = $tpl->get();
268
269 return $container_html;
270 }
271 }
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _formatPriceToString($a_price)
newBlockTemplate()
returns a new list block template
static _getSpecialObjectSymbol()
static _getPaymethodSymbol($a_paymethod)
static _addToShoppingCartSymbol($a_ref_id)
$ref_id
Definition: sahs_server.php:39

References $html, $ilUser, $ref_id, $results, $tpl, ilShopUtils\_addToShoppingCartSymbol(), ilPaymentPrices\_formatPriceToString(), ilObject\_getIcon(), ilShopUtils\_getPaymethodSymbol(), ilShopUtils\_getSpecialObjectSymbol(), ilPaymentObject\_lookupPobjectId(), addStandardRow(), getObjectListItem(), newBlockTemplate(), resetRowType(), and sortResult().

Referenced by renderItemList(), showSpecials(), and showTopics().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetRowType()

ilShopResultPresentationGUI::resetRowType ( )

Definition at line 439 of file class.ilShopResultPresentationGUI.php.

440 {
441 $this->cur_row_type = "";
442 }

Referenced by renderItems().

+ Here is the caller graph for this function:

◆ setSortDirection()

ilShopResultPresentationGUI::setSortDirection (   $a_sort_direction)

Definition at line 127 of file class.ilShopResultPresentationGUI.php.

128 {
129 $this->sort_direction = $a_sort_direction;
130 }

◆ setSortField()

ilShopResultPresentationGUI::setSortField (   $a_sort_field)

Definition at line 119 of file class.ilShopResultPresentationGUI.php.

120 {
121 $this->sort_field = $a_sort_field;
122 }

◆ setTypeOrdering()

ilShopResultPresentationGUI::setTypeOrdering (   $a_type_ordering_array)

Definition at line 111 of file class.ilShopResultPresentationGUI.php.

112 {
113 $this->type_ordering = $a_type_ordering_array;
114 }

◆ showAdvancedSearchResults()

ilShopResultPresentationGUI::showAdvancedSearchResults ( )

Definition at line 534 of file class.ilShopResultPresentationGUI.php.

535 {
536 $this->result = $this->result->getResultsForPresentation();
537 return $this->showSpecials();
538 }

References showSpecials().

+ Here is the call graph for this function:

◆ showResults()

ilShopResultPresentationGUI::showResults ( )

Definition at line 49 of file class.ilShopResultPresentationGUI.php.

50 {
51 // Get results
52 $this->showTopics();
53 }

References showTopics().

+ Here is the call graph for this function:

◆ showSpecials()

ilShopResultPresentationGUI::showSpecials ( )

Definition at line 55 of file class.ilShopResultPresentationGUI.php.

56 {
57 // Get specials
58 $oContainerTpl = new ilTemplate ('tpl.shop_container.html', true, true, 'Services/Payment');
59 include_once './Services/Payment/classes/class.ilShopTopic.php';
60 include_once './Services/Payment/classes/class.ilShopTopics.php';
62
63 ilShopTopics::_getInstance()->setIdFilter(false);
65 $html = '';
66
67 if(count($topics = ilShopTopics::_getInstance()->getTopics()))
68 {
69 foreach($topics as $oTopic)
70 {
71 $html .= $this->renderItems($oContainerTpl, $results, array('id' => $oTopic->getId(), 'title' => $oTopic->getTitle()));
72 }
73 $html .= $this->renderItems($oContainerTpl, $results, array('id' => 0, 'title' => $this->lng->txt('payment_no_topic')));
74 }
75 else
76 {
77 $html .= $this->renderItems($oContainerTpl, $results, array('id' => 0, 'title' => $this->lng->txt('payment_no_topic')));
78 }
79
80 return $html;
81 }

References $html, $result, $results, ilShopTopics\_getInstance(), and renderItems().

Referenced by showAdvancedSearchResults().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showTopics()

ilShopResultPresentationGUI::showTopics ( )

Definition at line 84 of file class.ilShopResultPresentationGUI.php.

85 {
86 $oContainerTpl = new ilTemplate ('tpl.shop_container.html', true, true, 'Services/Payment');
87 include_once './Services/Payment/classes/class.ilShopTopic.php';
88 include_once './Services/Payment/classes/class.ilShopTopics.php';
90
91 ilShopTopics::_getInstance()->setIdFilter(false);
93
94 $html = '';
95 if(count($topics = ilShopTopics::_getInstance()->getTopics()))
96 {
97 foreach($topics as $oTopic)
98 {
99 $html .= $this->renderItems($oContainerTpl, $results, array('id' => $oTopic->getId(), 'title' => $oTopic->getTitle()));
100 }
101 $html .= $this->renderItems($oContainerTpl, $results, array('id' => 0, 'title' => $this->lng->txt('payment_no_topic')));
102 }
103 else
104 {
105 $html .= $this->renderItems($oContainerTpl, $results, array('id' => 0, 'title' => $this->lng->txt('payment_no_topic')));
106 }
107
108 return $html;
109 }

References $html, $result, $results, ilShopTopics\_getInstance(), and renderItems().

Referenced by showResults().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sortResult()

ilShopResultPresentationGUI::sortResult (   $result)

Definition at line 136 of file class.ilShopResultPresentationGUI.php.

137 {
138 if ($this->sort_direction != '' && $this->sort_field != '')
139 {
140 switch ($this->sort_field)
141 {
142 case 'price':
143 $numeric_sort = true;
144 break;
145 default:
146 $numeric_sort = false;
147 break;
148 }
149
150 $result = ilUtil::sortArray($result, $this->sort_field, $this->sort_direction, $numeric_sort);
151 }
152
153 return $result;
154 }
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray

References $result, and ilUtil\sortArray().

Referenced by renderItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $lng

ilShopResultPresentationGUI::$lng

Definition at line 23 of file class.ilShopResultPresentationGUI.php.

Referenced by ilShopResultPresentationGUI().

◆ $result

ilShopResultPresentationGUI::$result = 0

◆ $search_cache

ilShopResultPresentationGUI::$search_cache = null
protected

Definition at line 20 of file class.ilShopResultPresentationGUI.php.

◆ $sort_direction

ilShopResultPresentationGUI::$sort_direction = ''
private

Definition at line 29 of file class.ilShopResultPresentationGUI.php.

Referenced by getSortDirection().

◆ $sort_field

ilShopResultPresentationGUI::$sort_field = ''
private

Definition at line 28 of file class.ilShopResultPresentationGUI.php.

Referenced by getSortField().

◆ $tpl

ilShopResultPresentationGUI::$tpl

Definition at line 22 of file class.ilShopResultPresentationGUI.php.

Referenced by newBlockTemplate(), and renderItems().


The documentation for this class was generated from the following file: