fix search
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
/.project
|
/.project
|
||||||
|
/.buildpath
|
||||||
|
|||||||
144
config.php
144
config.php
@@ -2620,7 +2620,6 @@ class SearchEngine extends PhpObject
|
|||||||
private $iLevelMax;
|
private $iLevelMax;
|
||||||
private $asItemRanks;
|
private $asItemRanks;
|
||||||
private $asItemInfos;
|
private $asItemInfos;
|
||||||
private $asCodeInfos;
|
|
||||||
private $asUserInfos;
|
private $asUserInfos;
|
||||||
|
|
||||||
//Constants
|
//Constants
|
||||||
@@ -2634,7 +2633,6 @@ class SearchEngine extends PhpObject
|
|||||||
$this->asWords = $this->setWords('');
|
$this->asWords = $this->setWords('');
|
||||||
$this->asItemRanks = array();
|
$this->asItemRanks = array();
|
||||||
$this->asItemInfos = array();
|
$this->asItemInfos = array();
|
||||||
$this->asCodeInfos = array();
|
|
||||||
$this->asUserInfos = array();
|
$this->asUserInfos = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2679,6 +2677,48 @@ class SearchEngine extends PhpObject
|
|||||||
$this->iLevelMax = count($this->asWords);
|
$this->iLevelMax = count($this->asWords);
|
||||||
$this->setResults();
|
$this->setResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setItemInfo($iSearchId, $iItemType, $iItemId)
|
||||||
|
{
|
||||||
|
if(!array_key_exists($iSearchId, $this->asItemInfos))
|
||||||
|
{
|
||||||
|
$this->asItemInfos[$iSearchId] = array('type'=>$iItemType, 'id_item'=>$iItemId);
|
||||||
|
switch($iItemType)
|
||||||
|
{
|
||||||
|
case Databap::CODE_TYPE:
|
||||||
|
$asItemInfo = $this->oMySql->selectRow
|
||||||
|
(
|
||||||
|
MySqlManager::CODE_TABLE,
|
||||||
|
$iItemId,
|
||||||
|
array(MySqlManager::getId(MySqlManager::USER_TABLE), 'description', 'led')
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case Databap::PROC_TYPE:
|
||||||
|
$asItemInfo = $this->oMySql->selectRow
|
||||||
|
(
|
||||||
|
MySqlManager::PROC_TABLE,
|
||||||
|
$iItemId,
|
||||||
|
array(MySqlManager::getId(MySqlManager::USER_TABLE), 'title AS description', 'led')
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case Databap::ART_TYPE:
|
||||||
|
$asItemInfo = $this->oMySql->selectRow
|
||||||
|
(
|
||||||
|
MySqlManager::ART_TABLE,
|
||||||
|
$iItemId,
|
||||||
|
array('first_name', 'last_name', 'title AS description', 'led')
|
||||||
|
);
|
||||||
|
$asItemInfo[MySqlManager::getId(MySqlManager::USER_TABLE)] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$this->asItemInfos[$iSearchId] += $asItemInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getItemInfo($iSearchId, $sInfoName)
|
||||||
|
{
|
||||||
|
return array_key_exists($iSearchId, $this->asItemInfos)?$this->asItemInfos[$iSearchId][$sInfoName]:false;
|
||||||
|
}
|
||||||
|
|
||||||
private function setResults()
|
private function setResults()
|
||||||
{
|
{
|
||||||
@@ -2698,29 +2738,23 @@ class SearchEngine extends PhpObject
|
|||||||
$this->oMySql->cleanSql($asSequence);
|
$this->oMySql->cleanSql($asSequence);
|
||||||
|
|
||||||
//$sRegExp = implode('(.{0,2})', $asSequence);
|
//$sRegExp = implode('(.{0,2})', $asSequence);
|
||||||
$sRegExp = implode(' ?', $asSequence);
|
$sRegExp = implode(self::KEYWORDS_SEPARATOR.'?', $asSequence);
|
||||||
|
|
||||||
//TODO replace with selectRow()
|
//TODO replace with selectRow()
|
||||||
$sQuery = "SELECT id_search, id_item, type FROM searchs WHERE keywords REGEXP '{$sRegExp}'";
|
$sQuery = "SELECT id_search, id_item, type FROM searchs WHERE keywords REGEXP '{$sRegExp}'";
|
||||||
|
|
||||||
//search sequence
|
//search sequence
|
||||||
$asRows = $this->oMySql->getArrayQuery($sQuery, true);
|
$asItems = $this->oMySql->getArrayQuery($sQuery, true);
|
||||||
foreach($asRows as $asRow)
|
foreach($asItems as $asItem)
|
||||||
{
|
{
|
||||||
$iItemId = $asRow['id_item'];
|
$iSearchId = $asItem['id_search'];
|
||||||
unset($asRow['id_item']);
|
$iItemId = $asItem['id_item'];;
|
||||||
|
$iItemType = $asItem['type'];
|
||||||
|
|
||||||
//TODO switch case type
|
$this->incItemRank($iSearchId, $iLevel);
|
||||||
switch($asRow['type'])
|
|
||||||
{
|
|
||||||
case Databap::CODE_TYPE:
|
|
||||||
$this->setCodeInfo($iItemId);
|
|
||||||
$this->setUserInfo($this->getCodeInfo($iItemId, MySqlManager::getId(MySqlManager::USER_TABLE)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->asItemInfos[$iItemId] = $asRow;
|
$this->setItemInfo($iSearchId, $iItemType, $iItemId);
|
||||||
$this->incItemRank($iItemId, $iLevel);
|
$this->setUserInfo($this->getItemInfo($iSearchId, MySqlManager::getId(MySqlManager::USER_TABLE)));
|
||||||
}
|
}
|
||||||
$iIndex++;
|
$iIndex++;
|
||||||
}
|
}
|
||||||
@@ -2734,71 +2768,37 @@ class SearchEngine extends PhpObject
|
|||||||
|
|
||||||
//Mixing info
|
//Mixing info
|
||||||
arsort($this->asItemRanks);
|
arsort($this->asItemRanks);
|
||||||
foreach($this->asItemRanks as $iItemId=>$iRank)
|
foreach($this->asItemRanks as $iSearchId=>$iRank)
|
||||||
{
|
{
|
||||||
switch($this->asItemInfos[$iItemId]['type'])
|
/* TODO Customized item preview
|
||||||
{
|
|
||||||
case Databap::CODE_TYPE:
|
|
||||||
//$asRow['code'] = $this->formatCode($asRow['code'], $sRegExp);
|
|
||||||
break;
|
|
||||||
case Databap::PROC_TYPE:
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//code
|
//code
|
||||||
$iUserId = $this->getCodeInfo($iItemId, MySqlManager::getId(MySqlManager::USER_TABLE));
|
$sCodeLines = implode("\n...\n", $this->getCodeInfo($iItemId, 'code'));
|
||||||
/* TODO
|
|
||||||
$sCodeLines = implode("\n...\n", $this->getCodeInfo($iItemId, 'code'));
|
|
||||||
$oCode = new Reader($sCodeLines);
|
$oCode = new Reader($sCodeLines);
|
||||||
$sCodeLines = $oCode->getColoredCode();
|
$sCodeLines = $oCode->getColoredCode();
|
||||||
*/
|
*/
|
||||||
$sCodeLines = '';
|
|
||||||
$asResult[$iItemId] = array('id_code'=>$iItemId,
|
$iUserId = $this->getItemInfo($iSearchId, MySqlManager::getId(MySqlManager::USER_TABLE));
|
||||||
'code'=>$sCodeLines,
|
$sFirstName = $this->getUserInfo($iUserId, 'first_name')?$this->getUserInfo($iUserId, 'first_name'):$this->getItemInfo($iSearchId, 'first_name');
|
||||||
'description'=>$this->getCodeInfo($iItemId, 'description'),
|
$sLastName = $this->getUserInfo($iUserId, 'last_name')?$this->getUserInfo($iUserId, 'last_name'):$this->getItemInfo($iSearchId, 'last_name');
|
||||||
'name'=>Databap::getNameFormat($this->getUserInfo($iUserId, 'first_name'), $this->getUserInfo($iUserId, 'last_name')),
|
$sCompany = $this->getUserInfo($iUserId, 'company')?$this->getUserInfo($iUserId, 'company'):'SAP';
|
||||||
'company'=>Databap::getCompanyFormat($this->getUserInfo($iUserId, 'company')),
|
$asResult[] = array('id_item'=>$this->getItemInfo($iSearchId, 'id_item'),
|
||||||
'led'=>Databap::getDateFormat($this->getCodeInfo($iItemId, 'led')));
|
'type'=>$this->getItemInfo($iSearchId, 'type'),
|
||||||
|
'description'=>$this->getItemInfo($iSearchId, 'description'),
|
||||||
|
'name'=>Databap::getNameFormat($sFirstName, $sLastName),
|
||||||
|
'company'=>Databap::getCompanyFormat($sCompany),
|
||||||
|
'led'=>Databap::getDateFormat($this->getItemInfo($iSearchId, 'led')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $asResult;
|
return $asResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCodeInfo($iCodeId, $sInfoName)
|
|
||||||
{
|
|
||||||
return $this->asCodeInfos[$iCodeId][$sInfoName];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getUserInfo($iUserId, $sInfoName)
|
private function getUserInfo($iUserId, $sInfoName)
|
||||||
{
|
{
|
||||||
return $this->asUserInfos[$iUserId][$sInfoName];
|
return array_key_exists($iUserId, $this->asUserInfos)?$this->asUserInfos[$iUserId][$sInfoName]:false;
|
||||||
}
|
|
||||||
|
|
||||||
private function setCodeInfo($iCodeId)
|
|
||||||
{
|
|
||||||
if(!array_key_exists($iCodeId, $this->asCodeInfos))
|
|
||||||
{
|
|
||||||
$this->asCodeInfos[$iCodeId] = $this->oMySql->selectRow
|
|
||||||
(
|
|
||||||
MySqlManager::CODE_TABLE,
|
|
||||||
$iCodeId,
|
|
||||||
array(MySqlManager::getId(MySqlManager::USER_TABLE), 'description', 'led')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->asCodeInfos[$iCodeId]['code'] = array_unique(array_merge($this->asCodeInfos[$iCodeId]['code'], $asInfos['code']));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setUserInfo($iUserId)
|
private function setUserInfo($iUserId)
|
||||||
{
|
{
|
||||||
if(!array_key_exists($iUserId, $this->asUserInfos))
|
if(!array_key_exists($iUserId, $this->asUserInfos) && $iUserId > 0)
|
||||||
{
|
{
|
||||||
$sCompanyIdCol = MySqlManager::getId(MySqlManager::COMP_TABLE);
|
$sCompanyIdCol = MySqlManager::getId(MySqlManager::COMP_TABLE);
|
||||||
$this->asUserInfos[$iUserId] = $this->oMySql->selectRow
|
$this->asUserInfos[$iUserId] = $this->oMySql->selectRow
|
||||||
@@ -2813,15 +2813,15 @@ class SearchEngine extends PhpObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function incItemRank($iItemId, $iRank)
|
private function incItemRank($iSearchId, $iRank)
|
||||||
{
|
{
|
||||||
if(array_key_exists($iItemId, $this->asItemRanks))
|
if(array_key_exists($iSearchId, $this->asItemRanks))
|
||||||
{
|
{
|
||||||
$this->asItemRanks[$iItemId] += $iRank;
|
$this->asItemRanks[$iSearchId] += $iRank;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->asItemRanks[$iItemId] = $iRank;
|
$this->asItemRanks[$iSearchId] = $iRank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
jquery/fileuploader.js
vendored
Normal file → Executable file
0
jquery/fileuploader.js
vendored
Normal file → Executable file
69
jquery/handler.js
vendored
Normal file → Executable file
69
jquery/handler.js
vendored
Normal file → Executable file
@@ -667,46 +667,19 @@ var databap =
|
|||||||
databap.getInfo
|
databap.getInfo
|
||||||
(
|
(
|
||||||
'search',
|
'search',
|
||||||
function(asData)
|
function(asItems)
|
||||||
{
|
{
|
||||||
databap.$main.find('#code_container').empty();
|
$Container = databap.$main.find('#list_container');
|
||||||
databap.setCodeContainer
|
$Container.empty();
|
||||||
(
|
if(asItems.length==0)
|
||||||
function()
|
{
|
||||||
{
|
$Container.append('Aucun résultat trouvé.');
|
||||||
//display results
|
}
|
||||||
if(asData.length==0)
|
else
|
||||||
{
|
{
|
||||||
databap.$main.find('#code_container').append('Aucun résultat trouvé.');
|
for(iRankId in asItems) databap.appendItem(asItems[iRankId], $Container);
|
||||||
}
|
}
|
||||||
else
|
databap.addSuccessIcon();
|
||||||
{
|
|
||||||
$.each
|
|
||||||
(
|
|
||||||
asData,
|
|
||||||
function(id_code, code_info)
|
|
||||||
{
|
|
||||||
//append container
|
|
||||||
codeBoxId = databap.appendContainer('#code_container', id_code);
|
|
||||||
|
|
||||||
//link
|
|
||||||
$('#'+codeBoxId).click
|
|
||||||
(
|
|
||||||
function()
|
|
||||||
{
|
|
||||||
databap.vars.code = databap.getFirstElemId($(this).attr('id'));
|
|
||||||
databap.switchPage(databap.pages.read_code);
|
|
||||||
}
|
|
||||||
).addClass('clickable');
|
|
||||||
|
|
||||||
//append code to main and refresh id and return tag
|
|
||||||
var idTag = databap.appendCode('#'+codeBoxId, code_info);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
databap.addSuccessIcon();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
{keywords:searchWords},
|
{keywords:searchWords},
|
||||||
'json'
|
'json'
|
||||||
@@ -722,6 +695,24 @@ var databap =
|
|||||||
//else debug('same words');
|
//else debug('same words');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
appendItem: function(asItemInfo, $Container)
|
||||||
|
{
|
||||||
|
//Filling up the item line
|
||||||
|
$verHtml = $(databap.consts.versionHtml);
|
||||||
|
$verHtml.find('#description').html(asItemInfo.description);
|
||||||
|
$verHtml.find('#author_name').html(asItemInfo.name);
|
||||||
|
$verHtml.find('#author_company').html(asItemInfo.company);
|
||||||
|
$verHtml.find('#led').html(asItemInfo.led);
|
||||||
|
|
||||||
|
//Link
|
||||||
|
var sItemLink = databap.getExternalLink(asItemInfo.type, asItemInfo.id_item);
|
||||||
|
$verHtml.find('#item_link').attr('href', sItemLink).attr('title', 'Lien vers '+sItemLink);
|
||||||
|
$verHtml = databap.setElemTags($verHtml, asItemInfo.id_item, false, asItemInfo.type);
|
||||||
|
|
||||||
|
//Display
|
||||||
|
$verHtml.hide().appendTo(databap.getMainElem('#list_container')).slideDown('fast');
|
||||||
|
},
|
||||||
|
|
||||||
getCodeLink: function(code)
|
getCodeLink: function(code)
|
||||||
{
|
{
|
||||||
return databap.getExternalLink('code', code);
|
return databap.getExternalLink('code', code);
|
||||||
|
|||||||
0
jquery/jquery-1.4.4.min.js
vendored
Normal file → Executable file
0
jquery/jquery-1.4.4.min.js
vendored
Normal file → Executable file
0
jquery/jquery-1.6.1.min.js
vendored
Normal file → Executable file
0
jquery/jquery-1.6.1.min.js
vendored
Normal file → Executable file
0
jquery/jquery.min.js
vendored
Normal file → Executable file
0
jquery/jquery.min.js
vendored
Normal file → Executable file
0
jquery/resize.js
vendored
Normal file → Executable file
0
jquery/resize.js
vendored
Normal file → Executable file
0
jquery/tinyscrollbar.js
vendored
Normal file → Executable file
0
jquery/tinyscrollbar.js
vendored
Normal file → Executable file
0
masks/add_code.html
Normal file → Executable file
0
masks/add_code.html
Normal file → Executable file
0
masks/chat.html
Normal file → Executable file
0
masks/chat.html
Normal file → Executable file
0
masks/code_block.html
Normal file → Executable file
0
masks/code_block.html
Normal file → Executable file
0
masks/doc.html
Normal file → Executable file
0
masks/doc.html
Normal file → Executable file
0
masks/error.html
Normal file → Executable file
0
masks/error.html
Normal file → Executable file
0
masks/index.html
Normal file → Executable file
0
masks/index.html
Normal file → Executable file
36
masks/list.html
Normal file → Executable file
36
masks/list.html
Normal file → Executable file
@@ -10,7 +10,19 @@ databap.pageInit = function()
|
|||||||
//TODO : to be replaced by tinyscrollbar
|
//TODO : to be replaced by tinyscrollbar
|
||||||
databap.$main.css('overflow', 'auto');
|
databap.$main.css('overflow', 'auto');
|
||||||
|
|
||||||
databap.getInfo('list', function(items){buildList(items);}, {}, 'json');
|
databap.getInfo
|
||||||
|
(
|
||||||
|
'list',
|
||||||
|
function(items)
|
||||||
|
{
|
||||||
|
buildList(items);
|
||||||
|
|
||||||
|
//Init's end
|
||||||
|
databap.setInitEnd(true);
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
'json'
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildList(asAllItems)
|
function buildList(asAllItems)
|
||||||
@@ -21,26 +33,10 @@ function buildList(asAllItems)
|
|||||||
{
|
{
|
||||||
for(iItemId in asAllItems[sType])
|
for(iItemId in asAllItems[sType])
|
||||||
{
|
{
|
||||||
asItemInfo = asAllItems[sType][iItemId];
|
asAllItems[sType][iItemId]['type'] = sType;
|
||||||
|
asAllItems[sType][iItemId]['id_item'] = iItemId;
|
||||||
//Filling up the item line
|
databap.appendItem(asAllItems[sType][iItemId], databap.getMainElem('#list_container'));
|
||||||
$verHtml = $(databap.consts.versionHtml);
|
|
||||||
$verHtml.find('#description').html(asItemInfo.description);
|
|
||||||
$verHtml.find('#author_name').html(asItemInfo.name);
|
|
||||||
$verHtml.find('#author_company').html(asItemInfo.company);
|
|
||||||
$verHtml.find('#led').html(asItemInfo.led);
|
|
||||||
|
|
||||||
//Link
|
|
||||||
var sItemLink = databap.getExternalLink(sType, iItemId);
|
|
||||||
$verHtml.find('#item_link').attr('href', sItemLink).attr('title', 'Lien vers '+sItemLink);
|
|
||||||
$verHtml = databap.setElemTags($verHtml, iItemId, false, sType);
|
|
||||||
|
|
||||||
//Display
|
|
||||||
$verHtml.hide().appendTo(databap.getMainElem('#list_container')).slideDown('fast');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Init's end
|
|
||||||
databap.setInitEnd(true);
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
0
masks/logon.html
Normal file → Executable file
0
masks/logon.html
Normal file → Executable file
0
masks/options.html
Normal file → Executable file
0
masks/options.html
Normal file → Executable file
0
masks/procedure.html
Normal file → Executable file
0
masks/procedure.html
Normal file → Executable file
0
masks/profile.html
Normal file → Executable file
0
masks/profile.html
Normal file → Executable file
0
masks/read_code.html
Normal file → Executable file
0
masks/read_code.html
Normal file → Executable file
2
masks/search.html
Normal file → Executable file
2
masks/search.html
Normal file → Executable file
@@ -2,7 +2,7 @@
|
|||||||
<div class="h1_wrap">
|
<div class="h1_wrap">
|
||||||
<h1 class="round"><span>Recherche</span></h1>
|
<h1 class="round"><span>Recherche</span></h1>
|
||||||
</div>
|
</div>
|
||||||
<div id="code_container"></div>
|
<div id="list_container" class="standalone"></div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
databap.pageInit = function()
|
databap.pageInit = function()
|
||||||
|
|||||||
0
masks/welcome.html
Normal file → Executable file
0
masks/welcome.html
Normal file → Executable file
Reference in New Issue
Block a user