/** * Translate data * * @param array &$data data * * @deprecated Joomfish not available in J1.7 * * @return void */ protected function translateData(&$data) { return; $params = $this->getParams(); if (!JPluginHelper::isEnabled('system', 'jfdatabase')) { return; } if (defined('JOOMFISH_PATH') && $params->get('allow-data-translation')) { $table = $this->getTable(); $db = FabrikWorker::getDbo(); $jf = JoomFishManager::getInstance(); $tableName = str_replace($this->config->get('dbprefix'), '', $table->db_table_name); $contentElement = $jf->getContentElement($tableName); if (!is_object($contentElement)) { return; } $title = Fabrikstring::shortColName($params->get('joomfish-title')); $activeLangs = $jf->getActiveLanguages(); $langId = $activeLangs[$this->config->get("jflang")]->id; $db->setQuery($contentElement->createContentSQL($langId)); if ($title == '') { $contentTable = $contentElement->getTable(); foreach ($contentTable->Fields as $tableField) { if ($tableField->Type == 'titletext') { $title = $tableField->Name; } } } $longKey = FabrikString::safeColNameToArrayKey($table->db_primary_key); $res = $db->loadObjectList(FabrikString::shortColName($table->db_primary_key)); // $$$ hugh - if no JF results, bail out, otherwise we pitch warnings in the foreach loop. if (empty($res)) { return; } foreach ($data as &$row) { // $$$ rob if the id isn't published fall back to __pk_val $translateRow = array_key_exists($longKey, $row) ? $res[$row->{$longKey}] : $res[$row->__pk_val]; foreach ($row as $key => $val) { $shortKey = array_pop(explode('___', $key)); if ($shortKey === $title) { $row->{$key} = $translateRow->titleTranslation; $key = $key . '_raw'; $row->{$key} = $translateRow->titleTranslation; } else { if (array_key_exists($shortKey, $translateRow)) { $row->{$key} = $translateRow->{$shortKey}; $key = $key . '_raw'; if (array_key_exists($key, $row)) { $row->{$key} = $translateRow->{$shortKey}; } } } } } } }
function translateData(&$data) { $params =& $this->getParams(); if (!JPluginHelper::isEnabled('system', 'jfdatabase')) { return; } if (defined('JOOMFISH_PATH') && $params->get('allow-data-translation')) { $table = $this->getTable(); $db = JFactory::getDBO(); $jf =& JoomFishManager::getInstance(); $config =& JFactory::getConfig(); $tableName = str_replace($config->getValue('dbprefix'), '', $table->db_table_name); $contentElement =& $jf->getContentElement($tableName); if (!is_object($contentElement)) { return; } // @TODO need top make and get xml file for any db join elements - otherwise their labels are replaced with the values $title = Fabrikstring::shortColName($params->get('joomfish-title')); $activelangs = $jf->getActiveLanguages(); $registry =& JFactory::getConfig(); $langid = $activelangs[$registry->getValue("config.jflang")]->id; $db->setQuery($contentElement->createContentSQL($langid)); if ($title == '') { $contentTable = $contentElement->getTable(); foreach ($contentTable->Fields as $tableField) { if ($tableField->Type == 'titletext') { $title = $tableField->Name; } } } $longKey = FabrikString::safeColNameToArrayKey($table->db_primary_key); $res =& $db->loadObjectList($this->_shortKey(null, true)); // $$$ hugh - if no JF results, bail out, otherwise we pitch warnings in the foreach loop. if (empty($res)) { return; } foreach ($data as &$row) { //$$$ rob if the id isnt published fall back to __pk_val $translateRow = array_key_exists($longKey, $row) ? $res[$row->{$longKey}] : $res[$row->__pk_val]; foreach ($row as $key => $val) { $shortkey = array_pop(explode("___", $key)); if ($shortkey === $title) { $row->{$key} = $translateRow->titleTranslation; $key = $key . "_raw"; $row->{$key} = $translateRow->titleTranslation; } else { if (array_key_exists($shortkey, $translateRow)) { $row->{$key} = $translateRow->{$shortkey}; $key = $key . "_raw"; if (array_key_exists($key, $row)) { $row->{$key} = $translateRow->{$shortkey}; } } } } } } }