/** * function _render * use viewVars['data'] in controller * * @return string * @access protected */ protected function _render($action = null, $path = null) { if (!isset($this->viewVars['no_html_data'])) { throw new AppViewException('Unknow Data'); } $this->_controller->header('Content-Type:application/json;charset=' . $this->encoding); App::import("vendor", "inc/json"); return BYRJSON::encode($this->viewVars['no_html_data']); }
/** * mail file via deliver * @param String $board * @param String $title * @param String $content * @return {v:} */ public function m_automail() { @($id = trim($this->params['url']['id'])); @($title = urldecode(trim($this->params['url']['title']))); @($content = urldecode(trim($this->params['url']['content']))); if (isset($this->params['form']['id'])) { @($id = $this->params['form']['id']); } if (isset($this->params['form']['title'])) { @($title = $this->params['form']['title']); } if (isset($this->params['form']['content'])) { @($content = $this->params['form']['content']); } if ($id == "" || $title == "") { $this->_stop(); } App::import("vendor", "model/mail"); $ret = Mail::autoMail(User::getInstance($id), $title, $content); echo BYRJSON::encode(array("v" => $ret)); }
/** * @override method */ public function beforeRender() { if (!$this->html) { //there is three ajax_st status //1:success //0:fail $data = $this->get('no_html_data'); if (null === $data) { $data = array(); } //use no_ajax_info param to ignore ajax info, //sometimes data may be a array if (!isset($data['ajax_st']) && null === $this->get('no_ajax_info')) { $data['ajax_st'] = 1; $data['ajax_code'] = isset($data['ajax_code']) ? $data['ajax_code'] : ECode::$SYS_AJAXOK; $data['ajax_msg'] = ECode::msg($data['ajax_code']); //code may be a string,check msg == code to set default code if ($data['ajax_msg'] == strval($data['ajax_code'])) { $data['ajax_code'] = ECode::$SYS_AJAXOK; } $this->set('no_html_data', $data); } return; } $site = Configure::read("site"); try { $u = User::getInstance(); $uid = $u->userid; $admin = $u->isAdmin(); $reg = $u->isReg(); } catch (UserNullException $e) { $uid = 'guest'; $admin = false; $reg = false; } //handle js & css $this->_initAsset(); //add pack js&css $asset_pack = nforum_cache_read('asset_pack'); if (is_array($asset_pack) && ($this->front || $this->spider)) { $this->set('js', array_merge(array('js/' . $asset_pack['js']), $this->get('js'))); $this->set('css', array_merge(array('css/' . $asset_pack['css']), $this->get('css'))); } //handle title $title = $site['name']; if (!empty($this->title)) { $title = $this->title; } else { if (isset($this->notice[0]) && $this->path != $site['home']) { $title .= "-" . $this->notice[0]["text"]; } else { $title .= "-" . $site['desc']; } } //handle notice if ($this->path != $site['home']) { $this->notice = array_merge(array(array("url" => $site['home'], "text" => $site['name'])), $this->notice); } /* handle jsr start*/ if (!$this->spider) { if ($this->front) { $site = Configure::read("site"); $cookie = Configure::read("cookie"); $jsr = Configure::read("jsr"); $jsr['iframe'] = $jsr['iframe'] ? 'true' : 'false'; $jsr['domain'] = preg_replace('/^https?:\\/\\//', '', $site['domain']); $jsr['cookie_domain'] = $cookie['domain']; $jsr['base'] = $this->base; $jsr['prefix'] = $cookie['prefix']; $jsr['home'] = $site['home']; $jsr['static'] = $site['static']; $jsr['protocol'] = $site['ssl'] ? 'https://' : 'http://'; App::import("vendor", "inc/json"); $jsr = 'var sys_merge=' . BYRJSON::encode($jsr); $this->jsr = array_merge(array($jsr), $this->jsr); $syn = Configure::read('ubb.syntax'); if (Configure::read('ubb.parse') && !empty($syn)) { $this->set('js', array_merge($this->get('js'), array($syn . '/scripts/shCore.js', $syn . '/scripts/shAutoloader.js'))); } } else { $tmp = array(); foreach ($this->notice as $v) { $tmp[] = '<a href="' . (empty($v['url']) ? 'javascript:void(0)' : $this->base . $v['url']) . '">' . $v['text'] . '</a>'; } $tmp = join(' >> ', $tmp); $this->jsr[] = <<<EOT \$('#notice_nav').html('{$tmp}');\$.setTitle('{$title}'); EOT; $syn = Configure::read('ubb.syntax'); if (Configure::read('ubb.parse') && !empty($syn) && $this->get('hasSyn') !== false) { $this->set('syntax', $syn); } } } /* handle jsr end*/ //basic variables $arr = array('base' => $this->base, 'islogin' => $this->ByrSession->isLogin, 'id' => $uid, 'isAdmin' => $admin, 'isReg' => $reg, 'notice' => $this->notice, 'webTitle' => $title, 'webTotal' => Forum::getOnlineNum(), 'webUser' => Forum::getOnlineUserNum(), 'webGuest' => Forum::getOnlineGuestNum(), 'encoding' => $this->encoding, 'domain' => $site['domain'], 'static' => $site['static'], 'siteName' => $site['name'], 'keywords' => $site['keywords'], 'description' => $site['description'], 'home' => $site['home'], 'preindex' => $site['preIndex'], 'front' => $this->front, 'spider' => $this->spider, 'jsr' => $this->jsr); $this->set($arr); }