summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2006-02-15 01:38:39 +0000
committerxue <>2006-02-15 01:38:39 +0000
commit2b194248b9bbd75887c1d5f991dca1f3fd441dd5 (patch)
tree833dc5c56d702d5188b383d3124759965d9b972f /framework
parentcd1ffb47a6c07deda47052eff80452e78a52495d (diff)
Added SourceTemplateControl property for TControl.
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/UI/TControl.php16
-rw-r--r--framework/Web/UI/TTemplateControl.php24
-rw-r--r--framework/Web/UI/TTemplateManager.php20
3 files changed, 58 insertions, 2 deletions
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index 50648d93..6fd25f76 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -256,6 +256,22 @@ class TControl extends TComponent
}
/**
+ * @return TTemplateControl the control whose template is loaded from
+ * some external storage, such as file, db, and whose template ultimately
+ * contains this control.
+ */
+ public function getSourceTemplateControl()
+ {
+ $control=$this;
+ while(($control instanceof TControl) && ($control=$control->getTemplateControl())!==null)
+ {
+ if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl())
+ return $control;
+ }
+ return $this->getPage();
+ }
+
+ /**
* Publishes a private asset and gets its URL.
* This method will publish a private asset (file or directory)
* and gets the URL to the asset. Note, if the asset refers to
diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php
index d7f1868b..d6ccb825 100644
--- a/framework/Web/UI/TTemplateControl.php
+++ b/framework/Web/UI/TTemplateControl.php
@@ -83,6 +83,30 @@ class TTemplateControl extends TControl implements INamingContainer
}
/**
+ * @return boolean whether this control is a source template control.
+ * A source template control loads its template from external storage,
+ * such as file, db, rather than from within another template.
+ */
+ public function getIsSourceTemplateControl()
+ {
+ if(($template=$this->getTemplate())!==null)
+ return $template->getIsSourceTemplate();
+ else
+ return false;
+ }
+
+ /**
+ * @return string the directory containing the template. Empty if no template available.
+ */
+ public function getTemplateDirectory()
+ {
+ if(($template=$this->getTemplate())!==null)
+ return $template->getContextPath();
+ else
+ return '';
+ }
+
+ /**
* Loads the template associated with this control class.
* @return ITemplate the parsed template structure
*/
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index abeb7466..59d15698 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -194,6 +194,10 @@ class TTemplate extends TComponent implements ITemplate
* @var string template content to be parsed
*/
private $_content;
+ /**
+ * @var boolean whether this template is a source template
+ */
+ private $_sourceTemplate=true;
/**
@@ -203,9 +207,12 @@ class TTemplate extends TComponent implements ITemplate
* @param string the template context directory
* @param string the template file, null if no file
* @param integer the line number that parsing starts from (internal use)
+ * @param boolean whether this template is a source template, i.e., this template is loaded from
+ * some external storage rather than from within another template.
*/
- public function __construct($template,$contextPath,$tplFile=null,$startingLine=0)
+ public function __construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true)
{
+ $this->_sourceTemplate=$sourceTemplate;
$this->_contextPath=$contextPath;
$this->_tplFile=$tplFile;
$this->_startingLine=$startingLine;
@@ -215,6 +222,15 @@ class TTemplate extends TComponent implements ITemplate
}
/**
+ * @return boolean whether this template is a source template, i.e., this template is loaded from
+ * some external storage rather than from within another template.
+ */
+ public function getIsSourceTemplate()
+ {
+ return $this->_sourceTemplate;
+ }
+
+ /**
* @return string context directory path
*/
public function getContextPath()
@@ -636,7 +652,7 @@ class TTemplate extends TComponent implements ITemplate
protected function parseTemplateProperty($content,$offset)
{
$line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1;
- return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line));
+ return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line,false));
}
/**