summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/THttpRequest.php53
-rw-r--r--framework/Web/THttpSession.php15
-rw-r--r--framework/Web/UI/TTemplateControl.php2
-rw-r--r--framework/Web/UI/WebControls/TDatePicker.php33
4 files changed, 77 insertions, 26 deletions
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index 01827f33..130dc3cf 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -57,13 +57,12 @@
* @package System.Web
* @since 3.0
*/
-class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,IModule
+class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule
{
/**
* Separator used to separate GET variable name and value when URL format is Path.
*/
- const URL_PARAM_SEPARATOR=',';
-
+ private $_separator=',';
/**
* @var boolean whether the module is initialized
*/
@@ -227,6 +226,26 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
}
/**
+ * @return string separator used to separate GET variable name and value when URL format is Path. Defaults to comma ','.
+ */
+ public function getUrlParamSeparator()
+ {
+ return $this->_separator;
+ }
+
+ /**
+ * @param string separator used to separate GET variable name and value when URL format is Path.
+ * @throws TInvalidDataValueException if the separator is not a single character
+ */
+ public function setUrlParamSeparator($value)
+ {
+ if(strlen($value)===1)
+ $this->_separator=$value;
+ else
+ throw new TInvalidDataValueException('httprequest_separator_invalid');
+ }
+
+ /**
* @return string request type, can be GET, POST, HEAD, or PUT
*/
public function getRequestType()
@@ -460,10 +479,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
*/
public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=false,$encodeGetItems=true)
{
- if($this->getUrlFormat()==='Path')
- $url=$serviceID.'/'.$serviceParam;
- else
- $url=$serviceID.'='.$serviceParam;
+ $url=$serviceID.'='.$serviceParam;
$amp=$encodeAmpersand?'&':'&';
if(is_array($getItems) || $getItems instanceof Traversable)
{
@@ -497,7 +513,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
}
if($this->getUrlFormat()==='Path')
{
- $url=strtr($url,array($amp=>'/','?'=>'/','='=>self::URL_PARAM_SEPARATOR));
+ $url=strtr($url,array($amp=>'/','?'=>'/','='=>$this->_separator));
if(defined('SID') && SID != '' && !((int)ini_get('session.use_cookies')===1 && ((int)ini_get('session.use_only_cookies')===1)))
$url.='?'.SID;
return $this->getApplicationUrl().'/'.$url;
@@ -523,13 +539,12 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
{
$paths=explode('/',$this->_pathInfo);
$getVariables=$_GET;
- $index=0;
$serviceID=null;
foreach($paths as $path)
{
if(($path=trim($path))!=='')
{
- if(($pos=strpos($path,','))!==false)
+ if(($pos=strpos($path,$this->_separator))!==false)
{
$name=substr($path,0,$pos);
$value=substr($path,$pos+1);
@@ -538,16 +553,8 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
else
$getVariables[$name]=$value;
}
- else if($index===0)
- {
- $serviceID=$path;
- $getVariables[$serviceID]='';
- }
- else if($index===1 && $serviceID!==null)
- $getVariables[$serviceID]=$path;
else
$getVariables[$path]='';
- $index++;
}
}
return $getVariables;
@@ -654,6 +661,16 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
}
/**
+ * Returns the number of items in the request.
+ * This method is required by Countable interface.
+ * @return integer number of items in the request.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
+
+ /**
* @return array the key list
*/
public function getKeys()
diff --git a/framework/Web/THttpSession.php b/framework/Web/THttpSession.php
index 4439cf57..19473cda 100644
--- a/framework/Web/THttpSession.php
+++ b/framework/Web/THttpSession.php
@@ -61,7 +61,7 @@
* @package System.Web
* @since 3.0
*/
-class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,IModule
+class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule
{
/**
* @var boolean whether this module has been initialized
@@ -139,7 +139,8 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc'));
if($this->_cookie!==null)
session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure());
- session_start();
+ if(ini_get('session.auto_start')!=='1')
+ session_start();
$this->_started=true;
}
}
@@ -487,6 +488,16 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
}
/**
+ * Returns the number of items in the session.
+ * This method is required by Countable interface.
+ * @return integer number of items in the session.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
+
+ /**
* @return array the list of session variable names
*/
public function getKeys()
diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php
index c7364d4b..3bbe52c5 100644
--- a/framework/Web/UI/TTemplateControl.php
+++ b/framework/Web/UI/TTemplateControl.php
@@ -129,7 +129,7 @@ class TTemplateControl extends TCompositeControl
*/
public function createChildControls()
{
- if($tpl=$this->getTemplate(true))
+ if($tpl=$this->getTemplate())
{
foreach($tpl->getDirective() as $name=>$value)
{
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php
index 27d080c6..42cb305e 100644
--- a/framework/Web/UI/WebControls/TDatePicker.php
+++ b/framework/Web/UI/WebControls/TDatePicker.php
@@ -69,6 +69,15 @@ Prado::using('System.Web.UI.WebControls.TTextBox');
class TDatePicker extends TTextBox
{
/**
+ * AutoPostBack is not supported.
+ */
+ public function setAutoPostBack($value)
+ {
+ throw new TNotSupportedException('tdatepicker_autopostback_unsupported',
+ get_class($this));
+ }
+
+ /**
* @return string the format of the date string
*/
public function getDateFormat()
@@ -328,7 +337,7 @@ class TDatePicker extends TTextBox
*/
protected function renderDatePickerButtons($writer)
{
- if($this->getShowCalendar())
+ if($this->getShowCalendar() && $this->getEnabled(true))
{
switch ($this->getMode())
{
@@ -384,7 +393,9 @@ class TDatePicker extends TTextBox
$year = intval($values[$key.'$year']);
else
$year = $date['year'];
+
$date = @mktime(0, 0, 0, $month, $day, $year);
+
$pattern = $this->getDateFormat();
$pattern = str_replace(array('MMMM', 'MMM'), array('MM','MM'), $pattern);
$formatter = Prado::createComponent('System.Util.TSimpleDateFormatter', $pattern);
@@ -497,12 +508,13 @@ class TDatePicker extends TTextBox
{
$formatter = Prado::createComponent('System.Util.TSimpleDateFormatter',
$this->getDateFormat());
+
foreach($formatter->getDayMonthYearOrdering() as $type)
{
if($type == 'day')
$this->renderCalendarDayOptions($writer,$date['mday']);
elseif($type == 'month')
- $this->renderCalendarMonthOptions($writer,$date['mon']-1);
+ $this->renderCalendarMonthOptions($writer,$date['mon']);
elseif($type == 'year')
$this->renderCalendarYearOptions($writer,$date['year']);
}
@@ -550,6 +562,8 @@ class TDatePicker extends TTextBox
$writer->addAttribute('id', $this->getClientID().'_day');
$writer->addAttribute('name', $this->getUniqueID().'$day');
$writer->addAttribute('class', 'datepicker_day_options');
+ if($this->getReadOnly() || !$this->getEnabled(true))
+ $writer->addAttribute('disabled', 'disabled');
$writer->renderBeginTag('select');
$this->renderDropDownListOptions($writer, $days, $selected);
$writer->renderEndTag();
@@ -562,13 +576,16 @@ class TDatePicker extends TTextBox
*/
protected function renderCalendarMonthOptions($writer, $selected=null)
{
+
$info = $this->getLocalizedCalendarInfo();
$writer->addAttribute('id', $this->getClientID().'_month');
$writer->addAttribute('name', $this->getUniqueID().'$month');
$writer->addAttribute('class', 'datepicker_month_options');
+ if($this->getReadOnly() || !$this->getEnabled(true))
+ $writer->addAttribute('disabled', 'disabled');
$writer->renderBeginTag('select');
$this->renderDropDownListOptions($writer,
- $this->getLocalizedMonthNames($info), $selected);
+ $this->getLocalizedMonthNames($info), $selected-1);
$writer->renderEndTag();
}
@@ -585,8 +602,12 @@ class TDatePicker extends TTextBox
$this->getDateFormat());
switch($formatter->getMonthPattern())
{
- case 'MMM':
- case 'MM': return $info->getAbbreviatedMonthNames();
+ case 'MMM': return $info->getAbbreviatedMonthNames();
+ case 'MM':
+ $array = array();
+ for($i=1;$i<=12;$i++)
+ $array[$i-1] = $i < 10 ? '0'.$i : $i;
+ return $array;
case 'M':
$array = array(); for($i=1;$i<=12;$i++) $array[$i-1] = $i;
return $array;
@@ -606,6 +627,8 @@ class TDatePicker extends TTextBox
$years[$i] = $i;
$writer->addAttribute('id', $this->getClientID().'_year');
$writer->addAttribute('name', $this->getUniqueID().'$year');
+ if($this->getReadOnly() || !$this->getEnabled(true))
+ $writer->addAttribute('disabled', 'disabled');
$writer->renderBeginTag('select');
$writer->addAttribute('class', 'datepicker_year_options');
$this->renderDropDownListOptions($writer, $years, $selected);