コード例 #1
0
 /**
  * @return WindHttpRequest
  */
 public function getRequest()
 {
     if ($this->_request === null) {
         $this->_request = WindFactory::createInstance('WindCommandRequest');
     }
     return $this->_request;
 }
コード例 #2
0
ファイル: pwadminBoot.php プロジェクト: ccq18/EduSoho
 public function beforeStart($front = null)
 {
     parent::beforeStart($front);
     if (!Wind::getComponent('router')->getRoute('pw')) {
         Wind::getComponent('router')->addRoute('pw', WindFactory::createInstance(Wind::import('LIB:route.PwRoute'), array('bbs')));
     }
 }
コード例 #3
0
ファイル: phpwindBoot.php プロジェクト: ccq18/EduSoho
 /**
  * 构造函数
  */
 public function __construct($re)
 {
     if (!is_file(Wind::getRealPath('DATA:install.lock', true))) {
         Wind::getComponent('response')->sendRedirect("install.php");
     }
     parent::__construct($re);
     //云应用监听sql执行
     WindFactory::_getInstance()->loadClassDefinitions(array('sqlStatement' => array('proxy' => 'WIND:filter.proxy.WindEnhancedClassProxy', 'listeners' => array('LIB:compile.acloud.PwAcloudDbListener'))));
     $this->charset = Wind::getComponent('response')->getCharset();
 }
コード例 #4
0
ファイル: PwCompile.php プロジェクト: ccq18/EduSoho
 public function preHandle()
 {
     if (!($compilers = $this->getCompiler())) {
         return;
     }
     /* @var $chain WindHandlerInterceptorChain */
     $chain = WindFactory::createInstance('WindHandlerInterceptorChain');
     foreach ($compilers as $key => $value) {
         $_compiler = Wind::import($value);
         $chain->addInterceptors(array($key => new $_compiler()));
     }
     $chain->getHandler()->handle();
 }
コード例 #5
0
 /**
  * 解析action过滤链的配置信息
  * 
  * @param WindSimpleController $handler        
  * @return void
  */
 protected function resolveActionFilters(&$handler)
 {
     if (!($filters = $this->getConfig('filters'))) {
         return;
     }
     /* @var $cache AbstractWindCache */
     $_filters = array();
     if ($cache = Wind::getComponent('windCache')) {
         $_filters = $cache->get('filters');
     }
     $_token = $this->handlerAdapter->getModule() . '/' . $this->handlerAdapter->getController() . '/' . $this->handlerAdapter->getAction();
     if (!isset($_filters[$_token])) {
         foreach ($filters as $_filter) {
             if (empty($_filter['class'])) {
                 continue;
             }
             $_pattern = empty($_filter['pattern']) ? '' : $_filter['pattern'];
             unset($_filter['pattern']);
             if ($_pattern) {
                 $_pattern = str_replace(array('*', '/'), array('\\w*', '\\/'), $_pattern);
                 if (in_array($_pattern[0], array('~', '!'))) {
                     $_pattern = substr($_pattern, 1);
                     if (preg_match('/^' . $_pattern . '$/i', $_token)) {
                         continue;
                     }
                 } else {
                     if (!preg_match('/^' . $_pattern . '$/i', $_token)) {
                         continue;
                     }
                 }
             }
             $_filters[$_token][] = $_filter;
         }
         $cache && $cache->set('filters', $_filters);
     }
     if (empty($_filters[$_token])) {
         return;
     }
     /* @var $proxy WindClassProxy */
     $proxy = WindFactory::createInstance(Wind::import('WIND:filter.proxy.WindClassProxy'));
     $proxy->registerTargetObject($handler);
     foreach ($_filters[$_token] as $value) {
         $proxy->registerEventListener($this->factory->createInstance(Wind::import($value['class']), array($handler->getForward(), $handler->getErrorMessage(), $this->handlerAdapter, $value)), 'doAction');
     }
     $handler = $proxy;
 }
コード例 #6
0
ファイル: AbstractWindRouter.php プロジェクト: ccq18/EduSoho
 public function setConfig($config)
 {
     parent::setConfig($config);
     if ($this->_config) {
         $this->_module = $this->getConfig('module', 'default-value', $this->_module);
         $this->_controller = $this->getConfig('controller', 'default-value', $this->_controller);
         $this->_action = $this->getConfig('action', 'default-value', $this->_action);
         $this->moduleKey = $this->getConfig('module', 'url-param', $this->moduleKey);
         $this->controllerKey = $this->getConfig('controller', 'url-param', $this->controllerKey);
         $this->actionKey = $this->getConfig('action', 'url-param', $this->actionKey);
         foreach ($this->getConfig('routes', '', array()) as $routeName => $route) {
             if (!isset($route['class'])) {
                 continue;
             }
             $instance = WindFactory::createInstance(Wind::import($route['class']));
             $instance->setConfig($route);
             $this->addRoute($routeName, $instance, isset($route['default']) && $route['default'] === true);
         }
     }
 }
コード例 #7
0
 public function preHandle()
 {
     if (!$this->form) {
         return null;
     }
     $className = Wind::import($this->form);
     $form = WindFactory::createInstance($className);
     $methods = get_class_methods($form);
     foreach ($methods as $method) {
         if (0 !== strpos($method, 'set') || '' == ($_tmp = substr($method, 3))) {
             continue;
         }
         if (null === ($input = $this->getRequest()->getRequest(WindUtility::lcfirst($_tmp), null))) {
             continue;
         }
         call_user_func_array(array($form, $method), array($input));
     }
     $form->validate();
     $this->getRequest()->setAttribute($form, WindUtility::lcfirst($className));
     $this->sendError($form->getErrorAction(), $form->getErrors());
 }
コード例 #8
0
ファイル: PwFrontFilters.php プロジェクト: fanqimeng/4tweb
 public function onCreate()
 {
     if (in_array(Wind::getAppName(), array('phpwind', 'pwadmin'))) {
         //云应用监听sql执行
         WindFactory::_getInstance()->loadClassDefinitions(array('sqlStatement' => array('proxy' => 'WIND:filter.proxy.WindEnhancedClassProxy', 'listeners' => array('LIB:compile.acloud.PwAcloudDbListener'))));
     }
     if (!is_file(Wind::getRealPath('DATA:install.lock', true))) {
         Wind::getApp()->getResponse()->sendRedirect("install.php");
     }
     Wekit::createapp(Wind::getAppName());
     $_debug = Wekit::C('site', 'debug');
     if ($_debug == !Wind::$isDebug) {
         Wind::$isDebug = $_debug;
     }
     if ('phpwind' == Wind::getAppName()) {
         error_reporting($_debug ? E_ALL ^ E_NOTICE ^ E_DEPRECATED : E_ERROR | E_PARSE);
         set_error_handler(array($this->front, '_errorHandle'), error_reporting());
     }
     $this->_convertCharsetForAjax();
     if ($components = Wekit::C('components')) {
         Wind::getApp()->getFactory()->loadClassDefinitions($components);
     }
 }
コード例 #9
0
 /**
  * 创建并返回过滤链,如果过滤链已经被创建不重复创建
  * 
  * @return WindHandlerInterceptorChain
  * @throws WindException
  */
 private function _getInterceptorChain()
 {
     if (null === $this->_interceptorChain) {
         $chain = Wind::import($this->_class_interceptorChain);
         $this->_interceptorChain = WindFactory::createInstance($chain);
         $this->_interceptorChain->addInterceptors($this->_listener);
     }
     return $this->_interceptorChain;
 }
コード例 #10
0
ファイル: WindFactory.php プロジェクト: fanqimeng/4tweb
 /**
  * 返回组建工厂单例对象
  *
  * @return WindFactory
  */
 public static function _getInstance()
 {
     if (!self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #11
0
 /**
  * 创建并执行当前应用,单应用访问入口
  */
 public function run()
 {
     $this->_app = $this->createApplication($this->_config['web-apps'][$this->_appName], WindFactory::_getInstance());
     set_error_handler(array($this, '_errorHandle'), error_reporting());
     set_exception_handler(array($this, '_exceptionHandle'));
     if ($this->_config['isclosed']) {
         throw new Exception('Sorry, Site has been closed!');
     }
     if ($this->_chain !== null) {
         $this->_chain->getHandler()->handle('onCreate');
     }
     /* @var $router WindRouter */
     $router = $this->_app->getFactory()->getInstance('router');
     $router->route($this->_app->getRequest());
     if ($this->_chain !== null) {
         $this->_chain->getHandler()->handle('onStart');
     }
     $this->_app->run($router);
     if ($this->_chain !== null) {
         $this->_chain->getHandler()->handle('onResponse');
     }
     $this->_app->getResponse()->sendResponse();
     $this->_app->getFactory()->executeDestroyMethod();
     restore_error_handler();
     restore_exception_handler();
 }
コード例 #12
0
 public function beforeStart($front = null)
 {
     parent::beforeStart($front);
     if (!Wind::getComponent('router')->getRoute('pw')) {
         Wind::getComponent('router')->addRoute('pw', WindFactory::createInstance(Wind::import('LIB:route.PwRoute'), array('bbs')));
     }
     Wind::getComponent('router')->addRoute('admin', WindFactory::createInstance(Wind::import('LIB:route.PwAdminRoute'), array('default')), true);
     Wekit::setapp('windid', Wekit::app());
 }
コード例 #13
0
 /**
  * action过滤链策略部署
  * 
  * @example <pre>
  *          $filters = array(array('expression'=>'', 'class'=>'',
  *          args=array()));
  *          </pre>
  * @param array $filters
  * @return void
  */
 protected function resolveActionFilter($filters)
 {
     if (!$filters) {
         return;
     }
     $chain = WindFactory::createInstance('WindHandlerInterceptorChain');
     $args = array($this->getForward(), $this->getErrorMessage(), null);
     foreach ((array) $filters as $value) {
         $chain->addInterceptors(WindFactory::createInstance(Wind::import($value['class']), empty($value['args']) ? $args : array_merge($args, array($value['args']))));
     }
     $chain->getHandler()->handle();
 }
コード例 #14
0
ファイル: WindClassProxy.php プロジェクト: ccq18/EduSoho
 /**
  * 创建并返回过滤链,如果过滤链已经被创建不重复创建
  * 
  * @param string $event 事件名称 默认值为空
  * @return WindHandlerInterceptorChain
  * @throws WindException
  */
 private function _getInterceptorChain($event = '')
 {
     if (null === $this->_interceptorChain) {
         $chain = Wind::import($this->_class_interceptorChain);
         $this->_interceptorChain = WindFactory::createInstance($chain);
     }
     $this->_interceptorChain->reset();
     return $this->_interceptorChain;
 }
コード例 #15
0
 /**
  * 创建并返回过滤链,如果过滤链已经被创建不重复创建
  * 
  * @param string $event 事件名称 默认值为空
  * @return WindHandlerInterceptorChain
  * @throws WindException
  */
 private function _getInterceptorChain($event = '')
 {
     if (null === $this->_interceptorChainObj) {
         $chain = Wind::import($this->_interceptorChain);
         $interceptorChain = WindFactory::createInstance($chain);
         if ($interceptorChain && $interceptorChain instanceof WindHandlerInterceptorChain) {
             $this->_interceptorChainObj = $interceptorChain;
         } else {
             throw new WindException('[base.WindClassProxy._getInterceptorChain] Unable to create interceptorChain.');
         }
     }
     $this->_interceptorChainObj->reset();
     return $this->_interceptorChainObj;
 }
コード例 #16
0
 /**
  * 返回验证器
  * 
  * @return WindValidator
  * @throws WindException 验证器创建失败抛出异常
  */
 protected function getValidator()
 {
     if ($this->_validator === null) {
         $_className = Wind::import($this->_validatorClass);
         $this->_validator = WindFactory::createInstance($_className);
         if ($this->_validator === null) {
             throw new WindException('[base.WindEnableValidateModule.getValidator] validator', WindException::ERROR_RETURN_TYPE_ERROR);
         }
     }
     return $this->_validator;
 }
コード例 #17
0
ファイル: WindMail.php プロジェクト: jellycheng/windframework
 /**
  * 发送邮件
  *
  * @param string $type 发送类型
  * @param array $config 邮件发送器需要的配置数据
  * @return boolean
  */
 public function send($type = self::SEND_SMTP, $config = array())
 {
     try {
         $class = Wind::import('Wind:mail.sender.Wind' . ucfirst($type) . 'Mail');
         /* @var $sender IWindSendMail */
         $sender = WindFactory::createInstance($class);
         return $sender->send($this, $config);
     } catch (Exception $e) {
         if (WIND_DEBUG & 2) {
             Wind::getApp()->getComponent('windLogger')->info('[mail.WindMail.send] send mail fail. ' . $e->getMessage(), 'windmail');
         }
         if (WIND_DEBUG & 1) {
             throw new WindMailException('[mail.WindMail.send] send mail fail.' . $e->getMessage());
         }
         return false;
     }
 }
コード例 #18
0
 /**
  * 获得组件对象
  *
  * @param string $componentName 组件名称呢个
  * @return object
  */
 public function getComponent($componentName, $args = array())
 {
     return $this->windFactory->getInstance($componentName, $args);
 }
コード例 #19
0
ファイル: Wind.php プロジェクト: fanqimeng/4tweb
 /**
  * 注册系统组建
  * <code>
  * 对象方式注册:
  * $converter = new WindGeneralConverter();
  * Wind::registeComponent($converter,'windConverter',singleton);
  * 定义方式注册:
  * Wind::registeComponent(array('path' =>
  * 'WIND:convert.WindGeneralConverter', 'scope' => 'singleton'),
  * 'windConverter');</code>
  * 
  * @param object|array $componentInstance        
  * @param string $componentName        
  * @param string $scope        
  * @return boolean
  */
 public static function registeComponent($componentInstance, $componentName, $scope = 'application')
 {
     if (is_array($componentInstance)) {
         isset($componentInstance['scope']) || ($componentInstance['scope'] = $scope);
         WindFactory::_getInstance()->loadClassDefinitions(array($componentName => $componentInstance));
     } elseif (is_object($componentInstance)) {
         WindFactory::_getInstance()->registInstance($componentInstance, $componentName, $scope);
     } else {
         throw new WindException('[Wind.registeComponent] registe component fail, array or object is required', WindException::ERROR_PARAMETER_TYPE_ERROR);
     }
 }
コード例 #20
0
 /** 
  * 需要发送新用户激活邮件
  * 
  * @param string $username 用户名
  * @param string $email 用户邮件
  * @param string $statu 激活标志
  * @param int $uid 用户ID
  * @return boolean
  */
 public function sendEmailActive($username, $email, $statu = '', $uid = 0)
 {
     if (!$this->config['active.mail']) {
         return true;
     }
     if ($uid == 0 || !$statu) {
         $info = $this->_getUserDs()->getUserByName($username, PwUser::FETCH_MAIN);
         if ($info['email'] != $email) {
             return new PwError('USER:illegal.request');
         }
         $uid = $info['uid'];
         $statu = self::createRegistIdentify($uid, $info['password']);
     }
     if (!Wind::getComponent('router')->getRoute('pw')) {
         Wind::getComponent('router')->addRoute('pw', WindFactory::createInstance(Wind::import('LIB:route.PwRoute'), array('bbs')));
     }
     $code = substr(md5(Pw::getTime()), mt_rand(1, 8), 8);
     $url = WindUrlHelper::createUrl('u/register/activeEmail', array('code' => $code, '_statu' => $statu), '', 'pw');
     list($title, $content) = $this->_buildTitleAndContent('active.mail.title', 'active.mail.content', $username, $url);
     /* @var $activeCodeDs PwUserActiveCode */
     $activeCodeDs = Wekit::load('user.PwUserActiveCode');
     $activeCodeDs->addActiveCode($uid, $email, $code, Pw::getTime());
     $mail = new PwMail();
     $mail->sendMail($email, $title, $content);
     return true;
 }
コード例 #21
0
ファイル: WindMail.php プロジェクト: ccq18/EduSoho
 /**
  * 发送邮件
  * 
  * @param string $type 发送类型
  * @param array $config 邮件发送器需要的配置数据
  * @return boolean
  * @throws Exception
  */
 public function send($type = self::SEND_SMTP, $config = array())
 {
     $class = Wind::import('Wind:mail.sender.Wind' . ucfirst($type) . 'Mail');
     /* @var $sender IWindSendMail */
     $sender = WindFactory::createInstance($class);
     return $sender->send($this, $config);
 }
コード例 #22
0
ファイル: pwadminBoot.php プロジェクト: fanqimeng/4tweb
 public function init($front = null)
 {
     parent::init($front);
     Wind::getComponent('router')->getRoute('pw') || Wind::getComponent('router')->addRoute('pw', WindFactory::createInstance(Wind::import('LIB:route.PwRoute')));
     Wind::getComponent('router')->addRoute('admin', WindFactory::createInstance(Wind::import('LIB:route.AdminRoute')), true);
 }
コード例 #23
0
ファイル: WindModule.php プロジェクト: ccq18/EduSoho
 /**
  * 重载了魔术方法__call
  * 当类的方法访问不到时调用该方法,在这里的实现是配置类属性对象的延迟加载策略
  * <code>
  * //延迟访问某个属性,当使用这种方式调用时该方法被调用,并访问该类中的$_delayAttributes属性,并创建该属性对象并返回
  * $this->_getMethodName();
  * </code>
  * 
  * @param string $methodName
  * @param array $args
  * @return mixed
  */
 public function __call($methodName, $args)
 {
     $_prefix = substr($methodName, 0, 4);
     $_propertyName = substr($methodName, 4);
     $_propertyName = WindUtility::lcfirst($_propertyName);
     if ($_prefix == '_get') {
         if (!$this->{$_propertyName} && isset($this->_delayAttributes[$_propertyName])) {
             $_property = $this->_delayAttributes[$_propertyName];
             $_value = null;
             if (isset($_property['value'])) {
                 $_value = $_property['value'];
             } elseif (isset($_property['ref'])) {
                 $_value = Wind::getComponent($_property['ref'], $args);
             } elseif (isset($_property['path'])) {
                 $_className = Wind::import($_property['path']);
                 $_value = WindFactory::createInstance($_className, $args);
             }
             $this->{$_propertyName} = $_value;
         }
         return $this->{$_propertyName};
     } elseif ($_prefix == '_set') {
         $this->{$_propertyName} = $args[0];
     }
 }