ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilStyleClassCopiedObjective Class Reference
+ Inheritance diagram for ilStyleClassCopiedObjective:
+ Collaboration diagram for ilStyleClassCopiedObjective:

Public Member Functions

 __construct (string $orig_class, string $class, string $type, string $tag, int $hide=0)
 
 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 getPreconditions (Environment $environment)
 
 achieve (Environment $environment)
 
 isApplicable (Environment $environment)
 

Protected Attributes

string $orig_class
 
string $class
 
string $type
 
string $tag
 
int $hide
 

Detailed Description

Definition at line 24 of file class.ilStyleClassCopiedObjective.php.

Constructor & Destructor Documentation

◆ __construct()

ilStyleClassCopiedObjective::__construct ( string  $orig_class,
string  $class,
string  $type,
string  $tag,
int  $hide = 0 
)

Member Function Documentation

◆ achieve()

ilStyleClassCopiedObjective::achieve ( Environment  $environment)

Definition at line 63 of file class.ilStyleClassCopiedObjective.php.

64 {
65 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
66
67 $sql =
68 "SELECT obj_id" . PHP_EOL
69 . "FROM object_data" . PHP_EOL
70 . "WHERE type = 'sty'" . PHP_EOL
71 ;
72
73 $result = $db->query($sql);
74
75 while ($row = $db->fetchAssoc($result)) {
76 $sql =
77 "SELECT style_id, type, characteristic, hide" . PHP_EOL
78 . "FROM style_char" . PHP_EOL
79 . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
80 . "AND characteristic = " . $db->quote($this->class, "text") . PHP_EOL
81 . "AND type = " . $db->quote($this->type, "text") . PHP_EOL
82 ;
83 $res = $db->query($sql);
84
85 if (!$db->fetchAssoc($res)) {
86 $values = [
87 "style_id" => ["integer", $row["obj_id"]],
88 "type" => ["text", $this->type],
89 "characteristic" => ["text", $this->class],
90 "hide" => ["integer", $this->hide]
91 ];
92 $db->insert("style_char", $values);
93
94 $sql =
95 "SELECT id, style_id, tag, class, parameter, value, type, mq_id, custom" . PHP_EOL
96 . "FROM style_parameter" . PHP_EOL
97 . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
98 . "AND type = " . $db->quote($this->type, "text") . PHP_EOL
99 . "AND class = " . $db->quote($this->orig_class, "text") . PHP_EOL
100 . "AND tag = " . $db->quote($this->tag, "text") . PHP_EOL
101 ;
102
103 $res = $db->query($sql);
104
105 while ($row_2 = $db->fetchAssoc($res)) {
106 $spid = $db->nextId("style_parameter");
107 $values = [
108 "id" => ["integer", $spid],
109 "style_id" => ["integer", $row["obj_id"]],
110 "tag" => ["text", $this->tag],
111 "class" => ["text", $this->class],
112 "parameter" => ["text", $row_2["parameter"]],
113 "value" => ["text", $row_2["value"]],
114 "type" => ["text", $row_2["type"]]
115 ];
116 $db->insert("style_parameter", $values);
117 }
118 }
119 }
120
121 return $environment;
122 }
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
$res
Definition: ltiservices.php:69

References $class, $hide, $res, $tag, $type, and ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ getHash()

ilStyleClassCopiedObjective::getHash ( )

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

41 : string
42 {
43 return hash("sha256", self::class);
44 }

◆ getLabel()

ilStyleClassCopiedObjective::getLabel ( )

Definition at line 46 of file class.ilStyleClassCopiedObjective.php.

46 : string
47 {
48 return "Copy style class";
49 }

◆ getPreconditions()

ilStyleClassCopiedObjective::getPreconditions ( Environment  $environment)

◆ isApplicable()

ilStyleClassCopiedObjective::isApplicable ( Environment  $environment)

Definition at line 124 of file class.ilStyleClassCopiedObjective.php.

124 : bool
125 {
126 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
127
128 $sql =
129 "SELECT obj_id" . PHP_EOL
130 . "FROM object_data" . PHP_EOL
131 . "WHERE type = 'sty'" . PHP_EOL
132 ;
133 $result = $db->query($sql);
134
135 if ($db->numRows($result) == 0) {
136 return false;
137 }
138
139 while ($row = $db->fetchAssoc($result)) {
140 $sql =
141 "SELECT style_id, type, characteristic, hide" . PHP_EOL
142 . "FROM style_char" . PHP_EOL
143 . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
144 . "AND characteristic = " . $db->quote($this->class, "text") . PHP_EOL
145 . "AND type = " . $db->quote($this->type, "text") . PHP_EOL
146 ;
147
148 $res = $db->query($sql);
149
150 if ($db->numRows($res)) {
151 return false;
152 }
153 }
154 return true;
155 }

References $res, and ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ isNotable()

ilStyleClassCopiedObjective::isNotable ( )

Definition at line 51 of file class.ilStyleClassCopiedObjective.php.

51 : bool
52 {
53 return true;
54 }

Field Documentation

◆ $class

string ilStyleClassCopiedObjective::$class
protected

Definition at line 27 of file class.ilStyleClassCopiedObjective.php.

Referenced by achieve().

◆ $hide

int ilStyleClassCopiedObjective::$hide
protected

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

Referenced by __construct(), and achieve().

◆ $orig_class

string ilStyleClassCopiedObjective::$orig_class
protected

Definition at line 26 of file class.ilStyleClassCopiedObjective.php.

Referenced by __construct().

◆ $tag

string ilStyleClassCopiedObjective::$tag
protected

Definition at line 29 of file class.ilStyleClassCopiedObjective.php.

Referenced by __construct(), and achieve().

◆ $type

string ilStyleClassCopiedObjective::$type
protected

Definition at line 28 of file class.ilStyleClassCopiedObjective.php.

Referenced by __construct(), and achieve().


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