From 8a4e5a9b04c479fa027acfba52f4d68cf3bd6679 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 12 Nov 2005 18:17:58 +0000 Subject: Added asset manager. --- framework/Web/UI/TControl.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'framework/Web/UI/TControl.php') diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index a3d3c93a..65993664 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -69,6 +69,10 @@ class TControl extends TComponent * prefix to an ID automatically generated */ const AUTOMATIC_ID_PREFIX='ctl'; + /** + * default control asset path + */ + const ASSET_PATH='assets'; /** * the stage of lifecycles that the control is currently at @@ -270,6 +274,28 @@ class TControl extends TComponent return Prado::getApplication()->getUser(); } + public function publishFile($file) + { + return Prado::getApplication()->getService()->getAssetManager()->publishFile($file); + } + + public function publishDirectory($directory) + { + return Prado::getApplication()->getService()->getAssetManager()->publishDirectory($directory); + } + + public function getAsset($assetName) + { + $class=new ReflectionClass(get_class($this)); + $assetFile=dirname($class->getFileName()).'/'.self::ASSET_PATH.'/'.$assetName; + if(is_file($assetFile)) + return $this->publishFile($assetFile); + else if(is_dir($assetFile)) + return $this->publishDirectory($assetFile); + else + return ''; + } + /** * Returns the id of the control. * Control ID can be either manually set or automatically generated. -- cgit v1.2.3