summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/DetailPage.php
diff options
context:
space:
mode:
authorxue <>2005-12-23 17:53:37 +0000
committerxue <>2005-12-23 17:53:37 +0000
commitb9cd9367da104e5d3a4310fd1c40b841f5fbb286 (patch)
treef57dc89a9afabb37aaa86f5411251e436d149e0c /demos/quickstart/protected/pages/DetailPage.php
parent9c1e1d5efa7ebef6596e4d2dd8a42892648c8e1b (diff)
Diffstat (limited to 'demos/quickstart/protected/pages/DetailPage.php')
-rw-r--r--demos/quickstart/protected/pages/DetailPage.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/demos/quickstart/protected/pages/DetailPage.php b/demos/quickstart/protected/pages/DetailPage.php
new file mode 100644
index 00000000..afd81272
--- /dev/null
+++ b/demos/quickstart/protected/pages/DetailPage.php
@@ -0,0 +1,55 @@
+<?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