public function bannerAction() { $id = null; $position = ""; $id = $this->_getParam('id', null); $position = $this->_getParam('position', ''); $this->view->width = $width = $this->_getParam('width', 500); $this->view->height = $height = $this->_getParam('height', 200); $model = new Cms_Model_Banner(); $this->view->banners = $banners = $model->getBanner($position, $id); //$banner = $model->find($id); //$this->_redirect($banner->getUrl()); //print_r($banner);exit; }
public function addAction() { $request = $this->getRequest(); $form = new Admin_Form_Banner(); if ($this->getRequest()->isPost()) { $options = $request->getPost(); if ($form->isValid($options)) { $model = new Cms_Model_Banner($options); $model->setPublished("1"); $id = $model->save(); /*--Image Upload ----*/ $upload = new Zend_File_Transfer_Adapter_Http(); if ($upload->isValid()) { $upload->setDestination("images/uploads/"); try { $upload->receive(); } catch (Zend_File_Transfer_Exception $e) { $e->getMessage(); } $upload->setOptions(array('useByteString' => false)); $file_name = $upload->getFileName('image'); $cardImageTypeArr = explode(".", $file_name); $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]); $target_file_name = "banner_{$id}_image.{$ext}"; $targetPath = 'media/banner/' . $target_file_name; $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true)); $filterFileRename->filter($file_name); $options['image'] = $target_file_name; $model = $model->find($id); $model->setImage($target_file_name); $model->save(); } return $this->_helper->redirector('add', 'banner', "admin", array('msg' => base64_encode("Banner Added successfully!"))); } else { $form->reset(); $form->populate($options); } } $this->view->msg = base64_decode($this->getRequest()->getParam("msg")); // Assign the form to the view $this->view->form = $form; }
private function setModel($row) { $model = new Cms_Model_Banner(); $model->setId($row->Id)->setTitle($row->Title)->setPosition($row->Position)->setImage($row->Image)->setUrl($row->Url)->setDescription($row->Description)->setPublished($row->Published)->setCreated($row->Created)->setUserId($row->UserId); return $model; }
public function getBanner($position, $bannerId = null) { $where = "Published='1' AND Position='{$position}' "; if (!is_null($bannerId)) { $where .= " and Id='{$bannerId}'"; } $banner = new Cms_Model_Banner(); $banners = $banner->fetchAll($where); return $banners; }