コード例 #1
0
 /**
  *帖子阅读页 - 钩子方法
  *
  */
 public function createHtmlBeforeContent($read)
 {
     if (!is_array($read) || empty($read)) {
         return false;
     }
     !$this->tid && ($this->tid = intval($read['tid']));
     $this->pid = intval($read['pid']);
     //快速回复帖子
     if (!$this->pids && $this->pid != 0) {
         $this->pids[] = $this->pid;
     }
     //first,需要组装数据
     if ($this->isIn === false) {
         $rewardInfo = $this->getReplyRewardBo()->getRewardInfo();
         if (!$rewardInfo) {
             $this->isReplyReward = false;
         }
         $recordInfo = $this->pids ? $this->_getReplyRewardRecordDs()->getRewardRecordByTidAndPids($this->tid, $this->pids) : array();
         $creditInfo = $this->getReplyRewardBo()->getCreditInfo($rewardInfo['credittype']);
         $this->threadInfo = array('rewardInfo' => $rewardInfo['creditnum'] . $creditInfo['unit'] . $creditInfo['name'], 'creditnum' => $rewardInfo['creditnum'], 'creditunit' => $creditInfo['unit'], 'creditname' => $creditInfo['name'], 'repeattimes' => $rewardInfo['repeattimes'], 'chance' => $rewardInfo['chance'], 'pool' => $rewardInfo['lefttimes'] * $rewardInfo['creditnum']);
         foreach ($recordInfo as $val) {
             $this->floorInfo[$val['pid']] = $rewardInfo['creditnum'];
         }
         $this->isIn = true;
     }
     if ($this->pid > 0 && !$this->floorInfo[$this->pid]) {
         return false;
     }
     if ($this->tid > 0 && $this->pid == 0 && $this->isReplyReward === false) {
         return false;
     }
     PwHook::template('displayReadBeforeContentHtml', 'EXT:replyreward.template.read_replyreward', true, $this);
 }
コード例 #2
0
 public function displayHtml($hook, $vProperty, $decorator)
 {
     list($tpl, $hookname) = explode('|', $hook);
     if (!$tpl || !$hookname) {
         return '';
     }
     PwHook::template($hookname, 'TPL:design.property.' . $tpl, true, array('property' => $vProperty, 'decorator' => $decorator));
 }
コード例 #3
0
 /**
  *
  *钩子执行方法
  */
 public function createHtmlAfterSubject($thread)
 {
     if (!$thread['app_mark']) {
         return false;
     }
     list($cNum, ) = $this->_getService()->splitStringToArray($thread['app_mark']);
     $cNum && PwHook::template('app_mark_displayThreadListHtml', 'EXT:mark.template.read_mark', true, $cNum);
 }
コード例 #4
0
 public function createHtmlForThreadButton($read)
 {
     if (!$read['pid']) {
         return true;
     }
     $read['app_mark'] && (list(, $count) = $this->_getService()->splitStringToArray($read['app_mark']));
     PwHook::template('app_mark_displayMarkHtmlForThreadButton', 'EXT:mark.template.read_mark', true, $read, (int) $count);
 }
コード例 #5
0
 public function createHtml($spaceBo)
 {
     if (!$spaceBo->allowView('work')) {
         return false;
     }
     $spaceBo->spaceUser['work'] = Wekit::load('work.PwWork')->getByUid($spaceBo->spaceUid);
     PwHook::template('work', 'TPL:space.profile_extend', true, $spaceBo);
 }
コード例 #6
0
 public function createHtml($spaceBo)
 {
     if (!$spaceBo->allowView('education')) {
         return false;
     }
     $educations = Wekit::load('education.srv.PwEducationService')->getEducationByUid($spaceBo->spaceUid, 100);
     $spaceBo->spaceUser['education'] = $educations;
     PwHook::template('education', 'TPL:space.profile_extend', true, $spaceBo);
 }
 /**
  *
  *钩子执行方法
  */
 public function createHtmlAfterSubject($thread)
 {
     if (!is_array($thread)) {
         return false;
     }
     $this->tid = intval($thread['tid']);
     if ($this->creditPoolInfo[$this->tid]) {
         PwHook::template('displayThreadListReplyRewardHtml', 'EXT:replyreward.template.threadlist_replyreward', true, $this);
     }
 }
コード例 #8
0
 /**
  * 钩子方法 帖子发布展示
  */
 public function createHtmlRightContent()
 {
     if (!$this->_getReplyRewardConfigService()->getReplyRewardCreditType()) {
         return false;
     }
     if ($this->action == 'add' && $this->_checkPrivilege()) {
         PwHook::template('displayPostReplyRewardHtml', 'EXT:replyreward.template.post_replyreward', true, $this);
     } elseif ($this->action == 'modify' && $this->getReplyRewardBo()->getRewardInfo()) {
         PwHook::template('displayModifyReplyRewardHtml', 'EXT:replyreward.template.modify_replyreward', true, $this);
     }
 }
コード例 #9
0
ファイル: PwSimpleHook.php プロジェクト: ccq18/EduSoho
 /**
  * 构造函数,默认启动埋在此钩子下的扩展服务
  *
  * @param string $hookKey 钩子点,默认为类名
  * @param string $interface
  * @param object $srv
  * @return void
  */
 private function __construct($hookKey)
 {
     if (!($hooks = PwHook::getRegistry('s_' . $hookKey))) {
         return;
     }
     if (!($map = PwHook::resolveActionHook($hooks))) {
         return;
     }
     foreach ($map as $key => $value) {
         $this->appendDo(Wekit::getInstance($value['class'], $value['loadway']), $value['method']);
     }
 }
コード例 #10
0
 public function createHtml($left, $tab)
 {
     $config = Wekit::C('app_majia');
     $list = array();
     $method = !in_array($this->bp->user->gid, $config['band.allow.groups']) ? 'displayMajiaForbidden' : 'displayList';
     if (!$config['isopen']) {
         $method = 'displayMajiaClose';
     } else {
         Wind::import('EXT:majia.service.srv.App_Majia_MajiaBandingBp');
         $bp = new App_Majia_MajiaBandingBp($this->bp->user);
         $list = $bp->doGetBanded();
     }
     PwHook::template($method, 'EXT:majia.template.my_run', true, $this->bp->user, $list, intval($config['band.max.num']));
 }
コード例 #11
0
 public function displayFootHtml($current)
 {
     $this->conf = Wekit::C('app_verify');
     if (!$this->conf['verify.isopen']) {
         return false;
     }
     $openTypes = $this->_getService()->getOpenVerifyType();
     $types = $this->_getService()->getVerifyTypeName();
     $data = array();
     foreach ($openTypes as $k => $v) {
         $data[$types[$k]] = WindUrlHelper::createUrl('app/verify/index/typeTab', array('type' => $types[$k]));
     }
     PwHook::template('displayAppProfileVerifyFootHtml', 'EXT:verify.template.index_run', true, $this->left, $data);
 }
コード例 #12
0
 /**
  *钩子
  */
 public function createHtmlBeforeContent($read)
 {
     $tid = intval($read['tid']);
     $pid = intval($read['pid']);
     if ($pid) {
         return false;
     }
     if (!$this->info) {
         return false;
     }
     $token = $this->info['token'];
     $this->url = WindUrlHelper::createUrl('bbs/read/run', array('tid' => $tid, 'fid' => $this->fid, 'token' => $token));
     PwHook::template('displayReadHtml', 'EXT:encryptposts.template.read_encryptposts', true, $this);
 }
コード例 #13
0
 /**
  * 钩子方法 帖子发布展示
  */
 public function createHtmlRightContent()
 {
     if (!$this->checkPrivilege()) {
         return false;
     }
     if ($this->action == 'modify') {
         Wind::import('SRC:library.Pw');
         if ($this->tid && $this->_getEncryptPostsDs()->get($this->tid)) {
             $this->ifCheck = true;
         }
         PwHook::template('displayUpdateHtml', 'EXT:encryptposts.template.update_encryptposts', true, $this);
     } elseif ($this->action == 'add') {
         PwHook::template('displayPostHtml', 'EXT:encryptposts.template.post_encryptposts', true, $this);
     }
 }
コード例 #14
0
ファイル: PwBaseHookService.php プロジェクト: ccq18/EduSoho
 protected function _prepare()
 {
     if ($this->_ready) {
         return !empty($this->_do);
     }
     !$this->_srv && ($this->_srv = $this);
     foreach ($this->_key as $key => $hookKey) {
         if (!($hooks = PwHook::getRegistry($hookKey))) {
             continue;
         }
         if (!($map = PwHook::resolveActionHook($hooks, $this->_srv))) {
             continue;
         }
         foreach ($map as $key => $value) {
             $this->appendDo(Wekit::getInstance($value['class'], $value['loadway'], array($this->_srv)));
         }
     }
     $this->_ready = true;
     return !empty($this->_do);
 }
コード例 #15
0
 /**
  * 个人设置--绑定设置--页面
  * @see PwProfileExtendsDoBase::createHtml()
  */
 public function createHtml($left, $tab)
 {
     $this->typeFilter = $this->_getCommonService()->getAccountType();
     if ($this->typeFilter === false) {
         return false;
     }
     $res = $this->_getAccountBindDs()->fetchByUidAndTypes($this->uid, $this->typeFilter);
     $bindType = array();
     foreach ($res as $v) {
         $bindType[] = $v['type'];
         $this->bindInfo[$v['type']] = array('isopen' => 1, 'iconClass' => $this->_getAccountTypeService()->getIconClassByType($v['type']));
     }
     $unbindType = array();
     $unbindType = array_diff($this->typeFilter, $bindType);
     foreach ($unbindType as $v) {
         $this->bindInfo[$v] = array('isopen' => 0, 'iconClass' => $this->_getAccountTypeService()->getIconClassByType($v));
     }
     krsort($this->bindInfo);
     $this->avatar = Pw::getAvatar($this->uid, 'small');
     PwHook::template('displayAppProfileAccount', 'EXT:account.template.profile', true, $this);
 }
コード例 #16
0
ファイル: PwThreadDisplay.php プロジェクト: fanqimeng/4tweb
 /**
  * 逻辑处理,数据准备
  */
 public function execute(PwReadDataSource $ds)
 {
     PwHook::registerHook('s_PwUbbCode_convert', array('class' => 'SRV:forum.srv.PwThreadDisplay', 'method' => 'escapeSpace', 'loadway' => 'static'));
     $this->_ds = $ds;
     $ds->execute();
     $this->total = $ds->total;
     $this->page = $ds->page;
     $this->perpage = $ds->perpage;
     $this->maxpage = $ds->maxpage;
     $start = $ds->firstFloor;
     $this->bulidUsers($ds->getUser());
     $this->readdb =& $ds->getData();
     $this->_initAttachs($ds->getAttach());
     foreach ($this->readdb as $key => $read) {
         $this->readdb[$key] = $this->bulidRead($read, $start++);
     }
     $this->thread->hit();
 }
コード例 #17
0
 /**
  * action Hook 注册
  *
  * @param string $registerKey 扩展点别名
  * @param PwBaseHookService $bp        	
  * @throws PwException
  * @return void
  */
 protected function runHook($registerKey, $bp)
 {
     if (!$registerKey) {
         return;
     }
     if (!$bp instanceof PwBaseHookService) {
         throw new PwException('class.type.fail', array('{parm1}' => 'src.library.base.PwBaseController.runHook', '{parm2}' => 'PwBaseHookService', '{parm3}' => get_class($bp)));
     }
     if (!($filters = PwHook::getRegistry($registerKey))) {
         return;
     }
     if (!($filters = PwHook::resolveActionHook($filters, $bp))) {
         return;
     }
     $args = func_get_args();
     $_filters = array();
     foreach ($filters as $key => $value) {
         $args[0] = isset($value['method']) ? $value['method'] : '';
         $_filters[] = array('class' => $value['class'], 'args' => $args);
     }
     $this->resolveActionFilter($_filters);
 }
コード例 #18
0
 public function createHtmlAfterContent($read)
 {
     if ($read['pid'] == 0) {
         PwHook::template('displayVoteHtmlAfterContent', 'TPL:bbs.read_vote', true, $this);
     }
 }
コード例 #19
0
 public function createHtmlAfterUserInfo($user, $read)
 {
     if (isset($this->medals[$user['uid']])) {
         PwHook::template('displayMedalHtmlAfterContent', 'TPL:medal.read_medal', true, $this->medals[$user['uid']]);
     }
 }
コード例 #20
0
 protected function _setPreHook($m, $mc, $mca)
 {
     $prehook = Wekit::V('prehook');
     PwHook::preset($prehook['ALL']);
     PwHook::preset($prehook[Wekit::getLoginUser()->isExists() ? 'LOGIN' : 'UNLOGIN']);
     if (isset($prehook[$m])) {
         PwHook::preset($prehook[$m]);
     }
     if (isset($prehook[$mc])) {
         PwHook::preset($prehook[$mc]);
     }
     if (isset($prehook[$mca])) {
         PwHook::preset($prehook[$mca]);
     }
 }
コード例 #21
0
ファイル: DemoHookExtend1.php プロジェクト: sanzhumu/nextwind
 public function display()
 {
     PwHook::template('testHook2', 'hook_sigment1', true, array('d' => 'bbb'), 'ddd');
 }
コード例 #22
0
 public function createHtmlBeforeContent($read)
 {
     if ($read['pid'] == 0 && isset($this->torrent)) {
         PwHook::template('displayReadTorrentHtml', 'EXT:torrent.template.read_injector_before_torrent', true, $this->torrent);
     }
 }
コード例 #23
0
ファイル: PwPostDoPoll.php プロジェクト: fanqimeng/4tweb
 public function createHtmlBeforeContent()
 {
     PwHook::template('displayPostPollHtml', 'TPL:bbs.post_poll', true, $this);
 }
コード例 #24
0
ファイル: PwHook.php プロジェクト: fanqimeng/4tweb
 /**
  * 解析模板内容并返回
  * 
  * 将输入的模板内容解析为方法数组{@example <pre>
  * 以下模板内容将解析为:
  * <hook-action name="testHook" args='a,c'>
  * <div>
  * hi, i am testHook
  * </div>
  * </hook-action>
  * <hook-action name="testHook1">
  * <div>
  * hi, i am testHook
  * </div>
  * </hook-action>
  * 
  * $content = array(
  * 'testHook' => array('content', array('a','c')),
  * 'testHook1' => array('content', array('data'))
  * );
  * </pre>}
  * @param string $template
  * @return array
  */
 private static function _resolveTemplate($template, $_prefix)
 {
     if (false === ($content = WindFile::read($template))) {
         throw new PwException('template.path.fail', array('{parm1}' => 'wekit.engine.hook.PwHook._resolveTemplate', '{parm2}' => $template));
     }
     self::$methods = array();
     $content = preg_replace_callback('/<(\\/)?hook-action[=,\\w\\s\'\\"]*>(\\n)*/i', 'PwHook::_pregContent', $content);
     $content = explode("</hook-action>", $content);
     $_content = array();
     $_i = 0;
     //如果该模板中只有一段片段没有使用hook-action,则该方法名将会设为该模板名称,接受的参数为$data
     if (count(self::$methods) == 0) {
         $_content[$_prefix] = array($content[0], array('data'));
     } else {
         $_i = 0;
         foreach (self::$methods as $method) {
             $key = $method['name'] ? $_prefix . '_' . strtoupper($method['name']) : $_prefix . '_' . ($_i + 1);
             $args = $method['args'] ? explode(',', $method['args']) : array('data');
             $_content[$key] = array($content[$_i], $args);
             $_i++;
         }
     }
     return $_content;
 }
コード例 #25
0
ファイル: PwPostDoTorrent.php プロジェクト: Going2333/WindPT
 public function createHtmlBeforeContent()
 {
     PwHook::template('displayPostTorrentHtml', 'EXT:torrent.template.post_injector_before_torrent', true, $this);
 }
コード例 #26
0
 /**
  *s_login_sidebar - 钩子  
  */
 public function login_sidebar()
 {
     $types = $this->getAccountType();
     if ($types === false) {
         return false;
     }
     $address = $this->getLoginAddress($types);
     $info = array();
     foreach ($types as $type) {
         $info[$type] = array('href' => $address[$type], 'class' => $this->_getAccountTypeService()->getHrefClassByType($type), 'name' => $this->_getAccountTypeService()->getTypeName($type));
     }
     PwHook::template('displayLoginSidebarHtml', 'EXT:account.template.login_sidebar', true, $info);
 }
コード例 #27
0
ファイル: PwHookDoTorrent.php プロジェクト: LastRitter/WindPT
 public function spaceProfile($space)
 {
     $PwThread = Wekit::load('forum.PwThread');
     $showuserinfo = Wekit::C('site', 'app.torrent.showuserinfo');
     if (is_array($showuserinfo) && !in_array('profile', $showuserinfo)) {
         return;
     }
     $user = Wekit::load('EXT:torrent.service.PwTorrentUser')->getTorrentUserByUid($space->spaceUid);
     $peers = Wekit::load('EXT:torrent.service.PwTorrentPeer')->fetchTorrentPeerByUid($space->spaceUid);
     $this->histories = Wekit::load('EXT:torrent.service.PwTorrentHistory')->fetchTorrentHistoryByUid($space->spaceUid);
     $this->torrents = $PwThread->getThreadByUid($space->spaceUid);
     $this->passkey = $user['passkey'];
     $this->seeding = $this->leeching = 0;
     if (is_array($peers)) {
         foreach ($peers as $peer) {
             if ($peer['seeder'] == 'yes') {
                 $this->seeding++;
             } else {
                 $this->leeching++;
             }
         }
     }
     if (is_array($this->histories)) {
         $PwTorrent = Wekit::load('EXT:torrent.service.PwTorrent');
         foreach ($this->histories as $key => $history) {
             $downloaded_total += $history['downloaded'];
             $uploaded_total += $history['uploaded'];
             $torrent = $PwTorrent->getTorrent($history['torrent']);
             $thread = $PwThread->getThread($torrent['tid']);
             if ($thread) {
                 $this->histories[$key]['tid'] = $torrent['tid'];
                 $this->histories[$key]['subject'] = $thread['subject'];
             } else {
                 unset($this->histories[$key]);
             }
         }
     }
     if ($downloaded_total != 0) {
         $this->rotio = round($uploaded_total / $downloaded_total, 2);
     } else {
         $this->rotio = 'Inf.';
     }
     $this->downloaded_total = PwUtils::readableDataTransfer($downloaded_total);
     $this->uploaded_total = PwUtils::readableDataTransfer($uploaded_total);
     PwHook::template('displayProfileTorrentHtml', 'EXT:torrent.template.profile_injector_after_content', true, $this);
 }