ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.arBuilder.php
Go to the documentation of this file.
1 <?php
2 
24 class arBuilder
25 {
26  protected ActiveRecord $ar;
27  protected ?int $step = null;
28 
29  public function __construct(ActiveRecord $activeRecord, ?int $step = null)
30  {
31  $this->setAr($activeRecord);
32  $this->setStep($step ?? 0);
33  }
34 
35  public function generateDBUpdateForInstallation(): void
36  {
37  $ilTemplate = new ilTemplate(__DIR__ . '/templates/dbupdate.txt', true, true);
38  $ar = $this->getAr();
39 
40  $ilTemplate->setVariable('TABLE_NAME', $ar->getConnectorContainerName());
41  $ilTemplate->setVariable('TABLE_NAME2', $ar->getConnectorContainerName());
42  $ilTemplate->setVariable('TABLE_NAME3', $ar->getConnectorContainerName());
43  $ilTemplate->setVariable('STEP', $this->getStep());
44  $ilTemplate->setVariable('PRIMARY', $this->getAr()->getArFieldList()->getPrimaryFieldName());
45 
46  foreach ($this->getAr()->getArFieldList()->getFields() as $arField) {
47  $ilTemplate->touchBlock('field');
48  $ilTemplate->setVariable('FIELD_NAME', $arField->getName());
49  foreach ($arField->getAttributesForConnector() as $name => $value) {
50  $ilTemplate->setCurrentBlock('attribute');
51  $ilTemplate->setVariable('NAME', arFieldList::mapKey($name));
52  $ilTemplate->setVariable('VALUE', $value);
53  $ilTemplate->parseCurrentBlock();
54  }
55  }
56 
57  if ($this->getAr()->getArFieldList()->getPrimaryField()->getFieldType() === arField::FIELD_TYPE_INTEGER) {
58  $ilTemplate->setCurrentBlock('attribute');
59  $ilTemplate->setVariable('TABLE_NAME4', $ar->getConnectorContainerName());
60  $ilTemplate->parseCurrentBlock();
61  }
62 
63  header('Content-type: application/x-httpd-php');
64  header("Content-Disposition: attachment; filename=\"dbupdate.php\"");
65  echo $ilTemplate->get();
66  exit;
67  }
68 
69  public function setAr(\ActiveRecord $activeRecord): void
70  {
71  $this->ar = $activeRecord;
72  }
73 
74  public function getAr(): \ActiveRecord
75  {
76  return $this->ar;
77  }
78 
79  public function setStep(int $step): void
80  {
81  $this->step = $step;
82  }
83 
84  public function getStep(): ?int
85  {
86  return $this->step;
87  }
88 }
setStep(int $step)
__construct(ActiveRecord $activeRecord, ?int $step=null)
static mapKey(string $key)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const FIELD_TYPE_INTEGER
setAr(\ActiveRecord $activeRecord)
getConnectorContainerName()
Return the Name of your Connector Table
ActiveRecord $ar
generateDBUpdateForInstallation()
header()
expected output: > ILIAS shows the rendered Component.
Definition: header.php:29
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...