protected function getData($field, $order, $limit, $offset)
 {
     Wind::import('SRV:tag.vo.PwTagSo');
     $so = new PwTagSo();
     $field['tag_ids'] && $so->setTagId(explode(' ', $field['tag_ids']));
     $field['category_id'] && $so->setCategoryId($field['category_id']);
     $so->setIflogo($field['islogo']);
     $so->setIfhot(1);
     switch ($field['order']) {
         case 0:
             $so->orderbyCreatedTime();
             break;
         case 1:
             $so->orderbyAttentionCount();
             break;
         case 2:
             $so->orderbyContentCount();
             break;
     }
     $list = Wekit::load('tag.PwTagSearch')->searchTag($so, $limit, $offset);
     if (!$list) {
         return array();
     }
     foreach ($list as $k => $v) {
         $list[$k]['tagid'] = $v['tag_id'];
         $list[$k]['tag_name'] = $this->_formatTitle($v['tag_name']);
         $list[$k]['url'] = WindUrlHelper::createUrl('tag/index/view', array('name' => $v['tag_name']), '', 'pw');
         $list[$k]['logo'] = Pw::getPath($v['tag_logo']);
         $list[$k]['attention_count'] = $v['attention_count'];
         $list[$k]['content_count'] = $v['content_count'];
         $list[$k]['excerpt'] = $v['excerpt'];
         $list[$k]['thumb_attach'] = $v['tag_logo'] ? $v['tag_logo'] : '';
     }
     return $list;
 }
 private function _buildSignKey($list)
 {
     $_username = array();
     $_tids = array();
     foreach ($list as $k => $v) {
         $_tids[] = $v['lastpost_tid'];
     }
     $thread = $this->_getThread($_tids);
     foreach ($list as $k => $v) {
         $list[$k]['name'] = $this->_filterForumHtml($v['name']);
         if ($v['type'] == 'category') {
             $list[$k]['forum_url'] = WindUrlHelper::createUrl('bbs/cate/run', array('fid' => $v['fid']), '', 'pw');
         } else {
             $list[$k]['forum_url'] = WindUrlHelper::createUrl('bbs/thread/run', array('fid' => $v['fid']), '', 'pw');
         }
         $list[$k]['descrip'] = $this->_formatDes($v['descrip']);
         $list[$k]['logo'] = $v['logo'] ? Pw::getPath($v['logo']) : '';
         $lastthread = $thread[$v['lastpost_tid']];
         $list[$k]['lastpost_time'] = $this->_formatTime($lastthread['lastpost_time']);
         $list[$k]['lastpost_smallavatar'] = $lastthread['lastpost_userid'] ? Pw::getAvatar($lastthread['lastpost_userid'], 'small') : '';
         $list[$k]['lastpost_middleavatar'] = $lastthread['lastpost_userid'] ? Pw::getAvatar($lastthread['lastpost_userid'], 'middle') : '';
         $list[$k]['lastpost_userid'] = $lastthread['lastpost_userid'];
         $list[$k]['lastpost_username'] = $lastthread['lastpost_username'];
         $list[$k]['lastpost_space'] = $lastthread['lastpost_userid'] ? WindUrlHelper::createUrl('space/index/run', array('uid' => $lastthread['lastpost_userid']), '', 'pw') : '';
         $list[$k]['lastthread_space'] = $lastthread['created_userid'] ? WindUrlHelper::createUrl('space/index/run', array('uid' => $lastthread['created_userid']), '', 'pw') : '';
         $list[$k]['lastthread_smallavatar'] = $lastthread['created_userid'] ? Pw::getAvatar($lastthread['created_userid'], 'small') : '';
         $list[$k]['lastthread_middleavatar'] = $lastthread['created_userid'] ? Pw::getAvatar($lastthread['created_userid'], 'middle') : '';
         $list[$k]['lastthread_username'] = $lastthread['created_username'];
         $list[$k]['lastthread_time'] = $this->_formatTime($lastthread['created_time']);
         $list[$k]['lastthread'] = $this->_formatTitle($lastthread['subject']);
     }
     return $list;
 }
 public function setStoragesAction()
 {
     $storage = $this->getInput('storage', 'post');
     $attService = Wekit::load('LIB:storage.PwStorage');
     $_r = $attService->setStoragesComponents($storage);
     if ($_r !== true) {
         $this->output(0);
     }
     $config = new PwConfigSet('attachment');
     $config->set('storage.type', $storage)->flush();
     $components = Wekit::C()->get('components')->toArray();
     Wind::getApp()->getFactory()->loadClassDefinitions($components);
     Wekit::C()->setConfig('site', 'avatarUrl', substr(Pw::getPath('1.gpg'), 0, -6));
     $this->_getNotifyService()->send('alterAvatarUrl', array(), $this->appid);
     $this->output(1);
 }
 /**
  * 附件存储方式设置列表页
  */
 public function dostroageAction()
 {
     $att_storage = $this->getInput('att_storage', 'post');
     $avatarurl = $this->getInput('avatarurl', 'post');
     $attService = Wekit::load('LIB:storage.PwStorage');
     $_r = $attService->setStoragesComponents($att_storage);
     if ($_r !== true) {
         $this->showError($_r->getError());
     }
     $config = new PwConfigSet('attachment');
     $config->set('storage.type', $att_storage)->flush();
     $components = Wekit::C()->get('components')->toArray();
     Wind::getApp()->getFactory()->loadClassDefinitions($components);
     Wekit::C()->setConfig('site', 'avatarUrl', substr(Pw::getPath('1.gpg'), 0, -6));
     Wekit::load('WSRV:notify.srv.WindidNotifyService')->send('alterAvatarUrl', array());
     $this->showMessage('WINDID:success');
 }
 public function getThreadImgs($tid)
 {
     $tid = intval($tid);
     if ($tid < 1) {
         return $this->buildResponse(THREAD_INVALID_PARAMS);
     }
     $_attaches = $this->_getThreadAttach()->getAttachByTid($tid, 0);
     $attaches = array();
     foreach ($_attaches as $v) {
         if ($v['type'] != 'img') {
             continue;
         }
         $attaches['img'][] = array('url' => Pw::getPath($v['path']));
     }
     $attaches['count'] = count($attaches['img']);
     return $this->buildResponse(0, $attaches);
 }
 private function _uploadFile()
 {
     Wind::import('SRV:upload.action.PwDesignImageUpload');
     Wind::import('SRV:upload.PwUpload');
     $bhv = new PwDesignImageUpload();
     $upload = new PwUpload($bhv);
     if (($result = $upload->check()) === true) {
         $result = $upload->execute();
     }
     if ($result !== true) {
         return $result;
     }
     $image = $bhv->getAttachInfo();
     if (!$image['filename']) {
         return '';
     }
     return Pw::getPath($image['path'] . $image['filename']);
 }
Exemple #7
0
 private function _uploadFile($key, $moduleid = 0)
 {
     Wind::import('SRV:upload.action.PwDesignDataUpload');
     Wind::import('SRV:upload.PwUpload');
     $bhv = new PwDesignDataUpload($key, $moduleid);
     $upload = new PwUpload($bhv);
     if (($result = $upload->check()) === true) {
         $result = $upload->execute();
     }
     if ($result !== true) {
         $this->showError($result->getError());
     }
     $image = $bhv->getAttachInfo();
     return $image['filename'] ? Pw::getPath($image['path'] . $image['filename']) : "";
 }
Exemple #8
0
 public function getAttachInfo()
 {
     if (!$this->attachs) {
         return array();
     }
     $array = current($this->attachs);
     $result = array('aid' => $array['aid']);
     if ($array['type'] == 'img') {
         $result['path'] = Pw::getPath($array['path']);
         $result['thumbpath'] = Pw::getPath($array['path'], $array['ifthumb']);
     }
     return $result;
 }
 /**
  * 淘宝推广图片 
  * 
  * @access public
  * @return void
  */
 public function dotaoAction()
 {
     if (!($user = $this->_getUser())) {
         $this->showError('login.not');
     }
     $fid = $this->getInput('fid', 'post');
     //
     $this->_accpetUploadForH5();
     //
     Wind::import('SRV:upload.action.PwTaoUpload');
     Wind::import('LIB:upload.PwUpload');
     $bhv = new PwTaoUpload();
     $bhv->filename = date('YmdHis');
     //
     $upload = new PwUpload($bhv);
     if (($result = $upload->check()) === true) {
         $result = $upload->execute();
     }
     if ($result !== true) {
         $this->showError($result->getError());
     }
     if (!($data = $bhv->getAttachInfo())) {
         $this->showError('upload.fail');
     }
     $data['path'] = Pw::getPath($data['path'] . $data['filename']);
     //
     $this->setOutput($data, 'data');
     $this->showMessage('upload.success');
 }
 public static function getNotifier()
 {
     $config = Wekit::C()->getValues('notifier');
     if (empty($config)) {
         $config = self::$defaultNotifier;
     } else {
         $config['avatar'] = empty($config['avatar']) ? self::$defaultNotifier['avatar'] : Pw::getPath($config['avatar']);
     }
     return $config;
 }
 public function getMedalImage($path = '', $filename = '')
 {
     if ($path) {
         return Pw::getPath($path . $filename);
     } else {
         return WindUrlHelper::checkUrl(PUBLIC_RES . '/images/medal/', PUBLIC_URL) . '/' . $filename;
     }
     /*if ($type == 'image'){
     			return WindUrlHelper::checkUrl(PUBLIC_RES . '/images/medal/big', PUBLIC_URL);
     		} else {
     			return WindUrlHelper::checkUrl(PUBLIC_RES . '/images/medal/small', PUBLIC_URL);	
     		}*/
 }
Exemple #12
0
 private function _bulidAttachs($attach)
 {
     if (!$attach) {
         return '';
     }
     $array = array();
     ksort($attach);
     reset($attach);
     foreach ($attach as $key => $value) {
         $array[$key] = array('name' => $value['name'], 'size' => $value['size'], 'path' => Pw::getPath($value['path'], $value['ifthumb'] & 1), 'thumbpath' => Pw::getPath($value['path'], $value['ifthumb']), 'desc' => $value['descrip'], 'special' => $value['special'], 'cost' => $value['cost'], 'ctype' => $value['ctype']);
     }
     return $array;
 }
Exemple #13
0
 private function _getSpace()
 {
     $this->space = $this->_getSpaceDs()->getSpace($this->spaceUid);
     empty($this->space['space_name']) && ($this->space['space_name'] = $this->spaceUser['username'] . '的个人空间');
     empty($this->space['space_privacy']) && ($this->space['space_privacy'] = array());
     $this->space['domain'] = $this->_getDomain();
     list($image, $repeat, $fixed, $align) = unserialize($this->space['back_image']);
     empty($repeat) && ($repeat = 'no-repeat');
     empty($fixed) && ($fixed = 'scroll');
     empty($align) && ($align = 'center');
     $this->space['back_image'] = array($image, $repeat, $fixed, $align);
     $this->space['backbround'] = '';
     if (empty($image)) {
         return;
     }
     $image = Pw::getPath('') . $image;
     $image = htmlentities($image);
     $repeat = htmlentities($repeat);
     $fixed = htmlentities($fixed);
     $align = htmlentities($align);
     $this->space['backbround'] = 'style="';
     $this->space['backbround'] .= 'background-image: url( ' . $image . ');';
     $this->space['backbround'] .= 'background-repeat:' . $repeat . ';';
     $this->space['backbround'] .= 'background-attachment:' . $fixed . ';';
     $this->space['backbround'] .= 'background-position:top ' . $align . ';';
     $this->space['backbround'] .= '"';
     return;
 }
 private function _getDataFromThread($infoids)
 {
     $_aTid = array();
     //有附件的帖子
     $datas = $data = array();
     $infos = Wekit::load('forum.PwThread')->fetchThread($infoids, PwThread::FETCH_ALL);
     foreach ($infos as $info) {
         $data['subject'] = $info['subject'];
         $data['lasttime'] = $info['created_time'];
         $data['content'] = $this->_buildLikeContent($info['content']);
         $data['from'] = '帖子';
         $data['uid'] = $info['created_userid'];
         $data['username'] = $info['created_username'];
         $data['fid'] = $info['fid'];
         $data['like_count'] = $info['like_count'];
         $data['url'] = WindUrlHelper::createUrl('bbs/read/run', array('tid' => $info['tid'], 'fid' => $info['fid']));
         $this->_appendFid($info['fid']);
         if ($info['aids']) {
             $_aTid[] = $info['tid'];
         }
         $datas[$info['tid']] = $data;
     }
     $images = $this->_getThreadAttachs($_aTid);
     foreach ($images as $img) {
         $datas[$img['tid']]['image'] = Pw::getPath($img['path'], $img['ifthumb']);
     }
     return $datas;
 }
 public function getAttachInfo()
 {
     $array = current($this->attachs);
     return array('aid' => $array['aid'], 'path' => Pw::getPath($array['path']), 'name' => $array['name']);
 }
 /**
  * 
  * 获取mini图地址
  *
  * @param string $path
  * @param  int $ifthumb  $ifthumb&1:原图      $ifthumb&2:缩略图     $ifthumb&1:mini图
  * @return string
  */
 public function getMiniUrl($path, $ifthumb, $where = null)
 {
     return array(0, Pw::getPath($path, $ifthumb));
 }
 /**
  * 自定义发现数据 
  * 
  * @access public
  * @return void
  * @example
  * <pre>
  * /index.php?m=native&c=Setting&a=freshList
  * </pre>
  */
 public function freshListAction()
 {
     $freshData = Wekit::loadDao('native.dao.PwFreshDao')->getFresh();
     foreach ($freshData as &$v) {
         $v['img'] = $v['img'] ? Pw::getPath($v['img']) : "";
     }
     $this->setOutput($freshData, 'data');
     $this->showMessage("success");
 }
 private function _buildAttachData($data)
 {
     $result = array();
     foreach ($data as $value) {
         $value['attachurl'] = Pw::getPath($value['path'], $value['ifthumb']);
         $result[$value['aid']] = $value;
     }
     return $result;
 }
Exemple #19
0
 /**
  * 组装我参与的勋章及自动勋章列表
  * 
  * 非cahce:PwUserMedalBo->getMyAndAutoMedal() 
  * Enter description here ...
  * @param int $uid
  */
 public function getMyAndAutoMedal($uid)
 {
     if (!$uid) {
         return array();
     }
     $_medals = $myMedalIds = $status = array();
     $logs = Wekit::load('medal.PwMedalLog')->getInfoListByUid($uid);
     foreach ($logs as $log) {
         $myMedalIds[] = $log['medal_id'];
         $status[$log['medal_id']] = $log['award_status'];
     }
     $cacheDs = Wekit::cache();
     $autoMedalIds = $cacheDs->get('medal_auto');
     $medals = $cacheDs->get('medal_all');
     $attachUrl = Pw::getPath('') . 'medal/';
     $localUrl = WindUrlHelper::checkUrl(PUBLIC_RES . '/images/medal/', PUBLIC_URL) . '/';
     $medalIds = array_merge($myMedalIds, $autoMedalIds);
     $medalIds = array_unique($medalIds);
     foreach ($medalIds as $id) {
         if (!isset($medals[$id])) {
             continue;
         }
         $medals[$id]['award_status'] = isset($status[$id]) ? $status[$id] : 0;
         $path = $medals[$id]['path'] ? $attachUrl : $localUrl;
         $_tmp = $medals[$id];
         $_tmp['image'] = $path . $_tmp['image'];
         $_tmp['icon'] = $path . $_tmp['icon'];
         $_medals[] = $_tmp;
     }
     return $_medals;
 }
 /**
  * 过滤版块数据,不需要的字段过滤掉 
  * 
  * @param mixed $data 
  * @access private
  * @return void
  */
 private function _filterForumData($forumList)
 {
     if ($forumList) {
         $vieworder = array();
         foreach ($forumList as $key => $forum) {
             $forumList[$key] = array('fid' => $forum['fid'], 'name' => $forum['name'], 'threads' => $forum['threads'], 'todayposts' => $forum['todayposts'], 'article' => $forum['article'], 'posts' => $forum['posts'], 'icon' => $forum['icon'] ? Pw::getPath($forum['icon']) : "", 'logo' => $forum['logo'] ? Pw::getPath($forum['logo']) : "", 'fup' => $forum['fup'], 'fupname' => $forum['fupname'], 'vieworder' => intval($forum['vieworder']), 'lastpost_time' => Pw::time2str($forum['lastpost_time'], 'auto'));
             $vieworder[] = intval($forum['vieworder']);
         }
     }
     array_multisort($vieworder, SORT_ASC, $forumList);
     return $forumList;
 }
 /**
  * 取贴子的附件 
  * 
  * @param array $tids 
  * @param array $pids 附件的个数
  * @access private
  * @return void
  */
 public function getThreadAttach($tids, $pids)
 {
     $result = array();
     $array = $this->_getThreadAttachDs()->fetchAttachByTidAndPid($tids, $pids);
     $i = 0;
     foreach ($array as $key => $value) {
         //只取9个
         if ($i > 9) {
             break;
         }
         $i++;
         //只取图片
         if ($value['type'] != 'img' || $value['special'] > 0 && $value['cost'] > 0) {
             continue;
         }
         $_key = $value['tid'] . '_' . $value['pid'];
         $value['path'] = Pw::getPath($value['path'], $value['ifthumb']);
         //$result[$_key][$value['aid']] = $value;
         //只用图片地址
         //$result[$_key][$value['aid']]['path'] = $value['path'];
         $result[$_key][]['path'] = $value['path'];
     }
     return $result;
 }
 public function analyse($attach)
 {
     if ($attach['type'] == 'img' && $attach['cost'] == 0) {
         $atype = 'pic';
         $url = Pw::getPath($attach['path']);
         $img = PwUbbCode::createImg(Pw::getPath($attach['path'], $attach['ifthumb'] & 1), $this->imgWidth, $this->imgHeight, $url, $this->imgLazy);
         $attr = '';
         if ($this->imgLazy && ($tmp = $this->_compare($attach['width'], $attach['height'], $this->imgWidth, $this->imgHeight))) {
             $attr .= ' width="' . $tmp[0] . '"';
             $attr .= ' height="' . $tmp[1] . '"';
         }
         $attach['descrip'] && ($attr .= ' alt="' . WindSecurity::escapeHTML($attach['descrip']) . '"');
         $attr && ($img = substr($img, 0, -3) . $attr . ' />');
         $attach += array('url' => $url, 'img' => $img, 'miniUrl' => Pw::getPath($attach['path'], $attach['ifthumb']));
     } else {
         $atype = 'downattach';
         $attach += array('cname' => '', 'ext' => strtolower(substr(strrchr($attach['name'], '.'), 1)));
     }
     return array($atype, $attach);
 }
 public function doeditAction()
 {
     $id = (int) $this->getInput('portalid', 'post');
     $title = $this->getInput('title', 'post');
     $coverfrom = (int) $this->getInput('coverfrom', 'post');
     $pagename = $this->getInput('pagename', 'post');
     $keywords = $this->getInput('keywords', 'post');
     $description = $this->getInput('description', 'post');
     if (!$title) {
         $this->showError("DESIGN:title.is.empty");
     }
     if (!$pagename) {
         $this->showError("DESIGN:pagename.is.empty");
     }
     //二级域名start
     list($domain, $root) = $this->getInput(array('domain', 'root'), 'post');
     if ($root) {
         if (!$domain) {
             Wekit::load('domain.PwDomain')->deleteByDomainKey("special/index/run?id={$id}");
         } else {
             $r = Wekit::load('domain.srv.PwDomainService')->isDomainValid($domain, $root, "special/index/run?id={$id}");
             if ($r instanceof PwError) {
                 $this->showError($r->getError());
             }
             Wind::import('SRV:domain.dm.PwDomainDm');
             $dm = new PwDomainDm();
             $dm->setDomain($domain)->setDomainKey("special/index/run?id={$id}")->setDomainType('special')->setRoot($root)->setFirst($domain[0])->setId($id);
             Wekit::load('domain.PwDomain')->replaceDomain($dm);
         }
         Wekit::load('domain.srv.PwDomainService')->flushAll();
     }
     //二级域名end
     if (!$this->_validator($pagename)) {
         $this->showError("DESIGN:pagename.validator.fail");
     }
     $ds = $this->_getPortalDs();
     $portal = $ds->getPortal($id);
     if (!$portal) {
         $this->showError("operate.fail");
     }
     $count = $ds->countPortalByPagename($pagename);
     if ($portal['pagename'] != $pagename && $count >= 1) {
         $this->showError("DESIGN:pagename.already.exists");
     }
     if ($coverfrom == 2) {
         $cover = '';
         $upload = $this->_upload($id);
         if ($upload['filename']) {
             $cover = Pw::getPath($upload['path'] . $upload['filename']);
         }
     } else {
         $cover = $this->getInput('webcover', 'post');
         $cover = preg_match("/^http:\\/\\/(.*)\$/", $cover) ? $cover : '';
     }
     Wind::import('SRV:design.dm.PwDesignPortalDm');
     $dm = new PwDesignPortalDm($id);
     $dm->setPageName($pagename)->setTitle($title)->setCover($cover)->setDomain($domain)->setIsopen((int) $this->getInput('isopen', 'post'))->setHeader((int) $this->getInput('isheader', 'post'))->setNavigate((int) $this->getInput('isnavigate', 'post'))->setFooter((int) $this->getInput('isfooter', 'post'))->setKeywords($keywords)->setDescription($description);
     $resource = $ds->updatePortal($dm);
     if ($resource instanceof PwError) {
         $this->showError($resource->getError());
     }
     $pageInfo = $this->_getPageDs()->getPageByTypeAndUnique(PwDesignPage::PORTAL, $id);
     //更新页面名称
     Wind::import('SRV:design.dm.PwDesignPageDm');
     $dm = new PwDesignPageDm($pageInfo['page_id']);
     $dm->setName($title);
     $this->_getPageDs()->updatePage($dm);
     //seo
     Wind::import('SRV:seo.dm.PwSeoDm');
     $dm = new PwSeoDm();
     $dm->setMod('area')->setPage('custom')->setParam($id)->setTitle($title)->setKeywords($keywords)->setDescription($description);
     Wekit::load('seo.srv.PwSeoService')->batchReplaceSeoWithCache($dm);
     $this->showMessage("operate.success", "special/index/run?id=" . $id, true);
 }
Exemple #24
0
 /**
  * 图片异步缩略
  * Enter description here ...
  * @param unknown_type $data
  */
 protected function asynCutImg($data)
 {
     if (!$this->multiSign['img']) {
         return $data;
     }
     $ds = Wekit::load('design.PwDesignAsynImage');
     Wind::import('SRV:design.dm.PwDesignAsynImageDm');
     foreach ((array) $this->multiSign['img'] as $k => $v) {
         $data['standard_image'] = '';
         if (!$data[$k]) {
             continue;
         }
         list($thumbW, $thumbH) = $v;
         if ($thumbW < 1 && $thumbH < 1) {
             $data[$k] = Pw::getPath($data[$k]);
         } else {
             $dm = new PwDesignAsynImageDm();
             $dm->setHeight($thumbH)->setWidth($thumbW)->setPath($data[$k])->setModuleid($this->bo->moduleid)->setSign($k);
             $result = $ds->addImage($dm);
             if ($result instanceof PwError) {
                 $data[$k] = Pw::getPath($data[$k]);
             } else {
                 $data[$k] = WindUrlHelper::createUrl('design/image/run', array('id' => (int) $result), '', 'pw');
                 $data['__asyn'] = (int) $result;
             }
             $data['standard_image'] = '';
         }
     }
     return $data;
 }