Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
refactor(action): Sort template action/action_{fail,success}
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Aug 17, 2019
1 parent 65cea9e commit 66998d3
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 49 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- **Auth:** Fix user session can't storage in database (30b1049)
- **Auth/Login:** Fix user can't login after commit `6009dc8` (d509127)
- **Component:** Fix parent::onRequest{Before,After} miss (200926f)
- **Search:** Search keywords in NPHP ways (ccde9c0)
- **User:** Fix User Class miss in string format (3680444)

### Perf
Expand Down Expand Up @@ -162,7 +163,7 @@
- **View:** Rename folder `error` to `action` (f5344af)
- **action_success:** Simple The Action Template (9facda1)
- **array/function:** move setDefault to \Rid class (b49d529)
- **auth/error:** merge `auth/error` page to `action/action_success` (9f02aae)
- **auth/error:** merge `auth/error` page to `action/success` (9f02aae)
- **class/cache:** Use trait to simple class value cache (9913873)
- **site/torrent_upload_rule:** Move rule loader to \library\Site::class (ed01663)
- **torrent/download:** Separate Torrent::getDownloadDict to torrent\DownloadForm (4b617ca)
Expand Down
2 changes: 1 addition & 1 deletion apps/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function actionService()
case 'redis':
return $this->infoRedis();
default:
return $this->render('action/action_fail', ['title' => 'Not Support Action', 'msg' => 'not support']);
return $this->render('action/fail', ['title' => 'Not Support Action', 'msg' => 'not support']);
}
}

Expand Down
12 changes: 6 additions & 6 deletions apps/controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function actionRegister()
$register_form->setInput(app()->request->post());
$success = $register_form->validate();
if (!$success) {
return $this->render('action/action_fail', [
return $this->render('action/fail', [
'title' => 'Register Failed',
'msg' => $register_form->getError()
]);
Expand All @@ -51,13 +51,13 @@ public function actionConfirm()
$confirm->setInput(app()->request->get());
$success = $confirm->validate();
if (!$success) {
return $this->render('action/action_fail', [
return $this->render('action/fail', [
'title' => 'Confirm Failed',
'msg' => $confirm->getError()
]);
} else {
$confirm->flush();
return $this->render('action/action_success', [
return $this->render('action/success', [
'notice' => $confirm->getConfirmMsg(),
'redirect' => '/auth/login'
]);
Expand All @@ -71,7 +71,7 @@ public function actionRecover()
$form->setInput(app()->request->post());
$success = $form->validate();
if (!$success) {
return $this->render('action/action_fail', [
return $this->render('action/fail', [
'title' => 'Action Failed',
'msg' => $form->getError()
]);
Expand All @@ -80,7 +80,7 @@ public function actionRecover()
if ($flush === true) {
return $this->render('auth/recover_next_step');
} else {
return $this->render('action/action_fail', [
return $this->render('action/fail', [
'title' => 'Confirm Failed',
'msg' => $flush
]);
Expand Down Expand Up @@ -118,7 +118,7 @@ public function actionLogout()
{
$logout = new Auth\UserLogoutForm();
if (false === $logout->validate()) {
return $this->render('action/action_fail', ['msg' => $logout->getError()]);
return $this->render('action/fail', ['msg' => $logout->getError()]);
} else {
$logout->flush();
}
Expand Down
12 changes: 6 additions & 6 deletions apps/controllers/LinksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public function actionApply()
$success = $form->validate();
if ($success) {
$form->flush();
return $this->render('action/action_success', ['msg' => 'Thanks you to apply links, Our team will check it ASAP.']); // FIXME
return $this->render('action/success', ['msg' => 'Thanks you to apply links, Our team will check it ASAP.']); // FIXME
} else {
return $this->render('action/action_fail', ['msg' => $form->getError()]);
return $this->render('action/fail', ['msg' => $form->getError()]);
}
}

Expand All @@ -44,19 +44,19 @@ public function actionManage()
$success = $edit_form->validate();
if ($success) {
$edit_form->flush();
return $this->render('action/action_success');
return $this->render('action/success');
} else {
return $this->render('action/action_fail', ['msg' => $edit_form->getError()]);
return $this->render('action/fail', ['msg' => $edit_form->getError()]);
}
} elseif (app()->request->post('action') == 'link_delete') {
$delete_form = new Links\RemoveForm();
$delete_form->setInput(app()->request->post());
$success = $delete_form->validate();
if ($success) {
$delete_form->flush();
return $this->render('action/action_success');
return $this->render('action/success');
} else {
return $this->render('action/action_fail', ['msg' => $delete_form->getError()]);
return $this->render('action/fail', ['msg' => $delete_form->getError()]);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions apps/controllers/ManageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ public function actionCategories()
$success = $edit_form->validate();
if ($success) {
$edit_form->flush();
return $this->render('action/action_success');
return $this->render('action/success');
} else {
return $this->render('action/action_fail', ['msg' => $edit_form->getError()]);
return $this->render('action/fail', ['msg' => $edit_form->getError()]);
}
} elseif (app()->request->post('action') == 'cat_delete') {
$delete_form = new Categories\RemoveForm();
$delete_form->setInput(app()->request->post());
$success = $delete_form->validate();
if ($success) {
$delete_form->flush();
return $this->render('action/action_success');
return $this->render('action/success');
} else {
return $this->render('action/action_fail', ['msg' => $delete_form->getError()]);
return $this->render('action/fail', ['msg' => $delete_form->getError()]);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions apps/controllers/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function actionIndex() {

$success = $pager->validate();
if (!$success) {
return $this->render('action/action_fail', ['title' => 'Attack', 'msg' => $pager->getError()]);
return $this->render('action/fail', ['title' => 'Attack', 'msg' => $pager->getError()]);
} else {
return $this->render('news/index', ['pager'=>$pager]);
}
Expand All @@ -32,15 +32,15 @@ public function actionNew() {
$newform->setInput(app()->request->post());
$success = $newform->validate();
if (!$success) {
return $this->render('action/action_fail', ['title' => 'new blog failed', 'msg' => $newform->getError()]);
return $this->render('action/fail', ['title' => 'new blog failed', 'msg' => $newform->getError()]);
} else {
$newform->flush(); // Save the news
return app()->response->redirect('/news');
}
} elseif (app()->auth->getCurUser()->isPrivilege('manage_news')) {
return $this->render('news/edit');
}
return $this->render('action/action_fail', ['title' => 'Action Failed', 'msg' => 'action not allowed']);
return $this->render('action/fail', ['title' => 'Action Failed', 'msg' => 'action not allowed']);
}

public function actionEdit()
Expand All @@ -50,7 +50,7 @@ public function actionEdit()
$newform->setInput(app()->request->post());
$success = $newform->validate();
if (!$success) {
return $this->render('action/action_fail', ['title' => 'Upload Failed', 'msg' => $newform->getError()]);
return $this->render('action/fail', ['title' => 'Upload Failed', 'msg' => $newform->getError()]);
} else {
$newform->flush(); // Save the news
return app()->response->redirect('/news');
Expand All @@ -63,7 +63,7 @@ public function actionEdit()
return $this->render('news/edit', ['news' => $news]);
}
}
return $this->render('action/action_fail', ['title' => 'Action Failed', 'msg' => 'action not allowed']);
return $this->render('action/fail', ['title' => 'Action Failed', 'msg' => 'action not allowed']);
}

public function actionDelete() {
Expand All @@ -75,7 +75,7 @@ public function actionDelete() {
}
return app()->response->redirect('/news');
}
return $this->render('action/action_fail', ['title' => 'Action Failed', 'msg' => 'action not allowed']);
return $this->render('action/fail', ['title' => 'Action Failed', 'msg' => 'action not allowed']);

}
}
2 changes: 1 addition & 1 deletion apps/controllers/RssController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function actionIndex()
// FIXME add torrent search
$feed = new FeedForm();
if (false === $feed->validate()) {
return $this->render('action/action_fail', ['msg' => $feed->getError()]);
return $this->render('action/fail', ['msg' => $feed->getError()]);
}

app()->response->setHeader('Content-Type', 'text/xml');
Expand Down
2 changes: 1 addition & 1 deletion apps/controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function actionLogs()
{
$logs = new Site\Logs();
if (!$logs->validate()) {
return $this->render('action/action_fail',['msg'=>$logs->getError()]);
return $this->render('action/fail',['msg'=>$logs->getError()]);
}
return $this->render('site/logs',['logs'=>$logs]);
}
Expand Down
12 changes: 6 additions & 6 deletions apps/controllers/SubtitlesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function actionSearch($upload = null)
{
$search = new Subtitles\SearchForm();
if (false === $success = $search->validate()) {
return $this->render('action/action_fail', ['msg' => $search->getError()]);
return $this->render('action/fail', ['msg' => $search->getError()]);
}
return $this->render('subtitles/search', ['search' => $search, 'upload_mode' => $upload]);
}
Expand All @@ -33,10 +33,10 @@ public function actionUpload()
if (app()->request->isPost()) {
$upload = new Subtitles\UploadForm();
if (false === $success = $upload->validate()) {
return $this->render('action/action_fail', ['msg' => $upload->getError()]); // TODO add redirect
return $this->render('action/fail', ['msg' => $upload->getError()]); // TODO add redirect
} else {
$upload->flush();
return $this->render('action/action_success'); // TODO add redirect
return $this->render('action/success'); // TODO add redirect
}
}

Expand All @@ -47,7 +47,7 @@ public function actionDownload()
{
$download = new Subtitles\DownloadForm();
if (false === $success = $download->validate()) {
return $this->render('action/action_fail', ['msg' => $download->getError()]);
return $this->render('action/fail', ['msg' => $download->getError()]);
}

return $download->sendFileContentToClient();
Expand All @@ -57,10 +57,10 @@ public function actionDelete()
{
$delete = new Subtitles\DeleteForm();
if (false === $success = $delete->validate()) {
return $this->render('action/action_fail', ['msg' => $delete->getError()]); // TODO add redirect
return $this->render('action/fail', ['msg' => $delete->getError()]); // TODO add redirect
} else {
$delete->flush();
return $this->render('action/action_success',['redirect' => '/subtitles']); // TODO add redirect
return $this->render('action/success',['redirect' => '/subtitles']); // TODO add redirect
}
}
}
10 changes: 5 additions & 5 deletions apps/controllers/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function actionDetails()
$details = new Torrent\DetailsForm();
$success = $details->validate();
if (!$success) {
return $this->render('action/action_fail', ['msg' => $details->getError()]);
return $this->render('action/fail', ['msg' => $details->getError()]);
}

return $this->render('torrent/details', ['details' => $details]);
Expand All @@ -35,7 +35,7 @@ public function actionSnatch()
$snatch = new Torrent\SnatchForm();
$success = $snatch->validate();
if (!$success) {
return $this->render('action/action_fail');
return $this->render('action/fail');
}

return $this->render('torrent/snatch', ['snatch' => $snatch]);
Expand All @@ -46,7 +46,7 @@ public function actionDownload()
$downloader = new Torrent\DownloadForm();
$success = $downloader->validate();
if (!$success) {
return $this->render('action/action_fail');
return $this->render('action/fail');
}

return $downloader->sendFileContentToClient();
Expand All @@ -57,7 +57,7 @@ public function actionComments()
$comments = new Torrent\CommentsForm();
$success = $comments->validate();
if (!$success) {
return $this->render('action/action_fail');
return $this->render('action/fail');
}

return $this->render('torrent/comments', ['comments' => $comments]);
Expand All @@ -68,7 +68,7 @@ public function actionStructure()
$structure = new Torrent\StructureForm();
$success = $structure->validate();
if (!$success) {
return $this->render('action/action_fail');
return $this->render('action/fail');
}

return $this->render('torrent/structure', ['structure' => $structure]);
Expand Down
9 changes: 4 additions & 5 deletions apps/controllers/TorrentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ public function actionIndex()

public function actionSearch()
{
// TODO add URI level Cache
$search = new Torrents\SearchForm();
$search->setInput(app()->request->get());
$success = $search->validate();
if (!$success) {
return $this->render('action/action_fail', ['msg' => $search->getError()]);
return $this->render('action/fail', ['msg' => $search->getError()]);
}

return $this->render('torrents/search', ['search' => $search]);
Expand All @@ -42,12 +41,12 @@ public function actionUpload()
$uploadForm->setFileInput(app()->request->files());
$success = $uploadForm->validate();
if (!$success) {
return $this->render('action/action_fail', ['title' => 'Upload Failed', 'msg' => $uploadForm->getError()]);
return $this->render('action/fail', ['title' => 'Upload Failed', 'msg' => $uploadForm->getError()]);
} else {
try {
$uploadForm->flush();
} catch (\Exception $e) {
return $this->render('action/action_fail', ['title' => 'Upload Failed', 'msg' => $e->getMessage()]);
return $this->render('action/fail', ['title' => 'Upload Failed', 'msg' => $e->getMessage()]);
}

return app()->response->redirect('/torrent/details?id=' . $uploadForm->getId());
Expand All @@ -65,7 +64,7 @@ public function actionTags()
$success = $pager->validate();

if (!$success) {
return $this->render('action/action_fail');
return $this->render('action/fail');
} else {
$tags = $pager->getPagerData();
if (count($tags) == 1 && $tags[0]['tag'] == $pager->search) { // If this search tag is unique and equal to the wanted, just redirect to search page
Expand Down
12 changes: 6 additions & 6 deletions apps/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function actionInvite()
$form->flush();
$msg = 'Send Invite Success!';
} else {
return $this->render('action/action_fail', ['title' => 'Invite Failed', 'msg' => $form->getError()]);
return $this->render('action/fail', ['title' => 'Invite Failed', 'msg' => $form->getError()]);
}
}

Expand All @@ -46,7 +46,7 @@ public function actionInvite()
if (app()->auth->getCurUser()->isPrivilege('view_invite')) {
$user = app()->site->getUser($uid);
} else {
return $this->render('action/action_fail', ['title' => 'Fail', 'msg' => 'Privilege is not enough to see other people\'s invite status.']);
return $this->render('action/fail', ['title' => 'Fail', 'msg' => 'Privilege is not enough to see other people\'s invite status.']);
}
}

Expand All @@ -58,7 +58,7 @@ public function actionInvite()
if ($success) {
$msg = $action_form->flush();
} else {
return $this->render('action/action_fail', ['title' => 'Invite Failed', 'msg' => $action_form->getError()]);
return $this->render('action/fail', ['title' => 'Invite Failed', 'msg' => $action_form->getError()]);
}
}

Expand All @@ -70,7 +70,7 @@ public function actionDetails()
{
$panel = new User\UserDetailsForm();
if (!$panel->validate()) {
return $this->render('action/action_fail', ['msg' => $panel->getError()]);
return $this->render('action/fail', ['msg' => $panel->getError()]);
}

return $this->render('user/details', ['details' => $panel]);
Expand All @@ -92,14 +92,14 @@ public function actionSessions()
if ($success > 0) {
app()->redis->zRem(app()->auth->getCurUser()->sessionSaveKey, $to_del_session);
} else {
return $this->render('action/action_fail', ['title' => 'Remove Session Failed', 'msg' => 'Remove Session Failed']);
return $this->render('action/fail', ['title' => 'Remove Session Failed', 'msg' => 'Remove Session Failed']);
}
}
}

$session_list = new User\SessionsListForm();
if (false === $session_list->validate()) {
return $this->render('action/action_fail', ['msg' => $session_list->getError()]);
return $this->render('action/fail', ['msg' => $session_list->getError()]);
}

return $this->render('user/sessions', ['session_list' => $session_list]);
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 66998d3

Please sign in to comment.