public function actionClearCache() { // ---------------------- CHECK IS AJAX REQUEST ------------------------ if (!Yii::$app->getRequest()->isAjax) { return $this->redirect(['/translate-panel/index']); } // ------------------ SET JSON FORMAT FOR RESPONSE --------------------- // @see https://github.com/samdark/yii2-cookbook/blob/master/book/response-formats.md Yii::$app->getResponse()->format = \yii\web\Response::FORMAT_JSON; // ---------------------- SET DEFAULT RESPONSE ------------------------- $response = array('status' => 'error', 'message' => Yii::t('app', 'An unexpected error occured!')); // -------------------------- CLEAR CACHE ------------------------------ if (SourceMessageSearch::cacheFlush()) { $response['status'] = 'success'; $response['message'] = Yii::t('app', 'Translations cache successfully cleared.'); } return $response; }
$this->params['breadcrumbs'][] = $this->title; Pjax::begin(['id' => 'translationGrid']); //AppTranslateAsset::register($this); ?> <div class="translations-index"> <div class="row"> <div class="col-lg-12"> <span class="pull-left btn-group"> <?php foreach ([SourceMessageSearch::STATUS_ALL => Yii::t('app', 'All'), SourceMessageSearch::STATUS_TRANSLATED => Yii::t('app', 'Translated'), SourceMessageSearch::STATUS_NOT_TRANSLATED => Yii::t('app', 'Not Translated'), SourceMessageSearch::STATUS_DELETED => Yii::t('app', 'Deleted')] as $status => $name) { ?> <a class="btn btn-default <?php $params = ArrayHelper::merge(Yii::$app->request->getQueryParams(), [$searchModel->formName() => ['status' => $status]]); $route = ArrayHelper::merge(['/translate-panel'], $params); echo SourceMessageSearch::isActiveTranslation(['url' => $route, 'current' => $status]); ?> " href="<?php echo Url::to($route); ?> "><?php echo $name; ?> </a> <?php } ?> </span> </div> </div> <h2>