ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjContentPage.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
12  protected $styleId = 0;
13 
17  protected function initType()
18  {
19  $this->type = self::OBJ_TYPE;
20  }
21 
25  public function getStyleSheetId() : int
26  {
27  return (int) $this->styleId;
28  }
29 
33  public function setStyleSheetId(int $styleId)
34  {
35  $this->styleId = $styleId;
36  }
37 
41  public function writeStyleSheetId(int $styleId)
42  {
43  $this->db->manipulateF(
44  'UPDATE content_object SET stylesheet = %s WHERE id = %s',
45  ['integer', 'integer'],
46  [(int) $styleId, $this->getId()]
47  );
48 
49  $this->setStyleSheetId($styleId);
50  }
51 
55  protected function doCloneObject($new_obj, $a_target_id, $a_copy_id = null)
56  {
58  parent::doCloneObject($new_obj, $a_target_id, $a_copy_id);
59 
60  if (\ilContentPagePage::_exists($this->getType(), $this->getId())) {
61  $originalPageObject = new \ilContentPagePage($this->getId());
62  $copiedXML = $originalPageObject->copyXmlContent();
63 
64  $duplicatePageObject = new \ilContentPagePage();
65  $duplicatePageObject->setId($new_obj->getId());
66  $duplicatePageObject->setParentId($new_obj->getId());
67  $duplicatePageObject->setXMLContent($copiedXML);
68  $duplicatePageObject->createFromXML();
69  }
70 
71  $styleId = $this->getStyleSheetId();
74  if ($style) {
75  $new_id = $style->ilClone();
76  $new_obj->setStyleSheetId($new_id);
77  $new_obj->update();
78  }
79  }
80 
82  $new_obj->getId(),
85  $this->getId(),
87  true
88  )
89  );
90 
91  $lpSettings = new ilLPObjSettings($this->getId());
92  $lpSettings->cloneSettings($new_obj->getId());
93  }
94 
98  protected function doRead()
99  {
100  parent::doRead();
101 
102  $res = $this->db->queryF(
103  'SELECT * FROM content_page_data WHERE content_page_id = %s',
104  ['integer'],
105  [$this->getId()]
106  );
107 
108  while ($data = $this->db->fetchAssoc($res)) {
109  $this->setStyleSheetId((int) $data['stylesheet']);
110  }
111  }
112 
116  protected function doCreate()
117  {
118  parent::doCreate();
119 
120  $this->db->manipulateF(
121  '
122  INSERT INTO content_page_data
123  (
124  content_page_id,
125  stylesheet
126  )
127  VALUES(%s, %s)',
128  ['integer', 'integer'],
129  [$this->getId(), 0]
130  );
131  }
132 
133 
137  protected function doUpdate()
138  {
139  parent::doUpdate();
140 
141  $this->db->manipulateF(
142  '
143  UPDATE content_page_data
144  SET
145  stylesheet = %s
146  WHERE content_page_id = %s',
147  ['integer', 'integer'],
148  [$this->getStyleSheetId(), $this->getId()]
149  );
150  }
151 
155  protected function doDelete()
156  {
157  parent::doDelete();
158 
159  if (\ilContentPagePage::_exists($this->getType(), $this->getId())) {
160  $originalPageObject = new \ilContentPagePage($this->getId());
161  $originalPageObject->delete();
162  }
163  }
164 
168  public function getPageObjIds() : array
169  {
170  $pageObjIds = [];
171 
172  $sql = "SELECT page_id FROM page_object WHERE parent_id = %s AND parent_type = %s";
173  $res = $this->db->queryF(
174  $sql,
175  ['integer', 'text'],
176  [$this->getId(), $this->getType()]
177  );
178 
179  while ($row = $this->db->fetchAssoc($res)) {
180  $pageObjIds[] = $row['page_id'];
181  }
182 
183  return $pageObjIds;
184  }
185 
189  public function trackProgress(int $usrId)
190  {
192  $this->getType(),
193  $this->getRefId(),
194  $this->getId(),
195  $usrId
196  );
197 
199  $this->getId(),
200  $usrId
201  );
202  }
203 }
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
$style
Definition: example_012.php:70
Interface ilContentPageObjectConstants.
writeStyleSheetId(int $styleId)
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _lookupStandard($a_id)
Lookup standard flag.
doCloneObject($new_obj, $a_target_id, $a_copy_id=null)
foreach($_POST as $key=> $value) $res
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjContentPage.
setStyleSheetId(int $styleId)
$row
static _writeContainerSetting($a_id, $a_keyword, $a_value)
Class ilObject2 This is an intermediate progress of ilObject class.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
$data
Definition: bench.php:6