function GetAdvertisementList($type = 'developer', $limit = 10, $orderBY = null, $OrderType = 'ASC') { App::import('Model', 'Advertisement'); $objAdvertisement = new Advertisement(); $this->Advertisement->recursive = -1; if ($orderBY != null) { $orderValue = array("Advertisement.{$orderBY}" => $OrderType); } else { $orderValue = 'RAND()'; } $arrData = $objAdvertisement->find("all", array("conditions" => array("Advertisement.gallery_type " => $type, 'Advertisement.active' => 'Y'), 'order' => $orderValue, 'limit' => $limit)); return $arrData; }
public function getData() { $result = array(); $result['preview'] = Advertisement::model()->getPreviewAdvertisementt($this->id); $result['next'] = Advertisement::model()->getNextAdvertisementt($this->id); return $result; }
/** * Save videos to youtube. * @param Advertisement $model * @param CUploadedFile[] $videos */ public static function processAdvertisement($model, $videos) { if (!empty($videos) && is_array($videos)) { $result = array(); foreach ($videos as $video) { $result[] = Upload($video, $model->name, $model->description, 'Animals', 'Tags'); } if (!empty($result)) { $model->youtube = $result; $model->save(); } } }
function get_links() { $this->Paging["count"] = Advertisement::get($param = array('cnt' => TRUE), NULL); $params = array('cnt' => FALSE, 'show' => $this->Paging["show"], 'page' => $this->Paging["page"], 'sort_by' => 'changed', 'direction' => 'DESC'); $ads_data = Advertisement::get($params, NULL); return $ads_data; }
public function getData() { $view = $this->view; $data = array(); switch ($view) { case $view == 'adlist': $data = Advertisement::model()->getAdvertisements(); break; case $view == 'channel': foreach (Channel::model()->generateChannelList() as $channel => $v) { $data[] = Channel::model()->getChannels(0, $channel); } break; case $view == 'message': $data = Advertisement::model()->getValidateAdvertisements(4); break; case $view == 'register': $data = User::model()->findAll(array('order' => 'lastlogin DESC', 'limit' => 10)); break; case $view == 'adrelated': $_model = Advertisement::model()->getAdvertisementModel($_GET['id']); $data = Advertisement::model()->findAll(array('condition' => 'cid = :cid', 'order' => 'id DESC', 'limit' => 10, 'params' => array(':cid' => $_model->cid))); unset($_model); break; case $view = 'infolist': $_model = Advertisement::model()->getAdvertisementModel($_GET['id']); $data = Advertisement::model()->findAll(array('condition' => 'uid = :uid', 'order' => 'id DESC', 'limit' => 10, 'params' => array(':uid' => $_model->uid))); unset($_model); break; } return $data; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Advertisement::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function run() { parent::run(); $criteria = new CDbCriteria(); $criteria->order = 't.order ASC'; $menu = Menu::model()->findAll($criteria); $data['adv'] = Advertisement::model()->findAll("state = 1"); $this->render('bottom_logos', $data); }
function rentFormat($advertisement) { $str = Advertisement::getCurrency($advertisement)->display_cn; if ($advertisement->rent_measurement == "month") { return $str . "每月"; } else { return $str . "每日"; } }
public static function fetchAd($position, $start_at, $end_at, $s_id = 0, $c_id = 0, $p_id = 0, $range = 1) { $query = Advertisement::select('advertisements.*')->with(['eventItem'])->where('advertisements.ad_status', '>', 0)->join('event_positions', function ($q) use($position) { $q->on('event_positions.e_id', '=', 'advertisements.e_id')->where('event_positions.position', '=', $position); })->join('event_ranges', function ($q) { $q->on('event_ranges.e_id', '=', 'advertisements.e_id'); }); if ($range == 1) { $query = $query->where('event_ranges.s_id', '=', 0)->where('event_ranges.c_id', '=', 0)->where('event_ranges.p_id', '=', 0); } if ($range == 2) { $query = $query->where(function ($q) use($c_id, $p_id) { $q->where(function ($qq) use($c_id, $p_id) { $qq->where('event_ranges.c_id', '=', $c_id)->where('event_ranges.p_id', '=', $p_id); })->orWhere(function ($qq) { $qq->where('event_ranges.s_id', '=', 0)->where('event_ranges.c_id', '=', 0)->where('event_ranges.p_id', '=', 0); }); }); } if ($range == 3) { $query = $query->where(function ($q) use($s_id) { $q->where(function ($qq) use($s_id) { $qq->where('event_ranges.s_id', '=', $s_id); })->orWhere(function ($qq) { $qq->where('event_ranges.s_id', '=', 0)->where('event_ranges.c_id', '=', 0)->where('event_ranges.p_id', '=', 0); }); }); } $query = $query->join('event_items', function ($q) { $q->on('event_items.e_id', '=', 'advertisements.e_id'); }); if ($start_at) { $query = $query->where('advertisements.created_at', '>', $start_at); } if ($end_at) { $query = $query->where('advertisements.created_at', '<', $end_at); } $now = Tools::getNow(); $query = $query->where('event_items.e_start_at', '<', $now)->where('event_items.e_end_at', '>', $now); $query->orderBy('advertisements.created_at', 'DESC'); $ads = $query->get(); if (count($ads) > 0) { $data = []; foreach ($ads as $key => $ad) { $tmp = $ad->showInList(); $tmp['item_type'] = 2; $data[] = $tmp; } } else { $data = null; } return $data; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Advertisement::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'id_user' => $this->id_user, 'date' => $this->date, 'id_category' => $this->id_category]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text]); return $dataProvider; }
public function print_advertisement($ad_type, $position = null, $center = false) { $ad = Advertisement::random($ad_type, substr($position, 0, 1)); if ($ad) { if ($ad->html) { $contents = $ad->html; } else { $contents = $this->linkTo($this->imageTag($ad->image_url, ['alt' => "Advertisement", 'width' => $ad->width, 'height' => $ad->height]), $this->redirectAdvertisementPath($ad), ['target' => '_blank']); } if ($center) { return $this->contentTag('div', $contents, ['style' => 'margin:0 auto;width:' . $ad->width . 'px;height:' . $ad->height . 'px;']); } else { return $contents; } } }
public function actionIndex() { $this->layout = '//layouts/frontend/home'; $this->pageTitle = 'Trang Chủ'; $listAds = Advertisement::model()->listAdvertisement(); $featuredPosts = Post::model()->getListFeaturedPost('vi', 7, 1); $homeServicesPosts = Post::model()->getListPostWithCategoryID(8, 6, Yii::app()->language); // $listProducts = Yii::app()->extraFunctions->parseTree(Menu::model()->getListMenu(Yii::app()->language, 'main_menu', 1, '2', NULL, 3, 8)); // $listServices = Yii::app()->extraFunctions->parseTree(Menu::model()->getListMenu(Yii::app()->language, 'main_menu', 1, '2', NULL, 4, 5)); // $listPromotions = Yii::app()->extraFunctions->parseTree(Menu::model()->getListMenu(Yii::app()->language, 'main_menu', 1, '2', NULL, 6, 4)); // $listNews = Yii::app()->extraFunctions->parseTree(Menu::model()->getListMenu(Yii::app()->language, 'main_menu', 1, '2', NULL, 5, 2)); // $listSupports = Yii::app()->extraFunctions->parseTree(Menu::model()->getListMenu(Yii::app()->language, 'main_menu', 1, '2', NULL, 7, 7)); // $listIntros = Yii::app()->extraFunctions->parseTree(Menu::model()->getListMenu(Yii::app()->language, 'main_menu', 1, '2', NULL, 2, 3)); // foreach ($listNews as $index => $obj) { // $listNews[$index]['url'] = preg_match('/^[http|https]+\:\/\//', $listNews[$index]['url']) ? $listNews[$index]['url'] : Yii::app()->createUrl($listNews[$index]['url']); // } $this->render('index', array('listAds' => $listAds, 'featuredPosts' => $featuredPosts, 'homeServicesPosts' => $homeServicesPosts)); }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $criteria = Advertisement::model()->setFetchCondition(5); $latestInfo = Yii::app()->cache->get($this->getUrlId() . '_latestInfo'); if ($latestInfo === false) { $latestInfo = Advertisement::model()->findAll($criteria); Yii::app()->cache->set($this->getUrlId() . '_latestInfo', $latestInfo, 3600, new CDbCacheDependency("SELECT MAX(id) FROM {{advertisement}}")); } $criteria->addColumnCondition(array('hasimg' => 1)); $criteria->limit = 4; $newInfo = Yii::app()->cache->get($this->getUrlId() . '_newInfo'); if ($newInfo === false) { $newInfo = Advertisement::model()->findAll($criteria); Yii::app()->cache->set($this->getUrlId() . '_newInfo', $newInfo, 3600, new CDbCacheDependency("SELECT MAX(id) FROM {{advertisement}}")); } // $newInfo = Advertisement::model()->findAll($criteria); // renders the view file 'protected/views/site/index.php' // using the default layout 'protected/views/layouts/main.php' $this->render('index', array('latestInfo' => $latestInfo, 'newInfo' => $newInfo)); }
$advertisement->url = $_POST['url']; $advertisement->timer = $_POST['timer']; $advertisement->launchin = $_POST['launchin']; $advertisement->appname = $_POST['appname']; $advertisement->appversion = $_POST['appversion']; $advertisement->clicked = $_POST['clicked']; $advertisement->bgcolor = $_POST['bgcolor']; $advertisement->textcolor = $_POST['textcolor']; $advertisement->create(); } else { if ($_POST['oper'] == 'edit') { $advertisement = Advertisement::get_by_id($_POST['id']); $advertisement->userid = $session->userid; $advertisement->image = $_POST['image']; $advertisement->text = $_POST['text']; $advertisement->url = $_POST['url']; $advertisement->timer = $_POST['timer']; $advertisement->launchin = $_POST['launchin']; $advertisement->appname = $_POST['appname']; $advertisement->appversion = $_POST['appversion']; // $advertisement->clicked = $_POST['clicked']; $advertisement->bgcolor = $_POST['bgcolor']; $advertisement->textcolor = $_POST['textcolor']; $advertisement->update(); } else { if ($_POST['oper'] == 'del') { $advertisement = Advertisement::get_by_id($_POST['id']); $advertisement->delete(); } } }
<span class="title"><a href="" class="bind_hover_card" bm_user_id="1"><?php echo $model->title; ?> </a></span> <br /> </h3> <span class="ico ico_footprint"></span> <span>有<?php echo count($model->statistics); ?> 人路过</span> <span class="ico ico_mark"></span> <span>特别提示:<span id="time"><?php echo Advertisement::model()->getAdvertisementExpired($model->end); ?> </span>过期</span> <?php if (Yii::app()->user->id == $model->uid) { ?> <span class="ico ico_pencil"></span> <span><a href="<?php echo $this->createUrl('/archiver/erelease', array('id' => $model->id, 't' => urlencode($model->title))); ?> ">编辑</a></span> <?php } ?> <br />
function get_links() { $condition = array(); if ($this->mode == 'textpad') { $condition['type'] = 'textpad'; } else { $condition['type'] = 'ad'; if (!empty($_REQUEST['gid'])) { $condition['group_id'] = (int) $_REQUEST['gid']; } else { $condition['group_id'] = NULL; } } $this->Paging["count"] = Advertisement::get(array('cnt' => TRUE), $condition); $params = array('cnt' => FALSE, 'show' => $this->Paging["show"], 'page' => $this->Paging["page"], 'sort_by' => 'changed', 'direction' => 'DESC'); $ads_data = Advertisement::get($params, $condition); return $ads_data; }
<script> $(document).ready(function () { totalUsers = "<?php echo User::model()->count(); ?> "; totalPosts = "<?php echo Post::model()->count(); ?> "; totalFeedbacks = "<?php echo Feedback::model()->count(); ?> "; totalAdvertisements = "<?php echo Advertisement::model()->count(); ?> "; countUp(totalUsers, '.count1'); countUp(totalPosts, '.count2'); countUp(totalFeedbacks, '.count3'); countUp(totalAdvertisements, '.count4'); }); function countUp(count, className) { var div_by = Math.round(count / 100), speed = Math.round(count / div_by), $display = $(className), run_count = 1, int_speed = 24;
/** * View detail post action. */ public function viewAction() { $config = Zend_Registry::get('config'); $this->view->headScript()->appendFile($config->baseurl . '/js/jquery.validate.min.js'); $this->view->headScript()->appendFile($config->baseurl . '/js/view.js'); $this->view->class = "view"; $city = $this->_getParam('city'); $id = $this->_getParam('id'); $advertisement = $this->advertisement->findById($id); if (isset($advertisement)) { $this->view->viewMode = 'detail'; $this->view->advertisement = $advertisement; $form = new SendIntrestMail($advertisement, $city); $this->view->form = $form; $cityObj = $this->city->findByName($city); $this->view->pageTitle = $advertisement->title . "| 租个房子 - " . $cityObj->name_cn_long; $pageDesc = ""; if ($advertisement->type == "want") { $this->view->pageImage = "want"; $pageDesc = $pageDesc . "最高房租:" . $advertisement->rent . $this->_helper->RentFormat($advertisement) . " | "; $pageDesc = $pageDesc . "最小面积:" . $advertisement->area . "平方米 | "; $pageDesc = $pageDesc . "时间:" . $advertisement->start_date; if ($this->_helper->DateIsValid($advertisement->stop_date)) { $pageDesc = $pageDesc . "到" . $advertisement->stop_date; } else { $pageDesc = $pageDesc . "起长期"; } $pageDesc = $pageDesc . "\n描述:" . $advertisement->description; } else { $this->view->pageImage = "lease"; $pageDesc = $pageDesc . "地址:" . $advertisement->address . " | "; $pageDesc = $pageDesc . "房租: " . $advertisement->rent . $this->_helper->RentFormat($advertisement) . " | "; $pageDesc = $pageDesc . "时间:" . $advertisement->start_date; if ($this->_helper->DateIsValid($advertisement->stop_date)) { $pageDesc = $pageDesc . "到" . $advertisement->stop_date; } else { $pageDesc = $pageDesc . "起长期"; } $pageDesc = $pageDesc . "\n描述:" . $advertisement->description; } if ($advertisement->category_id == Category::SHOP) { $this->view->pageImage = "business"; } $this->view->pageDesc = $pageDesc; if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { // $isValid = $this->_helper->common->validReCaptcha ($this->_getAllParams()); // if ($isValid) { $id = $form->getValue('id'); $city = $form->getValue('city'); // sender name $name = $form->getValue('name'); // sender email $email = $form->getValue('email'); // body $body = $form->getValue('body'); $advertisement = $this->advertisement->findById($id); $user = Advertisement::getUser($id); //$this->_helper->swiftEmail->sendEmail($body, Advertisement::getUser($advertisement->id)->email, $email, '租个房子'); $db = Zend_Registry::get('db'); $db->beginTransaction(); $data = array('name' => trim($name), 'email' => trim($email)); $sendUser = $this->user->addUser($data); $message = MailTemplate::getEmailMessage($name, $email, $user->email, $body, $advertisement, MailTemplate::SENDER_MAIL_BODY); $subject = MailTemplate::getEmailSubject($advertisement->title, MailTemplate::SUBJECT_SEND_TO_OWNER); $mailId = $this->mailQueue->addToQueue(MailType::USER, $name, $subject, $email, $user->email, $message, $this->_helper->generator->generateCurrentTime()); // add advertisement response $this->advertisementResponse->addAdvertisementResponse($id, $sendUser->id, $mailId); $message = MailTemplate::getEmailMessage($name, $email, $user->email, $body, $advertisement, MailTemplate::SENDER_RECIEPT_BODY); $subject = MailTemplate::getEmailSubject($advertisement->title, MailTemplate::SUBJECT_SENDER_RECEIPT); $this->mailQueue->addToQueue(MailType::USER, $name, $subject, Constant::SYSTEM_MAIL, $email, $message, $this->_helper->generator->generateCurrentTime()); $this->_flashMessenger->addMessage("您的邮件已成功发给贴主了!请等待回音!因为房源紧张,所以可能不会收到贴主的回复。请多找几处。最好电话联系!谢谢您的支持!!"); $db->commit(); $this->_redirect('/' . $city . '/bulletin/view/' . $advertisement->id); // } else { //// throw new Exception ( '验证码错误!' ); // } } } } else { throw new Exception('帖子ID缺失或者帖子未找到!'); } }
public function listCrowdFunding() { $per_page = Input::get('per_page', 30); $page = Input::get('page', 1); $cate = Input::get('cate', 0); $u_id = Input::get('u_id', 0); $range = Input::get('range', 1); $city = Input::get('city', 0); $province = Input::get('province', 0); $school = Input::get('school', 0); $filter_option = Input::get('filter_option', 0); //1-about to start, 2-hot, 3-about to end $key = Input::get('key', ''); try { if (!$u_id) { throw new Exception("请传入用户id", 7001); } $user = User::find($u_id); $user->load('school'); $now = Tools::getNow(); $query = CrowdFunding::select('crowd_fundings.*')->with(['city', 'school', 'user', 'user.school', 'product', 'eventItem', 'praises' => function ($q) { $q->where('praises.u_id', '=', $this->u_id); }])->where('c_status', '>', 2)->join('event_ranges', function ($q) { $q->on('event_ranges.e_id', '=', 'crowd_fundings.e_id'); })->join('event_items', function ($q) { $q->on('event_items.e_id', '=', 'crowd_fundings.e_id'); }); if ($cate) { $query = $query->where('c_cate', '=', $cate); } if ($school && $range == 3) { $query = $query->where('event_ranges.s_id', '=', $school); } if ($filter_option == 1) { $query = $query->where('event_items.e_start_at', '>', $now); } if ($filter_option == 2) { // time passed more than 20%, less than 50%, and gathered more than 60% quantity $query = $query->whereRaw('(DATEDIFF(CURDATE(), t_event_items.e_start_at)) > (t_crowd_fundings.c_time * 0.2)')->whereRaw('(DATEDIFF(CURDATE(), t_event_items.e_start_at)) < (t_crowd_fundings.c_time * 0.5)')->join('crowd_funding_products', function ($q) { $q->on('crowd_fundings.cf_id', '=', 'crowd_funding_products.cf_id'); })->whereRaw('t_crowd_funding_products.p_sold_quantity > (t_crowd_funding_products.p_target_quantity * 0.6)')->where('event_items.e_start_at', '<', $now); } if ($filter_option == 3) { // left time is less than 20% $query = $query->whereRaw('DATEDIFF(t_event_items.e_end_at, CURDATE()) < (t_crowd_fundings.c_time * 0.2)')->where('event_items.e_end_at', '>', $now); } if ($city && $province && $range == 2) { $query = $query->where(function ($q) use($city, $province) { $q->where(function ($qq) use($city, $province) { $qq->where('event_ranges.c_id', '=', $city)->where('event_ranges.p_id', '=', $province); })->orWhere(function ($qq) { $qq->where('event_ranges.c_id', '=', 0)->where('event_ranges.p_id', '=', 0)->where('event_ranges.s_id', '=', 0); }); }); } if ($key) { $query = $query->where(function ($q) use($key) { $q->where('event_items.e_title', 'LIKE', '%' . $key . '%')->orWhere('event_items.e_brief', 'LIKE', '%' . $key . '%')->orWhere('crowd_fundings.c_yield_desc', 'LIKE', '%' . $key . '%')->orWhere('crowd_fundings.c_content', 'LIKE', '%' . $key . '%'); }); } $query = $query->orderBy('crowd_fundings.created_at', 'DESC'); $list = $query->paginate($per_page); $data = []; $start = 0; $end = 0; foreach ($list as $k => $funding) { $tmp = $funding->showInList(); if ($k == 0) { $start = $end = $tmp['created_at_timestamps']; } else { $start = min($start, $tmp['created_at_timestamps']); $end = max($end, $tmp['created_at_timestamps']); } $tmp['is_praised'] = 0; if (count($funding->praises) > 0) { $tmp['is_praised'] = 1; } $tmp['item_type'] = 1; $data[] = $tmp; } if (!$key) { $start = $start > 0 ? date('Y-m-d H:i:s', $start) : null; if ($page == 1 && $list->getTotal() < $per_page) { $start = null; } $end = $end > 0 && $page != 1 ? date('Y-m-d H:i:s', $end) : null; $ad = Advertisement::fetchAd(1, $start, $end, $school, $city, $province, $range); if ($ad && $data) { $data = Advertisement::mergeArray($data, $ad); } elseif ($ad && !$data && $page < 2) { $data = $ad; } } $re = Tools::reTrue('获取众筹成功', $data, $list); } catch (Exception $e) { $re = Tools::reFalse($e->getCode(), '获取众筹失败:' . $e->getMessage()); } return Response::json($re); }
/** * Complete an offer if both ratings have been completed * * @param $id */ static function completeOffer($id) { $offer = self::getOfferSingle($id); $advertisement = Advertisement::getAdvertisement($offer['advertisement']); if (Rating::getRating($id, $offer['owner']) != null && Rating::getRating($id, $advertisement['owner']) != null) { $mysql = new MySQL(); $results = $mysql->query('UPDATE offer SET status = 3 WHERE id = :id', [':id' => $id]); } }
<?php include 'config.php'; if (isset($_GET['id_del'])) { //удаление объявления id из БД с ID = $id_del $id_del = $_GET['id_del']; // $bd = DbSimple_Generic::connect("mysqli://$user[user_name]:$user[password]@$user[server_name]/$user[database]"); // $bd->select('DELETE FROM form WHERE id = ?', $id_del); Advertisement::sql_DELETE($bd, $id_del); echo 'объявление удалено'; }
/** * @return \yii\db\ActiveQuery */ public function getAdvertisements() { return $this->hasMany(Advertisement::className(), ['advertisedby' => 'id']); }
<?php /** * @var $page */ if ($page['user']['usertype'] != "1") { Session::setError('You are not able to accept an Offer'); Session::redirect('/'); } $offer = Offer::getOfferSingle($page['parameters']['id']); if ($offer == null) { Session::setError('Offer does not exist'); Session::redirect('/'); } $advertisement = Advertisement::getAdvertisement($offer['advertisement']); if ($advertisement['owner'] != $page['user']['id']) { Session::setError('You do not own this offers parent advertisement'); Session::redirect('/'); } if ($offer['status'] != "0") { Session::setError('Offer can not be accepted.'); Session::redirect('/'); } $accepted = Offer::acceptOffer($page['parameters']['id']); if ($accepted) { Session::setSuccess('Successfully accepted offer'); Session::redirect('/offers/view/' . $offer['advertisement']); } Session::setError('Something went wrong, please try again.'); Session::redirect('/offers/view/' . $offer['advertisement']);
public function init() { if (isset($this->advertisement)) { $user = Advertisement::getUser($this->advertisement->id); $element = new Zend_Form_Element_Hidden('id'); $element->setValue($this->advertisement->id); $this->addElement($element); $element = new Zend_Form_Element_Hidden('password'); $element->setValue($this->password); $this->addElement($element); $this->setAction('/' . strtolower($this->city->name) . '/bulletin/update'); } else { $this->setAction('/' . strtolower($this->city->name) . '/bulletin/create'); } $element = new Zend_Form_Element_Hidden('city'); $element->setValue($this->city->id); $this->addElement($element); $this->setMethod('POST'); $this->setName('createAdForm'); $element = new Zend_Form_Element_Text('name'); $element->setLabel('怎么称呼您'); $element->setDescription('必填,中英文都可,2到30个字'); $element->setRequired(true); //$element->addValidator(new Zend_Validate_StringLength(2,30)); if (isset($user)) { $element->setValue($user->name); } $this->addElement($element); $element = new Zend_Form_Element_Text('email'); $element->setLabel('您的Email'); $element->setRequired(true); $element->addValidator(new Zend_Validate_EmailAddress()); $element->addValidator('NotEmpty'); $element->setDescription('必填,将不会显示在您的帖子里'); if (isset($user)) { $element->setValue($user->email); } $this->addElement($element); $element = new Zend_Form_Element_Text('mobile'); $element->setLabel('您的手机号'); $element->addFilter(new Zend_Filter_HtmlEntities()); $element->addFilter(new Zend_Filter_StripTags()); $element->setDescription('方便其他用户联系您'); if (isset($user)) { $element->setValue($user->mobile); } $this->addElement($element); $this->addDisplayGroup(array('name', 'email', 'mobile'), 'aboutYou'); $this->getDisplayGroup('aboutYou')->removeDecorator('DtDdWrapper'); // radio box $element = new Zend_Form_Element_Radio('type'); $element->addMultiOptions(array('lease' => '供', 'want' => '求'))->removeDecorator('Label'); $element->setSeparator('')->setValue(Advertisement::LEASE); if (isset($this->advertisement)) { $element->setValue($this->advertisement->type); } $this->addElement($element); // category $element = new Zend_Form_Element_Checkbox("isBusiness"); $element->setLabel('是商铺/店面吗?'); if (isset($this->advertisement) && $this->advertisement->category_id == Category::SHOP) { $element->setValue(1); } else { $element->setValue(0); } $this->addElement($element); $element = new Zend_Form_Element_Text('title'); $element->setLabel('帖子标题'); $element->setRequired(true); $element->addValidator('NotEmpty'); //$element->addValidator(new Zend_Validate_StringLength(10,30)); $element->setDescription('必填,5-100字,概括题目,突出重点'); if (isset($this->advertisement)) { $element->setValue($this->advertisement->title); } $this->addElement($element); $element = new Zend_Form_Element_Text('address'); $element->setLabel('房子的住址'); $element->setDescription('必填,以便用户在地图上方便的找到'); if (isset($this->advertisement)) { $element->setValue($this->advertisement->address); } $this->addElement($element); $element = new Zend_Form_Element_Text('rent'); $element->setLabel('租金'); if (isset($this->advertisement)) { $element->setValue($this->advertisement->rent); } $this->addElement($element); $element = new Zend_Form_Element_Select('currency'); //$element->setLabel("货币"); $element->addMultiOptions(Currency::getAvailableCurrencyAsArray()); if (isset($this->advertisement)) { $element->setValue(Advertisement::getCurrency($this->advertisement)->id); } else { $element->setValue(127); } $this->addElement($element); $element = new Zend_Form_Element_Radio('rent_measurement'); $element->addMultiOptions(array('month' => '每月', 'day' => '每日'))->setSeparator('')->setDescription('必填')->removeDecorator('Label'); $element->setSeparator('')->setValue(Advertisement::RENT_MONTHLY); if (isset($this->advertisement)) { if ($this->advertisement->rent_measurement == Advertisement::RENT_MONTHLY) { $element->setValue('month'); } else { if ($this->advertisement->rent_measurement == Advertisement::RENT_DAILY) { $element->setValue('day'); } } } $element->setRequired(true); $element->addValidator('NotEmpty'); $element->addValidator(new Zend_Validate_Alnum()); $this->addElement($element); // start date and stop date $element = new Zend_Form_Element_Text('start_date'); $element->setRequired(true); $element->addValidator('NotEmpty'); $element->setLabel('开始日期'); $element->setDescription('必填,格式为2010-09-11'); if (isset($this->advertisement)) { $element->setValue($this->advertisement->start_date); } $this->addElement($element); $element = new Zend_Form_Element_Text('stop_date'); $element->setLabel('结束日期'); $element->setDescription('同上,留空则为长期'); if (isset($this->advertisement)) { $element->setValue($this->advertisement->stop_date); } $this->addElement($element); $element = new Zend_Form_Element_Text('area'); $element->setLabel('面积(平方米)'); $element->addValidator(new Zend_Validate_Alnum()); if (isset($this->advertisement)) { $element->setValue($this->advertisement->area); } $this->addElement($element); $element = new Zend_Form_Element_Text('num_of_room'); $element->setLabel('房间数'); $element->addValidator(new Zend_Validate_Alnum()); $element->setDescription('卧房数'); if (isset($this->advertisement)) { $element->setValue($this->advertisement->num_of_room); } $this->addElement($element); $element = new Zend_Form_Element_Textarea('description'); $element->setLabel('其他描述'); $element->setDescription('更多详细信息,例如: 交通是否方便? 是否有独立卫生间和厨房? 是否仅限女生? 是否有家具? 月租是否包括网费? 您的个人习惯等等。'); $element->setAttrib('rows', 4); if (isset($this->advertisement)) { $element->setValue($this->advertisement->description); } $this->addElement($element); $element = new Elements(); $element->addReCaptcha($this); $element = new Zend_Form_Element_Submit('post'); $element->setValue('提交')->removeDecorator('Label'); $this->addElement($element); $this->addDisplayGroup(array('isBusiness', 'type', 'title', 'address', 'rent', 'currency', 'rent_measurement', 'start_date', 'stop_date', 'area', 'num_of_room', 'description', 'challenge', 'post'), 'aboutRoom'); $this->getDisplayGroup('aboutRoom')->removeDecorator('DtDdWrapper'); }
if ($searchOper == 'eq') { $searchString = $searchString; } if ($searchOper == 'bw' || $searchOper == 'bn') { $searchString .= '%'; } if ($searchOper == 'ew' || $searchOper == 'en') { $searchString = '%' . $searchString; } if ($searchOper == 'cn' || $searchOper == 'nc' || $searchOper == 'in' || $searchOper == 'ni') { $searchString = '%' . $searchString . '%'; } $where = "{$searchField} {$ops} '{$searchString}'"; $advertisements = Advertisement::get_by_sql("SELECT * FROM " . T_ADVERTISEMENTS . " WHERE " . $where . " AND userid = " . $session->userid . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}"); } else { $advertisements = Advertisement::get_by_sql("SELECT * FROM " . T_ADVERTISEMENTS . " WHERE userid = " . $session->userid . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}"); } header("Content-type: text/xml;charset=utf-8"); $s = "<?xml version='1.0' encoding='utf-8'?>"; $s .= "<rows>"; $s .= "<page>" . $page . "</page>"; $s .= "<total>" . $total_pages . "</total>"; $s .= "<records>" . $count . "</records>"; foreach ($advertisements as $advertisement) { $s .= "<row id='" . $advertisement->id . "'>"; $s .= "<cell></cell>"; // action $s .= "<cell>" . $advertisement->appname . "</cell>"; $s .= "<cell>" . $advertisement->image . "</cell>"; $s .= "<cell>" . $advertisement->text . "</cell>"; $s .= "<cell>" . $advertisement->url . "</cell>";
<?php $login_required = FALSE; global $path_prefix; include "includes/page.php"; require_once "{$path_prefix}/api/Advertisement/Advertisement.php"; if (!empty($_GET['ad_id'])) { $condition = array('ad_id' => $_GET['ad_id']); $res = Advertisement::get($params = NULL, $condition); $hit_count = $res[0]->hit_count; $hit_count++; $update_fields = array('hit_count' => $hit_count); Advertisement::update($update_fields, $condition); }
private function initNew($cb, $default_mode, $default_block_type, $setting_data) { global $page_uid, $uid; // render all modules foreach ($this->modules_array as $module) { // standard column-specific initialization switch ($module->column) { case 'left': case 'right': if ($default_mode) { $module->mode = $default_mode; } // some modules don't like to be set as PRI/HOMEPAGE switch ($module->module_name) { case 'LogoModule': case 'AdsByGoogleModule': case 'GroupAccessModule': case 'GroupStatsModule': break; default: if ($default_block_type) { $module->block_type = $default_block_type; } } break; case 'middle': break; } // now call the page callback and see if we need to skip // displaying this module $skipped = $module->skipped; if ($cb && !$skipped) { switch ($cb($module->column, $module->module_name, $module, $this)) { case 'skip': $skipped = TRUE; break; } } // now render for display $render_time = NULL; if (!$skipped) { $start_time = microtime(TRUE); $html = $module->render(); if (!$module->do_skip) { //add the module to list if it is not being skipped from within the module. $render_time = microtime(TRUE) - $start_time; $this->module_arrays[$module->column][] = $html; } } if ($this->debugging) { $dhtml = "← {$module->module_name} ({$module->block_type}; {$module->mode}; " . sprintf("%.3f s", $render_time) . ")"; if ($skipped) { $dhtml .= " SKIPPED"; } $dhtml .= "<br>"; $this->module_arrays[$module->column][] = $dhtml; } } /* $pages = Advertisement::get_pages(); // get pages where ads is to be displayed $display_ad = FALSE; foreach ($pages as $page) { if (PA::$config->page_type == $page['value']) { $display_ad = TRUE; break; } } */ // the following code does exactly the same as // the above commented, only much more efficient // because it'snot loading ALL pages $display_ad = false; if (preg_match("/(network|group)/", $this->setting_data['page_type'])) { $display_ad = true; } if ($display_ad) { // get all ads $netw_ads = array(); try { $netw_ads = Advertisement::get(array('direction' => 'ASC', 'sort_by' => 'orientation'), array('page_id' => PA::$config->page_type, 'is_active' => ACTIVE, 'group_id' => NULL)); } catch (PAException $e) { Logger::log(__FILE__ . " " . $e->getMessage(), 32); } $group_ads = array(); if (!empty($_REQUEST['gid'])) { try { $group_ads = Advertisement::get(array('direction' => 'ASC', 'sort_by' => 'orientation'), array('page_id' => PA::$config->page_type, 'is_active' => ACTIVE, 'group_id' => (int) $_REQUEST['gid'])); } catch (PAException $e) { Logger::log(__FILE__ . " " . $e->getMessage(), 32); } } $all_ads = array(); foreach ($group_ads as $ad) { $all_ads[] = $ad; } foreach ($netw_ads as $ad) { $all_ads[] = $ad; } if (!empty($all_ads)) { foreach ($all_ads as $ad) { $pos = $ad->orientation; $pos = explode(',', $ad->orientation); $x_loc = $pos[0]; //y_loc was not originally designed so for already created ads //FIX for already created ads if (array_key_exists(1, $pos)) { $y_loc = $pos[1]; } else { $y_loc = 1; //Ads created before this logic implementation should come on top } //horizontal and vertical position should not be empty if (!empty($x_loc) && !empty($y_loc)) { $array_of_data = array('links' => $ad); $inner_html = $this->add_block_module('AdvertisementModule', $array_of_data); $this->add_module_xy($x_loc, $y_loc, $inner_html); } } } //end of if all_ads } //end of display_ad }
/** * Extracts an Advertisement object from an input PDO query result object. * * @param PDOItem $result * @param boolean $skeleton */ public function extractAdvertisementSearchObject(&$result) { $advertisement = null; try { if ($result[AdvertisementSearchDao::ADVERTISEMENT_ID_FIELD] !== null) { $genreList = null; $positionList = null; $advertisement = new Advertisement(); $advertisement->setVariable(Advertisement::ADVERTISEMENT_ID, $result[AdvertisementSearchDao::ADVERTISEMENT_ID_FIELD]); $advertisement->setVariable(Advertisement::ADVERTISEMENT_TYPE_ID, $result[AdvertisementSearchDao::ADVERTISEMENT_TYPE_ID_FIELD]); $advertisement->setVariable(Advertisement::SUMMARY, $result[AdvertisementSearchDao::ADVERTISEMENT_SUMMARY_FIELD]); $advertisement->setVariable(Advertisement::MEMBER_ID, $result[AdvertisementSearchDao::MEMBER_ID_FIELD]); $advertisement->setVariable(Advertisement::MEMBER_FIRST_NAME, $result[AdvertisementSearchDao::MEMBER_FIRST_NAME_FIELD]); $advertisement->setVariable(Advertisement::MEMBER_LAST_NAME, $result[AdvertisementSearchDao::MEMBER_LAST_NAME_FIELD]); $i = 1; for ($i = 1; $i <= AdvertisementSearchDao::POSITION_COUNT; $i++) { $positionID = $result[AdvertisementSearchDao::INSTRUMENT_ID_FIELD . $i]; if ($positionID != null) { $position = new AdvertisementPosition(); $position->setVariable(AdvertisementPosition::INSTRUMENT_ID, $positionID); $position->setVariable(AdvertisementPosition::INSTRUMENT_NAME, $result[AdvertisementSearchDao::INSTRUMENT_NAME_FIELD . $i]); $positionList[] = $position; } } $advertisement->setVariable(Advertisement::POSITION_LIST, $positionList); $advertisement->setVariable(Advertisement::START_DATE, $result[AdvertisementSearchDao::START_DATE_FIELD]); $advertisement->setVariable(LocationConstants::COUNTRY_ID, $result[AdvertisementSearchDao::COUNTRY_ID_FIELD]); $advertisement->setVariable(LocationConstants::STATE_ID, $result[AdvertisementSearchDao::STATE_ID_FIELD]); $advertisement->setVariable(LocationConstants::CITY_ID, $result[AdvertisementSearchDao::CITY_ID_FIELD]); $advertisement->setVariable(LocationConstants::REGION_ID, $result[AdvertisementSearchDao::REGION_ID_FIELD]); } } catch (PDOException $Exception) { echo "extractAdvertisementObject error: " . $Exception->getMessage(); } return $advertisement; }
/** * Populate notification list. * * Example: ctl 1686825444, crc e233847ad0507ae1d0890633ced692b9 */ public function populatenoficationlistAction() { $this->_helper->viewRenderer->setNoRender(); //view info disabled $this->_helper->layout->disableLayout(); $ctl = $this->_getParam('ctl'); $crc = $this->_getParam('crc'); $customerKey = ''; $startDate = $this->_getParam('start'); $generated_crc = md5($ctl); if ($generated_crc == $crc) { $notifiedBeforeDate = $this->_helper->generator->manipulatDate($this->_helper->generator->generateCurrentTime(), -Constant::NOTIFICATION_DAY, Zend_Date::DAY); $advertisements = $this->advertisement->findAdvertisementToSendNofication($notifiedBeforeDate); $numOfAdvs = count($advertisements); echo "Check advertisments created before " . $notifiedBeforeDate . "<br/>"; echo $numOfAdvs . " advertisements found might need to be notified<br/>"; $numOfAffected = 0; foreach ($advertisements as $advertisement) { $data = array("advertisement_id" => $advertisement->id, "type" => "close_advertisement", "status" => "valid", "created" => $this->_helper->generator->generateCurrentTime()); $db = Zend_Registry::get("db"); $db->beginTransaction(); // check if notification to be added is already exist. // only add to mail queue if it's a new one. $notification = $this->advertisementNotification->findByAdvertisementTypeAndStatus($advertisement->id, "close_advertisement", "valid"); if (empty($notification)) { $this->advertisementNotification->addOneEntry($data); $subject = MailTemplate::SUBJECT_CLOSE_NOTICATION; $user = Advertisement::getUser($advertisement->id); $pos = strpos($user->email, "@zugefangzi.com"); if ($pos == false) { $sender = Constant::SYSTEM_MAIL; } else { $sender = Constant::EMAIL_TO_SERVER; } $recipient = $user->email; $message = MailTemplate::getNotificationEmailMessage($advertisement, $recipient, MailTemplate::CLOSE_NOTIFICATION_BODY, Constant::CLOSE_NOTIFICATION); $this->mailQueue->addToQueue(MailType::CLOSE_NOTIFICATION, null, $subject, $sender, $recipient, $message, $this->_helper->generator->generateCurrentTime()); $numOfAffected++; } $db->commit(); } echo $numOfAffected . " advertisement(s) are affected"; echo "<hr/>"; // close down expired advertisements $advertisements = $this->advertisement->findAdvertisementToClose(); $numOfAdvs = count($advertisements); echo "Close expired advertisements<br/>"; echo $numOfAdvs . " advertisements found<br/>"; $numOfAffected = 0; $db = Zend_Registry::get("db"); $db->beginTransaction(); foreach ($advertisements as $advertisement) { $advertisement->status = PostStatus::CLOSED; $advertisement->save(); $subject = MailTemplate::SUBJECT_CLOSED_POST; $user = Advertisement::getUser($advertisement->id); $pos = strpos($user->email, "@zugefangzi.com"); if ($pos == false) { $sender = Constant::SYSTEM_MAIL; } else { $sender = Constant::EMAIL_TO_SERVER; } $recipient = $user->email; $message = MailTemplate::getNotificationEmailMessage($advertisement, $recipient, MailTemplate::CLOED_POST_BODY, Constant::CLOSE_NOTIFICATION); $this->mailQueue->addToQueue(MailType::SYSINFO, null, $subject, $sender, $recipient, $message, $this->_helper->generator->generateCurrentTime()); $numOfAffected++; } $db->commit(); echo $numOfAffected . " advertisement(s) are affected"; } else { throw new Exception('Not allowed to run the service!'); } }
$response->message = $user; $session->login($user); $advertisement = new Advertisement(); $advertisement->userid = $session->userid; $advertisement->image = "http://imgur.com/vGmLqT9.png"; $advertisement->text = "This will launch the browser"; $advertisement->url = "http://m.facebook.com/nemoryoliver"; $advertisement->timer = 10; $advertisement->launchin = "browser"; $advertisement->appname = "My App Name"; $advertisement->appversion = "1.0"; $advertisement->clicked = "0"; $advertisement->bgcolor = "#000000"; $advertisement->textcolor = "#FFFFFF"; $advertisement->create(); $advertisement2 = new Advertisement(); $advertisement2->userid = $session->userid; $advertisement2->image = "http://imgur.com/vGmLqT9.png"; $advertisement2->text = "This will launch the BlackBerry World App"; $advertisement2->url = "appworld://content/47649895"; $advertisement2->timer = 10; $advertisement2->launchin = "bbworld"; $advertisement2->appname = "My App Name 2"; $advertisement2->appversion = "1.0"; $advertisement2->clicked = "0"; $advertisement2->bgcolor = "#000000"; $advertisement2->textcolor = "#FFFFFF"; $advertisement2->create(); } else { $response->status = "bad"; $response->message = "Username or Password is invalid.";