/** * Sets the meta description in the database to be part of the intro, part * of the first step, or 'original' which is something like "wikiHow * article on How to <title>". */ private function buildDescription($style) { if (self::DESC_STYLE_ORIGINAL == $style) { return array(true, ''); } if (self::DESC_STYLE_EDITED == $style) { return array(true, $this->row['ami_desc']); } $wikitext = $this->getArticleWikiText(); if (!$wikitext) { return array(false, ''); } if (self::DESC_STYLE_INTRO == $style || self::DESC_STYLE_INTRO_NO_TITLE == $style) { // grab intro $desc = Wikitext::getIntro($wikitext); // append first step to intro if intro maybe isn't long enough if (strlen($desc) < 2 * self::MAX_DESC_LENGTH) { list($steps, ) = Wikitext::getStepsSection($wikitext); if ($steps) { $desc .= ' ' . Wikitext::cutFirstStep($steps); } } } elseif (self::DESC_STYLE_STEP1 == $style) { // grab steps section list($desc, ) = Wikitext::getStepsSection($wikitext); // pull out just the first step if ($desc) { $desc = Wikitext::cutFirstStep($desc); } else { $desc = Wikitext::getIntro($wikitext); } } else { //throw new Exception('ArticleMetaInfo: unknown style'); return array(false, ''); } $desc = Wikitext::flatten($desc); $howto = wfMsg('howto', $this->titleText); if ($desc) { if (self::DESC_STYLE_INTRO_NO_TITLE != $style) { $desc = $howto . '. ' . $desc; } } else { $desc = $howto; } $desc = self::trimDescription($desc); return array(true, $desc); }