Example #1
0
 /**
  * get data for dropDownList in update setting page
  * @param $type
  * @return array
  */
 public static function getListData($type)
 {
     if ($type == '{TIMEZONE}') {
         return Core::getTimezoneList();
     }
     if ($type == '{LOCALE}') {
         return Core::getLocaleList();
     }
     return [];
 }
 /**
  * Index
  * @return string
  */
 public function actionIndex()
 {
     $searchModel = new MessageSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     /* new lang list */
     $langs = Core::getLocaleList();
     $currents = Message::getLocaleList([Yii::$app->sourceLanguage]);
     foreach ($currents as $key => $name) {
         unset($langs[$key]);
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'langs' => $langs]);
 }
Example #3
0
 /**
  * for user account settings
  * @param $e [] exception
  * @return array
  */
 public static function getLocaleList($e = [])
 {
     /* current translation languages */
     $l = (new Query())->select(['language'])->distinct()->from('{{%core_message}}')->column();
     $l[] = Yii::$app->sourceLanguage;
     /* site default language */
     $default = Setting::getValue('language');
     if (!in_array($default, $l)) {
         $l[] = $default;
     }
     $list = Core::getLocaleList($l);
     /* exception */
     if (is_array($e)) {
         foreach ($e as $key) {
             unset($list[$key]);
         }
     }
     return $list;
 }