Example #1
0
            while (!$glossary && $project->parent_project_id) {
                $project = GP::$project->get($project->parent_project_id);
                $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $slug, $locale);
                if ($translation_set) {
                    $glossary = $this->by_set_id($translation_set->id);
                }
            }
        }
        return $glossary;
    }
    function by_set_id($set_id)
    {
        return $this->one("\n\t\t    SELECT * FROM {$this->table}\n\t\t    WHERE translation_set_id = %d LIMIT 1", $set_id);
    }
    /**
     * Copies glossary items from a glossary to the current one
     * This function does not merge then, just copies unconditionally. If a translation already exists, it will be duplicated.
     *
     * @param int $source_glossary_id
     *
     * @return mixed
     */
    function copy_glossary_items_from($source_glossary_id)
    {
        global $wpdb;
        $current_date = $this->now_in_mysql_format();
        return $this->query("\n\t\t\tINSERT INTO {$wpdb->gp_glossary_items} (\n\t\t\t\tid, term, type, examples, comment, suggested_translation, last_update\n\t\t\t)\n\t\t\tSELECT\n\t\t\t\t%s AS id, term, type, examples, comment, suggested_translation, %s AS last_update\n\t\t\tFROM {$wpdb->gp_glossary_items} WHERE id = %s", $this->id, $current_date, $source_glossary_id);
    }
}
GP::$glossary = new GP_Glossary();