1+ <?php
2+
3+ /**
4+ * Frontend for importing records from a csv file.
5+ *
6+ * This Source Code Form is subject to the terms of the Mozilla Public License,
7+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
8+ * obtain one at https://mozilla.org/MPL/2.0/.
9+ *
10+ * @package phpMyFAQ
11+ * @author Thorsten Rinne <[email protected] > 12+ * @copyright 2003-2024 phpMyFAQ Team
13+ * @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14+ * @link https://www.phpmyfaq.de
15+ * @since 2003-02-24
16+ */
17+ use phpMyFAQ \Session \Token ;
18+ use phpMyFAQ \Template \TwigWrapper ;
19+ use phpMyFAQ \Translation ;
20+
21+ if (!defined ('IS_VALID_PHPMYFAQ ' )) {
22+ http_response_code (400 );
23+ exit ();
24+ }
25+
26+ if ($ user ->perm ->hasPermission ($ user ->getUserId (), 'add_faq ' )) {
27+ $ twig = new TwigWrapper (PMF_ROOT_DIR . '/assets/templates ' );
28+ $ template = $ twig ->loadTemplate ('./admin/content/csv.import.twig ' );
29+
30+ $ templateVars = [
31+ 'adminHeaderImport ' => Translation::get ('msgImportRecords ' ),
32+ 'adminHeaderCSVImport ' => Translation::get ('msgImportCSVFile ' ),
33+ 'adminBodyCSVImport ' => Translation::get ('msgImportCSVFileBody ' ),
34+ 'adminImportLabel ' => Translation::get ('ad_csv_file ' ),
35+ 'adminCSVImport ' => Translation::get ('msgImport ' ),
36+ 'adminHeaderCSVImportColumns ' => Translation::get ('msgColumnStructure ' ),
37+ 'categoryId ' => Translation::get ('ad_categ_categ ' ),
38+ 'question ' => Translation::get ('ad_entry_topic ' ),
39+ 'answer ' => Translation::get ('ad_entry_content ' ),
40+ 'keywords ' => Translation::get ('ad_entry_keywords ' ),
41+ 'author ' => Translation::get ('ad_entry_author ' ),
42+ 'email ' => Translation::get ('ad_entry_email ' ),
43+ 'languageCode ' => Translation::get ('msgLanguageCode ' ),
44+ 'seperateWithCommas ' => Translation::get ('msgSeperateWithCommas ' ),
45+ 'tags ' => Translation::get ('ad_entry_tags ' ),
46+ 'msgImportRecordsColumnStructure ' => Translation::get ('msgImportRecordsColumnStructure ' ),
47+ 'csrfToken ' => Token::getInstance ()->getTokenString ('importfaqs ' ),
48+ 'is_active ' => Translation::get ('ad_entry_active ' ),
49+ 'is_sticky ' => Translation::get ('ad_entry_sticky ' ),
50+ 'trueFalse ' => Translation::get ('msgCSVImportTrueOrFalse ' )
51+ ];
52+ echo $ template ->render ($ templateVars );
53+ } else {
54+ require 'no-permission.php ' ;
55+ }
0 commit comments