ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilParameterAppender Class Reference

Class ilParameterAppender. More...

+ Collaboration diagram for ilParameterAppender:

Public Member Functions

 __construct ($webr_id)
 Constructor public. More...
 
 getErrorCode ()
 
 setObjId ($a_obj_id)
 
 getObjId ()
 
 setName ($a_name)
 
 getName ()
 
 setValue ($a_value)
 
 getValue ()
 
 validate ()
 
 add ($a_link_id)
 
 delete ($a_param_id)
 

Static Public Member Functions

static getParameterIds ($a_webr_id, $a_link_id)
 Get Parameter ids of link. More...
 
static _isEnabled ()
 Check if dynamic parameters are enabled. More...
 
static _append ($a_link_data)
 
static _getParams ($a_link_id)
 Get dynamic parameter definitions. More...
 
static parameterToInfo ($a_name, $a_value)
 Get info text describing an existing dynamic link. More...
 
static _deleteAll ($a_webr_id)
 
static _getOptionSelect ()
 Get options as array. More...
 

Data Fields

 $webr_id = null
 
 $db = null
 
 $err = null
 

Detailed Description

Class ilParameterAppender.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 42 of file class.ilParameterAppender.php.

Constructor & Destructor Documentation

◆ __construct()

ilParameterAppender::__construct (   $webr_id)

Constructor public.

Definition at line 54 of file class.ilParameterAppender.php.

References $ilDB, and $webr_id.

55  {
56  global $ilDB;
57 
58  $this->webr_id = $webr_id;
59  $this->db = $ilDB;
60  }
global $ilDB

Member Function Documentation

◆ _append()

static ilParameterAppender::_append (   $a_link_data)
static

Definition at line 186 of file class.ilParameterAppender.php.

References $ilUser, $params, _getParams(), LINKS_LOGIN, LINKS_MATRICULATION, LINKS_SESSION_ID, and LINKS_USER_ID.

Referenced by ilObjLinkResourceListGUI\__readLink(), ilObjLinkResourceGUI\callDirectLink(), ilObjLinkResourceGUI\callLink(), and ilObjLinkResourceSubItemListGUI\getHTML().

187  {
188  global $ilUser;
189 
190  if(!is_array($a_link_data))
191  {
192  return false;
193  }
194  if(count($params = ilParameterAppender::_getParams($a_link_data['link_id'])))
195  {
196  // Check for prefix
197  foreach($params as $param_data)
198  {
199  if(!strpos($a_link_data['target'],'?'))
200  {
201  $a_link_data['target'] .= "?";
202  }
203  else
204  {
205  $a_link_data['target'] .= "&";
206  }
207  $a_link_data['target'] .= ($param_data['name']."=");
208  switch($param_data['value'])
209  {
210  case LINKS_LOGIN:
211  $a_link_data['target'] .= (urlencode($ilUser->getLogin()));
212  break;
213 
214  case LINKS_SESSION_ID:
215  $a_link_data['target'] .= (session_id());
216  break;
217 
218  case LINKS_USER_ID:
219  $a_link_data['target'] .= ($ilUser->getId());
220  break;
221 
222  case LINKS_MATRICULATION:
223  $a_link_data['target'] .= ($ilUser->getMatriculation());
224  break;
225  }
226  }
227  }
228  return $a_link_data;
229  }
const LINKS_MATRICULATION
const LINKS_LOGIN
$ilUser
Definition: imgupload.php:18
const LINKS_USER_ID
static _getParams($a_link_id)
Get dynamic parameter definitions.
$params
Definition: example_049.php:96
const LINKS_SESSION_ID
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteAll()

static ilParameterAppender::_deleteAll (   $a_webr_id)
static

Definition at line 278 of file class.ilParameterAppender.php.

References $ilDB, $query, and $res.

279  {
280  global $ilDB;
281 
282  $query = "DELETE FROM webr_params WHERE webr_id = ".
283  $ilDB->quote((int) $a_webr_id ,'integer');
284  $res = $ilDB->manipulate($query);
285 
286  return true;
287  }
global $ilDB

◆ _getOptionSelect()

static ilParameterAppender::_getOptionSelect ( )
static

Get options as array.

Returns

Definition at line 293 of file class.ilParameterAppender.php.

References $lng, array, LINKS_LOGIN, LINKS_MATRICULATION, LINKS_SESSION_ID, and LINKS_USER_ID.

Referenced by ilWebResourceEditableLinkTableGUI\fillRow(), and ilObjLinkResourceGUI\initFormLink().

294  {
295  global $lng;
296 
297  return array(0 => $lng->txt('links_select_one'),
298  LINKS_USER_ID => $lng->txt('links_user_id'),
299  LINKS_LOGIN => $lng->txt('links_user_name'),
300  LINKS_SESSION_ID => $lng->txt('links_session_id'),
301  LINKS_MATRICULATION => $lng->txt('matriculation')
302  );
303  }
const LINKS_MATRICULATION
const LINKS_LOGIN
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
const LINKS_USER_ID
const LINKS_SESSION_ID
+ Here is the caller graph for this function:

◆ _getParams()

static ilParameterAppender::_getParams (   $a_link_id)
static

Get dynamic parameter definitions.

Parameters
int$a_link_id
Returns

Definition at line 236 of file class.ilParameterAppender.php.

References $ilDB, $params, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by _append(), ilLinkResourceItems\cloneItems(), ilObjLinkResourceGUI\initFormLink(), ilWebResourceEditableLinkTableGUI\parse(), ilwebresourceTest\testWebResourceParameters(), and ilLinkResourceItems\toXML().

237  {
238  global $ilDB;
239 
240  $res = $ilDB->query("SELECT * FROM webr_params WHERE link_id = ".
241  $ilDB->quote((int) $a_link_id ,'integer'));
242  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
243  {
244  $params[$row->param_id]['name'] = $row->name;
245  $params[$row->param_id]['value'] = $row->value;
246  }
247 
248  return count($params) ? $params : array();
249  }
Create styles array
The data for the language used.
global $ilDB
$params
Definition: example_049.php:96
+ Here is the caller graph for this function:

◆ _isEnabled()

static ilParameterAppender::_isEnabled ( )
static

Check if dynamic parameters are enabled.

Returns

Definition at line 179 of file class.ilParameterAppender.php.

References $ilSetting.

Referenced by ilObjLinkResourceListGUI\__readLink(), ilObjLinkResourceGUI\callDirectLink(), ilObjLinkResourceGUI\callLink(), ilObjLinkResourceGUI\checkLinkInput(), ilWebResourceEditableLinkTableGUI\fillRow(), ilObjLinkResourceGUI\initFormLink(), ilObjLinkResourceGUI\saveAddLink(), ilObjLinkResourceGUI\setValuesFromLink(), and ilObjLinkResourceGUI\updateLink().

180  {
181  global $ilSetting;
182 
183  return $ilSetting->get('links_dynamic',false) ? true : false;
184  }
global $ilSetting
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ add()

ilParameterAppender::add (   $a_link_id)

Definition at line 137 of file class.ilParameterAppender.php.

References $ilDB, $query, $res, getName(), getObjId(), and getValue().

138  {
139  global $ilDB;
140 
141  if(!$a_link_id)
142  {
143  return false;
144  }
145  if(!strlen($this->getName() or !strlen($this->getValue())))
146  {
147  return false;
148  }
149 
150  $next_id = $ilDB->nextId('webr_params');
151  $query = "INSERT INTO webr_params (param_id,webr_id,link_id,name,value) ".
152  "VALUES( ".
153  $ilDB->quote($next_id,'integer').", ".
154  $ilDB->quote($this->getObjId() ,'integer').", ".
155  $ilDB->quote($a_link_id ,'integer').", ".
156  $ilDB->quote($this->getName() ,'text').", ".
157  $ilDB->quote($this->getValue() ,'integer').
158  ")";
159  $res = $ilDB->manipulate($query);
160 
161  return $next_id;
162  }
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilParameterAppender::delete (   $a_param_id)

Definition at line 164 of file class.ilParameterAppender.php.

References $ilDB, $query, $res, and getObjId().

Referenced by ilObjLinkResourceGUI\deleteParameter(), and ilObjLinkResourceGUI\deleteParameterForm().

165  {
166  global $ilDB;
167 
168  $query = "DELETE FROM webr_params ".
169  "WHERE param_id = ".$ilDB->quote($a_param_id ,'integer')." ".
170  "AND webr_id = ".$ilDB->quote($this->getObjId(),'integer');
171  $res = $ilDB->manipulate($query);
172  return true;
173  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorCode()

ilParameterAppender::getErrorCode ( )

Definition at line 83 of file class.ilParameterAppender.php.

References $err.

84  {
85  return $this->err;
86  }

◆ getName()

ilParameterAppender::getName ( )

Definition at line 103 of file class.ilParameterAppender.php.

Referenced by add(), and validate().

104  {
105  return $this->name;
106  }
+ Here is the caller graph for this function:

◆ getObjId()

ilParameterAppender::getObjId ( )

Definition at line 94 of file class.ilParameterAppender.php.

References $webr_id.

Referenced by add(), and delete().

+ Here is the caller graph for this function:

◆ getParameterIds()

static ilParameterAppender::getParameterIds (   $a_webr_id,
  $a_link_id 
)
static

Get Parameter ids of link.

Parameters
int$a_webr_id
int$a_link_id
Returns

Definition at line 68 of file class.ilParameterAppender.php.

References $ilDB, $params, $query, $res, $row, array, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilWebLinkXmlParser\handlerBeginTag().

69  {
70  global $ilDB;
71 
72  $query = "SELECT * FROM webr_params ".
73  "WHERE webr_id = ".$ilDB->quote($a_webr_id,'integer')." ".
74  "AND link_id = ".$ilDB->quote($a_link_id,'integer');
75  $res = $ilDB->query($query);
76  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
77  {
78  $params[] = $row['param_id'];
79  }
80  return (array) $params;
81  }
Create styles array
The data for the language used.
global $ilDB
$params
Definition: example_049.php:96
+ Here is the caller graph for this function:

◆ getValue()

ilParameterAppender::getValue ( )

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

Referenced by add(), and validate().

112  {
113  return $this->value;
114  }
+ Here is the caller graph for this function:

◆ parameterToInfo()

static ilParameterAppender::parameterToInfo (   $a_name,
  $a_value 
)
static

Get info text describing an existing dynamic link.

Parameters
string$a_name
int$a_value
Returns

Definition at line 257 of file class.ilParameterAppender.php.

References $info, LINKS_LOGIN, LINKS_MATRICULATION, LINKS_SESSION_ID, and LINKS_USER_ID.

Referenced by ilWebResourceEditableLinkTableGUI\fillRow(), and ilObjLinkResourceGUI\initFormLink().

258  {
259  $info = $a_name;
260 
261  switch($a_value)
262  {
263  case LINKS_USER_ID:
264  return $info.'=USER_ID';
265 
266  case LINKS_SESSION_ID:
267  return $info.'=SESSION_ID';
268 
269  case LINKS_LOGIN:
270  return $info.'=LOGIN';
271 
272  case LINKS_MATRICULATION:
273  return $info.'=MATRICULATION';
274  }
275  return '';
276  }
const LINKS_MATRICULATION
const LINKS_LOGIN
$info
Definition: example_052.php:80
const LINKS_USER_ID
const LINKS_SESSION_ID
+ Here is the caller graph for this function:

◆ setName()

ilParameterAppender::setName (   $a_name)

Definition at line 99 of file class.ilParameterAppender.php.

Referenced by ilObjLinkResourceGUI\updateLinks().

100  {
101  $this->name = $a_name;
102  }
+ Here is the caller graph for this function:

◆ setObjId()

ilParameterAppender::setObjId (   $a_obj_id)

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

90  {
91  $this->webr_id = $a_obj_id;
92  }

◆ setValue()

ilParameterAppender::setValue (   $a_value)

Definition at line 107 of file class.ilParameterAppender.php.

108  {
109  $this->value = $a_value;
110  }

◆ validate()

ilParameterAppender::validate ( )

Definition at line 116 of file class.ilParameterAppender.php.

References getName(), getValue(), LINKS_ERR_NO_NAME, LINKS_ERR_NO_NAME_VALUE, and LINKS_ERR_NO_VALUE.

117  {
118  if(!strlen($this->getName()) and !$this->getValue())
119  {
120  $this->err = LINKS_ERR_NO_NAME_VALUE;
121  return false;
122  }
123  if(!strlen($this->getName()))
124  {
125  $this->err = LINKS_ERR_NO_NAME;
126  return false;
127  }
128  if(!$this->getValue())
129  {
130  $this->err = LINKS_ERR_NO_VALUE;
131  return false;
132  }
133  return true;
134  }
const LINKS_ERR_NO_VALUE
const LINKS_ERR_NO_NAME
const LINKS_ERR_NO_NAME_VALUE
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilParameterAppender::$db = null

Definition at line 45 of file class.ilParameterAppender.php.

◆ $err

ilParameterAppender::$err = null

Definition at line 47 of file class.ilParameterAppender.php.

Referenced by getErrorCode().

◆ $webr_id

ilParameterAppender::$webr_id = null

Definition at line 44 of file class.ilParameterAppender.php.

Referenced by __construct(), and getObjId().


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