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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilNewsDataSet:
+ Collaboration diagram for ilNewsDataSet:

Public Member Functions

 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 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...
 
- 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. More...
 
- 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=[])
 

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
 
- 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
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning News data set class

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Member Function Documentation

◆ getSupportedVersions()

ilNewsDataSet::getSupportedVersions ( )

Reimplemented from ilDataSet.

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

25 : array
26 {
27 return ["5.4.0", "4.1.0"];
28 }

◆ getTypes()

ilNewsDataSet::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 35 of file class.ilNewsDataSet.php.

35 : array
36 {
37 if ($a_entity === "news") {
38 switch ($a_version) {
39 case "4.1.0":
40 case "5.4.0":
41 return [
42 "Id" => "integer",
43 "Title" => "text",
44 "Content" => "text",
45 "Priority" => "integer",
46 "ContextObjId" => "integer",
47 "ContextObjType" => "text",
48 "ContextSubObjId" => "integer",
49 "ContextSubObjType" => "text",
50 "ContentType" => "text",
51 "Visibility" => "text",
52 "ContentLong" => "text",
53 "ContentIsLangVar" => "integer",
54 "MobId" => "integer",
55 "Playtime" => "text"
56 ];
57 }
58 }
59 if ($a_entity === "news_settings") {
60 switch ($a_version) {
61 case "5.4.0":
62 return [
63 "ObjId" => "integer",
64 "PublicFeed" => "integer",
65 "DefaultVisibility" => "text",
66 "KeepRssMin" => "integer",
67 "HideNewsPerDate" => "integer",
68 "HideNewsDate" => "text",
69 "PublicNotifications" => "integer"
70 ];
71 }
72 }
73 return [];
74 }

◆ getXmlNamespace()

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

Reimplemented from ilDataSet.

Definition at line 30 of file class.ilNewsDataSet.php.

30 : string
31 {
32 return "https://www.ilias.de/xml/Services/News/" . $a_entity;
33 }

◆ importRecord()

ilNewsDataSet::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.

Reimplemented from ilDataSet.

Definition at line 115 of file class.ilNewsDataSet.php.

115 : void
116 {
117 $a_rec = $this->stripTags($a_rec);
118 switch ($a_entity) {
119 case "news":
120 $mob_id = null;
121 if ($a_rec["MobId"] > 0) {
122 $mob_id = $a_mapping->getMapping("components/ILIAS/MediaObjects", "mob", $a_rec["MobId"]);
123 }
124 $c = (int) $a_rec["ContextObjId"] . ":" . $a_rec["ContextObjType"] . ":" . (int) $a_rec["ContextSubObjId"] .
125 ":" . $a_rec["ContextSubObjType"];
126 $context = $a_mapping->getMapping("components/ILIAS/News", "news_context", $c);
127 $context = explode(":", $context);
128
129 $newObj = new ilNewsItem();
130 $newObj->setTitle($a_rec["Title"]);
131 $newObj->setContent($a_rec["Content"]);
132 $newObj->setPriority($a_rec["Priority"]);
133 $newObj->setContextObjId((int) $context[0]);
134 $newObj->setContextObjType($context[1]);
135 $newObj->setContextSubObjId((int) $context[2]);
136 $newObj->setContextSubObjType($context[3]);
137 $newObj->setContentType($a_rec["ContentType"]);
138 $newObj->setVisibility($a_rec["Visibility"]);
139 $newObj->setContentLong($a_rec["ContentLong"]);
140 $newObj->setContentIsLangVar($a_rec["ContentIsLangVar"]);
141 $newObj->setMobId((int) $mob_id);
142 $newObj->setPlaytime($a_rec["Playtime"]);
143 $newObj->create();
144 $a_mapping->addMapping("components/ILIAS/News", "news", $a_rec["Id"], (string) $newObj->getId());
145 break;
146
147 case "news_settings":
148
149 $dummy_dataset = new ilObjectDataSet();
150 $new_obj_id = $dummy_dataset->getNewObjId($a_mapping, $a_rec["ObjId"]);
151
152 if ($new_obj_id > 0 && $a_schema_version === "5.4.0") {
153 foreach ([
154 "public_feed" => "PublicFeed",
155 "keep_rss_min" => "KeepRssMin",
156 "default_visibility" => "DefaultVisibility",
157 "hide_news_per_date" => "HideNewsPerDate",
158 "hide_news_date" => "HideNewsDate",
159 "public_notifications" => "PublicNotifications"
160 ] as $set => $field) {
162 "news",
163 $set,
164 $a_rec[$field],
165 0,
166 $new_obj_id
167 );
168 }
169 }
170 break;
171 }
172 }
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
stripTags(array $rec, array $omit_keys=[])
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
A news item can be created by different sources.
Object data set class.
$c
Definition: deliver.php:25
$context
Definition: webdav.php:31

References $c, $context, ilBlockSetting\_write(), ilImportMapping\addMapping(), ilImportMapping\getMapping(), ILIAS\Repository\int(), and ilDataSet\stripTags().

+ Here is the call graph for this function:

◆ readData()

ilNewsDataSet::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 76 of file class.ilNewsDataSet.php.

76 : void
77 {
79
80 if (!is_array($a_ids)) {
81 $a_ids = [$a_ids];
82 }
83
84 if ($a_entity === "news") {
85 switch ($a_version) {
86 case "4.1.0":
87 case "5.4.0":
88 $this->getDirectDataFromQuery("SELECT id, title, content, priority," .
89 " context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, " .
90 " content_type, visibility, content_long, content_is_lang_var, mob_id, playtime" .
91 " FROM il_news_item " .
92 "WHERE " .
93 $ilDB->in("id", $a_ids, false, "integer"));
94 break;
95 }
96 }
97
98 if ($a_entity === "news_settings") {
99 switch ($a_version) {
100 case "5.4.0":
101 foreach ($a_ids as $obj_id) {
102 $this->data[$obj_id]["ObjId"] = $obj_id;
103 $this->data[$obj_id]["PublicFeed"] = ilBlockSetting::_lookup("news", "public_feed", 0, $obj_id);
104 $this->data[$obj_id]["KeepRssMin"] = (int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $obj_id);
105 $this->data[$obj_id]["DefaultVisibility"] = ilBlockSetting::_lookup("news", "default_visibility", 0, $obj_id);
106 $this->data[$obj_id]["HideNewsPerDate"] = (int) ilBlockSetting::_lookup("news", "hide_news_per_date", 0, $obj_id);
107 $this->data[$obj_id]["HideNewsDate"] = ilBlockSetting::_lookup("news", "hide_news_date", 0, $obj_id);
108 $this->data[$obj_id]["PublicNotifications"] = (int) ilBlockSetting::_lookup("news", "public_notifications", 0, $obj_id);
109 }
110 break;
111 }
112 }
113 }
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
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, ilBlockSetting\_lookup(), ilDataSet\getDirectDataFromQuery(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

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