PageRenderTime 22ms CodeModel.GetById 1ms app.highlight 14ms RepoModel.GetById 2ms app.codeStats 0ms

/upload/faq.php

http://torrentpier2.googlecode.com/
PHP | 110 lines | 83 code | 16 blank | 11 comment | 8 complexity | 8e8f72a9a2ad58037d1b0a042a68d74c MD5 | raw file
  1<?php
  2
  3define('IN_PHPBB', true);
  4define('BB_SCRIPT', 'faq');
  5define('BB_ROOT', './');
  6require(BB_ROOT ."common.php");
  7
  8// Start session management
  9$user->session_start();
 10
 11// Set vars to prevent naughtiness
 12$faq = array();
 13//
 14// Load the appropriate faq file
 15//
 16$mode = request_var('mode', '');
 17if(!empty($mode))
 18{
 19	switch($mode)
 20	{
 21		case 'bbcode':
 22			$lang_file = 'lang_bbcode';
 23			$l_title = $lang['BBCODE_GUIDE'];
 24			break;
 25		default:
 26			$lang_file = 'lang_faq';
 27			$l_title = $lang['FAQ'];
 28			break;
 29	}
 30}
 31else
 32{
 33	$lang_file = 'lang_faq';
 34	$l_title = $lang['FAQ'];
 35}
 36include(LANG_ROOT_DIR ."lang_{$bb_cfg['default_lang']}/$lang_file.php");
 37include(LANG_ROOT_DIR ."lang_{$bb_cfg['default_lang']}/lang_faq_attach.php");
 38
 39//
 40// Pull the array data from the lang pack
 41//
 42$j = 0;
 43$counter = 0;
 44$counter_2 = 0;
 45$faq_block = array();
 46$faq_block_titles = array();
 47
 48for($i = 0; $i < count($faq); $i++)
 49{
 50	if( $faq[$i][0] != '--' )
 51	{
 52		$faq_block[$j][$counter]['id'] = $counter_2;
 53		$faq_block[$j][$counter]['question'] = $faq[$i][0];
 54		$faq_block[$j][$counter]['answer'] = $faq[$i][1];
 55
 56		$counter++;
 57		$counter_2++;
 58	}
 59	else
 60	{
 61		$j = ( $counter != 0 ) ? $j + 1 : 0;
 62
 63		$faq_block_titles[$j] = $faq[$i][1];
 64
 65		$counter = 0;
 66	}
 67}
 68
 69//
 70// Lets build a page ...
 71//
 72$template->assign_vars(array(
 73	'PAGE_TITLE' => $l_title,
 74	'L_FAQ_TITLE' => $l_title,
 75));
 76
 77for($i = 0; $i < count($faq_block); $i++)
 78{
 79	if( count($faq_block[$i]) )
 80	{
 81		$template->assign_block_vars('faq_block', array(
 82			'BLOCK_TITLE' => $faq_block_titles[$i])
 83		);
 84		$template->assign_block_vars('faq_block_link', array(
 85			'BLOCK_TITLE' => $faq_block_titles[$i])
 86		);
 87
 88		for($j = 0; $j < count($faq_block[$i]); $j++)
 89		{
 90			$row_class = !($j % 2) ? 'row1' : 'row2';
 91
 92			$template->assign_block_vars('faq_block.faq_row', array(
 93				'ROW_CLASS' => $row_class,
 94				'FAQ_QUESTION' => $faq_block[$i][$j]['question'],
 95				'FAQ_ANSWER' => $faq_block[$i][$j]['answer'],
 96
 97				'U_FAQ_ID' => $faq_block[$i][$j]['id'])
 98			);
 99
100			$template->assign_block_vars('faq_block_link.faq_row_link', array(
101				'ROW_CLASS' => $row_class,
102				'FAQ_LINK' => $faq_block[$i][$j]['question'],
103
104				'U_FAQ_LINK' => '#' . $faq_block[$i][$j]['id'])
105			);
106		}
107	}
108}
109
110print_page('faq.tpl');