ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 
 $layout_id = null
 
 $title = null
 
 $description = null
 
 $active = null
 
 $modules = array()
 

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

References $ilDB, and array.

29  {
30  global $ilias, $ilDB;
31  //create new instance
32  if ($a_id == null) {
33  $this->layout_id = $ilDB->nextId("page_layout");
34  $ilDB->insert("page_layout", array(
35  "layout_id" => array("integer", $this->layout_id),
36  "active" => array("integer", 0),
37  "title" => array("text", ""),
38  "content" => array("clob", ""),
39  "description" => array("text", "")
40  ));
41  //$query = "INSERT INTO page_layout(active) values (0);";
42  //$result = $ilDB->query($query);
43  //$query = "SELECT LAST_INSERT_ID() as id";
44  //$res = $ilDB->query($query);
45  //$row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
46  //$this->layout_id = $row->id;
47  $this->active = false;
48  }
49  else {
50  $this->layout_id = $a_id;
51  }
52  }
Create styles array
The data for the language used.
global $ilDB

Member Function Documentation

◆ activate()

ilPageLayout::activate (   $a_setting = true)

(De-)Activate layout

Parameters
boolean$a_settingtrue/false

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

References $ilDB, $query, and $result.

140  {
141  global $ilias, $ilDB;
142 
143  $query = "UPDATE page_layout SET active=".$ilDB->quote($a_setting, "integer").
144  " WHERE layout_id =".$ilDB->quote($this->layout_id, "integer");
145  $result = $ilDB->manipulate($query);
146  }
$result
global $ilDB

◆ activeLayouts()

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

Get active layouts.

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

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

328  {
329  return self::getLayouts(true, $a_special_page, $a_module);
330  }
+ Here is the caller graph for this function:

◆ delete()

ilPageLayout::delete ( )

Delete page layout.

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

References $ilDB, $query, and $result.

152  {
153  global $ilias, $ilDB;
154 
155  $query = "DELETE FROM page_layout WHERE layout_id =".$ilDB->quote($this->layout_id, "integer");
156  $result = $ilDB->manipulate($query);
157  }
$result
global $ilDB

◆ generatePreview()

ilPageLayout::generatePreview ( )
private

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

References $error, $output, $path, $res, array, domxml_open_mem(), getXMLContent(), getXSLPath(), xpath_eval(), xpath_new_context(), xslt_create(), xslt_error(), and xslt_free().

Referenced by getPreview().

241  {
242 
243  $xml = $this->getXMLContent();
244 
245  $dom = @domxml_open_mem($xml, DOMXML_LOAD_PARSING, $error);
246  $xpc = xpath_new_context($dom);
247  $path = "////PlaceHolder";
248  $res = xpath_eval($xpc, $path);
249 
250  foreach ($res->nodeset as $item){
251  $height = $item->get_attribute("Height");
252 
253  $height = str_ireplace("px","",$height);
254  $height=$height/10;
255  $item->set_attribute("Height",$height."px");
256  }
257  $xsl = file_get_contents($this->getXSLPath());
258 
259  $xml = $dom->dump_mem(0, "UTF-8");
260 
261  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
262 
263  $xh = xslt_create();
264  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
265  xslt_error($xh);
266  xslt_free($xh);
267  return $output;
268  }
xslt_create()
$error
Definition: Error.php:17
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
xslt_free(&$proc)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
xslt_error(&$proc)
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Create styles array
The data for the language used.
domxml_open_mem($str, $mode=0, &$error=NULL)
getXMLContent()
Get xml content.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActive()

ilPageLayout::getActive ( )

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

References $active.

54  {
55  return $this->active;
56  }

◆ getAvailableModules()

static ilPageLayout::getAvailableModules ( )
static

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

References $lng, and array.

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

349  {
350  global $lng;
351 
352  return array(
353  self::MODULE_SCORM => $lng->txt("style_page_layout_module_scorm"),
354  self::MODULE_PORTFOLIO => $lng->txt("style_page_layout_module_portfolio")
355  );
356  }
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ getDescription()

ilPageLayout::getDescription ( )

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

References $description.

58  {
59  return $this->description;
60  }

◆ getId()

ilPageLayout::getId ( )

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

References $layout_id.

74  {
75  return $this->layout_id;
76  }

◆ getLayouts()

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

Get layouts.

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

References $ilDB, $query, $result, $row, array, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilPageLayoutAdministrationGUI\initAddPageLayoutForm().

296  {
297  global $ilDB;
298  $arr_layouts = array();
299  $add = "WHERE special_page = ".$ilDB->quote($a_special_page, "integer");
300  if ($a_active)
301  {
302  $add.= " AND (active = 1)";
303  }
304  switch($a_module)
305  {
306  case self::MODULE_SCORM:
307  $add .= " AND mod_scorm = 1";
308  break;
309 
310  case self::MODULE_PORTFOLIO:
311  $add .= " AND mod_portfolio = 1";
312  break;
313  }
314  $query = "SELECT layout_id FROM page_layout $add ORDER BY title ";
315  $result = $ilDB->query($query);
316  while($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
317  {
318  array_push($arr_layouts,new ilPageLayout($row['layout_id']));
319  }
320 
321  return $arr_layouts;
322  }
$result
Class ilPageLayout.
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getLayoutsAsArray()

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

Static access functions.

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

References $ilDB, $query, $result, $row, array, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilPageLayoutTableGUI\getPageLayouts().

275  {
276 
277  global $ilDB;
278  $arr_layouts = array();
279  if ($active!=0) {
280  $add ="WHERE (active=1)";
281  }
282  $query = "SELECT * FROM page_layout $add ORDER BY title ";
283  $result = $ilDB->query($query);
284  while($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
285  {
286  array_push($arr_layouts,$row);
287  }
288  return $arr_layouts;
289 
290  }
$result
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getModules()

ilPageLayout::getModules ( )

Get modules.

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

References $modules.

130  {
131  return $this->modules;
132  }

◆ getPreview()

ilPageLayout::getPreview ( )

Get preview.

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

References generatePreview().

232  {
233  return $this->generatePreview();
234  }
+ Here is the call graph for this function:

◆ getSpecialPage()

ilPageLayout::getSpecialPage ( )

Get special page.

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

Referenced by update().

106  {
107  return $this->special_page;
108  }
+ Here is the caller graph for this function:

◆ getStyleId()

ilPageLayout::getStyleId ( )

Get style id.

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

Referenced by update().

90  {
91  return $this->style_id;
92  }
+ Here is the caller graph for this function:

◆ getTitle()

ilPageLayout::getTitle ( )

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

References $title.

66  {
67  return $this->title;
68  }

◆ getXMLContent()

ilPageLayout::getXMLContent ( )

Get xml content.

Returns
string content xml

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

Referenced by generatePreview().

221  {
222  include_once "Services/COPage/Layout/classes/class.ilPageLayoutPage.php";
223  $layout_page = new ilPageLayoutPage($this->layout_id);
224  return $layout_page->getXMLContent();
225  }
Page layout page object.
+ Here is the caller graph for this function:

◆ getXSLPath()

ilPageLayout::getXSLPath ( )
private

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

Referenced by generatePreview().

237  {
238  return "./Services/COPage/Layout/xml/layout2html.xsl";
239  }
+ 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 340 of file class.ilPageLayout.php.

Referenced by ilPageLayoutAdministrationGUI\importPageLayout().

341  {
342  include_once("./Services/Export/classes/class.ilImport.php");
343  $imp = new ilImport();
344  $imp->importEntity($a_filepath, $a_filename,
345  "pgtp", "Services/COPage");
346  }
Import class.
+ Here is the caller graph for this function:

◆ readObject()

ilPageLayout::readObject ( )

Read page layout.

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

References $ilDB, $query, $result, $row, array, setModules(), setSpecialPage(), and setStyleId().

192  {
193  global $ilias, $ilDB;
194  $query = "SELECT * FROM page_layout WHERE layout_id =".$ilDB->quote($this->layout_id, "integer");
195  $result = $ilDB->query($query);
196  $row = $ilDB->fetchAssoc($result);
197  $this->title = $row['title'];
198  $this->setStyleId($row['style_id']);
199  $this->setSpecialPage($row['special_page']);
200  $this->description=$row['description'];
201  $this->active=$row['active'];
202 
203  $mods = array();
204  if($row["mod_scorm"])
205  {
206  $mods[] = self::MODULE_SCORM;
207  }
208  if($row["mod_portfolio"])
209  {
210  $mods[] = self::MODULE_PORTFOLIO;
211  }
212  $this->setModules($mods);
213  }
setStyleId($a_val)
Set style id.
$result
setSpecialPage($a_val)
Set special page.
Create styles array
The data for the language used.
global $ilDB
setModules(array $a_values=null)
Set modules.
+ Here is the call graph for this function:

◆ setDescription()

ilPageLayout::setDescription (   $a_description)

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

62  {
63  $this->description = $a_description;
64  }

◆ setModules()

ilPageLayout::setModules ( array  $a_values = null)

Set modules.

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

References $valid, array, and getAvailableModules().

Referenced by readObject().

114  {
115  if($a_values)
116  {
117  $valid = array_keys($this->getAvailableModules());
118  $this->modules = array_intersect($a_values, $valid);
119  }
120  else
121  {
122  $this->modules = array();
123  }
124  }
$valid
static getAvailableModules()
Create styles array
The data for the language used.
+ 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 97 of file class.ilPageLayout.php.

Referenced by readObject().

98  {
99  $this->special_page = $a_val;
100  }
+ Here is the caller graph for this function:

◆ setStyleId()

ilPageLayout::setStyleId (   $a_val)

Set style id.

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

Referenced by readObject().

82  {
83  $this->style_id = $a_val;
84  }
+ Here is the caller graph for this function:

◆ setTitle()

ilPageLayout::setTitle (   $a_title)

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

70  {
71  $this->title = $a_title;
72  }

◆ update()

ilPageLayout::update ( )

Update page layout.

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

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

163  {
164  global $ilias, $ilDB;
165 
166  $mod_scorm = $mod_portfolio = 0;
167  if(in_array(self::MODULE_SCORM, $this->modules))
168  {
169  $mod_scorm = 1;
170  }
171  if(in_array(self::MODULE_PORTFOLIO, $this->modules))
172  {
173  $mod_portfolio = 1;
174  }
175 
176  $query = "UPDATE page_layout SET title=".$ilDB->quote($this->title, "text").
177  ",description =".$ilDB->quote($this->description, "text").
178  ",active =".$ilDB->quote($this->active, "integer").
179  ",style_id =".$ilDB->quote($this->getStyleId(), "integer").
180  ",special_page =".$ilDB->quote((int) $this->getSpecialPage(), "integer").
181  ",mod_scorm =".$ilDB->quote($mod_scorm, "integer").
182  ",mod_portfolio =".$ilDB->quote($mod_portfolio, "integer").
183  " WHERE layout_id =".$ilDB->quote($this->layout_id, "integer");
184 
185  $result = $ilDB->manipulate($query);
186  }
$result
getSpecialPage()
Get special page.
getStyleId()
Get style id.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $active

ilPageLayout::$active = null

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

Referenced by getActive().

◆ $description

ilPageLayout::$description = null

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

Referenced by getDescription().

◆ $layout_id

ilPageLayout::$layout_id = null

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

Referenced by getId().

◆ $modules

ilPageLayout::$modules = array()

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

Referenced by getModules().

◆ $title

ilPageLayout::$title = null

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

Referenced by getTitle().

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


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