summaryrefslogtreecommitdiff
path: root/framework/pradolite.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/pradolite.php')
-rw-r--r--framework/pradolite.php163
1 files changed, 126 insertions, 37 deletions
diff --git a/framework/pradolite.php b/framework/pradolite.php
index fcf73364..bdbf1137 100644
--- a/framework/pradolite.php
+++ b/framework/pradolite.php
@@ -1,7 +1,7 @@
<?php
/**
* File Name: pradolite.php
- * Last Update: 2014/02/02 21:38:53
+ * Last Update: 2015/12/07 15:35:09
* Generated By: buildscripts/phpbuilder/build.php
*
* This file is used in lieu of prado.php to boost PRADO application performance.
@@ -25,7 +25,7 @@ class PradoBase
protected static $classExists = array();
public static function getVersion()
{
- return '3.2.3';
+ return '3.3.0';
}
public static function initErrorHandlers()
{
@@ -47,8 +47,8 @@ class PradoBase
$url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName,'.gif'));
}
else
- $url='http://www.pradosoft.com/images/'.$logoName.'.gif';
- return '<a title="Powered by PRADO" href="http://www.pradosoft.com/" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>';
+ $url='http://pradosoft.github.io/docs/'.$logoName.'.gif';
+ return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>';
}
public static function phpErrorHandler($errno,$errstr,$errfile,$errline)
{
@@ -587,7 +587,7 @@ class TErrorHandler extends TModule
$isDebug = $this->getApplication()->getMode()===TApplicationMode::Debug;
$errorMessage = $exception->getMessage();
if($isDebug)
- $version=$_SERVER['SERVER_SOFTWARE'].' <a href="http://www.pradosoft.com/">PRADO</a>/'.Prado::getVersion();
+ $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
else
{
$version='';
@@ -600,18 +600,7 @@ class TErrorHandler extends TModule
'%%Version%%' => $version,
'%%Time%%' => @strftime('%Y-%m-%d %H:%M',time())
);
- $CGI=substr(php_sapi_name(), 0, 3) == 'cgi'; if($isDebug)
- {
- if ($CGI)
- header("Status: $statusCode ".$exception->getMessage(), true, TPropertyValue::ensureInteger($statusCode));
- else
- header("HTTP/1.0 $statusCode ".$exception->getMessage(), true, TPropertyValue::ensureInteger($statusCode));
- } else {
- if ($CGI)
- header("Status: $statusCode", true, TPropertyValue::ensureInteger($statusCode));
- else
- header("HTTP/1.0 $statusCode", true, TPropertyValue::ensureInteger($statusCode));
- }
+ $this->getApplication()->getResponse()->setStatusCode($statusCode, $isDebug ? $exception->getMessage() : null);
echo strtr($content,$tokens);
}
protected function handleRecursiveError($exception)
@@ -661,7 +650,7 @@ class TErrorHandler extends TModule
$source=$this->getSourceCode(@file($fileName),$errorLine);
}
if($this->getApplication()->getMode()===TApplicationMode::Debug)
- $version=$_SERVER['SERVER_SOFTWARE'].' <a href="http://www.pradosoft.com/">PRADO</a>/'.Prado::getVersion();
+ $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
else
$version='';
$tokens=array(
@@ -748,7 +737,7 @@ class TErrorHandler extends TModule
}
private function addLink($message)
{
- $baseUrl='http://www.pradosoft.com/docs/classdoc';
+ $baseUrl='http://pradosoft.github.io/docs/manual/class-';
return preg_replace('/\b(T[A-Z]\w+)\b/',"<a href=\"$baseUrl/\${1}\" target=\"_blank\">\${1}</a>",$message);
}
}
@@ -2385,7 +2374,7 @@ class TXmlDocument extends TXmlElement
{
return $this->saveToString();
}
- private function buildElement($node)
+ protected function buildElement($node)
{
$element=new TXmlElement($node->tagName);
$element->setValue($node->nodeValue);
@@ -2894,14 +2883,23 @@ class TJavaScript
}
public static function jsonEncode($value, $options = 0)
{
- if (is_string($value) &&
- ($g=Prado::getApplication()->getGlobalization(false))!==null &&
- strtoupper($enc=$g->getCharset())!='UTF-8')
- $value=iconv($enc, 'UTF-8', $value);
+ if (($g=Prado::getApplication()->getGlobalization(false))!==null &&
+ strtoupper($enc=$g->getCharset())!='UTF-8') {
+ self::convertToUtf8($value, $enc);
+ }
$s = @json_encode($value,$options);
self::checkJsonError();
return $s;
}
+ private static function convertToUtf8(&$value, $sourceEncoding) {
+ if(is_string($value))
+ $value=iconv($sourceEncoding, 'UTF-8', $value);
+ else if (is_array($value))
+ {
+ foreach($value as &$element)
+ self::convertToUtf8($element, $sourceEncoding);
+ }
+ }
public static function jsonDecode($value, $assoc = false, $depth = 512)
{
$s= @json_decode($value, $assoc, $depth);
@@ -3951,10 +3949,12 @@ class THttpResponse extends TModule implements ITextWriter
}
protected function sendHttpHeader()
{
- if (($version=$this->getRequest()->getHttpProtocolVersion())==='')
- header (' ', true, $this->_status);
- else
- header($version.' '.$this->_status.' '.$this->_reason, true, $this->_status);
+ $protocol=$this->getRequest()->getHttpProtocolVersion();
+ if($this->getRequest()->getHttpProtocolVersion() === null)
+ $protocol='HTTP/1.1';
+ $phpSapiName = substr(php_sapi_name(), 0, 3);
+ $cgi = $phpSapiName == 'cgi' || $phpSapiName == 'fpm';
+ header(($cgi ? 'Status:' : $protocol).' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status));
$this->_httpHeaderSent = true;
}
protected function ensureContentTypeHeaderSent()
@@ -4103,7 +4103,7 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
if($this->_customStorage)
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_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly());
if(ini_get('session.auto_start')!=='1')
session_start();
$this->_started=true;
@@ -4202,8 +4202,11 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
else
{
$value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode');
- if($value===THttpSessionCookieMode::None)
+ if($value===THttpSessionCookieMode::None)
+ {
ini_set('session.use_cookies','0');
+ ini_set('session.use_only_cookies','0');
+ }
else if($value===THttpSessionCookieMode::Allow)
{
ini_set('session.use_cookies','1');
@@ -4536,9 +4539,6 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
private $_stage=0;
private $_flags=0;
private $_rf=array();
- public function __construct()
- {
- }
public function __get($name)
{
if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name]))
@@ -5536,6 +5536,7 @@ interface IButtonControl
}
interface ISurroundable
{
+ public function getSurroundingTag();
public function getSurroundingTagID();
}
class TBroadcastEventParameter extends TEventParameter
@@ -6804,6 +6805,77 @@ class TTemplateControl extends TCompositeControl
throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this));
parent::initRecursive($namingContainer);
}
+ public function tryToUpdateView($arObj, $throwExceptions = false)
+ {
+ $objAttrs = get_class_vars(get_class($arObj));
+ foreach (array_keys($objAttrs) as $key)
+ {
+ try
+ {
+ if ($key != "RELATIONS")
+ {
+ $control = $this->{$key};
+ if ($control instanceof TTextBox)
+ $control->Text = $arObj->{$key};
+ elseif ($control instanceof TCheckBox)
+ $control->Checked = (boolean) $arObj->{$key};
+ elseif ($control instanceof TDatePicker)
+ $control->Date = $arObj->{$key};
+ }
+ else
+ {
+ foreach ($objAttrs["RELATIONS"] as $relKey => $relValues)
+ {
+ $relControl = $this->{$relKey};
+ switch ($relValues[0])
+ {
+ case TActiveRecord::BELONGS_TO:
+ case TActiveRecord::HAS_ONE:
+ $relControl->Text = $arObj->{$relKey};
+ break;
+ case TActiveRecord::HAS_MANY:
+ if ($relControl instanceof TListControl)
+ {
+ $relControl->DataSource = $arObj->{$relKey};
+ $relControl->dataBind();
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ catch (Exception $ex)
+ {
+ if ($throwExceptions)
+ throw $ex;
+ }
+ }
+ }
+ public function tryToUpdateAR($arObj, $throwExceptions = false)
+ {
+ $objAttrs = get_class_vars(get_class($arObj));
+ foreach (array_keys($objAttrs) as $key)
+ {
+ try
+ {
+ if ($key == "RELATIONS")
+ break;
+ $control = $this->{$key};
+ if ($control instanceof TTextBox)
+ $arObj->{$key} = $control->Text;
+ elseif ($control instanceof TCheckBox)
+ $arObj->{$key} = $control->Checked;
+ elseif ($control instanceof TDatePicker)
+ $arObj->{$key} = $control->Date;
+ }
+ catch (Exception $ex)
+ {
+ if ($throwExceptions)
+ throw $ex;
+ }
+ }
+ }
}
class TForm extends TControl
{
@@ -7078,7 +7150,7 @@ class TClientScriptManager extends TApplicationComponent
$this->registerPradoScriptInternal('jquery');
if($target instanceof TControl)
$target=$target->getClientID();
- $this->_endScripts['prado:focus'] = 'new Prado.Element.scrollTo(\''.$target.'\'); jQuery(\'#'.$target.'\').focus();';
+ $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();';
$params=func_get_args();
$this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params);
}
@@ -8944,7 +9016,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
}
else
{
- if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name)) )
+ if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) )
{
if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name))
throw new TConfigurationException('template_property_readonly',$type,$name);
@@ -8977,7 +9049,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
throw new TConfigurationException('template_event_forbidden',$type,$name);
else
{
- if(strcasecmp($name,'id')!==0 && !$class->hasMethod('set'.$name))
+ if(strcasecmp($name,'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)))
{
if($class->hasMethod('get'.$name))
throw new TConfigurationException('template_property_readonly',$type,$name);
@@ -9050,6 +9122,23 @@ class TTemplate extends TApplicationComponent implements ITemplate
}
return $input;
}
+ protected function isClassBehaviorMethod(ReflectionClass $class,$method)
+ {
+ $component=new ReflectionClass('TComponent');
+ $behaviors=$component->getStaticProperties();
+ if(!isset($behaviors['_um']))
+ return false;
+ foreach($behaviors['_um'] as $name=>$list)
+ {
+ if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue;
+ foreach($list as $param)
+ {
+ if(method_exists($param->getBehavior(),$method))
+ return true;
+ }
+ }
+ return false;
+ }
}
class TThemeManager extends TModule
{
@@ -9589,7 +9678,7 @@ class TPageService extends TService
}
if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage')))
throw new THttpException(404,'pageservice_page_unknown',$pagePath);
- $page=new $className;
+ $page=Prado::createComponent($className);
$page->setPagePath($pagePath);
if($hasTemplateFile)
$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT));