ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilPollDataSet Class Reference

Poll Dataset class. More...

+ Inheritance diagram for ilPollDataSet:
+ Collaboration diagram for ilPollDataSet:

Public Member Functions

 __construct ()
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 getDirectDataFromQuery (string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text" > <ftype name="field_2" type="date" > <ftype name="field_3" type="integer" > </types> <types ...> ... </types> <set entity="table_name"> <rec> <field_1>content</field_1> <field_2>my_date</field_2> <field_3>my_number</field_3> </rec> ... </set> </dataset> More...
 
 addRecordsXml (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names.Please note that the abstract fields/types only depend on the version! Not on a choosen representation!

Returns
array types array, e.g. array("field_1" => "text", "field_2" => "integer", ...)
More...
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

const string ENTITY = "poll"
 
NotesService $notes
 
DataFactory $data_factory
 
ilObjuser $user
 
PollImageFactoryInterface $poll_image_factory
 
- Protected Attributes inherited from ilDataSet
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 
int $dircnt = 0
 

Detailed Description

Poll Dataset class.

This class implements the following entities:

  • poll: object data
  • poll_answer: data from table il_poll_answer
Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 35 of file class.ilPollDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilPollDataSet::__construct ( )

Reimplemented from ilDataSet.

Definition at line 43 of file class.ilPollDataSet.php.

44 {
45 global $DIC;
46
48 $this->notes = $DIC->notes();
49 $this->data_factory = new DataFactory();
50 $this->user = $DIC->user();
51 $this->poll_image_factory = new PollImageFactory();
52 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDependencies()

ilPollDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected

Reimplemented from ilDataSet.

Definition at line 189 of file class.ilPollDataSet.php.

194 : array {
195 switch ($a_entity) {
196 case "poll":
197 return array(
198 "poll_answer" => array("ids" => $a_rec["Id"] ?? null)
199 );
200 }
201 return [];
202 }

◆ getSupportedVersions()

ilPollDataSet::getSupportedVersions ( )

Reimplemented from ilDataSet.

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

54 : array
55 {
56 return array("4.3.0", "5.0.0", "10.0");
57 }

◆ getTypes()

ilPollDataSet::getTypes ( string  $a_entity,
string  $a_version 
)
protected

Get (abstract) types for (abstract) field names.Please note that the abstract fields/types only depend on the version! Not on a choosen representation!

Returns
array types array, e.g. array("field_1" => "text", "field_2" => "integer", ...)

Reimplemented from ilDataSet.

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

67 : array
68 {
69 if ($a_entity === self::ENTITY) {
70 switch ($a_version) {
71 case "4.3.0":
72 return array(
73 "Id" => "integer",
74 "Title" => "text",
75 "Description" => "text",
76 "Question" => "text",
77 "Image" => "text",
78 "ViewResults" => "integer",
79 "Dir" => "directory"
80 );
81 break;
82 case "5.0.0":
83 return array(
84 "Id" => "integer",
85 "Title" => "text",
86 "Description" => "text",
87 "Question" => "text",
88 "Image" => "text",
89 "ViewResults" => "integer",
90 "Dir" => "directory",
91 "ShowResultsAs" => "integer",
92 "ShowComments" => "integer",
93 "MaxAnswers" => "integer",
94 "ResultSort" => "integer",
95 "NonAnon" => "integer",
96 "Period" => "integer",
97 "PeriodBegin" => "integer",
98 "PeriodEnd" => "integer"
99
100 );
101 break;
102 case "10.0":
103 return array(
104 "Id" => "integer",
105 "Title" => "text",
106 "Description" => "text",
107 "Question" => "text",
108 "Image" => "text", // Image now contains the full path, not just the name
109 "ViewResults" => "integer",
110 "ShowResultsAs" => "integer",
111 "ShowComments" => "integer",
112 "MaxAnswers" => "integer",
113 "ResultSort" => "integer",
114 "NonAnon" => "integer",
115 "Period" => "integer",
116 "PeriodBegin" => "integer",
117 "PeriodEnd" => "integer"
118 );
119 break;
120 }
121 }
122
123 if ($a_entity === "poll_answer") {
124 switch ($a_version) {
125 case "4.3.0":
126 case "5.0.0":
127 case "10.0":
128 return array(
129 "Id" => "integer",
130 "PollId" => "integer",
131 "Answer" => "text",
132 "Pos" => "integer",
133 );
134 break;
135 }
136 }
137
138 return [];
139 }

◆ getXmlNamespace()

ilPollDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

Reimplemented from ilDataSet.

Definition at line 59 of file class.ilPollDataSet.php.

59 : string
60 {
61 return "http://www.ilias.de/xml/Modules/Poll/" . $a_entity;
62 }

◆ getXmlRecord()

ilPollDataSet::getXmlRecord ( string  $a_entity,
string  $a_version,
array  $a_set 
)

Get xml record for version.

Parameters
array$a_setabstract data record

Reimplemented from ilDataSet.

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

204 : array
205 {
206 if ($a_entity === self::ENTITY) {
207 $resource = $this->poll_image_factory->handler()->getRessource(
208 $this->data_factory->objId((int) $a_set["Id"])
209 );
210 if ($resource !== null) {
211 $title = $resource->getTitle();
212 $path_in_container = ltrim($this->export->getExportDirInContainer(), '/') . '/image/' . $title;
213 $this->export->getExportWriter()->writeFilesByResourceId(
214 $resource->getIdentification()->serialize(),
215 $path_in_container
216 );
217 /*
218 * For some reason, the name of the import file itself is included in getImportDirectory,
219 * so has to be removed here. Might need to take this out again if anything changes.
220 */
221 $path_to_image = explode('/', $path_in_container);
222 unset($path_to_image[0]);
223 $path_to_image = implode('/', $path_to_image);
224 $a_set["Image"] = $path_to_image;
225 } else {
226 $a_set["Image"] = '';
227 }
228
229 $a_set["ShowComments"] = $this->notes->domain()->commentsActive((int) $a_set["Id"]);
230 }
231 return $a_set;
232 }

◆ readData()

ilPollDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)

Read data from DB.

This should result in the abstract field structure of the version set in the constructor.

Reimplemented from ilDataSet.

Definition at line 141 of file class.ilPollDataSet.php.

141 : void
142 {
144
145 if ($a_entity === self::ENTITY) {
146 switch ($a_version) {
147 case "4.3.0":
148 $this->getDirectDataFromQuery("SELECT pl.id,od.title,od.description," .
149 "pl.question,pl.image,pl.view_results" .
150 " FROM il_poll pl" .
151 " JOIN object_data od ON (od.obj_id = pl.id)" .
152 " WHERE " . $ilDB->in("pl.id", $a_ids, false, "integer") .
153 " AND od.type = " . $ilDB->quote("poll", "text"));
154 break;
155 case "5.0.0":
156 $this->getDirectDataFromQuery("SELECT pl.id,od.title,od.description" .
157 ",pl.question,pl.image,pl.view_results,pl.show_results_as" .
158 ",pl.max_answers,pl.result_sort,pl.non_anon,pl.period,pl.period_begin,pl.period_end" .
159 " FROM il_poll pl" .
160 " JOIN object_data od ON (od.obj_id = pl.id)" .
161 " WHERE " . $ilDB->in("pl.id", $a_ids, false, "integer") .
162 " AND od.type = " . $ilDB->quote("poll", "text"));
163 break;
164 case "10.0":
165 $this->getDirectDataFromQuery("SELECT pl.id,od.title,od.description" .
166 ",pl.question,pl.view_results,pl.show_results_as" .
167 ",pl.max_answers,pl.result_sort,pl.non_anon,pl.period,pl.period_begin,pl.period_end" .
168 " FROM il_poll pl" .
169 " JOIN object_data od ON (od.obj_id = pl.id)" .
170 " WHERE " . $ilDB->in("pl.id", $a_ids, false, "integer") .
171 " AND od.type = " . $ilDB->quote("poll", "text"));
172 break;
173 }
174 }
175
176 if ($a_entity === "poll_answer") {
177 switch ($a_version) {
178 case "4.3.0":
179 case "5.0.0":
180 case "10.0":
181 $this->getDirectDataFromQuery("SELECT id,poll_id,answer,pos" .
182 " FROM il_poll_answer WHERE " .
183 $ilDB->in("poll_id", $a_ids, false, "integer"));
184 break;
185 }
186 }
187 }
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
ilDBInterface $db

References ilDataSet\$db, $ilDB, and ilDataSet\getDirectDataFromQuery().

+ Here is the call graph for this function:

Field Documentation

◆ $data_factory

DataFactory ilPollDataSet::$data_factory
protected

Definition at line 39 of file class.ilPollDataSet.php.

◆ $notes

NotesService ilPollDataSet::$notes
protected

Definition at line 38 of file class.ilPollDataSet.php.

◆ $poll_image_factory

PollImageFactoryInterface ilPollDataSet::$poll_image_factory
protected

Definition at line 41 of file class.ilPollDataSet.php.

◆ $user

ilObjuser ilPollDataSet::$user
protected

Definition at line 40 of file class.ilPollDataSet.php.

◆ ENTITY

const string ilPollDataSet::ENTITY = "poll"
protected

Definition at line 37 of file class.ilPollDataSet.php.


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