ILIAS  release_8 Revision v8.24
class.arBuilder.php
Go to the documentation of this file.
1<?php
2
3/******************************************************************************
4 *
5 * This file is part of ILIAS, a powerful learning management system.
6 *
7 * ILIAS is licensed with the GPL-3.0, you should have received a copy
8 * of said license along with the source code.
9 *
10 * If this is not the case or you just want to try ILIAS, you'll find
11 * us at:
12 * https://www.ilias.de
13 * https://github.com/ILIAS-eLearning
14 *
15 *****************************************************************************/
22{
23 protected ActiveRecord $ar;
24 protected ?int $step = null;
25
26 public function __construct(ActiveRecord $ar, int $step = null)
27 {
28 $this->setAr($ar);
29 $this->setStep($step ?? 0);
30 }
31
32 public function generateDBUpdateForInstallation(): void
33 {
34 $tpl = new ilTemplate(__DIR__ . '/templates/dbupdate.txt', true, true);
35 $ar = $this->getAr();
36
37 $tpl->setVariable('TABLE_NAME', $ar->getConnectorContainerName());
38 $tpl->setVariable('TABLE_NAME2', $ar->getConnectorContainerName());
39 $tpl->setVariable('TABLE_NAME3', $ar->getConnectorContainerName());
40 $tpl->setVariable('STEP', $this->getStep());
41 $tpl->setVariable('PRIMARY', $this->getAr()->getArFieldList()->getPrimaryFieldName());
42
43 foreach ($this->getAr()->getArFieldList()->getFields() as $field) {
44 $tpl->touchBlock('field');
45 $tpl->setVariable('FIELD_NAME', $field->getName());
46 foreach ($field->getAttributesForConnector() as $name => $value) {
47 $tpl->setCurrentBlock('attribute');
48 $tpl->setVariable('NAME', arFieldList::mapKey($name));
49 $tpl->setVariable('VALUE', $value);
50 $tpl->parseCurrentBlock();
51 }
52 }
53
54 if ($this->getAr()->getArFieldList()->getPrimaryField()->getFieldType() === arField::FIELD_TYPE_INTEGER) {
55 $tpl->setCurrentBlock('attribute');
56 $tpl->setVariable('TABLE_NAME4', $ar->getConnectorContainerName());
57 $tpl->parseCurrentBlock();
58 }
59
60 header('Content-type: application/x-httpd-php');
61 header("Content-Disposition: attachment; filename=\"dbupdate.php\"");
62 echo $tpl->get();
63 exit;
64 }
65
66 public function setAr(\ActiveRecord $ar): void
67 {
68 $this->ar = $ar;
69 }
70
71 public function getAr(): \ActiveRecord
72 {
73 return $this->ar;
74 }
75
76 public function setStep(int $step): void
77 {
78 $this->step = $step;
79 }
80
81 public function getStep(): int
82 {
83 return $this->step;
84 }
85}
Class ActiveRecord.
getConnectorContainerName()
@description Return the Name of your Connector Table
Class arBuilder.
generateDBUpdateForInstallation()
ActiveRecord $ar
setStep(int $step)
__construct(ActiveRecord $ar, int $step=null)
setAr(\ActiveRecord $ar)
static mapKey(string $key)
const FIELD_TYPE_INTEGER
special template class to simplify handling of ITX/PEAR
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
exit
Definition: login.php:28
if($format !==null) $name
Definition: metadata.php:247