Beispiel #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']);
 }
Beispiel #2
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return ADS_BOL_Service
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Beispiel #3
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;
 }