/** Give them a logo * @access public * @return void * */ public function logoAction() { $form = new AddStaffLogoForm(); $form->details->setLegend('Add a logo: '); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $upload = new Zend_File_Transfer_Adapter_Http(); $upload->addValidator('NotExists', true, array(self::LOGOPATH)); if ($upload->isValid()) { $filename = $form->getValue('image'); $insertData = array(); $insertData['host'] = $filename; $insertData['updated'] = $this->getTimeForForms(); $insertData['updatedBy'] = $this->getIdentityForForms(); $regions = new StaffRegions(); $where = array(); $where[] = $regions->getAdapter()->quoteInto('id = ?', $this->getParam('id')); $regions->update($insertData, $where); $upload->receive(); $this->getFlash()->addMessage('The image has been resized and zoomified!'); $this->redirect('/admin/contacts/institution/id/' . $this->getParam('id')); } else { $this->getFlash()->addMessage('There is a problem with your upload. Probably that image exists.'); $this->view->errors = $upload->getMessages(); } } else { $form->populate($formData); $this->getFlash()->addMessage('Check your form for errors'); } } }
/** Give them a logo */ public function logoAction() { $form = new AddStaffLogoForm(); $form->details->setLegend('Add a logo: '); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $upload = new Zend_File_Transfer_Adapter_Http(); $upload->addValidator('NotExists', true, array(self::LOGOPATH)); if ($upload->isValid()) { $filename = $form->getValue('image'); $insertData = array(); $insertData['host'] = $filename; $insertData['updated'] = $this->getTimeForForms(); $insertData['updatedBy'] = $this->getIdentityForForms(); foreach ($insertData as $key => $value) { if (is_null($value) || $value == "") { unset($insertData[$key]); } } $original = self::LOGOPATH . $filename; $name = substr($filename, 0, strrpos($filename, '.')); $ext = '.jpg'; $converted = $name . $ext; $smallpath = self::LOGOPATH . 'thumbnails/' . $converted; $mediumpath = self::LOGOPATH . 'resized/' . $converted; //create medium size $phMagick = new phMagick($original, $mediumpath); $phMagick->resize(300, 0); $phMagick->convert(); /* Zend_Debug::dump($convertsmall); Zend_Debug::dump($phMagick); exit; */ $phMagick = new phMagick($original, $smallpath); $phMagick->resize(100, 0); $phMagick->convert(); $regions = new StaffRegions(); $where = array(); $where[] = $regions->getAdapter()->quoteInto('id = ?', $this->_getParam('id')); $regions->update($insertData, $where); $upload->receive(); $this->_flashMessenger->addMessage('The image has been resized and zoomified!'); $this->_redirect('/admin/contacts/institution/id/' . $this->_getParam('id')); } else { $this->_flashMessenger->addMessage('There is a problem with your upload. Probably that image exists.'); $this->view->errors = $upload->getMessages(); } } else { $form->populate($formData); $this->_flashMessenger->addMessage('Check your form for errors'); } } }