/** * Return HTML to be used when embedding polls from inside parser * TODO: replace all this with a hook inside parser * * @param WikiaPoll $poll * @param Title $finalTitle */ public static function generate($poll, $finalTitle) { wfProfileIn(__METHOD__); if ($finalTitle instanceof Title && $finalTitle->exists() && $finalTitle->getNamespace() == NS_WIKIA_POLL) { $app = F::app(); $ret = $poll->renderEmbedded(); if (self::$alreadyAddedCSSJS == false) { // make sure we don't include twice if there are multiple polls on one page self::$alreadyAddedCSSJS = true; // add CSS & JS and Poll HTML together if ($app->checkSkin('wikiamobile')) { $cssLinks = AssetsManager::getInstance()->getURL('wikiapoll_wikiamobile_scss'); $jsLinks = AssetsManager::getInstance()->getURL('wikiapoll_wikiamobile_js'); $css = ''; $js = ''; if (is_array($cssLinks)) { foreach ($cssLinks as $s) { $css .= "<link rel=stylesheet href={$s} />"; } } if (is_array($jsLinks)) { foreach ($jsLinks as $s) { $js .= "<script src={$s}></script>"; } } $js .= JSMessages::printPackages(array('WikiaMobilePolls')); $ret = str_replace("\n", ' ', "{$css}{$ret}{$js}"); } else { $sassUrl = AssetsManager::getInstance()->getSassCommonURL('/extensions/wikia/WikiaPoll/css/WikiaPoll.scss'); $css = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($sassUrl) . ' " />'; $jsFile = JSSnippets::addToStack(array('/extensions/wikia/WikiaPoll/js/WikiaPoll.js'), array(), 'WikiaPoll.init'); $ret = str_replace("\n", ' ', "{$css} {$ret} {$jsFile}"); } } wfProfileOut(__METHOD__); return $ret; } wfProfileOut(__METHOD__); return ''; }