ILIAS  release_7 Revision v7.30-3-g800a261c036
ilPageLayout Class Reference

Class ilPageLayout. More...

+ Collaboration diagram for ilPageLayout:

Public Member Functions

 __construct ($a_id=null)
 
 getActive ()
 
 getDescription ()
 
 setDescription ($a_description)
 
 getTitle ()
 
 setTitle ($a_title)
 
 getId ()
 
 setStyleId ($a_val)
 Set style id. More...
 
 getStyleId ()
 Get style id. More...
 
 setSpecialPage ($a_val)
 Set special page. More...
 
 getSpecialPage ()
 Get special page. More...
 
 setModules (array $a_values=null)
 Set modules. More...
 
 getModules ()
 Get modules. More...
 
 activate ($a_setting=true)
 (De-)Activate layout More...
 
 delete ()
 Delete page layout. More...
 
 update ()
 Update page layout. More...
 
 readObject ()
 Read page layout. More...
 
 getXMLContent ()
 Get xml content. More...
 
 getPreview ()
 Get preview. More...
 

Static Public Member Functions

static getLayoutsAsArray ($a_active=0)
 Static access functions. More...
 
static getLayouts ($a_active=false, $a_special_page=false, $a_module=null)
 Get layouts. More...
 
static activeLayouts ($a_special_page=false, $a_module=null)
 Get active layouts. More...
 
static import ($a_filename, $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
 
 $layout_id = null
 
 $title = null
 
 $description = null
 
 $active = null
 
 $modules = array()
 

Protected Attributes

 $db
 

Private Member Functions

 getXSLPath ()
 
 generatePreview ()
 

Detailed Description

Class ilPageLayout.

Class for Page Layouts

Author
Hendrik Holtmann holtm.nosp@m.ann@.nosp@m.me.co.nosp@m.m
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilPageLayout::__construct (   $a_id = null)

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

35 {
36 global $DIC;
37
38 $this->db = $DIC->database();
39 $ilDB = $DIC->database();
40 //create new instance
41 if ($a_id == null) {
42 $this->layout_id = $ilDB->nextId("page_layout");
43 $ilDB->insert("page_layout", array(
44 "layout_id" => array("integer", $this->layout_id),
45 "active" => array("integer", 0),
46 "title" => array("text", ""),
47 "content" => array("clob", ""),
48 "description" => array("text", "")
49 ));
50 //$query = "INSERT INTO page_layout(active) values (0);";
51 //$result = $ilDB->query($query);
52 //$query = "SELECT LAST_INSERT_ID() as id";
53 //$res = $ilDB->query($query);
54 //$row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
55 //$this->layout_id = $row->id;
56 $this->active = false;
57 } else {
58 $this->layout_id = $a_id;
59 }
60 }
global $DIC
Definition: goto.php:24
global $ilDB

References $DIC, and $ilDB.

Member Function Documentation

◆ activate()

ilPageLayout::activate (   $a_setting = true)

(De-)Activate layout

Parameters
boolean$a_settingtrue/false

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

151 {
153
154 $query = "UPDATE page_layout SET active=" . $ilDB->quote($a_setting, "integer") .
155 " WHERE layout_id =" . $ilDB->quote($this->layout_id, "integer");
156 $result = $ilDB->manipulate($query);
157 }
$result
$query

References $db, $ilDB, $query, and $result.

◆ activeLayouts()

static ilPageLayout::activeLayouts (   $a_special_page = false,
  $a_module = null 
)
static

Get active layouts.

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

346 {
347 return self::getLayouts(true, $a_special_page, $a_module);
348 }
static getLayouts($a_active=false, $a_special_page=false, $a_module=null)
Get layouts.

References getLayouts().

Referenced by ilChapterHierarchyFormGUI\__construct(), ilSCORM2004OrganizationHFormGUI\getMenuItems(), ilObjPortfolioGUI\initCreateForm(), ilObjPortfolioBaseGUI\initPageForm(), and ilObjSCORM2004LearningModuleGUI\insertTemplateGUI().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilPageLayout::delete ( )

Delete page layout.

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

163 {
165
166 $query = "DELETE FROM page_layout WHERE layout_id =" . $ilDB->quote($this->layout_id, "integer");
167 $result = $ilDB->manipulate($query);
168 }

References $db, $ilDB, $query, and $result.

◆ generatePreview()

ilPageLayout::generatePreview ( )
private

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

257 {
258 $xml = $this->getXMLContent();
259
260 $dom = @domxml_open_mem($xml, DOMXML_LOAD_PARSING, $error);
261 $xpc = xpath_new_context($dom);
262 $path = "////PlaceHolder";
263 $res = xpath_eval($xpc, $path);
264
265 foreach ($res->nodeset as $item) {
266 $height = $item->get_attribute("Height");
267
268 $height = str_ireplace("px", "", $height);
269 $height = $height / 10;
270 $item->set_attribute("Height", $height . "px");
271 }
272 $xsl = file_get_contents($this->getXSLPath());
273
274 $xml = $dom->dump_mem(0, "UTF-8");
275
276 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
277
278 $xh = xslt_create();
279 $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, null);
280 xslt_error($xh);
281 xslt_free($xh);
282 return $output;
283 }
getXMLContent()
Get xml content.
xslt_error(&$proc)
xslt_free(&$proc)
xslt_create()
xpath_eval($xpath_context, $eval_str, $contextnode=null)
domxml_open_mem($str, $mode=0, &$error=null)
xpath_new_context($dom_document)
const DOMXML_LOAD_PARSING
$xml
Definition: metadata.php:332
foreach($_POST as $key=> $value) $res

References $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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActive()

ilPageLayout::getActive ( )

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

63 {
64 return $this->active;
65 }

References $active.

◆ getAvailableModules()

static ilPageLayout::getAvailableModules ( )
static

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

371 {
372 global $DIC;
373
374 $lng = $DIC->language();
375
376 return array(
377 self::MODULE_SCORM => $lng->txt("style_page_layout_module_scorm"),
378 self::MODULE_PORTFOLIO => $lng->txt("style_page_layout_module_portfolio"),
379 self::MODULE_LM => $lng->txt("style_page_layout_module_learning_module")
380 );
381 }
$lng

References $DIC, and $lng.

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

+ Here is the caller graph for this function:

◆ getDescription()

ilPageLayout::getDescription ( )

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

68 {
69 return $this->description;
70 }

References $description.

◆ getId()

ilPageLayout::getId ( )

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

88 {
89 return $this->layout_id;
90 }

References $layout_id.

◆ getLayouts()

static ilPageLayout::getLayouts (   $a_active = false,
  $a_special_page = false,
  $a_module = null 
)
static

Get layouts.

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

311 {
312 global $DIC;
313
314 $ilDB = $DIC->database();
315 $arr_layouts = array();
316 $add = "WHERE special_page = " . $ilDB->quote($a_special_page, "integer");
317 if ($a_active) {
318 $add .= " AND (active = 1)";
319 }
320 switch ($a_module) {
322 $add .= " AND mod_scorm = 1";
323 break;
324
326 $add .= " AND mod_portfolio = 1";
327 break;
328
329 case self::MODULE_LM:
330 $add .= " AND mod_lm = 1";
331 break;
332 }
333 $query = "SELECT layout_id FROM page_layout $add ORDER BY title ";
334 $result = $ilDB->query($query);
335 while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
336 array_push($arr_layouts, new ilPageLayout($row['layout_id']));
337 }
338
339 return $arr_layouts;
340 }
Class ilPageLayout.

References $DIC, $ilDB, $query, $result, ilDBConstants\FETCHMODE_ASSOC, MODULE_LM, MODULE_PORTFOLIO, and MODULE_SCORM.

Referenced by activeLayouts(), and ilPageLayoutAdministrationGUI\initAddPageLayoutForm().

+ Here is the caller graph for this function:

◆ getLayoutsAsArray()

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

Static access functions.

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

291 {
292 global $DIC;
293
294 $ilDB = $DIC->database();
295 $arr_layouts = array();
296 if ($active != 0) {
297 $add = "WHERE (active=1)";
298 }
299 $query = "SELECT * FROM page_layout $add ORDER BY title ";
300 $result = $ilDB->query($query);
301 while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
302 array_push($arr_layouts, $row);
303 }
304 return $arr_layouts;
305 }

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

Referenced by ilPageLayoutTableGUI\getPageLayouts().

+ Here is the caller graph for this function:

◆ getModules()

ilPageLayout::getModules ( )

Get modules.

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

141 {
142 return $this->modules;
143 }

References $modules.

◆ getPreview()

ilPageLayout::getPreview ( )

Get preview.

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

246 {
247 return $this->generatePreview();
248 }

References generatePreview().

+ Here is the call graph for this function:

◆ getSpecialPage()

ilPageLayout::getSpecialPage ( )

Get special page.

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

120 {
121 return $this->special_page;
122 }

Referenced by update().

+ Here is the caller graph for this function:

◆ getStyleId()

ilPageLayout::getStyleId ( )

Get style id.

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

104 {
105 return $this->style_id;
106 }

Referenced by update().

+ Here is the caller graph for this function:

◆ getTitle()

ilPageLayout::getTitle ( )

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

78 {
79 return $this->title;
80 }

References $title.

◆ getXMLContent()

ilPageLayout::getXMLContent ( )

Get xml content.

Returns
string content xml

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

235 {
236 include_once "Services/COPage/Layout/classes/class.ilPageLayoutPage.php";
237 $layout_page = new ilPageLayoutPage($this->layout_id);
238 return $layout_page->getXMLContent();
239 }
Page layout page object.

Referenced by generatePreview().

+ Here is the caller graph for this function:

◆ getXSLPath()

ilPageLayout::getXSLPath ( )
private

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

252 {
253 return "./Services/COPage/Layout/xml/layout2html.xsl";
254 }

Referenced by generatePreview().

+ Here is the caller graph for this function:

◆ import()

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

Import page layout.

Parameters
string$a_filenamefile name
string$a_fiepathcomplete path (incl. name) to file
Returns
object new object

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

359 {
360 include_once("./Services/Export/classes/class.ilImport.php");
361 $imp = new ilImport();
362 $imp->importEntity(
363 $a_filepath,
364 $a_filename,
365 "pgtp",
366 "Services/COPage"
367 );
368 }
Import class.

Referenced by ilPageLayoutAdministrationGUI\importPageLayout().

+ Here is the caller graph for this function:

◆ readObject()

ilPageLayout::readObject ( )

Read page layout.

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

205 {
207 $query = "SELECT * FROM page_layout WHERE layout_id =" . $ilDB->quote($this->layout_id, "integer");
208 $result = $ilDB->query($query);
209 $row = $ilDB->fetchAssoc($result);
210 $this->title = $row['title'];
211 $this->setStyleId($row['style_id']);
212 $this->setSpecialPage($row['special_page']);
213 $this->description = $row['description'];
214 $this->active = $row['active'];
215
216 $mods = array();
217 if ($row["mod_scorm"]) {
218 $mods[] = self::MODULE_SCORM;
219 }
220 if ($row["mod_portfolio"]) {
221 $mods[] = self::MODULE_PORTFOLIO;
222 }
223 if ($row["mod_lm"]) {
224 $mods[] = self::MODULE_LM;
225 }
226 $this->setModules($mods);
227 }
setSpecialPage($a_val)
Set special page.
setModules(array $a_values=null)
Set modules.
setStyleId($a_val)
Set style id.

References $db, $ilDB, $query, $result, MODULE_LM, MODULE_PORTFOLIO, MODULE_SCORM, setModules(), setSpecialPage(), and setStyleId().

+ Here is the call graph for this function:

◆ setDescription()

ilPageLayout::setDescription (   $a_description)

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

73 {
74 $this->description = $a_description;
75 }

◆ setModules()

ilPageLayout::setModules ( array  $a_values = null)

Set modules.

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

128 {
129 if ($a_values) {
130 $valid = array_keys($this->getAvailableModules());
131 $this->modules = array_intersect($a_values, $valid);
132 } else {
133 $this->modules = array();
134 }
135 }
static getAvailableModules()
$valid

References $valid, and getAvailableModules().

Referenced by readObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSpecialPage()

ilPageLayout::setSpecialPage (   $a_val)

Set special page.

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

112 {
113 $this->special_page = $a_val;
114 }

Referenced by readObject().

+ Here is the caller graph for this function:

◆ setStyleId()

ilPageLayout::setStyleId (   $a_val)

Set style id.

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

96 {
97 $this->style_id = $a_val;
98 }

Referenced by readObject().

+ Here is the caller graph for this function:

◆ setTitle()

ilPageLayout::setTitle (   $a_title)

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

83 {
84 $this->title = $a_title;
85 }

◆ update()

ilPageLayout::update ( )

Update page layout.

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

174 {
176
177 $mod_scorm = $mod_portfolio = $mod_lm = 0;
178 if (in_array(self::MODULE_SCORM, $this->modules)) {
179 $mod_scorm = 1;
180 }
181 if (in_array(self::MODULE_PORTFOLIO, $this->modules)) {
182 $mod_portfolio = 1;
183 }
184 if (in_array(self::MODULE_LM, $this->modules)) {
185 $mod_lm = 1;
186 }
187
188 $query = "UPDATE page_layout SET title=" . $ilDB->quote($this->title, "text") .
189 ",description =" . $ilDB->quote($this->description, "text") .
190 ",active =" . $ilDB->quote($this->active, "integer") .
191 ",style_id =" . $ilDB->quote($this->getStyleId(), "integer") .
192 ",special_page =" . $ilDB->quote((int) $this->getSpecialPage(), "integer") .
193 ",mod_scorm =" . $ilDB->quote($mod_scorm, "integer") .
194 ",mod_portfolio =" . $ilDB->quote($mod_portfolio, "integer") .
195 ",mod_lm =" . $ilDB->quote($mod_lm, "integer") .
196 " WHERE layout_id =" . $ilDB->quote($this->layout_id, "integer");
197
198 $result = $ilDB->manipulate($query);
199 }
getStyleId()
Get style id.
getSpecialPage()
Get special page.

References $db, $ilDB, $query, $result, getSpecialPage(), and getStyleId().

+ Here is the call graph for this function:

Field Documentation

◆ $active

ilPageLayout::$active = null

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

Referenced by getActive(), and getLayoutsAsArray().

◆ $db

ilPageLayout::$db
protected

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

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

◆ $description

ilPageLayout::$description = null

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

Referenced by getDescription().

◆ $layout_id

ilPageLayout::$layout_id = null

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

Referenced by getId().

◆ $modules

ilPageLayout::$modules = array()

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

Referenced by getModules().

◆ $title

ilPageLayout::$title = null

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

Referenced by getTitle().

◆ MODULE_LM

◆ MODULE_PORTFOLIO

const ilPageLayout::MODULE_PORTFOLIO = 2

◆ MODULE_SCORM

const ilPageLayout::MODULE_SCORM = 1

◆ SEQ_TEMPLATE_DIR

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

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


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