ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilPDPortfolioBlockGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once 'Services/Block/classes/class.ilBlockGUI.php';
6 
15 {
16  static $block_type = 'pdportf';
17  protected $default_portfolio = 0;
18 
22  public function __construct()
23  {
24  global $lng;
25 
26  parent::__construct();
27 
28  $this->setLimit(5);
29  $this->setAvailableDetailLevels(2);
30  }
31 
36  static function getBlockType()
37  {
38  return self::$block_type;
39  }
40 
45  static function isRepositoryObject()
46  {
47  return false;
48  }
49 
53  static function getScreenMode()
54  {
55  switch($_GET['cmd'])
56  {
57  case '...':
58  return IL_SCREEN_CENTER;
59  break;
60 
61  default:
62  return IL_SCREEN_SIDE;
63  break;
64  }
65  }
66 
70  public function executeCommand()
71  {
72  global $ilCtrl;
73 
74  $cmd = $ilCtrl->getCmd('getHTML');
75 
76  return $this->$cmd();
77  }
78 
82  public function getHTML()
83  {
84  global $lng, $ilCtrl, $ilSetting, $ilUser;
85 
86  if (!$ilSetting->get('user_portfolios'))
87  {
88  return '';
89  }
90 
91  if($this->getCurrentDetailLevel() == 0)
92  {
93  return '';
94  }
95  else
96  {
97  include_once("./Modules/Portfolio/classes/class.ilObjPortfolio.php");
98  $this->default_portfolio = ilObjPortfolio::getDefaultPortfolio($ilUser->getId());
99 
100  $lng->loadLanguageModule("prtf");
101  $this->setTitle($lng->txt('prtf_tab_portfolios'));
102  $this->addBlockCommand($ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui"), ""),
103  $lng->txt("prtf_manage_portfolios"));
104  $this->addBlockCommand($ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui", "ilobjportfoliogui"), "create"),
105  $lng->txt("prtf_add_portfolio"));
106 
107  $html = parent::getHTML();
108  return $html;
109  }
110  }
111 
115  public function fillDataSection()
116  {
117  global $ilUser;
118 
119  include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
120  $data = ilObjPortfolio::getPortfoliosOfUser($ilUser->getId());
121  $this->setData($data);
122 
123  if($this->getCurrentDetailLevel() > 1 && count($this->getData()) > 0)
124  {
125  $this->setRowTemplate("tpl.pd_portf_block_row.html", "Modules/Portfolio");
126  if($this->getCurrentDetailLevel() > 2)
127  {
128  $this->setColSpan(2);
129  }
130  parent::fillDataSection();
131  }
132  else
133  {
134  $this->setEnableNumInfo(false);
135  if (count($this->getData()) == 0)
136  {
137  $this->setEnableDetailRow(false);
138  }
139  $this->setDataSection($this->getOverview());
140  }
141  }
142 
146  public function fillRow($p)
147  {
148  global $ilCtrl, $lng;
149 
150  if($this->getCurrentDetailLevel() > 1)
151  {
152  $ilCtrl->setParameterByClass("ilobjportfoliogui", "prt_id", $p["id"]);
153  $this->tpl->setVariable("HREF", $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui", "ilobjportfoliogui"), "preview"));
154  $this->tpl->setVariable("TITLE", trim($p["title"]));
155 
156  if ($this->default_portfolio == $p["id"])
157  {
158  // #16490
159  $this->tpl->setVariable("DESC", $lng->txt("prtf_default_portfolio"));
160  }
161 
162  $ilCtrl->setParameterByClass("ilobjportfoliogui", "prt_id", "");
163  }
164  }
165 
169  protected function getOverview()
170  {
171  global $lng, $ilCtrl;
172 
173  if (count($this->getData()) == 0)
174  {
175  // ilias.php?cmd=create&cmdClass=ilobjportfoliogui&cmdNode=5f:o8:oh&baseClass=ilPersonalDesktopGUI
176  return '<div class="small"><a href="'.
177  $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui", "ilobjportfoliogui"), "create").
178  '">'.$lng->txt("prtf_add_portfolio").'</a></div>';
179  }
180  else
181  {
182  $t = (count($this->getData()) == 1)
183  ? $lng->txt("obj_prtf")
184  : $lng->txt("prtf_portfolios");
185  return '<div class="small"><a href="'.
186  $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui"), "").
187  '">'.((int)count($this->getData()))." ".$t."</a></div>";
188  }
189  }
190 
191 }
192 ?>
fillRow($p)
get flat bookmark list for personal desktop
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
$_GET["client_id"]
static getPortfoliosOfUser($a_user_id)
Get views of user.
$cmd
Definition: sahs_server.php:35
addBlockCommand($a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false, $a_html="")
Add Block Command.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
static isRepositoryObject()
Get block type.
global $ilCtrl
Definition: ilias.php:18
setColSpan($a_colspan)
Set Columns Span.
setTitle($a_title)
Set Title.
static getBlockType()
Get block type.
setData($a_data)
Set Data.
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
$ilUser
Definition: imgupload.php:18
const IL_SCREEN_CENTER
Create styles array
The data for the language used.
fillDataSection()
Fill data section.
getData()
Get Data.
setLimit($a_limit)
Set Limit.
static getScreenMode()
Get Screen Mode for current command.
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
static getDefaultPortfolio($a_user_id)
Get default portfolio of user.
This class represents a block method of a block.
const IL_SCREEN_SIDE
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setEnableDetailRow($a_enabledetailrow)
Set EnableDetailRow.
$html
Definition: example_001.php:87
getCurrentDetailLevel()
Get Current Detail Level.