ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 = './components/ILIAS/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: shib_login.php:22

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 340 of file class.ilPageLayout.php.

Referenced by ILIAS\LearningModule\Editing\GUIService\__construct(), ILIAS\LearningModule\Editing\EditSubObjectsGUI\__construct(), ilPCLayoutTemplateGUI\initCreationForm(), ilObjPortfolioBaseGUI\initPageForm(), ilPageConfig\loadParentKey(), and ilPageLayoutGUI\setTabs().

342  : array {
343  return self::getLayouts(true, $a_module);
344  }
+ 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 240 of file class.ilPageLayout.php.

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

Referenced by getPreview().

240  : string
241  {
242  $error = null;
243  $dom = $this->dom_util->docFromString($this->getXMLContent(), $error);
244  $path = "////PlaceHolder";
245  $nodes = $this->dom_util->path($dom, $path);
246  foreach ($nodes as $node) {
247  $height = $node->getAttribute("Height");
248 
249  $height = str_ireplace("px", "", $height);
250  $height = $height / 10;
251  $node->setAttribute("Height", $height . "px");
252  }
253 
254  $xml = $this->dom_util->dump($dom->documentElement);
255  $output = $this->xslt($xml, []);
256  return $output;
257  }
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 362 of file class.ilPageLayout.php.

References $DIC, and $lng.

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

362  : array
363  {
364  global $DIC;
365 
366  $lng = $DIC->language();
367 
368  return array(
369  self::MODULE_PORTFOLIO => $lng->txt("style_page_layout_module_portfolio"),
370  self::MODULE_LM => $lng->txt("style_page_layout_module_learning_module")
371  );
372  }
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
+ 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 301 of file class.ilPageLayout.php.

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

Referenced by ilPageLayoutAdministrationGUI\initAddPageLayoutForm().

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

◆ getLayoutsAsArray()

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

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

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

Referenced by ilPageLayoutTableGUI\getPageLayouts().

282  : array {
283  global $DIC;
284 
285  $ilDB = $DIC->database();
286  $arr_layouts = array();
287  $add = "";
288  if ($a_active != 0) {
289  $add = "WHERE (active=1)";
290  }
291  $query = "SELECT * FROM page_layout $add ORDER BY title ";
292  $result = $ilDB->query($query);
293  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
294  if (ilPageObject::_exists("stys", $row["layout_id"])) {
295  $arr_layouts[] = $row;
296  }
297  }
298  return $arr_layouts;
299  }
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
global $DIC
Definition: shib_login.php:22
+ 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  if (is_file("./components/ILIAS/COPage/Layout/xml/layout2html.xsl")) {
235  return "./components/ILIAS/COPage/Layout/xml/layout2html.xsl";
236  }
237  return "../components/ILIAS/COPage/Layout/xml/layout2html.xsl";
238  }
+ 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 349 of file class.ilPageLayout.php.

Referenced by ilPageLayoutAdministrationGUI\importPageLayout().

352  : void {
353  $imp = new ilImport();
354  $imp->importEntity(
355  $a_filepath,
356  $a_filename,
357  "pgtp",
358  "components/ILIAS/COPage"
359  );
360  }
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 259 of file class.ilPageLayout.php.

References getXSLPath().

Referenced by generatePreview().

262  : string {
263  $xslt = new \XSLTProcessor();
264  $xsl = file_get_contents($this->getXSLPath());
265  $xslt_domdoc = new \DomDocument();
266  $xslt_domdoc->loadXML($xsl);
267  $xslt->importStylesheet($xslt_domdoc);
268  foreach ($params as $key => $value) {
269  $xslt->setParameter("", $key, (string) $value);
270  }
271  $xml_domdoc = new \DomDocument();
272  $xml_domdoc->loadXML($xml);
273  // show warnings again due to discussion in #12866
274  $result = $xslt->transformToXml($xml_domdoc);
275  unset($xslt);
276  return $result;
277  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
+ 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 = './components/ILIAS/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: