<?php
!defined('P_W') && exit('Forbidden');
define('M_P',1);
/**
 * 店铺发送到新鲜事SERVICE
 */
class weibo_Dianpu extends baseWeibo {
	var $_did;
	var $_dianpuid;
	var $_productid;
	var $_url;
	function weibo_Dianpu() {
		
	}
	function init($id) {
		list($dianpuId,$productId) = explode('_',$id);
		if($productId){
			$this->_dianpuid = intval($dianpuId);
			$this->_productid = intval($productId);
			$this->initProduct();
		}else{
			$this->_dianpuid = intval($dianpuId);
			$this->initDianpu();
		}
	}
	
	function initDianpu(){
		$this->_url = $GLOBALS['db_bbsurl']."/index.php?m=dianpu&c=info";
		require_once(R_P. 'mode/dianpu/require/core.php');
		$dianpuDB = DP::loadDB('dianpu_dianpu'); /* @var $dianpuDB PW_Dianpu_DianpuDB */
		$dianpu = $dianpuDB->getDianpuById($this->_dianpuid);
		empty($dianpu) && Showmsg('data_error');
		$this->_url = $this->_url . "&id=".$this->_dianpuid;
		$title = $content = sprintf("[url=%s] %s [/url]", $this->_url, $dianpu['title']);
		$descrip = $dianpu['title'];
		$mailSubject =  getLangInfo('dianpu','dianpu_recommend');
		$mailContent = getLangInfo('dianpu','ajax_sendweibo_dianpuinfo',array('title'	=> $title,'descrip'=>$descrip));
		$this->_content = $content;
		$this->_mailSubject = $mailSubject;
		$this->_mailContent = $mailContent;
	}
	
	function initProduct(){
		$this->_url = $GLOBALS['db_bbsurl']."/index.php?m=dianpu&c=product&a=detail";
		require_once(R_P. 'mode/dianpu/require/core.php');
		$productService = DP::loadClass('productsservice','service');
		$product = $productService->getProduct($this->_productid);
		empty($product) && Showmsg('data_error');
		$this->_url = $this->_url . "&id=".$this->_dianpuid."&productid=".$this->_productid;
		$title = $content = sprintf("[url=%s] %s [/url]", $this->_url, $product['title']);
		$descrip = $product['description'];
		$mailSubject =  getLangInfo('dianpu','dianpu_product_recommend');
		$mailContent = getLangInfo('dianpu','ajax_sendweibo_dianpu_product',array('title'	=> $title,'descrip'=>$descrip));
		$this->_content = $content.getLangInfo('dianpu','dianpu_product_content');;
		$this->_mailSubject = $mailSubject;
		$this->_mailContent = $mailContent;
	}
}
?>