MyBB Community Forums

Full Version: [resolved] Language files are going strange :S
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ok, for some reason some of my lang variables show and others dont. I am adding to my plugin and the new language variables come up as blank Confused


i have $lang->userbar_leftdetail

linked to my language file and in that $l['userbar_leftdetail']
Code please?
here: http://gfx-core.com/community/usercp.php
test account:
username:test
password:test123

plugin file:
<?php
/**
Author: Tommy
Plugin name: Forum Userbar Plugin 
Version: 2.1
Website: GFX-Core.com
*/

//define no direct access
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
//These will be used later
$plugins->add_hook("usercp_menu", "userbarplugin");

//plugin info
function userbarplugin_info()
{
global $lang;
$lang->load("userbar"); 
return array(
   "name"    => $lang->userbar_pluginname,
   "description" => $lang->userbar_description,
   "website"  => "http://gfx-core.com",
   "author"  => "Tommy",
   "authorsite"  => "http://gfx-core.com",
   "version"  => "2.2",
   "compatibility" => "14*",
   "guid" => "3cdd57b02c41495574f5409e1728307e"
   );
}

//Activate code
function userbarplugin_activate()
{
	global $db, $lang;

//remove old verisons of userbar
if(mysql_num_rows(mysql_query("SELECT userid FROM ".TABLE_PREFIX."settinggroups WHERE gid = '999'")))
{
	$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE gid = '999'");
} 

//add table columns for personalised userbar
$db->query("ALTER TABLE `".TABLE_PREFIX."users` ADD `setting1` VARCHAR( 20 ) NOT NULL DEFAULT '1' AFTER `language` , ADD `setting2` VARCHAR( 20 ) NOT NULL DEFAULT '2' AFTER `setting1` , ADD `setting3` VARCHAR( 20 ) NOT NULL DEFAULT '3' AFTER `setting2` , ADD `userbarimage` VARCHAR( 10 ) NOT NULL DEFAULT '1' AFTER `setting3` ;");

//continue install
$lang->load("userbar"); 
	  
	  $group = array(
        "gid"            => "998",
        "title"          => $lang->userbar_setting_group_name,
        "name"           => "forum_userbar",
        "description"    => $lang->userbar_setting_group_description,
        "disporder"      => "1",
        "isdefault"      => "0",
    );
	      $db->insert_query("settinggroups", $group);
    $gid = $db->insert_id();
	
//This setting turns the usebar on and off	
$set_userbar = array(
		"name" => "set_userbar",
		"title" => $lang->userbar_set_userbar_title,
		"description" => $lang->userbar_set_userbar_description,
		"optionscode" => "yesno",
		"value" => "1",
		"disporder" => "1",
		"gid" => intval($gid),
		);
	$db->insert_query("settings", $set_userbar);
	
	
//use referral link instead of forum link
$set_userbar_referral = array(
		"name" => "set_userbar_referral",
		"title" => $lang->userbar_set_referral_title,
		"description" => $lang->userbar_set_referral_description,
		"optionscode" => "yesno",
		"value" => "0",
		"disporder" => "1",
		"gid" => intval($gid),
		);
	$db->insert_query("settings", $set_userbar_referral);
	
//set cache on/off
$set_userbar_cache = array(
		"name" => "set_userbar_cache",
		"title" => $lang->userbar_set_cache_title,
		"description" => $lang->userbar_set_cache_description,
		"optionscode" => "yesno",
		"value" => "0",
		"disporder" => "3",
		"gid" => intval($gid),
		);
	$db->insert_query("settings", $set_userbar_cache);
	
//set cache url
$set_userbar_cache_url = array(
		"name" => "set_userbar_cache_url",
		"title" => $lang->userbar_set_cache_url_title,
		"description" => $lang->userbar_set_cache_url_description,
		"optionscode" => "text",
		"value" => "cache/userbars/",
		"disporder" => "4",
		"gid" => intval($gid),
		);
	$db->insert_query("settings", $set_userbar_cache_url);

//set cache time
$set_userbar_cache_time = array(
		"name" => "set_userbar_cache_time",
		"title" => $lang->userbar_set_cache_time_title,
		"description" => $lang->userbar_set_cache_time_description,
		"optionscode" => "text",
		"value" => "3",
		"disporder" => "5",
		"gid" => intval($gid),
		);
	$db->insert_query("settings", $set_userbar_cache_time);

//chmod folder
chmod("/cache/userbars", 0777);
//This setting allows editing of background image
$userbarsetting_1 = array(
		"name" => "choose_image_userbar",
		"title" => $lang->userbar_userbarsetting_1_title,
		"description" => $lang->userbar_userbarsetting_1_description,
		"optionscode" => "text",
		"value" => "1",
		"disporder" => "2",
		"gid" => intval($gid),
		);
	$db->insert_query("settings", $userbarsetting_1);

// Thes are statsig setings
	  
	  $statsig_group = array(
        "gid"            => "997",
        "title"          => $lang->userbar_statsig_setting_group_name,
        "name"           => "forum_statsig",
        "description"    => $lang->userbar_statsig_setting_group_description,
        "disporder"      => "1",
        "isdefault"      => "0",
    );
	      $db->insert_query("settinggroups", $statsig_group);
    $gid = $db->insert_id();
	
//This setting turns the statsig on and off	
$set_userbar_statsig = array(
		"name" => "set_statsig_userbar",
		"title" => $lang->userbar_statsig_set_statsig_title,
		"description" => $lang->userbar_statsig_set_statsig_description,
		"optionscode" => "yesno",
		"value" => "1",
		"disporder" => "1",
		"gid" => "997",
		);
	$db->insert_query("settings", $set_userbar_statsig);
	
//set cache on/off (statsig)
$set_statsig_userbar_cache = array(
		"name" => "set_statsig_userbar_cache",
		"title" => $lang->userbar_statsig_set_cache_title,
		"description" => $lang->userbar_statsig_set_cache_description,
		"optionscode" => "yesno",
		"value" => "0",
		"disporder" => "3",
		"gid" => "997",
		);
	$db->insert_query("settings", $set_statsig_userbar_cache);
	
//set cache url (statsig)
$set_statsig_userbar_cache_url = array(
		"name" => "set_statsig_userbar_cache_url",
		"title" => $lang->userbar_set_cache_url_title,
		"description" => $lang->userbar_set_cache_url_description,
		"optionscode" => "text",
		"value" => "cache/userbars/",
		"disporder" => "4",
		"gid" => "997",
		);
	$db->insert_query("settings", $set_statsig_userbar_cache_url);

//set cache time (statsig)
$set_statsig_userbar_cache_time = array(
		"name" => "set_statsig_userbar_cache_time",
		"title" => $lang->userbar_statsig_set_cache_time_title,
		"description" => $lang->userbar_statsig_set_cache_time_description,
		"optionscode" => "text",
		"value" => "3",
		"disporder" => "5",
		"gid" => "997",
		);
	$db->insert_query("settings", $set_statsig_userbar_cache_time);

//This setting allows editing of background image (statsig)
$set_statsig_image = array(
		"name" => "choose_statsig_image_userbar",
		"title" => $lang->set_statsig_image_title,
		"description" => $lang->set_statsig_image_description,
		"optionscode" => "text",
		"value" => "1",
		"disporder" => "2",
		"gid" => "997",
		);
	$db->insert_query("settings", $set_statsig_image);

rebuildsettings();

	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
	find_replace_templatesets("usercp", '#'.preg_quote('{$latest_warnings}').'#', '{\$latest_warnings}{\$userbarplugin}');
}

//de-activate plugin
function userbarplugin_deactivate()
{
	global $db;
	$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name IN ('forum_userbar','forum_statsig')");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('set_userbar','choose_image_userbar','set_userbar_referral','set_userbar_cache_time','set_userbar_cache_url','set_userbar_cache','set_statsig_userbar','choose_statsig_image_userbar','set_statsig_userbar_cache_time','set_statsig_userbar_cache_url','set_statsig_userbar_cache')");
	$db->query("ALTER TABLE `".TABLE_PREFIX."users` DROP `setting1`, DROP `setting2`, DROP `setting3`, DROP `userbarimage`;");

	rebuild_settings();
	//delete old files
	$dir = ($mybb->settings['set_userbar_cache_url']);
	foreach(glob($dir.'*.png') as $v){
	unlink($v);
	}
	
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
	find_replace_templatesets("usercp", '#'.preg_quote('{$userbarplugin}').'#' , '',0);
}

function userbarplugin()
{
	
	global $mybb, $theme, $userbarplugin, $lang, $db;
	$lang->load("userbar");	
		if($mybb->settings['set_userbar_referral'] == "0")
	{		
$userbarplugin = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"tborder\">
<tr>
<td class=\"thead\">
<div class=\"theadleft\"></div>
<div class=\"theadright\"></div>
<div class=\"theadmain\"><strong>$lang->userbar_userbartitle:</strong></div>
</td>
</tr>
</table>
<table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\">
<tr>
<td class=\"trow1\" width=\"40%\"><strong>$lang->userbar_userbarimage:</strong></td>
<td class=\"trow1\" width=\"60%\"><img src=\"{$mybb->settings['bburl']}/userbar.php?uid={$mybb->user['uid']}\"</a></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\"><strong>$lang->userbar_bbcode:</strong>
<br></br>
$lang->userbar_bbcodetext</td>
<td class=\"trow1\" width=\"60%\"><textarea name=\"bbcode\" cols=\"60\" rows=\"3\" readonly=\"readonly\" id=\"bbcode\">[URL={$mybb->settings['bburl']}][IMG]{$mybb->settings['bburl']}/userbar.php?uid={$mybb->user['uid']}[/IMG][/URL]</textarea></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\"><strong>$lang->userbar_html:</strong>
<br></br>
$lang->userbar_htmltext</td>
<td class=\"trow1\" width=\"60%\"><textarea name=\"bbcode\" cols=\"60\" rows=\"3\" readonly=\"readonly\" id=\"html\"><a href=\"{$mybb->settings['bburl']}\"><img src=\"{$mybb->settings['bburl']}/userbar.php?uid={$mybb->user['uid']}\"/></a></textarea></td>
</tr>
</table>
</br>
<form id=\"form1\" name=\"form1\" method=\"post\" action=\"userbarsettings.php\">
<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"tborder\">
<tr>
<td class=\"thead\">
<div class=\"theadleft\"></div>
<div class=\"theadright\"></div>
<div class=\"theadmain\"><strong>Userbar Settings:</strong></div>
</td>
</tr>
</table>
<table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\">
<tr>
<td class=\"trow1\" width=\"40%\">$lang->userbar_leftdetail:</td>
<td class=\"trow1\" width=\"60%\">  <select name=\"setting1\" id=\"setting1\">
    <option value=\"1\" selected=\"selected\">Username</option>
    <option value=\"2\">Posts</option>
    <option value=\"3\">Usergroup</option>
  </select></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\">$lang->userbar_centerdetail:</td>
<td class=\"trow1\" width=\"60%\"> <select name=\"setting2\" id=\"setting2\">
    <option value=\"1\">Username</option>
    <option value=\"2\">Posts</option>
    <option value=\"3\" selected=\"selected\">Usergroup</option>
  </select></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\">$lang->userbar_rightdetail:</td>
<td class=\"trow1\" width=\"60%\">  <select name=\"setting3\" id=\"setting3\">
    <option value=\"1\">Username</option>
    <option value=\"2\" selected=\"selected\">Posts</option>
    <option value=\"3\">Usergroup</option>
  </select></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\">$lang->userbar_imageselect:</td>
<td class=\"trow1\" width=\"60%\">  <input name=\"image2\" type=\"text\" id=\"image2\" value=\"{$mybb->user['userbarimage']}\" /></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\"></td>
<td class=\"trow1\" width=\"60%\"><input name=\"uid\" type=\"hidden\" id=\"uid\" value=\"{$mybb->user['uid']}\" /><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Submit\" /></td>
</tr>
</table>
</form>";
	}
	else 
	{
	$userbarplugin = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"tborder\">
<tr>
<td class=\"thead\">
<div class=\"theadleft\"></div>
<div class=\"theadright\"></div>
<div class=\"theadmain\"><strong>$lang->userbar_userbartitle:</strong></div>
</td>
</tr>
</table>
<table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\">
<tr>
<td class=\"trow1\" width=\"40%\"><strong>$lang->userbar_userbarimage:</strong></td>
<td class=\"trow1\" width=\"60%\"><img src=\"{$mybb->settings['bburl']}/userbar.php?uid={$mybb->user['uid']}\"</a></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\"><strong>$lang->userbar_bbcode:</strong>
<br></br>
$lang->userbar_bbcodetext</td>
<td class=\"trow1\" width=\"60%\"><textarea name=\"bbcode\" cols=\"60\" rows=\"3\" readonly=\"readonly\" id=\"bbcode\">[URL={$mybb->settings['bburl']}/index.php?referrer={$mybb->user['uid']}][IMG]{$mybb->settings['bburl']}/userbar.php?uid={$mybb->user['uid']}[/IMG][/URL]</textarea></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\"><strong>$lang->userbar_html:</strong>
<br></br>
$lang->userbar_htmltext</td>
<td class=\"trow1\" width=\"60%\"><textarea name=\"bbcode\" cols=\"60\" rows=\"3\" readonly=\"readonly\" id=\"html\"><a href=\"{$mybb->settings['bburl']}/index.php?referrer={$mybb->user['uid']}\"><img src=\"{$mybb->settings['bburl']}/userbar.php?uid={$mybb->user['uid']}\"/></a></textarea></td>
</tr>
</table>
</br>
<form id=\"form1\" name=\"form1\" method=\"post\" action=\"userbarsettings.php\">
<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"tborder\">
<tr>
<td class=\"thead\">
<div class=\"theadleft\"></div>
<div class=\"theadright\"></div>
<div class=\"theadmain\"><strong>Userbar Settings:</strong></div>
</td>
</tr>
</table>
<table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\">
<tr>
<td class=\"trow1\" width=\"40%\">$lang->userbar_leftdetail:</td>
<td class=\"trow1\" width=\"60%\">  <select name=\"setting1\" id=\"setting1\">
    <option value=\"1\" selected=\"selected\">Username</option>
    <option value=\"2\">Posts</option>
    <option value=\"3\">Usergroup</option>
  </select></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\">$lang->userbar_centerdetail:</td>
<td class=\"trow1\" width=\"60%\"> <select name=\"setting2\" id=\"setting2\">
    <option value=\"1\">Username</option>
    <option value=\"2\">Posts</option>
    <option value=\"3\" selected=\"selected\">Usergroup</option>
  </select></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\">$lang->userbar_rightdetail:</td>
<td class=\"trow1\" width=\"60%\">  <select name=\"setting3\" id=\"setting3\">
    <option value=\"1\">Username</option>
    <option value=\"2\" selected=\"selected\">Posts</option>
    <option value=\"3\">Usergroup</option>
  </select></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\">$lang->userbar_imageselect:</td>
<td class=\"trow1\" width=\"60%\">  <input name=\"image2\" type=\"text\" id=\"image2\" value=\"{$mybb->user['userbarimage']}\" /></td>
</tr>
<tr>
<td class=\"trow1\" width=\"40%\"></td>
<td class=\"trow1\" width=\"60%\"><input name=\"uid\" type=\"hidden\" id=\"uid\" value=\"{$mybb->user['uid']}\" /><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Submit\" /></td>
</tr>
</table>
</form>";
	}
}
?>

lang file:
<?php
// Forum Userbar Plugin by Tommy - Language file for v2.1:

//DONT EDIT THIS!
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// Edit values below :)(dont add any ":"s on the end!)
// " and ' signs need to be escaped if they are in the text for example:
// "the man\'s cat said \"hello\""

//Admin CP

//info:
//Plugin name:
$l['userbar_pluginname'] = "Forum Userbar Plugin";
//Description
$l['userbar_description'] = "What was once a simple plugin, is now a complex board userbar script. It allows the user to display a userbar containing different information on the board. It now includes a cache that reduces the scripts resource usage, and everything can be changed in the Admin CP. It now includes a board wide stat-sig that displays the total number of posts, members and threads! Have fun!";

//Settings
//Settings group title:
$l['userbar_settings_group_title'] = "Userbar";
//Setting group name:
$l['userbar_setting_group_name'] = "Userbar";
//Settign gorup description:
$l['userbar_setting_group_description'] = "Settings for the userbar plugin.";
//set userbar title:
$l['userbar_set_userbar_title'] = "Userbar";
//set userbar desc.
$l['userbar_set_userbar_description'] = "Enable Userbar? (Disabling will make all displayed userbars blank)";
//set referral title:
$l['userbar_set_referral_title'] = "Referral Link";
//set referral description
$l['userbar_set_referral_description'] = "Use the referral link when click on userbar image (instead of forum link)";
//userbar setting1 title:
$l['userbar_userbarsetting_1_title'] = "Choose Userbar Image";
//userbar setting1 desc.:
$l['userbar_userbarsetting_1_description'] = "This can be used to change the Userbar image. Simply change the number in this box to any number, and upload an image to the ./images/userbar folder. The ID is the name of the image. So \"1.png\" is represented as \"1\"";
//cache on/off title
$l['userbar_set_cache_title'] = "Cache On?";
//cache on/off desc.
$l['userbar_set_cache_description'] = "Turn the cache on/off (You may only need to turn the cache on if you notice it is using a lot of resources. For smaller boards with not many people viewing the script it will probably not be needed.";
//cache url title
$l['userbar_set_cache_url_title'] = "Set Cache URL";
//cache url desc.
$l['userbar_set_cache_url_description'] = "This allows you to set a cache URL (note: it must be a folder on the webserver that is CHMOD 777), no slash is needed at the start but MAKE SURE YOU LEAVE THE TRAILING SLASH! Also NEVER set this as you mybb image folder as deactivating the plugin will delete ALL png files in the folder.";
//cache time title
$l['userbar_set_cache_time_title'] = "Set Cache Time";
//cache time desc.
$l['userbar_set_cache_time_description'] = "Put the number of MINUTES before the userbar will be allowed to regenrate, longer time means less stress on your server. Shorter times mean more stress on the server if the image is accessed regularly.";

//Statsig lang.
//Setting group name:
$l['userbar_statsig_setting_group_name'] = "Statsig";
//Settign gorup description:
$l['userbar_statsig_setting_group_description'] = "Settings for the Statsig plugin.";
//statsig on/off title
$l['userbar_statsig_set_statsig_title'] = "Statsig On?";
//statsig on/off desc.
$l['userbar_statsig_set_statsig_description'] = "Turn the statsig on/off";
//userbar setting1 title:
$l['set_statsig_image_title'] = "Choose Statsig Image";
//userbar setting1 desc:
$l['set_statsig_image_description'] = "This can be used to change the Statsig image. (Note it uses the same images as the userbar plugin.) Simply change the number in this box to any number, and upload an image to the ./images/userbar folder. The ID is the name of the image. So \"1.png\" is represented as \"1\"";
//cache on/off title
$l['userbar_statsig_set_cache_title'] = "Cache On?";
//cache on/off desc.
$l['userbar_statsig_set_cache_description'] = "Turn the cache on/off (You may only need to turn the cache on if you notice it is using a lot of resources. For smaller boards with not many people viewing the script it will probably not be needed.";
//cache url title
$l['userbar_statsig_set_cache_url_title'] = "Set Cache URL";
//cache url desc.
$l['userbar_statsig_set_cache_url_description'] = "This allows you to set a cache URL (note: it must be a folder on the webserver that is CHMOD 777), no slash is needed at the start but MAKE SURE YOU LEAVE THE TRAILING SLASH! Also NEVER set this as you mybb image folder as deactivating the plugin will delete ALL png files in the folder.";
//cache time title
$l['userbar_statsig_set_cache_time_title'] = "Set Cache Time";
//cache time desc.
$l['userbar_statsig_set_cache_time_description'] = "Put the number of MINUTES before the statsig will be allowed to regenrate, longer time means less stress on your server. Shorter times mean more stress on the server if the image is accessed regularly.";

//userbar settings left
$l['userbar_leftdetail'] = "HTML";
//userbar settings center
$l['userbar_centerdetail'] = "HTML";
//userbar settings right
$l['userbar_rightdetail'] = "HTML";
//userbar settings imageselect
$l['userbar_imageselect'] = "Image Select";

//User CP
// Profile edit title:
$l['userbar_userbartitle'] = "Userbar URL";
// Userbar image title:
$l['userbar_userbarimage'] = "Here is your Userbar";
// BBCODE title:
$l['userbar_bbcode'] = "BBCODE";
//BBCODE text:
$l['userbar_bbcodetext'] = "This can be used on forums/bulletin boards (If it doesnt work try the HTML code below)";
//HTML title:
$l['userbar_html'] = "HTML";
//HTML text:
$l['userbar_htmltext'] = "This can be used on websites that allow html (If it doesnt work try the BBCODE code above)";
?>

The template changes are in the userbarplugin() function
Which vars do not show exactly? By the way, put $lang->userbar_userbarimage:{$lang->userbar_userbarimage}
Have you looked in the userCP? The ones for the dropdowns

adding {} doesnt change it Confused
(2010-04-28, 09:37 PM)tommykent1210 Wrote: [ -> ]Have you looked in the userCP? The ones for the dropdowns

adding {} doesnt change it Confused

the brackets are not supposed to fix it.

Use the hook "usercp_start" instead of the one you're using.
Then in your userbarplugin() function check (after the globals part) if $mybb->input['action'] == ''

If it's not, return; so you don't run useless code on each page of the user panel.

I can't see anything causing that problem though, so you may want to check if the language file in your server is the one you posted here.
Found the problem, the lang file was in both the languages folder AND the languages/admin folder, and the plugin was taking variables from the languages folder not languages/admin Smile



SOLVED

Thanks anyway Pirata Smile