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;
}
Exemple #2
0
 private function processRelatedWikihows($list)
 {
     $relateds = array();
     $howto = wfMsg('howto', '');
     foreach ($list as $item) {
         $doc = phpQuery::newDocumentHTML($item['html']);
         $a = $doc['a'];
         if ($a->length) {
             $text = $a->html();
             $text = preg_replace('@^' . $howto . '@', '', $text);
             $title = Title::newFromText($text);
             if ($title && $title->exists()) {
                 $articleID = intval($title->getArticleID());
                 $image = AppDataFormatter::getArticleImage($title);
                 if ($image) {
                     unset($image['obj']);
                 }
                 $relateds[] = array('id' => $articleID, 'title' => wfMsg('howto', $title->getText()), 'image' => $image);
             }
         }
     }
     return $relateds;
 }