File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/includes/pages/viewauthor.php
<?php
/**
* This file contains the iwp_page_viewauthor class
*
* @version $Id$
*
*
* @package IWP
* @subpackage IWP_FrontEnd
*/
/**
* IWP Frontend View Author Page
* This class extends the iwp_engine abstract class.
* This class handles the actions for viewing an author's profile
*
* @package IWP
* @subpackage IWP_FrontEnd
*/
class iwp_page_viewauthor extends iwp_engine {
/**
* Calls the parent constructor
*
* @return void Doesn't return anything
*/
public function __construct(){
parent::__construct();
}
/**
* This function tells the controller to loads the view author page. It checks to make sure the ID number is valid and loads the author data from the database and sets up the database variables with the data.
*
* @return void Doesn't return anything
*/
public function ShowPage(){
$sections = $this->urls->GetCurrentMatches();
$userid = $sections['idnumber'];
if(!isset($userid) || !iwp_IsId($userid)){
$this->InvalidUser();
return;
}
$user = iwp_user::getInstance();
$user->Load($userid);
iwp_event::trigger(new iwp_event_users_beforeprofiledisplay($user));
$fullName = trim($user->Get('firstname') . ' '. $user->Get('lastname'));
$this->template->Assign('authorName', $fullName);
$this->template->Assign('authorFirstName', $user->Get('firstname'));
$this->template->Assign('authorLastName', $user->Get('lastname'));
$this->template->Assign('authorBio', $user->Get('biography'), false);
$this->template->Assign('authorBiography', $user->Get('biography'), false);
$this->template->Assign('websiteTitle', $fullName);
$this->lang->Set('ContentByAuthor', sprintf($this->lang->Get('ContentByAuthor'), $fullName));
/** start paging **/
$requestPage = max((int)@$_GET['page'], 1);
$perpage = 10;
$limit = (($requestPage*$perpage)-$perpage) . ', '.$perpage;
$authorList = new iwp_lists;
// $this->template->Assign('authorContentList', $authorList->OutputListByQuery('select * from '.IWP_TABLE_CONTENT.' as c where find_in_set('.$userid.',c.author) limit 10'), false);
$lists = new iwp_lists;
$sql = 'select SQL_CALC_FOUND_ROWS *, c.contentid as rowid, group_concat( ca.categoryid ) as categorylist from '.IWP_TABLE_CONTENT.' as c inner join '. IWP_TABLE_CONTENTTYPES .' as ct on ct.typeid = c.typeid inner join '. IWP_TABLE_URLS .' as u on c.contentid = u.associd left join '. IWP_TABLE_CATASSOC .' as ca on c.contentid = ca.contentid where /*%%visibility%%*/ (find_in_set('.$userid.',c.author)) group by c.contentid order by startdate desc limit ' . $limit;
$contentList = $lists->OutputListByQuery($sql);
$this->template->Assign('authorContentList', $contentList, false);
$cacheId = md5($sql.'paging');
$this->cache->SetDir('authors');
if(!$this->cache->HasExpired($cacheId)){
$this->template->Assign('authorPaging', $this->cache->ReadCache($cacheId), false);
}else{
if($lists->foundRows > $perpage){
$this->paging = new iwp_paging();
$this->paging->SetPaging($lists->foundRows, $perpage, $requestPage, '?page=%d', 5);
$paging = array();
$paging['PageCount'] = $this->paging->PageCount;
$paging['currentPage'] = $this->paging->CurrentPage;
$paging['prevPageLink'] = $this->paging->PreviousURL;
$paging['nextPageLink'] = $this->paging->NextURL;
$paging['links'] = $this->paging->PageList;
$paging['firstPageLink']= $this->paging->FirstURL;
$paging['lastPageLink'] = $this->paging->LastURL;
$this->template->Assign('paging', $paging);
$pagingHTML = $this->template->ParseSection('paginglinks_standard');
$this->template->Assign('authorPaging', $pagingHTML, false);
$this->cache->WriteCache($cacheId, $pagingHTML);
}else{
$this->cache->WriteCache($cacheId, '');
$this->template->Assign('authorPaging', '');
}
}
if(strlen($this->Get('picture')) < 10){
$authorImageExists = is_file(IWP_USER_IMAGES_PATH. '/' . $user->Get('picture'));
}else{
$authorImageExists = false;
}
$this->template->Assign('authorImageExists', $authorImageExists);
if($authorImageExists){
list($width, $height, $type, $attr) = getimagesize(IWP_USER_IMAGES_PATH. '/' . $user->Get('picture'));
$this->template->Assign('authorImageWidth', $width);
$this->template->Assign('authorImageHeight', $height);
$this->template->Assign('authorImageSrc', $this->urls->GetURLPrepend(true, false) .'/images/user/' . $user->Get('picture') );
switch($type){
case IMAGETYPE_GIF:
$imageType = 'imageGif';
break;
case IMAGETYPE_PNG:
$imageType = 'imagePng';
break;
case IMAGETYPE_JPEG:
$imageType = 'imageJpg';
break;
case IMAGETYPE_BMP:
$imageType = 'imageBmp';
break;
default:
$imageType = '';
break;
}
$this->template->Assign('authorImageType', $imageType);
}
$this->controller->SetContent($this->template->ParseSection('viewauthor_standard'));
$this->controller->ShowTemplate('user');
}
/**
* This function displays an error page with the Invalid User message
*
* @return void Doesn't return anything
*/
public function InvalidUser(){
$this->controller->SetContent('Invalid User!');
$this->controller->ShowTemplate('error');
}
}