/** Imports genre translations from a text files into database */ function importGenres($lines, $language) { if (empty($lines)) { logError("importGenres: file is empty"); return; } reset($lines); while (list(, $line) = each($lines)) { if (preg_match('/^\\s*$/', $line) || preg_match('/^#/', $line)) { continue; } if (!preg_match('/^\\s*(\\d+)\\s+(.*)/', $line, $items)) { logError("bad line syntax: {$line}"); continue; } debug("genre item", $items); $id = $items[1]; $name = trim($items[2]); $o1 = new sotf_NodeObject("sotf_genres"); $o1->setID($o1->makeId(0, $o1->tablename, $id . $language)); $o1->set('genre_id', $id); $o1->set('language', $language); $o1->set('name', $name); $o1->create(); } }