_dataObj) { $idBanner = (int) $_REQUEST['idBanner']; if (!$idBanner) { $this->_dataObj = null; } else { $this->_dataObj->setIdBanner($idBanner); } } return $this->_dataObj; } protected function _doEdit() { if ('image' != $this->dataObj->getBannerData('type')) { $this->doc->displayError( 'Only "Image" type banners support "hot spots" function.' . '

« Back to list' ); return false; } $item = array(); $this->dataObj->initData(); $item['tpl'] = 'Banner/spot_form.tpl'; $item['banner'] = $this->dataObj->getBannerData(); $item['pages'] = App_Cms_Obj::getInstance()->getParent4Select(0); $options = array(); $options['cancelUrl'] = $this->_getBackUrl(PARENT_PAGE); $options['spotsList'] = $this->dataObj->getData(); $options['containerWidth'] = $item['banner']['width']; $options['containerHeight'] = $item['banner']['height']; $options['bannerId'] = $item['banner']['id']; $this->_addItem($item); $this->doc->addScript('js/jquery-ui.js') ->addStylesheet('css/jquery-ui.css') ->addStylesheet('css/admin-banner.css') ->addScript('js/app/admin-banner.js') ->addInitFunction('initAppBannerSpotForm', array($options)); return $this; } public function _doSave() { return $this->_doSaveAjax(); } protected function _doSaveAjax() { $data = $_REQUEST; if (true === ($errors = $this->_isValid($data))) { $this->dataObj->save($data); $data = array('status' => 'ok'); } else { $data = array('status' => 'fail', 'errors' => $errors); } $this->_displayJson($data); } protected function _isValid($data) { $errors = array(); if (is_array($data['urlType']) && !empty($data['urlType'])) { foreach ($data['urlType'] as $index => $urlType) { if ($urlType == 'page' && intval($data['idPage'][$index]) == 0) { $errors[$index] = 'Please select page.'; break; } if ($urlType == 'url') { if ($data['url'][$index] == '') { $errors[$index] = 'Url is required.'; break; } else if (!preg_match("/^(http|ftp)s?:\/\/.+$/", $data['url'][$index])) { $errors[$index] = 'Url is in wrong format.'; break; } } } } return (empty($errors)) ? true : $errors; } }