ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilParameterAppender Class Reference

Class ilParameterAppender. More...

+ Collaboration diagram for ilParameterAppender:

Public Member Functions

 __construct ($webr_id)
 Constructor @access 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 @access public.

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

55 {
56 global $DIC;
57
58 $ilDB = $DIC['ilDB'];
59
60 $this->webr_id = $webr_id;
61 $this->db = $ilDB;
62 }
global $ilDB
$DIC
Definition: xapitoken.php:46

References $DIC, $ilDB, and $webr_id.

Member Function Documentation

◆ _append()

static ilParameterAppender::_append (   $a_link_data)
static

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

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

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

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

+ 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 279 of file class.ilParameterAppender.php.

280 {
281 global $DIC;
282
283 $ilDB = $DIC['ilDB'];
284
285 $query = "DELETE FROM webr_params WHERE webr_id = " .
286 $ilDB->quote((int) $a_webr_id, 'integer');
287 $res = $ilDB->manipulate($query);
288
289 return true;
290 }
$query
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $query, and $res.

◆ _getOptionSelect()

static ilParameterAppender::_getOptionSelect ( )
static

Get options as array.

Returns

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

297 {
298 global $DIC;
299
300 $lng = $DIC['lng'];
301
302 return array(0 => $lng->txt('links_select_one'),
303 LINKS_USER_ID => $lng->txt('links_user_id'),
304 LINKS_LOGIN => $lng->txt('links_user_name'),
305 LINKS_SESSION_ID => $lng->txt('links_session_id'),
306 LINKS_MATRICULATION => $lng->txt('matriculation')
307 );
308 }
$lng

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

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

+ 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 235 of file class.ilParameterAppender.php.

236 {
237 global $DIC;
238
239 $ilDB = $DIC['ilDB'];
240
241 $params = [];
242
243 $res = $ilDB->query("SELECT * FROM webr_params WHERE link_id = " .
244 $ilDB->quote((int) $a_link_id, 'integer'));
245 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
246 $params[$row->param_id]['name'] = $row->name;
247 $params[$row->param_id]['value'] = $row->value;
248 }
249
250 return $params;
251 }

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

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

+ Here is the caller graph for this function:

◆ _isEnabled()

static ilParameterAppender::_isEnabled ( )
static

Check if dynamic parameters are enabled.

Returns

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

182 {
183 global $DIC;
184
185 $ilSetting = $DIC['ilSetting'];
186
187 return $ilSetting->get('links_dynamic', false) ? true : false;
188 }
global $ilSetting
Definition: privfeed.php:17

References $DIC, and $ilSetting.

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

+ Here is the caller graph for this function:

◆ add()

ilParameterAppender::add (   $a_link_id)

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

138 {
139 global $DIC;
140
141 $ilDB = $DIC['ilDB'];
142
143 if (!$a_link_id) {
144 return false;
145 }
146 if (!strlen($this->getName() or !strlen($this->getValue()))) {
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 }

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

+ Here is the call graph for this function:

◆ delete()

ilParameterAppender::delete (   $a_param_id)

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

165 {
166 global $DIC;
167
168 $ilDB = $DIC['ilDB'];
169
170 $query = "DELETE FROM webr_params " .
171 "WHERE param_id = " . $ilDB->quote($a_param_id, 'integer') . " " .
172 "AND webr_id = " . $ilDB->quote($this->getObjId(), 'integer');
173 $res = $ilDB->manipulate($query);
174 return true;
175 }

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

+ Here is the call graph for this function:

◆ getErrorCode()

ilParameterAppender::getErrorCode ( )

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

References $err.

◆ getName()

ilParameterAppender::getName ( )

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

107 {
108 return $this->name;
109 }
if($format !==null) $name
Definition: metadata.php:230

References $name.

Referenced by add(), and validate().

+ Here is the caller graph for this function:

◆ getObjId()

ilParameterAppender::getObjId ( )

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

98 {
99 return $this->webr_id;
100 }

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 70 of file class.ilParameterAppender.php.

71 {
72 global $DIC;
73
74 $ilDB = $DIC['ilDB'];
75
76 $query = "SELECT * FROM webr_params " .
77 "WHERE webr_id = " . $ilDB->quote($a_webr_id, 'integer') . " " .
78 "AND link_id = " . $ilDB->quote($a_link_id, 'integer');
79 $res = $ilDB->query($query);
80 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
81 $params[] = $row['param_id'];
82 }
83 return (array) $params;
84 }

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilWebLinkXmlParser\handlerBeginTag().

+ Here is the caller graph for this function:

◆ getValue()

ilParameterAppender::getValue ( )

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

115 {
116 return $this->value;
117 }

Referenced by add(), and validate().

+ 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 259 of file class.ilParameterAppender.php.

260 {
261 $info = $a_name;
262
263 switch ($a_value) {
264 case LINKS_USER_ID:
265 return $info . '=USER_ID';
266
267 case LINKS_SESSION_ID:
268 return $info . '=SESSION_ID';
269
270 case LINKS_LOGIN:
271 return $info . '=LOGIN';
272
274 return $info . '=MATRICULATION';
275 }
276 return '';
277 }

References LINKS_LOGIN, LINKS_MATRICULATION, LINKS_SESSION_ID, and LINKS_USER_ID.

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

+ Here is the caller graph for this function:

◆ setName()

ilParameterAppender::setName (   $a_name)

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

103 {
104 $this->name = $a_name;
105 }

◆ setObjId()

ilParameterAppender::setObjId (   $a_obj_id)

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

93 {
94 $this->webr_id = $a_obj_id;
95 }

◆ setValue()

ilParameterAppender::setValue (   $a_value)

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

111 {
112 $this->value = $a_value;
113 }

◆ validate()

ilParameterAppender::validate ( )

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

120 {
121 if (!strlen($this->getName()) and !$this->getValue()) {
122 $this->err = LINKS_ERR_NO_NAME_VALUE;
123 return false;
124 }
125 if (!strlen($this->getName())) {
126 $this->err = LINKS_ERR_NO_NAME;
127 return false;
128 }
129 if (!$this->getValue()) {
130 $this->err = LINKS_ERR_NO_VALUE;
131 return false;
132 }
133 return true;
134 }
const LINKS_ERR_NO_NAME
const LINKS_ERR_NO_VALUE
const LINKS_ERR_NO_NAME_VALUE

References getName(), getValue(), LINKS_ERR_NO_NAME, LINKS_ERR_NO_NAME_VALUE, and LINKS_ERR_NO_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: