/** 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'); } } }
/** Change staff profile image */ public function logoAction() { $contacts = new Contacts(); $people = $contacts->fetchRow($contacts->select()->where('dbaseID = ?', $this->getIdentityForForms())); $inst = $people->identifier; $this->view->inst = $inst; $logos = new InstLogos(); $logoslisted = $logos->getLogosInst($inst); $this->view->logos = $logoslisted; $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('logo'); $largepath = self::LOGOPATH; $original = $largepath . $filename; $name = substr($filename, 0, strrpos($filename, '.')); $ext = '.jpg'; $converted = $name . $ext; $insertData = array(); $insertData['image'] = $converted; $insertData['instID'] = $inst; $insertData['created'] = $this->getTimeForForms(); $insertData['createdBy'] = $this->getIdentityForForms(); foreach ($insertData as $key => $value) { if (is_null($value) || $value == "") { unset($insertData[$key]); } } $replace = $form->getValue('replace'); if ($replace == 1) { foreach ($logoslisted as $l) { unlink(self::LOGOPATH . 'thumbnails/' . $l['image']); unlink(self::LOGOPATH . $l['image']); unlink(self::LOGOPATH . 'resized/' . $l['image']); } } $smallpath = self::LOGOPATH . 'thumbnails/' . $converted; $mediumpath = self::LOGOPATH . 'resized/' . $converted; //create medium size $phMagick = new phMagick($original, $mediumpath); $phMagick->resize(300, 0); $phMagick->convert(); $phMagick = new phMagick($original, $smallpath); $phMagick->resize(100, 0); $phMagick->convert(); $logos->insert($insertData); $upload->receive(); $this->getFlash()->addMessage('The image has been resized and zoomified!'); $this->redirect('/users/account/'); } 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'); } } }