/** * @dataProvider providerMimeFiltering * @param string $par Subpage for special page * @param string $major Major MIME type we expect to look for * @param string $minor Minor MIME type we expect to look for */ function testMimeFiltering($par, $major, $minor) { $this->page->run($par); $qi = $this->page->getQueryInfo(); $this->assertEquals($qi['conds']['img_major_mime'], $major); if ($minor !== null) { $this->assertEquals($qi['conds']['img_minor_mime'], $minor); } else { $this->assertArrayNotHasKey('img_minor_mime', $qi['conds']); } $this->assertContains('image', $qi['tables']); }
/** * constructor */ function wfSpecialMIMEsearch($par = null) { global $wgRequest, $wgTitle, $wgOut; $mime = isset($par) ? $par : $wgRequest->getText('mime'); $wgOut->addHTML(wfElement('form', array('id' => 'specialmimesearch', 'method' => 'get', 'action' => $wgTitle->escapeLocalUrl()), null) . wfOpenElement('label') . wfMsgHtml('mimetype') . wfElement('input', array('type' => 'text', 'size' => 20, 'name' => 'mime', 'value' => $mime), '') . ' ' . wfElement('input', array('type' => 'submit', 'value' => wfMsg('ilsubmit')), '') . wfCloseElement('label') . wfCloseElement('form')); list($major, $minor) = wfSpecialMIMEsearchParse($mime); if ($major == '' or $minor == '' or !wfSpecialMIMEsearchValidType($major)) { return; } $wpp = new MIMEsearchPage($major, $minor); list($limit, $offset) = wfCheckLimits(); $wpp->doQuery($offset, $limit); }
/** * Output the HTML search form, and constructs the MIMEsearchPage object. */ function wfSpecialMIMEsearch($par = null) { global $wgRequest, $wgTitle, $wgOut; $mime = isset($par) ? $par : $wgRequest->getText('mime'); $wgOut->addHTML(Xml::openElement('form', array('id' => 'specialmimesearch', 'method' => 'get', 'action' => $wgTitle->getLocalUrl())) . Xml::inputLabel(wfMsg('mimetype'), 'mime', 'mime', 20, $mime) . Xml::submitButton(wfMsg('ilsubmit')) . Xml::closeElement('form')); list($major, $minor) = wfSpecialMIMEsearchParse($mime); if ($major == '' or $minor == '' or !wfSpecialMIMEsearchValidType($major)) { return; } $wpp = new MIMEsearchPage($major, $minor); list($limit, $offset) = wfCheckLimits(); $wpp->doQuery($offset, $limit); }