ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAbstractBuddySystemRelationStateButtonRenderer.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Contact/BuddySystem/interfaces/interface.ilBuddySystemRelationStateButtonRenderer.php';
5 require_once 'Services/Utilities/classes/class.ilStr.php';
6 
12 {
16  protected $relation;
17 
21  protected $user_id;
22 
26  protected $tpl;
27 
33  {
34  $this->user_id = $user_id;
35  $this->relation = $relation;
36 
37  $this->tpl = new ilTemplate(
38  'tpl.buddy_system_state_' . ilStr::convertUpperCamelCaseToUnderscoreCase($this->relation->getState()->getName()) . '.html',
39  true,
40  true,
41  'Services/Contact/BuddySystem'
42  );
43  }
44 
48  protected function getLanguageVariableSuffix()
49  {
50  if($this->relation->isOwnedByRequest())
51  {
52  $suffix = '_a';
53  }
54  else
55  {
56  $suffix = '_p';
57  }
58  return $suffix;
59  }
60 
64  protected function render()
65  {
66  $this->renderStateButton();
67  $states = $this->relation->getCurrentPossibleTargetStates();
68  foreach($states as $target_state)
69  {
70  $this->renderTargetState($target_state);
71  }
72  }
73 
77  protected function getTemplateVariablePrefix()
78  {
79  return '';
80  }
81 
85  protected function renderStateButton()
86  {
90  global $lng;
91 
92  $state_id = ilStr::convertUpperCamelCaseToUnderscoreCase($this->relation->getState()->getName());
93 
94  $this->tpl->setVariable(
95  $this->getTemplateVariablePrefix() . 'BUTTON_TXT',
96  $lng->txt(
97  'buddy_bs_btn_txt_' . $state_id . $this->getLanguageVariableSuffix()
98  )
99  );
100  }
101 
105  protected function renderTargetState(ilBuddySystemRelationState $target_state)
106  {
110  global $lng;
111 
112  $state_id = ilStr::convertUpperCamelCaseToUnderscoreCase($this->relation->getState()->getName());
113  $target_state_id = ilStr::convertUpperCamelCaseToUnderscoreCase($target_state->getName());
114 
115  $this->tpl->setVariable(
116  $this->getTemplateVariablePrefix() . 'TARGET_STATE_' . strtoupper($target_state_id),
117  get_class($target_state)
118  );
119  $this->tpl->setVariable(
120  $this->getTemplateVariablePrefix() . 'TARGET_STATE_ACTION_' . strtoupper($target_state_id),
121  $target_state->getAction()
122  );
123  $this->tpl->setVariable(
124  $this->getTemplateVariablePrefix() . 'TARGET_STATE_TXT_' . strtoupper($target_state_id),
125  $lng->txt(
126  'buddy_bs_act_btn_txt_' . $state_id . '_to_' . $target_state_id
127  )
128  );
129  }
130 
134  public function getHtml()
135  {
136  $this->render();
137  return $this->tpl->get();
138  }
139 }
static convertUpperCamelCaseToUnderscoreCase($value)
Convert a value given in camel case conversion to underscore case conversion (e.g.
Interface ilBuddySystemRelationStateButtonRenderer.
special template class to simplify handling of ITX/PEAR
Class ilBuddySystemRelation.
global $lng
Definition: privfeed.php:40
Interface ilBuddySystemRelationState.