public function getImport() { $xsdstring = $_SERVER['DOCUMENT_ROOT'] . "/import.xml"; $excel = new XML2003Parser($xsdstring); $table = $excel->getTableData(); function mb_ucfirst($str, $enc = 'utf-8') { return mb_strtoupper(mb_substr($str, 0, 1, $enc), $enc) . mb_substr($str, 1, mb_strlen($str, $enc), $enc); } foreach ($table["table_contents"] as $row) { if (isset($row["row_contents"][2]) && isset($row["row_contents"][0])) { $id = $row["row_contents"][0]['value']; $value = trim(mb_ucfirst(mb_strtolower($row["row_contents"][2]['value']))); $postlang = PostLang::find($id); if ($postlang) { $postlang->title = $value; $postlang->uri = PostLang::uniqURI($id, $value); $postlang->save(); } else { echo "undefined {$id} <br>"; } //echo "$id $value<br><br><br>"; } } return []; }
public function getImport() { return []; $xsdstring = $_SERVER['DOCUMENT_ROOT'] . "/vars.xml"; $excel = new XML2003Parser($xsdstring); $table = $excel->getTableData(); $ids = []; foreach ($table["table_contents"] as $row) { if (isset($row["row_contents"][2]) && isset($row["row_contents"][0])) { $id = $row["row_contents"][0]['value']; if ($id && in_array($id, [84]) === FALSE) { $value = htmlspecialchars_decode($row["row_contents"][2]['value']); $varlang = VarLangModel::find($id); if ($varlang) { $varlang->value = $value; if ($varlang->value !== $value && strlen(trim($varlang->value)) > 0) { echo "DIFF [{$varlang->lang_id}] [{$varlang->id}] [[{$varlang->value}]] [[{$value}]]<br>\n"; } if ($varlang->value !== $value && strlen(trim($varlang->value)) == 0) { echo "CLEAR [{$varlang->lang_id}] [{$varlang->id}] [[{$varlang->value}]] [[{$value}]]<br>\n"; } $varlang->save(); } else { echo "interzis [{$varlang->lang_id}] {$id} {$varlang} <br>\n"; } } else { echo "clear<br>\n"; } } } return []; }