ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables 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 ()
 
 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 Attributes

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

References $DIC, and $ilDB.

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

Member Function Documentation

◆ activate()

ilPageLayout::activate ( bool  $a_setting = true)

(De-)Activate layout

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

References $db, $ilDB, and $query.

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

◆ activeLayouts()

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

Get active layouts.

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

Referenced by ilChapterHierarchyFormGUI\__construct(), ilObjPortfolioGUI\initCreateForm(), ilObjPortfolioBaseGUI\initPageForm(), and ilPageLayoutGUI\setTabs().

317  : array {
318  return self::getLayouts(true, $a_module);
319  }
+ Here is the caller graph for this function:

◆ copyXmlContent()

ilPageLayout::copyXmlContent ( bool  $self_ass = true)

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

210  : string
211  {
212  $layout_page = new ilPageLayoutPage($this->layout_id);
213  return $layout_page->copyXmlContent(true, 0, 0, $self_ass);
214  }
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 144 of file class.ilPageLayout.php.

References $db, $ilDB, and $query.

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

◆ generatePreview()

ilPageLayout::generatePreview ( )
private

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

References $path, $res, $xml, DOMXML_LOAD_PARSING, domxml_open_mem(), getXMLContent(), getXSLPath(), xpath_eval(), xpath_new_context(), xslt_create(), xslt_error(), and xslt_free().

Referenced by getPreview().

226  : string
227  {
228  $xml = $this->getXMLContent();
229 
230  $dom = domxml_open_mem($xml, DOMXML_LOAD_PARSING, $error);
231  $xpc = xpath_new_context($dom);
232  $path = "////PlaceHolder";
233  $res = xpath_eval($xpc, $path);
234 
235  foreach ($res->nodeset as $item) {
236  $height = $item->get_attribute("Height");
237 
238  $height = str_ireplace("px", "", $height);
239  $height = $height / 10;
240  $item->set_attribute("Height", $height . "px");
241  }
242  $xsl = file_get_contents($this->getXSLPath());
243 
244  $xml = $dom->dump_mem(0, "UTF-8");
245 
246  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
247 
248  $xh = xslt_create();
249  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, null);
250  xslt_error($xh);
251  xslt_free($xh);
252  return $output;
253  }
xpath_eval(php4DOMXPath $xpath_context, string $eval_str, $contextnode=null)
xslt_create()
$res
Definition: ltiservices.php:69
xslt_free(&$proc)
$path
Definition: ltiservices.php:32
xslt_error(&$proc)
xpath_new_context($dom_document)
domxml_open_mem($str, $mode=0, &$error=null)
$xml
Definition: metadata.php:351
const DOMXML_LOAD_PARSING
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActive()

ilPageLayout::getActive ( )

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

References $active.

70  : bool
71  {
72  return $this->active;
73  }

◆ getAvailableModules()

static ilPageLayout::getAvailableModules ( )
static

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

References $DIC, and $lng.

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

337  : array
338  {
339  global $DIC;
340 
341  $lng = $DIC->language();
342 
343  return array(
344  self::MODULE_PORTFOLIO => $lng->txt("style_page_layout_module_portfolio"),
345  self::MODULE_LM => $lng->txt("style_page_layout_module_learning_module")
346  );
347  }
$lng
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getDescription()

ilPageLayout::getDescription ( )

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

References $description.

75  : string
76  {
77  return $this->description;
78  }

◆ getId()

ilPageLayout::getId ( )

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

References $layout_id.

95  : int
96  {
97  return $this->layout_id;
98  }

◆ getLayouts()

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

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

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

Referenced by ilPageLayoutAdministrationGUI\initAddPageLayoutForm().

279  : array {
280  global $DIC;
281 
282  $ilDB = $DIC->database();
283  $arr_layouts = array();
284  $add = "";
285  $conc = " WHERE ";
286  if ($a_active) {
287  $add .= $conc . " (active = 1)";
288  $conc = " AND ";
289  }
290  switch ($a_module) {
291  case self::MODULE_SCORM:
292  $add .= $conc . " mod_scorm = 1";
293  break;
294 
295  case self::MODULE_PORTFOLIO:
296  $add .= $conc . " mod_portfolio = 1";
297  break;
298 
299  case self::MODULE_LM:
300  $add .= $conc . " mod_lm = 1";
301  break;
302  }
303  $query = "SELECT layout_id FROM page_layout $add ORDER BY title ";
304  $result = $ilDB->query($query);
305  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
306  $arr_layouts[] = new ilPageLayout($row['layout_id']);
307  }
308 
309  return $arr_layouts;
310  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$query
+ Here is the caller graph for this function:

◆ getLayoutsAsArray()

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

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

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

Referenced by ilPageLayoutTableGUI\getPageLayouts().

257  : array {
258  global $DIC;
259 
260  $ilDB = $DIC->database();
261  $arr_layouts = array();
262  $add = "";
263  if ($a_active != 0) {
264  $add = "WHERE (active=1)";
265  }
266  $query = "SELECT * FROM page_layout $add ORDER BY title ";
267  $result = $ilDB->query($query);
268  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
269  if (ilPageObject::_exists("stys", $row["layout_id"])) {
270  $arr_layouts[] = $row;
271  }
272  }
273  return $arr_layouts;
274  }
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.
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getModules()

ilPageLayout::getModules ( )

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

References $modules.

123  : array
124  {
125  return $this->modules;
126  }

◆ getPreview()

ilPageLayout::getPreview ( )

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

References generatePreview().

216  : string
217  {
218  return $this->generatePreview();
219  }
+ Here is the call graph for this function:

◆ getTitle()

ilPageLayout::getTitle ( )

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

References $title.

85  : string
86  {
87  return $this->title;
88  }

◆ getXMLContent()

ilPageLayout::getXMLContent ( )

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

Referenced by generatePreview().

204  : string
205  {
206  $layout_page = new ilPageLayoutPage($this->layout_id);
207  return $layout_page->getXMLContent();
208  }
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 221 of file class.ilPageLayout.php.

Referenced by generatePreview().

221  : string
222  {
223  return "./Services/COPage/Layout/xml/layout2html.xsl";
224  }
+ 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 324 of file class.ilPageLayout.php.

Referenced by ilPageLayoutAdministrationGUI\importPageLayout().

327  : void {
328  $imp = new ilImport();
329  $imp->importEntity(
330  $a_filepath,
331  $a_filename,
332  "pgtp",
333  "Services/COPage"
334  );
335  }
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:

◆ readObject()

ilPageLayout::readObject ( )

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

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

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

◆ setDescription()

ilPageLayout::setDescription ( string  $a_description)

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

80  : void
81  {
82  $this->description = $a_description;
83  }

◆ setModules()

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

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

References $valid, and getAvailableModules().

Referenced by readObject().

113  : void
114  {
115  if ($a_values) {
116  $valid = array_keys($this->getAvailableModules());
117  $this->modules = array_intersect($a_values, $valid);
118  } else {
119  $this->modules = array();
120  }
121  }
$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 90 of file class.ilPageLayout.php.

90  : void
91  {
92  $this->title = $a_title;
93  }

◆ update()

ilPageLayout::update ( )

Update page layout.

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

References $db, $ilDB, and $query.

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

Field Documentation

◆ $active

bool ilPageLayout::$active = false

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

Referenced by getActive().

◆ $db

ilDBInterface ilPageLayout::$db
protected

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

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

◆ $description

string ilPageLayout::$description = ""

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

Referenced by getDescription().

◆ $layout_id

int ilPageLayout::$layout_id = 0

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

Referenced by getId().

◆ $modules

array ilPageLayout::$modules = array()

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

Referenced by getModules().

◆ $special_page

int ilPageLayout::$special_page
protected

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

◆ $style_id

int ilPageLayout::$style_id
protected

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

◆ $title

string ilPageLayout::$title = ""

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

Referenced by getTitle().

◆ 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: