本文整理匯總了PHP中Model_Ad::updMedia方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Ad::updMedia方法的具體用法?PHP Model_Ad::updMedia怎麽用?PHP Model_Ad::updMedia使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model_Ad
的用法示例。
在下文中一共展示了Model_Ad::updMedia方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: add3Action
/**
* 設置廣告
*/
public function add3Action()
{
if ($this->isPost()) {
$iAdID = (int) $this->getParam('iAdID', 0);
$aAd = Model_Ad::getDetail($iAdID);
if (empty($aAd) || $aAd['iUserID'] != $this->aCurrUser['iUserID']) {
return $this->show404();
}
$aErr = array();
$aData = array();
$aData['iAdID'] = $iAdID;
$aData['iAdPos'] = (int) $this->getParam('iAdPos');
$aData['iPlanTime'] = strtotime($this->getParam('iPlanTime'));
if ($aData['iPlanTime'] < strtotime('+2hour')) {
$aErr['iPlanTime'] = '投放時間必須晚於當前時間2小時';
}
if ($aData['iPlanTime'] > strtotime('+7day')) {
$aErr['iPlanTime'] = '投放時間必須小於7天';
}
switch ($aAd['iMediaType']) {
case Model_Media::TYPE_WEIXIN:
$aData['sImportUrl'] = $this->getParam('sImportUrl', '');
$aData['sWordFile'] = $this->getParam('sWordFile', '');
$aData['sTitle'] = $this->getParam('sTitle');
$aData['sCoverImg'] = $this->getParam('sCoverImg');
$aData['iIsCover'] = (int) $this->getParam('iIsCover');
$aData['sAbstract'] = $this->getParam('sAbstract');
$aData['sContent'] = $this->getParam('sContent');
$aData['sOriginalUrl'] = $this->getParam('sOriginalUrl');
if (!Util_Validate::isCLength($aData['sTitle'], 2, 50)) {
$aErr['sTitle'] = '請輸入標題';
}
if ($aData['iIsCover'] && empty($aData['sCoverImg'])) {
$aErr['sCoverImg'] = '請上傳封麵圖';
}
// if (empty($aData['sAbstract'])) {
// $aErr['sAbstract'] = '請輸入摘要';
// }
if (!Util_Validate::isCLength($aData['sContent'], 20, 999999)) {
$aErr['sContent'] = '請輸入內容至少20個字';
}
break;
case Model_Media::TYPE_FRIEND:
case Model_Media::TYPE_WEIBO:
$aData['sForwardUrl'] = $this->getParam('sForwardUrl', '');
$aData['sForwardText'] = $this->getParam('sForwardText', '');
$aForwardImg = $this->getParam('aForwardImg');
if ($aData['iAdPos'] == 1) {
if (!Util_Validate::isAbsoluteUrl($aData['sForwardUrl'])) {
$aErr['sForwardUrl'] = '請輸入正確的投放地址';
}
} else {
if (!empty($aData['sForwardUrl']) && !Util_Validate::isAbsoluteUrl($aData['sForwardUrl'])) {
$aErr['sForwardUrl'] = '請輸入正確的投放地址';
}
}
if (!Util_Validate::isCLength($aData['sForwardText'], 5, 200)) {
$aErr['sForwardText'] = '投放文字長度為5~200字之間';
}
$aData['sForwardImg'] = array();
foreach ($aForwardImg as $sForwardImg) {
if (!empty($sForwardImg)) {
$aData['sForwardImg'][] = $sForwardImg;
}
}
if (empty($aData['sForwardImg'])) {
$aErr['sForwardImg'] = '請至少選擇一張投放配圖';
$aForwardImg = array();
}
$aData['sForwardImg'] = join(',', $aData['sForwardImg']);
break;
}
if (!empty($aErr)) {
return $this->showMsg($aErr, false);
}
Model_Ad::setSetting($aAd, $aData);
return $this->showMsg($aAd['iAdID'], true);
} else {
$iAdID = (int) $this->getParam('id', 0);
$aAd = Model_Ad::getDetail($iAdID);
if (empty($aAd) || $aAd['iUserID'] != $this->aCurrUser['iUserID']) {
return $this->show404();
}
$sCookieKey = 'media_choose_' . $aAd['iMediaType'];
$aChooseID = isset($_COOKIE[$sCookieKey]) ? explode(',', $_COOKIE[$sCookieKey]) : array();
if (!empty($aChooseID)) {
Model_Ad::updMedia($iAdID, $aChooseID, $this->aCurrUser['iUserID']);
}
setcookie($sCookieKey, null, 0, '/');
$aSetting = Model_Ad::getSetting($aAd);
if (!empty($aSetting) && isset($aSetting['sForwardImg'])) {
$aSetting['aForwardImg'] = explode(',', $aSetting['sForwardImg']);
}
$this->assign('aTitle', Model_Media::$aPos[$aAd['iMediaType']]);
$this->assign('aSetting', $aSetting);
$this->assign('aAd', $aAd);
$this->assign('sTopMenu', 'aadd');
//.........這裏部分代碼省略.........