_hotSpotObj) { $this->_hotSpotObj = new App_Banner_HotSpotObj(); } return $this->_hotSpotObj; } protected function _doView() { $item = $scriptOptions = $this->getConfig(); $item['tpl'] = 'Banner/view.tpl'; $item['width'] = $this->dataObj->imageWidth; $item['htmlWidth'] = $this->dataObj->htmlWidth; $item['height'] = $this->dataObj->imageHeight; $item['idItem'] = $this->getIdItem(); $listOptions = array('order' => array('Banner.sorter')); $limit = intval($this->getConfig('limit')); if ($limit) { $listOptions['limit'] = $limit; } $list = $this->dataObj->getList($listOptions); if (is_array($list) && !empty($list)) { $hotSpot = $this->_getHotSpotObj(); foreach ($list as &$banner) { $hotSpot->setIdBanner($banner['id']); $banner['hotSpotMap'] = $this->_getHotSpotsMap($hotSpot->getData(false, true), $banner); $banner['title'] = htmlspecialchars($banner['title']); if ($banner['backgroundImage']) { $banner['backgroundImage'] = Qs_ImageFs::get( $banner['backgroundImage'], $item['width'], $item['height'] ); } $banner['image'] = Qs_ImageFs::get( $banner['image'], $item['width'], $item['height'] ); } unset($banner); } $item['banners'] = $list; foreach ($scriptOptions as $field => &$value) { if (in_array($value, array('y', 'n'))) { $value = ('y' == $value); } } if ($scriptOptions['enablePaginator']) { $this->doc->addStylesheet('css/yui-build/paginator.css'); $this->doc->addScript('js/lib/yui-build/paginator.js'); } $scriptOptions['idItem'] = $item['idItem']; $scriptOptions['banners'] = $item['banners']; $scriptOptions['debug'] = Qs_Constant::get('DEBUG'); $scriptOptions['width'] = $item['width']; $scriptOptions['height'] = $item['height']; $scriptOptions['htmlWidth'] = $item['htmlWidth']; $this->_addItem($item); $this->doc->addStylesheet('css/banner.css') ->addScript('js/app/banner.js') ->addInitFunction('App_Banner.prototype.init', array($scriptOptions)); return $this; } protected function _getHotSpotsMap($hotSpot, $banner) { $map = array(); $target = ($banner['linkType'] == 'url') ? '_blank' : '_self'; if (is_array($hotSpot) && !empty($hotSpot)) { $hotSpot = array_reverse($hotSpot); foreach ($hotSpot as $k => $area) { $target = '_self'; if ($area['urlType'] == 'page') { $page = App_Cms_Obj::getInstance()->getPageById($area['idPage']); $area['url'] = BASE_URL . '/' . $page['fullAlias']; } else { if (strpos($area['url'], BASE_URL) !== 0) { $target = '_blank'; } } $coords = array(); if ($area['type'] == 'circle') { $radius = round((int) $area['height'] / 2); $coords[] = (int) $area['left'] + $radius; $coords[] = (int) $area['top'] + $radius; $coords[] = $radius; } else { $coords[] = (int) $area['left']; $coords[] = (int) $area['top']; $coords[] = $coords[0] + (int) $area['width']; $coords[] = $coords[1] + (int) $area['height']; } $coords = implode(',', $coords); $map[$k] = array( 'href' => htmlspecialchars($area['url']), 'target' => $target, 'shape' => $area['type'], 'coords' => $coords, 'alt' => '' ); } if ($banner['url']) { if (strpos($banner['url'], BASE_URL) !== 0) { $target = '_blank'; } $mapUrl = array( 'target' => $target, 'coords' => '0,0,' . $this->dataObj->imageWidth . ',' . $this->dataObj->imageHeight, 'href' => htmlspecialchars($banner['url']), 'shape' => 'rect', 'alt' => '' ); array_push($map, $mapUrl); } } else { if ($banner['url']) { $map[0] = array( 'target' => $target, 'shape' => 'rect', 'href' => htmlspecialchars($banner['url']), 'coords' => '0,0,' . $this->dataObj->imageWidth . ',' . $this->dataObj->imageHeight, 'alt' => '' ); } } if (empty($map) || (count($map) == 0)) { $map = 'empty'; } return $map; } public function fillConfigForm($form) { $form->addElement( 'select', 'effect', array( 'label' => 'Effect', 'multiOptions' => $this->dataObj->getDBannerEffect4Select() ) ); $form->addElement( 'text', 'interval', array('label' => 'Interval', 'required' => true, 'class' => 'digit', 'size' => 5) ); $form->interval->getDecorator('ViewHelper')->setAdditionalHtmlAfterElement(' seconds'); $form->interval->addValidator('Int', true); $checkboxDecorators = array( 'ViewHelper', 'Errors', array('decorator' => 'Label', 'options' => array('placement' => 'APPEND')), 'DtDdWrapper' ); $form->addElement('text', 'effectDuration', array('label' => 'Effect Duration', 'required' => true, 'class' => 'digit', 'size' => 5)); $form->effectDuration->getDecorator('ViewHelper')->setAdditionalHtmlAfterElement(' miliseconds'); $form->effectDuration->addValidator('Int', true); $form->addElement( 'checkbox', 'enableButtons', array('label' => 'Show Player Buttons', 'checkedValue' => 'y', 'uncheckedValue' => 'n', 'decorators' => $checkboxDecorators) ); $form->addElement( 'checkbox', 'autoHideToolbar', array('label' => 'Auto Hide Toolbar', 'checkedValue' => 'y', 'uncheckedValue' => 'n', 'decorators' => $checkboxDecorators) ); $form->addElement( 'checkbox', 'showArrows', array('label' => 'Show Arrows', 'checkedValue' => 'y', 'uncheckedValue' => 'n', 'decorators' => $checkboxDecorators) ); $form->addElement( 'checkbox', 'autostart', array('label' => 'Autostart', 'checkedValue' => 'y', 'uncheckedValue' => 'n', 'decorators' => $checkboxDecorators) ); $form->addElement( 'checkbox', 'enablePaginator', array( 'label' => 'Show Paginator', 'checkedValue' => 'y', 'uncheckedValue' => 'n', 'decorators' => $checkboxDecorators ) ); $form->addElement('text', 'limit', array('label' => 'Limit Banners', 'class' => 'digit', 'size' => 5)); $form->limit->getDecorator('ViewHelper') ->setAdditionalHtmlAfterElement(' (leave blank to have no limits)'); $paginatorOptions = new Qs_Form_SubForm(array('legend' => 'Paginator Options')); $paginatorOptions->addElement( 'text', 'pageLinks', array('label' => 'Links Count', 'required' => false, 'class' => 'digit', 'size' => 5) ); $paginatorOptions->pageLinks->getDecorator('ViewHelper') ->setAdditionalHtmlAfterElement(' (leave blank to calculate automatically)'); $paginatorOptions->pageLinks->addValidator('Int', true); $paginatorOptions->addElement( 'text', 'linkWidth', array('label' => 'Link Width', 'class' => 'digit', 'size' => 5) ); $paginatorOptions->linkWidth->getDecorator('ViewHelper')->setAdditionalHtmlAfterElement(' px'); $paginatorOptions->linkWidth->addValidator('Int', true); $paginatorOptions->addElement( 'text', 'template', array( 'label' => 'Template', 'description' => 'Constants: {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}' ) ); $form->addSubForm($paginatorOptions, 'paginatorOptions'); return $this; } }