1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- use \app\helpers\Uuid;
- use manager\models\News;
- $this->title="Редактирование статьи";
- $this->params['breadcrumbs'][] = ['label' => 'Новости', 'url' => ['newslist']];
- $this->params['breadcrumbs'][] = $this->title;
- if( !isset($id) ){
- $request = Yii::$app->request;
- $id = $request->get('id');
- }
- if( !isset($model) ){
- $model = new \app\models\News();
- $model = News::findOne($id);;
- }
- if( !(isset($model->uid) && $model->uid && Uuid::isvalid($model->uid)) )
- {
- if( strlen( $model->uid ) <> 32 ) //2f58b5602dc6500d645ea6032118884e old style
- {
- $i = 100;
- while( $i )
- {
- $uuid = Uuid::GetUUID();
- $model->uid = $uuid;
- $tmp = $model->find()->andWhere(['uid'=>$uuid])->one();
- if( !$tmp ) break;
- $i--;
- }
- }
- }
- echo $this->render('formNews', [
- 'news' => $model,
- ]);
- ?>
|