From 11775a08466ef2e372f95fa70cb44ca84f1f2b93 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 6 Jul 2006 23:02:55 +0000 Subject: [PATCH] new method to get the message_id of a phrase --- phpgwapi/inc/class.translation.inc.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/phpgwapi/inc/class.translation.inc.php b/phpgwapi/inc/class.translation.inc.php index 2149422c4e..19a177e4c4 100644 --- a/phpgwapi/inc/class.translation.inc.php +++ b/phpgwapi/inc/class.translation.inc.php @@ -793,4 +793,24 @@ return $this->db->next_record() ? $this->db->f('content') : false; } + + /** + * Return the message_id of a given translation + * + * @param string $translation + * @param string $app='' default check all apps + * @param string $lang='' default check all langs + * @return string + */ + function get_message_id($translation,$app=null,$lang=null) + { + $like = $this->db->Type == 'pgsql' ? 'ILIKE' : 'LIKE'; + $where = array('content '.$like.' '.$this->db->quote($translation)); // like to be case-insensitive + if ($app) $where['app_name'] = $app; + if ($lang) $where['lang'] = $lang; + + $this->db->select($this->lang_table,'message_id',$where,__LINE__,__FILE__); + + return $this->db->next_record() ? $this->db->f(0) : false; + } }