コード例 #1
0
ファイル: Translations.php プロジェクト: bombayworks/currycms
 public static function addLanguageForm(AbstractLegacyBackend $backend, $user = null)
 {
     if (!$user) {
         $user = User::getUser();
     }
     $languages = LanguageQuery::create()->useUserLanguageQuery()->filterByUser($user)->endUse()->find()->toKeyValue('Langcode', 'Name');
     if (!count($languages)) {
         throw new Exception('You do not have access to any languages.');
     }
     $langcode = null;
     if (isset($_GET['langcode'])) {
         $langcode = $_GET['langcode'];
     }
     if (!array_key_exists($langcode, $languages)) {
         $langcode = null;
     }
     if ($langcode === null) {
         $langcode = array_keys($languages);
         $langcode = array_shift($langcode);
     }
     if (empty($_GET['action'])) {
         header('cache-control: no-store');
         // dont store state as this may cause problem with the form below
         $backend->addMainContent(self::getLanguageForm($languages, $langcode));
     }
     return $langcode;
 }