public function bindFLEXI() { $db = JFactory::getDbo(); $db->setQuery("SELECT `enabled` FROM #__extensions WHERE `type` = 'component' AND `element` = 'com_flexicontent'"); $is_enabled = $db->loadResult(); if ($is_enabled == 1) { require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php'; JLoader::import('joomla.application.component.model'); JLoader::import('items', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'models'); if (version_compare(JVERSION, '3.0', 'ge')) { $model = JModelLegacy::getInstance('items', 'flexicontentModel'); } else { if (version_compare(JVERSION, '2.5', 'ge')) { $model = JModel::getInstance('items', 'flexicontentModel'); } else { $model = JModel::getInstance('items', 'flexicontentModel'); } } $rows = $model->getUnboundedItems(2500, $count_only = false, $checkNoExtData = true, $checkInvalidCat = false, $noCache = true); $model->bindExtData($rows); JalangHelperTool::fixFLEXIAssLanguage($rows); } jexit('DONE'); }
public static function fixFLEXIAssLanguage($rows) { if (version_compare(JVERSION, '3.0', 'ge')) { $assoc = JLanguageAssociations::isEnabled(); } else { $assoc = JLanguageMultilang::isEnabled(); } if ($assoc) { $db = JFactory::getDbo(); for ($i = 0; $i < count($rows); $i++) { $associations = JalangHelperTool::getAssociations('com_content', '#__content', 'com_content.item', $rows[$i]->id); if ($associations != false) { $j = 0; foreach ($associations as $tag => $association) { if ($j == 0) { // Only get the first tag language. $assocciation = explode(':', $association->id); $query = 'UPDATE #__flexicontent_items_tmp SET `lang_parent_id` = ' . $assocciation[0] . ' WHERE `id` = ' . $rows[$i]->id; $db->setQuery($query); $db->query(); $query = 'UPDATE #__flexicontent_items_ext SET `lang_parent_id` = ' . $assocciation[0] . ' WHERE `item_id` = ' . $rows[$i]->id; $db->setQuery($query); $db->query(); $query = 'UPDATE #__flexicontent_items_tmp SET `language` = "' . $tag . '" WHERE `id` = ' . $assocciation[0]; $db->setQuery($query); $db->query(); $query = 'UPDATE #__flexicontent_items_ext SET `language` = "' . $tag . '" WHERE `item_id` = ' . $assocciation[0]; $db->setQuery($query); $db->query(); } $j++; } } } } }