Esempio n. 1
0
 function __construct($scriptPath = "")
 {
     parent::__construct($scriptPath);
     //这里默认设置一些数据
     //包括 Header Title Css CharSet
     //XSLT等
     //其他一些数据等...
 }
Esempio n. 2
0
 /**
  * @todo 解决和dialog重复的问题
  *
  * @param boolean $show
  * @return string
  */
 public function render($show = true)
 {
     ob_start();
     /**
      * ajax 也要显示显示 Tq消息
      * Tq消息要在 tip 之前
      * ajax不显示消息, 此时消息存在 session 里,下次统一发送
      */
     //echo Tpm_Message_Sender_Tq::getMsgHtml();
     /**
      * 这里显示主体部分
      */
     parent::render(true);
     $out = ob_get_clean();
     if ($show) {
         echo $out;
     }
     //如果输出debug信息, Ajax会不爽
     Watt_Debug::getDefaultDebug()->clearDebugInfo();
     return $out;
 }
Esempio n. 3
0
 /**
  * 职责变了,这个方法没有用了
  *
  * @param boolean $show
  * @return string
  */
 public function render($show = true)
 {
     /**
      * 是否输出主体
      */
     $outputBody = true;
     ob_start();
     //echo "Html Header";
     //echo "Body Header";
     if ($this->_header && is_array($this->_header)) {
         //这里展开了 sys_title 和 tpm_css
         extract($this->_header);
     }
     include $this->_getAbsViewPathFilename("inc/header.dailog.html.php");
     /**
      * 这里显示 Tq消息
      * Tq消息要在 tip 之前
      */
     echo Tpm_Message_Sender_Tq::getMsgHtml();
     /**
      * 处理在 ctrl 里设置的tip提示信息
      */
     if (is_array($this->_header) && key_exists(Watt_Controller_Action::HEADER_TIP, $this->_header)) {
         $tip = $this->_header[Watt_Controller_Action::HEADER_TIP];
         echo "<script>";
         $msg = $tip[Watt_Controller_Action::HEADER_TIP_MSG];
         if ($nextUrl = $tip[Watt_Controller_Action::HEADER_TIP_URL]) {
             $matchs = null;
             if (preg_match("/^javascript:(.*)/", $nextUrl, $matchs)) {
                 //						echo "function onloadTip(){Ext.Msg.alert('TPM', '".addslashes($tip[Watt_Controller_Action::HEADER_TIP_MSG])."', function(){{$matchs[1]};return false;});}";
                 echo "function onloadTip() {" . ($msg ? "alert('" . addslashes($msg) . "');" : '') . "{$matchs[1]}}";
             } else {
                 //						echo "function onloadTip(){Ext.Msg.alert('TPM', '".addslashes($tip[Watt_Controller_Action::HEADER_TIP_MSG])."', function(){location.href='".$nextUrl."';return false;});}";
                 echo "function onloadTip() {" . ($msg ? "alert('" . addslashes($msg) . "');" : '') . "location.href='" . $nextUrl . "'}";
             }
             //如果有转向,则不输出主体
             $outputBody = false;
         } else {
             //					echo "function onloadTip(){Ext.Msg.alert('TPM', '".addslashes($tip[Watt_Controller_Action::HEADER_TIP_MSG])."');}";
             echo "function onloadTip() {" . ($msg ? "alert('" . addslashes($msg) . "');" : '') . "}";
         }
         echo "window.onload = onloadTip;";
         echo "</script>";
     }
     if ($outputBody) {
         //没有设置不显示主体
         //这里显示菜单 有true 是因为 菜单数据目前是在Watt_View_Helper_Menu里的
         //			if( isset( $this->_header["menu"] ) )
         //			{
         //				//var_dump( $this->_header );
         //				$menu = new Watt_View_Helper_Menu();
         //				$menu->buildMenu( $this->_header["menu"] );
         //				//$menu->buildMenu( null );
         //			}
         /**
          * 这里显示主体部分
          */
         parent::render(true);
     }
     /**
      * 这里显示底部
      */
     //echo "Body Footer";
     include $this->_getAbsViewPathFilename("inc/footer.dailog.html.php");
     $out = ob_get_clean();
     if ($show) {
         echo $out;
     }
     return $out;
 }
Esempio n. 4
0
 /**
  * 处理 do
  * 有可能会返回 goToDo
  * 
  * 只有一个单词的do,对应的action是 index
  * 
  *
  * @param string $do
  * @return string $goToDo
  */
 protected function processDo($do, $defaultView = "Html")
 {
     if ($do == "") {
         $e = new Watt_Exception(Watt_I18n::trans("ERR_DISPATCH_NODO"));
         throw $e;
     }
     $goToDo = "";
     $arrCtrlAndAction = $this->_analyzeDoToControllerAndAction($do);
     $controller = $arrCtrlAndAction[0];
     $action = $arrCtrlAndAction[1];
     $doFile = $arrCtrlAndAction[2];
     $doAction = $arrCtrlAndAction[3];
     //exit( $doFile . "|" . $doAction );
     //使用 ob_start 是为了Controller里的 redirect 可以正常使用
     if (defined('ENABLE_CTRL_BUFFER') && ENABLE_CTRL_BUFFER) {
         /**
          * 为了不让服务器过长等待时间,改为不启用Ctrl Buffer
          * @author terry
          * @version 0.1.0
          * Mon Jan 14 14:41:39 CST 2008
          */
         ob_start();
     }
     /**
      * 增加了对页面缓存的支持
      */
     $cache = null;
     Watt_Debug::addInfoToDefault('Begin create action [' . $controller . '] [' . $action . ']');
     $theCtrl = Watt_Controller_Action::factory($controller, $action);
     Watt_Debug::addInfoToDefault('After create action');
     $viewMenu = isset($_REQUEST["view_menu"]) ? trim($_REQUEST["view_menu"]) == '0' ? false : true : true;
     $theCtrl->setNeedMenu($viewMenu);
     $actionCacheTime = $theCtrl->getActionCacheTime($action);
     if ($actionCacheTime > 0) {
         $cache = new Watt_Cache($actionCacheTime);
         if ($cache->cacheCheck()) {
             //如果符合缓存条件,则会读取缓存文件,并 exit.
             /**
              * 改为退出处理,为了记录页面执行时间。
              * 这里一定不能 return true.
              * @author terry
              * @version 0.1.0
              * Mon Jan 14 14:30:43 CST 2008
              */
             return '';
         }
     }
     /**
      * 检查 会话的权限。 
      * 如果没有权限,抛出一个异常
      * 此处别扭
      */
     $rbac = new Watt_Rbac();
     //$rbac->checkSession(Watt_Session::getSession(), $do);
     $privilege = $rbac->checkActionPrivilege(Watt_Session::getSession(), $theCtrl, $action);
     if (is_object($privilege) && $privilege instanceof TpmYonghuzhaoquanxian) {
         if (!$theCtrl->getTitle()) {
             $theCtrl->setTitle(Watt_I18n::trans($privilege->getQxMingcheng()));
         }
     }
     Watt_Debug::addInfoToDefault('', 'Pre do action..');
     if (method_exists($theCtrl, $doAction)) {
         //执行controller中的action
         $theCtrl->{$doAction}();
     } else {
         throw new Exception(Watt_I18n::trans("ERR_APP_LOST_ACTION"));
     }
     Watt_Debug::addInfoToDefault('', 'After do action..');
     $goToDo = $theCtrl->getGoToDo();
     $data = $theCtrl->getData();
     /**
      * 改为对 Ctrl 不进行 Buffer 的处理
      * @author terry
      * @version 0.1.0
      * Mon Jan 14 15:05:28 CST 2008
      */
     if (defined('ENABLE_CTRL_BUFFER') && ENABLE_CTRL_BUFFER) {
         if (defined("DEBUG") && DEBUG) {
             //调试阶段才显示Controller里输出的信息
             echo ob_get_clean();
         } else {
             //用户使用阶段不允许 action 里输出显示数据
             ob_clean();
         }
     }
     if ($theCtrl->isNeedView()) {
         Watt_Debug::addInfoToDefault('', 'Pre load view..');
         if ($theCtrl->getViewType()) {
             $defaultView = $theCtrl->getViewType();
         }
         /**
          * 创建一个View。将来可以用不同的View代替此View
          */
         //$view = Watt_View::factory( "Html", Watt_Config::getViewPath() );
         $view = Watt_View::factory($defaultView, Watt_Config::getViewPath());
         $view->setHeader($theCtrl->getHeader());
         Watt_Debug::addInfoToDefault('', 'After view factory..');
         /**
          * 读取菜单应该由View来判断
          * @author terry
          * Thu Jul 22 10:46:07 CST 2010
          */
         if ($theCtrl->isNeedMenu() && strtolower($defaultView) == 'html') {
             //$theCtrl->isNeedCaidan();
             /**
              * 如果用户已登录,读取菜单信息
              * @todo 未登录可能也可以有菜单
              */
             if ($user_id = Watt_Session::getSession()->getUserId()) {
                 $tpmCaidans = TpmCaidanPeer::getJueseCaidan(Watt_Session::getSession()->getRoleId());
                 if (count($tpmCaidans)) {
                     $view->setHeader($tpmCaidans, "menu");
                 }
             }
             //读取菜单完
         }
         //$view->renderModel($theCtrl);
         $view->renderView($data, $this->_getDefaultViewFileOfAction($controller, $action), true);
     }
     /**
      * 与开始的Cache对应
      */
     if ($actionCacheTime > 0 && $cache instanceof Watt_Cache) {
         $cache->caching();
     }
     return $goToDo;
 }