Exemplo n.º 1
0
function returnAdaNodeIcon($icon, $type)
{
    //$pathAr = explode(MEDIA_PATH_DEFAULT);
    //if(preg_match((explode(MEDIA_PATH_DEFAULT))),$icon) == 0 ) return "img/".returnAdaNodeType($type).".png";
    $file_pathAR = explode("/", $icon);
    $num_el = count($file_pathAR);
    if ($num_el < 2) {
        return "img/" . returnAdaNodeType($type) . ".png";
    }
    // it is a path to a file
    //	if(preg_match("/services\/media/",$icon) == 0 ) return "img/".returnAdaNodeType($type).".png";
    $iconAR = explode("/", $icon);
    // $len = count($iconAR);
    //$file_name = $iconAR[count($iconAR)-1];
    // $file_thumb = 'thumb'.$file_name;
    $file_thumb = 'thumb_' . $iconAR[count($iconAR) - 1];
    $iconAR[count($iconAR) - 1] = $file_thumb;
    $icon_thumb = implode("/", $iconAR);
    if (file_exists($icon_thumb)) {
        return ereg_replace(ROOT_DIR, HTTP_ROOT_DIR, $icon_thumb);
    }
    $id_img = new ImageDevice();
    $new_icon = $id_img->resize_image($icon);
    imagejpeg($new_icon, $icon_thumb);
    if (file_exists($icon_thumb)) {
        return ereg_replace(ROOT_DIR, HTTP_ROOT_DIR, $icon_thumb);
    } else {
        return "img/" . returnAdaNodeType($type) . ".png";
    }
}
Exemplo n.º 2
0
 /**
  * Reduce image using GD
  * 
  */
 public function reduceImage()
 {
     require_once ROOT_DIR . '/browsing/include/class_image.inc.php';
     $id_img = new ImageDevice();
     $new_img = $id_img->resize_image($this->_tmpName, AVATAR_MAX_WIDTH, AVATAR_MAX_HEIGHT);
     if (stristr($this->_type, 'png')) {
         imagepng($new_img, $this->_tmpName);
     }
     if (stristr($this->_type, 'jpeg')) {
         imagejpeg($new_img, $this->_tmpName);
     }
     if (stristr($this->_type, 'gif')) {
         imagegif($new_img, $this->_tmpName);
     }
     //        imagejpeg($new_img,$this->_tmpName);
 }
Exemplo n.º 3
0
 /**
  * callback method for addADA success handling, called by
  * parent::addADAUser just before redirecting
  * 
  * This will download user avatar image to proper location
  *  
  * @param ADALoggableUser $userObj
  * @param string $downloadURL
  * 
  * @access public
  */
 public function addADASuccessCallBack($userObj, $downloadURL, $avatar)
 {
     if (is_object($userObj) && $userObj instanceof ADALoggableUser) {
         if (!is_null($avatar) && !is_null($downloadURL)) {
             $destDir = ADA_UPLOAD_PATH . $userObj->getId();
             if (!is_dir($destDir)) {
                 mkdir($destDir);
             }
             $destFile = $destDir . DIRECTORY_SEPARATOR . $avatar;
             /**
              * save the image locally from the url
              */
             $ch = curl_init($downloadURL);
             $fp = fopen($destFile, 'wb');
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
             curl_setopt($ch, CURLOPT_FILE, $fp);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_exec($ch);
             curl_close($ch);
             fclose($fp);
             /**
              * resize the image if needed
              */
             require_once ROOT_DIR . '/browsing/include/class_image.inc.php';
             $id_img = new ImageDevice();
             $new_img = $id_img->resize_image($destFile, AVATAR_MAX_WIDTH, AVATAR_MAX_HEIGHT);
             if (stristr($destFile, 'png')) {
                 imagepng($new_img, $destFile);
             } else {
                 if (stristr($destFile, 'jpeg') !== false || stristr($destFile, 'jpg') !== false) {
                     imagejpeg($new_img, $destFile);
                 } else {
                     if (stristr($destFile, 'gif')) {
                         imagegif($new_img, $destFile);
                     }
                 }
             }
         }
     }
 }