summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TDatePicker.php
diff options
context:
space:
mode:
authorwei <>2007-04-06 04:28:46 +0000
committerwei <>2007-04-06 04:28:46 +0000
commit34772099513df0734d3149e7b6d2d011f1f5e5e7 (patch)
treea3a348b0c2c7ca4c9034b9f3274d1c8547e91fa6 /framework/Web/UI/WebControls/TDatePicker.php
parentf9259279765279b63f4e80e3e62e2b90cdae247c (diff)
refactor client scripts.
Diffstat (limited to 'framework/Web/UI/WebControls/TDatePicker.php')
-rw-r--r--framework/Web/UI/WebControls/TDatePicker.php48
1 files changed, 16 insertions, 32 deletions
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php
index 3e85ffb9..dd922431 100644
--- a/framework/Web/UI/WebControls/TDatePicker.php
+++ b/framework/Web/UI/WebControls/TDatePicker.php
@@ -67,6 +67,11 @@ Prado::using('System.Web.UI.WebControls.TTextBox');
class TDatePicker extends TTextBox
{
/**
+ * Script path relative to the TClientScriptManager::SCRIPT_PATH
+ */
+ const SCRIPT_PATH = 'prado/datepicker';
+
+ /**
* @var TDatePickerClientScript validator client-script options.
*/
private $_clientScript;
@@ -735,7 +740,7 @@ class TDatePicker extends TTextBox
protected function renderImageButtonDatePicker($writer)
{
$url = $this->getButtonImageUrl();
- $url = empty($url) ? $this->publishDefaultButtonImage() : $url;
+ $url = empty($url) ? $this->getAssetUrl('calendar.png') : $url;
$writer->addAttribute('id', $this->getDatePickerButtonID());
$writer->addAttribute('src', $url);
$writer->addAttribute('alt', ' ');
@@ -747,16 +752,13 @@ class TDatePicker extends TTextBox
}
/**
- * Publish the default button image asset file.
- * @return string image file url.
+ * @param string date picker asset file in the self::SCRIPT_PATH directory.
+ * @return string date picker asset url.
*/
- protected function publishDefaultButtonImage()
+ protected function getAssetUrl($file='')
{
- $image = 'System.Web.Javascripts.prado.datepicker.calendar';
- if(($file = Prado::getPathOfNamespace($image, '.png'))!==null)
- return $this->publishFilePath($file);
- else
- throw new TConfigurationException('datepicker_defaultbuttonimage_invalid',$image);
+ $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl();
+ return $base.'/'.self::SCRIPT_PATH.'/'.$file;
}
/**
@@ -765,29 +767,11 @@ class TDatePicker extends TTextBox
*/
protected function publishCalendarStyle()
{
+ $url = $this->getAssetUrl($this->getCalendarStyle().'.css');
$cs = $this->getPage()->getClientScript();
- $style = 'System.Web.Javascripts.prado.datepicker.'.$this->getCalendarStyle();
- if(($cssFile=Prado::getPathOfNamespace($style,'.css'))!==null)
- {
- $url = $this->publishFilePath($cssFile);
- if(!$cs->isStyleSheetFileRegistered($style))
- $cs->registerStyleSheetFile($style, $url);
- return $url;
- }
- else
- throw new TConfigurationException('datepicker_calendarstyle_invalid',$style);
- }
-
- /**
- * Publish the spacer.gif for IE iframe source.
- * @return string the URL for the spacer.gif.
- */
- protected function publishIFrameSpacer()
- {
- $cs = $this->getPage()->getClientScript();
- $spacer = 'System.Web.Javascripts.prado.datepicker.spacer';
- if(($file = Prado::getPathOfNamespace($spacer,'.gif')) != null)
- return $this->publishFilePath($file);
+ if(!$cs->isStyleSheetFileRegistered($url))
+ $cs->registerStyleSheetFile($url, $url);
+ return $url;
}
/**
@@ -814,7 +798,7 @@ class TDatePicker extends TTextBox
if(!$cs->isEndScriptRegistered('TDatePicker.spacer'))
{
- $spacer = $this->publishIFrameSpacer();
+ $spacer = $this->getAssetUrl('spacer.gif');
$code = "Prado.WebUI.TDatePicker.spacer = '$spacer';";
$cs->registerEndScript('TDatePicker.spacer', $code);
}