ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 24 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 32 of file class.ilStyleClassAddedObjective.php.

References $hide, $parameters, $tag, $type, and ILIAS\UI\examples\Prompt\Standard\parameters().

33  {
34  $this->class = $class;
35  $this->type = $type;
36  $this->tag = $tag;
37  $this->parameters = $parameters;
38  $this->hide = $hide;
39  }
parameters()
description: > This shows how different states are being used in the same Prompt according to parame...
Definition: parameters.php:39
+ Here is the call graph for this function:

Member Function Documentation

◆ achieve()

ilStyleClassAddedObjective::achieve ( Environment  $environment)

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

References $class, $hide, $res, $tag, $type, ILIAS\Setup\Environment\getResource(), and ILIAS\UI\examples\Prompt\Standard\parameters().

63  : Environment
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  $result = $db->query($sql);
73 
74  while ($row = $db->fetchAssoc($result)) {
75  $sql =
76  "SELECT style_id, type, characteristic, hide" . PHP_EOL
77  . "FROM style_char" . PHP_EOL
78  . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
79  . "AND characteristic = " . $db->quote($this->class, "text") . PHP_EOL
80  . "AND type = " . $db->quote($this->type, "text") . PHP_EOL
81  ;
82  $res = $db->query($sql);
83 
84  if (!$db->fetchAssoc($res)) {
85  $values = [
86  "style_id" => ["integer", $row["obj_id"]],
87  "type" => ["text", $this->type],
88  "characteristic" => ["text", $this->class],
89  "hide" => ["integer", $this->hide]
90  ];
91  $db->insert("style_char", $values);
92 
93  foreach ($this->parameters as $k => $v) {
94  $spid = $db->nextId("style_parameter");
95  $values = [
96  "id" => ["integer", $spid],
97  "style_id" => ["integer", $row["obj_id"]],
98  "tag" => ["text", $this->tag],
99  "class" => ["text", $this->class],
100  "parameter" => ["text", $k],
101  "value" => ["text", $v],
102  "type" => ["text", $this->type]
103  ];
104  $db->insert("style_parameter", $values);
105  }
106  }
107  }
108 
109  return $environment;
110  }
$res
Definition: ltiservices.php:66
parameters()
description: > This shows how different states are being used in the same Prompt according to parame...
Definition: parameters.php:39
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 41 of file class.ilStyleClassAddedObjective.php.

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

◆ getLabel()

ilStyleClassAddedObjective::getLabel ( )

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

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

◆ getPreconditions()

ilStyleClassAddedObjective::getPreconditions ( Environment  $environment)

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

56  : array
57  {
58  return [
60  ];
61  }

◆ isApplicable()

ilStyleClassAddedObjective::isApplicable ( Environment  $environment)

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

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

112  : bool
113  {
114  $db = $environment->getResource(Environment::RESOURCE_DATABASE);
115 
116  $sql =
117  "SELECT obj_id" . PHP_EOL
118  . "FROM object_data" . PHP_EOL
119  . "WHERE type = 'sty'" . PHP_EOL
120  ;
121 
122  $result = $db->query($sql);
123 
124  while ($row = $db->fetchAssoc($result)) {
125  $sql =
126  "SELECT style_id, type, characteristic, hide" . PHP_EOL
127  . "FROM style_char" . PHP_EOL
128  . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
129  . "AND characteristic = " . $db->quote($this->class, "text") . PHP_EOL
130  . "AND type = " . $db->quote($this->type, "text") . PHP_EOL;
131  $res = $db->query($sql);
132 
133  // return true if no entry exists in style_char for obj_id from object_data
134  if ($db->numRows($res) == 0) {
135  return true;
136  }
137  }
138 
139  return false;
140  }
$res
Definition: ltiservices.php:66
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 51 of file class.ilStyleClassAddedObjective.php.

51  : bool
52  {
53  return true;
54  }

Field Documentation

◆ $class

string ilStyleClassAddedObjective::$class
protected

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

Referenced by achieve().

◆ $hide

int ilStyleClassAddedObjective::$hide
protected

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

Referenced by __construct(), and achieve().

◆ $parameters

array ilStyleClassAddedObjective::$parameters
protected

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

Referenced by __construct().

◆ $tag

string ilStyleClassAddedObjective::$tag
protected

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

Referenced by __construct(), and achieve().

◆ $type

string ilStyleClassAddedObjective::$type
protected

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

Referenced by __construct(), and achieve().


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