Update Core\Router

Now, to automatically calculate token, it does not need to be passed in arguments with a value equal to null.
This commit is contained in:
Visman 2021-02-13 21:25:17 +07:00
parent adc67e1e24
commit d303f1a002
11 changed files with 26 additions and 45 deletions

View file

@ -144,15 +144,15 @@ class Router
return $result . $data . $anchor;
}
list($link, $names) = $data;
// автоматическое вычисление токена
if (
\array_key_exists('token', $args)
isset($names['token'])
&& ! isset($args['token'])
) {
$args['token'] = $this->csrf->create($marker, $args);
}
list($link, $names) = $data;
$data = [];
// перечисление имен переменных для построения ссылки
foreach ($names as $name => $need) {

View file

@ -146,7 +146,7 @@ class Model extends DataModel
'SearchAction',
[
'action' => 'new',
'forum' => $this->id,
'forum' => $this->id,
]
);
}
@ -188,9 +188,9 @@ class Model extends DataModel
protected function getlinkMarkRead(): string
{
return $this->c->Router->link(
'MarkRead', [
'id' => $this->id,
'token' => null,
'MarkRead',
[
'id' => $this->id,
]
);
}
@ -206,9 +206,8 @@ class Model extends DataModel
return $this->c->Router->link(
'ForumSubscription',
[
'fid' => $this->id,
'type' => 'subscribe',
'token' => null,
'fid' => $this->id,
'type' => 'subscribe',
]
);
}
@ -225,9 +224,8 @@ class Model extends DataModel
return $this->c->Router->link(
'ForumSubscription',
[
'fid' => $this->id,
'type' => 'unsubscribe',
'token' => null,
'fid' => $this->id,
'type' => 'unsubscribe',
]
);
}

View file

@ -225,12 +225,7 @@ abstract class Page extends Model
}
$navUser['logout'] = [
$r->link(
'Logout',
[
'token' => null,
]
),
$r->link('Logout'),
'Logout',
'Logout',
];

View file

@ -505,8 +505,7 @@ class Bans extends Admin
'link' => $this->c->Router->link(
'AdminBansDelete',
[
'id' => $ban['id'],
'token' => null,
'id' => $ban['id'],
]
),
];

View file

@ -182,8 +182,7 @@ class BBCode extends Parser
'link' => $this->c->Router->link(
'AdminBBCodeDelete',
[
'id' => $id,
'token' => null,
'id' => $id,
]
),
'disabled' => 1 !== $tagData['bb_delete'],
@ -411,8 +410,7 @@ class BBCode extends Parser
'link' => $this->c->Router->link(
'AdminBBCodeDefault',
[
'id' => $id,
'token' => null,
'id' => $id,
]
),
],

View file

@ -204,8 +204,7 @@ class Smilies extends Parser
'link' => $this->c->Router->link(
'AdminSmiliesDelete',
[
'name' => $id,
'token' => null,
'name' => $id,
]
),
];
@ -291,8 +290,7 @@ class Smilies extends Parser
'href' => $this->c->Router->link(
'AdminSmiliesDelete',
[
'name' => $name,
'token' => null,
'name' => $name,
]
),
];

View file

@ -61,8 +61,7 @@ class Index extends Page
$this->linkMarkRead = $this->c->Router->link(
'MarkRead',
[
'id' => 0,
'token' => null,
'id' => 0,
]
);
}

View file

@ -94,9 +94,8 @@ abstract class Profile extends Page
$this->c->Router->link(
'AdminBansDelete',
[
'id' => $id,
'uid' => $this->curUser->id,
'token' => null,
'id' => $id,
'uid' => $this->curUser->id,
]
),
__('Unban user'),
@ -174,7 +173,6 @@ abstract class Profile extends Page
[
'action' => 'change_group',
'ids' => $this->curUser->id,
'token' => null,
]
);
}

View file

@ -125,8 +125,7 @@ class Model extends DataModel
return $this->c->Router->link(
'AdminReportsZap',
[
'id' => $this->id,
'token' => null,
'id' => $this->id,
]
);
} else {

View file

@ -168,9 +168,8 @@ class Model extends DataModel
return $this->c->Router->link(
'TopicSubscription',
[
'tid' => $this->id,
'type' => 'subscribe',
'token' => null,
'tid' => $this->id,
'type' => 'subscribe',
]
);
}
@ -183,9 +182,8 @@ class Model extends DataModel
return $this->c->Router->link(
'TopicSubscription',
[
'tid' => $this->id,
'type' => 'unsubscribe',
'token' => null,
'tid' => $this->id,
'type' => 'unsubscribe',
]
);
}

View file

@ -348,9 +348,8 @@ class Model extends DataModel
return $this->c->Router->link(
'AdminUserPromote',
[
'uid' => $post->user->id,
'pid' => $post->id,
'token' => null,
'uid' => $post->user->id,
'pid' => $post->id,
]
);
} else {