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'),
67 if (isset($cache[$suffix][$implode_targets])) {
68 return $cache[$suffix][$implode_targets];
71 $query =
'SELECT * FROM ' 73 .
' WHERE ext = %s AND name IN(' . $implode_targets .
')';
75 $result = $this->db->queryF(
80 return $cache[$suffix][$implode_targets] = $result->numRows() > 0;
101 $query =
'SELECT * FROM ' 103 .
' WHERE ext = %s AND name = %s';
105 $result = $this->db->queryF($query, [
'text',
'text'], [strtolower($suffix), $action_target->value]);
106 $row = $this->db->fetchAssoc($result);
112 foreach ($this->edit_actions as $action_target) {
114 if ($action !==
null) {
123 foreach ($this->view_actions as $action_target) {
125 if ($action !==
null) {
135 $query =
'SELECT * FROM ' . self::TABLE_NAME;
136 $result = $this->db->query($query);
137 while ($row = $this->db->fetchAssoc($result)) {
145 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE name = %s';
146 $result = $this->db->queryF($query, [
'text'], [$action_target->value]);
148 while ($row = $this->db->fetchAssoc($result)) {
157 foreach ($action_target as $target) {
165 $query =
'SELECT ext FROM ' 167 .
' WHERE name IN (' . $this->
implodeTargets(...$action_target) .
')';
168 $result = $this->db->query($query);
170 while ($row = $this->db->fetchAssoc($result)) {
171 $suffixes[] = $row[
'ext'];
179 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE app_id = %s';
180 $result = $this->db->queryF($query, [
'integer'], [$app->
getId()]);
181 while ($row = $this->db->fetchAssoc($result)) {
191 (
string) $row[
'name'],
192 (
string) $row[
'ext'],
193 new URI((
string) $row[
'urlsrc']),
194 empty($row[
'url_appendix']) ?
null : (
string) $row[
'url_appendix'],
195 empty($row[
'target_text']) ?
null : (
string) $row[
'target_text']
201 $query =
'DELETE FROM ' . self::TABLE_NAME;
202 $this->db->manipulate($query);
207 $collected_ids = array_map(
211 $query =
'DELETE FROM ' . self::TABLE_NAME .
' WHERE ' . $this->db->in(
'id', $collected_ids,
true,
'integer');
212 $this->db->manipulate($query);
223 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE name = %s AND ext = %s AND target_ext = %s';
224 $result = $this->db->queryF(
226 [
'text',
'text',
'text'],
230 if ($this->db->numRows($result) > 0) {
231 $row = $this->db->fetchAssoc($result);
232 $action = $action->
withId((
int) $row[
'id']);
235 if ($this->db->queryF(
236 'SELECT * FROM ' . self::TABLE_NAME .
' WHERE id = %s',
239 )->numRows() === 0) {
240 $next_id = (
int) $this->db->nextId(self::TABLE_NAME);
241 $this->db->insert(self::TABLE_NAME, [
242 'id' => [
'integer', $next_id],
243 'name' => [
'text', $action->
getName()],
246 'app_id' => [
'integer', $for_app->
getId()],
250 $action = $action->
withId($next_id);
252 $this->db->update(self::TABLE_NAME, [
253 'name' => [
'text', $action->
getName()],
256 'app_id' => [
'integer', $for_app->
getId()],
260 'id' => [
'integer', $action->
getId()],
getViewActionForSuffix(string $suffix)
hasViewActionForSuffix(string $suffix)
store(Action $action, App $for_app)
__construct(private \ilDBInterface $db)
implodeTargets(ActionTarget ... $targets)
getEditActionForSuffix(string $suffix)
clearSuperfluous(Action ... $actions)
getActionsForTarget(ActionTarget $action_target)
The scope of this class is split ilias-conform URI's into components.
null()
this is only for cases where you need an action (for compatibility), this action cannot be used for a...
ActionTarget
Officialy supported action targets, see https://learn.microsoft.com/en-us/openspecs/office_protocols/...
hasActionForSuffix(string $suffix, ActionTarget ... $action_target)
getActionsForApp(App $app)
getActionForSuffix(string $suffix, ActionTarget $action_target)
hasEditActionForSuffix(string $suffix)
getActionsForTargets(ActionTarget ... $action_target)
getSupportedSuffixes(ActionTarget ... $action_target)