ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 10 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 49 of file class.ilStyleClassCopiedObjective.php.

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

49  : Environment
50  {
51  $db = $environment->getResource(Environment::RESOURCE_DATABASE);
52 
53  $sql =
54  "SELECT obj_id" . PHP_EOL
55  . "FROM object_data" . PHP_EOL
56  . "WHERE type = 'sty'" . PHP_EOL
57  ;
58 
59  $result = $db->query($sql);
60 
61  while ($row = $db->fetchAssoc($result)) {
62  $sql =
63  "SELECT style_id, type, characteristic, hide" . PHP_EOL
64  . "FROM style_char" . PHP_EOL
65  . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
66  . "AND characteristic = " . $db->quote($this->class, "text") . PHP_EOL
67  . "AND type = " . $db->quote($this->type, "text") . PHP_EOL
68  ;
69  $res = $db->query($sql);
70 
71  if (!$db->fetchAssoc($res)) {
72  $values = [
73  "style_id" => ["integer", $row["obj_id"]],
74  "type" => ["text", $this->type],
75  "characteristic" => ["text", $this->class],
76  "hide" => ["integer", $this->hide]
77  ];
78  $db->insert("style_char", $values);
79 
80  $sql =
81  "SELECT id, style_id, tag, class, parameter, value, type, mq_id, custom" . PHP_EOL
82  . "FROM style_parameter" . PHP_EOL
83  . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
84  . "AND type = " . $db->quote($this->type, "text") . PHP_EOL
85  . "AND class = " . $db->quote($this->orig_class, "text") . PHP_EOL
86  . "AND tag = " . $db->quote($this->tag, "text") . PHP_EOL
87  ;
88 
89  $res = $db->query($sql);
90 
91  while ($row_2 = $db->fetchAssoc($res)) {
92  $spid = $db->nextId("style_parameter");
93  $values = [
94  "id" => ["integer", $spid],
95  "style_id" => ["integer", $row["obj_id"]],
96  "tag" => ["text", $this->tag],
97  "class" => ["text", $this->class],
98  "parameter" => ["text", $row_2["parameter"]],
99  "value" => ["text", $row_2["value"]],
100  "type" => ["text", $row_2["type"]]
101  ];
102  $db->insert("style_parameter", $values);
103  }
104  }
105  }
106 
107  return $environment;
108  }
$res
Definition: ltiservices.php:69
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
+ Here is the call graph for this function:

◆ getHash()

ilStyleClassCopiedObjective::getHash ( )

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

27  : string
28  {
29  return hash("sha256", self::class);
30  }

◆ getLabel()

ilStyleClassCopiedObjective::getLabel ( )

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

32  : string
33  {
34  return "Copy style class";
35  }

◆ getPreconditions()

ilStyleClassCopiedObjective::getPreconditions ( Environment  $environment)

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

42  : array
43  {
44  return [
46  ];
47  }

◆ isApplicable()

ilStyleClassCopiedObjective::isApplicable ( Environment  $environment)

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

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

110  : bool
111  {
112  $db = $environment->getResource(Environment::RESOURCE_DATABASE);
113 
114  $sql =
115  "SELECT obj_id" . PHP_EOL
116  . "FROM object_data" . PHP_EOL
117  . "WHERE type = 'sty'" . PHP_EOL
118  ;
119  $result = $db->query($sql);
120 
121  if ($db->numRows($result) == 0) {
122  return false;
123  }
124 
125  while ($row = $db->fetchAssoc($result)) {
126  $sql =
127  "SELECT style_id, type, characteristic, hide" . PHP_EOL
128  . "FROM style_char" . PHP_EOL
129  . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
130  . "AND characteristic = " . $db->quote($this->class, "text") . PHP_EOL
131  . "AND type = " . $db->quote($this->type, "text") . PHP_EOL
132  ;
133 
134  $res = $db->query($sql);
135 
136  if ($db->numRows($res)) {
137  return false;
138  }
139  }
140  return true;
141  }
$res
Definition: ltiservices.php:69
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
+ Here is the call graph for this function:

◆ isNotable()

ilStyleClassCopiedObjective::isNotable ( )

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

37  : bool
38  {
39  return true;
40  }

Field Documentation

◆ $class

string ilStyleClassCopiedObjective::$class
protected

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

Referenced by achieve().

◆ $hide

int ilStyleClassCopiedObjective::$hide
protected

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

Referenced by __construct(), and achieve().

◆ $orig_class

string ilStyleClassCopiedObjective::$orig_class
protected

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

Referenced by __construct().

◆ $tag

string ilStyleClassCopiedObjective::$tag
protected

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

Referenced by __construct(), and achieve().

◆ $type

string ilStyleClassCopiedObjective::$type
protected

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

Referenced by __construct(), and achieve().


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