예제 #1
0
파일: html.php 프로젝트: uzura8/flockbird
 /**
  * Creates an html image tag
  *
  * Sets the alt atribute to filename of it is not supplied.
  * DocumentRoot 以下の絶対パスを返すように改修
  *
  * @param	string	the source
  * @param	array	the attributes array
  * @return	string	the image tag
  */
 public static function img($src, $attr = array(), $is_absolute_url = false)
 {
     if (!preg_match('#^(\\w+://)# i', $src)) {
         $src = Site_Util::get_media_uri($src, $is_absolute_url);
     }
     $attr['src'] = $src;
     $attr['alt'] = isset($attr['alt']) ? $attr['alt'] : pathinfo($src, PATHINFO_FILENAME);
     return html_tag('img', $attr);
 }
예제 #2
0
파일: api.php 프로젝트: uzura8/flockbird
 /**
  * Create timeline
  * 
  * @access  public
  * @param   int     $parent_id  target parent id
  * @return  Response(json)
  * @throws  Exception in Controller_Base::controller_common_api
  * @see  Controller_Base::controller_common_api
  */
 public function post_create()
 {
     $this->controller_common_api(function () {
         $this->response_body['errors']['message_default'] = term('timeline') . 'の' . term('form.post') . 'に失敗しました。';
         $moved_files = array();
         $album_image_ids = array();
         $timeline = Model_Timeline::forge();
         $val = \Validation::forge();
         $val->add_model($timeline);
         if (!$val->run()) {
             throw new \ValidationFailedException($val->show_errors());
         }
         $post = $val->validated();
         $file_tmps = \Site_FileTmp::get_file_tmps_and_check_filesize($this->u->id, $this->u->filesize_total);
         if (!strlen($post['body']) && !$file_tmps) {
             throw new \ValidationFailedException('Data is empty.');
         }
         $type_key = 'normal';
         $album_id = (int) \Input::post('album_id', 0);
         if ($file_tmps && $album_id) {
             $album = \Album\Model_Album::check_authority($album_id, $this->u->id);
             if (\Album\Site_Util::check_album_disabled_to_update($album->foreign_table, true)) {
                 throw new \ValidationFailedException('Album id is invalid.');
             }
             $type_key = 'album_image';
         }
         try {
             \DB::start_transaction();
             if ($file_tmps) {
                 if (!$album_id) {
                     $type_key = 'album_image_timeline';
                     $album_id = \Album\Model_Album::get_id_for_foreign_table($this->u->id, 'timeline');
                 }
                 list($moved_files, $album_image_ids) = \Site_FileTmp::save_images($file_tmps, $album_id, 'album_id', 'album_image', $post['public_flag']);
             } else {
                 $album_id = null;
             }
             $timeline = \Timeline\Site_Model::save_timeline($this->u->id, $post['public_flag'], $type_key, $album_id, null, $post['body'], $timeline, $album_image_ids);
             \DB::commit_transaction();
             // thumbnail 作成 & tmp_file thumbnail 削除
             \Site_FileTmp::make_and_remove_thumbnails($moved_files);
         } catch (\Exception $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             if ($moved_files) {
                 \Site_FileTmp::move_files_to_tmp_dir($moved_files);
             }
             throw $e;
         }
         $data = array('id' => $timeline->id, 'message' => term('timeline') . 'を' . term('form.post') . 'しました。');
         if (conf('service.facebook.shareDialog.myhome.autoPopupAfterCreated')) {
             $link = \Uri::create(Site_Util::get_detail_uri($timeline->id, $timeline->type));
             $data['shareFacebook'] = array('obj' => array('link' => $link));
             if ($album_image_ids && ($album_image = \Album\Model_AlbumImage::find($album_image_ids[0]))) {
                 $data['shareFacebook']['obj']['picture'] = \Site_Util::get_media_uri(img_uri($album_image->file_name, 'thumbnail'), true);
             }
         }
         $this->set_response_body_api($data);
     });
 }
예제 #3
0
파일: detail.php 프로젝트: uzura8/flockbird
    $data['after_uri'] = 'admin/content/image/' . $after_id;
}
echo render('_parts/image/detail', $data);
?>

<?php 
$sizes = conf('upload.types.img.types.si.sizes');
?>
<ul class="media-list mt20">
<?php 
foreach ($sizes as $key => $size) {
    ?>
<li class="media">
	<?php 
    echo img($site_image->file_name, $key, '#', false, $site_image->name ?: '', false, false, array('class' => 'pull-left'), array('class' => 'media-object'));
    ?>
	<div class="media-body">
		<h4 class="media-heading"><?php 
    echo $size;
    ?>
</h4>
		<?php 
    echo Site_Util::get_media_uri(Site_Upload::get_uploaded_file_path($site_image->file_name, $size, 'img', false, true), true);
    ?>
	</div>
</li>
<?php 
}
?>
</ul>
예제 #4
0
파일: upload.php 프로젝트: uzura8/flockbird
 public static function get_upload_handler_options($member_id, $is_admin = false, $is_tmp = true, $file_cate = null, $split_criterion_id = 0, $is_multiple_upload = true, $upload_type = 'img', $with_accept_sizes = false)
 {
     if (!$split_criterion_id) {
         $split_criterion_id = $member_id;
     }
     if (!$file_cate) {
         $file_cate = $is_admin ? 'au' : 'm';
     }
     $filename_prefix = self::get_filename_prefix($file_cate, $split_criterion_id);
     $filepath_prefix = self::convert_filename2filepath($filename_prefix);
     $uploader_info = self::get_uploader_info($file_cate, $filepath_prefix, $is_tmp, $upload_type);
     $options = array('storage_type' => conf('upload.storageType'), 'is_tmp' => $is_tmp, 'max_file_size' => FBD_UPLOAD_MAX_FILESIZE, 'max_number_of_files' => $is_multiple_upload ? FBD_MAX_FILE_UPLOADS : 1, 'upload_dir' => $uploader_info['upload_dir'], 'upload_url' => $uploader_info['upload_url'], 'upload_uri' => $uploader_info['upload_uri'], 'mkdir_mode' => conf('upload.mkdir_mode'), 'member_id' => $member_id, 'upload_type' => $upload_type, 'user_type' => $is_admin ? 1 : 0, 'filename_prefix' => $filename_prefix, 'image_versions' => array(), 'is_clear_exif_on_file' => false, 'is_save_exif_to_db' => false, 'exif_accept_tags' => array(), 'exif_ignore_tags' => array(), 'is_output_log_save_error' => conf('upload.isOutputLogSaveError', false));
     if ($upload_type == 'img') {
         $options['image_library'] = 0;
         if (FBD_IMAGE_DRIVER == 'imagemagick') {
             $options['image_library'] = 1;
             $options['convert_bin'] = FBD_IMAGE_IMGMAGICK_PATH . 'convert';
         }
         $options['image_versions'] = array('' => array('auto_orient' => true));
         $options['image_versions']['thumbnail'] = array('upload_dir' => self::get_uploaded_path('thumbnail', $upload_type, $is_tmp, false, $filepath_prefix), 'upload_url' => Site_Util::get_media_uri(self::get_uploaded_path('thumbnail', $upload_type, $is_tmp, true, $filepath_prefix), true), 'max_width' => $uploader_info['thumbnail_sizes']['width'], 'max_height' => $uploader_info['thumbnail_sizes']['height'], 'crop' => true);
         if ($with_accept_sizes && ($accept_size = conf('upload.types.img.types.' . $file_cate . '.sizes'))) {
             $accept_size[] = 'raw';
             $options['accept_sizes'] = array_unique($accept_size);
         }
         $options['is_clear_exif_on_file'] = conf('isClearFromFile', 'exif');
         $options['is_save_exif_to_db'] = conf('isSaveToDb.isEnabled', 'exif');
         if (conf('isSaveToDb.filterTags.accept.isEnabled', 'exif')) {
             $options['exif_accept_tags'] = conf('isSaveToDb.filterTags.accept.tags', 'exif');
         }
         if (conf('isSaveToDb.filterTags.ignore.isEnabled', 'exif')) {
             $options['exif_ignore_tags'] = conf('isSaveToDb.filterTags.ignore.tags', 'exif');
         }
     }
     return $options;
 }
예제 #5
0
function img($filename = '', $size_key = '', $link_uri = '', $is_link2raw_file = false, $alt = '', $is_profile = false, $is_responsive = false, $anchor_attr = array(), $img_attr = array())
{
    list($uri_path, $filename, $file_cate, $size) = img_uri($filename, $size_key, $is_profile, true);
    if (!isset($img_attr['class'])) {
        $img_attr['class'] = '';
    }
    if ($is_responsive) {
        if (!empty($img_attr['class'])) {
            $img_attr['class'] .= ' ';
        }
        $img_attr['class'] .= 'img-responsive';
    }
    if ($is_profile) {
        if (!empty($img_attr['class'])) {
            $img_attr['class'] .= ' ';
        }
        $img_attr['class'] .= 'profile_image';
    }
    if (empty($filename)) {
        $noimage_tag = Site_Util::get_noimage_tag($size, $file_cate, $img_attr);
        if ($link_uri) {
            return Html::anchor($link_uri, $noimage_tag, $anchor_attr);
        }
        return $noimage_tag;
    }
    if ($alt) {
        $img_attr['alt'] = $alt;
    }
    $image_tag = Html::img($uri_path, $img_attr);
    if ($link_uri) {
        return Html::anchor($link_uri, $image_tag, $anchor_attr);
    }
    if ($is_link2raw_file) {
        $anchor_attr['target'] = '_blank';
        $uri_path = Site_Upload::get_uploaded_file_path($filename, 'raw', 'img', false, true);
        return Html::anchor(Site_Util::get_media_uri($uri_path), $image_tag, $anchor_attr);
    }
    return $image_tag;
}