Commit 7427b890 authored by lphuberdeau's avatar lphuberdeau

[ENH] Converting all inclusions for multilinguallib, fixing some notices

parent 5e177cc7
......@@ -17,5 +17,8 @@
<service id="tiki.lib.categ" class="CategLib">
<file>%kernel.root_dir%/lib/categories/categlib.php</file>
</service>
<service id="tiki.lib.multilingual" class="MultilingualLib">
<file>%kernel.root_dir%/lib/multilingual/multilinguallib.php</file>
</service>
</services>
</container>
......@@ -1055,7 +1055,7 @@ class ArtLib extends TikiLib
if (!empty($filter)) {
foreach ($filter as $typeF=>$val) {
if ($typeF == 'translationOrphan') {
global $multilinguallib; include_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
$multilinguallib->sqlTranslationOrphan('article', '`tiki_articles`', 'articleId', $val, $join, $mid, $bindvars);
$mid = ' where '.$mid;
}
......
......@@ -1510,7 +1510,7 @@ class CategLib extends ObjectLib
$this->applyManipulator($manip, $objType, $objId, $desc, $name, $href);
if ( $prefs['category_i18n_sync'] != 'n' && $prefs['feature_multilingual'] == 'y' ) {
global $multilinguallib; require_once 'lib/multilingual/multilinguallib.php';
$multilinguallib = TikiLib::lib('multilingual');
$targetCategories = $this->get_object_categories($objType, $objId, -1, false);
if ( $objType == 'wiki page' ) {
......
......@@ -182,8 +182,7 @@ class Tiki_Profile_InstallHandler_WikiPage extends Tiki_Profile_InstallHandler
TikiLib::lib('geo')->set_coordinates('wiki page', $this->name, $this->geolocation);
}
global $multilinguallib;
require_once 'lib/multilingual/multilinguallib.php';
$multilinguallib = TikiLib::lib('multilingual');
$current = $tikilib->get_page_id_from_name($finalName);
foreach ( $this->translations as $targetName ) {
......
......@@ -48,7 +48,7 @@ class DCSLib extends TikiLib
$info = $this->get_page_info($page);
if ( $prefs['feature_multilingual'] == 'y' ) {
global $multilinguallib; require_once 'lib/multilingual/multilinguallib.php';
$multilinguallib = TikiLib::lib('multilingual');
if ( $lang && $info['lang'] && $lang != $info['lang'] ) {
$bestLangPageId = $multilinguallib->selectLangObj('wiki page', $info['page_id'], $lang);
......
......@@ -1535,9 +1535,7 @@ class FreetagLib extends ObjectLib
*/
function translate_tag( $srcLang, $srcTagId, $dstLang, $content )
{
global $multilinguallib;
if ( !$multilinguallib )
die('Internal error: Multilingual library not imported.');
$multilinguallib = TikiLib::lib('multilingual');
if ( empty( $content ) )
return;
......
......@@ -65,7 +65,9 @@ class GoalEventLib
foreach ($goals as $goal) {
foreach ($goal['conditions'] as $condition) {
$list[] = $condition['eventType'];
if (! empty($condition['eventType'])) {
$list[] = $condition['eventType'];
}
if ($condition['metric'] == 'goal-count-unbounded' || $condition['metric'] == 'goal-count') {
$list[] = 'tiki.goal.reached';
......
......@@ -1153,18 +1153,8 @@ class MultilingualLib extends TikiLib
$callback =
function($match) use ($targ_lang)
{
/* For some reason, we are not able to use $this in the callback, even if we write
use ($this)
in the function header. So instead, we just use the global $multilinguallib, which
is actually the same instance as $this.
*/
global $multilinguallib;
$link_src_page = $match[1];
$link_targ_page = $multilinguallib->getTranslation('wiki page', $link_src_page, $targ_lang);
$link_targ_page = $this->getTranslation('wiki page', $link_src_page, $targ_lang);
if (isset($link_targ_page) && $link_targ_page != '')
{
$anchor_text = "";
......@@ -1254,4 +1244,3 @@ class MultilingualLib extends TikiLib
}
$multilinguallib = new MultilingualLib;
......@@ -51,7 +51,7 @@ class RankLib extends TikiLib
$disableBestLang = false;
if ($res['lang'] > '' && $prefs['feature_best_language'] == 'y') {
// find best language equivalent
global $multilinguallib; include_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
if ($multilinguallib->useBestLanguage()) {
$bestLangPageId = $multilinguallib->selectLangObj('wiki page', $res['page_id'], null, 'tiki_p_view');
if ($res['page_id'] != $bestLangPageId) {
......
......@@ -212,7 +212,7 @@ var syntaxHighlighter = {
$headerlib->add_js($js);
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
$smarty->assign('ie6', true);
......
......@@ -59,4 +59,4 @@ if (!isValidLocale($prefs['language'])) {
setLanguage($prefs['site_language']);
}
TikiLib::lib('multilingual')->setupBiDi();
\ No newline at end of file
TikiLib::lib('multilingual')->setupBiDi();
......@@ -45,7 +45,7 @@ if (strstr($_SERVER['SCRIPT_NAME'], 'tiki-index.php')
&& (isset($_REQUEST['page']) || isset($_REQUEST['page_ref_id']) || isset($_REQUEST['page_id']))
) { // perhaps we have to go to an another page
global $multilinguallib; include_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
if ( $multilinguallib->useBestLanguage()) {
if (empty($_REQUEST['page_id'])) {
......
......@@ -533,7 +533,7 @@ class StructLib extends TikiLib
public function use_user_language_preferences( $langContext = null )
{
global $prefs, $multilinguallib;
global $prefs;
if ( $prefs['feature_multilingual'] != 'y' ) {
return;
}
......@@ -541,9 +541,7 @@ class StructLib extends TikiLib
return;
}
if ( !$multilinguallib ) {
include_once('lib/multilingual/multilinguallib.php');
}
$multilinguallib = TikiLib::lib('multilingual');
$this->displayLanguageOrder = $multilinguallib->preferredLangs($langContext);
}
......
......@@ -144,7 +144,7 @@ class TemplatesLib extends TikiLib
$info = $this->get_page_info($page);
if ( $prefs['feature_multilingual'] == 'y' ) {
global $multilinguallib; require_once 'lib/multilingual/multilinguallib.php';
$multilinguallib = TikiLib::lib('multilingual');
if ( $lang && $info['lang'] && $lang != $info['lang'] ) {
$bestLangPageId = $multilinguallib->selectLangObj('wiki page', $info['page_id'], $lang);
......
......@@ -64,12 +64,10 @@ function loadTikiLibraries()
* Note that most of those global variables will be system variables that have nothing
* to do with Tiki, so we probably can ignore most of them.
*/
global $wikilib, $dbTiki, $smarty, $tikilib, $multilinguallib;
require_once('tiki-setup.php');
include_once('lib/wiki/wikilib.php');
include_once('lib/multilingual/multilinguallib.php');
require_once('lib/tikilib.php');
// print "-- AllTestsAcceptance: \$multilinguallib="; var_dump($multilinguallib); print "\n";
$wikilib = TikiLib::lib('wiki');
$multilinguallib = TikiLib::lib('multilingual');
$tikilib = TikiLib::lib('tiki');
/*
......
......@@ -7,16 +7,15 @@
* To change this template use File | Settings | File Templates.
*/
require_once('lib/multilingual/multilinguallib.php');
class MultilingualLibTest extends TikiTestCase
{
public $orig_user;
protected function setUp()
{
global $tikilib, $_SERVER, $user, $prefs, $multilinguallib;
global $user, $prefs;
$tikilib = TikiLib::lib('tiki');
$multilinguallib = TikiLib::lib('multilingual');
$this->orig_user = $user;
$prefs['site_language'] = 'en';
......@@ -73,8 +72,7 @@ class MultilingualLibTest extends TikiTestCase
*/
public function test_translateLinksInPageContent($src_content, $targ_lang, $exp_translated_content, $message)
{
global $multilinguallib;
$multilinguallib = TikiLib::lib('multilingual');
$got_translated_content = $multilinguallib->translateLinksInPageContent($src_content, $targ_lang);
$this->assertEquals($exp_translated_content, $got_translated_content,
......@@ -111,7 +109,7 @@ class MultilingualLibTest extends TikiTestCase
function test_defaultTargetLanguageForNewTranslation($src_lang, $langs_already_translated,
$user_langs, $exp_lang, $message)
{
global $multilinguallib;
$multilinguallib = TikiLib::lib('multilingual');
$got_lang = $multilinguallib->defaultTargetLanguageForNewTranslation($src_lang, $langs_already_translated, $user_langs);
$this->assertEquals($got_lang, $exp_lang, $message."\nThe default target language was not as expected.");
......@@ -139,7 +137,7 @@ class MultilingualLibTest extends TikiTestCase
*/
function test_partiallyPretranslateContentOfPage($source_page, $targ_lang, $exp_pretranslation, $message)
{
global $multilinguallib;
$multilinguallib = TikiLib::lib('multilingual');
$got_pretranslation = $multilinguallib->partiallyPretranslateContentOfPage($source_page, $targ_lang);
$this->assertEquals($got_pretranslation, $exp_pretranslation, "$message\nSource page was not properly pretranslated.");
......@@ -156,4 +154,4 @@ class MultilingualLibTest extends TikiTestCase
}
}
\ No newline at end of file
}
......@@ -17,8 +17,9 @@ class WikiPlugin_TranslationOfTest extends TikiTestCase
protected function setUp()
{
global $tikilib, $_SERVER, $user, $prefs, $multilinguallib;
global $user, $prefs;
$multilinguallib = TikiLib::lib('multilingual');
$tikilib = TikiLib::lib('tiki');
$this->orig_user = $user;
$prefs['site_language'] = 'en';
......
......@@ -65,9 +65,6 @@ class TikiLib extends TikiDb_Bridge
case 'tiki':
global $tikilib;
return self::$libraries[$name] = $tikilib;
case 'multilingual':
global $multilinguallib; include_once("lib/multilingual/multilinguallib.php");
return self::$libraries[$name] = $multilinguallib;
case 'score':
global $scorelib; include_once("lib/score/scorelib.php");
return self::$libraries[$name] = $scorelib;
......
......@@ -2279,7 +2279,7 @@ class UsersLib extends TikiLib
}
$info = $this->get_page_info($page);
global $multilinguallib; include_once ('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
$bestLangPageId = $multilinguallib->selectLangObj('wiki page', $info['page_id'], $prefs['language']);
if ($info['page_id'] == $bestLangPageId) {
......
......@@ -36,12 +36,10 @@ function wikiplugin_alink_info()
function wikiplugin_alink($data, $params)
{
global $multilinguallib, $tikilib, $prefs;
if ( ! isset( $multilinguallib ) || !is_object($multilinguallib) ) {
include_once('lib/multilingual/multilinguallib.php');// must be done even in feature_multilingual not set
}
extract($params, EXTR_SKIP);
global $prefs;
$multilinguallib = TikiLib::lib('multilingual');
$tikilib = TikiLib::lib('tiki');
extract($params, EXTR_SKIP);
if (!isset($aname)) {
return ("<b>missing parameter for aname</b><br />");
......
......@@ -368,8 +368,7 @@ function wikiplugin_articles($data, $params)
$listpages = $artlib->list_articles($start, $max, $sort, '', $dateStartTS, $dateEndTS, 'admin', $type, $topicId, 'y', $topic, $categIds, '', '', $lang, '', '', ($overrideDates == 'y'), 'y', $filter);
if ($prefs['feature_multilingual'] == 'y' && empty($translationOrphan)) {
global $multilinguallib;
include_once("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
$listpages['data'] = $multilinguallib->selectLangList('article', $listpages['data'], $pageLang);
foreach ($listpages['data'] as &$article) {
$article['translations'] = $multilinguallib->getTranslations('article', $article['articleId'], $article["title"], $article['lang']);
......
......@@ -259,8 +259,7 @@ function wikiplugin_listpages($data, $params)
$filter['structHead'] = $structHead;
}
if (!empty($translations) && $prefs['feature_multilingual'] == 'y') {
global $multilinguallib;
require_once 'lib/multilingual/multilinguallib.php';
$multilinguallib = TikiLib::lib('multilingual');
if ($translations == 'user') {
$translations = $multilinguallib->preferredLangs();
} else {
......
......@@ -50,7 +50,7 @@ class EditLib
function user_needs_to_specify_language_of_page_to_be_created($page, $page_info, $new_page_inherited_attributes = null)
{
global $_REQUEST, $multilinguallib, $prefs, $tikilib;
global $prefs;
if (isset($_REQUEST['need_lang']) && $_REQUEST['need_lang'] == 'n') {
return false;
}
......@@ -680,7 +680,7 @@ class EditLib
function saveCompleteTranslation()
{
global $multilinguallib, $tikilib;
$multilinguallib = TikiLib::lib('multilingual');
$sourceInfo = $tikilib->get_page_info($this->sourcePageName);
$targetInfo = $tikilib->get_page_info($this->targetPageName);
......@@ -697,7 +697,7 @@ class EditLib
function savePartialTranslation()
{
global $multilinguallib, $tikilib;
$multilinguallib = TikiLib::lib('multilingual');
$sourceInfo = $tikilib->get_page_info($this->sourcePageName);
$targetInfo = $tikilib->get_page_info($this->targetPageName);
......
......@@ -337,7 +337,7 @@ class SemanticLib
function onlyKeepAliasesFromPageInLanguage($language, $aliases)
{
global $multilinguallib;
$multilinguallib = TikiLib::lib('multilingual');
if (!$language) {
return $aliases;
}
......
......@@ -46,7 +46,7 @@ function module_terminology($mod_reference, $module_params)
$smarty = TikiLib::lib('smarty');
init_from_parameters($module_params);
global $multilinguallib; include_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
$search_terms_in_lang = $multilinguallib->currentTermSearchLanguage();
$smarty->assign('search_terms_in_lang', $search_terms_in_lang);
......
......@@ -72,8 +72,7 @@ function module_translation($mod_reference, $module_params)
if (! empty($page) && is_string($page)) {
global $multilinguallib;
include_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
if (isset($module_params['show_language']) && $module_params['show_language'] == 'n') {
$smarty->assign('show_language', 'n');
......
......@@ -11,12 +11,13 @@
global $prefs;
require 'tiki-setup.php';
include_once('lib/multilingual/multilinguallib.php');
include_once('lib/wiki/wikilib.php');
include_once('lib/wiki/renderlib.php');
$access->check_feature(array('feature_multilingual', 'feature_multilingual_one_page'));
$multilinguallib = TikiLib::lib('multilingual');
$wikilib = TikiLib::lib('wiki');
if ( !isset($_REQUEST['page']) ) {
header('Location: tiki-index.php');
die;
......
......@@ -12,7 +12,7 @@ include_once('tiki-setup.php');
include_once('lib/tikilib.php');
include_once('lib/wiki/wikilib.php');
include_once 'lib/wiki/semanticlib.php';
include_once ('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
$access->check_feature(array( 'feature_wiki', 'feature_multilingual' ));
$access->check_permission('tiki_p_edit');
......@@ -23,7 +23,7 @@ display();
function create_pages_if_necessary()
{
global $smarty, $_REQUEST;
$smarty = TikiLib::lib('smarty');
$template_name = null;
if (isset($_REQUEST['template_name'])) {
$template_name = $_REQUEST['template_name'];
......@@ -51,8 +51,9 @@ function create_pages_if_necessary()
*/
function create_page($page_name, $lang, $template_name=null)
{
global $tikilib, $multilinguallib, $user;
global $user;
$multilinguallib = TikiLib::lib('multilingual');
$tikilib = TikiLib::lib('tiki');
$content = '';
if ($template_name != null) {
$template_id = $multilinguallib->getTemplateIDInLanguage('wiki', $template_name, $lang);
......@@ -67,7 +68,8 @@ function create_page($page_name, $lang, $template_name=null)
*/
function make_pages_translations_of_each_other($pages)
{
global $tikilib, $multilinguallib;
$multilinguallib = TikiLib::lib('multilingual');
$tikilib = TikiLib::lib('tiki');
if (count($pages) == 0) return;
$first_page_id = null;
foreach ($pages as $this_page_lang => $this_page_name) {
......@@ -87,7 +89,9 @@ function make_pages_translations_of_each_other($pages)
*/
function compute_relevant_languages()
{
global $multilinguallib, $smarty, $_REQUEST, $prefs;
global $prefs;
$multilinguallib = TikiLib::lib('multilingual');
$smarty = TikiLib::lib('smarty');
$all_languages_with_country_codes = $prefs['available_languages'];
$all_languages = strip_country_code_from_lang_ids($all_languages_with_country_codes);
......@@ -112,7 +116,6 @@ function compute_relevant_languages()
*/
function get_pages_to_create()
{
global $_REQUEST;
$pages_to_create = array();
foreach ($_REQUEST as $arg_name => $arg_val) {
if (preg_match('/page_name_([\s\S]*)/', $arg_name, $matches)) {
......@@ -132,7 +135,8 @@ function get_pages_to_create()
*/
function check_for_existence_of_pages($pages_to_create)
{
global $tikilib, $semanticlib;
$tikilib = TikiLib::lib('tiki');
$semantic = TikiLib::lib('semantic');
$non_existant_pages = array();
$existing_pages = array();
......@@ -162,7 +166,8 @@ function check_for_existence_of_pages($pages_to_create)
*/
function set_smarty_page_links($page_names)
{
global $wikilib, $smarty;
$smarty = TikiLib::lib('smarty');
$wikilib = TikiLib::lib('wiki');
$page_links = array();
foreach ($page_names as $a_page_name) {
......@@ -176,7 +181,7 @@ function set_smarty_page_links($page_names)
function display()
{
global $smarty;
$smarty = TikiLib::lib('smarty');
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
$smarty->assign('mid', 'tiki-create_multilang_pages.tpl');
......
......@@ -579,7 +579,7 @@ if (isset($_REQUEST['save']) && empty($errors)) {
&& isset($_REQUEST['lang'])
&& $article_data['lang'] != $_REQUEST['lang']
) {
include_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
if ($multilinguallib->updateObjectLang('article', $article_data['articleId'], $_REQUEST['lang'], true)) {
$_REQUEST['lang'] = $article_data['lang'];
$smarty->assign('msg', tra("The language can't be changed as its set of translations has already this language"));
......@@ -653,7 +653,7 @@ if (isset($_REQUEST['save']) && empty($errors)) {
$translatedArticle = $artlib->get_article($translationOf);
// Quietly fail if translated article does not exist.
if (!empty($translatedArticle) && $translatedArticle['lang'] && $_REQUEST['lang'] != $translatedArticle['lang']) {
include_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
$multilinguallib->insertTranslation('article', $translatedArticle['articleId'], $translatedArticle['lang'], $artid, $_REQUEST["lang"]);
}
}
......@@ -740,7 +740,7 @@ if ($prefs['feature_multilingual'] == 'y') {
$smarty->assign_by_ref('languages', $languages);
// get translations
if ($articleId) {
include_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
$translations = $multilinguallib->getTranslations('article', $articleId);
} else {
$translations = array();
......
......@@ -10,7 +10,7 @@
require_once('tiki-setup.php');
include_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
include_once('modules/mod-func-translation.php');
require_once('lib/debug/Tracer.php');
......@@ -138,7 +138,9 @@ function execute_module_translation()
function smarty_assign_default_target_lang($src_lang, $targ_lang_requested, $existing_translations, $user_langs)
{
global $multilinguallib, $smarty, $tracer;
global $tracer;
$multilinguallib = TikiLib::lib('multilingual');
$smarty = TikiLib::lib('smarty');
$default_target_lang = $targ_lang_requested;
if (! isset($default_target_lang))
......@@ -164,4 +166,4 @@ function smarty_assign_translation_name()
$translation_name = $_REQUEST['translation_name'];
}
$smarty->assign('translation_name', $translation_name);
}
\ No newline at end of file
}
......@@ -78,9 +78,7 @@ function guess_new_page_attributes_from_parent_pages($page, $page_info)
*/
function translationsToThisPageAreInProgress($page_id)
{
global $multilinguallib;
include_once("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
$translations_in_progress = $multilinguallib->getTranslationsInProgressFlags($page_id);
$answer = count($translations_in_progress) > 0;
......@@ -109,7 +107,10 @@ function execute_module_translation()
function possibly_set_pagedata_to_pretranslation_of_source_page()
{
global $smarty, $multilinguallib, $editlib, $tracer;
global $tracer;
$multilinguallib = TikiLib::lib('multilingual');
$smarty = TikiLib::lib('smarty');
$editlib = TikiLib::lib('edit');
if ($editlib->isNewTranslationMode())
{
......@@ -124,7 +125,7 @@ $access->check_feature('feature_wiki');
if ($editlib->isNewTranslationMode() || $editlib->isUpdateTranslationMode()) {
$translation_mode = 'y';
include_once("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
} else {
$translation_mode = 'n';
}
......@@ -447,7 +448,7 @@ if (isset($_FILES['userfile1']) && is_uploaded_file($_FILES['userfile1']['tmp_na
if ($prefs['feature_multilingual'] === 'y') {
$info = $tikilib->get_page_info($pagename);
if ($info['lang'] !== $pageLang) {
include_once("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
if ($multilinguallib->updateObjectLang('wiki page', $info['page_id'], $pageLang, true)) {
$pageLang = $info['lang'];
$smarty->assign('msg', tra("The language can't be changed as its set of translations has already this language"));
......@@ -465,7 +466,7 @@ if (isset($_FILES['userfile1']) && is_uploaded_file($_FILES['userfile1']['tmp_na
// Handle the translation bits after actual creation/update
// This path is never used by minor updates
if ($prefs['feature_multilingual'] === 'y') {
include_once("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
$tikilib->cache_page_info = array();
if ( $editlib->isNewTranslationMode() ) {
......@@ -667,7 +668,7 @@ if ((isset($_REQUEST["template_name"]) || isset($_REQUEST["templateId"])) && !is
if (isset($_REQUEST["templateId"])) {
$templateId = $_REQUEST["templateId"];
} else {
include_once ('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
$templateId = $multilinguallib->getTemplateIDInLanguage('wiki', $_REQUEST["template_name"], $templateLang);
}
$template_data = $templateslib->get_template($templateId, $templateLang);
......@@ -859,7 +860,7 @@ if ($prefs['wiki_comments_allow_per_page'] !== 'n') {
}
if (isset($_REQUEST["lang"])) {
if ($prefs['feature_multilingual'] === 'y' && isset($info["lang"]) && $info['lang'] !== $_REQUEST["lang"]) {
include_once("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
if ($multilinguallib->updateObjectLang('wiki page', $info['page_id'], $_REQUEST["lang"], true)) {
$pageLang = $info['lang'];
$smarty->assign('msg', tra("The language can't be changed as its set of translations has already this language"));
......@@ -1140,7 +1141,7 @@ if (
$info_new = $tikilib->get_page_info($page);
if ($editlib->isNewTranslationMode() && ! empty( $pageLang)) {
include_once("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
$infoSource = $tikilib->get_page_info($editlib->sourcePageName);
$infoCurrent = $tikilib->get_page_info($editlib->targetPageName);
if ($multilinguallib->insertTranslation('wiki page', $infoSource['page_id'], $infoSource['lang'], $infoCurrent['page_id'], $pageLang)) {
......@@ -1152,7 +1153,7 @@ if (
}
if ($prefs['feature_multilingual'] === 'y') {
include_once("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
$tikilib->cache_page_info = array();
if ( $editlib->isNewTranslationMode() ) {
......@@ -1214,7 +1215,7 @@ if (
// Handle translation bits
if ($prefs['feature_multilingual'] === 'y' && !$minor) {
global $multilinguallib; include_once("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
$tikilib->cache_page_info = array();
if ($editlib->isUpdateTranslationMode()) {
......@@ -1404,7 +1405,7 @@ if ($prefs['feature_multilingual'] === 'y') {
die;
}
global $multilinguallib; include_once("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
$sourceInfo = $tikilib->get_page_info($editlib->sourcePageName);
if ($multilinguallib->getTranslation('wiki page', $sourceInfo['page_id'], $_REQUEST['lang'])) {
// Display an error if the page already exists
......@@ -1502,7 +1503,7 @@ if ( ! empty($prefs['geo_locate_wiki']) && $prefs['geo_locate_wiki'] == 'y' ) {
}
if ( $prefs['feature_multilingual'] === 'y' ) {
global $multilinguallib; include_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
$trads = $multilinguallib->getTranslations('wiki page', $info['page_id'], $page, $info['lang']);
$smarty->assign('trads', $trads);
}
......
......@@ -24,7 +24,7 @@ if ($cat_type != 'wiki page' && $cat_type != 'article') {
}
include_once "lib/freetag/freetaglib.php";
include_once "lib/multilingual/multilinguallib.php";
$multilinguallib = TikiLib::lib('multilingual');
if ( $cat_objId ) {
$info = $tikilib->get_page_info($cat_objId);
......
......@@ -42,14 +42,14 @@ $section = 'wiki page';
$isHomePage = (!isset($_REQUEST['page']));
require_once('tiki-setup.php');
require_once('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
if ( $prefs['feature_wiki_structure'] == 'y' ) {
include_once('lib/structures/structlib.php');
$structlib = TikiLib::lib('struct');
}
include_once('lib/wiki/wikilib.php');
include_once('lib/stats/statslib.php');
$wikilib = TikiLib::lib('wiki');
$statslib = TikiLib::lib('stats');
require_once ('lib/wiki/renderlib.php');
require_once('lib/debug/Tracer.php');
......
......@@ -56,8 +56,7 @@ if (isset($_REQUEST['mapview'])
}
if ($prefs['feature_multilingual'] == 'y' && isset($_REQUEST['lang']) && isset($_REQUEST['term_srch'])) {
global $multilinguallib;
include_once ('lib/multilingual/multilinguallib.php');
$multilinguallib = TikiLib::lib('multilingual');
if (isset($_REQUEST['term_srch'])) {
$multilinguallib->storeCurrentTermSearchLanguageInSession($_REQUEST['lang']);
}
......@@ -475,8 +474,10 @@ if (!empty($multiprint_pages)) {
*/
function setLangFilter($filter)
{
global $smarty, $prefs, $multilinguallib;
include_once ('lib/multilingual/multilinguallib.php');
global $prefs;
$multilinguallib = TikiLib::lib('multilingual');
$smarty = TikiLib::lib('smarty');
$lang = $multilinguallib->currentPageSearchLanguage();
if (isset($_REQUEST['listonly']) && $prefs['feature_jquery_autocomplete'] == 'y' && strlen($lang) > 2) {
$lang = substr($lang, 0, 2); // for autocomplete - use only language filter, not culture as well
......
......@@ -341,7 +341,7 @@ if (isset($preview)) {
$smarty->assign('current', 0);
}
if ($prefs['feature_multilingual'] == 'y' && isset($_REQUEST['show_translation_history'])) {
include_once ("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
$smarty->assign('show_translation_history', 1);
$sources = $multilinguallib->getSourceHistory($info['page_id']);
$targets = $multilinguallib->getTargetHistory($info['page_id']);
......@@ -362,7 +362,7 @@ if (!isset($newver)) {
$newver = 0;
}
if ($prefs['feature_multilingual'] == 'y') {
include_once ("lib/multilingual/multilinguallib.php");
$multilinguallib = TikiLib::lib('multilingual');
$languages = $tikilib->list_languages();
$smarty->assign_by_ref('languages', $languages);
if (isset($_REQUEST["update_translation"])) {
......
......@@ -339,7 +339,8 @@ class ObjectRenderer_MultilingualWiki extends ObjectRenderer // {{{
function __construct($type, $object, $options = array())
{
parent::__construct($type, $object, $options);