示例#1
0
 /** Get a logo from database by institution
  * 
  * @param string $inst
  */
 public function InstLogos($inst)
 {
     $logos = new InstLogos();
     $data = $logos->getLogosInst($inst);
     if (count($data)) {
         return $this->buildHtml($data);
     } else {
         return false;
     }
 }
 /** 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');
         }
     }
 }
示例#3
0
 /** Get the logos from the db
  * @access public
  * @param string $inst
  * @return array|function
  */
 public function getLogos($inst)
 {
     $logos = new InstLogos();
     $data = $logos->getLogosInst($inst);
     return $this->buildHtml($data);
 }