Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('search-index', 'i18n_search_nm_index');
- add_filter('search-item', 'i18n_search_nm_item');
- function i18n_search_nm_index() {
- $posts = nm_get_posts();
- foreach ($posts as $post) {
- $id=$post->slug;
- $title = strip_tags(strip_decode($post->title));
- $file = NMPOSTPATH . "$id.xml";
- $post = @getXML($file);
- $content = html_entity_decode(strip_tags(htmlspecialchars_decode($post->content)), ENT_QUOTES, 'UTF-8');;
- i18n_search_index_item('nm:'.$id, null, $date, $date, null, $title, $content);
- }
- }
- function i18n_search_nm_item($id, $language, $creDate, $pubDate, $score) {
- if (!class_exists('I18nSearchNewsManangerResultItem')) {
- class I18nSearchNewsManangerResultItem extends I18nSearchResultItem {
- protected $data = null;
- protected function get($name) {
- if (!$this->data) {
- $slug=substr($this->id,3);
- $file = NMPOSTPATH . "$slug.xml";
- $post = @getXML($file);
- if (!post) return null;
- }
- switch ($name) {
- case 'title': return strip_tags(strip_decode($post->title));
- case 'content': return null;
- case 'link': $url = nm_get_url('post') . $slug;return $url;
- default: return @$post>title;
- }
- }
- }
- }
- if (substr($id,0,3) == 'nm:') {
- // return the result item, if it is an item of our plugin
- return new I18nSearchNewsManangerResultItem($id, $language, $creDate, $pubDate, $score);
- }
- // item is not from our plugin - maybe from another plugin
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement