From 892620f635ce205f36aa40fa6d8860f6032ab3d7 Mon Sep 17 00:00:00 2001 From: Christian Helbling Date: Thu, 12 Feb 2015 17:09:24 +0100 Subject: make sure links to text-editor (using debug param texts) point to lib for labels defined in lib --- it_text.class | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/it_text.class b/it_text.class index e45b7d4..1ff7a51 100644 --- a/it_text.class +++ b/it_text.class @@ -24,6 +24,7 @@ class it_text var $languages = array(); # Active languages var $languages_available = array(); # Available languages var $statictext = array(); # Text array, read from php file on init + var $label_to_service = array(); # which label belongs to which service - only used for debug parameter texts /** * Constructor @@ -55,7 +56,14 @@ function it_text($p = array()) { $oldtext = $this->statictext; if (is_array($ret = include($phpfile))) + { $this->statictext += $ret; + if ($GLOBALS['debug_texts']) + { + $service = strpos($phpfile, $GLOBALS['ULTRAHOME']) !== false ? '' : it::match('/www/([^/.]+)', $phpfile); + $this->label_to_service += array_combine(array_keys($ret), array_fill(0, count($ret), $service)); + } + } else $this->statictext = $oldtext + $this->statictext; # FIXME: compatibility mode } @@ -125,7 +133,7 @@ static function init() * INTERNAL function for T(): : Return translated text in the selected language */ function text($label, $language = null) -{ +{ if (!$language) $language = $this->actlanguage; @@ -141,7 +149,13 @@ function text($label, $language = null) } if ($GLOBALS['debug_texts'] && !preg_match('/submit|button|servicedomain/i', $label) && (!$_GET['it_texts_mark'] || $label == $_GET['it_texts_mark'])) - $text = "1, 'skipfiles'=>"text|auto_prepend")) . ")'>" . ($text ? $text : $label) . "."; + { + $host = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . preg_replace('/\.texts/', '', $_SERVER['HTTP_HOST']); + if ($service = $this->label_to_service[$label]) + $host = preg_replace('#//(admin\.)?[^.]*\.#', "//$service.", $host); + + $text = "1, 'skipfiles'=>"text|auto_prepend")) . ")'>" . ($text ? $text : $label) . "."; + } if (isset($GLOBALS['it_text_sampling'])) $GLOBALS['it_text_sampling'][$label] = true; -- cgit v1.2.3