public function sitemapXML() { static $mlp_installed; if (!isset($mlp_installed)) { $mlp_installed = is_callable('l10n_installed') ? call_user_func('l10n_installed', true) : false; } $out = '<?xml version="1.0" encoding="utf-8"?>'; $out .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; // Homepage $out .= $this->urlXML(hu); // Excluded sections $excluded = $GLOBALS['prefs']['jmd_sitemap_exclude']; $excluded = unserialize($excluded); foreach ($excluded as $key => $value) { $notIn[$key] = "'{$value}'"; } $notIn = implode(',', $notIn); $notIn .= ",'default'"; // List sections $site_langs = array(); if ($mlp_installed) { $site_langs = MLPLanguageHandler::get_site_langs(); } $sections = safe_column("name", "txp_section", "name not in({$notIn})"); foreach ($sections as $section) { if ($mlp_installed) { foreach ($site_langs as $lang) { $lang = substr($lang, 0, 2) . '/'; $loc = hu . $lang . urlencode($section) . '/'; $out .= $this->urlXML($loc); } } else { $loc = pagelinkurl(array('s' => $section)); $out .= $this->urlXML($loc); } } // Articles $fields = 'ID as thisid, Section as section, Title as title, url_title, unix_timestamp(Posted) as posted, unix_timestamp(LastMod) as lastmod'; if ($mlp_installed) { $fields .= ', l10n_lang'; } $articles = getRows("select {$fields} from " . safe_pfx('textpattern') . " where Status = 4 and Posted<= now() and section not in({$notIn})"); if ($articles) { include_once txpath . '/publish/taghandlers.php'; foreach ($articles as $article) { $loc = permlinkurl($article); if ($mlp_installed) { $loc = str_replace(hu, hu . substr($article['l10n_lang'], 0, 2) . '/', $loc); } $lastmod = date('c', $article['lastmod']); $out .= $this->urlXML($loc, $lastmod); } } $out .= '</urlset>'; return $out; }
function get_site_default_lang() { /* Returns a string containing the ISO-639-1 language to be used as the site's default. */ $lang_codes = MLPLanguageHandler::get_site_langs(); return $lang_codes[0]; }
function _l10n_image_paint($page) { $default = MLPLanguageHandler::get_site_default_lang(); # # Insert the remaining language fields... # global $l10n_mappings; $langs = MLPLanguageHandler::get_site_langs(); $fields = $l10n_mappings['txp_image']; $id = gps('id'); $row = safe_row('*', 'txp_image', "`id`='{$id}'"); $r = ''; $count = 2; foreach ($langs as $lang) { if ($lang !== $default) { $full_name = MLPLanguageHandler::get_native_name_of_lang($lang); $dir = MLPLanguageHandler::get_lang_direction_markup($lang); foreach ($fields as $field => $attributes) { $field_name = _l10n_make_field_name($field, $lang); if ($field === 'alt') { $r .= '<p>' . gTxt('alt_text') . ' ' . $full_name . '<br/>'; $r .= '<input type="text" name="' . $field_name . '" ' . $dir . ' value="' . $row[$field_name] . '" size="50" class="edit" id="' . $field_name . '" /></p>' . n; } else { $r .= '<p>' . gTxt('caption') . ' ' . $full_name . '<br/>'; $r .= '<textarea name="' . $field_name . '" cols="40" rows="5" style="width: 400px; height: 100px;"' . $dir . '>'; $r .= $row[$field_name] . '</textarea></p>' . n; } } } } $f = '<p><input type="submit" value="'; $page = str_replace($f, $r . n . $f, $page); # # Insert the default title field's language's direction... # $dir = MLPLanguageHandler::get_lang_direction_markup($default) . ' '; $f = '<input type="text" name="alt"'; $page = str_replace($f, $f . $dir, $page); $f = '<textarea id="caption"'; $page = str_replace($f, $f . $dir, $page); # # Insert the default title field's language name... # $f = 'for="alt-text">' . gTxt('alt_text'); $r = ' ' . MLPLanguageHandler::get_native_name_of_lang($default); $page = str_replace($f, $f . sp . $r, $page); $f = 'for="caption">' . gTxt('caption'); $page = str_replace($f, $f . sp . $r, $page); return $page; }
function cleanup_4a_cb($table, $field, $attributes) { $langs = MLPLanguageHandler::get_site_langs(); foreach ($langs as $lang) { $f = _l10n_make_field_name($field, $lang); $sql = "DROP `{$f}`"; $ok = @safe_alter($table, $sql); $this->add_report_item(gTxt('l10n-drop_field', array('{field}' => $f, '{table}' => $table)), $ok, true); } }
function l10n_lang_list($atts) { global $thisarticle, $l10n_language, $is_article_list, $pretext, $prefs; extract(lAtts(array('title' => '', 'on404' => '', 'current_class' => 'l10n_current', 'language_class' => 'long', 'list_class' => 'l10n_lang_list', 'show_empty' => '', 'link_current' => '', 'display' => 'native', 'article_list' => $is_article_list, 'surpress_current' => '', 'empty_title' => '', 'appendslash' => '', 'wraptag' => 'ul', 'break' => 'li', 'hide_langs' => ''), $atts)); $on404 = !empty($on404); # User marked this list as a 404 special lookup list. $show_empty = !empty($show_empty); $link_current = !empty($link_current); $surpress_current = !empty($surpress_current); $break = $wraptag == 'select' ? 'option' : $break; // Ensure 'option' break tag if select used $appendslash = !empty($appendslash); $processing404 = $pretext['status'] === '404'; $messy_urls = $pretext['permlink_mode'] === 'messy'; $category_list = !empty($pretext['c']); $get_style_cat = gps('c'); $processingcats = $category_list && !$messy_urls && !$get_style_cat; # Don't process (localise) category list urls in messy mode. $author_list = !empty($pretext['author']); $get_style_auth = gps('author'); $processingauths = $author_list && !$messy_urls && !$get_style_auth; # Don't process (localise) author list urls in messy mode. $list = array(); static $alangs; $slangs = MLPLanguageHandler::get_site_langs(); $hide_langs = do_list(trim($hide_langs)); $slangs = array_diff($slangs, $hide_langs); $section = empty($pretext['s']) ? '' : $pretext['s']; $id = $pretext['id']; $subpath = preg_quote(preg_replace("/https?:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/"); $uri = preg_replace("/^{$subpath}/i", "/", serverSet('REQUEST_URI')); #$uri = preg_replace("/^$subpath/i" , "/" , rtrim(serverSet('REQUEST_URI'),'/')); $parts = chopUrl($uri); //echo br , "l10n_lang_list(" , var_dump($atts) , ") Section($section) ID($id)" ; //echo br , 'uri = ' , $uri; //echo br , "parts = " , var_dump( $parts ); $name_mappings = array(); if ($processingcats || $processingauths) { # echo br , 'Processing by category or author : '; $info = safe_rows_start('name,lang,data', 'txp_lang', "`name` IN ('category','author')"); if ($info and mysql_num_rows($info) > 0) { while ($r = nextRow($info)) { $name_mappings[$r['name']][$r['lang']] = urlencode($r['data']); } } # echo var_dump( $name_mappings ) . br ; } if ($on404 or $processing404) { # # Find the section and id of the faulting article (if possible)... # if (empty($id)) { $id = gps('id'); } # Try out a messy match first if (empty($id)) { extract($parts); //echo br , 'permlink_mode = ' , $prefs['permlink_mode']; switch ($prefs['permlink_mode']) { case 'section_id_title': $id = $u1; break; case 'year_month_day_title': $when = "{$u0}-{$u1}-{$u2}"; $rs = safe_row("ID,Section", L10N_MASTER_TEXTPATTERN, "posted like '" . doSlash($when) . "%' and url_title like '" . doSlash($u3) . "' and Status >= 4 limit 1"); $id = !empty($rs['ID']) ? $rs['ID'] : ''; break; case 'section_title': $rs = safe_row("ID,Section", L10N_MASTER_TEXTPATTERN, "url_title like '" . doSlash($u1) . "' AND Section='" . doSlash($u0) . "' and Status >= 4 limit 1"); $id = @$rs['ID']; break; case 'title_only': $rs = safe_row('ID', L10N_MASTER_TEXTPATTERN, "url_title like '" . doSlash($u0) . "' and Status >= 4 limit 1"); $id = @$rs['ID']; break; case 'id_title': $id = $u0; break; } } if (!empty($id) and is_numeric($id)) { $article_list = false; } else { return ''; } # # Make sure we show all alternatives, even if they are in the current language... # $link_current = true; } $show_title = !empty($title); if (!$article_list) { if (!isset($alangs) or !is_array($alangs)) { $alangs = _l10n_get_alternate_mappings($id, 'nothing', true); } //echo br , 'alangs = ' , var_dump( $alangs ); if ($show_title) { $show_title = !empty($alangs); } } if ($show_title) { $title = tag($title, 'p') . n; } else { $title = ''; } foreach ($slangs as $lang) { $codes = MLPLanguageHandler::compact_code($lang); $short = $codes['short']; $long = $codes['long']; $dir = MLPLanguageHandler::get_lang_direction_markup($lang); # # Surpress the current item when needed... # $current = $l10n_language['long'] === $lang; if ($current && $surpress_current) { continue; } switch ($display) { case 'short': $lname = $short; break; case 'long': $lname = $long; break; case 'native+': $lname = MLPLanguageHandler::get_native_name_of_lang($lang) . " [{$short}]"; break; case 'native++': $lname = MLPLanguageHandler::get_native_name_of_lang($lang) . " [{$long}]"; break; default: $lname = MLPLanguageHandler::get_native_name_of_lang($lang); break; } if ($article_list) { # # No individual ID but we should be able to serve all the languages # so use the current url and inject the language component into each one... # $text = tag($lname, 'span', $dir); # # Prep the line class... # $class = 'short' === $language_class ? $short : $lang; if ($current) { $class .= ' ' . $current_class; } $class = ' class="' . $class . '"'; if (!$current or $link_current) { #$subpath = preg_quote(preg_replace("/https?:\/\/.*(\/.*)/Ui","$1",hu),"/"); #$uri = preg_replace("/^$subpath/i" , "/" , serverSet('REQUEST_URI')); if ($processing404) { $uri = ''; } if ($processingcats || $processingauths) { # # Category lists are a special case. For this to work, we need to # replace the local 'category'/'author' string with it's name in the target language. # # Not doing the replace results in 404 errors. # $type = $processingcats ? 'category' : 'author'; $target_name = $name_mappings[$type][$lang]; #echo br . $uri . ' => ' . $lang . ' = ' . $target_name . '(' . urldecode($target_name) . ')'; $chunks = explode('/', ltrim($uri, '/')); $chunks[0] = $target_name; $uri = '/' . join('/', $chunks); } if (!$processing404 && $appendslash && $uri == '') { $uri = '/'; } if ($break == 'option') { $line = $text; $class .= ' value="' . hu . $short . $uri . '"'; } else { $line = '<a href="' . hu . $short . $uri . '">' . $text . '</a>'; } } else { if ($break == 'option') { $class .= ' selected="selected"'; } $line = $text; } $list[] = tag($line, $break, $class); } else { # # If a translation exists for that language then we # build a valid url to it and make it active in the list, otherwise include it in the # list but wihtout the hyper-link. # # The active page is marked up with a css class. # if (array_key_exists($lang, $alangs)) { $record = $alangs[$lang]; $lang_rendition_title = $record['Title']; $lang_rendition_id = $record['ID']; $text = $lname; if ($processing404) { $text = strong($text) . sp . ':' . sp . $lang_rendition_title; } $text = tag($text, 'span', $dir); # # Prep the line class... # $class = 'short' === $language_class ? $short : $lang; if ($current) { $class .= ' ' . $current_class; } $class = ' class="' . $class . '"'; if (!$current or $link_current) { $url = permlinkurl($record); $f = hu; $url = str_replace($f, $f . $short . '/', $url); if ($break == 'option') { $line = $text; $class .= ' value="' . $url . '"'; } else { $line = '<a href="' . $url . '">' . $text . '</a>'; } } else { if ($break == 'option') { $class .= ' selected="selected"'; } $line = $text; } $list[] = tag($line, $break, $class); } else { if ($show_empty) { $list[] = tag($lname, $break); } } } } $selopts = ''; if (!empty($list)) { if ($wraptag == 'select') { $selopts .= ' onchange="location.href=this.options[selectedIndex].value"'; } $list = $title . tag(join("\n\t", $list), $wraptag, " class=\"{$list_class}\"" . $selopts); } else { $list = tag($empty_title, 'p') . n; } return $list; }