예제 #1
0
파일: User.php 프로젝트: laiello/quickbug
 /**
  * 发送通知
  *
  * @param unknown_type $uid 接收者用户ID或用户名,多个ID用","连接,如:"501,yuanwei"
  * @param unknown_type $msg 消息文本
  * @param unknown_type $url 连接地址
  * @param unknown_type $notifyType 通知类型 'rtx' | 'mail'
  * @param unknown_type $title 标题,可以为空
  */
 public static function notify($uids, $msg, $url, $notifyType, $title = '')
 {
     // 得到 userid 得到 username
     $usernames = $spr = '';
     $uidArr = explode(',', $uids);
     foreach ($uidArr as $uid) {
         $idtype = is_numeric($uid) ? 0 : 1;
         $uinfo = self::getInfo($uid, '', $idtype);
         $value = $notifyType == 'rtx' ? $uinfo['username'] : $uinfo['email'];
         if ($value) {
             $usernames .= $spr . $value;
             $spr = ',';
         }
     }
     // 找不到接收者则退出
     if ($usernames == '') {
         return;
     }
     // 发送对应的通知
     if ($title == '') {
         $title = 'QuickBug Notify';
     } else {
         $title = 'QuickBug-' . $title;
     }
     if ($notifyType == 'rtx') {
         Rtx::send($usernames, $msg, $url, $title);
     } else {
         $usernames = str_replace(',', ';', $usernames);
         $mailObj = new Qmail();
         $view = new QP_View();
         $contents = $view->render('/Common/Mail-tpl.html');
         $body = str_replace(array('{title}', '{msg}', '{url}'), array($title, $msg, $url), $contents);
         $mailObj->send($usernames, $title, $body);
     }
 }
예제 #2
0
파일: View.php 프로젝트: laiello/quickbug
 /**
  * 生成单个实例,这个方法框架会用到,APP中使用建议: new QP_View();
  *
  * @return Request object
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #3
0
 /**
  * 这样处理的机制是为了实现不至于任何情况下都装载 VIEW
  *
  * @param string $var
  * @return mixed
  */
 public function __get($var)
 {
     if ($var == 'view') {
         if (null === $this->_view) {
             $this->_view = QP_View::getInstance();
             // 给视图注册这个全局请求对象,方便视图的操作
             $this->_view->request = $this->request;
         }
         return $this->_view;
     }
     return $this->{$var};
 }
예제 #4
0
/**
 * 得到默认模板的内容
 *
 */
function getDefaultBugTpl()
{
    $view = new QP_View();
    return $view->render('/Common/Default-bugtpl.html');
}
예제 #5
0
 /**
  * 运行调度器
  *
  */
 public function run()
 {
     // APP运行的开始时间
     $this->_setDebugInfo('beginTime', microtime(true));
     // 运行应用的 Bootstrap
     require APPLICATION_PATH . '/Bootstrap.php';
     $bootStrap = new Bootstrap();
     $bootStrap->init();
     // 解析当前的URI(包括解析路由)
     $this->_parseUri();
     // 得到控制器
     $controller = $this->_getController();
     $action = $this->_action . 'Action';
     // 判断动作是否存在
     if (!method_exists($controller, $action)) {
         throw new QP_Exception('控制器:' . get_class($controller) . ' 中未定义动作:' . $action, QP_Exception::EXCEPTION_NO_ACTION);
     }
     // 选择的动作
     $this->_setDebugInfo('action', $action);
     // 把执行的输出先保存起来放到 Layout 中显示
     ob_start();
     // 执行 init 方法
     $controller->init();
     // 执行动作
     $controller->{$action}();
     // 得到所有输出内容
     $viewContent = ob_get_clean();
     // 是否自动输出视图
     if ($controller->viewIsAutoRender()) {
         $controller->view->setPath($this->_controllerPath);
         $viewContent .= $controller->view->render($this->_action . '.html');
         // 使用的视图
         $this->_setDebugInfo('view', $this->_action . '.html');
     }
     // 是否启用了 Layout
     if (QP_Layout::isEnabled()) {
         // 将 Layout 当作当前视图的一部分
         $view = QP_View::getInstance();
         $view->setPath(APPLICATION_PATH . '/Views/Layouts', true);
         // 将布局的变量与重新赋值给视图
         $view->assign(QP_Layout::get());
         // 'LayoutContent' 为框架的布局内容引用
         $view->LayoutContent = $viewContent;
         $layoutName = QP_Layout::name();
         $viewContent = $view->render($layoutName);
         // 使用的 Layout
         $this->_setDebugInfo('layout', $layoutName);
     }
     // 如果是 SAPI 运行模式就要设置字符集,防止乱码
     if (PHP_SAPI != 'cli') {
         header("Content-Type:text/html; charset=" . $this->_appConfig['charset']);
     }
     // 有视图内容则输出
     if ($viewContent != '') {
         echo $viewContent;
     }
     // APP运行的结束时间
     $this->_setDebugInfo('endTime', microtime(true));
     // 如果显示调试信息 并且 当前不是 AJAX 的请求 并且框架不是以 CLI方式运行
     if ($this->_appConfig['debug'] && !$this->_request->isAjax() && PHP_SAPI != 'cli') {
         $debugInfo = $this->_debugInfo;
         include QUICKPHP_PATH . '/Debug/Debuginfo.php';
     }
 }
예제 #6
0
 /**
  * 解析得到BUG的详细信息
  */
 private function bugHtml($bugid)
 {
     $view = new QP_View();
     $view->setPath('Bug');
     // 得到BUG详细信息
     $view->buginfo = $this->bugModel->bugInfo($bugid);
     // 得到所有的附件
     $view->doclist = $this->bugModel->bugDocList($bugid);
     // 所有的评论
     $view->commentlist = $this->bugModel->commentList($bugid);
     // 所有的操作历史
     $view->operatelist = $this->bugModel->operateList($bugid);
     return $view->render('Print.html');
 }
예제 #7
0
파일: Smarty.php 프로젝트: laiello/quickbug
 /**
  * 重载:返回解析后的视图
  *
  * @param string $name 视图名
  * @return string
  */
 public function render($name)
 {
     // 设置模块目录
     $this->_smarty->template_dir = $this->getPath();
     $file = $this->_smarty->template_dir . $name;
     // 检测视图文件是否存在
     if (!file_exists($file)) {
         require_once QUICKPHP_PATH . '/Exception.php';
         throw new QP_Exception("视图不存在:{$file}");
     }
     // 是否有全局设置
     $globalVal = QP_View::getGlobal();
     if ($globalVal) {
         $this->assign($globalVal);
     }
     // 把所有变量设置到 SMARTY 中
     $this->_smarty->assign($this->_vars);
     return $this->_smarty->fetch($file);
 }