/** * Generate the content of each table row (1 row = 1 banner) * @param $row object: database row * @return string HTML */ function formatRow($row) { // Begin banner row $htmlOut = Xml::openElement('tr'); if ($this->editable) { // Remove box $htmlOut .= Xml::tags('td', array('valign' => 'top'), Xml::check('removeTemplates[]', false, array('value' => $row->tmp_name, 'onchange' => $this->onRemoveChange))); } // Link and Preview $render = new SpecialBannerLoader(); $render->siteName = 'Wikipedia'; $render->language = $this->mRequest->getVal('wpUserLanguage'); try { $preview = $render->getHtmlNotice($row->tmp_name); } catch (SpecialBannerLoaderException $e) { $preview = wfMsg('centralnotice-nopreview'); } $htmlOut .= Xml::tags('td', array('valign' => 'top'), $this->getSkin()->makeLinkObj($this->viewPage, htmlspecialchars($row->tmp_name), 'template=' . urlencode($row->tmp_name)) . Xml::fieldset(wfMsg('centralnotice-preview'), $preview, array('class' => 'cn-bannerpreview'))); // End banner row $htmlOut .= Xml::closeElement('tr'); return $htmlOut; }
/** * Generate the content of each table row (1 row = 1 banner) */ function formatRow($row) { // Begin banner row $htmlOut = Xml::openElement('tr'); if ($this->editable) { // Add box $htmlOut .= Xml::tags('td', array('valign' => 'top'), Xml::check('addTemplates[]', '', array('value' => $row->tmp_name))); // Weight select $htmlOut .= Xml::tags('td', array('valign' => 'top'), Xml::listDropDown("weight[{$row->tmp_id}]", CentralNotice::dropDownList(wfMsg('centralnotice-weight'), range(0, 100, 5)), '', '25', '', '')); } // Link and Preview $render = new SpecialBannerLoader(); $render->siteName = 'Wikipedia'; $render->language = $this->mRequest->getVal('wpUserLanguage'); try { $preview = $render->getHtmlNotice($row->tmp_name); } catch (SpecialBannerLoaderException $e) { $preview = wfMsg('centralnotice-nopreview'); } $htmlOut .= Xml::tags('td', array('valign' => 'top'), $this->getSkin()->makeLinkObj($this->viewPage, htmlspecialchars($row->tmp_name), 'template=' . urlencode($row->tmp_name)) . Xml::fieldset(wfMsg('centralnotice-preview'), $preview, array('class' => 'cn-bannerpreview'))); // End banner row $htmlOut .= Xml::closeElement('tr'); return $htmlOut; }
/** * Create form for managing banners assigned to a campaign */ function assignedTemplatesForm($notice) { $sk = $this->getSkin(); $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(array('cn_notices', 'cn_assignments', 'cn_templates'), array('cn_templates.tmp_id', 'cn_templates.tmp_name', 'cn_assignments.tmp_weight'), array('cn_notices.not_name' => $notice, 'cn_notices.not_id = cn_assignments.not_id', 'cn_assignments.tmp_id = cn_templates.tmp_id'), __METHOD__, array('ORDER BY' => 'cn_notices.not_id')); // No banners found if ($dbr->numRows($res) < 1) { return ''; } // Build Assigned banners HTML $htmlOut = Html::hidden('change', 'weight'); $htmlOut .= Xml::fieldset(wfMsg('centralnotice-assigned-templates')); $htmlOut .= Xml::openElement('table', array('cellpadding' => 9, 'width' => '100%')); if ($this->editable) { $htmlOut .= Xml::element('th', array('align' => 'left', 'width' => '5%'), wfMsg("centralnotice-remove")); } $htmlOut .= Xml::element('th', array('align' => 'left', 'width' => '5%'), wfMsg("centralnotice-weight")); $htmlOut .= Xml::element('th', array('align' => 'left', 'width' => '70%'), wfMsg("centralnotice-templates")); // Table rows foreach ($res as $row) { $htmlOut .= Xml::openElement('tr'); if ($this->editable) { // Remove $htmlOut .= Xml::tags('td', array('valign' => 'top'), Xml::check('removeTemplates[]', false, array('value' => $row->tmp_name))); } // Weight $htmlOut .= Xml::tags('td', array('valign' => 'top'), $this->weightDropDown("weight[{$row->tmp_id}]", $row->tmp_weight)); $viewPage = $this->getTitleFor('NoticeTemplate', 'view'); /* XXX this code is duplicated in the CentralNoticePager::formatRow */ $render = new SpecialBannerLoader(); $render->siteName = 'Wikipedia'; global $wgRequest; $render->language = $wgRequest->getVal('wpUserLanguage'); try { $preview = $render->getHtmlNotice($row->tmp_name); } catch (SpecialBannerLoaderException $e) { $preview = wfMsg('centralnotice-nopreview'); } $htmlOut .= Xml::tags('td', array('valign' => 'top'), $sk->makeLinkObj($viewPage, htmlspecialchars($row->tmp_name), 'template=' . urlencode($row->tmp_name)) . Xml::fieldset(wfMsg('centralnotice-preview'), $preview, array('class' => 'cn-bannerpreview'))); $htmlOut .= Xml::closeElement('tr'); } $htmlOut .= XMl::closeElement('table'); $htmlOut .= Xml::closeElement('fieldset'); return $htmlOut; }
/** * Preview all available translations of a banner */ public function showViewAvailable($template) { global $wgOut, $wgUser; // Testing to see if bumping up the memory limit lets meta preview ini_set('memory_limit', '120M'); $sk = $this->getSkin(); // Pull all available text for a banner $langs = array_keys($this->getTranslations($template)); $htmlOut = ''; // Begin View Banner fieldset $htmlOut .= Html::openElement('fieldset', array('class' => 'prefsection')); $htmlOut .= Html::element('h2', null, wfMsg('centralnotice-banner-heading', $template)); foreach ($langs as $lang) { // Link and Preview all available translations $viewPage = $this->getTitle('view'); $render = new SpecialBannerLoader(); $render->siteName = 'Wikipedia'; $render->language = $lang; try { $preview = $render->getHtmlNotice($template); } catch (SpecialBannerLoaderException $e) { $preview = wfMsg('centralnotice-nopreview'); } $htmlOut .= Xml::tags('td', array('valign' => 'top'), $sk->makeLinkObj($viewPage, $lang, 'template=' . urlencode($template) . "&wpUserLanguage={$lang}") . Xml::fieldset(wfMsg('centralnotice-preview'), $preview, array('class' => 'cn-bannerpreview'))); } // End View Banner fieldset $htmlOut .= Html::closeElement('fieldset'); return $wgOut->addHtml($htmlOut); }