I solved my initial problem thanks to krileons reply, a lot of searching around the net and irc.freenode channels #joomla and #php.
What I needed was to be able to check a incoming string for a certain word, check if it exist in some language translation defined constant, and if it did, replace it with the constants name. In short, replace a constant value with its constant name, backwards of what most people use constants for.
First I included the CB Api as described in one of krielons signature tutorials.
Then I imported the language:
[code:1]
cbimport('language.front');
cbimport('cb.plugins');
[/code:1]
Searching for a value, if found, return its key (the constants name):
[code:1]
$returnMe = "null";
$array = get_defined_constants(true);
foreach ($array as $subarray) {
foreach ($subarray as $key => $value) {
if ($value === $searchKey) {
$returnMe = $key;
}
}
}
[/code:1]
This is just for reference if someone stumble upon this thread in the future
The reason I needed this is because of working on a module that enables mysql full-text search. So this searching function is just a tweak to deal with the fact that language translated fields get stored in the DB as _UE_Constantname, making them hard to find without knowing their names
Hopefully the module will be uploaded to the JED sometime this christmas. I will post a link to it here for reference if someone wants to see how it works.
-Kristian