diff options
Diffstat (limited to 'framework/Web/UI')
-rw-r--r-- | framework/Web/UI/TControl.php | 26 |
1 files changed, 26 insertions, 0 deletions
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.
|