<commit_before><?php

namespace backend\controllers;

use common\models\SitePages;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
use yii;

class PageController extends AppController {

  public function behaviors() {
    return [
      'access' => [
        'class' => AccessControl::className(),
        'only'  => ['index', 'add', 'edit', 'inlinesave'],
        'rules' => [
          [
            'actions' => ['index', 'add', 'edit', 'inlinesave'],
            'allow'   => TRUE,
            'roles'   => ['@'],
          ],
        ],
      ],
      'verbs'  => [
        'class'   => VerbFilter::className(),
        'actions' => [
          'add'        => ['post', 'get'],
          'edit'       => ['post', 'get'],
          'inlinesave' => ['post'],
        ],
      ],
    ];
  }

  public function beforeAction($action) {
    $this->enableCsrfValidation = FALSE;
    return parent::beforeAction($action);
  }


  public function actionIndex() {
    return $this->render('index', ['pages' => SitePages::getListPages()]);
  }

  public function actionAdd() {

    $result = null;
    $pageid = null;

    if (Yii::$app->request->isPost) {
      $model = new SitePages();
      $page = $model->InsertOrUpdate(Yii::$app->request->post());
      $result = $page ? 'success' : 'error';
      $pageid = $page->id;
    }

    return $this->render('add', ['result'  => $result,
                                 'id'      => $pageid,
                                 'parents' => SitePages::find()->where(['parent' => ''])->all()
    ]);<commit_msg>Fixed: rewrite control page’s list ds method<commit_after><?php

namespace backend\controllers;

use common\models\SitePages;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
use yii;

class PageController extends AppController {

  public function behaviors() {
    return [
      'access' => [
        'class' => AccessControl::className(),
        'only'  => ['index', 'add', 'edit', 'inlinesave'],
        'rules' => [
          [
            'actions' => ['index', 'add', 'edit', 'inlinesave'],
            'allow'   => TRUE,
            'roles'   => ['@'],
          ],
        ],
      ],
      'verbs'  => [
        'class'   => VerbFilter::className(),
        'actions' => [
          'add'        => ['post', 'get'],
          'edit'       => ['post', 'get'],
          'inlinesave' => ['post'],
        ],
      ],
    ];
  }

  public function beforeAction($action) {
    $this->enableCsrfValidation = FALSE;
    return parent::beforeAction($action);
  }


  public function actionIndex() {
    $pages = SitePages::find()->all();

    return $this->render('index', [
      'pages' => $pages
    ]);
  }

  public function actionAdd() {

    $result = null;
    $pageid = null;

    if (Yii::$app->request->isPost) {
      $model = new SitePages();
      $page = $model->InsertOrUpdate(Yii::$app->request->post());
      $result = $page ? 'success' : 'error';
      $pageid = $page->id;
    }

    return $this->render('add', ['result'  => $result,
                                 'id'      => $pageid,
                                 'parents' => SitePages::find()->where(['parent' => ''])->all()
    ]);
{'fraction_non_alphanumeric': 0.19123997532387416, 'fraction_numerical': 0.0, 'mean_word_length': 2.0652173913043477, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 62, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '960014', 'n_tokens_mistral': 998, 'n_tokens_neox': 983, 'n_words': 194}