ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Style\Content\Style\StyleRepo Class Reference
+ Collaboration diagram for ILIAS\Style\Content\Style\StyleRepo:

Public Member Functions

 __construct (ilDBInterface $db, InternalDataService $factory, protected IRSSWrapper $irss)
 
 readRid (int $style_id)
 
 createContainerFromLocalZip (int $style_id, string $local_zip_path, ResourceStakeholder $stakeholder)
 
 createContainerFromLocalDir (int $style_id, string $local_dir_path, ResourceStakeholder $stakeholder, string $container_path="", bool $recursive=true)
 
 getOrCreateRid (int $style_id, ResourceStakeholder $stakeholder)
 
 writeCss (int $style_id, string $css, ResourceStakeholder $stakeholder)
 
 getPath (int $style_id, bool $add_random=true, bool $add_token=true)
 
 getResourceIdentification (int $style_id)
 
 cloneResourceContainer (int $from_style_id, int $to_style_id)
 
 saveUpToDate (int $style_id, bool $up_to_date)
 
 migrateImages (int $style_id)
 

Protected Member Functions

 createRid (int $style_id, ResourceStakeholder $stakeholder)
 

Protected Attributes

ilDBInterface $db
 
InternalDataService $factory
 

Detailed Description

Definition at line 29 of file StyleRepo.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Style\Content\Style\StyleRepo::__construct ( ilDBInterface  $db,
InternalDataService  $factory,
protected IRSSWrapper  $irss 
)

Definition at line 34 of file StyleRepo.php.

38 {
39 $this->db = $db;
40 $this->factory = $factory;
41 }
factory()
InternalDataService $factory
Definition: StyleRepo.php:32

References ILIAS\Style\Content\Style\StyleRepo\$db, ILIAS\Style\Content\Style\StyleRepo\$factory, and factory().

+ Here is the call graph for this function:

Member Function Documentation

◆ cloneResourceContainer()

ILIAS\Style\Content\Style\StyleRepo::cloneResourceContainer ( int  $from_style_id,
int  $to_style_id 
)

Definition at line 177 of file StyleRepo.php.

180 : void {
181 $from_rid = $this->readRid($from_style_id);
182 $to_rid = $this->irss->cloneContainer($from_rid);
183 if ($to_rid !== "") {
184 $this->db->update(
185 "style_data",
186 [
187 "rid" => ["string", $to_rid]
188 ],
189 [ // where
190 "id" => ["integer", $to_style_id]
191 ]
192 );
193 }
194 }

◆ createContainerFromLocalDir()

ILIAS\Style\Content\Style\StyleRepo::createContainerFromLocalDir ( int  $style_id,
string  $local_dir_path,
ResourceStakeholder  $stakeholder,
string  $container_path = "",
bool  $recursive = true 
)

Definition at line 92 of file StyleRepo.php.

98 : string {
99 $rid = $this->irss->createContainerFromLocalDir($local_dir_path, $stakeholder, $container_path, $recursive);
100 $this->db->update(
101 "style_data",
102 [
103 "rid" => ["string", $rid]
104 ],
105 [ // where
106 "id" => ["integer", $style_id]
107 ]
108 );
109 return $rid;
110 }

◆ createContainerFromLocalZip()

ILIAS\Style\Content\Style\StyleRepo::createContainerFromLocalZip ( int  $style_id,
string  $local_zip_path,
ResourceStakeholder  $stakeholder 
)

Definition at line 74 of file StyleRepo.php.

78 : string {
79 $rid = $this->irss->createContainerFromLocalZip($local_zip_path, $stakeholder);
80 $this->db->update(
81 "style_data",
82 [
83 "rid" => ["string", $rid]
84 ],
85 [ // where
86 "id" => ["integer", $style_id]
87 ]
88 );
89 return $rid;
90 }

◆ createRid()

ILIAS\Style\Content\Style\StyleRepo::createRid ( int  $style_id,
ResourceStakeholder  $stakeholder 
)
protected

Definition at line 57 of file StyleRepo.php.

60 : string {
61 $rid = $this->irss->createContainer($stakeholder);
62 $this->db->update(
63 "style_data",
64 [
65 "rid" => ["string", $rid]
66 ],
67 [ // where
68 "id" => ["integer", $style_id]
69 ]
70 );
71 return $rid;
72 }

◆ getOrCreateRid()

ILIAS\Style\Content\Style\StyleRepo::getOrCreateRid ( int  $style_id,
ResourceStakeholder  $stakeholder 
)

Definition at line 112 of file StyleRepo.php.

115 : string {
116 $rid = $this->readRid($style_id);
117 if ($rid === "") {
118 $rid = $this->createRid(
119 $style_id,
120 $stakeholder
121 );
122 }
123 return $rid;
124 }
createRid(int $style_id, ResourceStakeholder $stakeholder)
Definition: StyleRepo.php:57

◆ getPath()

ILIAS\Style\Content\Style\StyleRepo::getPath ( int  $style_id,
bool  $add_random = true,
bool  $add_token = true 
)

Definition at line 137 of file StyleRepo.php.

141 : string {
142 $rid = $this->readRid($style_id);
143
144 if ($rid !== "") {
145 $path = $this->irss->getContainerUri(
146 $rid,
147 "style.css"
148 );
149 if ($add_random) {
150 $random = new \Random\Randomizer();
151 $rand = $random->getInt(1, 999999);
152 $path .= "?dummy=$rand";
153 }
154 } else {
155 $path = \ilFileUtils::getWebspaceDir("output") . "/css/style_" . $style_id . ".css";
156 if ($add_random) {
157 $random = new \Random\Randomizer();
158 $rand = $random->getInt(1, 999999);
159 $path .= "?dummy=$rand";
160 }
161 if ($add_token) {
163 }
164 }
165 return $path;
166 }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static signFile(string $path_to_file)
$path
Definition: ltiservices.php:30

References $path.

◆ getResourceIdentification()

ILIAS\Style\Content\Style\StyleRepo::getResourceIdentification ( int  $style_id)

Definition at line 168 of file StyleRepo.php.

168 : ?ResourceIdentification
169 {
170 $rid = $this->readRid($style_id);
171 if ($rid !== "") {
172 return $this->irss->getResourceIdForIdString($rid);
173 }
174 return null;
175 }

◆ migrateImages()

ILIAS\Style\Content\Style\StyleRepo::migrateImages ( int  $style_id)

Definition at line 211 of file StyleRepo.php.

213 : void {
214 $source_dir = CLIENT_WEB_DIR . '/sty/sty_' . $style_id . "/images";
215 $rid = $this->readRid($style_id);
216 if (is_dir($source_dir) && $rid !== "") {
217 $this->irss->addDirectoryToContainer(
218 $rid,
219 $source_dir,
220 "images"
221 );
222 $style_dir = CLIENT_WEB_DIR . '/sty/sty_' . $style_id;
223 \ilFileUtils::delDir($style_dir);
224 }
225 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
const CLIENT_WEB_DIR
Definition: constants.php:47

◆ readRid()

ILIAS\Style\Content\Style\StyleRepo::readRid ( int  $style_id)

Definition at line 43 of file StyleRepo.php.

43 : string
44 {
45 $set = $this->db->queryF(
46 "SELECT rid FROM style_data " .
47 " WHERE id = %s ",
48 ["integer"],
49 [$style_id]
50 );
51 while ($rec = $this->db->fetchAssoc($set)) {
52 return (string) $rec["rid"];
53 }
54 return "";
55 }

◆ saveUpToDate()

ILIAS\Style\Content\Style\StyleRepo::saveUpToDate ( int  $style_id,
bool  $up_to_date 
)

Definition at line 196 of file StyleRepo.php.

199 : void {
200 $this->db->update(
201 "style_data",
202 [
203 "uptodate" => ["integer", (int) $up_to_date]
204 ],
205 [
206 "id" => ["integer", $style_id]
207 ]
208 );
209 }

◆ writeCss()

ILIAS\Style\Content\Style\StyleRepo::writeCss ( int  $style_id,
string  $css,
ResourceStakeholder  $stakeholder 
)

Definition at line 126 of file StyleRepo.php.

130 : void {
131 $rid = $this->readRid($style_id);
132 if ($rid !== "") {
133 $this->irss->addStringToContainer($rid, $css, "style.css");
134 }
135 }

Field Documentation

◆ $db

ilDBInterface ILIAS\Style\Content\Style\StyleRepo::$db
protected

Definition at line 31 of file StyleRepo.php.

Referenced by ILIAS\Style\Content\Style\StyleRepo\__construct().

◆ $factory

InternalDataService ILIAS\Style\Content\Style\StyleRepo::$factory
protected

Definition at line 32 of file StyleRepo.php.

Referenced by ILIAS\Style\Content\Style\StyleRepo\__construct().


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