Commit c33061a9 authored by Shakarim Sapa's avatar Shakarim Sapa

- Исправлены некоторые (О_о синтаксические ошибки)

parent 04f3509e
...@@ -7,6 +7,7 @@ use common\components\AdminController; ...@@ -7,6 +7,7 @@ use common\components\AdminController;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use dosamigos\transliterator\TransliteratorHelper; use dosamigos\transliterator\TransliteratorHelper;
use yii\data\ActiveDataProvider;
use common\modules\school\models\Courses; use common\modules\school\models\Courses;
use common\modules\school\models\SearchCourses; use common\modules\school\models\SearchCourses;
...@@ -86,10 +87,10 @@ class CoursesAdminController extends AdminController ...@@ -86,10 +87,10 @@ class CoursesAdminController extends AdminController
$model->upload_image->saveAs($model->getPath().$model->image); $model->upload_image->saveAs($model->getPath().$model->image);
} }
} }
return $this->redirect(['view', 'id' => $model->id]); return $this->redirect(['view', 'id' => $model->id]);
} }
else else
{ {
$form = new \common\components\BaseForm('/common/modules/school/forms/CourseForm', $model); $form = new \common\components\BaseForm('/common/modules/school/forms/CourseForm', $model);
return $this->render('create', [ return $this->render('create', [
...@@ -133,8 +134,8 @@ class CoursesAdminController extends AdminController ...@@ -133,8 +134,8 @@ class CoursesAdminController extends AdminController
} }
} }
return $this->redirect(['view', 'id' => $model->id]); return $this->redirect(['view', 'id' => $model->id]);
} }
else else
{ {
$form = new \common\components\BaseForm('/common/modules/school/forms/CourseForm', $model); $form = new \common\components\BaseForm('/common/modules/school/forms/CourseForm', $model);
return $this->render('update', [ return $this->render('update', [
...@@ -151,11 +152,13 @@ class CoursesAdminController extends AdminController ...@@ -151,11 +152,13 @@ class CoursesAdminController extends AdminController
return $this->redirect(['manage']); return $this->redirect(['manage']);
} }
public function actionManage() public function actionManage()
{ {
$searchModel = new SearchCourses(); $searchModel = new SearchCourses();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams["SearchCourses"]); $dataProvider = new ActiveDataProvider([
'query' => SearchCourses::find()
]);
\yii::$app->controller->page_title = 'Управление курсами'; \yii::$app->controller->page_title = 'Управление курсами';
...@@ -185,13 +188,13 @@ class CoursesAdminController extends AdminController ...@@ -185,13 +188,13 @@ class CoursesAdminController extends AdminController
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
} }
public function actionUpload() public function actionUpload()
{ {
$model = new Courses; $model = new Courses;
if (empty($_FILES['Courses'])) { if (empty($_FILES['Courses'])) {
echo json_encode(['error'=>'No files found for upload.']); echo json_encode(['error'=>'No files found for upload.']);
// or you can throw an exception // or you can throw an exception
return; // terminate return; // terminate
} }
...@@ -209,17 +212,17 @@ class CoursesAdminController extends AdminController ...@@ -209,17 +212,17 @@ class CoursesAdminController extends AdminController
$images['name']["upload_image"] = str_replace("-", "_", $images['name']["upload_image"]); $images['name']["upload_image"] = str_replace("-", "_", $images['name']["upload_image"]);
$images['name']["upload_image"] = TransliteratorHelper::process($images['name']["upload_image"], '', 'en'); $images['name']["upload_image"] = TransliteratorHelper::process($images['name']["upload_image"], '', 'en');
$images['name']["upload_image"] = preg_replace('/[^0-9a-z_\.]/i', '', $images['name']["upload_image"]); $images['name']["upload_image"] = preg_replace('/[^0-9a-z_\.]/i', '', $images['name']["upload_image"]);
$target = $model->getPath() . $images['name']["upload_image"];//md5(uniqid()) . "." . array_pop($ext); $target = $model->getPath() . $images['name']["upload_image"];//md5(uniqid()) . "." . array_pop($ext);
if(move_uploaded_file($images['tmp_name']["upload_image"], $target)) { if(move_uploaded_file($images['tmp_name']["upload_image"], $target)) {
$success = true; $success = true;
$paths[] = $target; $paths[] = $target;
} else { } else {
$success = false; $success = false;
break; // break; ??? WTF IS THAT?
} }
// check and process based on successful status // check and process based on successful status
if ($success === true) { if ($success === true) {
$output = []; $output = [];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment