protected function setSearchResultsAsXml($searchValue, $searchResults)
    {
        $pagePublishTable = $this->getServiceLocator()->get('MelisEngineTablePagePublished');
        $pageLangTbl = $this->getServiceLocator()->get('MelisEngineTablePageLang');
        $cmsLangTbl  = $this->getServiceLocator()->get('MelisEngineTableCmsLang');
        $pageTreeSvc = $this->getServiceLocator()->get('MelisEngineTree');
        $xmlContent = '<?xml version="1.0" encoding="UTF-8"?>';
        $xmlContent.= '<document type="MelisSearchResults" author="MelisTechnology" version="2.0">';
        $xmlContent.= '<searchQuery>'.$searchValue.'</searchQuery>';

        $lastEditedDate = null;
        $pageStatus     = null;
        $totalResults   = 0;

        foreach($searchResults as $result) {

            $pageData = $pagePublishTable->getEntryById($result->page_id)->current();
            $pageLangId = $pageLangTbl->getEntryByField('plang_page_id',(int) $result->page_id )->current();
            $pageUrl    = $pageTreeSvc->getPageLink($result->page_id,true);
            $pageLangId = $pageLangId->plang_lang_id;
            $pageLangLocale = $cmsLangTbl->getEntryById($pageLangId)->current();
            $pageLangLocale = $pageLangLocale->lang_cms_locale;

            if($pageData) {
                $lastEditedDate = $pageData->page_edit_date;
                $pageStatus     = $pageData->page_status;
            }

            $description = $this->limitedText($result->description);

            $xmlContent .= '<result>';
            $xmlContent .= '    <score>' . round($result->score, 2, PHP_ROUND_HALF_EVEN) . '</score>';
            $xmlContent .= '    <pageStatus>' . $pageStatus         .'</pageStatus>';
            $xmlContent .= '    <url>'        . $pageUrl        .'</url>';
            $xmlContent .= '    <pageId>'     . $result->page_id    .'</pageId>';
            $xmlContent .= '    <pageName>'   . $result->page_name  .'</pageName>';
            $xmlContent .= '    <pageLangId>'   . $pageLangId  .'</pageLangId>';
            $xmlContent .= '    <pageLangLocale>'   . $pageLangLocale  .'</pageLangLocale>';
            $xmlContent .= '    <lastPageEdit>' . $lastEditedDate   .'</lastPageEdit>';
            $xmlContent .= '    <description>' .  $description  .'</description>';
            $xmlContent .= '</result>';

            $totalResults++;
        }
        $xmlContent.= '<totalResults>'.$totalResults.'</totalResults>';


        $xmlContent.= '</document>';

        return $xmlContent;
    }
protected function setSearchResultsAsXml($searchValue, $searchResults)
    {
        $pagePublishTable = $this->getServiceLocator()->get('MelisEngineTablePagePublished');
        $pageLangTbl = $this->getServiceLocator()->get('MelisEngineTablePageLang');
        $cmsLangTbl  = $this->getServiceLocator()->get('MelisEngineTableCmsLang');
        $pageTreeSvc = $this->getServiceLocator()->get('MelisEngineTree');
        $xmlContent = '<?xml version="1.0" encoding="UTF-8"?>';
        $xmlContent.= '<document type="MelisSearchResults" author="MelisTechnology" version="2.0">';
        $xmlContent.= '<searchQuery>'.$searchValue.'</searchQuery>';

        $lastEditedDate = null;
        $pageStatus     = null;
        $totalResults   = 0;

        foreach($searchResults as $result) {

            $pageData = $pagePublishTable->getEntryById($result->page_id)->current();
            $pageLangId = $pageLangTbl->getEntryByField('plang_page_id',(int) $result->page_id )->current();
            $pageUrl    = $pageTreeSvc->getPageLink($result->page_id,true);
            $pageLangId = $pageLangId->plang_lang_id;
            $pageLangLocale = $cmsLangTbl->getEntryById($pageLangId)->current();
            $pageLangLocale = $pageLangLocale->lang_cms_locale;

            if($pageData) {
                $lastEditedDate = $pageData->page_edit_date;
                $pageStatus     = $pageData->page_status;
            }

            $description = $this->limitedText($result->description);

            $xmlContent .= '<result>';
            $xmlContent .= '    <score>' . round($result->score, 2, PHP_ROUND_HALF_EVEN) . '</score>';
            $xmlContent .= '    <pageStatus>' . $pageStatus         .'</pageStatus>';
            $xmlContent .= '    <url>'        . $pageUrl        .'</url>';
            $xmlContent .= '    <pageId>'     . $result->page_id    .'</pageId>';
            $xmlContent .= '    <pageName>'   . $result->page_name  .'</pageName>';
            $xmlContent .= '    <pageLangId>'   . $pageLangId  .'</pageLangId>';
            $xmlContent .= '    <pageLangLocale>'   . $pageLangLocale  .'</pageLangLocale>';
            $xmlContent .= '    <lastPageEdit>' . $lastEditedDate   .'</lastPageEdit>';
            $xmlContent .= '    <description>' .  $description  .'</description>';
            $xmlContent .= '</result>';

            $totalResults++;
        }
        $xmlContent.= '<totalResults>'.$totalResults.'</totalResults>';


        $xmlContent.= '</document>';

        return $xmlContent;
    }
protected function setSearchResultsAsXml ( $ searchValue , $ searchResults ) { $ pagePublishTable = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePagePublished' ) ; $ pageLangTbl = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePageLang' ) ; $ cmsLangTbl = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableCmsLang' ) ; $ pageTreeSvc = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTree' ) ; $ xmlContent = '<?xml version="1.0" encoding="UTF-8"?>' ; $ xmlContent .= '<document type="MelisSearchResults" author="MelisTechnology" version="2.0">' ; $ xmlContent .= '<searchQuery>' . $ searchValue . '</searchQuery>' ; $ lastEditedDate = null ; $ pageStatus = null ; $ totalResults = 0 ; foreach ( $ searchResults as $ result ) { $ pageData = $ pagePublishTable -> getEntryById ( $ result -> page_id ) -> current ( ) ; $ pageLangId = $ pageLangTbl -> getEntryByField ( 'plang_page_id' , ( int ) $ result -> page_id ) -> current ( ) ; $ pageUrl = $ pageTreeSvc -> getPageLink ( $ result -> page_id , true ) ; $ pageLangId = $ pageLangId -> plang_lang_id ; $ pageLangLocale = $ cmsLangTbl -> getEntryById ( $ pageLangId ) -> current ( ) ; $ pageLangLocale = $ pageLangLocale -> lang_cms_locale ; if ( $ pageData ) { $ lastEditedDate = $ pageData -> page_edit_date ; $ pageStatus = $ pageData -> page_status ; } $ description = $ this -> limitedText ( $ result -> description ) ; $ xmlContent .= '<result>' ; $ xmlContent .= '    <score>' . round ( $ result -> score , 2 , PHP_ROUND_HALF_EVEN ) . '</score>' ; $ xmlContent .= '    <pageStatus>' . $ pageStatus . '</pageStatus>' ; $ xmlContent .= '    <url>' . $ pageUrl . '</url>' ; $ xmlContent .= '    <pageId>' . $ result -> page_id . '</pageId>' ; $ xmlContent .= '    <pageName>' . $ result -> page_name . '</pageName>' ; $ xmlContent .= '    <pageLangId>' . $ pageLangId . '</pageLangId>' ; $ xmlContent .= '    <pageLangLocale>' . $ pageLangLocale . '</pageLangLocale>' ; $ xmlContent .= '    <lastPageEdit>' . $ lastEditedDate . '</lastPageEdit>' ; $ xmlContent .= '    <description>' . $ description . '</description>' ; $ xmlContent .= '</result>' ; $ totalResults ++ ; } $ xmlContent .= '<totalResults>' . $ totalResults . '</totalResults>' ; $ xmlContent .= '</document>' ; return $ xmlContent ; }
Returns the search results as XML

@param string $searchValue
@param array $searchResults
@return string
Returns the search results as XML