예제 #1
0
function getSubjectByTid($tid, $param)
{
    global $db;
    $tid = (int) $tid;
    if (!$tid) {
        return false;
    }
    $thread = $db->get_one("SELECT tid,fid,author,authorid,subject,type,postdate,hits,replies FROM pw_threads WHERE tid=" . pwEscape($tid));
    $thread['url'] = 'read.php?tid=' . $thread['tid'];
    $thread['title'] = $thread['subject'];
    $thread['titlealt'] = $thread['subject'];
    $thread['image'] = '';
    $thread['forumname'] = getForumName($thread['fid']);
    $thread['forumurl'] = getForumUrl($thread['fid']);
    $temp = array();
    foreach ($param as $key => $value) {
        $temp_2 = '';
        if ($key == 'descrip') {
            $temp_2 = getDescripByTid($tid);
        } elseif ($key == 'image') {
            $temp[$key] = getImagesByTid($tid);
            continue;
        } elseif (array_key_exists($key, $thread)) {
            $temp_2 = $thread[$key];
        } else {
            $temp_2 = '';
        }
        $temp[$key] = PW_tplGetData::_analyseResultByParameter($temp_2, $value);
    }
    return $temp;
}
예제 #2
0
 function getRelateDataByKey($key)
 {
     global $db;
     L::loadClass('tplgetdata', 'area', false);
     $tid = (int) $key;
     if (!$tid) {
         return array();
     }
     $thread = $db->get_one("SELECT tid,fid,author,authorid,subject,type,postdate,hits,replies FROM pw_threads WHERE tid=" . S::sqlEscape($tid));
     if (!$thread) {
         return array();
     }
     $thread['url'] = $this->_getSubjectUrl($thread['tid']);
     $thread['title'] = $thread['subject'];
     $thread['titlealt'] = $thread['subject'];
     $thread['authorurl'] = 'u.php?uid=' . $thread['authorid'];
     $thread['image'] = $this->_getImagesByTid($tid);
     $thread['forumname'] = getForumName($thread['fid']);
     $thread['forumurl'] = getForumUrl($thread['fid']);
     $thread['descrip'] = getDescripByTid($tid);
     return $thread;
 }
예제 #3
0
define('AJAX', 1);
InitGP(array('tid', 'block_id'));
$tid = (int) $tid;
if (!$tid) {
    exit;
}
$thread = $db->get_one("SELECT tid,fid,author,authorid,subject,type,postdate,hits,replies FROM pw_threads WHERE tid=" . pwEscape($tid));
$temp = array();
if ($thread) {
    $temp = array();
    $temp['url'] = 'read.php?tid=' . $thread['tid'];
    $temp['title'] = $thread['subject'];
    $temp['image'] = '';
    $temp['forumname'] = getForumName($thread['fid']);
    $temp['forumurl'] = getForumUrl($thread['fid']);
    $temp['descrip'] = getDescripByTid($tid);
    //	$block	= $stopic_service->getBlockById($block_id);
    //	foreach ($block['config'] as $value) {
    //		if ($value == 'descrip') {
    //			$temp[$value] = getDescripByTid($tid);
    //		} elseif (array_key_exists($value,$thread)) {
    //			$temp[$value] = $thread[$value];
    //		} else {
    //			$temp[$value] = '';
    //		}
    //	}
    $temp = pwJsonEncode($temp);
    echo "success\t" . $temp;
} else {
    echo "error";
}
예제 #4
0
 function _analyseResult($parameter, $value)
 {
     if (!$parameter) {
         return array();
     }
     $temp = array();
     foreach ($parameter as $k => $val) {
         if (in_array($k, array('url', 'title', 'image', 'value', 'forumname', 'forumurl'))) {
             $temp_2 = $value[$k];
         } elseif ($k == 'descrip' && !isset($value[$k])) {
             //TODO
             $temp_2 = getDescripByTid($value['addition']['tid']);
         } elseif ($k == 'tagrelate') {
             $temp_2 = array();
         } elseif (isset($value[$k])) {
             $temp_2 = $value[$k];
         } elseif (isset($value['addition'][$k])) {
             $temp_2 = $value['addition'][$k];
         } elseif ($k == 'icon') {
             if (isset($value['uid'])) {
                 $uid = $value['uid'];
             } elseif (isset($value['addition']['uid'])) {
                 $uid = $value['addition']['uid'];
             } elseif (isset($value['authorid'])) {
                 $uid = $value['authorid'];
             } elseif (isset($value['addition']['authorid'])) {
                 $uid = $value['addition']['authorid'];
             }
             $temp_2 = $uid ? $this->_getUserIconByUid($uid) : '';
         } else {
             $temp_2 = '';
         }
         $temp[$k] = $this->_analyseResultByParameter($temp_2, $val, $k);
     }
     return $temp;
 }
예제 #5
0
 function _analyseResults($result, $parameter)
 {
     if ($parameter && is_array($parameter)) {
         $temp = array();
         foreach ($result as $key => $value) {
             foreach ($parameter as $k => $val) {
                 if (in_array($k, array('url', 'title', 'image', 'value', 'forumname', 'forumurl'))) {
                     $temp_2 = $value[$k];
                 } elseif ($k == 'descrip') {
                     $temp_2 = getDescripByTid($value['addition']['tid']);
                 } elseif ($k == 'tagrelate') {
                     $temp_2 = array();
                 } elseif (isset($value['addition'][$k])) {
                     $temp_2 = $value['addition'][$k];
                 } else {
                     $temp_2 = '';
                 }
                 $temp[$key][$k] = $this->_analyseResultByParameter($temp_2, $val, $k);
             }
         }
         $result = $temp;
     }
     return $result;
 }