Example #1
0
 public static function get_image_by_height($path, $height = "original")
 {
     if ($path instanceof File) {
         $image_file = $path;
     } else {
         $image_file = new File($path);
     }
     $image_dir = $image_file->getDirectory();
     $full_cache_dir = new Dir(self::THUMBNAILS_DIR . $image_dir->getPath());
     $full_cache_dir->touch();
     $data = ImageUtils::get_image_data($image_file);
     if ($height == "original") {
         $thumb_folder = "original";
     } else {
         if ($data["height"] > $height) {
             $thumb_folder = "__x" . $height;
         } else {
             $thumb_folder = "original";
         }
     }
     if ($thumb_folder == "original") {
         return $image_file->getPath();
     }
     $final_image_folder = new Dir(self::THUMBNAILS_DIR . $image_dir->getPath() . $thumb_folder);
     //copio l'immagine nella cache
     $final_image_folder->touch();
     $thumbnail_image_file = $final_image_folder->newFile($image_file->getFilename());
     if (!$thumbnail_image_file->exists()) {
         ImageUtils::resize_by_height($image_file, $thumbnail_image_file, $height);
     }
     return $thumbnail_image_file->getPath();
 }
 private function _getImageInfoByTids($page, $pageSize)
 {
     $imageList = $this->_getImageTidsByFids($page, $pageSize);
     $list = array();
     global $_G;
     $forum = $_G['forum'];
     foreach ($imageList as $image) {
         $tmpImageInfo = ForumUtils::getTopicInfo($image);
         $imageSummary = ForumUtils::getTopicCover((int) $image);
         $imageInfo['board_id'] = (int) $tmpImageInfo['fid'];
         $imageInfo['board_name'] = $fid != 0 ? $forum['name'] : ForumUtils::getForumName($tmpImageInfo['fid']);
         $imageInfo['board_name'] = WebUtils::emptyHtml($imageInfo['board_name']);
         $imageInfo['topic_id'] = (int) $image;
         $imageInfo['title'] = WebUtils::emptyHtml($tmpImageInfo['subject']);
         $imageInfo['user_id'] = (int) $tmpImageInfo['authorid'];
         $imageInfo['last_reply_date'] = $tmpImageInfo['lastpost'] . "000";
         $imageInfo['user_nick_name'] = $tmpImageInfo['author'];
         $imageInfo['hits'] = (int) $tmpImageInfo['views'];
         $imageInfo['replies'] = (int) $tmpImageInfo['replies'];
         $imageInfo['top'] = (int) ForumUtils::isTopTopic($image) ? 1 : 0;
         $imageInfo['status'] = (int) $tmpImageInfo['status'];
         $imageInfo['essence'] = (int) $tmpImageInfo['digest'] ? 1 : 0;
         $imageInfo['hot'] = (int) $tmpImageInfo['highlight'] ? 1 : 0;
         $tempImageInfo = ImageUtils::getThumbImageEx($imageSummary, 15, true, false);
         $imageInfo['pic_path'] = $tempImageInfo['image'];
         $imageInfo['ratio'] = $tempImageInfo['ratio'];
         $imageInfo['userAvatar'] = UserUtils::getUserAvatar($tmpImageInfo['authorid']);
         $imageInfo['recommendAdd'] = (int) ForumUtils::getRecommendAdd($image);
         $imageInfo['isHasRecommendAdd'] = (int) ForumUtils::isHasRecommendAdd($image);
         $imageInfo['imageList'] = array();
         $imageInfo['sourceWebUrl'] = (string) ForumUtils::getSourceWebUrl($image, 'topic');
         $list[] = $imageInfo;
     }
     return $list;
 }
 public function createFileNode(Element $parentElement, $desiredFilename, $workingFilePath, StorageFacilityFile $preconfiguredFile = null)
 {
     if (empty($desiredFilename)) {
         $desiredFilename = $this->filenameFromBasename(basename($workingFilePath));
     }
     $path = pathinfo($workingFilePath);
     $ext = !empty($path['extension']) ? strtolower($path['extension']) : '';
     if (in_array(strtolower($ext), array_map("strtolower", $this->mediaRestrictedExtensions))) {
         throw new Exception('Cannot add file with restricted extension [' . $ext . ']');
     }
     list($storageFacility, $sfParams) = $this->deriveStorageFacility($parentElement);
     $element = $this->NodeRefService->oneFromAspect('@files')->getElement();
     $file = $preconfiguredFile !== null ? $preconfiguredFile : new StorageFacilityFile();
     $file->setId($storageFacility->findUniqueFileID($sfParams, $desiredFilename));
     $file->setLocalPath($workingFilePath);
     $file = $storageFacility->putFile($sfParams, $file);
     list($width, $height) = ImageUtils::getImageDimensions($file->getLocalPath());
     $mimetype = FileSystemUtils::getMimetype($file->getExtension());
     //CREATE FILE NODE & SAVE
     $nodeRef = new NodeRef($element, SlugUtils::createSlug($file->getId()));
     $nodeRef = $this->NodeService->generateUniqueNodeRef($nodeRef, null, true);
     $node = $nodeRef->generateNode();
     $this->NodeMapper->defaultsOnNode($node);
     $node->Title = $file->getId();
     $node->setMeta('#url', $file->getURL());
     //        $node->setMeta('#path',$file->getLocalPath());
     $node->setMeta('#mimetype', $mimetype);
     $node->setMeta('#size', filesize($file->getLocalPath()));
     $node->setMeta('#width', $width);
     $node->setMeta('#height', $height);
     $node->setMeta('#parent-element', $parentElement->Slug);
     $this->NodeService->add($node);
     return $node;
 }
Example #4
0
 function applyFilter(Canvas $canvas)
 {
     $himage = $canvas->getImage();
     $m = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0));
     $div = 16;
     $offs = 0;
     ImageUtils::imageconvolution($himage, $m, $div, $offs);
 }
Example #5
0
 public function run()
 {
     $image = ImageUtils::getDefaultImage('profiles');
     $ids = array();
     foreach ($this->users as $user) {
         $ids[] = $user->id;
     }
     $images = UserPhotosApi::getPrimaryImageForUsers($ids);
     $this->render('peopleResults', array('modelProperty' => $this->modelProperty, 'modelUser' => $this->modelUser, 'modelProfile' => $this->modelProfile, 'users' => $this->users, 'images' => $images, 'ids' => $ids, 'image' => $image, 'totalResults' => $this->totalResults, 'pages' => $this->pages, 'userType' => $this->userType));
 }
Example #6
0
 public static function getAllImages($imageOfId, $entityId)
 {
     $models = Images::model()->findAll('image_of_id=:imageOfId AND entity_id=:entityId', array(':imageOfId' => $imageOfId, ':entityId' => $entityId));
     $result = false;
     $entityName = EntityApi::getTypeById($entityId);
     foreach ($models as $model) {
         $result[] = ImageUtils::getImageUrl($entityName, $imageOfId, $model->filename);
     }
     return $result;
 }
Example #7
0
 public function run()
 {
     $image = ImageUtils::getDefaultImage('properties');
     $ids = array();
     foreach ($this->properties as $property) {
         $ids[] = $property->id;
     }
     $images = PropertyImagesApi::getPrimaryImageForProperties($ids);
     $this->render('propertylist', array('properties' => $this->properties, 'images' => $images, 'ids' => $ids, 'image' => $image));
 }
Example #8
0
 public function run()
 {
     $image = ImageUtils::getDefaultImage('profiles');
     $ids = array();
     foreach ($this->users as $user) {
         $ids[] = $user->id;
     }
     $images = UserPhotosApi::getPrimaryImageForUsers($ids);
     $this->render('peopleSearchResults', array('modelProperty' => $this->modelProperty, 'modelUser' => $this->modelUser, 'modelProfile' => $this->modelProfile, 'users' => $this->users, 'images' => $images, 'ids' => $ids, 'image' => $image, 'pagesAgent' => $this->pagesAgent, 'pagesUser' => $this->pagesUser, 'pagesBuilder' => $this->pagesBuilder, 'pagesSpecialists' => $this->pagesSpecialists));
 }
Example #9
0
 public static function getPrimaryImageForUsers($userIds)
 {
     $criteria = new CDbCriteria();
     $criteria->addInCondition('user_id', $userIds);
     $models = UserPhotos::model()->findAll($criteria);
     $result = false;
     foreach ($models as $model) {
         $result[$model->user_id] = ImageUtils::getImageUrl('profiles', $model->user_id, $model->image);
     }
     return $result;
 }
Example #10
0
 public function run()
 {
     $image = ImageUtils::getDefaultImage('projects');
     $ids = array();
     if ($this->projects) {
         foreach ($this->projects as $project) {
             $ids[] = $project->id;
         }
     }
     $images = ProjectImagesApi::getPrimaryImageForProjects($ids);
     $this->render('projectSearchResults', array('modelProject' => $this->modelProject, 'modelCity' => $this->modelCity, 'projectAmenities' => $this->projectAmenities, 'projects' => $this->projects, 'images' => $images, 'ids' => $ids, 'image' => $image, 'pagesProject' => $this->pagesProject));
 }
 public function run()
 {
     $images = null;
     $image = ImageUtils::getDefaultImage('properties');
     $ids = array();
     if ($this->properties) {
         foreach ($this->properties as $property) {
             $ids[] = $property->id;
         }
         $images = PropertyImagesApi::getPrimaryImageForProperties($ids);
     }
     $this->render('propertySearchResults', array('pages' => $this->pages, 'modelProperty' => $this->modelProperty, 'modelCity' => $this->modelCity, 'propertyAmenities' => $this->propertyAmenities, 'properties' => $this->properties, 'images' => $images, 'ids' => $ids, 'image' => $image, 'propertiesCount' => $this->propertiesCount, 'wishlistRemove' => $this->wishlistRemove));
 }
Example #12
0
 public function actionindex()
 {
     $model = new Feedback();
     if (isset($_POST['Feedback'])) {
         $model->attributes = $_POST['Feedback'];
         if ($model->validate()) {
             $imagePath = ImageUtils::uploadImage($model, 'image');
             if ($imagePath) {
                 $model->image = FeedbackImagesApi::addImage($imagePath);
             }
             if ($model->save()) {
                 EmailApi::sendEmail($model->email_id, "FEEDBACK.SUCCESS");
                 $this->redirect('/feedback/thanks');
             }
         }
     }
     $feedbackTopics = new FeedbackTopic();
     $this->renderPartial('index', array('model' => $model, 'feedbackTopics' => $feedbackTopics));
 }
Example #13
0
 private function _filterContent($content)
 {
     $newContent = array();
     foreach ($content as $key => $value) {
         $newContent[$key]['infor'] = $value['content'];
         $newContent[$key]['type'] = $value['type'];
         // 兼容老版本的url类型
         if ($value['type'] == 'url') {
             $newContent[$key]['infor'] = sprintf('[mobcent_url=%s]%s[/mobcent_url]', $value['extraInfo']['url'], $value['content']);
             $newContent[$key]['type'] = 'text';
         } else {
             if ($value['type'] == 'image') {
                 $image = ImageUtils::getThumbImageEx($value['content'], 5);
                 // 分享返回缩略大图
                 $image['image'] = str_replace('xgsize_', 'mobcentBigPreview_', $image['image']);
                 $newContent[$key]['infor'] = $image['image'];
             }
         }
     }
     return $newContent;
 }
 private function _transTopicList($topicList, $type)
 {
     $list = array();
     global $_G;
     $forum = $_G['forum'];
     foreach ($topicList as $topic) {
         $tmpTopicInfo = ForumUtils::getTopicInfo((int) $topic);
         $topicSummary = ForumUtils::getTopicSummary((int) $topic);
         $topicInfo['board_id'] = (int) $tmpTopicInfo['fid'];
         $topicInfo['board_name'] = $fid != 0 ? $forum['name'] : ForumUtils::getForumName($tmpTopicInfo['fid']);
         $topicInfo['board_name'] = WebUtils::emptyHtml($topicInfo['board_name']);
         $topicInfo['topic_id'] = (int) $topic;
         $topicInfo['type_id'] = (int) $tmpTopicInfo['typeid'];
         $topicInfo['sort_id'] = (int) $tmpTopicInfo['sortid'];
         $topicInfo['title'] = WebUtils::emptyHtml($tmpTopicInfo['subject']);
         $topicSummary['msg'] = WebUtils::emptyReturnLine($topicSummary['msg'], ' ');
         $topicInfo['subject'] = $topicSummary['msg'];
         $topicInfo['user_id'] = (int) $tmpTopicInfo['authorid'];
         if ($type = 'favorite' && empty($tmpTopicInfo['author'])) {
             $dateline = UserTopicInfo::getUserfavorite($_G['uid'], $topic);
             $topicInfo['last_reply_date'] = $dateline . '000';
             $topicInfo['user_nick_name'] = UserUtils::getUserName($dateline['uid']);
         } else {
             $topicInfo['last_reply_date'] = $tmpTopicInfo['dateline'] . '000';
             $topicInfo['user_nick_name'] = (string) $tmpTopicInfo['author'];
         }
         $topicInfo['hits'] = (int) $tmpTopicInfo['views'];
         $topicInfo['replies'] = (int) $tmpTopicInfo['replies'];
         $topicInfo['top'] = (int) ForumUtils::isTopTopic($topic) ? 1 : 0;
         $topicInfo['status'] = (int) $tmpTopicInfo['status'];
         $topicInfo['essence'] = (int) $tmpTopicInfo['digest'] ? 1 : 0;
         $topicInfo['hot'] = (int) $tmpTopicInfo['highlight'] ? 1 : 0;
         $topicInfo['pic_path'] = ImageUtils::getThumbImage($topicSummary['image']);
         $list[] = $topicInfo;
     }
     return $list;
 }
Example #15
0
 public static function CheckImageSize($fileName, $maxWidth, $maxHeight)
 {
     list($width, $height) = ImageUtils::GetImageSize($fileName);
     if ($width > $maxWidth || $height > $maxHeight) {
         return false;
     } else {
         return true;
     }
 }
Example #16
0
 /**
  * 上传帖子图片(正常的附件目录)
  * 
  * @param mixed $uid        Description.
  * @param mixed $allowValue Description.
  *
  * @access private
  *
  * @return mixed Value.
  */
 private function _uploadAttach($uid, $allowValue)
 {
     global $_G;
     $fileExtension = FileUtils::getFileExtension($_FILES['uploadFile']['name'][$allowValue], 'jpg');
     $type = 'forum';
     $extid = 0;
     $forcename = '';
     Yii::import('application.components.discuz.source.class.discuz.discuz_upload', true);
     $upload = new Mobcent_upload();
     $attach['extension'] = $fileExtension;
     $attach['attachdir'] = $upload->get_target_dir($type, $extid);
     $filename = $upload->get_target_filename($type, $extid, $forcename) . '.' . $attach['extension'];
     $attach['attachment'] = $attach['attachdir'] . $filename;
     $attach['target'] = getglobal('setting/attachdir') . './' . $type . '/' . $attach['attachment'];
     $savePath = getglobal('setting/attachdir') . './' . $type . '/' . $attach['attachdir'];
     if (!is_dir($savePath)) {
         mkdir($savePath, 0777, true);
     }
     $remote = $width = $thumb = 0;
     $res = array();
     $saveName = $savePath . $filename;
     if (move_uploaded_file($_FILES['uploadFile']['tmp_name'][$allowValue], $saveName)) {
         $aid = getattachnewaid($uid);
         $img_info = getimagesize($attach['target']);
         $size = filesize($attach['target']);
         $insert = array('aid' => $aid, 'dateline' => $_G['timestamp'], 'filename' => $filename, 'filesize' => $size, 'attachment' => $attach['attachment'], 'isimage' => 1, 'uid' => $uid, 'thumb' => $thumb, 'remote' => $remote, 'width' => $img_info[0]);
         C::t('forum_attachment_unused')->insert($insert);
         // 添加水印
         Yii::import('application.components.discuz.source.class.class_image', true);
         $image = new Mobcent_Image();
         if ($image->param['watermarkstatus']['forum'] > 0) {
             $image->makeWatermark($attach['target'], '', 'forum');
         }
         $path_url = ImageUtils::getAttachUrl() . '/' . $type . '/' . $attach['attachment'];
         ImageUtils::getThumbImageEx($path_url, 10, false, false, true);
         $res['id'] = $aid;
         $res['urlName'] = $path_url;
     }
     return $res;
 }
Example #17
0
 /**
  * 获取主题摘要(内容摘要以及图片)
  *
  * @param int $tid 帖子id
  * @param string $type forum为论坛模块,portal为门户模块
  * @param bool $transBr 是否要转换换行
  * @param array $options 参数选项, 可选值: array('imageList' => 1, 'imageListLen' => 9, 'imageListThumb' => 1)
  * @return array array('msg' => '', 'image' => '', 'imageList' => array())
  */
 public static function getTopicSummary($tid, $type = 'forum', $transBr = true, $options = array())
 {
     $summary = array('msg' => '', 'image' => '', 'imageList' => array());
     $summaryLength = WebUtils::getDzPluginAppbymeAppConfig($type == 'forum' ? 'forum_summary_length' : 'portal_summary_length');
     $allowImage = WebUtils::getDzPluginAppbymeAppConfig($type == 'forum' ? 'forum_allow_image' : 'portal_allow_image');
     $allowImage = !($allowImage === '0');
     if ($summaryLength === '0' && !$allowImage) {
         return $summary;
     }
     $content = self::getTopicContent($tid);
     if (!empty($content['main'])) {
         $msg = '';
         $isFindImage = false;
         $isFindImageList = false;
         $getImageList = isset($options['imageList']) ? $options['imageList'] : 0;
         $imageListLen = isset($options['imageListLen']) ? $options['imageListLen'] : 9;
         $imageListThumb = isset($options['imageListThumb']) ? $options['imageListThumb'] : 1;
         $imageListCount = 0;
         foreach ($content['main'] as $line) {
             if ($line['type'] == 'image' && !$isFindImageList) {
                 $imageListCount++;
                 if ($allowImage) {
                     !$isFindImage && ($summary['image'] = $line['content']);
                     if ($getImageList && !$isFindImageList) {
                         $imageListThumb && ($line['content'] = ImageUtils::getThumbImage($line['content']));
                         $summary['imageList'][] = $line['content'];
                     }
                 }
                 $isFindImage = true;
                 !$getImageList && ($isFindImageList = true);
                 $imageListCount == $imageListLen && ($isFindImageList = true);
             }
             if ($line['type'] == 'text') {
                 $msg .= $line['content'] . "\r\n";
             }
         }
         $msg = preg_replace('/\\[mobcent_phiz=.+?\\]/', '', $msg);
         $msg = preg_replace(WebUtils::t('/本帖最后由 .*? 于 .*? 编辑/'), '', $msg);
         $transBr && ($msg = WebUtils::emptyReturnLine($msg, ' '));
         $msg = trim($msg);
         $summaryLength === false && ($summaryLength = 40);
         $summary['msg'] = (string) WebUtils::subString($msg, 0, $summaryLength);
     }
     return $summary;
 }
Example #18
0
 public static function getImage($userId)
 {
     $model = UserBuilderProfile::model()->find('user_id=:userId', array(':userId' => $userId));
     $result = ImageUtils::getDefaultImage('builders');
     if ($model && $model->image) {
         $result = ImageUtils::getImageUrl('builders', $userId, $model->image);
     }
     return $result;
 }
Example #19
0
 public function actionImage($id)
 {
     Yii::beginProfile('property_image');
     $propertyId = $id;
     $property = PropertyApi::getPropertyById($propertyId);
     $userId = Yii::app()->user->id;
     if (!isset($property) || $property->user_id != $userId) {
         $this->redirect('/search');
         die;
     }
     $model = new PropertyImages();
     $images = PropertyImagesApi::getAllImages($propertyId);
     if (isset($_POST['submit'])) {
         //$model->attributes=$_POST['PropertyImages'];
         $files = CUploadedFile::getInstancesByName('PropertyImages[image]');
         $valid = 1;
         if ($files == null) {
             $model->addError('image', 'Please select atleast one image.');
             $valid = 0;
         }
         if ($valid) {
             $imagePaths = ImageUtils::uploadMultipleImage($files);
             $count = PropertyImagesApi::addMultipleImage($propertyId, $imagePaths);
             ImageUtils::deleteMultipleImages($imagePaths);
             $this->refresh();
         }
     }
     $this->render('image', array('property' => $property, 'model' => $model, 'images' => $images));
     Yii::endProfile('property_image');
 }
Example #20
0
<div>
<table width="909" border="0" cellspacing="0" cellpadding="0"
	class="my_messages">
	<thead>
		<tr>
			<th width="400" style="padding-left: 8px;">Property Name</th>
			<th width="130">City</th>
			<th width="128" align="left">Property Type</th>
			<th width="198" align="left">Looking To</th>
			<th width="42" align="left"></th>
		</tr>
	</thead>
	<?php 
if ($properties) {
    foreach ($properties as $property) {
        $image = ImageUtils::getDefaultImage('properties');
        if (isset($propertyImages[$property->id])) {
            $image = $propertyImages[$property->id];
        }
        echo '<tr>
            <td colspan="5">
            <a href="/property/' . $property->id . '"><div class="c1_1">' . $property->property_name . '</div> <div class="c2_1">' . $propertyLocations[$property->city_id] . '</div> <div class="c3_1">' . $propertyTypes[$property->property_type_id] . '</div> <div class="c4">' . $property->i_want_to . '</div><div class="c5_1"><img src="' . $image . '" alt="" width="61" height="40" /></div></a></td>
          </tr>';
    }
    echo '<tr><td colspan="5"><div align="right"><a href="/properties" class="red-txt">View All Properties</a></div></td></tr>';
} else {
    echo '<tr>
            <td colspan="5">
            <div class="red-txt" align="center"><b>No Properties</b></div>
            </td>
          </tr>';
Example #21
0
 public static function transArticleContent($content)
 {
     $content = PortalUtils::parseArticleContent($content);
     $newContent = array();
     $matches = array();
     preg_match_all('/(.+?)\\[mobcent_br\\]/s', $content, $matches);
     foreach ($matches[1] as $match) {
         $tempMatches = array();
         $tempContent = array('type' => 'text', 'content' => '');
         preg_match('/\\[mobcent_(audio|video|image)=(.*?)\\]/', $match, $tempMatches);
         if (!empty($tempMatches)) {
             $tempContent['type'] = $tempMatches[1];
             $tempContent['content'] = $tempMatches[2];
             if ($tempContent['type'] == 'image') {
                 $tempContent['extraInfo']['source'] = $tempMatches[2];
                 $tempContent['content'] = ImageUtils::getThumbImage($tempMatches[2]);
             }
         } else {
             $match = preg_replace('/(<p>|<\\/p>|<div>|<\\/div>|<br>|<br\\/>)/i', PortalUtils::CONTENT_DELIMITER, $match);
             $match .= PortalUtils::CONTENT_DELIMITER;
             $tempText = '';
             $tempMatches = array();
             preg_match_all('/(.+?)\\[mobcent_br\\]/s', $match, $tempMatches);
             foreach ($tempMatches[1] as $value) {
                 $value = str_replace(PortalUtils::CONTENT_DELIMITER, '', $value);
                 $tempText .= $value . "\r\n";
             }
             $tempText = WebUtils::emptyHtml($tempText);
             $tempText = (string) trim($tempText);
             $tempContent['content'] = $tempText;
         }
         $tempContent['content'] != '' && ($newContent[] = $tempContent);
     }
     return $newContent;
 }
 public function actionMakeThumb($count = 10)
 {
     $thumbTaskList = CacheUtils::getDzPluginCache('thumb_task_list');
     $thumbTaskList === false && ($thumbTaskList = array());
     $count <= 0 && ($count = count($thumbTaskList));
     $count = min(count($thumbTaskList), $count);
     $i = 0;
     foreach ($thumbTaskList as $key => $thumb) {
         if ($i >= $count) {
             break;
         }
         ImageUtils::getThumbImageEx($thumb, 20, false, false, true);
         $i++;
     }
     echo WebUtils::jsonEncode($thumbTaskList);
     array_splice($thumbTaskList, 0, $count);
     CacheUtils::setDzPluginCache('thumb_task_list', $thumbTaskList);
 }
Example #23
0
 public static function getThumbImageEx($image, $timeout = 15, $getImageInfo = false, $inBackgroud = false, $force = false)
 {
     $res = array('image' => $image, 'ratio' => '1');
     if (empty($image)) {
         return $res;
     }
     $config = self::_getThumbConfig();
     $allowDiscuzThumb = WebUtils::getDzPluginAppbymeAppConfig('image_thumb_allow_discuz');
     if (!$force && !$config['isThumb'] && $allowDiscuzThumb < 0) {
         return $res;
     }
     $thumbImage = $image;
     global $_G;
     $attachFile = '';
     // 是否用discuz生成的缩略图
     if ($allowDiscuzThumb === false || $allowDiscuzThumb > 0) {
         if ($_G['setting']['ftp']['on'] == 0) {
             $attachUrl = self::getAttachUrl();
             $attachUrl = str_replace($attachUrl, '', $image);
             $attachFile = $_G['setting']['attachdir'] . $attachUrl;
             $attachThumbFile = $attachFile . self::DISCUZ_THUMB_SUFFIX;
             if (file_exists($attachThumbFile)) {
                 $res['image'] = $thumbImage . self::DISCUZ_THUMB_SUFFIX;
                 if ($getImageInfo) {
                     $imageInfo = ImageUtils::getImageInfo($attachThumbFile);
                     $res['ratio'] = $imageInfo['ratio'];
                 }
                 return $res;
             }
         }
     }
     if (!$force && !$config['isThumb']) {
         return $res;
     }
     // 获取缩略图文件名
     $savePath = sprintf('%s/%s', MOBCENT_THUMB_PATH, self::_getThumbTempPath($image));
     $tempFileName = self::_getThumbTempFile($image);
     $smallFileName = $savePath . '/mobcentSmallPreview_' . $tempFileName;
     $bigFileName = $savePath . '/mobcentBigPreview_' . $tempFileName;
     if (file_exists($smallFileName) && file_exists($bigFileName)) {
         $res['image'] = self::_getThumbUrlFile($image, $tempFileName);
         if ($getImageInfo) {
             $imageInfo = ImageUtils::getImageInfo($smallFileName);
             $res['ratio'] = $imageInfo['ratio'];
         }
         return $res;
     }
     if ($inBackgroud) {
         CacheUtils::addThumbTaskList($image);
         return $res;
     }
     if (!is_dir($savePath)) {
         mkdir($savePath, 0777, true);
     }
     if (is_writable($savePath)) {
         // $timer = new CountTimer;
         // 先查看是否是本地附件的图片, 如果不是才去网络取图片数据
         $imageData = '';
         if ($attachFile != '' && file_exists($attachFile)) {
             $imageData = file_get_contents($attachFile);
         }
         if ($imageData == '') {
             $imageData = WebUtils::httpRequest($image, $timeout);
             if ($imageData == '') {
                 return $res;
             }
         }
         $thumb = null;
         $zoomRes = true;
         require_once MOBCENT_APP_ROOT . '/components/discuz/source/class/class_image.php';
         if (!file_exists($smallFileName)) {
             if (file_put_contents($smallFileName, $imageData) == false) {
                 return $res;
             }
             $thumb = new Mobcent_Image();
             $zoomRes &= $thumb->makeThumb($smallFileName, '', $config['imageSmallLength']);
         }
         if (!file_exists($bigFileName)) {
             if (file_put_contents($bigFileName, $imageData) == false) {
                 return $res;
             }
             $thumb == null && ($thumb = new Mobcent_Image());
             $zoomRes &= $thumb->makeThumb($bigFileName, '', $config['imageBigLength']);
         }
         if (file_exists($smallFileName) && file_exists($bigFileName) && $zoomRes) {
             $thumbImage = self::_getThumbUrlFile($image, $tempFileName);
             if ($getImageInfo) {
                 $imageInfo = ImageUtils::getImageInfo($smallFileName);
                 $res['ratio'] = $imageInfo['ratio'];
             }
         } else {
             FileUtils::safeDeleteFile($smallFileName);
             FileUtils::safeDeleteFile($bigFileName);
         }
         // var_dump($timer->stop());
     }
     $res['image'] = $thumbImage;
     return $res;
 }
Example #24
0
 private function _getInfoList($uid, $puid)
 {
     $list = array();
     $topicList = array();
     if ($uid == $puid) {
         $topicList = DzUserInfo::getFavouriteTopics($uid);
     } else {
         $topicList = DzUserInfo::getTopicsByUid($puid);
     }
     foreach ($topicList as $topic) {
         $topicSummary = ForumUtils::getTopicSummary((int) $topic['tid']);
         $tmpTopic['board_id'] = (int) $topic['fid'];
         $tmpTopic['board_name'] = ForumUtils::getForumName((int) $topic['fid']);
         $tmpTopic['topic_id'] = (int) $topic['tid'];
         $tmpTopic['title'] = $topic['subject'];
         $tmpTopic['user_id'] = (int) $topic['authorid'];
         $tmpTopic['lastpost'] = $topic['lastpost'] . "000";
         $tmpTopic['user_nick_name'] = $topic['author'];
         $tmpTopic['hits'] = (int) $topic['views'];
         $tmpTopic['content'] = WebUtils::emptyReturnLine($topicSummary['msg'], ' ');
         $tmpTopic['replies'] = (int) $topic['replies'];
         $tmpTopic['pic_path'] = ImageUtils::getThumbImage($topicSummary['image']);
         $list[] = $tmpTopic;
     }
     return $list;
 }
 private function _filterContent($content)
 {
     $typeMaps = array('text' => 0, 'image' => 1, 'video' => 2, 'audio' => 3, 'url' => 4, 'attachment' => 5);
     $newContent = array();
     foreach ($content as $value) {
         $tempContent['infor'] = $value['content'];
         $tempContent['type'] = $typeMaps[$value['type']];
         switch ($value['type']) {
             case 'image':
                 $tempContent['originalInfo'] = $value['content'];
                 $tempContent['aid'] = isset($value['extraInfo']['aid']) ? $value['extraInfo']['aid'] : 0;
                 $tempContent['infor'] = ImageUtils::getThumbImage($value['content']);
                 break;
             case 'url':
                 $tempContent['infor'] = $value['content'];
                 $tempContent['url'] = $value['extraInfo']['url'];
                 break;
             case 'attachment':
                 $tempContent['infor'] = $value['content'];
                 $tempContent['url'] = $value['extraInfo']['url'];
                 $tempContent['desc'] = $value['extraInfo']['desc'];
                 break;
             case 'video':
                 $videoInfo = ForumUtils::parseVideoUrl($value['content']);
                 $tempContent['extParams'] = array('videoType' => $videoInfo['type'], 'videoId' => $videoInfo['vid']);
                 break;
             default:
                 break;
         }
         // 判定是否开启附件下载
         if (!WebUtils::getDzPluginAppbymeAppConfig('forum_allow_attachment') && $tempContent['type'] == 5) {
             $tempContent = array();
         }
         !empty($tempContent) && ($newContent[] = $tempContent);
     }
     return $newContent;
 }
Example #26
0
 /**
  * расчёт парметров выравнивания двух картинок по ВЫСОТЕ
  * $margin - поле сверху и снизу конечной картинки
  * $offset - смещение картинки 1
  * возвращает массив параметров, какие надо установить у картинок
  */
 function image_align($file1, $file2, $pos1, $pos2, $margin = 0, $offset = 0)
 {
     $array = array();
     $info1 = ImageUtils::info($file1);
     $info2 = ImageUtils::info($file2);
     $h1 = $info1['height'];
     $h2 = $info2['height'];
     //echo "$h1<br>$h2<br>";
     $h_max = $h1 >= $h2 ? $h1 : $h2;
     $h_min = $h1 >= $h2 ? $h2 : $h1;
     $h_delta = $h_max - $h_min;
     if ($pos1 == 'top' && $pos2 == 'top') {
         $array['y1'] = $margin + $offset;
         $array['y2'] = $margin;
         $array['h'] = $h_max + $margin * 2 + $offset;
     }
     if ($pos1 == 'top' && $pos2 == 'down') {
         $array['y1'] = $margin + $offset + $h2;
         $array['y2'] = $margin;
         $array['h'] = $h_max + $margin * 2 + $offset + $h2;
     }
     if ($pos1 == 'down' && $pos2 == 'down') {
         $array['y1'] = $margin + $offset + $h2 - $h_min;
         $array['y2'] = $margin + $h1 - $h_min;
         $array['h'] = $h_max + $margin * 2 + $offset;
     }
     if ($pos1 == 'down' && $pos2 == 'top') {
         $array['y1'] = $margin;
         $array['y2'] = $margin + $offset + $h1;
         $array['h'] = $h_max + $margin * 2 + $offset + $h1;
     }
     return $array;
 }
Example #27
0
<?php

$this->breadcrumbs = array('Project Images' => array('index'), $model->id);
$this->menu = array(array('label' => 'List ProjectImages', 'url' => array('index')), array('label' => 'Create ProjectImages', 'url' => array('create')), array('label' => 'Update ProjectImages', 'url' => array('update', 'id' => $model->id)), array('label' => 'Delete ProjectImages', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => 'Manage ProjectImages', 'url' => array('admin')));
?>

<h1>View ProjectImages #<?php 
echo $model->id;
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'project.project_name', array('name' => 'image', 'value' => '<img src="' . ImageUtils::getImageUrl('projects', $model->project_id, $model->image) . '" width="100" />', 'type' => 'raw'), 'updated_time', 'updated_by', 'created_time', 'created_by')));
Example #28
0
 private function _transMessage($msgString)
 {
     $msg = array('type' => 'text', 'content' => '');
     $matches = array();
     preg_match_all('/<img.*?src="(.*?)".*?\\/>/s', $msgString, $matches, PREG_SET_ORDER);
     if (!empty($matches)) {
         foreach ($matches as $match) {
             $match[1] = WebUtils::getHttpFileName($match[1]);
             if (strpos($match[0], 'static/image/smiley') !== false || strpos($match[0], 'mobcent/app/data/phiz') !== false) {
                 $msgString = str_replace($match[0], sprintf('[mobcent_phiz=%s]', $match[1]), $msgString);
             } else {
                 $msg['type'] = 'image';
                 $msgString = ImageUtils::getThumbImage($match[1]);
                 break;
             }
         }
     }
     $matches = array();
     preg_match_all('/<a href="(.*?)".*?>(.*?)<\\/a>/s', $msgString, $matches, PREG_SET_ORDER);
     if (!empty($matches)) {
         foreach ($matches as $match) {
             $match[1] = WebUtils::getHttpFileName($match[1]);
             if (strpos($match[0], UploadUtils::getUploadAudioBaseUrlPath()) !== false) {
                 $msg['type'] = 'audio';
                 $msgString = $match[1];
                 break;
             } else {
                 // $msgString = str_replace($match[0], sprintf('[mobcent_url=%s]%s[/mobcent_url]', $match[1], $match[2]), $msgString);
                 $msgString = str_replace($match[0], sprintf(' %s %s ', $match[2], $match[1]), $msgString);
             }
         }
     }
     $msg['content'] = WebUtils::emptyHtml($msgString);
     return $msg;
 }
Example #29
0
 function ApplyFilter(&$imageString, $output = null)
 {
     $image = imagecreatefromstring($imageString);
     $imageSize = array(imagesx($image), imagesy($image));
     $imageWidth = $imageSize[0];
     $imageHeight = $imageSize[1];
     $newImageSize = $this->GetTransformedSize($imageSize);
     $newImageWidth = $newImageSize[0];
     $newImageHeight = $newImageSize[1];
     $result = imagecreatetruecolor($newImageWidth, $newImageHeight);
     ImageUtils::EnableAntiAliasing($result);
     imagecopyresampled($result, $image, 0, 0, 0, 0, $newImageWidth, $newImageHeight, $imageWidth, $imageHeight);
     if ($output == null) {
         return imagejpeg($result);
     } else {
         imagejpeg($result, $output);
     }
 }
Example #30
0
 public function post_slideshow($num)
 {
     $input = Input::all();
     if (empty($input["image{$num}"])) {
         $image = DB::table('slideshow_images')->where('number', '=', $num)->first();
         if ($image) {
             $affected = DB::table('slideshow_images')->where('number', '=', $num)->delete();
             if ($affected) {
                 $directory = path('public') . 'uploads/slideshow/' . sha1("image{$num}");
                 File::rmdir($directory);
             }
             return Redirect::to(URL::to_route('dashboard.slideshow'))->with('status_success', __('application.slideshow_deleted'));
         }
     }
     try {
         $validator = new Services\Dashboard\Slideshow\Validator($input, $num);
         $validator->publish();
     } catch (ValidateException $errors) {
         return Redirect::to(URL::to_route('dashboard.slideshow'))->with_input()->with_errors($errors->get());
     }
     $errors = new Laravel\Messages();
     $extension = File::extension($input["image{$num}"]['name']);
     $directory = path('public') . 'uploads/slideshow/' . sha1("image{$num}");
     $filename = "original.{$extension}";
     $upload_success = ImageUtils::upload_slideshow("image{$num}", $directory, $filename);
     $image_path = URL::base() . '/uploads/slideshow/' . sha1("image{$num}");
     if ($upload_success) {
         $image = DB::table('slideshow_images')->where('number', '=', $num)->first();
         if ($image) {
             DB::table('slideshow_images')->where('number', '=', $num)->update(array('image_path' => $image_path));
         } else {
             DB::table('slideshow_images')->insert(array('number' => $num, 'image_path' => $image_path));
         }
         return Redirect::to(URL::to_route('dashboard.slideshow'))->with('status_success', __('application.slideshow_added'));
     } else {
         $errors->add('errors', __('application.generic_error'));
         return Redirect::to(URL::to_route('dashboard.slideshow'))->with_input()->with_errors($errors);
     }
 }