HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/includes/pages/viewcontent.php
<?php

/**
 * This file contains the iwp_page_viewcontent class
 *
 * @version $Id$
 * 
 *
 * @package IWP
 * @subpackage IWP_FrontEnd
 */

/**
 * IWP Frontend View Content Class
 * This class extends the iwp_engine abstract class.
 * This class handles the actions for displaying content on the frontend
 *
 * @package IWP
 * @subpackage IWP_FrontEnd
 */

class iwp_page_viewcontent 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 content page.
	 * It checks to make sure the ID number is valid and loads the content data from the database and sets up the database variables with the data.
	 *
	 * @return void Doesn't return anything
	 */
	public function ShowPage($contentid){

		$content = iwp_content::getInstance();
		$content->Load($contentid);

		iwp_event::trigger(new iwp_event_content_afterdbload($content));

		// add a canonical tag for this content item
		$this->template->Append('headTagEnd', '<link rev="canonical" href="' . IWP_BASE_URI . '/' . $content->getId() . '" />', false);

		$this->template->Assign('contentTitle', $content->Get('title'));
		$this->template->Assign('hasTitle', true);
		$this->template->Assign('hasViews', true);
		$this->template->Assign('contentViews', $content->Get('views'), false);
		$this->template->Assign('contentId', $content->GetId());

		if(strlen(trim($content->Get('content'))) == ''){
			$this->template->Assign('hasContent', true);
			$this->template->Assign('contentContent', $content->Get('summary'), false);
		}else{
			$this->template->Assign('hasContent', true);
			$this->template->Assign('contentContent', $content->Get('content'), false);
		}

		$this->template->Assign('hasContentDetails', false);

		$contenttypes = iwp_contenttypes::getInstance();
		$contenttype = $content->GetContentTypeInstance();

		$fieldList = $contenttypes->FlattenFieldsArray($contenttypes->ExplodeFields($contenttype->Get('modulelist')));

		// if the content item is not marked as visible, show a 404 page
		if($content->Get('visible') == 0 && in_array('field_visible', $fieldList)){
			$page = new iwp_page_notfound();
			$page->ShowPage();
			die();
		}

		// if the content item has expired, show a 404 page
		if ($content->HasField('expiryoptions')) {
			if($content->get('enableexpiry') == 1 && strtotime($content->get('expirydate')) < time()) {
				$page = new iwp_page_notfound();
				$page->ShowPage();
				die();
			}
		}

		if(in_array('field_multiplepages', $fieldList) && $content->HasAdditionalPages()) {
			$pages = $content->GetAdditionalPagesList();
			$requestPage = max((int)@$_GET['page'], 1);
			$this->paging = new iwp_paging();
			if($requestPage > 1){
				$num = $requestPage-2;
				$this->template->Assign('contentContent', $content->DecodeSiteURLs($pages[$num]['content']), false);
				if(!empty($pages[$num]['title'])){
					$this->template->Assign('contentTitle', $content->DecodeSiteURLs($pages[$num]['title']), false);
				}
			}
			$this->paging->SetPaging(sizeof($pages)+1, 1, $requestPage, '?page=%d', 10);

			$paging = array();
			$paging['PageCount']	= $this->paging->PageCount;
			$paging['currentPage']	= $this->paging->CurrentPage;
			$paging['prevPageLink']	= $_SERVER['REQUEST_URI'] . $this->paging->PreviousURL;
			$paging['nextPageLink']	= $_SERVER['REQUEST_URI'] . $this->paging->NextURL;
			$paging['links']		= $this->paging->PageList;
			$paging['firstPageLink']= $this->paging->FirstURL;
			$paging['lastPageLink']	= $this->paging->LastURL;

			$this->template->Assign('paging', $paging);
			$this->template->Assign('paging', $this->template->ParseSection('paginglinks_standard'), false);
		}


		if($content->HasField('metacontent')){
			if(!$this->valid->IsBlank($content->Get('metatitle'))) {
				$this->template->Assign('websiteTitle', $content->Get('metatitle'));
			} else {
				$this->template->Assign('websiteTitle', $content->Get('title'));
			}

			if(!$this->valid->IsBlank($content->Get('metakeywords'))) {
				$this->template->Assign('metaKeywords', $content->Get('metakeywords'));
			}

			if(!$this->valid->IsBlank($content->Get('metadesc'))) {
				$this->template->Assign('metaDescription', $content->Get('metadesc'));
			}
		} else {
			$this->template->Assign('websiteTitle', $content->Get('title'));
		}

		if($content->HasField('author')){
			$authorList = iwp_user::getInstance()->GetAuthorNameListByIdList($content->Get('author'));
			if($authorList === false){
				$this->template->Assign('hasAuthors', false);
			}else{
				$this->template->Assign('hasAuthors', true);
				$this->template->Assign('hasContentDetails', true);
				$this->template->Assign('contentAuthors', sprintf(GetLang('ContentWrittenBy'), $authorList), false);
			}
		}

		if($content->HasField('summary')){
			$this->template->Assign('hasSummary', true);
			$this->template->Assign('contentSummary', $content->Get('summary'), false);
		}else {
			$this->template->Assign('hasSummary', false);
		}

		if($content->HasField('categories')){
			$catList = iwp_categories::getInstance()->GetCategoryListByIdList(implode(',', $content->categories));
			if($catList === false){
				$this->template->Assign('hasCategories', false);
			}else{
				$this->template->Assign('hasCategories', true);
				$this->template->Assign('hasContentDetails', true);
				$this->template->Assign('contentCategories', sprintf(GetLang('StoredInCats'), $catList), false);
			}
		}

		if($content->HasField('startdate')){
			$startDate =  date(iwp_getShortDateFormat(), strtotime($content->Get('startdate')));
			if($startDate === false){
				$this->template->Assign('hasPublishDate', false);
				$this->template->Assign('hasPublishdate', false);
			}else{
				$this->template->Assign('hasPublishDate', true);
				$this->template->Assign('hasPublishdate', true);
				$this->template->Assign('hasContentDetails', true);
				$this->template->Assign('contentPublishdatewithlabel', sprintf(GetLang('ContentPublished'), $startDate), false);
				$this->template->Assign('contentPublishdate', $startDate, false);
			}
		}

		$whereTrail = $breadCrumbTrailLinks = array();
		$breadCrumbTrailLinks[] = array('Url' => iwp_config::Get('siteURL') .'/', 'Title' => $this->lang->Get('HomePage'));

		$contentSortCache = $this->db->FetchOne('select sortcache from ' . IWP_TABLE_LIST_SORTCACHE . ' where listid=0 and contentid=' . $content->GetId());
		$sortCache = $contentSortCache;

		while((strpos($sortCache, '.') !== false)) {
			$sortCache = substr($sortCache, 0, strrpos($sortCache, '.'));
			$whereTrail[] = 'lc.sortcache="' . $sortCache . '"';
		}

		if(!empty($whereTrail)) {
			$breadcrumbQuery = 'select c.title, c.contentid, u.urlpath, lc.sortcache from ' . IWP_TABLE_CONTENT . ' as c left join ' . IWP_TABLE_URLS .' as u on c.contentid=u.associd left join '. IWP_TABLE_LIST_SORTCACHE .' as lc on c.contentid=lc.contentid where lc.listid=0 and u.assoctype="content" and (' . implode (' or ', $whereTrail) .') order by lc.sortcache asc';
			$resource = $this->db->Query($breadcrumbQuery);

			while($thisParent = $this->db->Fetch($resource)) {
				$breadCrumbTrailLinks[] = array('Url' => $this->urls->GetURLPrepend(true, false) . $thisParent['urlpath'], 'Title' => $thisParent['title']);
			}
		}

		//	add an unlinked breadcrumb entry for the current cotnent item
		$breadCrumbTrailLinks[] = array('Title' => $content->Get('title'));

		$this->template->Assign(array('breadcrumbtrail', 'links'), $breadCrumbTrailLinks);
		$this->template->Assign('contentBreadcrumb', $this->template->ParseSection('breadcrumbtrail_standard'), false);

		$modules = iwp_modules::getInstance();

		foreach ($fieldList as $fieldName) {
			if (substr($fieldName, 0, 7) == 'module_') {
				$moduleName = substr($fieldName, 7);
				if (!$modules->IsModule($moduleName)) {
					continue;
				}
				$module = $modules->GetModule($moduleName);
				if ($module->GetActiveId()) {
					$setVar = $module->LoadFrontEndData($contentid);
					if($setVar === false){
						continue;
					}
					$setVar['lang'] = $module->lang->GetLangVars();
					$setVar['urlToModule'] = IWP_MODULES_URI . '/' . $moduleName;
					$this->template->Assign($moduleName, $setVar, false);
					$moduleData = $this->template->ParseTemplate($module->GetFrontEndTemplateName(), true, $moduleName);
					if ($module->AppendContent()) {
						$this->template->Append($module->GetFrontEndAppendSection(), $moduleData, false);
					} else {
						$this->template->Prepend($module->GetFrontEndAppendSection(), $moduleData, false);
					}
				}
			}
		}

		iwp_event::trigger(new iwp_event_content_beforedisplay());

		$content->Hit();

		$this->controller->SetContent($this->template->ParseSection('viewcontent_standard'));

		if($content->Get('haslayout') == 1) {
			$this->controller->ShowTemplate('contentitem_' . $content->GetId());
		} else {
			$this->controller->ShowTemplate('content_' . $content->Get('typeid'));
		}
	}
}