19declare(strict_types=1);
34 private array
$edit_actions = [ActionTarget::EDIT, ActionTarget::EMBED_EDIT];
35 private array
$view_actions = [ActionTarget::VIEW, ActionTarget::EMBED_VIEW];
47 fn(
ActionTarget $target):
string => $this->db->quote($target->value,
'text'),
61 if (isset($cache[$suffix][$implode_targets])) {
62 return $cache[$suffix][$implode_targets];
65 $query =
'SELECT * FROM '
67 .
' WHERE ext = %s AND name IN(' . $implode_targets .
')';
69 $result = $this->db->queryF(
74 return $cache[$suffix][$implode_targets] = $result->numRows() > 0;
79 return $this->hasActionForSuffix($suffix, ...$this->edit_actions);
84 return $this->hasActionForSuffix($suffix, ...$this->view_actions);
91 if (!$this->hasActionForSuffix($suffix, $action_target)) {
95 $query =
'SELECT * FROM '
97 .
' WHERE ext = %s AND name = %s';
99 $result = $this->db->queryF($query, [
'text',
'text'], [strtolower($suffix), $action_target->value]);
100 $row = $this->db->fetchAssoc($result);
101 return $this->fromDBRow($row);
106 foreach ($this->edit_actions as $action_target) {
107 $action = $this->getActionForSuffix($suffix, $action_target);
108 if ($action !==
null) {
117 foreach ($this->view_actions as $action_target) {
118 $action = $this->getActionForSuffix($suffix, $action_target);
119 if ($action !==
null) {
129 $query =
'SELECT * FROM ' . self::TABLE_NAME;
130 $result = $this->db->query($query);
131 while ($row = $this->db->fetchAssoc($result)) {
132 $actions[] = $this->fromDBRow($row);
139 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE name = %s';
140 $result = $this->db->queryF($query, [
'text'], [$action_target->value]);
142 while ($row = $this->db->fetchAssoc($result)) {
143 $actions[] = $this->fromDBRow($row);
151 foreach ($action_target as $target) {
152 $actions += $this->getActionsForTarget($target);
159 $query =
'SELECT ext FROM '
161 .
' WHERE name IN (' . $this->implodeTargets(...$action_target) .
')';
162 $result = $this->db->query($query);
164 while ($row = $this->db->fetchAssoc($result)) {
165 $suffixes[] = $row[
'ext'];
173 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE app_id = %s';
174 $result = $this->db->queryF($query, [
'integer'], [$app->
getId()]);
175 while ($row = $this->db->fetchAssoc($result)) {
176 $actions[] = $this->fromDBRow($row);
185 (
string) $row[
'name'],
186 (
string) $row[
'ext'],
187 new URI((
string) $row[
'urlsrc']),
188 empty($row[
'url_appendix']) ?
null : (
string) $row[
'url_appendix'],
189 empty($row[
'target_text']) ?
null : (
string) $row[
'target_text']
195 $query =
'DELETE FROM ' . self::TABLE_NAME;
196 $this->db->manipulate($query);
201 $collected_ids = array_map(
205 $query =
'DELETE FROM ' . self::TABLE_NAME .
' WHERE ' . $this->db->in(
'id', $collected_ids,
true,
'integer');
206 $this->db->manipulate($query);
217 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE name = %s AND ext = %s AND target_ext = %s';
218 $result = $this->db->queryF(
220 [
'text',
'text',
'text'],
224 if ($this->db->numRows($result) > 0) {
225 $row = $this->db->fetchAssoc($result);
226 $action = $action->
withId((
int) $row[
'id']);
229 if ($this->db->queryF(
230 'SELECT * FROM ' . self::TABLE_NAME .
' WHERE id = %s',
233 )->numRows() === 0) {
234 $next_id = $this->db->nextId(self::TABLE_NAME);
235 $this->db->insert(self::TABLE_NAME, [
236 'id' => [
'integer', $next_id],
237 'name' => [
'text', $action->
getName()],
240 'app_id' => [
'integer', $for_app->
getId()],
244 $action = $action->
withId($next_id);
246 $this->db->update(self::TABLE_NAME, [
247 'name' => [
'text', $action->
getName()],
250 'app_id' => [
'integer', $for_app->
getId()],
254 'id' => [
'integer', $action->
getId()],
The scope of this class is split ilias-conform URI's into components.
getEditActionForSuffix(string $suffix)
getActionsForApp(App $app)
hasViewActionForSuffix(string $suffix)
getActionForSuffix(string $suffix, ActionTarget $action_target)
clearSuperfluous(Action ... $actions)
getViewActionForSuffix(string $suffix)
getActionsForTarget(ActionTarget $action_target)
store(Action $action, App $for_app)
hasActionForSuffix(string $suffix, ActionTarget ... $action_target)
__construct(private \ilDBInterface $db)
implodeTargets(ActionTarget ... $targets)
getActionsForTargets(ActionTarget ... $action_target)
hasEditActionForSuffix(string $suffix)
getSupportedSuffixes(ActionTarget ... $action_target)
ActionTarget
Officialy supported action targets, see https://learn.microsoft.com/en-us/openspecs/office_protocols/...
if(!file_exists('../ilias.ini.php'))