ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilShopResultPresentationGUI Class Reference

Class ilShopResultPresentationGUI. More...

+ Collaboration diagram for ilShopResultPresentationGUI:

Public Member Functions

 ilShopResultPresentationGUI ($result)
 showResults ()
 showSpecials ()
 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, $a_ref_id)
 adds a standard row to a block template
 newBlockTemplate ()
 returns a new list block template
 addHeaderRow (&$a_tpl, $a_type)
 adds a header row to a block template
 addSeparatorRow (&$a_tpl)
 __appendChildLinks ($html, $item, &$item_list_gui)
 resetRowType ()

Data Fields

 $tpl
 $lng
 $result = 0

Protected Attributes

 $search_cache = null

Private Member Functions

 renderItems ($oContainerTpl, $results, $topic)

Private Attributes

 $sort_field = ''
 $sort_direction = ''

Detailed Description

Class ilShopResultPresentationGUI.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id:$

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

Member Function Documentation

ilShopResultPresentationGUI::__appendChildLinks (   $html,
  $item,
$item_list_gui 
)

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

References $tpl, ilLink\_getLink(), ilGlossaryTerm\_lookGlossaryTerm(), ilObjForum\_lookupThreadSubject(), ilLMObject\_lookupTitle(), ilNewsItem\_lookupTitle(), ilLMObject\_lookupType(), ilWikiPage\lookupTitle(), and ilWikiUtil\makeUrlTitle().

Referenced by renderItems().

{
if(!count($item['child']))
{
return $html;
}
$tpl = new ilTemplate('tpl.detail_links.html',true,true,'Services/Search');
switch($item['type'])
{
case 'lm':
$tpl->setVariable("HITS",$this->lng->txt('search_hits'));
include_once 'Modules/LearningModule/classes/class.ilLMObject.php';
foreach($item['child'] as $child)
{
$tpl->setCurrentBlock("link_row");
switch(ilLMObject::_lookupType($child))
{
case 'pg':
$tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('obj_pg'));
break;
case 'st':
$tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('obj_st'));
break;
}
$item_list_gui->setChildId($child);
$tpl->setVariable("SEPERATOR",' -> ');
$tpl->setVariable("LINK",$item_list_gui->getCommandLink('page'));
$tpl->setVariable("TARGET",$item_list_gui->getCommandFrame('page'));
$tpl->setVariable("TITLE",ilLMObject::_lookupTitle($child));
$tpl->parseCurrentBlock();
}
break;
case 'frm':
$tpl->setVariable("HITS",$this->lng->txt('search_hits'));
include_once './Modules/Forum/classes/class.ilObjForum.php';
foreach($item['child'] as $child)
{
$thread_post = explode('_',$child);
$tpl->setCurrentBlock("link_row");
$tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('thread'));
$item_list_gui->setChildId($thread_post);
$tpl->setVariable("SEPERATOR",': ');
$tpl->setVariable("LINK",$item_list_gui->getCommandLink('posting'));
$tpl->setVariable("TARGET",$item_list_gui->getCommandFrame(''));
$tpl->setVariable("TITLE",ilObjForum::_lookupThreadSubject($thread_post[0]));
$tpl->parseCurrentBlock();
}
break;
case 'glo':
$tpl->setVariable("HITS",$this->lng->txt('search_hits'));
include_once './Modules/Glossary/classes/class.ilGlossaryTerm.php';
$this->lng->loadLanguageModule('content');
foreach($item['child'] as $child)
{
$tpl->setCurrentBlock("link_row");
$tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('cont_term'));
$tpl->setVariable("SEPERATOR",': ');
$tpl->setVariable("LINK",ilLink::_getLink($item['ref_id'],'git',array('target' => 'git_'.$child.'_'.$item['ref_id'])));
$tpl->setVariable("TITLE",ilGlossaryTerm::_lookGlossaryTerm($child));
$tpl->parseCurrentBlock();
}
break;
case 'wiki':
$tpl->setVariable("HITS",$this->lng->txt('search_hits'));
include_once './Modules/Wiki/classes/class.ilWikiPage.php';
include_once './Modules/Wiki/classes/class.ilWikiUtil.php';
$this->lng->loadLanguageModule('wiki');
foreach($item['child'] as $child)
{
$page_title = ilWikiPage::lookupTitle($child);
$tpl->setCurrentBlock("link_row");
$tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('wiki_page'));
$tpl->setVariable("SEPERATOR",': ');
$tpl->setVariable("LINK",ilLink::_getLink($item['ref_id'],'wiki',array(), "_".
ilWikiUtil::makeUrlTitle($page_title)));
$tpl->setVariable("TITLE", $page_title);
$tpl->parseCurrentBlock();
}
break;
case 'mcst':
$tpl->setVariable("HITS",$this->lng->txt('search_hits'));
include_once("./Services/News/classes/class.ilNewsItem.php");
foreach($item['child'] as $child)
{
$tpl->setCurrentBlock("link_row");
//$tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('item'));
$item_list_gui->setChildId($child);
//$tpl->setVariable("SEPERATOR",': ');
$tpl->setVariable("LINK", $item_list_gui->getCommandLink('listItems'));
$tpl->setVariable("TARGET", $item_list_gui->getCommandFrame(''));
$tpl->setVariable("TITLE", ilNewsItem::_lookupTitle($child));
$tpl->parseCurrentBlock();
}
break;
default:
;
}
return $html . $tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilShopResultPresentationGUI::addHeaderRow ( $a_tpl,
  $a_type 
)

adds a header row to a block template

Parameters
object$a_tplblock template
string$a_typeobject type private

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

References $title, and ilUtil\getImagePath().

Referenced by renderItems().

{
if ($a_type != "lres")
{
$icon = ilUtil::getImagePath("icon_".$a_type.".gif");
$title = $this->lng->txt("objs_".$a_type);
}
else
{
$icon = ilUtil::getImagePath("icon_lm.gif");
$title = $this->lng->txt("learning_resources");
}
$a_tpl->setCurrentBlock("container_header_row_image");
$a_tpl->setVariable("HEADER_IMG", $icon);
$a_tpl->setVariable("HEADER_ALT", $title);
$a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
$a_tpl->parseCurrentBlock();
#$a_tpl->setCurrentBlock("container_header_row");
#$a_tpl->parseCurrentBlock();
#$a_tpl->touchBlock("container_row");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilShopResultPresentationGUI::addSeparatorRow ( $a_tpl)

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

Referenced by renderItems().

{
$a_tpl->touchBlock("separator_row");
$a_tpl->touchBlock("container_row");
}

+ Here is the caller graph for this function:

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

adds a standard row to a block template

Parameters
object$a_tplblock template
string$a_htmlhtml code private

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

Referenced by renderItems().

{
$this->cur_row_type = ($this->cur_row_type == "row_type_1")
? "row_type_2"
: "row_type_1";
$a_tpl->touchBlock($this->cur_row_type);
$a_tpl->setCurrentBlock("container_standard_row");
$a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
// add checkbox for saving results
#$a_tpl->setVariable("BLOCK_ROW_CHECK",ilUtil::formCheckbox(0,'result[]',$a_ref_id));
#$a_tpl->setVariable("ITEM_ID",$a_ref_id);
$a_tpl->parseCurrentBlock();
$a_tpl->touchBlock("container_row");
}

+ Here is the caller graph for this function:

ilShopResultPresentationGUI::getSortDirection ( )

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

References $sort_direction.

{
}
ilShopResultPresentationGUI::getSortField ( )

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

References $sort_field.

{
}
ilShopResultPresentationGUI::getTypeOrdering ( )

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

{
return $this->type_ordering;
}
ilShopResultPresentationGUI::ilShopResultPresentationGUI (   $result)

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

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

{
global $tpl,$lng,$ilCtrl,$ilUser;
$this->lng = $lng;
$this->result = $result;
$this->type_ordering = array(
"cat", "crs", "grp", "chat", "frm", "wiki", "lres",
"glo", "webr", "lm", "sahs", "htlm", "file",'mcst', "exc",
"tst", "svy", "sess","mep", "qpl", "spl");
$this->ctrl = $ilCtrl;
include_once('Services/Search/classes/class.ilUserSearchCache.php');
$this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
}

+ Here is the call graph for this function:

ilShopResultPresentationGUI::newBlockTemplate ( )

returns a new list block template

private

Returns
object block template

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

References $tpl.

Referenced by renderItems().

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

+ Here is the caller graph for this function:

ilShopResultPresentationGUI::renderItemList (   $results)

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

References $results, and renderItems().

Referenced by showResults().

{
global $ilUser;
$oContainerTpl = new ilTemplate ('tpl.shop_container.html', true, true, 'Services/Payment');
foreach($this->result->getTopics() as $oTopic)
{
$this->renderItems($oContainerTpl, $results, array('id' => $oTopic->getId(), 'title' => $oTopic->getTitle()));
}
$this->renderItems($oContainerTpl, $results, array('id' => 0, 'title' => $this->lng->txt('payment_no_topic')));
return $oContainerTpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

References $ref_id, $results, $tpl, __appendChildLinks(), ilShopUtils\_addToShoppingCartSymbol(), ilPaymentPrices\_formatPriceToString(), ilObjectListGUIFactory\_getListGUIByType(), ilShopUtils\_getPaymethodSymbol(), ilShopUtils\_getSpecialObjectSymbol(), ilPaymentObject\_hasAccess(), ilPaymentObject\_lookupPobjectId(), addHeaderRow(), addSeparatorRow(), addStandardRow(), ilObjectListGUI\CONTEXT_SHOP, ilPaymentPrices\getLowestPrice(), newBlockTemplate(), resetRowType(), and sortResult().

Referenced by renderItemList(), and showSpecials().

{
// main shop_content
global $ilUser;
$items_counter = 0;
$cur_obj_type = '';
$tpl = $this->newBlockTemplate();
$first = true;
foreach($this->type_ordering as $act_type)
{
$item_html = array();
if(count($results[$topic['id']][$act_type]))
{
foreach($results[$topic['id']][$act_type] as $key => $item)
{
// price presentation
$oPaymentObject =
new ilPaymentObject($ilUser, ilPaymentObject::_lookupPobjectId($item['ref_id']));
$oPrice = new ilPaymentPrices($oPaymentObject->getPobjectId());
$lowest_price = $oPrice->getLowestPrice();
$special_icon = ' ';
if($oPaymentObject->getSpecial() == '1')
{
}
$results[$topic['id']][$act_type][$key]['title'] = $item['title'].' '.
//special icon
$results[$topic['id']][$act_type][$key]['special_icon'] = $special_icon;
$results[$topic['id']][$act_type][$key]['price'] = $lowest_price['price'];
$paymethod_icon = ilShopUtils::_getPaymethodSymbol($oPaymentObject->getPayMethod());
if(!ilPaymentObject::_hasAccess($item['ref_id']))
{
$shoppingcart_icon = ilShopUtils::_addToShoppingCartSymbol($act_type, $item['ref_id']);
}
else $shoppingcart_icon = '';
$results[$topic['id']][$act_type][$key]['price_string'] =
($oPrice->getNumberOfPrices() > 1 ? $this->lng->txt('price_from').' ' : '').
ilPaymentPrices::_formatPriceToString($lowest_price['price']).' '.
//shoppingcart icon
$results[$topic['id']][$act_type][$key]['shoppingcart_icon'] = $shoppingcart_icon.' '.
// paymethod icon
$results[$topic['id']][$act_type][$key]['paymethod_icon'] = $paymethod_icon;
// TODO: CURRENCY ilPaymentPrices::_formatPriceToString($lowest_price['price'], $lowest_price['currency']);
// authors
include_once 'Services/MetaData/classes/class.ilMD.php';
$md_obj = new ilMD($item['obj_id'], 0, $item['type']);
if(is_object($md_section = $md_obj->getLifecycle()))
{
$sep = $ent_str = "";
foreach(($ids = $md_section->getContributeIds()) as $con_id)
{
$md_con = $md_section->getContribute($con_id);
if ($md_con->getRole() == "Author")
{
foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
{
$md_ent = $md_con->getEntity($ent_id);
$ent_str = $ent_str.$sep.$md_ent->getEntity();
$sep = ", ";
}
}
}
$results[$topic['id']][$act_type][$key]['author'] = $ent_str;
}
}
$results[$topic['id']][$act_type] = $this->sortResult($results[$topic['id']][$act_type]);
foreach($results[$topic['id']][$act_type] as $key => $item)
{
// get list gui class for each object type
if ($cur_obj_type != $item['type'])
{
include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
$item_list_gui = ilObjectListGUIFactory::_getListGUIByType($item['type']);
}
$item_list_gui->initItem(
$item['ref_id'],
$item['obj_id'],
$item['title'],
$item['description'],
);
$item_list_gui->enableDelete(false);
$item_list_gui->enableCut(false);
$item_list_gui->enableCopy(false);
$item_list_gui->enableLink(false);
$item_list_gui->enableSubscribe(false);
$item_list_gui->enablePayment(true);
$item_list_gui->enableCommands(true);
$item_list_gui->enablePath(false);
$item_list_gui->insertCommands();
$item_list_gui->enableInfoScreen(false);
$item_list_gui->enableSubstitutions(false);
$item_list_gui->enableNoticeProperties(false);
$item_list_gui->enablePreconditions(false);
$item_list_gui->enableProperties(false);
$item_list_gui->setBoldTitle(true);
if(ilPaymentObject::_hasAccess($item['ref_id']))
{
$item_list_gui->enableInfoScreen(true);
$item_list_gui->enableCommands(true);
}
else
{
switch ($item['type'])
{
case 'sahs':
$demo_link = 'ilias.php?baseClass=ilSAHSPresentationGUI&ref_id='.$item['ref_id'].'&purchasetype=demo';
break;
case 'lm':
$demo_link = 'ilias.php?baseClass=ilLMPresentationGUI&ref_id='.$item['ref_id'].'&purchasetype=demo';
break;
case 'exc':
#$demo_link = 'repository.php?baseClass=ilExcerciseHandlerGUI&ref_id='.$item['ref_id'].'&purchasetype=demo';
$demo_link = $this->ctrl->getLinkTargetByClass('ilshoppurchasegui', 'showDemoVersion').'&purchasetype=demo&ref_id='.$item["ref_id"];
break;
default:
$demo_link = $this->ctrl->getLinkTargetByClass('ilshoppurchasegui', 'showDemoVersion').'&purchasetype=demo&ref_id='.$item["ref_id"];
break;
}
$item['title'] = '<a href="'.$demo_link.'">'.$item["title"].'</a>';
}
$tpl_pinfo = new ilTemplate ('tpl.shop_item_info.html', true, true, 'Services/Payment');
if($item['price_string'] != '')
{
$tpl_pinfo->setCurrentBlock('ploop');
$tpl_pinfo->setVariable('PROPERTY', $this->lng->txt('price_a'));
$tpl_pinfo->setVariable('VALUE', $item['price_string']);
$tpl_pinfo->parseCurrentBlock();
}
if($item['author'] != '')
{
$tpl_pinfo->setCurrentBlock('ploop');
$tpl_pinfo->setVariable('PROPERTY', $this->lng->txt('author'));
$tpl_pinfo->setVariable('VALUE', $item['author']);
$tpl_pinfo->parseCurrentBlock();
}
$oFile = new ilFileDataShop(ilPaymentObject::_lookupPobjectId($item['ref_id']));
if(($webpath_file = $oFile->getCurrentImageWebPath()) !== false)
{
$tpl_pinfo->setCurrentBlock('image');
$tpl_pinfo->setVariable('SRC', $webpath_file);
$tpl_pinfo->setVariable('ALT', strip_tags($item['title']));
$tpl_pinfo->parseCurrentBlock();
}
$item_list_gui->addSubItemHTML($tpl_pinfo->get());
$html = $item_list_gui->getListItemHTML(
$item['ref_id'],
$item['obj_id'],
$item['title'],
$item['description'],
false, false, "",
);
if($html)
{
$html = $this->__appendChildLinks($html, $item, $item_list_gui);
$item_html[$item['ref_id']] = $html;
}
}
// output block for resource type
if(count($item_html) > 0)
{
// separator row
if (!$first)
{
}
$first = false;
// add a header for each resource type
$this->addHeaderRow($tpl, $act_type);
$this->resetRowType();
// content row
foreach($item_html as $ref_id => $html)
{
$this->addStandardRow($tpl, $html, $ref_id);
}
++$items_counter;
}
}
}
if($items_counter > 0)
{
$oContainerTpl->setCurrentBlock('loop');
$oContainerTpl->setVariable('TOPIC_TITLE', $topic['title']);
$oContainerTpl->setVariable('COTAINER_LIST_BLOCK', $tpl->get());
$oContainerTpl->parseCurrentBlock();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilShopResultPresentationGUI::resetRowType ( )

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

Referenced by renderItems().

{
$this->cur_row_type = "";
}

+ Here is the caller graph for this function:

ilShopResultPresentationGUI::setSortDirection (   $a_sort_direction)

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

{
$this->sort_direction = $a_sort_direction;
}
ilShopResultPresentationGUI::setSortField (   $a_sort_field)

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

{
$this->sort_field = $a_sort_field;
}
ilShopResultPresentationGUI::setTypeOrdering (   $a_type_ordering_array)

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

{
$this->type_ordering = $a_type_ordering_array;
}
ilShopResultPresentationGUI::showResults ( )

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

References $results, and renderItemList().

{
// Get results
$results = $this->result->getResultsForPresentation();
$html = $this->renderItemList($results);
return $html;
}

+ Here is the call graph for this function:

ilShopResultPresentationGUI::showSpecials ( )

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

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

{
// Get specials
$oContainerTpl = new ilTemplate ('tpl.shop_container.html', true, true, 'Services/Payment');
include_once './Services/Payment/classes/class.ilShopTopic.php';
include_once './Services/Payment/classes/class.ilShopTopics.php';
ilShopTopics::_getInstance()->setIdFilter(false);
$topic_option = array();
if(count($topics = ilShopTopics::_getInstance()->getTopics()))
{
foreach($topics as $oTopic)
{
$this->renderItems($oContainerTpl, $results, array('id' => $oTopic->getId(), 'title' => $oTopic->getTitle()));
}
$this->renderItems($oContainerTpl, $results, array('id' => 0, 'title' => $this->lng->txt('payment_no_topic')));
}
else
$this->renderItems($oContainerTpl, $results, array('id' => 0, 'title' => $this->lng->txt('payment_no_topic')));
$html = $oContainerTpl->get();
return $html;
}

+ Here is the call graph for this function:

ilShopResultPresentationGUI::sortResult (   $result)

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

References $result, and ilUtil\sortArray().

Referenced by renderItems().

{
if ($this->sort_direction != '' && $this->sort_field != '')
{
switch ($this->sort_field)
{
case 'price':
$numeric_sort = true;
break;
default:
$numeric_sort = false;
break;
}
$result = ilUtil::sortArray($result, $this->sort_field, $this->sort_direction, $numeric_sort);
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilShopResultPresentationGUI::$lng

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

Referenced by ilShopResultPresentationGUI().

ilShopResultPresentationGUI::$result = 0
ilShopResultPresentationGUI::$search_cache = null
protected

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

ilShopResultPresentationGUI::$sort_direction = ''
private

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

Referenced by getSortDirection().

ilShopResultPresentationGUI::$sort_field = ''
private

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

Referenced by getSortField().

ilShopResultPresentationGUI::$tpl

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