<?php
/*---------------------------------------------\
|											   |
| @Author:       Andrey Brykin (Drunya)        |
| @Version:      1.5.3                         |
| @Project:      CMS                           |
| @package       CMS Fapos                     |
| @subpackege    mods Module               |
| @copyright     ©Andrey Brykin 2010-2011      |
| @last mod      2011/12/12                    |
|----------------------------------------------|
|											   |
| any partial or not partial extension         |
| CMS Fapos,without the consent of the         |
| author, is illegal                           |
|----------------------------------------------|
| Любое распространение                        |
| CMS Fapos или ее частей,                     |
| без согласия автора, является не законным    |
\---------------------------------------------*/




Class modsModule extends Module {
	/**
	* @template  layout for module
	*/
	public $template = 'mods';
	/**
	* @module_title  title of module
	*/
	public $module_title = 'Проекты';
	/**
	* @module module indentifier
	*/
	public $module = 'mods';

	
	/**
	* default action ( show main page )
	*/
	function index() {
		$this->ACL->turn(array('mods', 'view_list'));
		if ($this->cached && $this->Cache->check($this->cacheKey)) {
			$html = $this->Cache->read($this->cacheKey);
		} else {
		
		
			//Узнаем кол-во материалов в БД
			$total = $this->DB->select('mods', DB_COUNT);
			$cntPages = ceil( $total / Config::read('per_page', 'mods') );
			if ( isset($_GET['page']) ) {
				$page = (int)$_GET['page'];
				if ( $page < 1 ) $page = 1;
			} else {
				$page = 1;
			}
			if ( $page > $cntPages ) $page = $cntPages;
			$pages = ($cntPages > 1) ? pagination($page, $cntPages, '/mods/') : '&nbsp;';
			
			
			//navigation panel
			$navi = array();
			$navi['{ADD_LINK}'] = ($this->ACL->turn(array('mods', 'add_materials'), false)) ? 
				get_link(__('Add material'), '/mods/add_form/') : '';
			$navi['{PAGINATION}'] = $pages;
			$navi['{META}'] = __('Count all material') . $total;
			$this->_globalize($navi);
			
			if ($total == 0) {
				$html = __('Materials not found');
				return $this->_view($html);
			}
			

			$html = '';
			// get data 
			$sql = $this->DB->select('mods', DB_ALL, array(
				array(
					'table' => 'games',
					'type' => 'LEFT',
					'alias' => 'b',
						'cond' => 'a.`title` = b.`game_title`',
				),
				'joins' => array(
					array(
						'table' => 'users',
						'type' => 'LEFT',
						'alias' => 'd',
						'cond' => 'd.`id` = a.`author_id`',
					),
				),
				'fields' => array('`a`.*', 'd.`name` AS author', 'd.`status` AS author_status'),
				'alias' => 'a',
				'order' => getOrderParam(__CLASS__),
				'page' => $page,
				'limit' => Config::read('per_page', 'mods'),
			));
			
			// get ids list
			$ids = array();
			foreach ($sql as $result) {
				$ids[] = $result['id'];
			}
			$ids = implode(', ', $ids);
			
			//ITERATION RECORDS
			foreach ($sql as $result) {
				$markets = array();
				$result = $this->Parser->quoteTags($result);
				$_SESSION['current_vars'] = $result;
				$htmlmods = $this->Parser->getAndParse('tablemat.html');

				
				$rec_attaches = array();
				if (!empty($attaches) && count($attaches) > 0) {
					foreach ($attaches as $k => $attach) {
						if ($attach['entity_id'] == $result['id']) {
							$rec_attaches[] = $attach;
							unset($attaches[$k]);
						}
					}
				}

				$markets['{MODER_PANEL}'] = $this->_getAdminBar($result);
				$entry_url = get_url(entryUrl($result, $this->module));
				$markets['{ENTRY_URL}'] = $entry_url;

				
				$announce = $this->Parser->unquoteTags($result['desc']);
				$announce = $this->Textarier->getAnnounce($announce, $entry_url, 0, 
					Config::read('announce_lenght', 'mods'), $result);
				$markets['{ANNOUNCE}'] = $this->Parser->quoteTags($announce);
				
				if($result['icon']=='1') {$iconid = $result['id'];} else {$iconid = 'none';};
				$markets['{ICONM}'] = '<img src="/sys/files/mods/' . $iconid . '.jpg">';
				$markets['{GAME_URL}'] = get_url('/games/' . $result['game_title']);
				foreach ($result as $key=>$value) {
					$markets['{'.strtoupper($key).'}'] = h($value);  
				}
				$html .= $this->_replaceMarkets($markets, $htmlmods);

				//prepear cache tags
				$this->setCacheTag(array(
					'user_id_' . $result['author_id'],
					'record_id_' . $result['id'],
				));
			}
	
			$materials_tpl = $this->Parser->getAndParse('materials_container.html');
			$markets = array(
				'{MATERIALS}' => $html,
			);
			$html = $this->_replaceMarkets($markets, $materials_tpl);

			if ($this->cached)
				$this->Cache->write($html, $this->cacheKey, $this->cacheTags);
		}
		return $this->_view($html);
	}























	/**
	 * show page with load info
	 * @ page title
	 * @ categories
	 *
	 * @param int $id
	 */
	function view ($id = null) {
		//turn access
		$id = intval($id);
		if (empty($id) || $id < 1) redirect('/');

		// извлекаем из БД информацию материала
		$sql = $this->DB->select('mods', DB_FIRST, array(
			'joins' => array(
				array(
					'table' => 'users',
					'type' => 'LEFT',
					'alias' => 'd',
					'cond' => 'd.`id` = a.`author_id`',
				),
			),
			'fields' => array('a.*', 'd.`name` AS author', 'd.`status` AS author_status'),
			'alias' => 'a',
			'cond' => array('`a`.`id`' => $id),
		));
		//if no record - redirect ( info message )
		if (count($sql) < 1) return showInfoMessage(__('Some error occurred'), '/mods/');
					$result = $this->Parser->quoteTags($sql[0]);
		//  в другом случае извлекаем шаблон отображения материала
		$html = $this->Parser->getAndParse('vievmat.html');
		
		//если админ, выводим админбар
		$markets = array();
		
		$text_load = $this->Parser->unquoteTags($result['desc']);
		// replace image tags in text
		if (!empty($attaches) && count($attaches) > 0) {
			$attachDir = R . 'sys/files/' . $this->module . '/';
			foreach ($attaches as $attach) {
				if ($attach['is_image'] == 1 && file_exists($attachDir . $attach['filename'])) {
					$text_load = str_replace('{IMAGE'.$attach['attach_number'].'}'
					, '[img]' . get_url('/sys/files/'.$this->module.'/'.$attach['filename']).'[/img]'
					, $text_load);
				}
			}
		}
		$text_load = $this->Textarier->print_page($text_load, $result['title']);
		$markets['{MAIN_TEXT}'] = $this->Parser->quoteTags($text_load);
		
		foreach ($result as $key=>$value) {
		   $markets['{'.strtoupper($key).'}'] = h($value);
		}
		
		$markets['{PROFILE_URL}'] = getProfileUrl($result['author_id']);

		$markets['{FILES_URL}'] = '<a href="/loads/category/'.$result['id_l'].'">файлы</a>';

		$html = $this->_replaceMarkets($markets, $html);

		$this->page_title = $this->page_title . ' - ' . h($result['title']);
		if (!empty($result['desc'])) $this->page_meta_description = h($result['desc']);
	
		/* COMMENT BLOCK */
			$this->comments  = $this->_add_comment_form($id);
			$this->comments  = $this->_get_comments($result) . $this->comments;

		//prepear cache tags
		$this->setCacheTag(array(
			'user_id_' . $result['author_id'],
			'record_id_' . $result['id'],
		));
		
		return $this->_view($html);
	}

























	/**
	 *
	 */
	public function add_form () {
		//turn access
		$this->ACL->turn(array('mods', 'add_materials'));
	
		$html = $this->Parser->getAndParse('addform.html' );
		$markets = array();

		// Если при заполнении формы были допущены ошибки
		if (isset( $_SESSION['FpsForm'])) {
			$info           = $this->Parser->getAndParse('infomessage.html' );
			$info           = str_replace( '{INFO_MESSAGE}', $_SESSION['FpsForm']['error'], $info );
			$html           = $info . $html . "\n";
			$title    	    = h($_SESSION['FpsForm']['title']);
			$game    	    = h($_SESSION['FpsForm']['game']);
			$description 	= h($_SESSION['FpsForm']['description']);
			$platforms 		= h($_SESSION['FpsForm']['platforms']);
			unset( $_SESSION['FpsForm'] );
		}

		// список игр
		$sql = $this->DB->select('games', DB_ALL);
		$game_change = $this->_buildSelector($sql, ((!empty($game)) ? $game : false));

		// список платформ
		$array_platforms = $this->DB->select('platforms', DB_ALL);
		$platforms_change = $this->_buildSelectorM($array_platforms);

		$markets['{ACTION}'] 		= get_url('/mods/add/');
		$markets['{TITLE}'] 		= (!empty($title)) ? $title : '';
		$markets['{GAME_SELECTOR}'] = $game_change;
		$markets['{DESCRIPTION}']	= (!empty($description)) ? $description : '';
		$markets['{PLATFORMS_SELECTOR}'] = $platforms_change;
		$html = $this->_replaceMarkets($markets, $html);
		
		
		//navigation panel

		return $this->_view($html);
	}






	/**
	 * 
	 * Validate data and create a new record into 
	 * Data Base. If an errors, redirect user to add form
	 * and show error message where speaks as not to admit 
	 * errors in the future
	 * 
	 */
	public function add() {
		$this->ACL->turn(array('mods', 'add_materials'));
		
		if (!isset($_POST['description']) || !isset($_POST['title'])) {
			redirect('/');
		}

		$error  = '';
		
		// Обрезаем переменные до длины, указанной в параметре maxlength тега input
		$title  = trim(mb_substr($_POST['title'], 0, 128));
		$description   = trim($_POST['description']);
		$platforms = $_POST['platforms'];
		$game    = intval($_POST['game']);

		$valobj = new Validate;  //validation data class
		if (empty($title))                      
			$error = $error . '<li>' . __('Empty field "title"') . '</li>' . "\n";
		elseif (!$valobj->cha_val($title, V_TITLE)) 
			$error = $error . '<li>' . __('Wrong chars in "title"') . '</li>' ."\n";	

		$sqlt = $this->DB->select('mods', DB_FIRST, array('cond' => array('title' => $title)));
		if (!empty($sqlt)) $error = $error . __('Такой мод уже есть')."\n";

		$sqlg = $this->DB->select('games', DB_FIRST, array('cond' => array('title' => $title)));
		if (!empty($sqlg)) $error = $error . __('Название мода не должно соответствовать названию игры. Смените заголовок.')."\n";

		$sql = $this->DB->select('games', DB_FIRST, array('cond' => array('id' => $game)));
		if (empty($sql)) $error = $error . __('Не найдена игра')."\n";

		if (mb_strlen($description) > Config::read('max_lenght', 'mods')) 
			$error = $error .'<li>'. sprintf(__('Wery big "material"'), Config::read('max_lenght', 'mods')) .'</li>'."\n";
		if (mb_strlen($description) < Config::read('min_lenght', 'mods')) 
			$error = $error .'<li>'. sprintf(__('Wery small "material"'), Config::read('min_lenght', 'mods')) .'</li>'."\n";

		if (empty($platforms) && !$valobj->cha_val($platforms, V_TITLE)) 
			$error = $error. '<li>' . __('Не выбрана платформа') . '</li>' ."\n";

		// Errors
		if (!empty($error)) {
			$_SESSION['FpsForm'] = array_merge(array('title' => null, 'description' => null, 'platforms' => null), $_POST);
			$_SESSION['FpsForm']['error'] = '<p class="errorMsg">' . __('Some error in form') . '</p>'.
				"\n".'<ul class="errorMsg">'."\n".$error.'</ul>'."\n";
			redirect('/mods/add_form/');
		}

		// Защита от того, чтобы один пользователь не добавил
		// 100 материалов за одну минуту
		if ( isset( $_SESSION['unix_last_post'] ) and ( time()-$_SESSION['unix_last_post'] < 10 ) ) {
			return showInfoMessage(__('Your message has been added'), '/mods/');
		}

		/* проверка файла */
		if (!empty($_FILES['icon']['name']))
		{
			if ($_FILES['icon']['size'] > Config::read('max_icon_size', 'mods')) 
				$error = $error .'<li>'. sprintf(__('Wery big file2'), Config::read('max_icon_size', 'mods')/1000) .'</li>'."\n";
			if ($_FILES['icon']['type'] != 'image/jpeg' &&
			$_FILES['icon']['type'] != 'image/gif' &&
			$_FILES['icon']['type'] != 'image/png') 
				$error = $error .'<li>'.__('Wrong file format').'</li>'."\n";
		}

		$platforms = implode(", ", $platforms);

		//remove cache
		$this->Cache->clean(CACHE_MATCHING_ANY_TAG, array('module_mods'));
		$this->DB->cleanSqlCache();
		// Формируем SQL-запрос на добавление темы	
		$this->DB->save('news_sections', array(
			'parent_id'	   => '',
			'announce'  => $description,
			'title'        => $title,
			'view_on_home'    => '1',
		));
		$id_n = mysql_insert_id();
		$this->DB->save('stat_sections', array(
			'parent_id'	   => '',
			'announce'  => $description,
			'title'        => $title,
			'view_on_home'    => '1',
		));
		$id_s = mysql_insert_id();
		$this->DB->save('loads_sections', array(
			'parent_id'	   => '',
			'announce'  => $description,
			'title'        => $title,
			'view_on_home'    => '1',
		));
		$id_l = mysql_insert_id();
		$this->DB->save('mods', array(
			'title'        => $title,
			'desc'  => $description,
			'author_id'    => $_SESSION['user']['id'],
			'platforms'    => $platforms,
			'game'    => $game,
			'id_n'    => $id_n,
			'id_s'    => $id_s,
			'id_l'    => $id_l,
		));
		$id = mysql_insert_id();
		
		/* сохранение файла */
		if (!empty($_FILES['icon']['name']))
		{
			//$ext = strchr($_FILES['icon']['name'], '.');
			$save_path = R . 'sys/files/mods/' . $id . '.jpg';
		
			$sbsry = $this->DB->save('mods', array('id' => $id, 'icon' => '1'));

			if (!move_uploaded_file($_FILES['icon']['tmp_name'], $save_path)) $error_flag = true;
			if (!chmod($save_path, 0644)) $error_flag = true; 

			$resample = resampleImage($save_path, $save_path, 120);
		}

		//clean cache
		$this->Cache->clean(CACHE_MATCHING_TAG, array('module_' . $this->module));
		$this->DB->cleanSqlCache();
		if ($this->Log) $this->Log->write('adding mod', 'mod id(' . $id . ')');
		return showInfoMessage(__('Material successful added'), '/mods/');			  
	}
	























	/**
	 * 
	 * Create form and fill his data from record which ID
	 * transfered into function. Show errors if an exists
	 * after unsuccessful attempt.
	 * 
	 */
	function edit_form($id = null) {
		$idMod = (int)$id;
		if ($idMod < 1 || empty($idMod)) redirect('/');
		$writer_status = (!empty($_SESSION['user']['status'])) ? $_SESSION['user']['status'] : 0;

		
		// Получаем из БД информацию о редактируемой теме
		$res = $this->DB->select('mods', DB_FIRST, array(
			'joins' => array(
				array(
					'table' => 'users',
					'type' => 'LEFT',
					'alias' => 'd',
					'cond' => 'd.`id` = a.`author_id`',
				),
			),
			'fields' => array('a.*', 'd.`name` AS author', 'd.`status` AS author_status'),
			'alias' => 'a',
			'cond' => array('`a`.`id`' => $id),
		));
		if (count($res) == 0) redirect('/mods/');
		
		$mod = $res[0];
		$this->page_title .= __('Material editing');
		$html = '';
		$markets = array();
		
		
		if (!$this->ACL->turn(array('mods', 'edit_materials'), false) 
		&& (empty($_SESSION['user']['id']) || $mod['author_id'] != $_SESSION['user']['id'] 
		|| !$this->ACL->turn(array('mods', 'edit_mine_materials'), false))) {
			return showInfoMessage(__('Permission denied'), '/mods/' );
		}
		
		$_SESSION['current_vars'] = $mod;
		
		// Если при заполнении формы были допущены ошибки
		if (isset($_SESSION['FpsForm'])) {
			$info           = $this->Parser->getAndParse('infomessage.html' );
			$info           = str_replace( '{INFO_MESSAGE}', $_SESSION['FpsForm']['error'], $info );
			$html           = $info . $html . "\n";
			$game    	    = h($_SESSION['FpsForm']['game']);
			$description 	= h($_SESSION['FpsForm']['description']);
			$platforms 	= h($_SESSION['FpsForm']['platforms']);
			unset( $_SESSION['FpsForm'] );
		} else {
			$description		= h($mod['desc']);
			$platforms 				= h($mod['platforms']);
			$game 				= h($mod['game']);
		}
	

		// список платформ
		$array_platforms = $this->DB->select('platforms', DB_ALL);
		$platforms_change = $this->_buildSelectorM($array_platforms);

		$platforms_old = $mod['platforms'];

		// список игр
		$sql = $this->DB->select('games', DB_ALL);
		$game_change = $this->_buildSelector($sql, ((!empty($game)) ? $game : false));

		$markets['{GAME_SELECTOR}'] = $game_change;

		// Считываем в переменную файл шаблона, содержащего форму для редактирования темы
		$tpl = $this->Parser->getAndParse('editform.html' );
		$markets['{ACTION}'] = get_url('/mods/update/' . $idMod);
		$markets['{GAME_SELECTOR}'] = $game_change;
		$markets['{DESCRIPTION}'] = $description;
		$markets['{PLATFORMS_OLD}'] = $platforms_old;
		$markets['{PLATFORMS_SELECTOR}'] = $platforms_change;
		
		$markets = $this->Parser->quoteTags($markets);
		$html = $html . $this->_replaceMarkets($markets, $tpl);
		
		setReferer();
		return $this->_view($html);
	}







	/**
	 * 
	 * Validate data and update record into 
	 * Data Base. If an errors, redirect user to add form
	 * and show error message where speaks as not to admit 
	 * errors in the future
	 * 
	 */
	function update($id = null) {
		// Если не переданы данные формы - функция вызвана по ошибке
		if (!isset($id) or !isset($_POST['description'])) {
			redirect('/');
		}
		$idMod = (int)$id;
		if ( $idMod < 1 ) redirect('/mods/');


		
		$target = $this->DB->select('mods', DB_FIRST, array('cond' => array('id' => $idMod)));
		if (count($target) < 1) redirect('/mods/');
		$mod = $target[0];
		
		if (!$this->ACL->turn(array('mods', 'edit_materials'), false) 
		&& (empty($_SESSION['user']['id']) || $mod['author_id'] != $_SESSION['user']['id'] 
		|| !$this->ACL->turn(array('mods', 'edit_mine_materials'), false))) {
			return showInfoMessage(__('Permission denied'), '/mods/' );
		}

		$error  = '';
		
		// Обрезаем переменные до длины, указанной в параметре maxlength тега input
		$description   = trim($_POST['description']);
		$platforms   = $_POST['platforms'];
		// Preview
		if (isset($_POST['viewMessage'])) {
			$_SESSION['viewMessage'] = array_merge(array('description' => null, 'platforms' => null), $_POST);
			redirect('/mods/edit_form/' . $id);
		}
		
		if (mb_strlen($description) > Config::read('max_lenght', 'mods')) 
			$error = $error . '<li>' . sprintf(__('Wery big "material"'), Config::read('max_lenght', 'mods')).'</li>'."\n";
		if (mb_strlen($description) < Config::read('min_lenght', 'mods')) 
			$error = $error .'<li>' . sprintf(__('Wery small "material"'), Config::read('min_lenght', 'mods')).'</li>'."\n";
		
		// Проверяем, заполнены ли обязательные поля
		$valobj = new Validate;  //validation data class
		if ( empty( $description ) ) 
			$error = $error.'<li>' . __('Empty field "material"') .'</li>'."\n";
		if (empty($platforms) && !$valobj->cha_val($platforms, V_TITLE)) 
			$error = $error. '<li>' . __('Не выбрана платформа') . '</li>' ."\n";

		/* сохранение файла */
		if (!empty($_FILES['icon']['name']))
		{
			if ($mod['icon']=='1' && file_exists(R . 'sys/files/mods/' . $id . '.jpg')) {
				_unlink(R . 'sys/files/mods/' . $id . '.jpg');
			}
			//$ext = strchr($_FILES['icon']['name'], '.');
			$save_path = R . 'sys/files/mods/' . $id . '.jpg';
		
			if ($mod['icon'] != '1') $this->DB->save('mods', array('id' => $id, 'icon' => '1'));

			if (!move_uploaded_file($_FILES['icon']['tmp_name'], $save_path)) $error_flag = true;
			if (!chmod($save_path, 0644)) $error_flag = true; 

			resampleImage($save_path, $save_path, 120);
		}

		// Errors
		if (!empty($error)) {
			$_SESSION['FpsForm'] = array_merge(array('description' => null, 'platforms' => null), $_POST);
			$_SESSION['FpsForm']['error'] = '<p class="errorMsg">' . __('Some error in form') 
				. '</p>' . "\n" . '<ul class="errorMsg">'."\n".$error.'</ul>'."\n";
			redirect('/mods/edit_form/' . $idMod );
		}
		
		$platforms = implode(", ", $platforms);

		// Запрос на обновление новости
		$this->DB->save('mods', array(
			'id' 		   => $idMod,
			'desc'		   => $description,
			'platforms'    => $platforms,
		));
		
		//clear cache
		$this->Cache->clean(CACHE_MATCHING_TAG, array('record_id_' . $idMod, 'module_mod'));
		$this->DB->cleanSqlCache();
		if ($this->Log) $this->Log->write('editing mod', 'mod id(' . $idMod . ')');
		return showInfoMessage(__('Operation is successful'), getReferer());

	}
























	



	// Функция удаляет тему; ID темы передается методом GET
	function delete($id = null) {
		$idMod = (int)$id;
		if ( $idMod < 1 ) {
			redirect('/');
		}

		$sql = $this->DB->select('mods', DB_ALL, array('cond' => array('id' => $idMod)));
		$result = $sql[0];
		
		if (!$this->ACL->turn(array('mods', 'delete_materials'), false) 
		&& (empty($_SESSION['user']['id']) || $result['author_id'] != $_SESSION['user']['id'] 
		|| !$this->ACL->turn(array('mods', 'delete_mine_materials'), false))) {
			return showInfoMessage(__('Permission denied'), '/mods/' );
		}
		
		$this->Cache->clean(CACHE_MATCHING_ANY_TAG, array('module_mod'));

		if ($result['icon']='1' and is_file( R . 'sys/files/mods/' . $idMod . '.jpg' ) )
			unlink(R . 'sys/files/mods/' . $idMod . '.jpg' );
			
		// Delete records from data base. Also delete additional fields data
		$this->DB->query("DELETE FROM `" . $this->DB->getFullTableName('mods') . "` WHERE `id` = '" . $idMod . "'");

		$this->DB->cleanSqlCache();
		if ($this->Log) $this->Log->write('delete mod', 'mod id(' . $idMod . ')');
		return showInfoMessage(__('Operation is successful'), getReferer());
	}



	/**
	* @param array $record - assoc record array
	* @return string - admin buttons
	*
	* create and return admin bar
	*/
	protected function _getAdminBar($record) {
		$moder_panel = '';
		if ($this->ACL->turn(array('mods', 'edit_materials'), false) 
		|| (!empty($_SESSION['user']['id']) && $record['author_id'] == $_SESSION['user']['id'] 
		&& $this->ACL->turn(array('mods', 'edit_mine_materials'), false))) {
			$moder_panel .= get_link(get_img('/sys/img/edit_16x16.png'), '/mods/edit_form/' . $record['id']) . '&nbsp;';
		}
		if ($this->ACL->turn(array('mods', 'delete_materials'), false) 
		|| (!empty($_SESSION['user']['id']) && $record['author_id'] == $_SESSION['user']['id'] 
		&& $this->ACL->turn(array('mods', 'delete_mine_materials'), false))) {
			$moder_panel .= get_link(get_img('/sys/img/delete_16x16.png'), '/mods/delete/' . $record['id'], 
				array('onClick' => "return confirm('" . __('Are you sure') . "')")) . '&nbsp;';
		}
		return $moder_panel;
	}





	public function add_comment($id = null) {
		include_once(R . 'sys/inc/includes/add_comment.php');
	}
	
	private function _add_comment_form($id = null) {
		include_once(R . 'sys/inc/includes/_add_comment_form.php');
		return $html;
	}


	private function _get_comments($entity = null) {
		include_once(R . 'sys/inc/includes/_get_comments.php');
		return $html;
	}

}

?>
