Skip to content

Commit

Permalink
unacms#1785 Page builder for search pages
Browse files Browse the repository at this point in the history
  • Loading branch information
romanlesnikov committed Nov 12, 2020
1 parent ba9e18f commit def524c
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 31 deletions.
5 changes: 4 additions & 1 deletion install/sql/system.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4835,7 +4835,8 @@ INSERT INTO `sys_objects_page` (`object`, `uri`, `title_system`, `title`, `modul
('sys_std_dashboard', '', '_sys_page_title_system_studio_dashboard', '_sys_page_title_studio_dashboard', 'system', 1, 4, '', 2147483647, 1, '', '', '', '', 0, 1, 0, '', '', 0),
('sys_cmts_view' ,'cmts-view', '', '_cmt_page_view_header', 'system', 1, 5, '', 2147483647, 1, 'page.php?i=cmts-view', '', '', '', 0, 1, 0, 'BxTemplCmtsPageView', '', 0),
('sys_cmts_administration' ,'cmts-administration', '_sys_page_title_system_cmts_administration', '_sys_page_title_cmts_administration', 'system', 1, 5, '', 192, 1, 'page.php?i=cmts-administration', '', '', '', 0, 1, 0, '', '', 0),
('sys_audit' ,'audit-administration', '_sys_page_title_system_audit_administration', '_sys_page_title_audit_administration', 'system', 1, 5, '', 192, 1, 'page.php?i=audit-administration', '', '', '', 0, 1, 0, '', '', 0);
('sys_audit' ,'audit-administration', '_sys_page_title_system_audit_administration', '_sys_page_title_audit_administration', 'system', 1, 5, '', 192, 1, 'page.php?i=audit-administration', '', '', '', 0, 1, 0, '', '', 0),
('sys_search_keyword', 'search-keyword', '_sys_page_title_system_search_keyword', '_sys_page_title_search_keyword', 'system', 1, 5, '', 2147483647, 1, 'searchKeyword.php', '', '', '', 0, 1, 0, '', '', 0);


CREATE TABLE IF NOT EXISTS `sys_pages_types` (
Expand Down Expand Up @@ -5032,6 +5033,8 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `

('sys_audit', 1, 'system', '_sys_page_block_title_system_audit_administration', '_sys_page_block_title_audit_administration', 11, 0, 0, 192, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:12:"manage_tools";s:6:"params";a:1:{i:0;s:14:"administration";}s:5:"class";s:18:"TemplAuditServices";}', 0, 1, 1, 1),

('sys_search_keyword', 1, 'system', '', '_sys_page_block_title_search_keyword_form', 13, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:19:"search_keyword_form";s:6:"params";a:0:{}s:5:"class";s:13:"TemplServices";}', 0, 1, 1, 1),
('sys_search_keyword', 1, 'system', '', '_sys_page_block_title_search_keyword_result', 13, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:21:"search_keyword_result";s:6:"params";a:0:{}s:5:"class";s:13:"TemplServices";}', 0, 1, 1, 1),
-- studio dashboard blocks
('sys_std_dashboard', 1, 'system', '', '_sys_page_block_title_std_dash_version', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:17:"get_block_version";s:6:"params";a:0:{}s:5:"class";s:20:"TemplStudioDashboard";}', 0, 0, 1, 1),

Expand Down
4 changes: 4 additions & 0 deletions modules/boonex/english/data/langs/system/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2823,6 +2823,8 @@ If it is not enabled then please consider implement this optimization, since it
<string name="_sys_page_block_title_homepage_menu"><![CDATA[Content modules menu]]></string>
<string name="_sys_page_block_title_homepage_splash"><![CDATA[Splash]]></string>
<string name="_sys_page_block_title_forgot_password"><![CDATA[Forgot Password]]></string>
<string name="_sys_page_block_title_search_keyword_form"><![CDATA[Search Form]]></string>
<string name="_sys_page_block_title_search_keyword_result"><![CDATA[Search Result]]></string>
<string name="_sys_page_block_title_membership_stats"><![CDATA[Membership Limits]]></string>
<string name="_sys_page_block_system_title_login"><![CDATA[Log in with Sign up link]]></string>
<string name="_sys_page_block_system_title_login_step2"><![CDATA[Log in - step2]]></string>
Expand Down Expand Up @@ -2884,6 +2886,8 @@ If it is not enabled then please consider implement this optimization, since it
<string name="_sys_page_title_system_create_account"><![CDATA[Sign up]]></string>
<string name="_sys_page_title_system_dashboard"><![CDATA[Dashboard]]></string>
<string name="_sys_page_title_system_forgot_password"><![CDATA[Forgot Password]]></string>
<string name="_sys_page_title_system_search_keyword"><![CDATA[Search by Keyword]]></string
<string name="_sys_page_title_search_keyword"><![CDATA[Search by Keyword]]></string>
<string name="_sys_page_title_system_home"><![CDATA[Homepage]]></string>
<string name="_sys_page_title_system_login"><![CDATA[Log in]]></string>
<string name="_sys_page_title_system_login_step2"><![CDATA[Log in - step 2]]></string>
Expand Down
4 changes: 4 additions & 0 deletions modules/boonex/russian/data/langs/system/ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2774,6 +2774,8 @@
<string name="_sys_page_block_title_homepage_menu"><![CDATA[Меню модулей с содержимым]]></string>
<string name="_sys_page_block_title_homepage_splash"><![CDATA[Заставка]]></string>
<string name="_sys_page_block_title_forgot_password"><![CDATA[Забыли пароль]]></string>
<string name="_sys_page_block_title_search_keyword_form"><![CDATA[Форма поиска]]></string>
<string name="_sys_page_block_title_search_keyword_result"><![CDATA[Результаты поиска]]></string>
<string name="_sys_page_block_title_membership_stats"><![CDATA[Лимиты членства]]></string>
<string name="_sys_page_block_system_title_login"><![CDATA[Вход с линкой регистрации]]></string>
<string name="_sys_page_block_system_title_login_step2"><![CDATA[Вход - шаг 2]]></string>
Expand Down Expand Up @@ -2835,6 +2837,8 @@
<string name="_sys_page_title_system_create_account"><![CDATA[Присоединиться]]></string>
<string name="_sys_page_title_system_dashboard"><![CDATA[Панель]]></string>
<string name="_sys_page_title_system_forgot_password"><![CDATA[Забыли пароль]]></string>
<string name="_sys_page_title_system_search_keyword"><![CDATA[Поиск по ключевым словам]]></string>
<string name="_sys_page_title_search_keyword"><![CDATA[Поиск по ключевым словам]]></string
<string name="_sys_page_title_system_home"><![CDATA[Домашняя страница]]></string>
<string name="_sys_page_title_system_login"><![CDATA[Вход]]></string>
<string name="_sys_page_title_system_login_step2"><![CDATA[Вход - шаг2]]></string>
Expand Down
30 changes: 2 additions & 28 deletions searchKeyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,7 @@
require_once('./inc/header.inc.php');
require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");

$sClass = 'BxTemplSearch';

$sElsName = 'bx_elasticsearch';
$sElsMethod = 'is_configured';
if(BxDolRequest::serviceExists($sElsName, $sElsMethod) && BxDolService::call($sElsName, $sElsMethod) && !bx_get('cat') && !bx_get('type')) {
$oModule = BxDolModule::getInstance($sElsName);
bx_import('Search', $oModule->_aModule);
$sClass = 'BxElsSearch';
}
bx_alert('system', 'search_keyword', 0, 0, array('class' => &$sClass));

$oSearch = new $sClass(bx_get('section'));
$oSearch->setLiveSearch(bx_get('live_search') ? 1 : 0);
$oSearch->setMetaType(bx_process_input(bx_get('type')));
$oSearch->setCategoryObject(bx_process_input(bx_get('cat')));

$sCode = '';
if (bx_get('keyword') !== false) {
$sCode = $oSearch->response();
if (!$sCode)
$sCode = $oSearch->getEmptyResult();
}

$oTemplate = BxDolTemplate::getInstance();
$oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
$oTemplate->setPageHeader (_t("_Search"));
$oTemplate->setPageContent ('page_main_code', $oSearch->getForm() . ($sCode ? $oSearch->getResultsContainer($sCode) : ''));
$oTemplate->getPageCode();
$_GET['i'] = 'search-keyword';
require_once("./page.php");

/** @} */
6 changes: 4 additions & 2 deletions template/scripts/BxBaseSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct($aChoice, $oTemplate)
$this->_oTemplate = $oTemplate ? $oTemplate : BxDolTemplate::getInstance();
}

public function getForm($iDesignBoxTemplate = BX_DB_PADDING_DEF, $sTitle = false)
public function getForm($iDesignBoxTemplate = BX_DB_PADDING_DEF, $sTitle = false, $bOnlyForm = false)
{
if ($this->_sMetaType || $this->_sCategoryObject)
return '';
Expand Down Expand Up @@ -108,7 +108,9 @@ public function getForm($iDesignBoxTemplate = BX_DB_PADDING_DEF, $sTitle = false
$o = new BxTemplPaginate(array());
$o->addCssJs();
}

if ($bOnlyForm)
return $sForm;

return '<div class="bx-page-block-container bx-def-padding-sec-topbottom bx-clearfix">' . DesignBoxContent($sTitle, $sForm, $iDesignBoxTemplate) . '</div>';
}

Expand Down
69 changes: 69 additions & 0 deletions template/scripts/BxBaseServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,55 @@ public function serviceKeywordSearch ($sSection, $aCondition, $sTemplate = '', $
return $oSearch->response();
}

/**
* @page service Service Calls
* @section bx_system_general System Services
* @subsection bx_system_general-general General
* @subsubsection bx_system_general-keyword_search keyword_search
*
* @code bx_srv('system', 'search_keyword_form', 'TemplServices'); @endcode
*
* Block with Search by Keywords Form
*
* @see BxBaseServices::serviceSearchKeywordForm
*/
/**
* @ref bx_system_general-keyword_search "keyword_search"
*/
public function serviceSearchKeywordForm ()
{
return $this->_getSearchObject()->getForm(BX_DB_PADDING_DEF, false, true);
}

/**
* @page service Service Calls
* @section bx_system_general System Services
* @subsection bx_system_general-general General
* @subsubsection bx_system_general-keyword_search keyword_search
*
* @code bx_srv('system', 'search_keyword_result', 'TemplServices'); @endcode
*
* Block with Search by Keywords Results
*
* @see BxBaseServices::serviceSearchKeywordResult
*/
/**
* @ref bx_system_general-keyword_search "keyword_search"
*/
public function serviceSearchKeywordResult ()
{
$oSearch = $this->_getSearchObject();

$sCode = '';
if (bx_get('keyword') !== false) {
$sCode = $oSearch->response();
if (!$sCode)
$sCode = $oSearch->getEmptyResult();
}

return $sCode;
}

/**
* @page service Service Calls
* @section bx_system_general System Services
Expand Down Expand Up @@ -494,6 +543,26 @@ public function serviceGetBadge($aBadge, $bIsCompact = false)
)
);
}

private function _getSearchObject()
{
$sClass = 'BxTemplSearch';
$sElsName = 'bx_elasticsearch';
$sElsMethod = 'is_configured';
if(BxDolRequest::serviceExists($sElsName, $sElsMethod) && BxDolService::call($sElsName, $sElsMethod) && !bx_get('cat') && !bx_get('type')) {
$oModule = BxDolModule::getInstance($sElsName);
bx_import('Search', $oModule->_aModule);
$sClass = 'BxElsSearch';
}
bx_alert('system', 'search_keyword', 0, 0, array('class' => &$sClass));

$oSearch = new $sClass(bx_get('section'));
$oSearch->setLiveSearch(bx_get('live_search') ? 1 : 0);
$oSearch->setMetaType(bx_process_input(bx_get('type')));
$oSearch->setCategoryObject(bx_process_input(bx_get('cat')));

return $oSearch;
}
}

/** @} */

0 comments on commit def524c

Please sign in to comment.