/** * Method to get information of site languages * * @return object * @since 1.5 */ static function getlanguageslist($published_only = false, $add_all = true) { $app = JFactory::getApplication(); $db = JFactory::getDBO(); static $pub_languages = null; static $all_languages = null; if ($published_only) { if ($pub_languages) { return $pub_languages; } else { $pub_languages = false; } } if (!$published_only) { if ($all_languages) { return $all_languages; } else { $all_languages = false; } } // ****************** // Retrieve languages // ****************** if (FLEXI_J16GE) { // Use J1.6+ language info $query = 'SELECT DISTINCT lc.lang_id as id, lc.image as image_prefix, lc.lang_code as code, lc.title_native, ' . ' lc.title as name ' . ' FROM #__languages as lc ' . ' WHERE 1 ' . ($published_only ? ' AND lc.published=1' : '') . ' ORDER BY lc.ordering ASC '; } else { if (FLEXI_FISH) { // Use joomfish languages table $query = 'SELECT l.* ' . (FLEXI_FISH_22GE ? ', lext.* ' : '') . (FLEXI_FISH_22GE ? ', l.lang_id as id ' : ', l.id ') . (FLEXI_FISH_22GE ? ', l.lang_code as code, l.sef as shortcode' : ', l.code, l.shortcode') . (FLEXI_FISH_22GE ? ', CASE WHEN CHAR_LENGTH(l.title_native) THEN CONCAT(l.title, " (", l.title_native, ")") ELSE l.title END as name ' : ', l.name ') . ' FROM #__languages as l' . (FLEXI_FISH_22GE ? ' LEFT JOIN #__jf_languages_ext as lext ON l.lang_id=lext.lang_id ' : '') . ' WHERE ' . (FLEXI_FISH_22GE ? ' l.published=1 ' : ' l.active=1 ') . ' ORDER BY ' . (FLEXI_FISH_22GE ? ' lext.ordering ASC ' : ' l.ordering ASC '); } else { //echo "<pre>"; debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); echo "</pre>"; //JError::raiseNotice(500, 'getlanguageslist(): Notice no joomfish installed'); //return array(); } } if (!empty($query)) { $db->setQuery($query); $languages = $db->loadObjectList('id'); //echo "<pre>"; print_r($languages); echo "</pre>"; exit; if ($db->getErrorNum()) { JFactory::getApplication()->enqueueMessage(__FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg()), 'error'); } } // ********************* // Calculate image paths // ********************* if (FLEXI_J16GE) { // FLEXI_J16GE, use J1.6+ images $imgpath = $app->isAdmin() ? '../images/' : 'images/'; $mediapath = $app->isAdmin() ? '../media/mod_languages/images/' : 'media/mod_languages/images/'; } else { // Use joomfish images $imgpath = $app->isAdmin() ? '../images/' : 'images/'; $mediapath = $app->isAdmin() ? '../components/com_joomfish/images/flags/' : 'components/com_joomfish/images/flags/'; } // ************************ // Prepare language objects // ************************ $_languages = array(); // J1.6+ add 'ALL' also add 'ALL' if no languages found, since this is default for J1.6+ if (FLEXI_J16GE && $add_all) { $lang_all = new stdClass(); $lang_all->code = '*'; $lang_all->name = JText::_('FLEXI_ALL'); $lang_all->shortcode = '*'; $lang_all->id = 0; $_languages = array(0 => $lang_all); } // J1.5 add default site language if no languages found, e.g. no Joom!Fish installed if (!FLEXI_J16GE && empty($languages)) { $lang_default = new stdClass(); $lang_default->code = flexicontent_html::getSiteDefaultLang(); $lang_default->name = $lang_default->code; $lang_default->shortcode = strpos($lang_default->code, '-') ? substr($lang_default->code, 0, strpos($lang_default->code, '-')) : $lang_default->code; $lang_default->id = 0; $_languages = array(0 => $lang_default); } // Check if no languages found and return if (empty($languages)) { return $_languages; } if (FLEXI_J16GE) { foreach ($languages as $lang) { // Calculate/Fix languages data $lang->shortcode = strpos($lang->code, '-') ? substr($lang->code, 0, strpos($lang->code, '-')) : $lang->code; //$lang->id = $lang->extension_id; $image_prefix = $lang->image_prefix ? $lang->image_prefix : $lang->shortcode; // $lang->image, holds a custom image path $lang->imgsrc = @$lang->image ? $imgpath . $lang->image : $mediapath . $image_prefix . '.gif'; $_languages[$lang->id] = $lang; } // Also prepend '*' (ALL) language to language array //echo "<pre>"; print_r($languages); echo "</pre>"; exit; // Select language -ALL- if none selected //$selected = $selected ? $selected : '*'; // WRONG behavior commented out } else { if (FLEXI_FISH_22GE) { require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_joomfish' . DS . 'helpers' . DS . 'extensionHelper.php'; foreach ($languages as $lang) { // Get image path via helper function $_imgsrc = JoomfishExtensionHelper::getLanguageImageSource($lang); $lang->imgsrc = JURI::root(true) . ($_imgsrc[0] != '/' ? '/' : '') . $_imgsrc; $_languages[$lang->id] = $lang; } } else { foreach ($languages as $lang) { // $lang->image, holds a custom image path $lang->imgsrc = @$lang->image ? $imgpath . $lang->image : $mediapath . $lang->shortcode . '.gif'; $_languages[$lang->id] = $lang; } } } $languages = $_languages; if ($published_only) { $pub_languages = $_languages; } else { $all_languages = $_languages; } return $_languages; }
/** * Method to determine the correct image path for language flags. * The works as the standard JHTMLImage method except that it uses always the live site basic as URL * * @param unknown_type $language * @param unknown_type $altFile * @param unknown_type $altFolder * @param unknown_type $alt * @param unknown_type $attribs * @return string image path */ function languageImage($language, $alt = NULL, $attribs = '') { $src = JoomfishExtensionHelper::getLanguageImageSource($language); return '<img src="' . JURI::root() . $src . '" alt="' . html_entity_decode($alt) . '" ' . $attribs . ' />'; }
?> value="<?php echo $language->lang_id; ?> " /></td> <td><input type="text" name="sef[]" value="<?php echo $language->sef; ?> " maxlength="10" /></td> <td><input type="text" name="fallbackCode[]" value="<?php echo $language->fallback_code; ?> " maxlength="20" /></td> <td nowrap="nowrap"> <?php $src = JoomfishExtensionHelper::getLanguageImageSource($language); ?> <img src="<?php echo $src != '' ? $src : JURI::base() . 'images/blank.png'; ?> " alt="<?php echo html_entity_decode($src); ?> " title="<?php echo $language->title; ?> " class="flag" id="flagImage<?php echo $i; ?> " /> <input id="flagValue<?php
/** * Returns the language image based on the standard media folder (as configured in the component) or template information * The component parameters will be used as folder path within the template or starting with the root directory of your site * If the image is found in the current template + folder this reference is returned. Otherwise the reference from * JPATH_SITE + folder. The reference is not verified if the image exists! * * @param $language JFLnaguage language object including the detailed information * @return string Path to the image found */ function getLanguageImageSource($language) { return JoomfishExtensionHelper::getLanguageImageSource($language); }