MyBB Community Forums

Full Version: How does the board read variables
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How does the board read variables and whatever they have(content) is displayed in a textarea?
This is in the languages
whene you create a new variable in the php files, let's say the variable name is $var
you will need to add it like that {$var} in the templates..
but you must be sure that the variable is in a function that runs the pre_output_page hook
U got the question wrong
I mean when editing the language from the admin panel how does it make very variable into textareas?
in admin/languages.php
		$plugins->run_hooks("admin_languages_edit_edit");

		// Start output
		cpheader();
		startform("languages.php", "edit", "do_edit");

		// Check if file is writable, before allowing submission
		if(!is_writable($editfile))
		{
			$lang->update_button = '';
			makewarning($lang->note_cannot_write);
		}

		starttable();
		if($editwithfile)
		{
			// Editing with another file
			$lang->editing_file_in_set_with = sprintf($lang->editing_file_in_set_with, $file, $languages[$editlang], $languages[$editwith]);
			tableheader($lang->editing_file_in_set_with, "", 1);
			//tablesubheader(array($lang->variable, $languages[$editlang], $languages[$editwith]));
			if(count($editvars) == 0)
			{
				makelabelcode("<div align=\"center\">".$lang->no_variables."</div>", "", 1);
			}
			else
			{
				// Make each editing row
				foreach($editvars as $key => $value)
				{
					if(strtolower($langinfo['charset']) == "utf-8")
					{
						$withvars[$key] = preg_replace("#%u([0-9A-F]{1,4})#ie", "dec_to_utf8(hexdec('$1'));", $withvars[$key]);
						$value = preg_replace("#%u([0-9A-F]{1,4})#ie", "dec_to_utf8(hexdec('$1'));", $value);
					}
					else
					{
						$withvars[$key] = preg_replace("#%u([0-9A-F]{1,4})#ie", "dec_to_utf8(hexdec('$1'));", $withvars[$key]);
						$value = preg_replace("#%u([0-9A-F]{1,4})#ie", "'&#'.hexdec('$1').';'", $value);
					}	
					tablesubheader($key, "", 1);
					echo "<tr>\n";
					echo "<td class=\"altbg1\"><strong>".$languages[$editwith]."</strong><br /><textarea style=\"width: 98%; padding: 4px;\" rows=\"2\" disabled=\"disabled\">".htmlspecialchars($withvars[$key])."</textarea></td>\n";
					echo "</tr>";
					echo "<tr>\n";
					echo "<td class=\"altbg1\"><strong>".$languages[$editlang]."</strong><br /><textarea style=\"width: 98%; padding: 4px;\" rows=\"2\" name=\"edit[$key]\">".htmlspecialchars($value)."</textarea></td>\n";
					echo "</tr>";
				}
			}
		}
		else
		{
			// Editing individually
			$lang->editing_file_in_set = sprintf($lang->editing_file_in_set, $file, $languages[$editlang]);
			tableheader($lang->editing_file_in_set, "", 1);
			if(count($editvars) == 0)
			{
				makelabelcode("<div align=\"center\">".$lang->no_variables."</div>", "", 1);
			}
			else
			{
				// Make each editing row
				foreach($editvars as $key => $value)
				{
					if(strtolower($langinfo['charset']) == "utf-8")
					{
						$value = preg_replace("#%u([0-9A-F]{1,4})#ie", "dec_to_utf8(hexdec('$1'));", $value);
					}
					else
					{
						$value = preg_replace("#%u([0-9A-F]{1,4})#ie", "'&#'.hexdec('$1').';'", $value);
					}
					tablesubheader($key, "", 1);
					echo "<tr>\n";
					echo "<td class=\"altbg1\"><textarea style=\"width: 98%; padding: 4px;\" rows=\"2\" name=\"edit[$key]\">".htmlspecialchars($value)."</textarea></td>\n";
					echo "</tr>";
				}
			}
I see.
Thank you!