Ejemplo n.º 1
1
 /**
  * @return Constructor.
  */
 public function __construct($params)
 {
     parent::__construct();
     $adsService = ADS_BOL_Service::getInstance();
     $rhandlerAttrs = OW::getRequestHandler()->getHandlerAttributes();
     $pluginKey = OW::getAutoloader()->getPluginKey($rhandlerAttrs['controller']);
     if (empty($params['position']) || OW::getUser()->isAuthorized('ads', 'hide_ads')) {
         $this->setVisible(false);
         return;
     }
     $position = trim($params['position']);
     if (!in_array($position, array(ADS_BOL_Service::BANNER_POSITION_TOP, ADS_BOL_Service::BANNER_POSITION_SIDEBAR, ADS_BOL_Service::BANNER_POSITION_BOTTOM))) {
         $this->setVisible(false);
         return;
     }
     $location = BOL_GeolocationService::getInstance()->ipToCountryCode3(OW::getRequest()->getRemoteAddress());
     $banners = ADS_BOL_Service::getInstance()->findPlaceBannerList($pluginKey, $params['position'], $location);
     if (empty($banners)) {
         $this->setVisible(false);
         return;
     }
     $banner = $banners[array_rand($banners)];
     $event = new OW_Event('ads_get_banner_code', array('pluginKey' => $pluginKey, 'position' => $params['position'], 'location' => $location));
     $result = OW::getEventManager()->trigger($event);
     $data = $result->getData();
     $this->assign('code', empty($data) ? $banner->getCode() : $data);
     $this->assign('position', $params['position']);
 }
Ejemplo n.º 2
0
 /**
  *
  * @return BOL_GeolocationService 
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Ejemplo n.º 3
0
 public function findAllBannersInfo()
 {
     $info = $this->bannerDao->findAllBannersInfo();
     $resultArray = array();
     foreach ($info as $infoItem) {
         if (!isset($resultArray[$infoItem['id']])) {
             $resultArray[$infoItem['id']] = array();
             $resultArray[$infoItem['id']] = array('label' => $infoItem['label'], 'code' => $infoItem['code']);
         }
         if ($infoItem['location'] !== null) {
             if (!isset($resultArray[$infoItem['id']]['location'])) {
                 $resultArray[$infoItem['id']]['location'] = array();
             }
             $resultArray[$infoItem['id']]['location'][$infoItem['location']] = BOL_GeolocationService::getInstance()->getCountryNameForCC3($infoItem['location']);
         }
     }
     return $resultArray;
 }
Ejemplo n.º 4
0
 private function getAdsForm($name)
 {
     $language = OW::getLanguage();
     $form = new Form($name);
     $title = new TextField('title');
     $title->setLabel($language->text('ads', 'ads_add_banner_title_label'));
     $title->setRequired(true);
     $form->addElement($title);
     $bannerCode = new Textarea('code');
     $bannerCode->setRequired(true);
     $bannerCode->setLabel($language->text('ads', 'ads_add_banner_code_label'));
     $bannerCode->setDescription($language->text('ads', 'ads_add_banner_code_desc'));
     $form->addElement($bannerCode);
     if ($this->adsService->getLocationEnabled()) {
         $countSelect = new Multiselect('select_country');
         $countSelect->setLabel($language->text('ads', 'ads_add_banner_country_label'));
         $countSelect->setDescription($language->text('ads', 'ads_add_banner_country_desc'));
         $countSelect->setOptions(BOL_GeolocationService::getInstance()->getAllCountryNameListForCC3());
         $form->addElement($countSelect);
     } else {
         $this->assign('locDisabled', true);
     }
     $submit = new Submit('submit');
     $submit->setValue($language->text('ads', 'ads_add_banner_submit_label'));
     $form->addElement($submit);
     return $form;
 }