当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_Ad::setSetting方法代码示例

本文整理汇总了PHP中Model_Ad::setSetting方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Ad::setSetting方法的具体用法?PHP Model_Ad::setSetting怎么用?PHP Model_Ad::setSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model_Ad的用法示例。


在下文中一共展示了Model_Ad::setSetting方法的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');
//.........这里部分代码省略.........
开发者ID:pancke,项目名称:yyaf,代码行数:101,代码来源:Ad.php


注:本文中的Model_Ad::setSetting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。