function pof_taxonomy_translate_form_view()
{
    $taxonomies = array();
    $taxonomies['place_of_performance'] = "Suorituspaikat";
    $taxonomies['groupsize'] = "Ryhmäkoot";
    $taxonomies['mandatory'] = "Pakollisuus";
    $taxonomies['taskduration'] = "Aktiviteetin kestot";
    $taxonomies['taskpreaparationduration'] = "Aktiviteetin valmistelun kestot";
    $taxonomies['equpment'] = "Tarvikkeet";
    $taxonomies['skillarea'] = "Taitoalueet";
    $taxonomies['growth_target'] = "Kasvatustavoitteen avainsanat";
    $taxonomies['taskgroup_term'] = "Aktiviteettipaketin yläkäsite";
    global $wpdb;
    $table_name = pof_taxonomy_translate_get_table_name();
    $languages = pof_taxonomy_translate_get_languages();
    $agegroups = pof_taxonomy_translate_get_agegroups();
    $selected_lang = 'fi';
    $taxonomy_base_key = "place_of_performance";
    if (isset($_POST['language'])) {
        $selected_lang = $_POST['language'];
    }
    if (isset($_POST['taxonomy'])) {
        $taxonomy_base_key = $_POST['taxonomy'];
    }
    $items = pof_taxonomy_translate_get_items_by_taxonomy_base_key($taxonomy_base_key);
    $title = $taxonomies[$taxonomy_base_key];
    echo '<div class="wrap">';
    echo '<h1>' . $title . '</h1>';
    echo '<form method="post" action="">';
    echo 'Valitse taksonomia:';
    echo '<select name="taxonomy">';
    foreach ($taxonomies as $taxonomy_key => $taxonomy_title) {
        if ($taxonomy_key == $taxonomy_base_key) {
            echo '<option selected="selected" value="' . $taxonomy_key . '">' . $taxonomy_title . '</option>';
        } else {
            echo '<option value="' . $taxonomy_key . '">' . $taxonomy_title . '</option>';
        }
    }
    echo '</select>';
    echo '<br />';
    echo 'Valitse kieli:';
    echo '<select name="language">';
    foreach ($languages as $lang_key => $lang) {
        if ($lang_key == $selected_lang) {
            echo '<option selected="selected" value="' . $lang_key . '">' . $lang . '</option>';
        } else {
            echo '<option value="' . $lang_key . '">' . $lang . '</option>';
        }
    }
    echo '</select>';
    echo '<br />';
    echo '<input type="submit" value="Vaihda" />';
    echo '</form>';
    echo '<br /><br /><br />';
    echo '<h2>Kieli: ' . $languages[$selected_lang] . ' (' . $selected_lang . ')</h2>';
    echo '<table cellpadding="2" cellspacing="2" border="2">';
    echo '<thead>';
    echo '<tr>';
    echo '<th></th>';
    foreach ($agegroups as $agegroup) {
        echo '<th><h2>' . $agegroup->title . '</h2></th>';
    }
    echo '</tr>';
    echo '</thead>';
    echo '<tbody>';
    foreach ($items as $tmp_key => $tmp_title) {
        echo '<tr>';
        echo '<td>' . $tmp_title . '<br /> (' . $tmp_key . ')</td>';
        foreach ($agegroups as $agegroup) {
            echo '<td>';
            $translation = pof_taxonomy_translate_get_translation($taxonomy_base_key, $tmp_key, $agegroup->id, $selected_lang, false);
            $translation_content = "";
            if (!empty($translation)) {
                $translation_content = $translation[0]->content;
            }
            echo $translation_content;
            echo '</td>';
        }
        echo '</tr>';
    }
    echo '</tbody>';
    echo '</table>';
    echo '</div>';
}
function pof_importer_get_places($places_str)
{
    global $wpdb;
    $taxonomy_base_key = "place_of_performance";
    global $pof_importer_driverimporter_places;
    if (count($pof_importer_driverimporter_places) == 0) {
        $pof_importer_driverimporter_places = pof_taxonomy_translate_get_items_by_taxonomy_base_key($taxonomy_base_key, true);
    }
    $ret = array();
    $parts = explode(',', $places_str);
    foreach ($parts as $part) {
        $part = trim($part);
        $part_key = array_search(strtolower($part), $pof_importer_driverimporter_places);
        if ($part_key == false) {
            $part_tmp = str_replace(" ", "_", strtolower($part));
            $taxonomy_full_key = $taxonomy_base_key . "::" . sanitize_title_with_dashes(pof_importer_normalize_key($part_tmp));
            $tmp = $wpdb->insert(pof_taxonomy_translate_get_table_name(), array('taxonomy_slug' => $taxonomy_full_key, 'agegroup_id' => 0, 'lang' => 'fi', 'content' => $part), array('%s', '%d', '%s', '%s'));
            $pof_importer_driverimporter_places = pof_taxonomy_translate_get_items_by_taxonomy_base_key($taxonomy_base_key, true);
        }
        $part_key = str_replace($taxonomy_base_key . '::', "", $part_key);
        array_push($ret, $part_key);
    }
    return $ret;
}
function pof_taxonomy_translate_get_items_by_taxonomy_base_key($taxonomy_base_key, $tolower = false)
{
    $ret = array();
    global $wpdb;
    $table_name = pof_taxonomy_translate_get_table_name();
    $translate_res = $wpdb->get_results("\r\n\t\tSELECT taxonomy_slug, content, id\r\n\t\tFROM " . pof_taxonomy_translate_get_table_name() . "\r\n\t\tWHERE lang = 'fi'\r\n\t\t\tAND agegroup_id = 0\r\n\t\t\tAND taxonomy_slug LIKE '" . $taxonomy_base_key . "::%'\r\n\r\n        ORDER BY taxonomy_slug, content\r\n\t\t");
    foreach ($translate_res as $item) {
        $key = str_replace($taxonomy_base_key . '::', "", $item->taxonomy_slug);
        if (trim($key) == "") {
            $wpdb->delete(pof_taxonomy_translate_get_table_name(), array('id' => $item->id), array('%d'));
        }
        if ($tolower) {
            $ret[$key] = strtolower($item->content);
        } else {
            $ret[$key] = $item->content;
        }
    }
    return $ret;
}