Beispiel #1
0
 /**
  * The UI to translate content.
  *
  * @return tempcode		The UI
  */
 function interface_content()
 {
     $title = get_page_title('TRANSLATE_CONTENT');
     if (!multi_lang()) {
         warn_exit(do_lang_tempcode('MULTILANG_OFF'));
     }
     $max = get_param_integer('max', 100);
     $lang = choose_language($title);
     if (is_object($lang)) {
         return $lang;
     }
     // Fiddle around in order to find what we haven't translated. Subqueries and self joins don't work well enough across different db's
     if (!db_has_subqueries($GLOBALS['SITE_DB']->connection_read)) {
         $_done_id_list = collapse_2d_complexity('id', 'text_original', $GLOBALS['SITE_DB']->query_select('translate', array('id', 'text_original'), array('language' => $lang, 'broken' => 0)));
         $done_id_list = '';
         foreach (array_keys($_done_id_list) as $done_id) {
             if ($done_id_list != '') {
                 $done_id_list .= ',';
             }
             $done_id_list .= strval($done_id);
         }
         $and_clause = $done_id_list == '' ? '' : 'AND id NOT IN (' . $done_id_list . ')';
         $query = 'FROM ' . get_table_prefix() . 'translate WHERE ' . db_string_not_equal_to('language', $lang) . ' ' . $and_clause . ' AND ' . db_string_not_equal_to('text_original', '') . ' ORDER BY importance_level';
         $to_translate = $GLOBALS['SITE_DB']->query('SELECT * ' . $query, $max);
     } else {
         $query = 'FROM ' . get_table_prefix() . 'translate a LEFT JOIN ' . get_table_prefix() . 'translate b ON a.id=b.id AND b.broken=0 AND ' . db_string_equal_to('b.language', $lang) . ' WHERE b.id IS NULL AND ' . db_string_not_equal_to('a.language', $lang) . ' AND ' . db_string_not_equal_to('a.text_original', '');
         $to_translate = $GLOBALS['SITE_DB']->query('SELECT a.* ' . $query . (can_arbitrary_groupby() ? ' GROUP BY a.id' : '') . ' ORDER BY a.importance_level', $max);
     }
     $total = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query);
     if (count($to_translate) == 0) {
         inform_exit(do_lang_tempcode('NOTHING_TO_TRANSLATE'));
     }
     require_all_lang($lang, true);
     require_all_open_lang_files($lang);
     // Make our translation page
     require_code('lang2');
     $lines = '';
     $intertrans = $this->get_intertran_conv($lang);
     $actions = make_string_tempcode(' ');
     $last_level = NULL;
     $too_many = count($to_translate) == $max;
     $ids_to_lookup = array();
     foreach ($to_translate as $it) {
         $ids_to_lookup[] = $it['id'];
     }
     $names = find_lang_content_names($ids_to_lookup);
     foreach ($to_translate as $i => $it) {
         if ($it['importance_level'] == 0) {
             continue;
         }
         // Corrupt data
         $id = $it['id'];
         $old = $it['text_original'];
         $current = $this->find_lang_matches($old, $lang);
         $priority = $last_level === $it['importance_level'] ? NULL : do_lang('PRIORITY_' . strval($it['importance_level']));
         $name = $names[$id];
         if (is_null($name)) {
             continue;
         }
         // Orphaned string
         if ($intertrans != '') {
             $actions = do_template('TRANSLATE_ACTION', array('_GUID' => 'f625cf15c9db5e5af30fc772a7f0d5ff', 'LANG_FROM' => $it['language'], 'LANG_TO' => $lang, 'NAME' => 'trans_' . strval($id), 'OLD' => $old));
         }
         $line = do_template('TRANSLATE_LINE_CONTENT', array('_GUID' => '87a0f5298ce9532839f3206cd0e06051', 'NAME' => $name, 'ID' => strval($id), 'OLD' => $old, 'CURRENT' => $current, 'ACTIONS' => $actions, 'PRIORITY' => $priority));
         $lines .= $line->evaluate();
         /*XHTMLXHTML*/
         $last_level = $it['importance_level'];
     }
     $url = build_url(array('page' => '_SELF', 'type' => '_content', 'lang' => $lang), '_SELF');
     require_code('lang2');
     return do_template('TRANSLATE_SCREEN_CONTENT_SCREEN', array('_GUID' => 'af732c5e595816db1c6f025c4b8fa6a2', 'MAX' => integer_format($max), 'TOTAL' => integer_format($total - $max), 'LANG_ORIGINAL_NAME' => get_site_default_lang(), 'LANG_NICE_ORIGINAL_NAME' => lookup_language_full_name(get_site_default_lang()), 'LANG_NICE_NAME' => lookup_language_full_name($lang), 'TOO_MANY' => $too_many, 'INTERTRANS' => $intertrans, 'LANG' => $lang, 'LINES' => $lines, 'TITLE' => $title, 'URL' => $url));
 }
Beispiel #2
0
/**
 * Handle special page type output.
 *
 * @param  ID_TEXT		The special page type.
 * @set    query templates tree lang
 * @param  tempcode		The normal script tempcode output
 * @param  string			The normal script evaluated output
 */
function special_page_types($special_page_type, &$out, $out_evaluated)
{
    global $RECORDED_TEMPLATES_USED;
    if (function_exists('set_time_limit')) {
        @set_time_limit(280);
    }
    $echo = do_header();
    //$echo->evaluate_echo();
    $echo2 = new ocp_tempcode();
    if (is_null($out_evaluated)) {
        ob_start();
        $out->evaluate_echo();
        // False evaluation
        ob_end_clean();
    }
    // HACKHACK: Yuck. we have to after-the-fact make it wide, and empty lots of internal caching to reset the state.
    $_GET['wide_high'] = '1';
    $_GET['wide'] = '1';
    $GLOBALS['LOADED_PANELS'] = array();
    $GLOBALS['IS_WIDE_HIGH'] = 1;
    $GLOBALS['IS_WIDE'] = 1;
    $GLOBALS['TEMPCODE_SETGET'] = array();
    $GLOBALS['LOADED_TPL_CACHE'] = array();
    $GLOBALS['HELPER_PANEL_PIC'] = NULL;
    $GLOBALS['HELPER_PANEL_TEXT'] = NULL;
    $GLOBALS['HELPER_PANEL_TUTORIAL'] = NULL;
    $GLOBALS['HELPER_PANEL_HTML'] = NULL;
    // CSS
    if (substr($special_page_type, -4) == '.css') {
        $url = build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'file' => $special_page_type, 'keep_wide_high' => 1), get_module_zone('admin_themes'));
        header('Location: ' . $url->evaluate());
        exit;
    }
    // Site Tree Editor
    if ($special_page_type == 'site_tree') {
        $url = build_url(array('page' => 'admin_sitetree', 'type' => 'site_tree', 'id' => get_zone_name() . ':' . get_page_name()), get_module_zone('admin_sitetree'));
        header('Location: ' . $url->evaluate());
        exit;
    }
    // IDE linkage
    if ($special_page_type == 'ide_linkage') {
        $title = get_page_title('IDE_LINKAGE');
        $file_links = new ocp_tempcode();
        global $JAVASCRIPTS, $CSSS, $_REQUIRED_CODE, $LANGS_REQUESTED;
        /*foreach (array_keys($JAVASCRIPTS) as $name)	Already in list of templates
        		{
        			$txtmte_url='txmt://open?url=file://'.$name;
        			$file_links->attach(do_template('INDEX_SCREEN_ENTRY',array('URL'=>$txtmte_url,'NAME'=>$name)));
        		}*/
        foreach (array_keys($CSSS) as $name) {
            $search = find_template_place($name, get_site_default_lang(), $GLOBALS['FORUM_DRIVER']->get_theme(), '.css', 'css');
            if (!is_null($search)) {
                list($theme, $type) = $search;
                $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/themes/' . $theme . '/' . $type . '/' . $name . '.css';
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(CSS)', 'URL' => $txtmte_url, 'NAME' => $name . '.css')));
            }
        }
        foreach (array_keys($_REQUIRED_CODE) as $name) {
            $path_a = get_file_base() . '/' . (strpos($name, '.php') === false ? '/sources_custom/' . $name . '.php' : $name);
            $path_b = get_file_base() . '/' . (strpos($name, '.php') === false ? '/sources/' . $name . '.php' : str_replace('_custom', '', $name));
            if (file_exists($path_a)) {
                $txtmte_url = 'txmt://open?url=file://' . $path_a;
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(PHP)', 'URL' => $txtmte_url, 'NAME' => $name . (strpos($name, '.php') === false ? '.php' : ''))));
            }
            if (file_exists($path_b)) {
                $txtmte_url = 'txmt://open?url=file://' . $path_b;
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(PHP)', 'URL' => $txtmte_url, 'NAME' => $name . (strpos($name, '.php') === false ? '.php' : ''))));
            }
        }
        foreach (array_keys($LANGS_REQUESTED) as $name) {
            if (file_exists(get_file_base() . '/lang_custom/' . fallback_lang() . '/' . $name . '.ini')) {
                $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/lang_custom/' . fallback_lang() . '/' . $name . '.ini';
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(Language)', 'URL' => $txtmte_url, 'NAME' => $name . '.ini')));
            }
            if (file_exists(get_file_base() . '/lang/' . fallback_lang() . '/' . $name . '.ini')) {
                $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/lang/' . fallback_lang() . '/' . $name . '.ini';
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(Language)', 'URL' => $txtmte_url, 'NAME' => $name . '.ini')));
            }
        }
        foreach (array_unique($RECORDED_TEMPLATES_USED) as $name) {
            $search = find_template_place($name, get_site_default_lang(), $GLOBALS['FORUM_DRIVER']->get_theme(), '.tpl', 'templates');
            if (!is_null($search)) {
                list($theme, $type) = $search;
                $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/themes/' . $theme . '/' . $type . '/' . $name . '.tpl';
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(Templates)', 'URL' => $txtmte_url, 'NAME' => $name . '.tpl')));
            }
        }
        $echo2 = do_template('INDEX_SCREEN', array('TITLE' => $title, 'CONTENT' => $file_links, 'PRE' => do_lang_tempcode('TXMT_PROTOCOL_EXPLAIN'), 'POST' => ''));
    }
    // Theme images mode
    if ($special_page_type == 'theme_images') {
        $title = get_page_title('THEME_IMAGE_EDITING');
        $theme_images = new ocp_tempcode();
        global $RECORDED_IMG_CODES;
        foreach (array_keys($RECORDED_IMG_CODES) as $theme_image_details) {
            list($id, $theme, $lang) = unserialize($theme_image_details);
            $url = build_url(array('page' => 'admin_themes', 'type' => 'edit_image', 'theme' => is_null($theme) ? $GLOBALS['FORUM_DRIVER']->get_theme() : $theme, 'lang' => $lang, 'id' => $id), 'adminzone');
            $image = find_theme_image($id, false, false, $theme, $lang);
            if ($image == '') {
                continue;
            }
            $theme_images->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('IMG' => $image, 'DESCRIPTION' => '', 'URL' => $url, 'NAME' => $id)));
        }
        $echo2 = do_template('INDEX_SCREEN_FANCIER_SCREEN', array('TITLE' => $title, 'CONTENT' => $theme_images, 'PRE' => do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'), 'POST' => ''));
    }
    // Profile mode?
    if ($special_page_type == 'profile') {
        if (function_exists('xdebug_dump_function_profile')) {
            $type = XDEBUG_PROFILER_FS_SUM;
            xdebug_dump_function_profile($type);
        } else {
            $echo2 = make_string_tempcode('Check out the dump using KCacheGrind.');
        }
    } elseif (substr($special_page_type, 0, 12) == 'lang_content') {
        $map_a = get_file_base() . '/lang/langs.ini';
        $map_b = get_custom_file_base() . '/lang_custom/langs.ini';
        if (!file_exists($map_b)) {
            $map_b = $map_a;
        }
        $map = better_parse_ini_file($map_b);
        $lang_name = user_lang();
        if (array_key_exists($lang_name, $map)) {
            $lang_name = $map[$lang_name];
        }
        global $RECORDED_LANG_STRINGS_CONTENT;
        require_lang('lang');
        require_code('form_templates');
        $fields = new ocp_tempcode();
        require_code('lang2');
        $names = find_lang_content_names(array_keys($RECORDED_LANG_STRINGS_CONTENT));
        foreach ($RECORDED_LANG_STRINGS_CONTENT as $key => $forum_db) {
            $value_found = get_translated_text($key, $forum_db ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']);
            if ($value_found != '') {
                $description = make_string_tempcode(escape_html($value_found));
                if (get_value('google_translate_api_key') === NULL || user_lang() == get_site_default_lang()) {
                    $actions = new ocp_tempcode();
                } else {
                    require_javascript('javascript_translate');
                    $actions = do_template('TRANSLATE_ACTION', array('LANG_FROM' => get_site_default_lang(), 'LANG_TO' => user_lang(), 'NAME' => 'trans_' . strval($key), 'OLD' => $value_found));
                }
                $description->attach($actions);
                $fields->attach(form_input_text(is_null($names[$key]) ? '#' . strval($key) : $names[$key], $description, 'trans_' . strval($key), $value_found, false));
            }
        }
        if ($fields->is_empty()) {
            inform_exit(do_lang_tempcode('NOTHING_TO_TRANSLATE'));
        }
        $title = get_page_title('__TRANSLATE_CONTENT', true, array($lang_name));
        $post_url = build_url(array('page' => 'admin_lang', 'type' => '_content', 'contextual' => 1), 'adminzone');
        $hidden = form_input_hidden('redirect', get_self_url(true, true));
        $hidden = form_input_hidden('lang', user_lang());
        $echo2 = do_template('FORM_SCREEN', array('_GUID' => '0d4dd16b023d0a7960f3eac85f54ddc4', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'), 'SUBMIT_NAME' => do_lang_tempcode('SAVE')));
    } elseif (substr($special_page_type, 0, 4) == 'lang') {
        $map_a = get_file_base() . '/lang/langs.ini';
        $map_b = get_custom_file_base() . '/lang_custom/langs.ini';
        if (!file_exists($map_b)) {
            $map_b = $map_a;
        }
        $map = better_parse_ini_file($map_b);
        $lang_name = user_lang();
        if (array_key_exists($lang_name, $map)) {
            $lang_name = $map[$lang_name];
        }
        global $RECORDED_LANG_STRINGS;
        require_lang('lang');
        require_code('form_templates');
        require_code('lang2');
        $fields = new ocp_tempcode();
        $descriptions = get_lang_file_descriptions(fallback_lang());
        foreach (array_keys($RECORDED_LANG_STRINGS) as $key) {
            $value_found = do_lang($key, NULL, NULL, NULL, NULL, false);
            $description = array_key_exists($key, $descriptions) ? make_string_tempcode($descriptions[$key]) : new ocp_tempcode();
            if (!is_null($value_found)) {
                if (get_value('google_translate_api_key') === NULL || user_lang() == get_site_default_lang()) {
                    $actions = new ocp_tempcode();
                } else {
                    require_javascript('javascript_translate');
                    $actions = do_template('TRANSLATE_ACTION', array('LANG_FROM' => get_site_default_lang(), 'LANG_TO' => user_lang(), 'NAME' => 'l_' . $key, 'OLD' => str_replace('\\n', chr(10), $value_found)));
                }
                $description->attach($actions);
                $fields->attach(form_input_text($key, $description, 'l_' . $key, str_replace('\\n', chr(10), $value_found), false));
            }
        }
        $title = get_page_title('__TRANSLATE_CODE', true, array($lang_name));
        $post_url = build_url(array('page' => 'admin_lang', 'type' => '_code2'), 'adminzone');
        $hidden = form_input_hidden('redirect', get_self_url(true, true));
        $hidden = form_input_hidden('lang', user_lang());
        $echo2 = do_template('FORM_SCREEN', array('_GUID' => '0d4dd16b023d0a7960f3eac85f54ddc4', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'), 'SUBMIT_NAME' => do_lang_tempcode('SAVE')));
    }
    // Template mode?
    if ($special_page_type == 'templates' || $special_page_type == 'tree') {
        require_lang('themes');
        global $RECORD_TEMPLATES_USED;
        $RECORD_TEMPLATES_USED = false;
        $templates = new ocp_tempcode();
        if ($special_page_type == 'templates') {
            $title = get_page_title('TEMPLATES');
            $_RECORDED_TEMPLATES_USED = array_count_values($RECORDED_TEMPLATES_USED);
            ksort($_RECORDED_TEMPLATES_USED);
            foreach ($_RECORDED_TEMPLATES_USED as $name => $count) {
                //$restore_from=find_template_path($name);
                $file = $name . '.tpl';
                $edit_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'f0file' => $file), 'adminzone', NULL, false, true);
                $templates->attach(do_template('TEMPLATE_LIST_ENTRY', array('COUNT' => integer_format($count), 'NAME' => $name, 'EDIT_URL' => $edit_url)));
            }
        } else {
            $title = get_page_title('TEMPLATE_TREE');
            $hidden = new ocp_tempcode();
            global $CSSS, $JAVASCRIPTS;
            foreach (array_keys($CSSS) as $c) {
                $hidden->attach(form_input_hidden('f' . strval(mt_rand(0, 100000)) . 'file', $c . '.css'));
            }
            foreach (array_keys($JAVASCRIPTS) as $c) {
                $hidden->attach(form_input_hidden('f' . strval(mt_rand(0, 100000)) . 'file', strtoupper($c) . '.tpl'));
            }
            $edit_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'preview_url' => get_self_url(true, false, array('special_page_type' => NULL)), 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme()), 'adminzone', NULL, false, true);
            $tree = find_template_tree_nice($out->codename, $out->children, $out->fresh);
            $templates = do_template('TEMPLATE_TREE', array('_GUID' => 'ff2a2233b8b4045ba4d8777595ef64c7', 'HIDDEN' => $hidden, 'EDIT_URL' => $edit_url, 'TREE' => $tree));
        }
        $echo2 = do_template('TEMPLATE_LIST_SCREEN', array('_GUID' => 'ab859f67dcb635fcb4d1747d3c6a2c17', 'TITLE' => $title, 'TEMPLATES' => $templates));
    }
    // Query mode?
    if ($special_page_type == 'query') {
        require_lang("profiling");
        global $QUERY_LIST;
        $queries = new ocp_tempcode();
        $total_time = 0.0;
        global $M_SORT_KEY;
        $M_SORT_KEY = 'time';
        usort($QUERY_LIST, 'multi_sort');
        $QUERY_LIST = array_reverse($QUERY_LIST);
        foreach ($QUERY_LIST as $query) {
            $queries->attach(do_template('QUERY_LOG', array('_GUID' => 'ab88e1e92609136229ad920c30647647', 'TIME' => float_format($query['time'], 3), 'TEXT' => $query['text'])));
            $total_time += $query['time'];
        }
        $title = get_page_title("VIEW_PAGE_QUERIES");
        $total = count($QUERY_LIST);
        $echo2 = do_template('QUERY_SCREEN', array('_GUID' => '5f679c8f657b4e4ae94ae2d0ed4843fa', 'TITLE' => $title, 'TOTAL' => integer_format($total), 'TOTAL_TIME' => float_format($total_time, 3), 'QUERIES' => $queries));
    }
    $echo->attach(globalise($echo2));
    $echo->attach(do_footer());
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
    exit;
}