1 | <?php |
||
13 | class SMF2_1 extends Importers\AbstractSourceImporter |
||
14 | { |
||
15 | protected $setting_file = '/Settings.php'; |
||
16 | |||
17 | protected $smf_attach_folders = null; |
||
18 | |||
19 | public function getName() |
||
20 | { |
||
21 | return 'SMF2_1'; |
||
22 | } |
||
23 | |||
24 | public function getVersion() |
||
25 | { |
||
26 | return 'ElkArte 1.0'; |
||
27 | } |
||
28 | |||
29 | public function setDefines() |
||
30 | { |
||
31 | if (!defined('SMF')) |
||
32 | { |
||
33 | define('SMF', 1); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | public function getPrefix() |
||
38 | { |
||
39 | $db_name = $this->getDbName(); |
||
40 | $db_prefix = $this->fetchSetting('db_prefix'); |
||
41 | |||
42 | return '`' . $db_name . '`.' . $db_prefix; |
||
43 | } |
||
44 | |||
45 | public function getDbName() |
||
48 | } |
||
49 | |||
50 | public function getTableTest() |
||
51 | { |
||
52 | return 'members'; |
||
53 | } |
||
54 | |||
55 | public function fetchSetting($name) |
||
56 | { |
||
57 | static $content = null; |
||
58 | |||
59 | if ($content === null) |
||
60 | { |
||
61 | $content = file_get_contents($this->path . '/Settings.php'); |
||
62 | } |
||
63 | |||
64 | $match = array(); |
||
65 | preg_match('~\$' . $name . '\s*=\s*\'(.*?)\';~', $content, $match); |
||
66 | |||
67 | return isset($match[1]) ? $match[1] : ''; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Read the attachment directory structure from the source db |
||
72 | * |
||
73 | * @return array|null |
||
74 | */ |
||
75 | public function getAttachmentDirs() |
||
76 | { |
||
77 | if ($this->smf_attach_folders === null) |
||
78 | { |
||
79 | $from_prefix = $this->config->from_prefix; |
||
80 | |||
81 | $request = $this->db->query(" |
||
82 | SELECT value |
||
83 | FROM {$from_prefix}settings |
||
84 | WHERE variable='attachmentUploadDir';"); |
||
85 | list ($smf_attachments_dir) = $this->db->fetch_row($request); |
||
86 | |||
87 | $this->smf_attach_folders = @unserialize($smf_attachments_dir); |
||
88 | |||
89 | if (!is_array($this->smf_attach_folders)) |
||
90 | { |
||
91 | $this->smf_attach_folders = array(1 => $smf_attachments_dir); |
||
92 | } |
||
93 | } |
||
94 | |||
95 | return $this->smf_attach_folders; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Import likes from the 2.1 table |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | public function fetchLikes() |
||
123 | } |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * Copy attachments from the source to our destination |
||
128 | * |
||
129 | * @param array $row |
||
130 | * @param \OpenImporter\Database $db |
||
207 |