ILIAS  eassessment Revision 61809
 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 ()
 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 16 of file class.ilShopResultPresentationGUI.php.

Member Function Documentation

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

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

References $tpl, ilLink\_getLink(), ilGlossaryTerm\_lookGlossaryTerm(), ilLMObject\_lookupTitle(), ilNewsItem\_lookupTitle(), and ilLMObject\_lookupType().

Referenced by renderItems().

{
if(!count($item['child']))
{
return $html;
}
$tpl = new ilTemplate('tpl.detail_links.html',true,true,'Services/Search');
$tpl->setVariable("HITS",$this->lng->txt('search_hits'));
switch($item['type'])
{
case 'lm':
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 'glo':
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 'mcst':
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 325 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 350 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 286 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 77 of file class.ilShopResultPresentationGUI.php.

References $sort_direction.

{
}
ilShopResultPresentationGUI::getSortField ( )

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

References $sort_field.

{
}
ilShopResultPresentationGUI::getTypeOrdering ( )

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

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

Definition at line 29 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", "lres",
"glo", "webr", "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 309 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 264 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 102 of file class.ilShopResultPresentationGUI.php.

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

Referenced by renderItemList().

{
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)
{
$oPaymentObject =
new ilPaymentObject($ilUser, ilPaymentObject::_lookupPobjectId($item['ref_id']));
$oPrice = new ilPaymentPrices($oPaymentObject->getPobjectId());
$lowest_price = $oPrice->getLowestPrice();
$results[$topic['id']][$act_type][$key]['price'] = $lowest_price['price'];
$results[$topic['id']][$act_type][$key]['price_string'] =
($oPrice->getNumberOfPrices() > 1 ? $this->lng->txt('price_from').' ' : '').
ilPaymentPrices::_formatPriceToString($lowest_price['price']);
// 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->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(false);
$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);
}
$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', $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']
);
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 431 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 73 of file class.ilShopResultPresentationGUI.php.

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

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

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

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

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

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

References $results, and renderItemList().

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

+ Here is the call graph for this function:

ilShopResultPresentationGUI::sortResult (   $result)

Definition at line 82 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 21 of file class.ilShopResultPresentationGUI.php.

Referenced by ilShopResultPresentationGUI().

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

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

ilShopResultPresentationGUI::$sort_direction = ''
private

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

Referenced by getSortDirection().

ilShopResultPresentationGUI::$sort_field = ''
private

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

Referenced by getSortField().

ilShopResultPresentationGUI::$tpl

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