public function actionExport($id) { $filepath = dirname(__FILE__) . '/../runtime/result.docx'; $template_filepath = dirname(__FILE__) . '/../runtime/templates/Template.docx'; if (file_exists($template_filepath)) { $resource = Resource::findOne($id); $filename = $resource->name . '.docx'; $coordinates = json_decode($resource->coordinates); $owner = PersonalData::findOne($resource->owner_data_id); $owner_name = $owner->last_name . ' ' . $owner->first_name . ' ' . $owner->middle_name; $resource_class = ResourceClass::findOne($resource->class_id)->name; $parameters = Parameter::find()->where(['resource_id' => $id])->all(); $attributes = []; foreach ($parameters as $parameter) { $parameter_name = ResourceAttribute::findOne($parameter->attribute_id); $attributes[$parameter_name->name] = $parameter->value; } $linear_size = $attributes['length']; if ($attributes['width']) { $linear_size .= ':' . $attributes['width']; } if ($attributes['height']) { $linear_size .= ':' . $attributes['height']; } \PhpOffice\PhpWord\Autoloader::register(); $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($template_filepath); // Template processing $templateProcessor->setValue('name', htmlspecialchars($resource->name, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('class', htmlspecialchars($resource_class, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('subclass', htmlspecialchars($subclass, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('owner', htmlspecialchars($owner_name, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('linear_size', htmlspecialchars($linear_size, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('area', htmlspecialchars($attributes['square'], ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('weight', htmlspecialchars($attributes['weight'], ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('perimeter', htmlspecialchars($attributes['perimeter'], ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('volume', htmlspecialchars($attributes['volume'], ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('reason', htmlspecialchars($reason, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('registrar', htmlspecialchars($registrar, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('registrar_address', htmlspecialchars($registrar, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('registration_number', htmlspecialchars($registration_number, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('registration_date', htmlspecialchars($creation_date, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('registrar_shortname', htmlspecialchars($registrar_short_name, ENT_COMPAT, 'UTF-8')); for ($i = 1; $i <= 20; $i++) { $lat = ""; $lng = ""; if (count($coordinates) >= $i) { $lat = $coordinates[$i - 1][0]; $lng = $coordinates[$i - 1][1]; } $templateProcessor->setValue('lat#' . $i, htmlspecialchars($lat, ENT_COMPAT, 'UTF-8')); $templateProcessor->setValue('lng#' . $i, htmlspecialchars($lng, ENT_COMPAT, 'UTF-8')); } // Saving the document as OOXML file... $templateProcessor->saveAs($filepath); if (file_exists($filepath)) { return \Yii::$app->response->sendFile($filepath, $filename, ['inline' => false])->send(); } } }
/** * Updates an existing Banner model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post())) { $resourceModel = new Resource(); $model = $resourceModel->uploadImg($model, 'img'); $model->update_time = Common::getTime(); if ($model->save()) { return $this->redirect(['index']); } } return $this->render('update', ['model' => $model]); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $resource = Resource::findFail($id); $resource->delete(); $this->data->name = $resource->name; return $this->json(); }
/** * Bootstrap any application services. * * @return void */ public function boot() { if (\Schema::hasTable('resources')) { $this->resources = Resource::all(); view()->share('resources', $this->resources); } }
public function run() { // Create necessary resources... Resource::firstOrCreate(['name' => 'gold']); Resource::firstOrCreate(['name' => 'wood']); Resource::firstOrCreate(['name' => 'food']); }
public function run() { DB::table('resources')->delete(); Resource::create(['name' => 'Doosan Puma 700LM', 'short_name' => 'Puma 700LM', 'controller' => 'Fanuc 2liT']); Resource::create(['name' => 'Mazak Quick-Turn Nexus 250-II M', 'short_name' => 'Nexus 250', 'controller' => 'Mazatrol Matrix']); Resource::create(['name' => 'Mazak Horizontal Center Nexus 6800-II', 'short_name' => 'Nexus 6800-II', 'controller' => 'Mazatrol Matrix']); Resource::create(['name' => 'Mazak Quick-Turn Nexus 350MY x 1500', 'short_name' => 'Nexus 350MY', 'controller' => 'Mazatrol 640T']); Resource::create(['name' => 'Mazak Integrex 200Y', 'short_name' => 'Integrex 200Y', 'controller' => 'Mazatrol 640MT']); Resource::create(['name' => 'Mazak Integrex 35Y x 1500', 'short_name' => 'Integrex 35Y', 'controller' => 'Mazatrol T+']); Resource::create(['name' => 'Mazak Quick Turn 20', 'short_name' => 'Quick Turn 20', 'controller' => 'Mazatrol T+']); }
/** * Show form to manage resource for a plan * * @return \Illuminate\Http\Response */ public function index(Request $request, $plan_id) { // get current plan with resources $plan = Plan::with('resources')->find($plan_id); // get FULL list of resources $resources = Resource::get(); // return view if ($plan) { return view('cspot.resources', ['plan' => $plan, 'resources' => $resources]); } flashError('Plan with ID "' . $id . '" not found'); return redirect()->back(); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Resource::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'resource_type' => $this->resource_type, 'course_id' => $this->course_id, 'play_count' => $this->play_count, 'download_count' => $this->download_count, 'create_time' => $this->create_time, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'icon', $this->icon])->andFilterWhere(['like', 'extension', $this->extension])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'size', $this->size])->andFilterWhere(['like', 'duration', $this->duration]); return $dataProvider; }
public function joinBattle() { $user = Auth::user(); // Препросчет актуальных ресурсов $user->castle->calcCastleIncreaseResources(); $attack = $user->lastPveAttack(); if ($attack->status == 0) { $result = $user->castle->army->defend($attack->army_level, $attack->army_count); $resource = Resource::find($attack->demanded_resource_id); if ($result == true) { $attack->status = 2; $user->castle->addResource($resource->name, $attack->demanded_resource_count); } else { $attack->status = 1; $user->castle->subResource($resource->name, $attack->demanded_resource_count, true); } } $attack->save(); $user->save(); return redirect('game'); }
public function getBuildingFromResName($resName) { return $this->buildings()->where('buildings_id', BuildingType::where('resources_id', Resource::where('name', $resName)->first()->id)->first()->id)->first(); }
/** * [actionUploadHeadPic 上传头像] * @return [type] [description] */ public function actionUploadHeadPic() { $data = Yii::$app->request->post(); $id = $data['User']['id']; $model = $this->findModel($id); $model->setScenario('profile'); $resourceModel = new Resource(); $model = $resourceModel->uploadImg($model, 'head_picture'); if ($model) { if ($model->save()) { $res = ['initialPreview' => '<p>' . Yii::t('app', 'Upload success!') . '</p>']; echo json_encode($res); } } }
/** * @return \yii\db\ActiveQuery */ public function getResources() { return $this->hasMany(Resource::className(), ['class_id' => 'class_id']); }
public function getResources() { try { $resourcesArray = []; $i = 1; $categories = ResourcesCategory::orderBy('category')->get(); foreach ($categories as $category) { $resourcesArray[$i]['category'] = $category->category; $category_id = $category->id; $resources = Resource::where('category_id', $category_id)->where('active', 1)->orderBy('resource', 'ASC')->get(); $resourcesArray[$i]['resources'] = $resources; $i++; } return $resourcesArray; } catch (\Exception $e) { throw new LambdaException('The resources could not be found', null, $e); } }
public function actionUpload() { $model = new Course(); $data = Yii::$app->request->post(); $id = $data['Course']['id']; $model = $model::findModel($id); $resourceModel = new Resource(); $model = $resourceModel->uploadImg($model, 'icon'); if ($model) { if ($model->save()) { $res = ['initialPreview' => '<p>' . Yii::t('app', 'Upload success!') . '</p>']; echo json_encode($res); } } }
/** * Display the specified resource. * * @param int $id * @param ResourceTransformer $transformer * @return \Illuminate\Http\Response */ public function show($id, ResourceTransformer $transformer) { $resources = Resource::where('category_id', $id)->where('active', 1)->get(); return $this->respond(['data' => $transformer->transformCollection($resources->toArray())]); }
/** * Updates an existing Task model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post())) { $model = $model->validateAttr($model); if (empty($model->errors)) { $resourceModel = new Resource(); $model = $resourceModel->uploadImg($model, 'image'); if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } } } if ($model->is_timing == $model::IS_NOT_TIMING) { $model->complete_time = '00:00'; } if ($model->task_type == $model::TYPE_CHOICE) { $optionArr = json_decode($model->option_json, true); // var_dump($optionArr);die; foreach ($optionArr as $k => $v) { $index = 'option_' . $k; $model->{$index} = $v; } $model->answer_choice = json_decode($model->answer_json, true); return $this->render('update-choice', ['model' => $model]); } if ($model->task_type == $model::TYPE_SHORT_ANSWER || $model->task_type == $model::TYPE_CALCULATION) { return $this->render('update-short-calculation', ['model' => $model]); } }
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-detail"> <?php $i = 1; foreach (CourseComment::commentList($course->id) as $comment): ?> <div class="media col-lg-12 evaluation-con"> <div class="media-left media-middle"> <a href="#"> <img class="media-object img-circle" src="<?php echo User::findModel($comment->user_id)->head_picture?>" alt="" width="60px"> </a> </div> <div class="media-body"> <span class="evaluation-name"><?php echo User::findModel($comment->user_id)->username?></span> <h5 class="media-heading evaluation-content" id="comment-content-<?php echo $i?>"><?php echo $comment->content?></h5> <?php if ($comment->course_id == $comment->root_id): ?> <span class="evaluation-time">时间:<?php echo Common::getAwayTime($comment->comment_time)?></span> <?php else: ?> <span class="evaluation-time">时间:<?php echo Common::getAwayTime($comment->comment_time)?> <a href="/resource/play?id=<?php echo Resource::getVideo($comment->course_id)->url?>">源自:<?php Course::findModel($comment->course_id)->name?></a></span> <?php endif ?> <span class="fa fa-thumbs-o-down comment-down" onclick="commentDown(<?php echo $comment->id?>)"><?php echo $comment->down_count?></span> <span class="fa fa-thumbs-o-up comment-up" onclick="commentUp(<?php echo $comment->id?>)"><?php echo $comment->up_count?></span> </div> </div> <?php $i++;endforeach ?> </div> </div>
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // // find a single resource by ID $output = Resource::find($id); if ($output) { $output->delete(); $message = 'Resource with id "' . $id . '" deleted.'; return \Redirect::route($this->view_idx)->with(['status' => $message]); } // $message = 'Error! Resource with ID "' . $id . '" not found'; return \Redirect::route($this->view_idx)->with(['status' => $message]); }
/** * [transcode Transcode video] * @param [Resource] $model [] * @return [bool] [success or failed] */ public function transcode(Resource $model) { if ($model->save()) { $rootPath = Yii::$app->params['uploadUrl']; $time = time(); exec("ffmpeg -i {$rootPath}{$model->url} -f mp4 -vcodec libx264 -s 640x360 {$rootPath}/uploads/video/{$model->name}.{$time}.mp4", $res, $rc); if (!$rc) { $model->status = static::STATUS_AUTHEN; $model->extension = 'mp4'; $model->url = "/uploads/video/{$model->name}.{$time}.mp4"; $model->update_time = Common::getTime(); if ($model->save()) { return true; } } } return false; }
public function actionExport($id) { $templateFilepath = dirname(__FILE__) . '/../runtime/templates/Template2.docx'; $source = dirname(__FILE__) . '/../runtime/temp.docx'; \PhpOffice\PhpWord\Autoloader::register(); $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($templateFilepath); $months = ['Січня', 'Лютого', 'Березня', 'Квітня', 'Травня', 'Червня', 'Липня', 'Серпня', 'Вересня', 'Жовтня', 'Листопада', 'Грудня']; $date = getdate(); $currentDate = $date['mday'] . ' ' . $months[$date['mon'] - 1] . ' ' . $date['year'] . ' року'; $extractNumber = '№' . $date['mday'] . ($date['mon'] - 1) . substr($date['year'], -2); $templateProcessor->setValue('date', $currentDate); $templateProcessor->setValue('number', $extractNumber); $templateProcessor->saveAs($source); $phpWord = \PhpOffice\PhpWord\IOFactory::load($source); //$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->setDefaultFontName('Times New Roman'); $phpWord->setDefaultFontSize(11); $sectionStyle = ['marginTop' => 1000]; $tableStyle = ['borderSize' => 6, 'borderColor' => '000', 'cellMargin' => 0]; $innerTableStyle = ['cellMargin' => 20]; $boldFontStyle = ['bold' => true]; $italicFontStyle = ['italic' => true]; $styleCell = ['valign' => 'center']; $styleCellBTLR = ['valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR]; $innerTableCellStyle = ['borderRightSize' => 6, 'borderRightColor' => '000', 'borderLeftSize' => 6, 'borderLeftColor' => '000', 'borderBottomSize' => 6, 'borderBottomColor' => '000']; $innerTableRightCellStyle = ['borderLeftSize' => 6, 'borderLeftColor' => '000', 'borderBottomSize' => 6, 'borderBottomColor' => '000']; $innerTableFontStyle = ['size' => 9]; $innerTableParagraphStyle = ['align' => 'center']; // Get resource data $resource = Resource::findOne($id); $filename = $resource->name . '.docx'; $coordinates = json_decode($resource->coordinates); $owner_name = 'народ України (Український народ)'; $resource_class = 'природний ресурс'; $resource_subclass = ResourceClass::findOne($resource->class_id)->name; $creation_date = $resource->date; $registrar = PersonalData::findOne($resource->registrar_data_id); $registrar_info = $registrar->last_name . ' ' . $registrar->first_name . ' ' . $registrar->middle_name . ' ' . $registrar->address; $registrar_shortname = $registrar->last_name . $registrar->first_name[0] . '. ' . $registrar->middle_name[0] . '.'; $parameters = Parameter::find()->where(['resource_id' => $id])->all(); $attributes = []; foreach ($parameters as $parameter) { $parameter_name = ResourceAttribute::findOne($parameter->attribute_id); $attributes[$parameter_name->name] = $parameter->value; } $length = $attributes['length']; $width = $attributes['width']; $height = $attributes['height']; if ($length || $width || $height) { if (!$length) { $length = '0'; } if (!$width) { $width = '0'; } if (!$height) { $height = '0'; } $attributes['linear_size'] = $length . ':' . $width . ':' . $height; } $reason = $resource->reason; function formatCoords($num) { $num = round($num, 4, PHP_ROUND_HALF_DOWN); $degrees = floor($num); $minfloat = ($num - $degrees) * 60; $minutes = floor($minfloat); $secfloat = ($minfloat - $minutes) * 60; $seconds = round($secfloat); if ($seconds == 60) { $minutes++; $seconds = 0; } if ($minutes == 60) { $degrees++; $minutes = 0; } return (string) $degrees . '°' . (string) $minutes . '\'' . (string) $seconds . '"'; } $tableFields = ['Найменування об’єкту' => $resource->name, 'Клас об’єкту' => $resource_class, 'Підклас об’єкту' => $resource_subclass, 'Власник об’єкту' => $owner_name, 'Географічні координати кутів (вершин) об’єкту у форматі ГГ°ММ\'СС,СС". ' => $coordinates, 'Лінійні розміри об’єкту, Д:Ш:В, м' => $attributes['linear_size'], 'Загальна площа об’єкту, га' => $attributes['square'] / 10000, 'Маса (вага) об’єкту, кг' => $attributes['weight'], 'Периметр об’єкту, м' => $attributes['perimeter'], 'Об’єм об’єкту, м3' => $attributes['volume'], 'Підстава для внесення відомостей до Реєстру' => $reason, 'ПІБ та поштова адреса народного реєстратора' => $registrar_info, 'Реєстраційний номер об’єкту' => $registration_number, 'Дата створення запису' => $creation_date]; $tableUnitalicFields = ['Клас об’єкту', 'Власник об’єкту']; $sections = $phpWord->getSections(); $section = $sections[0]; $phpWord->addTableStyle('Resource Table', $tableStyle); $table = $section->addTable('Resource Table'); foreach ($tableFields as $key => $value) { if ($value) { if (!is_array($value)) { $valueFontStyle = []; if (in_array($key, $tableUnitalicFields)) { $valueFontStyle = $italicFontStyle; } $table->addRow(200); $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(8))->addText(htmlspecialchars($key, ENT_COMPAT, 'UTF-8'), $boldFontStyle); $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(15))->addText(htmlspecialchars($value, ENT_COMPAT, 'UTF-8'), $valueFontStyle); } else { $row = $table->addRow(); $row->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(8))->addText(htmlspecialchars($key, ENT_COMPAT, 'UTF-8'), $boldFontStyle); $cell = $row->addCell(); $innerTable = $cell->addTable($innerTableStyle); $innerTable->addRow(10); $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars('Північна широта', ENT_COMPAT, 'UTF-8'), $innerTableFontStyle, $innerTableParagraphStyle); $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars('Східна довгота', ENT_COMPAT, 'UTF-8'), $innerTableFontStyle, $innerTableParagraphStyle); $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars("Північна широта \n(продовження)", ENT_COMPAT, 'UTF-8'), $innerTableFontStyle, $innerTableParagraphStyle); $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableRightCellStyle)->addText(htmlspecialchars("Східна довгота \n(продовження)", ENT_COMPAT, 'UTF-8'), $innerTableFontStyle, $innerTableParagraphStyle); $coordinatesNumber = count($coordinates); for ($i = 1; $i <= round($coordinatesNumber / 2); $i++) { $lat = ''; $lng = ''; $latCont = ''; $lngCont = ''; if ($coordinatesNumber >= $i) { $lat = formatCoords($coordinates[$i - 1][0]); $lng = formatCoords($coordinates[$i - 1][1]); } if ($coordinatesNumber >= round($coordinatesNumber / 2) + $i) { $latCont = formatCoords($coordinates[$i + round($coordinatesNumber / 2) - 1][0]); $lngCont = formatCoords($coordinates[$i + round($coordinatesNumber / 2) - 1][1]); } $innerTable->addRow(10); $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars($lat, ENT_COMPAT, 'UTF-8'), $italicFontStyle); $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars($lng, ENT_COMPAT, 'UTF-8'), $italicFontStyle); $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars($latCont, ENT_COMPAT, 'UTF-8'), $italicFontStyle); $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableRightCellStyle)->addText(htmlspecialchars($lngCont, ENT_COMPAT, 'UTF-8'), $italicFontStyle); } } } } $section->addTextBreak(2); $section->addText('Народний реєстратор', $boldFontStyle); $section->addText(htmlspecialchars($registrar_shortname, ENT_COMPAT, 'UTF-8')); header("Content-Description: File Transfer"); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Expires: 0'); $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $xmlWriter->save("php://output"); }
/** * @return \yii\db\ActiveQuery */ public function getResources() { return $this->hasMany(Resource::className(), ['owner_data_id' => 'personal_data_id']); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // find a single resource by ID $type = Type::find($id); if ($type) { // get the resources table $resources = Resource::get(); // also get the users table $users = User::orderBy('first_name')->get(); // return the view with all the data return view('admin.type', ['type' => $type, 'users' => $users, 'resources' => $resources]); } // $message = 'Error! Type with id "' . $id . '" not found'; return \Redirect::route('types.index')->with(['status' => $message]); }
<?php use yii\widgets\LinkPager; use app\models\Course; use app\models\Resource; use app\models\UserCourse; /* @var $this yii\web\View */ $this->title = Yii::t('app', 'Learn'); $chapterList = Course::getChapterList($course->id); $resModel = new Resource(); ?> <div class="wrap"> <div class="row course-view-infos"> <?= $this->render('course-top', ['course' => $course, 'categoryModel' => $categoryModel])?> </div> <div class="row learn-body"> <div class="col-lg-9 col-md-9 col-sm-9 course-learn-body"> <div class="learn-progress progress"> <?php if ($learnPersent == 0): ?> <div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" style="width: 20%;"> <span >已学<?php echo $learnPersent . '%'?> 用时 <?php echo $learnTimeToal?></span> </div> <?php else: ?> <div class="progress-bar" role="progressbar" aria-valuenow="<?php echo $learnPersent?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $learnPersent?>%;"> <span >已学<?php echo $learnPersent . '%'?> 用时 <?php echo $learnTimeToal?></span> </div>
<?php use yii\helpers\Html; use yii\widgets\DetailView; use app\models\Resource; use app\models\Course; /* @var $this yii\web\View */ /* @var $model app\models\Resource */ $this->title = $model->name; $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Resources'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; $statusList = Resource::statusList(); $typeList = Resource::typeList(); ?> <div class="resource-view"> <?= DetailView::widget([ 'model' => $model, 'attributes' => [ 'id', 'name', 'icon', 'extension', 'url:url', 'size', 'duration', [ 'attribute' => 'status', 'value' => $statusList[$model->status],
public function actionTranscode() { $model = new Resource(); //如果数据库还有需要转码的视频,取一条记录开始转码 while ($model->findOneTranscodeVideo()) { $video = $model->findOneTranscodeVideo(); if (!$model->transcode($video)) { Yii::error("{$video->update_time}---{$video->name} transcode failed", 'error'); break; } } }
public function getResource() { return $this->hasOne(Resource::className(), ['resource_id' => 'resource_id']); }
use app\models\Resource; /* @var $this yii\web\View */ /* @var $model app\models\Resource */ $this->title = Yii::t('app', 'Update {modelClass}: ', [ 'modelClass' => 'Resource', ]) . ' ' . $model->name; $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Resources'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = Yii::t('app', 'Update'); ?> <div class="resource-update"> <div class="resource-form"> <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'status')->dropDownList(Resource::statusList()) ?> <div class="form-group"> <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> </div> <?php ActiveForm::end(); ?> </div> </div>