Skip to content
Snippets Groups Projects
Unverified Commit 2ce8affc authored by Michael Große's avatar Michael Große
Browse files

l10n(search): Add link to create page from query to searchintro

Implements the functionality requested in #1124
parent 55dc8783
No related branches found
No related tags found
No related merge requests found
......@@ -43,10 +43,10 @@ class Search extends Ui
{
$searchHTML = '';
$searchHTML .= $this->getSearchFormHTML($this->query);
$searchHTML .= $this->getSearchIntroHTML($this->query);
$searchHTML .= $this->getSearchFormHTML($this->query);
$searchHTML .= $this->getPageLookupHTML($this->pageLookupResults);
$searchHTML .= $this->getFulltextResultsHTML($this->fullTextResults, $this->highlight);
......@@ -460,19 +460,43 @@ class Search extends Ui
*/
protected function getSearchIntroHTML($query)
{
global $ID, $lang;
global $lang;
$intro = p_locale_xhtml('searchpage');
// allow use of placeholder in search intro
$pagecreateinfo = (auth_quickaclcheck($ID) >= AUTH_CREATE) ? $lang['searchcreatepage'] : '';
$queryPagename = $this->createPagenameFromQuery($this->parsedQuery);
$createQueryPageLink = html_wikilink($queryPagename . '?do=edit', $queryPagename);
$pagecreateinfo = '';
if (auth_quickaclcheck($queryPagename) >= AUTH_CREATE) {
$pagecreateinfo = sprintf($lang['searchcreatepage'], $createQueryPageLink);
}
$intro = str_replace(
array('@QUERY@', '@SEARCH@', '@CREATEPAGEINFO@'),
array(hsc(rawurlencode($query)), hsc($query), $pagecreateinfo),
$intro
);
return $intro;
}
/**
* Create a pagename based the parsed search query
*
* @param array $parsedQuery
*
* @return string pagename constructed from the parsed query
*/
protected function createPagenameFromQuery($parsedQuery)
{
$pagename = '';
if (!empty($parsedQuery['ns'])) {
$pagename .= cleanID($parsedQuery['ns'][0]);
}
$pagename .= ':' . cleanID(implode(' ' , $parsedQuery['highlight']));
return $pagename;
}
/**
* Build HTML for a list of pages with matching pagenames
*
......@@ -524,7 +548,9 @@ class Search extends Ui
return '<div class="nothing">' . $lang['nothingfound'] . '</div>';
}
$html = '';
$html = '<div class="search_fulltextresult">';
$html .= '<h3>' . $lang['search_fullresults'] . ':</h3>';
$html .= '<dl class="search_results">';
$num = 1;
......@@ -571,6 +597,8 @@ class Search extends Ui
}
$html .= '</dl>';
$html .= '</div>';
return $html;
}
......
......@@ -69,8 +69,9 @@ $lang['badpassconfirm'] = 'Sorry, the password was wrong';
$lang['minoredit'] = 'Minor Changes';
$lang['draftdate'] = 'Draft autosaved on'; // full dformat date will be added
$lang['nosecedit'] = 'The page was changed in the meantime, section info was out of date loaded full page instead.';
$lang['searchcreatepage'] = 'If you didn\'t find what you were looking for, you can create or edit the page named after your query with the appropriate tool.';
$lang['searchcreatepage'] = 'If you didn\'t find what you were looking for, you can create or edit the page %s, named after your query, with the appropriate tool.';
$lang['search_fullresults'] = 'Fulltext results';
$lang['search_exact_match'] = 'Exact match';
$lang['search_starts_with'] = 'Starts with';
$lang['search_ends_with'] = 'Ends with';
......
......@@ -2,4 +2,3 @@
You can find the results of your search below. @CREATEPAGEINFO@
===== Results =====
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment