Filter:   InfoImg
download pagemaker.inc
Language: NonCode
LOC: 0
Project Info
HPE
Server: SourceForge
Type: cvs
[Show Code]






[Show Code]
...ceForge\h\hpe\hpe\hpe1\HPE\
   .cvsignore
   clickerr.inc
   config.inc
   Config_File.class.php
   database.inc
   database.mysql.inc
   database.pear.inc
   FormChek.js
   HPE.inc
   HPEbase.inc
   HPEUsers.default.xml
   HPEUsers.guest.xml
   layout.js
   local.inc
   modules.inc
   ...andlers.addChannel.ftsc
   navcond.js
   newsaccess.inc
   newssource.inc
   newstools.js
   overlib.js
   overlib_mini.js
   pagemaker.inc
   pages.inc
   PHPClientSniffer.inc
   phpodp.inc
   publisher.inc
   services.inc
   sitelister.inc
   Smarty.addons.php
   Smarty.class.php
   Smarty_Compiler.class.php
   sourcetools.js
   thememaker.inc
   toparser.inc
   user.edit.inc
   user.inc
   xmlrpc.inc
   xmlrpcs.inc
   xmltree.inc

<?
/*

HPE - News Portal Engine
Copyright (C) 2000-2001 Mike Krus

This program is free software; it is distributed in the hope 
that it will be useful, but WITHOUT ANY WARRANTY; without 
even the implied warranty of MERCHANTABILITY or FITNESS 
FOR A PARTICULAR PURPOSE.  

READ LICENSE.TXT IN THE BASE DIRECTORY FOR INFORMATION 
ABOUT REDISTRIBUTING THIS SOURCE CODE

*/


class HPEPageMaker 
{

	var $message = "";

	var $pagetitle = "";
	var $pageid = 0;		// the unique (for the user) id of the page (creation date by default)
	var $pagetype = 0;		// the type of the page
	var $pageindex = -1;	// the index in the list of pages for the user


	function HPEPageMaker() 
	{
		$this->message = "";
	}


	function showmessage()
	{
		if($this->message == "") return;
		echo "$this->message";
	}


	function initpage($pg)
	{
		global $HPEtheConfig;
		global $HPEtheUser;

		if($HPEtheUser->nbpages == 0) return;

//		if($pg == -1) $pg = 0;

		if($pg >= 0) {
			if(!isset($HPEtheUser->pages[$pg])) {
				echo "<P><B>Page number $pg is out of bounds</B></P>";
			} else {
				$this->pageindex = $pg;
				$this->pagetype = $HPEtheUser->pages[$this->pageindex]["type"];
				$this->pageid = $HPEtheUser->pages[$this->pageindex]["id"];
				if(!isset($HPEtheConfig->pagehandlers[$this->pagetype])) 
					die("Page type $this->pagetype unsupported");
			}
		}
	}


	function MakePrintURL()
	{
		global $HPEtheConfig;

		$url = $HPEtheConfig->makeURLToPage();
		$url .= "mode=print";
		return $url;
	}


	function MakeEditURL()
	{
		global $HPEtheConfig;
		global $HPEtheUser;

		if($HPEtheUser->userid <= 0) return "";
		if($this->pageindex < 0 && $this->pageindex >= $HPEtheUser->nbpages) return "";

		if(!isset($HPEtheConfig->pagehandlers[$this->pagetype])) return "";
		if(!($HPEtheConfig->pagehandlers[$this->pagetype]["control"]->flags & HPEPageExternEdit)) return "";

		$url = $HPEtheConfig->siteroot . "user/pages/$this->pageindex/";
		return $url;
	}


	function GetPageData(&$data)
	{
		global $HPEtheSession;
		global $HPEtheUser;
		global $HPEtheConfig;
		global $HPEtheThemeMaker;
		global $page;

		if(!isset($data["title"]))
			$data["title"] = "";
		if($data["title"] == "" && $page >= 0) 
			$data["title"] = $HPEtheUser->pages[$page]["title"];
/*		if($data["title"] != "") 
			$data["title"] = ": " . $data["title"];
		$data["title"] = $HPEtheConfig->sitename . $data["title"];
*/

		$data["pagelist"] = array();
		for($i=0; $i<$HPEtheUser->nbpages; $i++) 
		{
			if(!isset($HPEtheConfig->pagehandlers[$HPEtheUser->pages[$i]["type"]])) 
				continue;
//			if($HPEtheConfig->pagehandlers[$HPEtheUser->pages[$i]["type"]] == "") continue;

			$url = $HPEtheConfig->pagehandlers[$HPEtheUser->pages[$i]["type"]]["control"]->url;
			$data["pagelist"][$i]["link"]  = $this->url($url, "page=$i");
			$data["pagelist"][$i]["title"] = trim($HPEtheUser->pages[$i]["title"]);
			$data["pagelist"][$i]["id"] = $i;
		}

		if($page > 0)
		{
			$data["relfirst"] = array(
								"link" => $data["pagelist"][0]["link"],
								"title" => $data["pagelist"][0]["title"]
							   );
			$data["relprev"] = array(
								"link" => $data["pagelist"][$page - 1]["link"],
								"title" => $data["pagelist"][$page - 1]["title"]
							   );
		}
		if($page >= 0 && $page < $HPEtheUser->nbpages - 1)
		{
			$data["relnext"] = array(
								"link" => $data["pagelist"][$page + 1]["link"],
								"title" => $data["pagelist"][$page + 1]["title"]
							   );
			$data["rellast"] = array(
								"link" => $data["pagelist"][$HPEtheUser->nbpages - 1]["link"],
								"title" => $data["pagelist"][$HPEtheUser->nbpages - 1]["title"]
							   );
		}

		$data["edit_link"] = $this->MakeEditURL();
		$data["print_link"] = $this->MakePrintURL();
	}


	function beginpage($title, $data = array())
	{
		global $HPEtheThemeMaker;

		$data["title"] = $title;

		echo $HPEtheThemeMaker->TPLRun("pagebanner", $data);
	}


	function beginpopup($title)
	{
		global $HPEtheThemeMaker;

		echo $HPEtheThemeMaker->TPLRun("pagepopup", array() );
	}


	function endpage($data = array())
	{
		global $HPEtheThemeMaker;

		echo $HPEtheThemeMaker->TPLRun("pagefooter", $data );
	}


	function countview()
	{
		global $HPEtheDB;
		global $REMOTE_ADDR;
		global $HPEtheUser;
		global $HPEtheConfig;

		$dt = gmdate("ymd");
		$query = "UPDATE $HPEtheDB->dbtuseraccess SET total=total+1, host='$REMOTE_ADDR' WHERE userid=$HPEtheUser->userid AND date='$dt'";
		$res = $HPEtheDB->query($query);
		if($HPEtheDB->iserror($res) || $HPEtheDB->getaffectedrowcount() == 0) 
		{
			$query = "INSERT INTO $HPEtheDB->dbtuseraccess (userid, host, date, total) VALUES " .
					 "($HPEtheUser->userid, '$REMOTE_ADDR', '$dt', 1)";
			$HPEtheDB->query($query);
		}
	}


	function url($t, $q = "")
	{
		global $HPEtheConfig;
		global $page;
		
		$url = $HPEtheConfig->siteroot . $t;
		
		if($q != "") 
		{
			$url .= "?$q";
			$q = "&";
		} else $q = "?";

		return $url;
	}
};


/*
function HPEwindowopener($winname = "hpenews")
{
	global $HPEtheConfig;
?>
<script LANGUAGE="JavaScript1.1"><!--
function displayNews(newsid)
{
	res = window.open('<? echo $HPEtheConfig->siteroot ?>shownews.php3?newsid='+newsid,
					  '<? echo $winname ?>', 'toolbar=no,scrollbars=yes,width=300,height=600');
	res.focus();
}
//--></script>
<?
}


function HPEhelplauncher()
{
	global $HPEtheConfig;
?>
<script LANGUAGE="JavaScript1.1"><!--
function displayHelp(helpid)
{
	res = window.open('<? echo $HPEtheConfig->siteroot ?>help.php3?page='+helpid,
					  'hpehelp', 'toolbar=no,scrollbars=yes,width=<? echo $HPEtheConfig->popupwidth ?>,height=<? echo $HPEtheConfig->popupwidth ?>');
	res.focus();
}

function linkFromHelp(url)
{
	if(window.opener.name == window.name) {
		res = window.open(url);
		res.focus();
	} else {
		window.opener.location.href = url;
		window.opener.focus();
	}
}
//--></script>
<?
}

function HPEhelplink($title, $page = "main")
{
	return "<A HREF=\"javascript:displayHelp('$page')\">$title</A>";
}

function HPEhelplinkback($title, $page = "")
{
	global $HPEtheConfig;
	return "<A HREF=\"javascript:linkFromHelp('$HPEtheConfig->siteroot$page')\">$title</A>";
}
*/


$HPEthePager = new HPEPageMaker();

?>