Control Panel D6 not working in other languages

sobkowiak - September 10, 2008 - 21:23
Project:Control Panel
Version:6.x-1.0-beta2
Component:User interface
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

I've installed 6.x-1.0-beta2 on D6.4 it seems to be working only when default language is set to English. I'm looking into this problem now and will post findings.
Please verify this problem if you have it. Please post any helpful info.

#1

NaX - October 13, 2008 - 15:46

I have the i18n module installed and only the default icon was being used.

This is my fix for D5.x. I dont know about D6.x.

<?php
function theme_controlpanel_panel_view($pid, $block = NULL) {
 
$content = '';
 
$menu = menu_get_menu();
 
$menu_visible = $menu['visible'];
 
$theme_path = path_to_theme() . '/controlpanel/' . variable_get('controlpanel_icon_size' . $block, '48x48');

  if (
file_exists($theme_path . '/control_panel_default.png')) {
   
$image_directory = $theme_path;
  } else {
   
$image_directory = drupal_get_path('module', 'controlpanel') . '/images/' . variable_get('controlpanel_icon_size' . $block, '48x48');
  }

 
$content .= '<div id="control-panel-' . $pid . '" class="control-panel">';
  if (isset(
$menu_visible[$pid]) && $menu_visible[$pid]['children']) {
    foreach (
$menu_visible[$pid]['children'] as $mid) {
      if (
$menu_visible[$mid]['children'] && (variable_get('controlpanel_build_children' . $block, 0) != 0)) {
       
//do nothing
     
}
      else {
       
$content .= '<div class="control-panel-item control-panel-icon-size-' . variable_get('controlpanel_icon_size' . $block, '48x48') . '">';
       
$content .= '<a href="' . url($menu_visible[$mid]['path']) . '">';
       
$working_path = drupal_get_path_alias($menu_visible[$mid]['path']);
        if (
module_exists('i18n')) {
          global
$i18n_langpath;
         
$current_lang = is_null($i18n_langpath) ? i18n_default_language() : $i18n_langpath;
         
$working_path_parts = explode('/', $working_path);
          if (
$working_path_parts[0] == $current_lang) {
            unset(
$working_path_parts[0]);
          }
         
$working_path = implode('/', $working_path_parts);
        }
        if (
is_numeric(substr($working_path, strrpos($working_path, "/") + 1))) {
         
$working_path = substr($working_path, 0, strrpos($working_path, "/"));
        }
       
$file_name = $image_directory . '/' . str_replace('/', '_', $working_path) . '.png';
       
//drupal_set_message($file_name);
       
if (file_exists($file_name)) {
         
$src = $file_name;
        }
        else {
         
$src = $image_directory . '/control_panel_default.png';
        }
       
$content .= '<span style="display:block;">';
       
$content .= '<img src="' . base_path() . $src . '" alt="'. $menu_visible[$mid]['title'] .'" title="'. $menu_visible[$mid]['title'] .'" />';
       
$content .= '<br />' . $menu_visible[$mid]['title'];
       
$content .= '</span>';
       
$content .= '</a>';
       
$content .= '</div>';
      }
    }
  }
 
$content .= '</div>';
  return
$content;
}
?>

 
 

Drupal is a registered trademark of Dries Buytaert.