示例#1
0
 /**
  * Creates the requested SOAP server.
  * The SOAP server is initialized with the property values specified
  * in the configuration.
  * @return TSoapServer the SOAP server instance
  */
 protected function createServer()
 {
     $properties = $this->_servers[$this->_serverID];
     $serverClass = null;
     if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP && isset($config['class'])) {
         $serverClass = $config['class'];
     } else {
         if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML) {
             $serverClass = $properties->remove('class');
         }
     }
     if ($serverClass === null) {
         $serverClass = self::DEFAULT_SOAP_SERVER;
     }
     Prado::using($serverClass);
     $className = ($pos = strrpos($serverClass, '.')) !== false ? substr($serverClass, $pos + 1) : $serverClass;
     if ($className !== self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER)) {
         throw new TConfigurationException('soapservice_server_invalid', $serverClass);
     }
     $server = new $className();
     $server->setID($this->_serverID);
     foreach ($properties as $name => $value) {
         $server->setSubproperty($name, $value);
     }
     return $server;
 }
示例#2
0
文件: TPage.php 项目: pradosoft/prado
use Prado\Collections\TMap;
use Prado\Collections\TStack;
use Prado\Data\ActiveRecord\TActiveRecord;
use Prado\Exceptions\TConfigurationException;
use Prado\Exceptions\THttpException;
use Prado\Exceptions\TInvalidDataValueException;
use Prado\Exceptions\TInvalidDataTypeException;
use Prado\Exceptions\TInvalidOperationException;
use Prado\Prado;
use Prado\TPropertyValue;
use Prado\Web\Javascripts\TJavaScript;
use Prado\Web\UI\ActiveControls\TActivePageAdapter;
use Prado\Web\UI\ActiveControls\TCallbackClientScript;
use Prado\Web\UI\WebControls\THead;
Prado::using('System.Web.UI.*');
Prado::using('System.Web.UI.WebControls.*');
/**
 * TPage class
 *
 * @author Qiang Xue <*****@*****.**>
 * @package Prado\Web\UI
 * @since 3.0
 */
class TPage extends TTemplateControl
{
    /**
     * system post fields
     */
    const FIELD_POSTBACK_TARGET = 'PRADO_POSTBACK_TARGET';
    const FIELD_POSTBACK_PARAMETER = 'PRADO_POSTBACK_PARAMETER';
    const FIELD_LASTFOCUS = 'PRADO_LASTFOCUS';
示例#3
0
 /**
  * Creates the API provider instance for the current request
  * @param TRpcProtocol $protocolHandler instance
  * @param string $providerId
  */
 public function createApiProvider(TRpcProtocol $protocolHandler, $providerId)
 {
     $_properties = $this->apiProviders[$providerId];
     if (($_providerClass = $_properties->remove('class')) === null) {
         throw new TConfigurationException('rpcservice_apiprovider_required');
     }
     Prado::using($_providerClass);
     $_providerClassName = ($_pos = strrpos($_providerClass, '.')) !== false ? substr($_providerClass, $_pos + 1) : $_providerClass;
     if (!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER)) {
         throw new TConfigurationException('rpcservice_apiprovider_invalid');
     }
     if (($_rpcServerClass = $_properties->remove('server')) === null) {
         $_rpcServerClass = self::BASE_RPC_SERVER;
     }
     Prado::using($_rpcServerClass);
     $_rpcServerClassName = ($_pos = strrpos($_rpcServerClass, '.')) !== false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass;
     if ($_rpcServerClassName !== self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER)) {
         throw new TConfigurationException('rpcservice_rpcserver_invalid');
     }
     $_apiProvider = new $_providerClassName(new $_rpcServerClassName($protocolHandler));
     $_apiProvider->setId($providerId);
     foreach ($_properties as $_key => $_value) {
         $_apiProvider->setSubProperty($_key, $_value);
     }
     return $_apiProvider;
 }
示例#4
0
 /**
  * Creates a page instance based on requested page path.
  * @param string requested page path
  * @return TPage the requested page instance
  * @throws THttpException if requested page path is invalid
  * @throws TConfigurationException if the page class cannot be found
  */
 protected function createPage($pagePath)
 {
     $path = $this->getBasePath() . DIRECTORY_SEPARATOR . strtr($pagePath, '.', DIRECTORY_SEPARATOR);
     $hasTemplateFile = is_file($path . self::PAGE_FILE_EXT);
     $hasClassFile = is_file($path . Prado::CLASS_FILE_EXT);
     if (!$hasTemplateFile && !$hasClassFile) {
         throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
     }
     if ($hasClassFile) {
         $className = basename($path);
         $namespacedClassName = static::PAGE_NAMESPACE_PREFIX . str_replace('.', '\\', $pagePath);
         if (!class_exists($className, false) && !class_exists($namespacedClassName, false)) {
             include_once $path . Prado::CLASS_FILE_EXT;
         }
         if (!class_exists($className, false)) {
             $className = $namespacedClassName;
         }
     } else {
         $className = $this->getBasePageClass();
         Prado::using($className);
         if (($pos = strrpos($className, '.')) !== false) {
             $className = substr($className, $pos + 1);
         }
     }
     if (!class_exists($className, false) || $className !== 'TPage' && !is_subclass_of($className, 'TPage')) {
         throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
     }
     $page = Prado::createComponent($className);
     $page->setPagePath($pagePath);
     if ($hasTemplateFile) {
         $page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT));
     }
     return $page;
 }
示例#5
0
 protected function validateAttributes($type, $attributes)
 {
     Prado::using($type);
     if (($pos = strrpos($type, '.')) !== false) {
         $className = substr($type, $pos + 1);
     } else {
         $className = $type;
     }
     $class = new \ReflectionClass($className);
     if (is_subclass_of($className, '\\Prado\\Web\\UI\\TControl') || $className === '\\Prado\\Web\\UI\\TControl') {
         foreach ($attributes as $name => $att) {
             if (($pos = strpos($name, '.')) !== false) {
                 // a subproperty, so the first segment must be readable
                 $subname = substr($name, 0, $pos);
                 if (!$class->hasMethod('get' . $subname)) {
                     throw new TConfigurationException('template_property_unknown', $type, $subname);
                 }
             } else {
                 if (strncasecmp($name, 'on', 2) === 0) {
                     // an event
                     if (!$class->hasMethod($name)) {
                         throw new TConfigurationException('template_event_unknown', $type, $name);
                     } else {
                         if (!is_string($att)) {
                             throw new TConfigurationException('template_eventhandler_invalid', $type, $name);
                         }
                     }
                 } else {
                     // a simple property
                     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);
                         } else {
                             throw new TConfigurationException('template_property_unknown', $type, $name);
                         }
                     } else {
                         if (is_array($att) && $att[0] !== self::CONFIG_EXPRESSION) {
                             if (strcasecmp($name, 'id') === 0) {
                                 throw new TConfigurationException('template_controlid_invalid', $type);
                             } else {
                                 if (strcasecmp($name, 'skinid') === 0) {
                                     throw new TConfigurationException('template_controlskinid_invalid', $type);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         if (is_subclass_of($className, '\\Prado\\TComponent') || $className === '\\Prado\\TComponent') {
             foreach ($attributes as $name => $att) {
                 if (is_array($att) && $att[0] === self::CONFIG_DATABIND) {
                     throw new TConfigurationException('template_databind_forbidden', $type, $name);
                 }
                 if (($pos = strpos($name, '.')) !== false) {
                     // a subproperty, so the first segment must be readable
                     $subname = substr($name, 0, $pos);
                     if (!$class->hasMethod('get' . $subname)) {
                         throw new TConfigurationException('template_property_unknown', $type, $subname);
                     }
                 } else {
                     if (strncasecmp($name, 'on', 2) === 0) {
                         throw new TConfigurationException('template_event_forbidden', $type, $name);
                     } else {
                         // id is still alowed for TComponent, even if id property doesn't exist
                         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);
                             } else {
                                 throw new TConfigurationException('template_property_unknown', $type, $name);
                             }
                         }
                     }
                 }
             }
         } else {
             throw new TConfigurationException('template_component_required', $type);
         }
     }
 }
示例#6
0
 public function testUsingInterface()
 {
     $this->assertFalse(interface_exists(self::INTERFACE_SHORT_NAME, false));
     Prado::using(self::INTERFACE_FQN);
     $this->assertTrue(interface_exists(self::INTERFACE_SHORT_NAME, false));
 }
示例#7
0
 /**
  * Returns the WSDL content of the SOAP server.
  * If {@link getWsdlUri WsdlUri} is set, its content will be returned.
  * If not, the {@link setProvider Provider} class will be investigated
  * and the WSDL will be automatically genearted.
  * @return string the WSDL content of the SOAP server
  */
 public function getWsdl()
 {
     if ($this->_wsdlUri === '') {
         $provider = $this->getProvider();
         $providerClass = ($pos = strrpos($provider, '.')) !== false ? substr($provider, $pos + 1) : $provider;
         Prado::using($provider);
         if ($this->getApplication()->getMode() === TApplicationMode::Performance && ($cache = $this->getApplication()->getCache()) !== null) {
             $wsdl = $cache->get(self::WSDL_CACHE_PREFIX . $providerClass);
             if (is_string($wsdl)) {
                 return $wsdl;
             }
             $wsdl = WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding());
             $cache->set(self::WSDL_CACHE_PREFIX . $providerClass, $wsdl);
             return $wsdl;
         } else {
             return WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding());
         }
     } else {
         return file_get_contents($this->_wsdlUri);
     }
 }