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

Commit

Permalink
style(Form): Sort Forms
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Aug 6, 2019
1 parent 07820ea commit ae72ce3
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 53 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- **Crontab:** Move From Timer to Process
- **Editor:** Support wysibb editor
- **Gravatar:** Add support of gravatar
- **Pager:** Add Pager Support
- **Process:** Clean Components before sleep
- **Process:** Add custom Process Support
- **Redis:** Add mutiDelete() function for Redis
Expand Down
9 changes: 4 additions & 5 deletions apps/controllers/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
namespace apps\controllers;


use apps\models\form\NewEditForm;
use apps\models\form\News\SearchForm;
use apps\models\form\News;
use Rid\Http\Controller;

class NewsController extends Controller
{
public function actionIndex() {
$pager = new SearchForm();
$pager = new News\SearchForm();
$pager->setData(app()->request->get());

$success = $pager->validate();
Expand All @@ -29,7 +28,7 @@ public function actionIndex() {

public function actionNew() {
if (app()->request->isPost()) {
$newform = new NewEditForm();
$newform = new News\EditForm();
$newform->setData(app()->request->post());
$success = $newform->validate();
if (!$success) {
Expand All @@ -47,7 +46,7 @@ public function actionNew() {
public function actionEdit()
{
if (app()->request->isPost()) {
$newform = new NewEditForm();
$newform = new News\EditForm();
$newform->setData(app()->request->post());
$success = $newform->validate();
if (!$success) {
Expand Down
27 changes: 0 additions & 27 deletions apps/controllers/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace apps\controllers;

use apps\models\Torrent;
use apps\models\form\TorrentUploadForm;

use Rid\Http\Controller;

Expand All @@ -36,32 +35,6 @@ public function actionSnatch() // TODO
return $this->render('torrent/snatch', ['torrent' => $torrent]);
}


public function actionUpload()
{
// TODO Check user upload pos
if (app()->request->isPost()) {
$uploadForm = new TorrentUploadForm();
$uploadForm->setData(app()->request->post());
$uploadForm->setFileData(app()->request->files());
$success = $uploadForm->validate();
if (!$success) {
return $this->render('action/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 app()->response->redirect('/torrent/details?id=' . $uploadForm->id);
}
} else {
return $this->render('torrent/upload');
}

}

public function actionDownload()
{
$tid = app()->request->get('id');
Expand Down
34 changes: 29 additions & 5 deletions apps/controllers/TorrentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

namespace apps\controllers;

use apps\models\form\Torrents\SearchForm;
use apps\models\form\Torrents\TagsForm;
use Rid\Http\Controller;
use apps\models\form\Torrents;

use Rid\Http\Controller;

class TorrentsController extends Controller
{
Expand All @@ -24,7 +23,7 @@ public function actionIndex()
public function actionSearch()
{
// TODO add URI level Cache
$pager = new SearchForm();
$pager = new Torrents\SearchForm();
$pager->setData(app()->request->get());
$success = $pager->validate();
if (!$success) {
Expand All @@ -34,9 +33,34 @@ public function actionSearch()
return $this->render('torrents/list', ['pager' => $pager]);
}

public function actionUpload()
{
// TODO Check user upload pos
if (app()->request->isPost()) {
$uploadForm = new Torrents\UploadForm();
$uploadForm->setData(app()->request->post());
$uploadForm->setFileData(app()->request->files());
$success = $uploadForm->validate();
if (!$success) {
return $this->render('action/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 app()->response->redirect('/torrent/details?id=' . $uploadForm->id);
}
} else {
return $this->render('torrents/upload');
}

}

public function actionTags()
{
$pager = new TagsForm();
$pager = new Torrents\TagsForm();
$pager->setData(app()->request->get());
$success = $pager->validate();

Expand Down
7 changes: 3 additions & 4 deletions apps/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

namespace apps\controllers;

use apps\models\form\UserInviteForm;
use apps\models\form\UserInviteActionForm;
use apps\models\form\User;

use Rid\Http\Controller;

Expand All @@ -30,7 +29,7 @@ public function actionInvite()
{
$msg = '';
if (app()->request->isPost()) {
$form = new UserInviteForm();
$form = new User\InviteForm();
$form->setData(app()->request->post());
$success = $form->validate();
if ($success) {
Expand All @@ -53,7 +52,7 @@ public function actionInvite()

// FIXME By using Form Class
if (!is_null(app()->request->get('action'))) {
$action_form = new UserInviteActionForm();
$action_form = new User\InviteActionForm();
$action_form->setData(app()->request->get());
$success = $action_form->validate();
if ($success) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
* Time: 19:56
*/

namespace apps\models\form;

namespace apps\models\form\News;

use Rid\Validators\Validator;

class NewEditForm extends Validator
class EditForm extends Validator
{
public $id = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Time: 21:45
*/

namespace apps\models\form;
namespace apps\models\form\Torrents;

use apps\models\Torrent;

Expand All @@ -15,7 +15,7 @@
use Rid\Bencode\Bencode;
use Rid\Bencode\ParseErrorException;

class TorrentUploadForm extends Validator
class UploadForm extends Validator
{

public $id = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Time: 17:59
*/

namespace apps\models\form;
namespace apps\models\form\User;

use apps\models\User;
use Rid\Validators\Validator;

class UserInviteActionForm extends Validator
class InviteActionForm extends Validator
{
public $uid;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* Time: 21:45
*/

namespace apps\models\form;
namespace apps\models\form\User;

use apps\models\form\Auth\UserRegisterForm;

use Rid\Helpers\StringHelper;
use Rid\Validators\CaptchaTrait;

class UserInviteForm extends UserRegisterForm
class InviteForm extends UserRegisterForm
{
use CaptchaTrait;

Expand Down
2 changes: 1 addition & 1 deletion apps/public/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ body{background-color:#f6f6f6}

#tags_list{margin-top:20px}

/* '/torrent/upload' */
/* '/torrents/upload' */
#torrent_upload_table > tbody > tr > td:first-child{vertical-align:middle;text-align:right}

/* '/torrent/details' */
Expand Down
2 changes: 1 addition & 1 deletion apps/public/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ jQuery(document).ready(function () {
});
}

// Help to insert tags in `/torrent/upload`
// Help to insert tags in `/torrents/upload`
if ($('div.tag-help-block').length) {
let tags_input = $('input[name="tags"]');
$('a.add-tag').click(function (e) {
Expand Down
2 changes: 1 addition & 1 deletion apps/views/layout/nav_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<li><a href="/forums"><?= __('nav_forums') ?></a></li> <!-- TODO -->
<li><a href="/collections"><?= __('nav_collections') ?></a></li> <!-- TODO -->
<li><a href="/torrents"><?= __('nav_torrents') ?></a></li>
<li><a href="/torrent/upload"><?= __('nav_upload') ?></a></li>
<li><a href="/torrents/upload"><?= __('nav_upload') ?></a></li>
<li><a href="/torrents/request"><?= __('nav_requests') ?></a></li> <!-- TODO -->
<li><a href="/subtitles"><?= __('nav_subtitles') ?></a></li> <!-- TODO -->
<li><a href="/site/rules"><?= __('nav_rules') ?></a></li> <!-- TODO -->
Expand Down
File renamed without changes.

0 comments on commit ae72ce3

Please sign in to comment.