/**
  * returns a image link
  * 
  * @param  array $contactArray
  * @return string
  */
 protected function _getImageLink($contactArray)
 {
     $link = 'images/empty_photo_blank.png';
     if (!empty($contactArray['jpegphoto'])) {
         $link = Tinebase_Model_Image::getImageUrl('Addressbook', $contactArray['id'], '');
     } else {
         if (isset($contactArray['salutation']) && !empty($contactArray['salutation'])) {
             $salutations = Addressbook_Config::getInstance()->get(Addressbook_Config::CONTACT_SALUTATION, NULL);
             if ($salutations && $salutations->records instanceof Tinebase_Record_RecordSet) {
                 $salutationRecord = $salutations->records->getById($contactArray['salutation']);
                 if ($salutationRecord && $salutationRecord->image) {
                     $link = $salutationRecord->image;
                 }
             }
         }
     }
     return $link;
 }
 /**
  * crops a image identified by an imgageURL and returns a new tempFileImage
  * 
  * @param  string $imageurl imageURL of the image to be croped
  * @param  int    $left     left position of crop window
  * @param  int    $top      top  position of crop window
  * @param  int    $widht    widht  of crop window
  * @param  int    $height   heidht of crop window
  * @return string imageURL of new temp image
  * 
  */
 public function cropImage($imageurl, $left, $top, $widht, $height)
 {
     $this->checkAuth();
     $image = Tinebase_Model_Image::getImageFromImageURL($imageurl);
     Tinebase_ImageHelper::crop($image, $left, $top, $widht, $height);
 }
Esempio n. 3
0
 /**
  * scales given image to given size
  * 
  * @param  Tinebase_Model_Image $_image
  * @param  int    $_width desitination width
  * @param  int    $_height destination height
  * @param  int    $_ratiomode
  * @throws  Tinebase_Exception_InvalidArgument
  */
 public static function resize(Tinebase_Model_Image $_image, $_width, $_height, $_ratiomode)
 {
     $_image->resize($_width, $_height, $_ratiomode);
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->_testImagePath = dirname(__FILE__) . '/ImageHelper/phpunit-logo.gif';
     $this->_testImage = Tinebase_Model_Image::getImageFromPath($this->_testImagePath);
     $this->_testImageData = array('width' => 94, 'height' => 80, 'bits' => 8, 'channels' => 3, 'mime' => 'image/gif');
 }
 /**
  * adds image property with image url like this:
  *  'index.php?method=Tinebase.getImage&application=Tinebase&location=vfs&id=e4b7de34e229672c0d5e22be0912779441e6e051'
  *
  * @param $records
  */
 public static function resolveAttachmentImage($records)
 {
     // get all images from attachments and set 'image' properties
     // TODO find an additional condition to better detect the attachments that should be the record image(s)
     /** @var Tinebase_Record_Interface $record */
     foreach ($records as $record) {
         if ($record->has('image') && $record->attachments instanceof Tinebase_Record_RecordSet) {
             foreach ($record->attachments as $attachment) {
                 if (in_array($attachment->contenttype, Tinebase_ImageHelper::getSupportedImageMimeTypes())) {
                     $record->image = Tinebase_Model_Image::getImageUrl('Tinebase', $attachment->getId(), 'vfs');
                     break;
                 }
             }
         }
     }
 }
 /**
  * saveRecordWithImage
  */
 public function testSaveRecordWithImage()
 {
     // create TEMPFILE and save in inv item
     $imageFile = dirname(dirname(dirname(dirname(__FILE__)))) . '/tine20/images/cancel.gif';
     $tempImage = Tinebase_TempFile::getInstance()->createTempFile($imageFile);
     $imageUrl = Tinebase_Model_Image::getImageUrl('Tinebase', $tempImage->getId(), 'tempFile');
     $invItem = $this->_getInventoryItem()->toArray();
     $invItem['image'] = $imageUrl;
     $savedInvItem = $this->_json->saveInventoryItem($invItem);
     //$savedInvItem = $this->_json->getInventoryItem($savedInvItem['id']);
     $this->assertTrue(!empty($savedInvItem['image']), 'image url is empty');
     $this->assertTrue(preg_match('/location=vfs&id=([a-z0-9]*)/', $savedInvItem['image']) == 1, print_r($savedInvItem, true));
     // check if favicon is delivered
     $image = Tinebase_Model_Image::getImageFromImageURL($savedInvItem['image']);
     $this->assertEquals(52, $image->width);
 }