ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilPCSection Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilPCSection:
+ Collaboration diagram for ilPCSection:

Public Member Functions

 init ()
 Init object. More...
 
 create (ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
 
 setCharacteristic (string $a_char)
 
 getCharacteristic ()
 
 modifyPageContentPostXsl (string $a_output, string $a_mode, bool $a_abstract_only=false)
 
 setActiveFrom (int $a_unix_ts)
 
 getActiveFrom ()
 Get activation from. More...
 
 setActiveTo (int $a_unix_ts)
 Set activation to. More...
 
 getActiveTo ()
 
 setPermission (string $a_val)
 Set permission. More...
 
 getPermission ()
 
 setPermissionRefId (int $a_ref_id)
 
 getPermissionRefId ()
 
 setNoLink ()
 Set no link. More...
 
 setExtLink (string $a_href)
 Set link of area to an external one. More...
 
 setIntLink (string $a_type, string $a_target, string $a_target_frame, string $a_anchor="")
 Set link of area to an internal one. More...
 
 getLink ()
 
 handleAccess (string $a_html, string $a_mode)
 
 insertTimings (string $a_html)
 Insert timings (in edit mode) More...
 
 getProtected ()
 
 setProtected (bool $val)
 
 getModel ()
 Get model as needed for the front-end editor. More...
 
- Public Member Functions inherited from ilPageContent
 __construct (ilPageObject $a_pg_obj, ?PageManagerInterface $page_manager=null, ?ObjectAdapterInterface $object_adapter=null)
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 init ()
 Init object. More...
 
 getType ()
 
 getDomNode ()
 
 getDomDoc ()
 
 setDomNode (DOMNode $node)
 
 getChildNode ()
 
 getJavascriptFiles (string $a_mode)
 
 getCssFiles (string $a_mode)
 
 getOnloadCode (string $a_mode)
 
 setHierId (string $a_hier_id)
 
 getHierId ()
 
 lookupHierId ()
 
 readHierId ()
 
 setPcId (string $a_pcid)
 
 getPCId ()
 
 setFileDownloadLink (string $a_download_link)
 
 getFileDownloadLink ()
 
 setProfileBackUrl (string $url)
 
 getProfileBackUrl ()
 
 setFullscreenLink (string $a_fullscreen_link)
 
 getFullscreenLink ()
 
 setSourcecodeDownloadScript (string $script_name)
 
 getSourcecodeDownloadScript ()
 
 readPCId ()
 
 writePCId (string $a_pc_id)
 
 setEnabled (string $value)
 Set Enabled value for page content component. More...
 
 enable ()
 
 disable ()
 
 isEnabled ()
 
 createPageContentNode (bool $a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 getNewPageContentNode ()
 
 modifyPageContentPostXsl (string $a_output, string $a_mode, bool $a_abstract_only=false)
 Modify page content after xsl. More...
 
 getModel ()
 Get model as needed for the front-end editor. More...
 

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing. More...
 
static afterPageUpdate (ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
 After page has been updated (or created) More...
 
static saveTimings (ilPageObject $a_page)
 
static getCacheTriggerString (ilPageObject $a_page)
 Get page cache update trigger string. More...
 
- Static Public Member Functions inherited from ilPageContent
static sortHierIds (array $a_array)
 Sort an array of Hier IDS in ascending order. More...
 
static isGreaterHierId (string $a, string $b)
 Check whether Hier ID $a is greater than Hier ID $b. More...
 
static getLangVars ()
 Get lang vars needed for editing. More...
 
static handleCopiedContent (DOMDocument $a_domdoc, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
 Handle copied content. More...
 
static afterPageUpdate (ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete (ilPageObject $a_page)
 Before page is being deleted. More...
 
static afterRepositoryCopy (ilPageObject $page, array $mapping, int $source_ref_id)
 After repository (container) copy action. More...
 
static afterPageHistoryEntry (ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
 After page history entry has been created. More...
 
static deleteHistoryLowerEqualThan (string $parent_type, int $page_id, string $lang, int $delete_lower_than_nr)
 Overwrite in derived classes, if old history entries are being deleted. More...
 

Protected Attributes

ilAccessHandler $access
 
ilCtrl $ctrl
 
ilLanguage $lng
 
- Protected Attributes inherited from ilPageContent
DOMDocument $dom_doc
 
ILIAS COPage InternalDomainService $domain
 
string $pcid
 
string $type = ""
 
ilPageObject $pg_obj
 
string $file_download_link = ''
 
string $fullscreen_link = ''
 
string $sourcecode_download_script = ''
 
ilLogger $log
 
string $profile_back_url = ""
 
ILIAS COPage Dom DomUtil $dom_util
 
PageManagerInterface $page_manager = null
 
ObjectAdapterInterface $object = null
 

Additional Inherited Members

- Data Fields inherited from ilPageContent
string $hier_id = ""
 
DOMNode $dom_node = null
 
string $page_lang = ""
 
- Protected Member Functions inherited from ilPageContent
 getPageManager ()
 
 setType (string $a_type)
 Set Type. More...
 
 hasNode ()
 
 createInitialChildNode (string $hier_id, string $pc_id, string $child, array $child_attributes=[])
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilPCSection Section content object (see ILIAS DTD)

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 24 of file class.ilPCSection.php.

Member Function Documentation

◆ afterPageUpdate()

static ilPCSection::afterPageUpdate ( ilPageObject  $a_page,
DOMDocument  $a_domdoc,
string  $a_xml,
bool  $a_creation 
)
static

After page has been updated (or created)

Reimplemented from ilPageContent.

Definition at line 78 of file class.ilPCSection.php.

83 : void {
84 self::saveTimings($a_page);
85 }
static saveTimings(ilPageObject $a_page)

◆ create()

ilPCSection::create ( ilPageObject  $a_pg_obj,
string  $a_hier_id,
string  $a_pc_id = "" 
)

Definition at line 40 of file class.ilPCSection.php.

44 : void {
46 $a_hier_id,
47 $a_pc_id,
48 "Section",
49 ["Characteristic" => "Block"]
50 );
51 }
createInitialChildNode(string $hier_id, string $pc_id, string $child, array $child_attributes=[])

◆ getActiveFrom()

ilPCSection::getActiveFrom ( )

Get activation from.

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

110 : int
111 {
112 if (is_object($this->getChildNode())) {
113 return (int) $this->getChildNode()->getAttribute("ActiveFrom");
114 }
115 return 0;
116 }

◆ getActiveTo()

ilPCSection::getActiveTo ( )

Definition at line 127 of file class.ilPCSection.php.

127 : int
128 {
129 if (is_object($this->getChildNode())) {
130 return (int) $this->getChildNode()->getAttribute("ActiveTo");
131 }
132 return 0;
133 }

◆ getCacheTriggerString()

static ilPCSection::getCacheTriggerString ( ilPageObject  $a_page)
static

Get page cache update trigger string.

Returns
string trigger string
Exceptions
ilDateTimeException

Definition at line 322 of file class.ilPCSection.php.

324 : string {
325 global $DIC;
326
327 $ilDB = $DIC->database();
328
329 $set = $ilDB->query(
330 "SELECT * FROM copg_section_timings " .
331 " WHERE page_id = " . $ilDB->quote($a_page->getId(), "integer") .
332 " AND parent_type = " . $ilDB->quote($a_page->getParentType(), "text")
333 );
334 $str = "1"; // changed to 1 to force cache miss for #24277
335 $current_ts = new ilDateTime(time(), IL_CAL_UNIX);
336 $current_ts = $current_ts->get(IL_CAL_UNIX);
337 while ($rec = $ilDB->fetchAssoc($set)) {
338 $unix_ts = $rec["unix_ts"];
339 if ($unix_ts < $current_ts) {
340 $unix_ts .= "a";
341 }
342 $str .= "-" . $unix_ts;
343 }
344
345 return $str;
346 }
const IL_CAL_UNIX
@classDescription Date and time handling
global $DIC
Definition: shib_login.php:26

Referenced by ilPageObjectGUI\showPage().

+ Here is the caller graph for this function:

◆ getCharacteristic()

ilPCSection::getCharacteristic ( )

Definition at line 58 of file class.ilPCSection.php.

58 : string
59 {
60 if (is_object($this->getChildNode())) {
61 $char = $this->getChildNode()->getAttribute("Characteristic");
62 if (substr($char, 0, 4) == "ilc_") {
63 $char = substr($char, 4);
64 }
65 return $char;
66 }
67 return "";
68 }

◆ getLangVars()

static ilPCSection::getLangVars ( )
static

Get lang vars needed for editing.

Returns
string[] array of lang var keys

Reimplemented from ilPageContent.

Definition at line 70 of file class.ilPCSection.php.

70 : array
71 {
72 return array("ed_insert_section");
73 }

◆ getLink()

ilPCSection::getLink ( )

Definition at line 213 of file class.ilPCSection.php.

213 : array
214 {
215 $childs = $this->getChildNode()->childNodes;
216 foreach ($childs as $child) {
217 if ($child->nodeName === "ExtLink") {
218 return array("LinkType" => "ExtLink",
219 "Href" => $child->getAttribute("Href"));
220 }
221 if ($child->nodeName === "IntLink") {
222 return array("LinkType" => "IntLink",
223 "Target" => $child->getAttribute("Target"),
224 "Type" => $child->getAttribute("Type"),
225 "TargetFrame" => $child->getAttribute("TargetFrame"),
226 "Anchor" => $child->getAttribute("Anchor")
227 );
228 }
229 }
230 return array("LinkType" => "NoLink");
231 }

◆ getModel()

ilPCSection::getModel ( )

Get model as needed for the front-end editor.

Reimplemented from ilPageContent.

Definition at line 412 of file class.ilPCSection.php.

412 : ?stdClass
413 {
414 if ($this->getChildNode()->nodeName !== "Section") {
415 return null;
416 }
417 $model = new stdClass();
418 $model->protected = $this->getProtected();
419
420 return $model;
421 }

◆ getPermission()

ilPCSection::getPermission ( )

Definition at line 144 of file class.ilPCSection.php.

144 : string
145 {
146 return $this->getChildNode()->getAttribute("Permission");
147 }

◆ getPermissionRefId()

ilPCSection::getPermissionRefId ( )

Definition at line 154 of file class.ilPCSection.php.

154 : int
155 {
156 $id = explode("_", $this->getChildNode()->getAttribute("PermissionRefId"));
157 if (isset($id[3]) && in_array($id[1], array("", 0, IL_INST_ID))) {
158 return (int) $id[3];
159 }
160 return 0;
161 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
const IL_INST_ID
Definition: constants.php:40

References $id, and IL_INST_ID.

◆ getProtected()

ilPCSection::getProtected ( )

Definition at line 394 of file class.ilPCSection.php.

394 : bool
395 {
396 if (is_object($this->getChildNode())) {
397 return ($this->getChildNode()->getAttribute("Protected") === "1");
398 }
399
400 return false;
401 }

◆ handleAccess()

ilPCSection::handleAccess ( string  $a_html,
string  $a_mode 
)

Definition at line 234 of file class.ilPCSection.php.

237 : string {
238 $ilAccess = $this->access;
239
240 while (($start = strpos($a_html, "{{{{{Section;Access;")) > 0) {
241 $end = strpos($a_html, "}}}}}", $start);
242 $access_attr = explode(";", substr($a_html, $start, $end - $start));
243 $id = explode("_", $access_attr[3]);
244 $section_nr = $access_attr[6];
245 $access = true;
246 if (in_array($id[1], array("", 0, IL_INST_ID)) && $id[3] > 0) {
247 if ($access_attr[5] == "no_read") {
248 $access = !$ilAccess->checkAccess("read", "", $id[3]);
249 } else {
250 $access = $ilAccess->checkAccess($access_attr[5], "", $id[3]);
251 }
252 }
253 if ($a_mode == ilPageObjectGUI::EDIT) {
254 $access = true;
255 }
256 $end_limiter = "{{{{{Section;AccessEnd;" . $section_nr . "}}}}}";
257 if ($access) {
258 $a_html = substr($a_html, 0, $start) . substr($a_html, $end + 5);
259 $a_html = str_replace($end_limiter, "", $a_html);
260 } else {
261 $end = strpos($a_html, $end_limiter, $start);
262 $a_html = substr($a_html, 0, $start) . substr($a_html, $end + strlen($end_limiter));
263 }
264 }
265
266 $a_html = str_replace("{{{{{Section;Access}}}}}", "", $a_html);
267 return $a_html;
268 }
ilAccessHandler $access
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)

References $id, ilRBACAccessHandler\checkAccess(), ilPageObjectGUI\EDIT, and IL_INST_ID.

+ Here is the call graph for this function:

◆ init()

ilPCSection::init ( )

Init object.

This function must be overwritten and at least set the content type.

Reimplemented from ilPageContent.

Definition at line 30 of file class.ilPCSection.php.

30 : void
31 {
32 global $DIC;
33
34 $this->access = $DIC->access();
35 $this->ctrl = $DIC->ctrl();
36 $this->lng = $DIC->language();
37 $this->setType("sec");
38 }
setType(string $a_type)
Set Type.

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilPageContent\setType().

+ Here is the call graph for this function:

◆ insertTimings()

ilPCSection::insertTimings ( string  $a_html)

Insert timings (in edit mode)

Exceptions
ilDateTimeException

Definition at line 352 of file class.ilPCSection.php.

354 : string {
356
357 $end = 0;
358 $start = strpos($a_html, "{{{{{Section;ActiveFrom");
359 if (is_int($start)) {
360 $end = strpos($a_html, "}}}}}", $start);
361 }
362 $i = 1;
363 while ($end > 0) {
364 $param = substr($a_html, $start + 13, $end - $start - 13);
365 $param = explode(";", $param);
366 $from = $param[1];
367 $to = $param[3];
368 $html = "";
369 if ($from != "") {
371 $from = new ilDateTime($from, IL_CAL_UNIX);
372 $html .= $lng->txt("cont_active_from") . ": " . ilDatePresentation::formatDate($from);
373 }
374 if ($to != "") {
375 $to = new ilDateTime($to, IL_CAL_UNIX);
376 $html .= " " . $lng->txt("cont_active_to") . ": " . ilDatePresentation::formatDate($to);
377 }
378
379 $h2 = substr($a_html, 0, $start) .
380 $html .
381 substr($a_html, $end + 5);
382 $a_html = $h2;
383 $i++;
384
385 $start = strpos($a_html, "{{{{{Section;ActiveFrom;", $start + 5);
386 $end = 0;
387 if (is_int($start)) {
388 $end = strpos($a_html, "}}}}}", $start);
389 }
390 }
391 return $a_html;
392 }
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ilLanguage $lng
$param
Definition: xapitoken.php:44

◆ modifyPageContentPostXsl()

ilPCSection::modifyPageContentPostXsl ( string  $a_output,
string  $a_mode,
bool  $a_abstract_only = false 
)
Exceptions
ilDateTimeException

Reimplemented from ilPageContent.

Definition at line 90 of file class.ilPCSection.php.

94 : string {
95 $a_output = self::insertTimings($a_output);
96 $a_output = $this->handleAccess($a_output, $a_mode);
97
98 return $a_output;
99 }
handleAccess(string $a_html, string $a_mode)
insertTimings(string $a_html)
Insert timings (in edit mode)

◆ saveTimings()

static ilPCSection::saveTimings ( ilPageObject  $a_page)
static

Definition at line 270 of file class.ilPCSection.php.

272 : void {
273 global $DIC;
274
275 $ilDB = $DIC->database();
276 $dom_util = $DIC->copage()->internal()->domain()->domUtil();
277
278 $ilDB->manipulate(
279 "DELETE FROM copg_section_timings WHERE " .
280 " page_id = " . $ilDB->quote($a_page->getId(), "integer") .
281 " AND parent_type = " . $ilDB->quote($a_page->getParentType(), "text")
282 );
283
284 $doc = $a_page->getDomDoc();
285
286 // media aliases
287 $path = "//Section";
288 $nodes = $dom_util->path($doc, $path);
289 foreach ($nodes as $node) {
290 $from = $node->getAttribute("ActiveFrom");
291 if ($from != "") {
292 $ilDB->replace(
293 "copg_section_timings",
294 array(
295 "page_id" => array("integer", $a_page->getId()),
296 "parent_type" => array("text", $a_page->getParentType()),
297 "unix_ts" => array("integer", $from)
298 ),
299 array()
300 );
301 }
302 $to = $node->getAttribute("ActiveTo");
303 if ($to != "") {
304 $ilDB->replace(
305 "copg_section_timings",
306 array(
307 "page_id" => array("integer", $a_page->getId()),
308 "parent_type" => array("text", $a_page->getParentType()),
309 "unix_ts" => array("integer", $to)
310 ),
311 array()
312 );
313 }
314 }
315 }
ILIAS COPage Dom DomUtil $dom_util
getDomDoc()
Get dom doc (DOMDocument)
$path
Definition: ltiservices.php:30

References $ilDB, ilPageObject\getId(), and ilPageObject\getParentType().

+ Here is the call graph for this function:

◆ setActiveFrom()

ilPCSection::setActiveFrom ( int  $a_unix_ts)

Definition at line 101 of file class.ilPCSection.php.

101 : void
102 {
103 $a_unix_ts = ($a_unix_ts > 0) ? (string) $a_unix_ts : null;
104 $this->dom_util->setAttribute($this->getChildNode(), "ActiveFrom", $a_unix_ts);
105 }

◆ setActiveTo()

ilPCSection::setActiveTo ( int  $a_unix_ts)

Set activation to.

Definition at line 121 of file class.ilPCSection.php.

121 : void
122 {
123 $a_unix_ts = ($a_unix_ts > 0) ? (string) $a_unix_ts : null;
124 $this->dom_util->setAttribute($this->getChildNode(), "ActiveTo", $a_unix_ts);
125 }

◆ setCharacteristic()

ilPCSection::setCharacteristic ( string  $a_char)

Definition at line 53 of file class.ilPCSection.php.

53 : void
54 {
55 $this->dom_util->setAttribute($this->getChildNode(), "Characteristic", $a_char);
56 }

◆ setExtLink()

ilPCSection::setExtLink ( string  $a_href)

Set link of area to an external one.

Definition at line 174 of file class.ilPCSection.php.

174 : void
175 {
176 $this->setNoLink();
177 if (trim($a_href) != "") {
178 $attributes = array("Href" => trim($a_href));
179 $this->dom_util->setFirstOptionalElement(
180 $this->getChildNode(),
181 "ExtLink",
182 [],
183 "",
184 $attributes
185 );
186 }
187 }
setNoLink()
Set no link.

◆ setIntLink()

ilPCSection::setIntLink ( string  $a_type,
string  $a_target,
string  $a_target_frame,
string  $a_anchor = "" 
)

Set link of area to an internal one.

Definition at line 192 of file class.ilPCSection.php.

197 : void {
198 $this->setNoLink();
199 $attributes = array("Type" => $a_type, "Target" => $a_target,
200 "TargetFrame" => $a_target_frame);
201 if ($a_anchor !== "") {
202 $attributes["Anchor"] = trim($a_anchor);
203 }
204 $this->dom_util->setFirstOptionalElement(
205 $this->getChildNode(),
206 "IntLink",
207 [],
208 "",
209 $attributes
210 );
211 }

◆ setNoLink()

ilPCSection::setNoLink ( )

Set no link.

Definition at line 166 of file class.ilPCSection.php.

166 : void
167 {
168 $this->dom_util->deleteAllChildsByName($this->getChildNode(), ["IntLink", "ExtLink"]);
169 }

◆ setPermission()

ilPCSection::setPermission ( string  $a_val)

Set permission.

Parameters
string$a_val"read"|"write"|"visible"|"no_read"

Definition at line 139 of file class.ilPCSection.php.

139 : void
140 {
141 $this->dom_util->setAttribute($this->getChildNode(), "Permission", $a_val);
142 }

◆ setPermissionRefId()

ilPCSection::setPermissionRefId ( int  $a_ref_id)

Definition at line 149 of file class.ilPCSection.php.

149 : void
150 {
151 $this->dom_util->setAttribute($this->getChildNode(), "PermissionRefId", "il__ref_" . $a_ref_id);
152 }

◆ setProtected()

ilPCSection::setProtected ( bool  $val)

Definition at line 403 of file class.ilPCSection.php.

403 : void
404 {
405 if ($val) {
406 $this->getChildNode()->setAttribute("Protected", "1");
407 } else {
408 $this->getChildNode()->setAttribute("Protected", "0");
409 }
410 }

Field Documentation

◆ $access

ilAccessHandler ilPCSection::$access
protected

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

◆ $ctrl

ilCtrl ilPCSection::$ctrl
protected

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

◆ $lng

ilLanguage ilPCSection::$lng
protected

Definition at line 28 of file class.ilPCSection.php.


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