function getArticleThumbWithPath($t, $width, $height, $file) { global $wgContLang, $wgLanguageCode; $sourceWidth = $file->getWidth(); $sourceHeight = $file->getHeight(); $xScale = $width / $sourceWidth; if ($height > $xScale * $sourceHeight) { $heightPreference = true; } else { $heightPreference = false; } $thumb = WatermarkSupport::getUnwatermarkedThumbnail($file, $width, $height, true, true, $heightPreference); //removed the fixed width for now $articleName = $t->getText(); if ($wgLanguageCode == "zh") { $articleName = $wgContLang->convert($articleName); } $html = "<div class='thumbnail' ><a href='{$t->getFullUrl()}'><img src='" . wfGetPad($thumb->getUrl()) . "' alt='' /><div class='text'><p>" . wfMessage('Howto', '')->text() . "<br /><span>{$articleName}</span></p></div></a></div>"; return $html; }
function getArticleThumbWithPath($t, $width, $height, $file) { $sourceWidth = $file->getWidth(); $sourceHeight = $file->getHeight(); $xScale = $width / $sourceWidth; if ($height > $xScale * $sourceHeight) { $heightPreference = true; } else { $heightPreference = false; } $thumb = WatermarkSupport::getUnwatermarkedThumbnail($file, $width, $height, true, true, $heightPreference); //removed the fixed width for now $html = "<div class='thumbnail' ><a href='{$t->getFullUrl()}'><img src='" . wfGetPad($thumb->url) . "' alt='' /><div class='text'><p>" . wfMsg('Howto', '') . "<br /><span>{$t->getText()}</span></p></div></a></div>"; return $html; }
private static function formatResults($results) { $ret = array(); if ($results) { foreach ($results as $title) { $image = self::getArticleImage($title); $abstract = self::getAbstract($title); $rev = GoodRevision::newFromTitle($title, $title->getArticleId()); if ($rev) { $revid = $rev->latestGood(); } if ($image['obj']) { // Required to make a cropped square image $imageObj = $image['obj']; $srcWidth = $imageObj->getWidth(); $srcHeight = $imageObj->getHeight(); $heightPreference = $srcWidth > $srcHeight; $thumb = WatermarkSupport::getUnwatermarkedThumbnail($imageObj, self::SEARCH_THUMB_WIDTH, self::SEARCH_THUMB_HEIGHT, true, true, $heightPreference); if (!$thumb instanceof MediaTransformError) { $thumburl = AppDataFormatter::uriencode(wfGetPad($thumb->url)); } } unset($image['obj']); $ret[] = array('id' => intval($title->getArticleId()), 'revision_id' => $revid, 'title' => $title->getText(), 'fulltitle' => wfMsg('howto', $title->getText()), 'url' => self::makeFullURL($title->getPartialUrl()), 'image' => $image, 'image_58x58' => $thumburl, 'abstract' => $abstract); } } return $ret; }
function getDocData($row, $noImages) { $page_id = $row->page_id; $page_counter = $row->page_counter; $title = Title::newFromDBkey($row->page_title); if (!$title || !$title->exists()) { decho("unknown title for id", $page_id, false); return ""; } $title_text = "<![CDATA[" . wfMsg('howto', $title->getText()) . "]]>"; if (!$noImages) { $image = Wikitext::getTitleImage($title, true) ?: AppDataFormatter::getCategoryImageFile($title); } if ($image) { $heightPreference = $image->getWidth() > $image->getHeight(); $thumb = WatermarkSupport::getUnwatermarkedThumbnail($image, AppDataFormatter::SEARCH_THUMB_WIDTH, AppDataFormatter::SEARCH_THUMB_HEIGHT, true, true, $heightPreference); } if ($thumb && !$thumb instanceof MediaTransformError) { $thumbUrl = AppDataFormatter::uriencode(wfGetPad($thumb->url)); } $update = ""; if ($noImages) { $update = 'update="set"'; } $postData = '<doc>' . '<field name="id">' . $page_id . '</field>' . '<field name="title" ' . $update . '>' . $title_text . '</field>' . '<field name="page_counter" ' . $update . '>' . $page_counter . '</field>'; if ($thumbUrl) { $postData .= '<field name="image_58x58">' . $thumbUrl . '</field>'; } $postData .= '</doc>'; return $postData; }
public static function getImageDetails($image) { $result = array('obj' => '', 'url' => ''); if ($image) { $result['obj'] = $image; $thumb = WatermarkSupport::getUnwatermarkedThumbnail($image, self::INDEX_THUMB_MAX_WIDTH); if ($thumb && !$thumb instanceof MediaTransformError) { $result['url'] = self::uriencode(wfGetPad($thumb->getUrl())); $dim = self::getThumbnailDimensions($thumb); $result['width'] = $dim['width']; $result['height'] = $dim['height']; } $thumb = WatermarkSupport::getUnwatermarkedThumbnail($image, self::INDEX_THUMB_LARGE_MAX_WIDTH); if ($thumb && !$thumb instanceof MediaTransformError) { $largeUrl = self::uriencode(wfGetPad($thumb->getUrl())); if ($largeUrl != $result['url']) { $result['large'] = self::uriencode(wfGetPad($thumb->getUrl())); $dim = self::getThumbnailDimensions($thumb); $result['large_width'] = $dim['width']; $result['large_height'] = $dim['height']; } } $original = self::uriencode(wfGetPad($image->url)); if ($original != $largeUrl) { $result['original'] = self::uriencode(wfGetPad($image->getUrl())); $result['original_width'] = intval($image->getWidth()); $result['original_height'] = intval($image->getHeight()); } } return $result; }