diff --git a/backend/migrations/m240507_121449_create_language_table.php b/backend/migrations/m240507_121449_create_language_table.php new file mode 100644 index 000000000..3b1bdb355 --- /dev/null +++ b/backend/migrations/m240507_121449_create_language_table.php @@ -0,0 +1,646 @@ + 'Abkhazian'], + ['ace' => 'Achinese'], + ['ach' => 'Acoli'], + ['ada' => 'Adangme'], + ['ady' => 'Adyghe'], + ['aa' => 'Afar'], + ['afh' => 'Afrihili'], + ['af' => 'Afrikaans'], + ['agq' => 'Aghem'], + ['ain' => 'Ainu'], + ['ak' => 'Akan'], + ['akk' => 'Akkadian'], + ['bss' => 'Akoose'], + ['akz' => 'Alabama'], + ['sq' => 'Albanian'], + ['ale' => 'Aleut'], + ['arq' => 'Algerian Arabic'], + ['en_US' => 'American English'], + ['ase' => 'American Sign Language'], + ['am' => 'Amharic'], + ['egy' => 'Ancient Egyptian'], + ['grc' => 'Ancient Greek'], + ['anp' => 'Angika'], + ['njo' => 'Ao Naga'], + ['ar' => 'Arabic'], + ['an' => 'Aragonese'], + ['arc' => 'Aramaic'], + ['aro' => 'Araona'], + ['arp' => 'Arapaho'], + ['arw' => 'Arawak'], + ['hy' => 'Armenian'], + ['rup' => 'Aromanian'], + ['frp' => 'Arpitan'], + ['as' => 'Assamese'], + ['ast' => 'Asturian'], + ['asa' => 'Asu'], + ['cch' => 'Atsam'], + ['en_AU' => 'Australian English'], + ['de_AT' => 'Austrian German'], + ['av' => 'Avaric'], + ['ae' => 'Avestan'], + ['awa' => 'Awadhi'], + ['ay' => 'Aymara'], + ['az' => 'Azerbaijani'], + ['bfq' => 'Badaga'], + ['ksf' => 'Bafia'], + ['bfd' => 'Bafut'], + ['bqi' => 'Bakhtiari'], + ['ban' => 'Balinese'], + ['bal' => 'Baluchi'], + ['bm' => 'Bambara'], + ['bax' => 'Bamun'], + ['bjn' => 'Banjar'], + ['bas' => 'Basaa'], + ['ba' => 'Bashkir'], + ['eu' => 'Basque'], + ['bbc' => 'Batak Toba'], + ['bar' => 'Bavarian'], + ['bej' => 'Beja'], + ['be' => 'Belarusian'], + ['bem' => 'Bemba'], + ['bez' => 'Bena'], + ['bn' => 'Bengali'], + ['bew' => 'Betawi'], + ['bho' => 'Bhojpuri'], + ['bik' => 'Bikol'], + ['bin' => 'Bini'], + ['bpy' => 'Bishnupriya'], + ['bi' => 'Bislama'], + ['byn' => 'Blin'], + ['zbl' => 'Blissymbols'], + ['brx' => 'Bodo'], + ['bs' => 'Bosnian'], + ['brh' => 'Brahui'], + ['bra' => 'Braj'], + ['pt_BR' => 'Brazilian Portuguese'], + ['br' => 'Breton'], + ['en_GB' => 'British English'], + ['bug' => 'Buginese'], + ['bg' => 'Bulgarian'], + ['bum' => 'Bulu'], + ['bua' => 'Buriat'], + ['my' => 'Burmese'], + ['cad' => 'Caddo'], + ['frc' => 'Cajun French'], + ['en_CA' => 'Canadian English'], + ['fr_CA' => 'Canadian French'], + ['yue' => 'Cantonese'], + ['cps' => 'Capiznon'], + ['car' => 'Carib'], + ['ca' => 'Catalan'], + ['cay' => 'Cayuga'], + ['ceb' => 'Cebuano'], + ['tzm' => 'Central Atlas Tamazight'], + ['dtp' => 'Central Dusun'], + ['ckb' => 'Central Kurdish'], + ['esu' => 'Central Yupik'], + ['shu' => 'Chadian Arabic'], + ['chg' => 'Chagatai'], + ['ch' => 'Chamorro'], + ['ce' => 'Chechen'], + ['chr' => 'Cherokee'], + ['chy' => 'Cheyenne'], + ['chb' => 'Chibcha'], + ['cgg' => 'Chiga'], + ['qug' => 'Chimborazo Highland Quichua'], + ['zh' => 'Chinese'], + ['chn' => 'Chinook Jargon'], + ['chp' => 'Chipewyan'], + ['cho' => 'Choctaw'], + ['cu' => 'Church Slavic'], + ['chk' => 'Chuukese'], + ['cv' => 'Chuvash'], + ['nwc' => 'Classical Newari'], + ['syc' => 'Classical Syriac'], + ['ksh' => 'Colognian'], + ['swb' => 'Comorian'], + ['swc' => 'Congo Swahili'], + ['cop' => 'Coptic'], + ['kw' => 'Cornish'], + ['co' => 'Corsican'], + ['cr' => 'Cree'], + ['mus' => 'Creek'], + ['crh' => 'Crimean Turkish'], + ['hr' => 'Croatian'], + ['cs' => 'Czech'], + ['dak' => 'Dakota'], + ['da' => 'Danish'], + ['dar' => 'Dargwa'], + ['dzg' => 'Dazaga'], + ['del' => 'Delaware'], + ['din' => 'Dinka'], + ['dv' => 'Divehi'], + ['doi' => 'Dogri'], + ['dgr' => 'Dogrib'], + ['dua' => 'Duala'], + ['nl' => 'Dutch'], + ['dyu' => 'Dyula'], + ['dz' => 'Dzongkha'], + ['frs' => 'Eastern Frisian'], + ['efi' => 'Efik'], + ['arz' => 'Egyptian Arabic'], + ['eka' => 'Ekajuk'], + ['elx' => 'Elamite'], + ['ebu' => 'Embu'], + ['egl' => 'Emilian'], + ['en' => 'English'], + ['myv' => 'Erzya'], + ['eo' => 'Esperanto'], + ['et' => 'Estonian'], + ['pt_PT' => 'European Portuguese'], + ['es_ES' => 'European Spanish'], + ['ee' => 'Ewe'], + ['ewo' => 'Ewondo'], + ['ext' => 'Extremaduran'], + ['fan' => 'Fang'], + ['fat' => 'Fanti'], + ['fo' => 'Faroese'], + ['hif' => 'Fiji Hindi'], + ['fj' => 'Fijian'], + ['fil' => 'Filipino'], + ['fi' => 'Finnish'], + ['nl_BE' => 'Flemish'], + ['fon' => 'Fon'], + ['gur' => 'Frafra'], + ['fr' => 'French'], + ['fur' => 'Friulian'], + ['ff' => 'Fulah'], + ['gaa' => 'Ga'], + ['gag' => 'Gagauz'], + ['gl' => 'Galician'], + ['gan' => 'Gan Chinese'], + ['lg' => 'Ganda'], + ['gay' => 'Gayo'], + ['gba' => 'Gbaya'], + ['gez' => 'Geez'], + ['ka' => 'Georgian'], + ['de' => 'German'], + ['aln' => 'Gheg Albanian'], + ['bbj' => 'Ghomala'], + ['glk' => 'Gilaki'], + ['gil' => 'Gilbertese'], + ['gom' => 'Goan Konkani'], + ['gon' => 'Gondi'], + ['gor' => 'Gorontalo'], + ['got' => 'Gothic'], + ['grb' => 'Grebo'], + ['el' => 'Greek'], + ['gn' => 'Guarani'], + ['gu' => 'Gujarati'], + ['guz' => 'Gusii'], + ['gwi' => 'Gwichʼin'], + ['hai' => 'Haida'], + ['ht' => 'Haitian'], + ['hak' => 'Hakka Chinese'], + ['ha' => 'Hausa'], + ['haw' => 'Hawaiian'], + ['he' => 'Hebrew'], + ['hz' => 'Herero'], + ['hil' => 'Hiligaynon'], + ['hi' => 'Hindi'], + ['ho' => 'Hiri Motu'], + ['hit' => 'Hittite'], + ['hmn' => 'Hmong'], + ['hu' => 'Hungarian'], + ['hup' => 'Hupa'], + ['iba' => 'Iban'], + ['ibb' => 'Ibibio'], + ['is' => 'Icelandic'], + ['io' => 'Ido'], + ['ig' => 'Igbo'], + ['ilo' => 'Iloko'], + ['smn' => 'Inari Sami'], + ['id' => 'Indonesian'], + ['izh' => 'Ingrian'], + ['inh' => 'Ingush'], + ['ia' => 'Interlingua'], + ['ie' => 'Interlingue'], + ['iu' => 'Inuktitut'], + ['ik' => 'Inupiaq'], + ['ga' => 'Irish'], + ['it' => 'Italian'], + ['jam' => 'Jamaican Creole English'], + ['ja' => 'Japanese'], + ['jv' => 'Javanese'], + ['kaj' => 'Jju'], + ['dyo' => 'Jola-Fonyi'], + ['jrb' => 'Judeo-Arabic'], + ['jpr' => 'Judeo-Persian'], + ['jut' => 'Jutish'], + ['kbd' => 'Kabardian'], + ['kea' => 'Kabuverdianu'], + ['kab' => 'Kabyle'], + ['kac' => 'Kachin'], + ['kgp' => 'Kaingang'], + ['kkj' => 'Kako'], + ['kl' => 'Kalaallisut'], + ['kln' => 'Kalenjin'], + ['xal' => 'Kalmyk'], + ['kam' => 'Kamba'], + ['kbl' => 'Kanembu'], + ['kn' => 'Kannada'], + ['kr' => 'Kanuri'], + ['kaa' => 'Kara-Kalpak'], + ['krc' => 'Karachay-Balkar'], + ['krl' => 'Karelian'], + ['ks' => 'Kashmiri'], + ['csb' => 'Kashubian'], + ['kaw' => 'Kawi'], + ['kk' => 'Kazakh'], + ['ken' => 'Kenyang'], + ['kha' => 'Khasi'], + ['km' => 'Khmer'], + ['kho' => 'Khotanese'], + ['khw' => 'Khowar'], + ['ki' => 'Kikuyu'], + ['kmb' => 'Kimbundu'], + ['krj' => 'Kinaray-a'], + ['rw' => 'Kinyarwanda'], + ['kiu' => 'Kirmanjki'], + ['tlh' => 'Klingon'], + ['bkm' => 'Kom'], + ['kv' => 'Komi'], + ['koi' => 'Komi-Permyak'], + ['kg' => 'Kongo'], + ['kok' => 'Konkani'], + ['ko' => 'Korean'], + ['kfo' => 'Koro'], + ['kos' => 'Kosraean'], + ['avk' => 'Kotava'], + ['khq' => 'Koyra Chiini'], + ['ses' => 'Koyraboro Senni'], + ['kpe' => 'Kpelle'], + ['kri' => 'Krio'], + ['kj' => 'Kuanyama'], + ['kum' => 'Kumyk'], + ['ku' => 'Kurdish'], + ['kru' => 'Kurukh'], + ['kut' => 'Kutenai'], + ['nmg' => 'Kwasio'], + ['ky' => 'Kyrgyz'], + ['quc' => 'Kʼicheʼ'], + ['lad' => 'Ladino'], + ['lah' => 'Lahnda'], + ['lkt' => 'Lakota'], + ['lam' => 'Lamba'], + ['lag' => 'Langi'], + ['lo' => 'Lao'], + ['ltg' => 'Latgalian'], + ['la' => 'Latin'], + ['es_419' => 'Latin American Spanish'], + ['lv' => 'Latvian'], + ['lzz' => 'Laz'], + ['lez' => 'Lezghian'], + ['lij' => 'Ligurian'], + ['li' => 'Limburgish'], + ['ln' => 'Lingala'], + ['lfn' => 'Lingua Franca Nova'], + ['lzh' => 'Literary Chinese'], + ['lt' => 'Lithuanian'], + ['liv' => 'Livonian'], + ['jbo' => 'Lojban'], + ['lmo' => 'Lombard'], + ['nds' => 'Low German'], + ['sli' => 'Lower Silesian'], + ['dsb' => 'Lower Sorbian'], + ['loz' => 'Lozi'], + ['lu' => 'Luba-Katanga'], + ['lua' => 'Luba-Lulua'], + ['lui' => 'Luiseno'], + ['smj' => 'Lule Sami'], + ['lun' => 'Lunda'], + ['luo' => 'Luo'], + ['lb' => 'Luxembourgish'], + ['luy' => 'Luyia'], + ['mde' => 'Maba'], + ['mk' => 'Macedonian'], + ['jmc' => 'Machame'], + ['mad' => 'Madurese'], + ['maf' => 'Mafa'], + ['mag' => 'Magahi'], + ['vmf' => 'Main-Franconian'], + ['mai' => 'Maithili'], + ['mak' => 'Makasar'], + ['mgh' => 'Makhuwa-Meetto'], + ['kde' => 'Makonde'], + ['mg' => 'Malagasy'], + ['ms' => 'Malay'], + ['ml' => 'Malayalam'], + ['mt' => 'Maltese'], + ['mnc' => 'Manchu'], + ['mdr' => 'Mandar'], + ['man' => 'Mandingo'], + ['mni' => 'Manipuri'], + ['gv' => 'Manx'], + ['mi' => 'Maori'], + ['arn' => 'Mapuche'], + ['mr' => 'Marathi'], + ['chm' => 'Mari'], + ['mh' => 'Marshallese'], + ['mwr' => 'Marwari'], + ['mas' => 'Masai'], + ['mzn' => 'Mazanderani'], + ['byv' => 'Medumba'], + ['men' => 'Mende'], + ['mwv' => 'Mentawai'], + ['mer' => 'Meru'], + ['mgo' => 'Metaʼ'], + ['es_MX' => 'Mexican Spanish'], + ['mic' => 'Micmac'], + ['dum' => 'Middle Dutch'], + ['enm' => 'Middle English'], + ['frm' => 'Middle French'], + ['gmh' => 'Middle High German'], + ['mga' => 'Middle Irish'], + ['nan' => 'Min Nan Chinese'], + ['min' => 'Minangkabau'], + ['xmf' => 'Mingrelian'], + ['mwl' => 'Mirandese'], + ['lus' => 'Mizo'], + ['ar_001' => 'Modern Standard Arabic'], + ['moh' => 'Mohawk'], + ['mdf' => 'Moksha'], + ['ro_MD' => 'Moldavian'], + ['lol' => 'Mongo'], + ['mn' => 'Mongolian'], + ['mfe' => 'Morisyen'], + ['ary' => 'Moroccan Arabic'], + ['mos' => 'Mossi'], + ['mul' => 'Multiple Languages'], + ['mua' => 'Mundang'], + ['ttt' => 'Muslim Tat'], + ['mye' => 'Myene'], + ['naq' => 'Nama'], + ['na' => 'Nauru'], + ['nv' => 'Navajo'], + ['ng' => 'Ndonga'], + ['nap' => 'Neapolitan'], + ['ne' => 'Nepali'], + ['new' => 'Newari'], + ['sba' => 'Ngambay'], + ['nnh' => 'Ngiemboon'], + ['jgo' => 'Ngomba'], + ['yrl' => 'Nheengatu'], + ['nia' => 'Nias'], + ['niu' => 'Niuean'], + ['zxx' => 'No linguistic content'], + ['nog' => 'Nogai'], + ['nd' => 'North Ndebele'], + ['frr' => 'Northern Frisian'], + ['se' => 'Northern Sami'], + ['nso' => 'Northern Sotho'], + ['no' => 'Norwegian'], + ['nb' => 'Norwegian Bokmål'], + ['nn' => 'Norwegian Nynorsk'], + ['nov' => 'Novial'], + ['nus' => 'Nuer'], + ['nym' => 'Nyamwezi'], + ['ny' => 'Nyanja'], + ['nyn' => 'Nyankole'], + ['tog' => 'Nyasa Tonga'], + ['nyo' => 'Nyoro'], + ['nzi' => 'Nzima'], + ['nqo' => 'NʼKo'], + ['oc' => 'Occitan'], + ['oj' => 'Ojibwa'], + ['ang' => 'Old English'], + ['fro' => 'Old French'], + ['goh' => 'Old High German'], + ['sga' => 'Old Irish'], + ['non' => 'Old Norse'], + ['peo' => 'Old Persian'], + ['pro' => 'Old Provençal'], + ['or' => 'Oriya'], + ['om' => 'Oromo'], + ['osa' => 'Osage'], + ['os' => 'Ossetic'], + ['ota' => 'Ottoman Turkish'], + ['pal' => 'Pahlavi'], + ['pfl' => 'Palatine German'], + ['pau' => 'Palauan'], + ['pi' => 'Pali'], + ['pam' => 'Pampanga'], + ['pag' => 'Pangasinan'], + ['pap' => 'Papiamento'], + ['ps' => 'Pashto'], + ['pdc' => 'Pennsylvania German'], + ['fa' => 'Persian'], + ['phn' => 'Phoenician'], + ['pcd' => 'Picard'], + ['pms' => 'Piedmontese'], + ['pdt' => 'Plautdietsch'], + ['pon' => 'Pohnpeian'], + ['pl' => 'Polish'], + ['pnt' => 'Pontic'], + ['pt' => 'Portuguese'], + ['prg' => 'Prussian'], + ['pa' => 'Punjabi'], + ['qu' => 'Quechua'], + ['raj' => 'Rajasthani'], + ['rap' => 'Rapanui'], + ['rar' => 'Rarotongan'], + ['rif' => 'Riffian'], + ['rgn' => 'Romagnol'], + ['ro' => 'Romanian'], + ['rm' => 'Romansh'], + ['rom' => 'Romany'], + ['rof' => 'Rombo'], + ['root' => 'Root'], + ['rtm' => 'Rotuman'], + ['rug' => 'Roviana'], + ['rn' => 'Rundi'], + ['ru' => 'Russian'], + ['rue' => 'Rusyn'], + ['rwk' => 'Rwa'], + ['ssy' => 'Saho'], + ['sah' => 'Sakha'], + ['sam' => 'Samaritan Aramaic'], + ['saq' => 'Samburu'], + ['sm' => 'Samoan'], + ['sgs' => 'Samogitian'], + ['sad' => 'Sandawe'], + ['sg' => 'Sango'], + ['sbp' => 'Sangu'], + ['sa' => 'Sanskrit'], + ['sat' => 'Santali'], + ['sc' => 'Sardinian'], + ['sas' => 'Sasak'], + ['sdc' => 'Sassarese Sardinian'], + ['stq' => 'Saterland Frisian'], + ['saz' => 'Saurashtra'], + ['sco' => 'Scots'], + ['gd' => 'Scottish Gaelic'], + ['sly' => 'Selayar'], + ['sel' => 'Selkup'], + ['seh' => 'Sena'], + ['see' => 'Seneca'], + ['sr' => 'Serbian'], + ['sh' => 'Serbo-Croatian'], + ['srr' => 'Serer'], + ['sei' => 'Seri'], + ['ksb' => 'Shambala'], + ['shn' => 'Shan'], + ['sn' => 'Shona'], + ['ii' => 'Sichuan Yi'], + ['scn' => 'Sicilian'], + ['sid' => 'Sidamo'], + ['bla' => 'Siksika'], + ['szl' => 'Silesian'], + ['zh_Hans' => 'Simplified Chinese'], + ['sd' => 'Sindhi'], + ['si' => 'Sinhala'], + ['sms' => 'Skolt Sami'], + ['den' => 'Slave'], + ['sk' => 'Slovak'], + ['sl' => 'Slovenian'], + ['xog' => 'Soga'], + ['sog' => 'Sogdien'], + ['so' => 'Somali'], + ['snk' => 'Soninke'], + ['azb' => 'South Azerbaijani'], + ['nr' => 'South Ndebele'], + ['alt' => 'Southern Altai'], + ['sma' => 'Southern Sami'], + ['st' => 'Southern Sotho'], + ['es' => 'Spanish'], + ['srn' => 'Sranan Tongo'], + ['zgh' => 'Standard Moroccan Tamazight'], + ['suk' => 'Sukuma'], + ['sux' => 'Sumerian'], + ['su' => 'Sundanese'], + ['sus' => 'Susu'], + ['sw' => 'Swahili'], + ['ss' => 'Swati'], + ['sv' => 'Swedish'], + ['fr_CH' => 'Swiss French'], + ['gsw' => 'Swiss German'], + ['de_CH' => 'Swiss High German'], + ['syr' => 'Syriac'], + ['shi' => 'Tachelhit'], + ['tl' => 'Tagalog'], + ['ty' => 'Tahitian'], + ['dav' => 'Taita'], + ['tg' => 'Tajik'], + ['tly' => 'Talysh'], + ['tmh' => 'Tamashek'], + ['ta' => 'Tamil'], + ['trv' => 'Taroko'], + ['twq' => 'Tasawaq'], + ['tt' => 'Tatar'], + ['te' => 'Telugu'], + ['ter' => 'Tereno'], + ['teo' => 'Teso'], + ['tet' => 'Tetum'], + ['th' => 'Thai'], + ['bo' => 'Tibetan'], + ['tig' => 'Tigre'], + ['ti' => 'Tigrinya'], + ['tem' => 'Timne'], + ['tiv' => 'Tiv'], + ['tli' => 'Tlingit'], + ['tpi' => 'Tok Pisin'], + ['tkl' => 'Tokelau'], + ['to' => 'Tongan'], + ['fit' => 'Tornedalen Finnish'], + ['zh_Hant' => 'Traditional Chinese'], + ['tkr' => 'Tsakhur'], + ['tsd' => 'Tsakonian'], + ['tsi' => 'Tsimshian'], + ['ts' => 'Tsonga'], + ['tn' => 'Tswana'], + ['tcy' => 'Tulu'], + ['tum' => 'Tumbuka'], + ['aeb' => 'Tunisian Arabic'], + ['tr' => 'Turkish'], + ['tk' => 'Turkmen'], + ['tru' => 'Turoyo'], + ['tvl' => 'Tuvalu'], + ['tyv' => 'Tuvinian'], + ['tw' => 'Twi'], + ['kcg' => 'Tyap'], + ['udm' => 'Udmurt'], + ['uga' => 'Ugaritic'], + ['uk' => 'Ukrainian'], + ['umb' => 'Umbundu'], + ['und' => 'Unknown Language'], + ['hsb' => 'Upper Sorbian'], + ['ur' => 'Urdu'], + ['ug' => 'Uyghur'], + ['uz' => 'Uzbek'], + ['vai' => 'Vai'], + ['ve' => 'Venda'], + ['vec' => 'Venetian'], + ['vep' => 'Veps'], + ['vi' => 'Vietnamese'], + ['vo' => 'Volapük'], + ['vro' => 'Võro'], + ['vot' => 'Votic'], + ['vun' => 'Vunjo'], + ['wa' => 'Walloon'], + ['wae' => 'Walser'], + ['war' => 'Waray'], + ['wbp' => 'Warlpiri'], + ['was' => 'Washo'], + ['guc' => 'Wayuu'], + ['cy' => 'Welsh'], + ['vls' => 'West Flemish'], + ['fy' => 'Western Frisian'], + ['mrj' => 'Western Mari'], + ['wal' => 'Wolaytta'], + ['wo' => 'Wolof'], + ['wuu' => 'Wu Chinese'], + ['xh' => 'Xhosa'], + ['hsn' => 'Xiang Chinese'], + ['yav' => 'Yangben'], + ['yao' => 'Yao'], + ['yap' => 'Yapese'], + ['ybb' => 'Yemba'], + ['yi' => 'Yiddish'], + ['yo' => 'Yoruba'], + ['zap' => 'Zapotec'], + ['dje' => 'Zarma'], + ['zza' => 'Zaza'], + ['zea' => 'Zeelandic'], + ['zen' => 'Zenaga'], + ['za' => 'Zhuang'], + ['gbz' => 'Zoroastrian Dari'], + ['zu' => 'Zulu'], + ['zun' => 'Zuni'], + ]; + + /** + * {@inheritdoc} + */ + public function safeUp() + { + $this->createTable('{{%language}}', [ + 'id' => $this->string(8)->notNull(), + 'l' => $this->string(36), + 'PRIMARY KEY (id)' + ]); + + foreach($this->languages as $entry) + { + $this->upsert('language',['id'=>key($entry),'l'=>current($entry)]); + } + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropTable('{{%language}}'); + } +} diff --git a/backend/migrations/m240507_121450_add_language_column_to_writeup_table.php b/backend/migrations/m240507_121450_add_language_column_to_writeup_table.php new file mode 100644 index 000000000..5c6dcd0a7 --- /dev/null +++ b/backend/migrations/m240507_121450_add_language_column_to_writeup_table.php @@ -0,0 +1,27 @@ +addColumn('{{%writeup}}', 'language_id', $this->string(8)->after('formatter')->notNull()->defaultValue('en')); + $this->addForeignKey('fk_language_id', 'writeup', 'language_id', 'language', 'id'); + + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropColumn('{{%writeup}}', 'language'); + } +} diff --git a/backend/modules/activity/models/SpinHistorySearch.php b/backend/modules/activity/models/SpinHistorySearch.php index 5fab2f7a6..80d5faed7 100644 --- a/backend/modules/activity/models/SpinHistorySearch.php +++ b/backend/modules/activity/models/SpinHistorySearch.php @@ -14,95 +14,78 @@ class SpinHistorySearch extends SpinHistory public $target_name; public $username; - /** - * {@inheritdoc} - */ - public function rules() - { - return [ - [['id', 'target_id', 'player_id'], 'integer'], - [['created_at', 'updated_at', 'target_name', 'username'], 'safe'], - ]; + /** + * {@inheritdoc} + */ + public function rules() + { + return [ + [['id', 'target_id', 'player_id'], 'integer'], + [['created_at', 'updated_at', 'target_name', 'username'], 'safe'], + ]; + } + + /** + * {@inheritdoc} + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = SpinHistory::find()->joinWith(['target', 'player']); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; } - /** - * {@inheritdoc} - */ - public function scenarios() - { - // bypass scenarios() implementation in the parent class - return Model::scenarios(); - } - - /** - * Creates data provider instance with search query applied - * - * @param array $params - * - * @return ActiveDataProvider - */ - public function search($params) - { - $query=SpinHistory::find()->joinWith(['target', 'player']); - - // add conditions that should always apply here - - $dataProvider=new ActiveDataProvider([ - 'query' => $query, - ]); - - $this->load($params); - - if(!$this->validate()) - { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); - return $dataProvider; - } - - // grid filtering conditions - $query->andFilterWhere([ - 'spin_history.id' => $this->id, - 'spin_history.target_id' => $this->target_id, - 'spin_history.player_id' => $this->player_id, - ]); - - $query->andFilterWhere(['like', 'spin_history.created_at', $this->created_at]); - $query->andFilterWhere(['like', 'spin_history.updated_at', $this->updated_at]); - $query->andFilterWhere(['like', 'player.username', $this->username]); - $query->andFilterWhere(['like', 'target.name', $this->target_name]); - $dataProvider->setSort([ - 'attributes' => array_merge( - $dataProvider->getSort()->attributes, - [ - 'username' => [ - 'asc' => ['player.username' => SORT_ASC], - 'desc' => ['player.username' => SORT_DESC], - ], - 'target_name' => [ - 'asc' => ['target.name' => SORT_ASC], - 'desc' => ['target.name' => SORT_DESC], - ], - ] - ), - ]); - - - $query->andFilterWhere(['like', 'target.fqdn', $this->target]); - $dataProvider->setSort([ - 'defaultOrder' => ['id'=>SORT_DESC], - 'attributes' => array_merge( - $dataProvider->getSort()->attributes, - [ - 'target' => [ - 'asc' => ['target_id' => SORT_ASC], - 'desc' => ['target_id' => SORT_DESC], - ], - ] - ), - ]); - - - return $dataProvider; - } + // grid filtering conditions + $query->andFilterWhere([ + 'spin_history.id' => $this->id, + 'spin_history.target_id' => $this->target_id, + 'spin_history.player_id' => $this->player_id, + ]); + + $query->andFilterWhere(['like', 'spin_history.created_at', $this->created_at]); + $query->andFilterWhere(['like', 'spin_history.updated_at', $this->updated_at]); + $query->andFilterWhere(['like', 'player.username', $this->username]); + $query->andFilterWhere(['like', 'target.name', $this->target_name]); + $dataProvider->setSort([ + 'attributes' => array_merge( + $dataProvider->getSort()->attributes, + [ + 'username' => [ + 'asc' => ['player.username' => SORT_ASC], + 'desc' => ['player.username' => SORT_DESC], + ], + 'target_name' => [ + 'asc' => ['target.name' => SORT_ASC], + 'desc' => ['target.name' => SORT_DESC], + ], + ] + ), + ]); + + return $dataProvider; + } } diff --git a/backend/modules/activity/models/Writeup.php b/backend/modules/activity/models/Writeup.php index 7d0e55bc7..b72be0599 100644 --- a/backend/modules/activity/models/Writeup.php +++ b/backend/modules/activity/models/Writeup.php @@ -20,6 +20,7 @@ * @property string|null $status * @property resource|null $comment * @property string|null $formatter + * @property string $language * @property string|null $created_at * @property string|null $updated_at * @@ -42,17 +43,19 @@ public static function tableName() public function rules() { return [ - [['player_id', 'target_id'], 'required'], + [['player_id', 'target_id','language_id'], 'required'], [['player_id', 'target_id'], 'integer'], [['approved'], 'boolean'], - [['content', 'status', 'comment','formatter'], 'string'], + [['content', 'status', 'comment','formatter','language_id'], 'string'], ['formatter','in','range'=>['text','markdown']], ['formatter','default','value'=>'text'], + ['language_id','default','value'=>'en'], ['status','in','range'=>['PENDING','NEEDS FIXES','REJECTED','OK']], [['created_at', 'updated_at'], 'safe'], [['player_id', 'target_id'], 'unique', 'targetAttribute' => ['player_id', 'target_id']], [['player_id'], 'exist', 'skipOnError' => true, 'targetClass' => Player::class, 'targetAttribute' => ['player_id' => 'id']], [['target_id'], 'exist', 'skipOnError' => true, 'targetClass' => Target::class, 'targetAttribute' => ['target_id' => 'id']], + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => \app\modules\settings\models\Language::class, 'targetAttribute' => ['language_id' => 'id']], ]; } @@ -91,6 +94,9 @@ public function attributeLabels() 'approved' => 'Approved', 'status' => 'Status', 'comment' => 'Comment', + 'formatter' => 'Formatter', + 'language_id' => 'Language', + 'lang' => 'Language', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; @@ -126,6 +132,16 @@ public function getTarget() return $this->hasOne(Target::class, ['id' => 'target_id']); } + /** + * Gets query for [[Target]]. + * + * @return \yii\db\ActiveQuery|Target + */ + public function getLanguage() + { + return $this->hasOne(\app\modules\settings\models\Language::class, ['id' => 'language_id']); + } + /** * {@inheritdoc} * @return WriteupQuery the active query used by this AR class. diff --git a/backend/modules/activity/models/WriteupSearch.php b/backend/modules/activity/models/WriteupSearch.php index 19aec13d3..813969a6f 100644 --- a/backend/modules/activity/models/WriteupSearch.php +++ b/backend/modules/activity/models/WriteupSearch.php @@ -14,6 +14,7 @@ class WriteupSearch extends Writeup public $username; public $fqdn; public $ipoctet; + public $lang; /** * {@inheritdoc} @@ -22,7 +23,7 @@ public function rules() { return [ [['player_id', 'target_id', 'approved'], 'integer'], - [['content', 'status', 'comment', 'created_at', 'updated_at', 'username', 'fqdn', 'ipoctet'], 'safe'], + [['content', 'status', 'comment', 'created_at', 'updated_at', 'username', 'fqdn', 'ipoctet','lang'], 'safe'], ]; } @@ -44,7 +45,7 @@ public function scenarios() */ public function search($params) { - $query = Writeup::find()->joinWith(['player', 'target']); + $query = Writeup::find()->joinWith(['player', 'target','language']); // add conditions that should always apply here @@ -71,8 +72,10 @@ public function search($params) ->andFilterWhere(['like', 'writeup.updated_at', $this->updated_at]) ->andFilterWhere(['like', 'content', $this->content]) ->andFilterWhere(['like', 'writeup.status', $this->status]) + ->andFilterWhere(['like', 'writeup.language', $this->language]) ->andFilterWhere(['like', 'comment', $this->comment]); $query->andFilterWhere(['like', 'player.username', $this->username]); + $query->andFilterWhere(['like', 'language.l', $this->lang]); $query->andFilterWhere(['like', 'target.fqdn', $this->fqdn]); $query->andFilterWhere(['like', 'INET_NTOA(target.ip)', $this->ipoctet]); @@ -84,7 +87,11 @@ public function search($params) 'asc' => ['player.username' => SORT_ASC], 'desc' => ['player.username' => SORT_DESC], ], - 'fqdn' => [ + 'lang' => [ + 'asc' => ['language.l' => SORT_ASC], + 'desc' => ['language.l' => SORT_DESC], + ], + 'fqdn' => [ 'asc' => ['target.fqdn' => SORT_ASC], 'desc' => ['target.fqdn' => SORT_DESC], ], diff --git a/backend/modules/activity/views/writeup/_form.php b/backend/modules/activity/views/writeup/_form.php index d582424f1..bfbea5f27 100644 --- a/backend/modules/activity/views/writeup/_form.php +++ b/backend/modules/activity/views/writeup/_form.php @@ -26,6 +26,7 @@ field($model, 'formatter')->dropDownList([ 'text' => 'TEXT', 'markdown' => 'Markdown' ], ['prompt' => '']) ?> + field($model, 'language_id')->dropDownList(ArrayHelper::map(\app\modules\settings\models\Language::find()->orderBy('l')->all(), 'id', 'l'))?> field($model, 'content')->textArea(['rows'=>15]) ?> field($model, 'approved')->checkbox() ?> diff --git a/backend/modules/activity/views/writeup/help/create.php b/backend/modules/activity/views/writeup/help/create.php index 01ac985f8..52ec2ff6c 100644 --- a/backend/modules/activity/views/writeup/help/create.php +++ b/backend/modules/activity/views/writeup/help/create.php @@ -1 +1,17 @@ -

Comming soon...

+Create a writeup for a platform target. + +Writeups allow players to share their methodology when solving a target. + +The form fields include: +* `Target ID`: The target this writeup belongs to +* `Player ID`: The username that the writeup will display as author +* `Formatter`: The formatter that will be used by the frontend to display this writeup (supported formatters `Markdown`, `Text`). +* `Language`: The language that this writeup is written (defaults to `English`) +* `Content`: The raw content of the writeup +* `Approved`: Whether a writeup is approved or not +* `Status`: Status of writeup + * `OK`: Writeup is published and its ok to be displayed + * `Pending`: The writeup is pending for review by a moderator + * `Rejected`: The writeup is rejected by a moderator + * `Needs Fixes`: The writeup needs fixes as suggested by a moderator. (This usually means there is also a comment left for the player to read) +* `Comment`: A comment that will be left for the author to read \ No newline at end of file diff --git a/backend/modules/activity/views/writeup/help/index.php b/backend/modules/activity/views/writeup/help/index.php index 01ac985f8..53de374fa 100644 --- a/backend/modules/activity/views/writeup/help/index.php +++ b/backend/modules/activity/views/writeup/help/index.php @@ -1 +1,17 @@ -

Comming soon...

+Manage the player contributed Writeups for your platform targets. + +Writeups allow players to share their methodology when solving a target. + +The displayed fields include: +* `ID`: The record id +* `Username`: The username of the writeup author +* `Fqdn`: The name and IP of the target this writeup belongs to +* `Content`: A small portion of the writeup content +* `Approved`: Whether a writeup is approved or not +* `Status`: Status of writeup + * `OK`: Writeup is published and its ok to be displayed + * `Pending`: The writeup is pending for review by a moderator + * `Rejected`: The writeup is rejected by a moderator + * `Needs Fixes`: The writeup needs fixes as suggested by a moderator. (This usually means there is also a comment left for the player to read) +* `Language`: The language that this writeup is written (defaults to `English`) +* `Created At/Updated At`: When was the writeup created and last updated at \ No newline at end of file diff --git a/backend/modules/activity/views/writeup/help/update.php b/backend/modules/activity/views/writeup/help/update.php index 01ac985f8..c5ad0506c 100644 --- a/backend/modules/activity/views/writeup/help/update.php +++ b/backend/modules/activity/views/writeup/help/update.php @@ -1 +1,17 @@ -

Comming soon...

+Update an existing writeup for a platform target. + +Writeups allow players to share their methodology when solving a target. + +The form fields include: +* `Target ID`: The target this writeup belongs to +* `Player ID`: The username that the writeup will display as author +* `Formatter`: The formatter that will be used by the frontend to display this writeup (supported formatters `Markdown`, `Text`). +* `Language`: The language that this writeup is written (defaults to `English`) +* `Content`: The raw content of the writeup +* `Approved`: Whether a writeup is approved or not +* `Status`: Status of writeup + * `OK`: Writeup is published and its ok to be displayed + * `Pending`: The writeup is pending for review by a moderator + * `Rejected`: The writeup is rejected by a moderator + * `Needs Fixes`: The writeup needs fixes as suggested by a moderator. (This usually means there is also a comment left for the player to read) +* `Comment`: A comment that will be left for the author to read \ No newline at end of file diff --git a/backend/modules/activity/views/writeup/index.php b/backend/modules/activity/views/writeup/index.php index 8578f37d2..b0376b1be 100644 --- a/backend/modules/activity/views/writeup/index.php +++ b/backend/modules/activity/views/writeup/index.php @@ -50,7 +50,12 @@ 'attribute'=>'status', 'filter'=>['OK'=>'OK','PENDING'=>'PENDING','REJECTED'=>'REJECTED','NEEDS FIXES'=>'NEEDS FIXES'], ], - //'comment', + [ + 'attribute'=>'lang', + 'label'=>'Language', + 'value'=>'language.l' + + ], 'created_at', 'updated_at', diff --git a/backend/modules/activity/views/writeup/view.php b/backend/modules/activity/views/writeup/view.php index d57954ef3..157e4314b 100644 --- a/backend/modules/activity/views/writeup/view.php +++ b/backend/modules/activity/views/writeup/view.php @@ -36,6 +36,10 @@ 'target.name', 'target.ipoctet', 'formatter', + [ + 'attribute'=>'language.l', + 'label'=>'Language' + ], [ 'attribute'=>'content', 'format'=>'raw', diff --git a/backend/modules/infrastructure/models/NetworkTargetScheduleSearch.php b/backend/modules/infrastructure/models/NetworkTargetScheduleSearch.php index 6319e05e2..334f4c64b 100644 --- a/backend/modules/infrastructure/models/NetworkTargetScheduleSearch.php +++ b/backend/modules/infrastructure/models/NetworkTargetScheduleSearch.php @@ -61,6 +61,7 @@ public function search($params) // grid filtering conditions $query->andFilterWhere([ 'network_target_schedule.id' => $this->id, + 'network_target_schedule.target_id' => $this->target_id, ]); $query->andFilterWhere(['like','network_target_schedule.created_at',$this->created_at]) ->andFilterWhere(['like','network_target_schedule.updated_at',$this->updated_at]); diff --git a/backend/modules/infrastructure/views/target/full-view.php b/backend/modules/infrastructure/views/target/full-view.php index 2b9001a1f..2fba50268 100644 --- a/backend/modules/infrastructure/views/target/full-view.php +++ b/backend/modules/infrastructure/views/target/full-view.php @@ -79,9 +79,10 @@ ], [ 'label' => '', - 'content' => $this->render('full-view/_metadata-tab', ['model' => $model]), + 'content' => $this->render('full-view/_metadata-tab', ['model' => $model->metadata]), 'headerOptions' => ['style' => 'font-weight:bold'], 'options' => ['id' => '_metadata-tab'], + 'visible' => $model->metadata!==null, ], [ 'label' => '', diff --git a/backend/modules/infrastructure/views/target/full-view/_metadata-tab.php b/backend/modules/infrastructure/views/target/full-view/_metadata-tab.php index 3115a9e13..b5094bfc0 100644 --- a/backend/modules/infrastructure/views/target/full-view/_metadata-tab.php +++ b/backend/modules/infrastructure/views/target/full-view/_metadata-tab.php @@ -1,14 +1,12 @@
Target Metadata
- $model->metadata, + $model, 'attributes' => [ [ 'attribute' => 'scenario', @@ -75,4 +73,4 @@ } ], ], -]) ?> \ No newline at end of file +]); \ No newline at end of file diff --git a/backend/modules/infrastructure/views/target/full-view/_writeups.php b/backend/modules/infrastructure/views/target/full-view/_writeups.php index a9665620a..e743ab921 100644 --- a/backend/modules/infrastructure/views/target/full-view/_writeups.php +++ b/backend/modules/infrastructure/views/target/full-view/_writeups.php @@ -14,6 +14,10 @@ 'columns' => [ ['class' => 'app\components\columns\ProfileColumn','attribute'=>'username','label'=>'Username','idkey'=>'player.profile.id','field'=>'player.username'], 'approved:boolean', + [ + 'attribute'=>'lang', + 'value'=>'language.l' + ], [ 'attribute'=>'status', 'filter'=>['OK'=>'OK','PENDING'=>'PENDING','REJECTED'=>'REJECTED','NEEDS FIXES'=>'NEEDS FIXES'], diff --git a/backend/modules/settings/controllers/LanguageController.php b/backend/modules/settings/controllers/LanguageController.php new file mode 100644 index 000000000..749df84c3 --- /dev/null +++ b/backend/modules/settings/controllers/LanguageController.php @@ -0,0 +1,124 @@ +search($this->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Language model. + * @param string $id ID + * @return string + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Language model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return string|\yii\web\Response + */ + public function actionCreate() + { + $model = new Language(); + + if ($this->request->isPost) { + if ($model->load($this->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + } else { + $model->loadDefaultValues(); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing Language model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param string $id ID + * @return string|\yii\web\Response + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing Language model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param string $id ID + * @return \yii\web\Response + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Language model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param string $id ID + * @return Language the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Language::findOne(['id' => $id])) !== null) { + return $model; + } + + throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.')); + } +} diff --git a/backend/modules/settings/models/Language.php b/backend/modules/settings/models/Language.php new file mode 100644 index 000000000..f09227147 --- /dev/null +++ b/backend/modules/settings/models/Language.php @@ -0,0 +1,55 @@ + 8], + [['l'], 'string', 'max' => 36], + [['id'], 'unique'], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('app', 'ID'), + 'l' => Yii::t('app', 'L'), + ]; + } + + /** + * {@inheritdoc} + * @return LanguageQuery the active query used by this AR class. + */ + public static function find() + { + return new LanguageQuery(get_called_class()); + } +} diff --git a/backend/modules/settings/models/LanguageQuery.php b/backend/modules/settings/models/LanguageQuery.php new file mode 100644 index 000000000..a006c6206 --- /dev/null +++ b/backend/modules/settings/models/LanguageQuery.php @@ -0,0 +1,34 @@ +andWhere('[[status]]=1'); + }*/ + + /** + * {@inheritdoc} + * @return Language[]|array + */ + public function all($db = null) + { + return parent::all($db); + } + + /** + * {@inheritdoc} + * @return Language|array|null + */ + public function one($db = null) + { + return parent::one($db); + } +} diff --git a/backend/modules/settings/models/LanguageSearch.php b/backend/modules/settings/models/LanguageSearch.php new file mode 100644 index 000000000..9d861d2e0 --- /dev/null +++ b/backend/modules/settings/models/LanguageSearch.php @@ -0,0 +1,64 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere(['like', 'id', $this->id]) + ->andFilterWhere(['like', 'l', $this->l]); + + return $dataProvider; + } +} diff --git a/backend/modules/settings/views/language/_form.php b/backend/modules/settings/views/language/_form.php new file mode 100644 index 000000000..2f3ff8485 --- /dev/null +++ b/backend/modules/settings/views/language/_form.php @@ -0,0 +1,25 @@ + + +
+ + + + field($model, 'id')->textInput(['maxlength' => true]) ?> + + field($model, 'l')->textInput(['maxlength' => true]) ?> + +
+ 'btn btn-success']) ?> +
+ + + +
diff --git a/backend/modules/settings/views/language/_search.php b/backend/modules/settings/views/language/_search.php new file mode 100644 index 000000000..f8f7254ea --- /dev/null +++ b/backend/modules/settings/views/language/_search.php @@ -0,0 +1,32 @@ + + + diff --git a/backend/modules/settings/views/language/create.php b/backend/modules/settings/views/language/create.php new file mode 100644 index 000000000..799dd6040 --- /dev/null +++ b/backend/modules/settings/views/language/create.php @@ -0,0 +1,20 @@ +title = Yii::t('app', 'Create Language'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Languages'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/settings/views/language/index.php b/backend/modules/settings/views/language/index.php new file mode 100644 index 000000000..01ae34cf7 --- /dev/null +++ b/backend/modules/settings/views/language/index.php @@ -0,0 +1,46 @@ +title = Yii::t('app', 'Languages'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ 'btn btn-success']) ?> +

+ + + render('_search', ['model' => $searchModel]); ?> + + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'l', + [ + 'class' => ActionColumn::className(), + 'urlCreator' => function ($action, Language $model, $key, $index, $column) { + return Url::toRoute([$action, 'id' => $model->id]); + } + ], + ], + ]); ?> + + + +
diff --git a/backend/modules/settings/views/language/update.php b/backend/modules/settings/views/language/update.php new file mode 100644 index 000000000..386fc2c3b --- /dev/null +++ b/backend/modules/settings/views/language/update.php @@ -0,0 +1,23 @@ +title = Yii::t('app', 'Update Language: {name}', [ + 'name' => $model->id, +]); +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Languages'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/settings/views/language/view.php b/backend/modules/settings/views/language/view.php new file mode 100644 index 000000000..7ae11fb21 --- /dev/null +++ b/backend/modules/settings/views/language/view.php @@ -0,0 +1,37 @@ +title = $model->id; +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Languages'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+ +

title) ?>

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + 'l', + ], + ]) ?> + +
diff --git a/backend/views/layouts/main.php b/backend/views/layouts/main.php index 59ee5d8fa..2481dd220 100644 --- a/backend/views/layouts/main.php +++ b/backend/views/layouts/main.php @@ -194,6 +194,7 @@ ['label' => 'Avatars', 'url' => ['/settings/avatar/index'], 'visible' => !Yii::$app->user->isGuest,], ['label' => 'Experience', 'url' => ['/settings/experience/index'], 'visible' => !Yii::$app->user->isGuest,], ['label' => 'Countries', 'url' => ['/settings/country/index'], 'visible' => !Yii::$app->user->isGuest && Yii::$app->user->identity->isAdmin,], + ['label' => 'Languages', 'url' => ['/settings/language/index'], 'visible' => !Yii::$app->user->isGuest && Yii::$app->user->identity->isAdmin,], ['label' => 'Users', 'url' => ['/settings/user/index'], 'visible' => !Yii::$app->user->isGuest && Yii::$app->user->identity->isAdmin,], ['label' => 'URL Routes', 'url' => ['/settings/url-route/index'], 'visible' => !Yii::$app->user->isGuest && Yii::$app->user->identity->isAdmin,], ['label' => 'Disabled Routes', 'url' => ['/settings/disabled-route/index'], 'visible' => !Yii::$app->user->isGuest && Yii::$app->user->identity->isAdmin,], diff --git a/frontend/models/Language.php b/frontend/models/Language.php new file mode 100644 index 000000000..731522ffc --- /dev/null +++ b/frontend/models/Language.php @@ -0,0 +1,55 @@ + 8], + [['l'], 'string', 'max' => 36], + [['id'], 'unique'], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('app', 'ID'), + 'l' => Yii::t('app', 'L'), + ]; + } + + /** + * {@inheritdoc} + * @return LanguageQuery the active query used by this AR class. + */ + public static function find() + { + return new LanguageQuery(get_called_class()); + } +} diff --git a/frontend/models/LanguageQuery.php b/frontend/models/LanguageQuery.php new file mode 100644 index 000000000..ef2225d4a --- /dev/null +++ b/frontend/models/LanguageQuery.php @@ -0,0 +1,34 @@ +andWhere('[[status]]=1'); + }*/ + + /** + * {@inheritdoc} + * @return Language[]|array + */ + public function all($db = null) + { + return parent::all($db); + } + + /** + * {@inheritdoc} + * @return Language|array|null + */ + public function one($db = null) + { + return parent::one($db); + } +} diff --git a/frontend/modules/target/models/Writeup.php b/frontend/modules/target/models/Writeup.php index d842912b0..b38bfb772 100644 --- a/frontend/modules/target/models/Writeup.php +++ b/frontend/modules/target/models/Writeup.php @@ -20,10 +20,12 @@ * @property int|null $approved * @property string|null $status * @property string|null $formatter + * @property string $language_id * @property resource|null $comment * @property string|null $created_at * @property string|null $updated_at * + * @property Language $language * @property Player $player * @property Target $target */ @@ -66,14 +68,16 @@ public function rules() [['approved'], 'boolean'], [['approved'], 'default','value'=>false], ['formatter', 'default','value'=>'text'], + ['language_id', 'default','value'=>'en'], [['status', 'comment'], 'string'], [['content'], 'filter','filter'=>'trim'], [['content'], 'string','skipOnEmpty'=>false, 'min'=>'20'], ['status','default','value'=>'PENDING'], [['created_at', 'updated_at'], 'safe'], -// [['player_id', 'target_id'], 'unique', 'targetAttribute' => ['player_id', 'target_id']], [['player_id'], 'exist', 'skipOnError' => true, 'targetClass' => Player::class, 'targetAttribute' => ['player_id' => 'id']], [['target_id'], 'exist', 'skipOnError' => true, 'targetClass' => Target::class, 'targetAttribute' => ['target_id' => 'id']], + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => \app\models\Language::class, 'targetAttribute' => ['language_id' => 'id']], + ]; } @@ -138,6 +142,16 @@ public function getTarget() return $this->hasOne(Target::class, ['id' => 'target_id']); } + /** + * Gets query for [[Language]]. + * + * @return \yii\db\ActiveQuery|LanguageQuery|Language + */ + public function getLanguage() + { + return $this->hasOne(\app\models\Language::class, ['id' => 'language_id']); + } + /** * Gets query for [[Headshot]]. * diff --git a/frontend/themes/material/modules/target/views/default/_target_writeups.php b/frontend/themes/material/modules/target/views/default/_target_writeups.php index 11c85915f..a6286d8ca 100644 --- a/frontend/themes/material/modules/target/views/default/_target_writeups.php +++ b/frontend/themes/material/modules/target/views/default/_target_writeups.php @@ -26,10 +26,10 @@ $item_classes[]='active'; } if($writeups_activated) - echo Html::a($item->player->username.' '.\Yii::t('app',$item->averageRatingName).'',['/target/writeup/read','target_id'=>$item->target_id,'id'=>$item->id],['class'=>implode(' ',$item_classes)]); + echo Html::a($item->player->username.' ('.$item->language->id.') '.\Yii::t('app',$item->averageRatingName).'',['/target/writeup/read','target_id'=>$item->target_id,'id'=>$item->id],['class'=>implode(' ',$item_classes)]); else echo Html::a( - $item->player->username.' '.\Yii::t('app',$item->averageRatingName).'', + $item->player->username.' ('.$item->language->id.') '.\Yii::t('app',$item->averageRatingName).'', //' '.\Yii::t('app','Writeups available.'), ['/target/writeup/enable', 'id'=>$item->target_id], [ diff --git a/frontend/themes/material/modules/target/views/writeup/read.php b/frontend/themes/material/modules/target/views/writeup/read.php index 92b15eaf4..361cc3524 100644 --- a/frontend/themes/material/modules/target/views/writeup/read.php +++ b/frontend/themes/material/modules/target/views/writeup/read.php @@ -31,7 +31,7 @@ ?>
-

Html::a($model->target->name,$goback),'username'=>$model->player->profile->link]);?>

+

Html::a($model->target->name,$goback),'username'=>$model->player->profile->link,'language'=>$model->language->l]);?>