From da3e4e99d6a2e3b2c9591d969cb63d61a6114eee Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 24 Dec 2005 17:14:39 +0000 Subject: --- demos/quickstart/protected/pages/DetailPage.php | 55 ----------------- demos/quickstart/protected/pages/ViewSource.page | 16 +++++ demos/quickstart/protected/pages/ViewSource.php | 66 +++++++++++++++++++++ .../quickstart/protected/pages/chap3/Hangman.page | 6 ++ .../protected/pages/chap3/HelloWorld.page | 26 ++++++++ .../protected/pages/chap3/HelloWorld/Home.page | 18 ++++++ .../protected/pages/chap3/HelloWorld/Home.php | 11 ++++ .../protected/pages/chap3/HelloWorld/config.xml | 5 ++ .../protected/pages/chap3/HelloWorld/sequence.gif | Bin 0 -> 5557 bytes .../protected/pages/chap3/HelloWorld/sequence.vsd | Bin 0 -> 143360 bytes 10 files changed, 148 insertions(+), 55 deletions(-) delete mode 100644 demos/quickstart/protected/pages/DetailPage.php create mode 100644 demos/quickstart/protected/pages/ViewSource.page create mode 100644 demos/quickstart/protected/pages/ViewSource.php create mode 100644 demos/quickstart/protected/pages/chap3/Hangman.page create mode 100644 demos/quickstart/protected/pages/chap3/HelloWorld.page create mode 100644 demos/quickstart/protected/pages/chap3/HelloWorld/Home.page create mode 100644 demos/quickstart/protected/pages/chap3/HelloWorld/Home.php create mode 100644 demos/quickstart/protected/pages/chap3/HelloWorld/config.xml create mode 100644 demos/quickstart/protected/pages/chap3/HelloWorld/sequence.gif create mode 100644 demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd (limited to 'demos') 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 @@ -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 @@ + + + + + + + + +
+ +
+
+ +
+ + \ 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 @@ +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="

{$this->_path}

\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: $file
"; + } + } + + } + 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 @@ + +

Sample: Hangman Game

+

+ +

Sample: Hello World

+

+"Hello World" is the simplest interactive PRADO application that you can build. It displays to end-users a page with a submit button whose caption is Click Me. When the user clicks on the button, the button changes the caption to Hello World. +

+

+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 onclick event. +

+

+PRADO promotes component-based and event-driven Web programming. The button is represented by a TButton object. It encapsulates the button caption as the Text property and associates the user button click action with a server-side Click event. Therefore, the "Hello World" task can be handled intuitively and easily. One simply needs to attach a function to the button's Click event. Within the function, the button's Text property is modified as "Hello World". The following diagram shows the above sequence, +

+ +

+The code that a developer needs to write is merely the following event handler function, where $sender refers to the button object. +

+
+public function buttonClicked($sender,$param)
+{
+	$sender->Text="Hello World";
+}
+
+
+Run Sample +View Source +
+
\ 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 @@ + + + + + +Hello World + + + + + + + + + + + \ 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 @@ +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 @@ + + + + + \ 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 new file mode 100644 index 00000000..a1e51200 Binary files /dev/null and b/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.gif differ diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd b/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd new file mode 100644 index 00000000..e8c2f5a7 Binary files /dev/null and b/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd differ -- cgit v1.2.3