ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStyleClassAddedObjective Class Reference
+ Inheritance diagram for ilStyleClassAddedObjective:
+ Collaboration diagram for ilStyleClassAddedObjective:

Public Member Functions

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

Protected Attributes

string $class
 
string $type
 
string $tag
 
array $parameters
 
int $hide
 

Detailed Description

Definition at line 10 of file class.ilStyleClassAddedObjective.php.

Constructor & Destructor Documentation

◆ __construct()

ilStyleClassAddedObjective::__construct ( string  $class,
string  $type,
string  $tag,
array  $parameters = [],
int  $hide = 0 
)

Definition at line 18 of file class.ilStyleClassAddedObjective.php.

References $hide, $parameters, $tag, and $type.

Member Function Documentation

◆ achieve()

ilStyleClassAddedObjective::achieve ( Environment  $environment)

Definition at line 49 of file class.ilStyleClassAddedObjective.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  $result = $db->query($sql);
59 
60  while ($row = $db->fetchAssoc($result)) {
61  $sql =
62  "SELECT style_id, type, characteristic, hide" . PHP_EOL
63  . "FROM style_char" . PHP_EOL
64  . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
65  . "AND characteristic = " . $db->quote($this->class, "text") . PHP_EOL
66  . "AND type = " . $db->quote($this->type, "text") . PHP_EOL
67  ;
68  $res = $db->query($sql);
69 
70  if (!$db->fetchAssoc($res)) {
71  $values = [
72  "style_id" => ["integer", $row["obj_id"]],
73  "type" => ["text", $this->type],
74  "characteristic" => ["text", $this->class],
75  "hide" => ["integer", $this->hide]
76  ];
77  $db->insert("style_char", $values);
78 
79  foreach ($this->parameters as $k => $v) {
80  $spid = $db->nextId("style_parameter");
81  $values = [
82  "id" => ["integer", $spid],
83  "style_id" => ["integer", $row["obj_id"]],
84  "tag" => ["text", $this->tag],
85  "class" => ["text", $this->class],
86  "parameter" => ["text", $k],
87  "value" => ["text", $v],
88  "type" => ["text", $this->type]
89  ];
90  $db->insert("style_parameter", $values);
91  }
92  }
93  }
94 
95  return $environment;
96  }
$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()

ilStyleClassAddedObjective::getHash ( )

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

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

◆ getLabel()

ilStyleClassAddedObjective::getLabel ( )

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

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

◆ getPreconditions()

ilStyleClassAddedObjective::getPreconditions ( Environment  $environment)

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

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

◆ isApplicable()

ilStyleClassAddedObjective::isApplicable ( Environment  $environment)

Definition at line 98 of file class.ilStyleClassAddedObjective.php.

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

98  : bool
99  {
100  $db = $environment->getResource(Environment::RESOURCE_DATABASE);
101 
102  $sql =
103  "SELECT obj_id" . PHP_EOL
104  . "FROM object_data" . PHP_EOL
105  . "WHERE type = 'sty'" . PHP_EOL
106  ;
107 
108  $result = $db->query($sql);
109 
110  while ($row = $db->fetchAssoc($result)) {
111  $sql =
112  "SELECT style_id, type, characteristic, hide" . PHP_EOL
113  . "FROM style_char" . PHP_EOL
114  . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
115  . "AND characteristic = " . $db->quote($this->class, "text") . PHP_EOL
116  . "AND type = " . $db->quote($this->type, "text") . PHP_EOL;
117  $res = $db->query($sql);
118 
119  // return true if no entry exists in style_char for obj_id from object_data
120  if ($db->numRows($res) == 0) {
121  return true;
122  }
123  }
124 
125  return false;
126  }
$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()

ilStyleClassAddedObjective::isNotable ( )

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

37  : bool
38  {
39  return true;
40  }

Field Documentation

◆ $class

string ilStyleClassAddedObjective::$class
protected

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

Referenced by achieve().

◆ $hide

int ilStyleClassAddedObjective::$hide
protected

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

Referenced by __construct(), and achieve().

◆ $parameters

array ilStyleClassAddedObjective::$parameters
protected

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

Referenced by __construct().

◆ $tag

string ilStyleClassAddedObjective::$tag
protected

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

Referenced by __construct(), and achieve().

◆ $type

string ilStyleClassAddedObjective::$type
protected

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

Referenced by __construct(), and achieve().


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