_hotSpotObj) { $this->_hotSpotObj = new App_Slide_HotSpotObj(); } return $this->_hotSpotObj; } protected function _getHotSpots(array $ids) { $group = array(); if (true === $this->getConfig('hasHotSpots') && $ids) { $hotSpotObj = $this->_getHotSpotObj(); $hotSpotObj->setFilter(array('slideId' => $ids)); $list = $hotSpotObj->getList(); foreach ($list as $spot) { $group[$spot['slideId']][] = $spot; } } return $group; } protected function _doView() { $item = $scriptOptions = $this->getConfig()->toArray(); unset($item['__constructorOptions']); $item['tpl'] = 'Slide/view.tpl'; $item['maxWidth'] = $this->getConfig('image')->get('width'); $item['maxHeight'] = $this->getConfig('image')->get('height'); $item['resizeMethod'] = $this->getConfig('image')->get('resizeMethod'); $item['idItem'] = $this->getIdItem(); $limit = intval($this->getConfig('limit')); if ($limit) { $this->_getDataObj()->getListSelect()->limit($limit); } $list = $this->_getDataObj()->getList(); if (empty($list)) { return false; } if (is_array($list) && !empty($list)) { $hotSpotsData = $this->_getHotSpots(Qs_Array::fetchCol($list, 'id', array())); foreach ($list as &$slide) { $slide['hotSpotMap'] = $this->_getHotSpotsMap(Qs_Array::get($hotSpotsData, $slide['id']), $slide); $slide['title'] = htmlspecialchars($slide['title']); if ($slide['backgroundImage']) { $slide['backgroundImage'] = Qs_ImageFs::get( $slide['backgroundImage'], $item['maxWidth'], $item['maxHeight'], $item['resizeMethod'] ); } if ($slide['image']) { $slide['image'] = Qs_ImageFs::get( $slide['image'], $item['maxWidth'], $item['maxHeight'], $item['resizeMethod'] ); } if ($slide['type'] == App_Slide_View::HTML_TYPE) { Qs_Smarty_File::setTemplate('Slide/slide.tpl'); $slide['content'] = Qs_Smarty_File::render($slide); } } unset($slide); } $item['slides'] = $list; foreach ($scriptOptions as &$value) { if (in_array($value, array('y', 'n'))) { $value = ('y' == $value); } } if ($scriptOptions['enablePaginator']) { $this->_doc->addStylesheet('css/thirdpart/yui-build/paginator.css'); $this->_doc->addScript('js/lib/yui-build/paginator.js'); } $scriptOptions['idItem'] = $item['idItem']; $scriptOptions['slides'] = $item['slides']; $scriptOptions['debug'] = Qs_Constant::get('DEBUG'); $scriptOptions['maxWidth'] = $item['maxWidth']; $scriptOptions['maxHeight'] = $item['maxHeight']; if (is_file(constant('WWW_PATH') . '/' . $this->_testImage)) { $scriptOptions['testImage'] = constant('BASE_URL') . '/' . $this->_testImage; } $this->_addItem($item); $this->_doc->addStylesheet('css/modules/slide.css') ->addScript('js/jquery.cj-swipe.js') ->addScript('js/app/slide.js') ->addInitFunction('App_Slide.prototype.init', array($scriptOptions)); return $this; } protected function _getHotSpotsMap($hotSpot, $slide) { $_coords = '0,0,' . $this->getConfig()->get('image')->width . ',' . $this->getConfig()->get('image')->height; $map = array(); $slideTarget = (strpos($slide['url'], BASE_URL) !== 0) ? '_blank' : '_self'; if (!empty($hotSpot) && is_array($hotSpot)) { $hotSpot = array_reverse($hotSpot); foreach ($hotSpot as $k => $area) { $target = '_self'; if ($area['urlType'] == 'page') { $page = App_Cms_Obj::getInstance()->getPageById($area['pageId']); $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 ($slide['url']) { $mapUrl = array( 'target' => $slideTarget, 'coords' => $_coords, 'href' => htmlspecialchars($slide['url']), 'shape' => 'rect', 'alt' => '' ); array_push($map, $mapUrl); } } else { if ($slide['url']) { $map[0] = array( 'target' => $slideTarget, 'shape' => 'rect', 'href' => htmlspecialchars($slide['url']), 'coords' => $_coords, 'alt' => '' ); } } if (empty($map) || (count($map) == 0)) { $map = 'empty'; } return $map; } }