diff options
Diffstat (limited to 'demos/quickstart')
| -rw-r--r-- | demos/quickstart/protected/pages/DetailPage.php | 55 | ||||
| -rw-r--r-- | demos/quickstart/protected/pages/ViewSource.page | 16 | ||||
| -rw-r--r-- | demos/quickstart/protected/pages/ViewSource.php | 66 | ||||
| -rw-r--r-- | demos/quickstart/protected/pages/chap3/Hangman.page | 6 | ||||
| -rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld.page | 26 | ||||
| -rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld/Home.page | 18 | ||||
| -rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld/Home.php | 11 | ||||
| -rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld/config.xml | 5 | ||||
| -rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld/sequence.gif | bin | 0 -> 5557 bytes | |||
| -rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd | bin | 0 -> 143360 bytes | 
10 files changed, 148 insertions, 55 deletions
diff --git a/demos/quickstart/protected/pages/DetailPage.php b/demos/quickstart/protected/pages/DetailPage.php deleted file mode 100644 index afd81272..00000000 --- a/demos/quickstart/protected/pages/DetailPage.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php
 -
 -class DetailPage extends TPage
 -{
 -	private $_file;
 -
 -	public function onLoad($param)
 -	{
 -		parent::onLoad($param);
 -		$isSrc=true;
 -		if(($id=$this->Request->Items['src'])===null)
 -			$this->_file=$this->determineFile($this->Request->Items['tpl'],false);
 -		else
 -			$this->_file=$this->determineFile($id,true);
 -	}
 -
 -	protected function determineFile($id,$isSrcFile)
 -	{
 -		$basePath=dirname(__FILE__).'/controls';
 -
 -		$xml=new TXmlDocument;
 -		$xml->loadFromFile($basePath.'/config.xml');
 -		$pages=$xml->getElementByTagName('pages')->getElementsByTagName('page');
 -		$fileName='';
 -		foreach($pages as $page)
 -		{
 -			if($page->Attributes['id']===$id)
 -			{
 -				if($isSrcFile)
 -					$fileName=$basePath.'/'.$page->Attributes['class'].'.php';
 -				else if($page->Attributes['TemplateFile']!==null)
 -				{
 -					$fileName=$page->Attributes['TemplateFile'];
 -					if(($pos=strrpos($fileName,'.'))!==false)
 -						$fileName=substr($fileName,$pos+1);
 -					$fileName=$basePath.'/'.$fileName.'.tpl';
 -				}
 -				else
 -					$fileName=$basePath.'/'.$page->Attributes['class'].'.tpl';
 -				break;
 -			}
 -		}
 -		if(empty($fileName) || !is_file($fileName))
 -			throw new THttpException(500,"File not exists!");
 -		return $fileName;
 -	}
 -
 -	protected function render($writer)
 -	{
 -		$contents=file_get_contents($this->_file);
 -		$writer->write(highlight_string($contents,true));
 -	}
 -}
 -
 -?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ViewSource.page b/demos/quickstart/protected/pages/ViewSource.page new file mode 100644 index 00000000..3732771a --- /dev/null +++ b/demos/quickstart/protected/pages/ViewSource.page @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
 +
 +<com:THead Title="PRADO QuickStart Source View">
 +<meta http-equiv="content-language" content="en"/>
 +</com:THead>
 +
 +<body>
 +<div id="sourceList">
 +<com:TLiteral ID="SourceList" />
 +</div>
 +<div id="sourceView">
 +<com:TLiteral ID="SourceView" />
 +</div>
 +</body>
 +</html>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ViewSource.php b/demos/quickstart/protected/pages/ViewSource.php new file mode 100644 index 00000000..9509e400 --- /dev/null +++ b/demos/quickstart/protected/pages/ViewSource.php @@ -0,0 +1,66 @@ +<?php
 +
 +class ViewSource extends TPage
 +{
 +	private $_path=null;
 +	private $_fullPath=null;
 +	private $_fileType=null;
 +
 +	protected function isFileTypeAllowed($extension)
 +	{
 +		return in_array($extension,array('tpl','page','php'));
 +	}
 +
 +	protected function getFileExtension($fileName)
 +	{
 +		if(($pos=strrpos($fileName,'.'))===false)
 +			return '';
 +		else
 +			return substr($fileName,$pos+1);
 +	}
 +
 +	public function onLoad($param)
 +	{
 +		parent::onLoad($param);
 +		$path=$this->Request->Items['path'];
 +		$fullPath=realpath($this->Service->BasePath.'/'.$path);
 +		if($fullPath!==false && is_file($fullPath) && strpos($fullPath,$this->Service->BasePath)!==false)
 +		{
 + 			if($this->isFileTypeAllowed($this->getFileExtension($fullPath)))
 + 			{
 +				$this->_fullPath=strtr($fullPath,'\\','/');
 +				$this->_path=strtr(substr($fullPath,strlen($this->Service->BasePath)),'\\','/');
 + 			}
 +		}
 +		if($this->_fullPath===null)
 +			throw new THttpException(500,'File Not Found: %s',$path);
 +		$basePath=dirname($this->_fullPath);
 +		if($dh=opendir($basePath))
 +		{
 +			$str="<h4>{$this->_path}</h4>\n";
 +			while(($file=readdir($dh))!==false)
 +			{
 +				if(is_file($basePath.'/'.$file))
 +				{
 +					$fileType=$this->getFileExtension($basePath.'/'.$file);
 +					if($this->isFileTypeAllowed($fileType))
 +					{
 +						if($fileType==='tpl' || $fileType==='page')
 +							$type='Template file';
 +						else
 +							$type='Class file';
 +						$path='/'.ltrim(strtr(dirname($this->_path),'\\','/').'/'.$file,'/');
 +						$str.="$type: <a href=\"?page=ViewSource&path=$path\">$file</a><br/>";
 +					}
 +				}
 +
 +			}
 +			closedir($dh);
 +			$this->SourceList->Text=$str;
 +		}
 +
 +		$this->SourceView->Text=highlight_string(file_get_contents($this->_fullPath),true);
 +	}
 +}
 +
 +?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/Hangman.page b/demos/quickstart/protected/pages/chap3/Hangman.page new file mode 100644 index 00000000..603a040b --- /dev/null +++ b/demos/quickstart/protected/pages/chap3/Hangman.page @@ -0,0 +1,6 @@ +<com:TContent ID="body" >
 +<h4>Sample: Hangman Game</h4>
 +<p>
 +<a href="?page=Samples.Hangman.
 +</p>
 +</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld.page b/demos/quickstart/protected/pages/chap3/HelloWorld.page new file mode 100644 index 00000000..8ded6585 --- /dev/null +++ b/demos/quickstart/protected/pages/chap3/HelloWorld.page @@ -0,0 +1,26 @@ +<com:TContent ID="body" >
 +<h4>Sample: Hello World</h4>
 +<p>
 +"Hello World" is the simplest <i>interactive</i> PRADO application that you can build. It displays to end-users a page with a submit button whose caption is <i>Click Me</i>. When the user clicks on the button, the button changes the caption to <i>Hello World</i>.
 +</p>
 +<p>
 +There are many approaches that can achieve the above goal. One can submit the page to the server, examine the POST variable, and generate a new page with the button caption updated. Or one can simply use JavaScript to update the button caption upon its <i>onclick</i> event.
 +</p>
 +<p>
 +PRADO promotes component-based and event-driven Web programming. The button is represented by a <i>TButton</i> object. It encapsulates the button caption as the <i>Text</i> property and associates the user button click action with a server-side <i>Click</i> event. Therefore, the "Hello World" task can be handled intuitively and easily. One simply needs to attach a function to the button's <i>Click</i> event. Within the function, the button's <i>Text</i> property is modified as "Hello World". The following diagram shows the above sequence,
 +</p>
 +<img src="<%~HelloWorld/sequence.gif%>" />
 +<p>
 +The code that a developer needs to write is merely the following event handler function, where <code>$sender</code> refers to the button object.
 +</p>
 +<pre class="code">
 +public function buttonClicked($sender,$param)
 +{
 +	$sender->Text="Hello World";
 +}
 +</pre>
 +<div class="runbar">
 +<a href="?page=chap3.HelloWorld.Home" target="_blank">Run Sample</a>
 +<a href="?page=ViewSource&path=/chap3/HelloWorld/Home.php" target="_blank">View Source</a>
 +</div>
 +</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/Home.page b/demos/quickstart/protected/pages/chap3/HelloWorld/Home.page new file mode 100644 index 00000000..158255cb --- /dev/null +++ b/demos/quickstart/protected/pages/chap3/HelloWorld/Home.page @@ -0,0 +1,18 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 +        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 +
 +<head>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +<title>Hello World</title>
 +</head>
 +
 +<body>
 +
 +<com:TForm>
 +<com:TButton Text="Click Me" Click="buttonClicked" />
 +</com:TForm>
 +
 +</body>
 +
 +</html>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/Home.php b/demos/quickstart/protected/pages/chap3/HelloWorld/Home.php new file mode 100644 index 00000000..b1a7f991 --- /dev/null +++ b/demos/quickstart/protected/pages/chap3/HelloWorld/Home.php @@ -0,0 +1,11 @@ +<?php
 +
 +class Home extends TPage
 +{
 +	public function buttonClicked($sender,$param)
 +	{
 +		$sender->Text="Hello World";
 +	}
 +}
 +
 +?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/config.xml b/demos/quickstart/protected/pages/chap3/HelloWorld/config.xml new file mode 100644 index 00000000..67056f9d --- /dev/null +++ b/demos/quickstart/protected/pages/chap3/HelloWorld/config.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?>
 +
 +<configuration>
 +  <pages MasterClass="" />
 +</configuration>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.gif b/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.gif Binary files differnew file mode 100644 index 00000000..a1e51200 --- /dev/null +++ b/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.gif diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd b/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd Binary files differnew file mode 100644 index 00000000..e8c2f5a7 --- /dev/null +++ b/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd  | 
