newsUpdate.php 864 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use \app\helpers\Uuid;
  3. use manager\models\News;
  4. $this->title="Редактирование статьи";
  5. $this->params['breadcrumbs'][] = ['label' => 'Новости', 'url' => ['newslist']];
  6. $this->params['breadcrumbs'][] = $this->title;
  7. if( !isset($id) ){
  8. $request = Yii::$app->request;
  9. $id = $request->get('id');
  10. }
  11. if( !isset($model) ){
  12. $model = new \app\models\News();
  13. $model = News::findOne($id);;
  14. }
  15. if( !(isset($model->uid) && $model->uid && Uuid::isvalid($model->uid)) )
  16. {
  17. if( strlen( $model->uid ) <> 32 ) //2f58b5602dc6500d645ea6032118884e old style
  18. {
  19. $i = 100;
  20. while( $i )
  21. {
  22. $uuid = Uuid::GetUUID();
  23. $model->uid = $uuid;
  24. $tmp = $model->find()->andWhere(['uid'=>$uuid])->one();
  25. if( !$tmp ) break;
  26. $i--;
  27. }
  28. }
  29. }
  30. echo $this->render('formNews', [
  31. 'news' => $model,
  32. ]);
  33. ?>