summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected
diff options
context:
space:
mode:
Diffstat (limited to 'demos/quickstart/protected')
-rw-r--r--demos/quickstart/protected/pages/ViewSource.page12
-rw-r--r--demos/quickstart/protected/pages/ViewSource.php90
2 files changed, 69 insertions, 33 deletions
diff --git a/demos/quickstart/protected/pages/ViewSource.page b/demos/quickstart/protected/pages/ViewSource.page
index 900c45f6..8f1239b3 100644
--- a/demos/quickstart/protected/pages/ViewSource.page
+++ b/demos/quickstart/protected/pages/ViewSource.page
@@ -7,9 +7,19 @@
<body>
<div id="sourceList">
-<com:TLiteral ID="SourceList" />
+<table border="0">
+<com:TRepeater ID="SourceList">
+<prop:ItemTemplate>
+<tr>
+ <td align="right"><%# $this->DataItem['type']%>:</td>
+ <td><a href="<%# $this->DataItem['active']?'':$this->DataItem['url']%>"><%# $this->DataItem['name']%></a></td>
+</tr>
+</prop:ItemTemplate>
+</com:TRepeater>
+</table>
</div>
<div id="sourceView">
+<h3 style="text-align:center"><%= $this->FilePath %></h3>
<com:TTextHighlighter ID="Highlighter" ShowLineNumbers="true" CssClass="source">
<com:TLiteral ID="SourceView" />
</com:TTextHighlighter>
diff --git a/demos/quickstart/protected/pages/ViewSource.php b/demos/quickstart/protected/pages/ViewSource.php
index cfdc63ef..9a8d7d09 100644
--- a/demos/quickstart/protected/pages/ViewSource.php
+++ b/demos/quickstart/protected/pages/ViewSource.php
@@ -6,19 +6,6 @@ class ViewSource extends TPage
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);
@@ -35,49 +22,88 @@ class ViewSource extends TPage
}
if($this->_fullPath===null)
throw new THttpException(500,'File Not Found: %s',$path);
+
+ $this->SourceList->DataSource=$this->SourceFiles;
+ $this->SourceList->dataBind();
+
+ $this->Highlighter->Language=$this->getFileLanguage($fileExt);
+ $this->SourceView->Text=file_get_contents($this->_fullPath);
+ }
+
+ public function getFilePath()
+ {
+ return $this->_path;
+ }
+
+ protected function getSourceFiles()
+ {
+ $list=array();
$basePath=dirname($this->_fullPath);
if($dh=opendir($basePath))
{
- $str="<h2>{$this->_path}</h2>\n";
while(($file=readdir($dh))!==false)
{
if(is_file($basePath.'/'.$file))
{
- $fileType=$this->getFileExtension($basePath.'/'.$file);
- if($this->isFileTypeAllowed($fileType))
+ $extension=$this->getFileExtension($basePath.'/'.$file);
+ if($this->isFileTypeAllowed($extension))
{
- 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&amp;path=$path\">$file</a><br/>";
+ $fileType=$this->getFileType($extension);
+ $list[]=array(
+ 'name'=>$file,
+ 'type'=>$fileType,
+ 'active'=>basename($this->_fullPath)===$file,
+ 'url'=>'?page=ViewSource&amp;path=/'.ltrim(strtr(dirname($this->_path),'\\','/').'/'.$file,'/')
+ );
}
}
}
closedir($dh);
- $this->SourceList->Text=$str;
}
+ foreach($list as $item)
+ $aux[]=$item['name'];
+ array_multisort($aux, SORT_ASC, $list);
+ return $list;
+ }
- switch($fileExt)
+ protected function isFileTypeAllowed($extension)
+ {
+ return in_array($extension,array('tpl','page','php','html'));
+ }
+
+ protected function getFileExtension($fileName)
+ {
+ if(($pos=strrpos($fileName,'.'))===false)
+ return '';
+ else
+ return substr($fileName,$pos+1);
+ }
+
+ protected function getFileType($extension)
+ {
+ if($extension==='tpl' || $extension==='page')
+ return 'Template file';
+ else
+ return 'Class file';
+ }
+
+ protected function getFileLanguage($extension)
+ {
+ switch($extension)
{
case 'page' :
case 'tpl' :
- $this->Highlighter->Language='prado';
- break;
+ return 'prado';
case 'php' :
- $this->Highlighter->Language='php';
+ return 'php';
break;
case 'xml' :
- $this->Highlighter->Language='xml';
+ return 'xml';
break;
default :
- $this->Highlighter->Language='html';
- break;
+ return 'html';
}
-
- $this->SourceView->Text=file_get_contents($this->_fullPath);
}
}