コード例 #1
0
ファイル: WechatShare.class.php プロジェクト: kevicki/pig
	public function getShareData($params)
	{
		$params["moduleName"] = (empty($params["moduleName"]) ? MODULE_NAME : $params["moduleName"]);
		$params["moduleID"] = (empty($params["moduleID"]) ? 0 : $params["moduleID"]);
		$params["imgUrl"] = (empty($params["imgUrl"]) ? "" : $params["imgUrl"]);

		if (empty($params["sendFriendLink"])) {
			$params["sendFriendLink"] = stripslashes(getSelfUrl(array("wecha_id")));
		}
		else {
			$params["sendFriendLink"] = stripslashes(getSelfUrl(array("wecha_id"), $params["sendFriendLink"]));
		}

		$params["tTitle"] = (empty($params["tTitle"]) ? "" : shareFilter($params["tTitle"]));
		$params["tContent"] = (empty($params["tContent"]) ? $params["tTitle"] : shareFilter($params["tContent"]));
		$shareData = str_replace("\/", "/", json_encode($params));
		$html = "\t\t<script type=\"text/javascript\">\r\n\t\t\t\twindow.shareData = $shareData;\r\n\t\t</script>";
		return $html;
	}
コード例 #2
0
ファイル: WechatShare.class.php プロジェクト: fkssei/pigcms10
    /**
     * 分享
     * @param Array $params
     * @return string
     */
    public function getShareData($params = array())
    {
        $params['moduleName'] = empty($params['moduleName']) ? MODULE_NAME : $params['moduleName'];
        $params['moduleID'] = empty($params['moduleID']) ? 0 : $params['moduleID'];
        $params['imgUrl'] = empty($params['imgUrl']) ? '' : $params['imgUrl'];
        if (empty($params['sendFriendLink'])) {
            $params['sendFriendLink'] = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
            $parseUrl = parse_url($params['sendFriendLink']);
            parse_str(htmlspecialchars_decode($parseUrl['query']), $query);
            $wecha_id = isset($query['wecha_id']) ? $query['wecha_id'] : '';
            if (1 == count($query)) {
                $wecha_id = '\\?wecha_id=' . $wecha_id;
            } else {
                $wecha_id = '&wecha_id=' . $wecha_id . '|' . 'wecha_id=' . $wecha_id . '&';
            }
            $params['sendFriendLink'] = preg_replace("/{$wecha_id}/i", '', $params['sendFriendLink']);
        } else {
            $params['sendFriendLink'] = stripslashes($params['sendFriendLink']);
        }
        $params['tTitle'] = empty($params['tTitle']) ? '' : shareFilter($params['tTitle']);
        $params['tContent'] = empty($params['tContent']) ? $params['tTitle'] : shareFilter($params['tContent']);
        $shareData = str_replace('\\/', '/', json_encode($params));
        $html = <<<EOM
\t\t<script type="text/javascript">
\t\t\t\twindow.shareData = {$shareData};
\t\t</script>
EOM;
        return $html;
    }
コード例 #3
0
ファイル: WechatShare.class.php プロジェクト: hehekeke/pigcms
 public function getShareData($params = array())
 {
     $params['moduleName'] = empty($params['moduleName']) ? MODULE_NAME : $params['moduleName'];
     $params['moduleID'] = empty($params['moduleID']) ? 0 : $params['moduleID'];
     $params['imgUrl'] = empty($params['imgUrl']) ? '' : $params['imgUrl'];
     if (empty($params['sendFriendLink'])) {
         $params['sendFriendLink'] = stripslashes(getSelfUrl(array('wecha_id')));
     } else {
         $params['sendFriendLink'] = stripslashes(getSelfUrl(array('wecha_id'), $params['sendFriendLink']));
     }
     $params['tTitle'] = empty($params['tTitle']) ? '' : shareFilter($params['tTitle']);
     $params['tContent'] = empty($params['tContent']) ? $params['tTitle'] : shareFilter($params['tContent']);
     $shareData = str_replace('\\/', '/', json_encode($params));
     $html = '		<script type="text/javascript">' . "\r\n" . '				window.shareData = ' . $shareData . ';' . "\r\n" . '		</script>';
     return $html;
 }