/**
  * 调用视图文件的挂件(widget)
  *
  * 加载挂件内容,一般用在视图内容中
  *
  * @access public
  *
  * @param string $widgetName 所要加载的widget名称,注没有后缀名
  * @param array $params 所要传递的参数
  *
  * @return boolean
  */
 public static function widget($widgetName, $params = array())
 {
     //参数分析
     if (!$widgetName) {
         return false;
     }
     //分析Widget名称
     $widgetName = 'widgets.' . trim($widgetName) . 'Widget';
     Doit::singleton($widgetName)->renderContent($params);
     return true;
 }
Exemplo n.º 2
0
 /**
  * 构造函数
  *
  * @access public
  * @return boolean
  */
 public function __construct()
 {
     $this->_cookieObj = Doit::singleton('Cookie');
     return true;
 }
 /**
  * 加载并单例模式实例化扩展模块(通常为第三方程序)
  *
  *  注:这里所调用的扩展模声要放在项目extension目录里的子目录中
  *
  * @access public
  *
  * @param string $extensionName 扩展插件名称
  *
  * @access object
  */
 public static final function loadExtension($extensionName)
 {
     //参数分析
     if (!$extensionName) {
         return false;
     }
     //当所加载的扩展模块还示被实例化时
     if (!isset(self::$_extensionObjArray[$extensionName])) {
         //加载扩展模块的引导文件(index)
         $extensionPath = self::_getExtRoot($extensionName) . DS . $extensionName . 'Ext.php';
         Doit::loadFile($extensionPath);
         self::$_extensionObjArray[$extensionName] = Doit::singleton('extensions.' . $extensionName . 'Ext');
     }
     return self::$_extensionObjArray[$extensionName];
 }
Exemplo n.º 4
0
 /**
  * 设置某cookie变量的值
  *
  * @access public
  *
  * @param string $cookieName cookie的变量名
  * @param mixed $value cookie值
  * @param integer $expire cookie的生存周期
  * @param string $path cookie所存放的目录
  * @param string $domain cookie所支持的域名
  *
  * @return boolean
  */
 public function set($cookieName, $value, $expire = null, $path = null, $domain = null)
 {
     //参数分析
     if (!$cookieName) {
         return false;
     }
     $expire = is_null($expire) ? $this->_options['expire'] : $expire;
     $path = is_null($path) ? $this->_options['path'] : $path;
     $domain = is_null($domain) ? $this->_options['domain'] : $domain;
     $expire = $_SERVER['REQUEST_TIME'] + $this->_options['expire'];
     if ($this->_options['secretkey']) {
         $value = Doit::singleton('Encrypt')->encode(serialize($value), $this->_options['secretkey']);
     } else {
         $value = base64_encode(serialize($value));
     }
     setcookie($cookieName, $value, $expire, $path, $domain);
     $_COOKIE[$cookieName] = $value;
     return true;
 }