<?php
include_once("../inc/content.inc.php");

class Home extends Content
{
public function __construct()
	{
	Content::__construct();
	if(!isset($this->id))$this->id=0;
	if(!isset($this->img))$this->img=0;

	$this->fox->Select("select * from users_img where uid=$this->id order by id","Image");
	foreach( $this->images as $key=> $value) break;
	if(!$this->img) $this->img=$key; 

	$this->fox->Select("select  id,visible_mail as mail,position,concat(lname,' ',fname,' ',mname) as name,text,instr,admin from users where id=$this->id ","Row");

	$this->title="Личная страница  {$this->name}, {$this->position} </title>";

	}

public function Image($row)
	{
	$this->images[$row['id']]=$row['path'];
	}

public function Row($row)
	{
	foreach($row as $key=>$value) $this->$key=$value;
	}



protected function Face1()
	{
	 $path="usr/{$this->id}/{$this->images[$this->img]}";
	 $size=getimagesize("/var/www/html/$path");        if($size[0]>$size[1]) $tbl="tbl";  else $tbl="tbl1";
	$txt=<<<EOS
<tr><td colspan=3 rowspan=4>
<img border=0  class='face' id='$tbl' src='/preview.php?height=500&path=$path'>
</td>
EOS;
	return $txt;
	}
protected function Images()
	{
	$i=0; $txt="";
	foreach( $this->images as $key=>$value) if($key!=$this->img)
		{   
        	 $path="usr/{$this->id}/{$value}";
		 $size=getimagesize("/var/www/html/$path");        if($size[0]>$size[1]) $tbl="tbl";  else $tbl="tbl1";

		$txt.=<<<EOS
<td><a href='{$this->self}?img={$key}&id={$this->id}'>
<img border=0  class='face' id='$tbl' SRC='/preview.php?height=120&path={$path}'>
</a>
</td>
EOS;
		$i++; if(!($i%2)) $txt.="</tr>";
		}
	return $txt;
	}

protected function Main()
	{
	$txt1=$this->Face1().$this->Images();

	$txt=<<<EOS
<h1>{$this->name}</h1>
<h3>{$this->position}</h3>
<h3><a href='mailto:{$this->mail}'>{$this->mail}</a></h3>
<table width=100% >
<tr ><td width='20%'><td width='20%'><td width='20%'>
$txt1
</table>
<p class='text'>{$this->text}</p>
<table width=100&>
EOS;
	if($this->instr>0)$txt.="<tr><td><a href='../classes/seminars.php?instr={$this->id}'>Семинары инструктора</a>";
	$txt.="<td><a href='../classes/classes.php?instr={$this->id}'>Занятия инструктора</a>";
	if($this->fox->Select("select id from blogs where uid={$this->id}")) $txt.="<td><a href='../blogs/blog.php?uid={$this->id}'>Блог</a>";
	$txt.="<td><a href='{$this->folder}/index.php?admin={$this->admin}'>Список страниц</a>\n";
	return  $txt; 
	}
}

(new Home)->Type();
?>
