ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilPageLayout Class Reference

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

+ Collaboration diagram for ilPageLayout:

Public Member Functions

 __construct (int $a_id=0)
 
 getActive ()
 
 getDescription ()
 
 setDescription (string $a_description)
 
 getTitle ()
 
 setTitle (string $a_title)
 
 getId ()
 
 setModules (array $a_values=[])
 
 getModules ()
 
 activate (bool $a_setting=true)
 (De-)Activate layout More...
 
 delete ()
 Delete page layout. More...
 
 update ()
 Update page layout. More...
 
 readObject ()
 
 setXMLContent (string $content)
 
 getXMLContent ()
 
 copyXmlContent (bool $self_ass=true)
 
 getPreview ()
 

Static Public Member Functions

static getLayoutsAsArray (int $a_active=0)
 
static getLayouts (bool $a_active=false, int $a_module=0)
 
static activeLayouts (int $a_module=0)
 Get active layouts. More...
 
static import (string $a_filename, string $a_filepath)
 Import page layout. More...
 
static getAvailableModules ()
 

Data Fields

const SEQ_TEMPLATE_DIR = './Modules/Scorm2004/templates/editor/page_layouts_temp/thumbnails'
 
const MODULE_SCORM = 1
 
const MODULE_PORTFOLIO = 2
 
const MODULE_LM = 3
 
int $layout_id = 0
 
string $title = ""
 
string $description = ""
 
bool $active = false
 
array $modules = array()
 

Protected Member Functions

 xslt (string $xml, array $params)
 

Protected Attributes

string $xml_content = null
 
ILIAS COPage Dom DomUtil $dom_util
 
int $special_page
 
int $style_id
 
ilDBInterface $db
 

Private Member Functions

 getXSLPath ()
 
 generatePreview ()
 

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 for Page Layouts

Author
Hendrik Holtmann holtm.nosp@m.ann@.nosp@m.me.co.nosp@m.m

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

Constructor & Destructor Documentation

◆ __construct()

ilPageLayout::__construct ( int  $a_id = 0)

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

References $DIC, and $ilDB.

44  {
45  global $DIC;
46 
47  $this->db = $DIC->database();
48  $ilDB = $DIC->database();
49 
50  //create new instance
51  if ($a_id == 0) {
52  $this->layout_id = $ilDB->nextId("page_layout");
53  $ilDB->insert("page_layout", array(
54  "layout_id" => array("integer", $this->layout_id),
55  "active" => array("integer", 0),
56  "title" => array("text", ""),
57  "content" => array("clob", ""),
58  "description" => array("text", "")
59  ));
60  //$query = "INSERT INTO page_layout(active) values (0);";
61  //$result = $ilDB->query($query);
62  //$query = "SELECT LAST_INSERT_ID() as id";
63  //$res = $ilDB->query($query);
64  //$row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
65  //$this->layout_id = $row->id;
66  $this->active = false;
67  } else {
68  $this->layout_id = $a_id;
69  }
70  $this->dom_util = $DIC->copage()->internal()->domain()->domUtil();
71  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ activate()

ilPageLayout::activate ( bool  $a_setting = true)

(De-)Activate layout

Definition at line 134 of file class.ilPageLayout.php.

References $db, and $ilDB.

136  : void {
137  $ilDB = $this->db;
138 
139  $query = "UPDATE page_layout SET active=" . $ilDB->quote($a_setting, "integer") .
140  " WHERE layout_id =" . $ilDB->quote($this->layout_id, "integer");
141  $result = $ilDB->manipulate($query);
142  }
ilDBInterface $db

◆ activeLayouts()

static ilPageLayout::activeLayouts ( int  $a_module = 0)
static

Get active layouts.

Definition at line 337 of file class.ilPageLayout.php.

Referenced by ilChapterHierarchyFormGUI\__construct(), ilPCLayoutTemplateGUI\initCreationForm(), ilObjPortfolioBaseGUI\initPageForm(), ilPageConfig\loadParentKey(), and ilPageLayoutGUI\setTabs().

339  : array {
340  return self::getLayouts(true, $a_module);
341  }
+ Here is the caller graph for this function:

◆ copyXmlContent()

ilPageLayout::copyXmlContent ( bool  $self_ass = true)

Definition at line 221 of file class.ilPageLayout.php.

221  : string
222  {
223  $layout_page = new ilPageLayoutPage($this->layout_id);
224  return $layout_page->copyXmlContent(true, 0, 0, $self_ass);
225  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ delete()

ilPageLayout::delete ( )

Delete page layout.

Definition at line 147 of file class.ilPageLayout.php.

References $db, and $ilDB.

147  : void
148  {
149  $ilDB = $this->db;
150 
151  $query = "DELETE FROM page_layout WHERE layout_id =" . $ilDB->quote($this->layout_id, "integer");
152  $result = $ilDB->manipulate($query);
153  }
ilDBInterface $db

◆ generatePreview()

ilPageLayout::generatePreview ( )
private

Definition at line 237 of file class.ilPageLayout.php.

References $path, getXMLContent(), and xslt().

Referenced by getPreview().

237  : string
238  {
239  $error = null;
240  $dom = $this->dom_util->docFromString($this->getXMLContent(), $error);
241  $path = "////PlaceHolder";
242  $nodes = $this->dom_util->path($dom, $path);
243  foreach ($nodes as $node) {
244  $height = $node->getAttribute("Height");
245 
246  $height = str_ireplace("px", "", $height);
247  $height = $height / 10;
248  $node->setAttribute("Height", $height . "px");
249  }
250 
251  $xml = $this->dom_util->dump($dom->documentElement);
252  $output = $this->xslt($xml, []);
253  return $output;
254  }
$path
Definition: ltiservices.php:32
xslt(string $xml, array $params)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActive()

ilPageLayout::getActive ( )

Definition at line 73 of file class.ilPageLayout.php.

References $active.

73  : bool
74  {
75  return $this->active;
76  }

◆ getAvailableModules()

static ilPageLayout::getAvailableModules ( )
static

Definition at line 359 of file class.ilPageLayout.php.

References $DIC, and $lng.

Referenced by ilPageLayoutTableGUI\getPageLayouts(), ilPageLayoutAdministrationGUI\initAddPageLayoutForm(), ilPageLayoutGUI\initForm(), and setModules().

359  : array
360  {
361  global $DIC;
362 
363  $lng = $DIC->language();
364 
365  return array(
366  self::MODULE_PORTFOLIO => $lng->txt("style_page_layout_module_portfolio"),
367  self::MODULE_LM => $lng->txt("style_page_layout_module_learning_module")
368  );
369  }
global $DIC
Definition: feed.php:28
$lng
+ Here is the caller graph for this function:

◆ getDescription()

ilPageLayout::getDescription ( )

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

References $description.

78  : string
79  {
80  return $this->description;
81  }

◆ getId()

ilPageLayout::getId ( )

Definition at line 98 of file class.ilPageLayout.php.

References $layout_id.

98  : int
99  {
100  return $this->layout_id;
101  }

◆ getLayouts()

static ilPageLayout::getLayouts ( bool  $a_active = false,
int  $a_module = 0 
)
static

Definition at line 298 of file class.ilPageLayout.php.

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

Referenced by ilPageLayoutAdministrationGUI\initAddPageLayoutForm().

301  : array {
302  global $DIC;
303 
304  $ilDB = $DIC->database();
305  $arr_layouts = array();
306  $add = "";
307  $conc = " WHERE ";
308  if ($a_active) {
309  $add .= $conc . " (active = 1)";
310  $conc = " AND ";
311  }
312  switch ($a_module) {
313  case self::MODULE_SCORM:
314  $add .= $conc . " mod_scorm = 1";
315  break;
316 
317  case self::MODULE_PORTFOLIO:
318  $add .= $conc . " mod_portfolio = 1";
319  break;
320 
321  case self::MODULE_LM:
322  $add .= $conc . " mod_lm = 1";
323  break;
324  }
325  $query = "SELECT layout_id FROM page_layout $add ORDER BY title ";
326  $result = $ilDB->query($query);
327  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
328  $arr_layouts[] = new ilPageLayout($row['layout_id']);
329  }
330 
331  return $arr_layouts;
332  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getLayoutsAsArray()

static ilPageLayout::getLayoutsAsArray ( int  $a_active = 0)
static

Definition at line 277 of file class.ilPageLayout.php.

References $DIC, $ilDB, ilPageObject\_exists(), and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilPageLayoutTableGUI\getPageLayouts().

279  : array {
280  global $DIC;
281 
282  $ilDB = $DIC->database();
283  $arr_layouts = array();
284  $add = "";
285  if ($a_active != 0) {
286  $add = "WHERE (active=1)";
287  }
288  $query = "SELECT * FROM page_layout $add ORDER BY title ";
289  $result = $ilDB->query($query);
290  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
291  if (ilPageObject::_exists("stys", $row["layout_id"])) {
292  $arr_layouts[] = $row;
293  }
294  }
295  return $arr_layouts;
296  }
global $DIC
Definition: feed.php:28
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getModules()

ilPageLayout::getModules ( )

Definition at line 126 of file class.ilPageLayout.php.

References $modules.

126  : array
127  {
128  return $this->modules;
129  }

◆ getPreview()

ilPageLayout::getPreview ( )

Definition at line 227 of file class.ilPageLayout.php.

References generatePreview().

227  : string
228  {
229  return $this->generatePreview();
230  }
+ Here is the call graph for this function:

◆ getTitle()

ilPageLayout::getTitle ( )

Definition at line 88 of file class.ilPageLayout.php.

References $title.

88  : string
89  {
90  return $this->title;
91  }

◆ getXMLContent()

ilPageLayout::getXMLContent ( )

Definition at line 212 of file class.ilPageLayout.php.

References $xml_content.

Referenced by generatePreview().

212  : string
213  {
214  if (!is_null($this->xml_content)) {
215  return $this->xml_content;
216  }
217  $layout_page = new ilPageLayoutPage($this->layout_id);
218  return $layout_page->getXMLContent();
219  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getXSLPath()

ilPageLayout::getXSLPath ( )
private

Definition at line 232 of file class.ilPageLayout.php.

Referenced by xslt().

232  : string
233  {
234  return "./Services/COPage/Layout/xml/layout2html.xsl";
235  }
+ Here is the caller graph for this function:

◆ import()

static ilPageLayout::import ( string  $a_filename,
string  $a_filepath 
)
static

Import page layout.

Definition at line 346 of file class.ilPageLayout.php.

Referenced by ilPageLayoutAdministrationGUI\importPageLayout().

349  : void {
350  $imp = new ilImport();
351  $imp->importEntity(
352  $a_filepath,
353  $a_filename,
354  "pgtp",
355  "Services/COPage"
356  );
357  }
Import class.
+ Here is the caller graph for this function:

◆ readObject()

ilPageLayout::readObject ( )

Definition at line 184 of file class.ilPageLayout.php.

References $db, $ilDB, and setModules().

184  : void
185  {
186  $ilDB = $this->db;
187  $query = "SELECT * FROM page_layout WHERE layout_id =" . $ilDB->quote($this->layout_id, "integer");
188  $result = $ilDB->query($query);
189  $row = $ilDB->fetchAssoc($result);
190  $this->title = (string) $row['title'];
191  $this->description = (string) $row['description'];
192  $this->active = (bool) $row['active'];
193 
194  $mods = array();
195  if ($row["mod_scorm"]) {
196  $mods[] = self::MODULE_SCORM;
197  }
198  if ($row["mod_portfolio"]) {
199  $mods[] = self::MODULE_PORTFOLIO;
200  }
201  if ($row["mod_lm"]) {
202  $mods[] = self::MODULE_LM;
203  }
204  $this->setModules($mods);
205  }
setModules(array $a_values=[])
ilDBInterface $db
+ Here is the call graph for this function:

◆ setDescription()

ilPageLayout::setDescription ( string  $a_description)

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

83  : void
84  {
85  $this->description = $a_description;
86  }

◆ setModules()

ilPageLayout::setModules ( array  $a_values = [])

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

References $valid, and getAvailableModules().

Referenced by readObject().

116  : void
117  {
118  if ($a_values) {
119  $valid = array_keys($this->getAvailableModules());
120  $this->modules = array_intersect($a_values, $valid);
121  } else {
122  $this->modules = array();
123  }
124  }
$valid
static getAvailableModules()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTitle()

ilPageLayout::setTitle ( string  $a_title)

Definition at line 93 of file class.ilPageLayout.php.

93  : void
94  {
95  $this->title = $a_title;
96  }

◆ setXMLContent()

ilPageLayout::setXMLContent ( string  $content)

Definition at line 207 of file class.ilPageLayout.php.

207  : void
208  {
209  $this->xml_content = $content;
210  }

◆ update()

ilPageLayout::update ( )

Update page layout.

Definition at line 158 of file class.ilPageLayout.php.

References $db, and $ilDB.

158  : void
159  {
160  $ilDB = $this->db;
161 
162  $mod_scorm = $mod_portfolio = $mod_lm = 0;
163  if (in_array(self::MODULE_SCORM, $this->modules)) {
164  $mod_scorm = 1;
165  }
166  if (in_array(self::MODULE_PORTFOLIO, $this->modules)) {
167  $mod_portfolio = 1;
168  }
169  if (in_array(self::MODULE_LM, $this->modules)) {
170  $mod_lm = 1;
171  }
172 
173  $query = "UPDATE page_layout SET title=" . $ilDB->quote($this->title, "text") .
174  ",description =" . $ilDB->quote($this->description, "text") .
175  ",active =" . $ilDB->quote($this->active, "integer") .
176  ",mod_scorm =" . $ilDB->quote($mod_scorm, "integer") .
177  ",mod_portfolio =" . $ilDB->quote($mod_portfolio, "integer") .
178  ",mod_lm =" . $ilDB->quote($mod_lm, "integer") .
179  " WHERE layout_id =" . $ilDB->quote($this->layout_id, "integer");
180 
181  $result = $ilDB->manipulate($query);
182  }
ilDBInterface $db

◆ xslt()

ilPageLayout::xslt ( string  $xml,
array  $params 
)
protected

Definition at line 256 of file class.ilPageLayout.php.

References ILIAS\LTI\ToolProvider\$key, and getXSLPath().

Referenced by generatePreview().

259  : string {
260  $xslt = new \XSLTProcessor();
261  $xsl = file_get_contents($this->getXSLPath());
262  $xslt_domdoc = new \DomDocument();
263  $xslt_domdoc->loadXML($xsl);
264  $xslt->importStylesheet($xslt_domdoc);
265  foreach ($params as $key => $value) {
266  $xslt->setParameter("", $key, (string) $value);
267  }
268  $xml_domdoc = new \DomDocument();
269  $xml_domdoc->loadXML($xml);
270  // show warnings again due to discussion in #12866
271  $result = $xslt->transformToXml($xml_domdoc);
272  unset($xslt);
273  return $result;
274  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $active

bool ilPageLayout::$active = false

Definition at line 39 of file class.ilPageLayout.php.

Referenced by getActive().

◆ $db

ilDBInterface ilPageLayout::$db
protected

Definition at line 35 of file class.ilPageLayout.php.

Referenced by activate(), delete(), readObject(), and update().

◆ $description

string ilPageLayout::$description = ""

Definition at line 38 of file class.ilPageLayout.php.

Referenced by getDescription().

◆ $dom_util

ILIAS COPage Dom DomUtil ilPageLayout::$dom_util
protected

Definition at line 31 of file class.ilPageLayout.php.

◆ $layout_id

int ilPageLayout::$layout_id = 0

Definition at line 36 of file class.ilPageLayout.php.

Referenced by getId().

◆ $modules

array ilPageLayout::$modules = array()

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

Referenced by getModules().

◆ $special_page

int ilPageLayout::$special_page
protected

Definition at line 32 of file class.ilPageLayout.php.

◆ $style_id

int ilPageLayout::$style_id
protected

Definition at line 33 of file class.ilPageLayout.php.

◆ $title

string ilPageLayout::$title = ""

Definition at line 37 of file class.ilPageLayout.php.

Referenced by getTitle().

◆ $xml_content

string ilPageLayout::$xml_content = null
protected

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

Referenced by getXMLContent().

◆ MODULE_LM

◆ MODULE_PORTFOLIO

const ilPageLayout::MODULE_PORTFOLIO = 2

◆ MODULE_SCORM

const ilPageLayout::MODULE_SCORM = 1

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

Referenced by ilPageLayoutTableGUI\fillRow().

◆ SEQ_TEMPLATE_DIR

const ilPageLayout::SEQ_TEMPLATE_DIR = './Modules/Scorm2004/templates/editor/page_layouts_temp/thumbnails'

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


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