<?php
/**
*
* @package ppkBB3cker
* @version $Id: posting_add2.php 1.000 2009-03-25 12:02:00 PPK $
* @copyright (c) 2009 PPK
* http://ppkbb3cker.rx22.ru, http://protoneutron.narod.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

		function build_addfields($l, $k, $v, $c)
		{
			$b_fields='';

			if(intval($c))
			{
				for($i=1;$i<=$c;$i++)
				{
					$b_fields ? $b_fields.='<br />' : '';
					$b_fields.=sprintf($l, $k.$i, $v);
					$b_fields.=build_hlp_addfields($k, $i);
				}
			}
			else
			{
				$b_fields=sprintf($l, $k, $v);
				$b_fields.=build_hlp_addfields($k);
			}

			return $b_fields;
		}

		function build_hlp_addfields($k, $c='')
		{
			global $user;

			$forum_addfields='';

			if(is_array(@$user->lang['TRACKER_FORUM_ADDFIELDS_HLP'][$k]))
			{
				$forum_addfields.='<br />'.$user->lang['TRACKER_ADDFIELDS_EXAMPLE'].': <select name="ins_'.$k.$c.'" onchange="this.form.'.$k.$c.'.value=this.form.ins_'.$k.$c.'.value;"><option value="" selected="selected"></option>';
				foreach($user->lang['TRACKER_FORUM_ADDFIELDS_HLP'][$k] as $k2=>$v2)
				{
					$user->lang['TRACKER_FORUM_ADDFIELDS_HLP'][$k][$k2]=htmlspecialchars($user->lang['TRACKER_FORUM_ADDFIELDS_HLP'][$k][$k2]);
					$forum_addfields.='<option value="'.$user->lang['TRACKER_FORUM_ADDFIELDS_HLP'][$k][$k2].'">'.$user->lang['TRACKER_FORUM_ADDFIELDS_HLP'][$k][$k2].'</option>';
				}
				$forum_addfields.='</select>';
			}
			else if(@$user->lang['TRACKER_FORUM_ADDFIELDS_HLP'][$k])
			{
				$forum_addfields.='<br />'.$user->lang['TRACKER_ADDFIELDS_EXAMPLE'].': ' .$user->lang['TRACKER_FORUM_ADDFIELDS_HLP'][$k];
			}

			return $forum_addfields;
		}

		$forum_addfields='';
		foreach($array_addfields as $k)
		{
			$v='';
			$c=intval(@$user->lang['TRACKER_FORUM_ADDFIELDS_COUNT'][$k]);
			if(@$user->lang['TRACKER_FORUM_ADDFIELDS_FIELDS'][$k])
			{
				$template->assign_block_vars('addfields_option', array(
				'ADDFIELDS_DESCR'=>$k,
				'ADDFIELDS_NAME'=>$user->lang['TRACKER_FORUM_ADDFIELDS'][$k],
				'ADDFIELDS_VALUE'=>build_addfields($user->lang['TRACKER_FORUM_ADDFIELDS_FIELDS'][$k], $k, $v, $c),
					)
				);
				$forum_addfields=1;
			}
			else if(@$user->lang['TRACKER_FORUM_ADDFIELDS_TA'][$k])
			{
				$template->assign_block_vars('addfields_option', array(
				'ADDFIELDS_DESCR'=>$k,
				'ADDFIELDS_NAME'=>$user->lang['TRACKER_FORUM_ADDFIELDS'][$k],
				'ADDFIELDS_VALUE'=>build_addfields($user->lang['TRACKER_FORUM_ADDFIELDS_TEXTAREA'], $k, $v, $c),
					)
				);
				$forum_addfields=1;
			}
			else if(@$user->lang['TRACKER_FORUM_ADDFIELDS'][$k])
			{
				$template->assign_block_vars('addfields_option', array(
				'ADDFIELDS_DESCR'=>$k,
				'ADDFIELDS_NAME'=>$user->lang['TRACKER_FORUM_ADDFIELDS'][$k],
				'ADDFIELDS_VALUE'=>build_addfields($user->lang['TRACKER_FORUM_ADDFIELDS_TEXT'], $k, $v, $c),
					)
				);
				$forum_addfields=1;
			}

		}

		if($forum_addfields)
		{
			$template->assign_vars(array(
				'FORUM_ADDFIELDS'=>$forum_addfields
				)
			);
		}

?>