19 declare(strict_types=1);
31 private array
$edit_actions = [ActionTarget::EDIT, ActionTarget::EMBED_EDIT];
32 private array
$view_actions = [ActionTarget::VIEW, ActionTarget::EMBED_VIEW];
44 fn(
ActionTarget $target):
string => $this->db->quote($target->value,
'text'),
58 if (isset($cache[$suffix][$implode_targets])) {
59 return $cache[$suffix][$implode_targets];
62 $query =
'SELECT * FROM ' 64 .
' WHERE ext = %s AND name IN(' . $implode_targets .
')';
66 $result = $this->db->queryF(
71 return $cache[$suffix][$implode_targets] = $result->numRows() > 0;
92 $query =
'SELECT * FROM ' 94 .
' WHERE ext = %s AND name = %s';
96 $result = $this->db->queryF($query, [
'text',
'text'], [strtolower($suffix), $action_target->value]);
97 $row = $this->db->fetchAssoc($result);
103 foreach ($this->edit_actions as $action_target) {
105 if ($action !== null) {
114 foreach ($this->view_actions as $action_target) {
116 if ($action !== null) {
126 $query =
'SELECT * FROM ' . self::TABLE_NAME;
127 $result = $this->db->query($query);
128 while ($row = $this->db->fetchAssoc($result)) {
136 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE name = %s';
137 $result = $this->db->queryF($query, [
'text'], [$action_target->value]);
139 while ($row = $this->db->fetchAssoc($result)) {
148 foreach ($action_target as $target) {
156 $query =
'SELECT ext FROM ' 158 .
' WHERE name IN (' . $this->
implodeTargets(...$action_target) .
')';
159 $result = $this->db->query($query);
161 while ($row = $this->db->fetchAssoc($result)) {
162 $suffixes[] = $row[
'ext'];
170 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE app_id = %s';
171 $result = $this->db->queryF($query, [
'integer'], [$app->
getId()]);
172 while ($row = $this->db->fetchAssoc($result)) {
182 (
string) $row[
'name'],
183 (
string) $row[
'ext'],
184 new URI((
string) $row[
'urlsrc']),
185 empty($row[
'url_appendix']) ? null : (
string) $row[
'url_appendix'],
186 empty($row[
'target_text']) ? null : (
string) $row[
'target_text']
192 $query =
'DELETE FROM ' . self::TABLE_NAME;
193 $this->db->manipulate($query);
202 $query =
'DELETE FROM ' . self::TABLE_NAME .
' WHERE ' . $this->db->in(
'id', $collected_ids,
true,
'integer');
203 $this->db->manipulate($query);
214 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE name = %s AND ext = %s AND target_ext = %s';
215 $result = $this->db->queryF(
217 [
'text',
'text',
'text'],
221 if ($this->db->numRows($result) > 0) {
222 $row = $this->db->fetchAssoc($result);
223 $action = $action->
withId((
int) $row[
'id']);
226 if ($this->db->queryF(
227 'SELECT * FROM ' . self::TABLE_NAME .
' WHERE id = %s',
230 )->numRows() === 0) {
231 $next_id = (
int) $this->db->nextId(self::TABLE_NAME);
232 $this->db->insert(self::TABLE_NAME, [
233 'id' => [
'integer', $next_id],
234 'name' => [
'text', $action->
getName()],
237 'app_id' => [
'integer', $for_app->
getId()],
241 $action = $action->
withId($next_id);
243 $this->db->update(self::TABLE_NAME, [
244 'name' => [
'text', $action->
getName()],
247 'app_id' => [
'integer', $for_app->
getId()],
251 'id' => [
'integer', $action->
getId()],
getActionsForApp(App $app)
implodeTargets(ActionTarget ... $targets)
clearSuperfluous(Action ... $actions)
hasEditActionForSuffix(string $suffix)
hasViewActionForSuffix(string $suffix)
getViewActionForSuffix(string $suffix)
store(Action $action, App $for_app)
getActionsForTargets(ActionTarget ... $action_target)
The scope of this class is split ilias-conform URI's into components.
ActionTarget
Officialy supported action targets, see https://learn.microsoft.com/en-us/openspecs/office_protocols/...
hasActionForSuffix(string $suffix, ActionTarget ... $action_target)
getActionsForTarget(ActionTarget $action_target)
getSupportedSuffixes(ActionTarget ... $action_target)
getEditActionForSuffix(string $suffix)
getActionForSuffix(string $suffix, ActionTarget $action_target)
__construct(private \ilDBInterface $db)