示例#1
0
 private static function fuukaFormat(Post $post) : array
 {
     $fuukaData = ['doc_id' => $post->getDocId(), 'num' => $post->getNo(), 'subnum' => 0, 'thread_num' => $post->getThreadId(), 'op' => $post->getNo() == $post->getThreadId() ? 1 : 0, 'fourchan_date' => $post->getChanTime(), 'timestamp' => $post->getTime(), 'name' => $post->name, 'name_processed' => $post->getName(), 'email' => $post->email, 'email_processed' => $post->getEmail(), 'trip' => $post->trip, 'trip_processed' => $post->getTripcode(), 'poster_hash_processed' => $post->getID(), 'poster_hash' => $post->id, 'comment_sanitized' => Yotsuba::toBBCode($post->getComment()), 'comment' => Yotsuba::toBBCode($post->getComment()), 'comment_processed' => $post->getComment(), 'title' => $post->sub, 'title_processed' => $post->getSubject()];
     if ($post->hasImage()) {
         $fuukaData['media'] = ['op' => $post->getThreadId() == $post->getNo() ? 1 : 0, 'preview_w' => $post->getThumbWidth(), 'preview_h' => $post->getThumbHeight(), 'media_filename' => $post->getFullFilename(), 'media_filename_processed' => $post->getFullFilename(), 'media_w' => $post->getWidth(), 'media_h' => $post->getHeight(), 'media_size' => $post->getFilesize(), 'media_hash' => base64_encode($post->getMD5Bin()), 'media_orig' => $post->getTim() . $post->getExtension(), 'media' => $post->getTim() . $post->getExtension(), 'preview_reply' => $post->getTim() . "s.jpg", 'remote_media_link' => $post->getImgUrl(), 'media_link' => $post->getImgUrl(), 'thumb_link' => $post->getThumbUrl()];
     } else {
         $fuukaData['media'] = null;
     }
     return $fuukaData;
 }
示例#2
0
 private static function makeImageBlock(Post $post, $display)
 {
     /**
      * The following block is only for posts with an image attached.
      */
     if ($post->hasImage() && !$post->imgbanned) {
         $md5Filename = str_replace('/', '-', $post->md5);
         $humanFilesize = $post->fsize > 0 ? human_filesize($post->fsize) . ", " : "";
         list($thumbW, $thumbH) = tn_Size($post->w, $post->h);
         if ($display == self::DISPLAY_OP && ($post->w > 125 || $post->h > 125)) {
             //OP thumbs are 250x250 rather than 125x125
             $thumbW *= 2;
             $thumbH *= 2;
         }
         $thumb = "<a class='fileThumb' href='{$post->getImgUrl()}' target='_blank'>" . "<img src='{$post->getThumbUrl()}' alt='' data-md5='{$post->md5}' data-md5-filename='{$md5Filename}' data-ext='{$post->ext}' data-full-img='{$post->getImgUrl()}' width='{$thumbW}' height='{$thumbH}' data-width='{$post->w}' data-height='{$post->h}' />" . "</a>";
         $chanMedia = $post->board == 'f' ? '//i.4cdn.org/f/src/' . $post->filename . $post->ext : '//i.4cdn.org/' . $post->board . '/src/' . $post->tim . $post->ext;
         $fullImgLink = $post->getExtension() == '.swf' ? $post->getSwfUrl() : $post->getImgUrl();
         $fileDiv = div('', 'file')->set('id', 'f' . $post->no);
         $fileInfo = div('', 'fileInfo');
         $fileText = span('', 'fileText')->set('id', 'fT' . $post->no)->set('data-filename', $post->filename . $post->ext);
         $fileText->append(a($post->filename . $post->ext, $chanMedia)->set("target", "_blank")->set("title", $post->filename . $post->ext)->set("class", 'imageLink')->set('rel', 'noreferrer'))->append('&nbsp;')->append("({$humanFilesize}{$post->w}x{$post->h}, " . ($post->board == 'f' ? $post->tag . ")" : "<span title='{$post->filename}{$post->ext}'>{$post->tim}{$post->ext}</span>)&nbsp;"));
         if ($post->getExtension() != '.swf') {
             $fileText->append(a('iqdb', "http://iqdb.org/?url={$post->getThumbUrl()}")->set("target", "_blank") . '&nbsp;' . a('google', "http://www.google.com/searchbyimage?image_url={$post->getThumbUrl()}")->set("target", "_blank"));
         }
         $fileText->append('&nbsp;' . a('reposts', "/{$post->board}/search/md5/{$post->getMD5Hex()}")->set("target", "_blank") . '&nbsp;' . a('full', $fullImgLink)->set("target", '_blank'));
         $fileInfo->append($fileText);
         $fileDiv->append($fileInfo);
         $fileDiv->append($thumb);
         return $fileDiv;
     } else {
         if ($post->imgbanned) {
             return Site::parseHtmlFragment("post/banned_image.html");
         } else {
             return "";
         }
     }
 }