BUGFIX: fixed search index field naming from module to entity to be consistent. BUGFIX: fixed url for opensearch description. ENHANCEMENT: moved author information to meta_data

This commit is contained in:
Will Rossiter 2011-08-11 17:02:13 +12:00
parent a12169c9e0
commit 7381733b4c
2 changed files with 21 additions and 10 deletions

View File

@ -198,7 +198,7 @@ class DocumentationSearch {
$moduleQuery = new Zend_Search_Lucene_Search_Query_MultiTerm(); $moduleQuery = new Zend_Search_Lucene_Search_Query_MultiTerm();
foreach($this->modules as $module) { foreach($this->modules as $module) {
$moduleQuery->addTerm(new Zend_Search_Lucene_Index_Term($module, 'Module')); $moduleQuery->addTerm(new Zend_Search_Lucene_Index_Term($module, 'Entity'));
} }
$query->addSubquery($moduleQuery, true); $query->addSubquery($moduleQuery, true);
@ -275,7 +275,7 @@ class DocumentationSearch {
'Link' => DBField::create('Varchar',$doc->getFieldValue('Link')), 'Link' => DBField::create('Varchar',$doc->getFieldValue('Link')),
'Language' => DBField::create('Varchar',$doc->getFieldValue('Language')), 'Language' => DBField::create('Varchar',$doc->getFieldValue('Language')),
'Version' => DBField::create('Varchar',$doc->getFieldValue('Version')), 'Version' => DBField::create('Varchar',$doc->getFieldValue('Version')),
'Module' => DBField::create('Varchar', $doc->getFieldValue('Module')), 'Entity' => DBField::create('Varchar', $doc->getFieldValue('Entity')),
'Content' => DBField::create('HTMLText', $content), 'Content' => DBField::create('HTMLText', $content),
'Score' => $hit->score, 'Score' => $hit->score,
'Number' => $k + 1, 'Number' => $k + 1,
@ -372,7 +372,8 @@ class DocumentationSearch {
} }
/** /**
* OpenSearch MetaData. Includes 'description', 'tags', 'contact' * OpenSearch MetaData fields. For a list of fields consult
* {@link self::get_meta_data()}
* *
* @param array * @param array
*/ */
@ -382,6 +383,9 @@ class DocumentationSearch {
self::$meta_data[strtolower($key)] = $value; self::$meta_data[strtolower($key)] = $value;
} }
} }
else {
user_error("set_meta_data must be passed an array", E_USER_ERROR);
}
} }
/** /**
@ -392,12 +396,19 @@ class DocumentationSearch {
public static function get_meta_data() { public static function get_meta_data() {
$data = self::$meta_data; $data = self::$meta_data;
return array( $defaults = array(
'Description' => (isset($data['description'])) ? $data['description'] : _t('DocumentationViewer.OPENSEARCHDESC', 'Search the documentation'), 'Description' => _t('DocumentationViewer.OPENSEARCHDESC', 'Search the documentation'),
'Tags' => (isset($data['tags'])) ? $data['tags'] : _t('DocumentationViewer.OPENSEARCHTAGS', 'documentation'), 'Tags' => _t('DocumentationViewer.OPENSEARCHTAGS', 'documentation'),
'Contact' => (isset($data['contact'])) ? $data['contact'] : Email::getAdminEmail(), 'Contact' => Email::getAdminEmail(),
'ShortName' => (isset($data['shortname'])) ? $data['shortname'] : _t('DocumentationViewer.OPENSEARCHNAME', 'Documentation Search') 'ShortName' => _t('DocumentationViewer.OPENSEARCHNAME', 'Documentation Search'),
'Author' => 'SilverStripe'
); );
foreach($defaults as $key => $value) {
if(isset($data[$key])) $defaults[$key] = $data[$key];
}
return $defaults;
} }
/** /**
@ -417,7 +428,7 @@ class DocumentationSearch {
// alter the fields for the opensearch xml. // alter the fields for the opensearch xml.
$title = ($title = $this->getTitle()) ? ' - '. $title : ""; $title = ($title = $this->getTitle()) ? ' - '. $title : "";
$link = Controller::join_links($this->outputController->Link(), 'DocumentationOpenSearch_Controller/description/'); $link = Controller::join_links($this->outputController->Link(), 'DocumentationOpenSearchController/description/');
$data->setField('Title', $data->Title . $title); $data->setField('Title', $data->Title . $title);
$data->setField('DescriptionURL', $link); $data->setField('DescriptionURL', $link);

View File

@ -3,7 +3,7 @@
<title>$Title</title> <title>$Title</title>
<link>$Link</link> <link>$Link</link>
<author> <author>
<name>SilverStripe Ltd.</name> <name>$Author</name>
</author> </author>
<updated>$Now</updated> <updated>$Now</updated>