|
|
|
|
@@ -668,7 +668,8 @@ class Databap extends PhpObject
|
|
|
|
|
{
|
|
|
|
|
$asSearchTypes = array( self::CODE_TYPE=>MySqlManager::CODE_TABLE,
|
|
|
|
|
self::PROC_TYPE=>MySqlManager::PROC_TABLE,
|
|
|
|
|
self::ART_TYPE=>MySqlManager::ART_TABLE);
|
|
|
|
|
self::ART_TYPE=>MySqlManager::ART_TABLE,
|
|
|
|
|
self::DOC_TYPE=>MySqlManager::DOC_TABLE);
|
|
|
|
|
|
|
|
|
|
$this->oMySql->getArrayQuery("TRUNCATE ".MySqlManager::SEARCH_TABLE);
|
|
|
|
|
foreach($asSearchTypes as $sSearchType=>$sSearchTable)
|
|
|
|
|
@@ -813,7 +814,7 @@ class Databap extends PhpObject
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Load doc into database
|
|
|
|
|
$asData = array('title'=>$sTitle, 'description'=>$sDescription, 'file_name'=>$sFileName, MySqlManager::getId(MySqlManager::USER_TABLE)=>$iUserId);
|
|
|
|
|
$asData = array('title'=>$sTitle, 'description'=>$sDescription, MySqlManager::getId(MySqlManager::USER_TABLE)=>$iUserId);
|
|
|
|
|
$iDbDocId = $this->oMySql->insertRow(MySqlManager::DOC_TABLE, $asData);
|
|
|
|
|
|
|
|
|
|
//Load doc files into database
|
|
|
|
|
@@ -840,14 +841,7 @@ class Databap extends PhpObject
|
|
|
|
|
$this->oMySql->updateRow(MySqlManager::DOC_TABLE, $iDbDocId, array('refer_id'=>$iReferId));
|
|
|
|
|
|
|
|
|
|
//Add Message in chat
|
|
|
|
|
if($bCreation)
|
|
|
|
|
{
|
|
|
|
|
$this->addMessage($iDbDocId, self::MESSAGE_ADD_DOC, self::ALL_CHAN_ID);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$this->addMessage($iDbDocId, self::MESSAGE_EDIT_DOC, self::ALL_CHAN_ID);
|
|
|
|
|
}
|
|
|
|
|
$this->addMessage($iDbDocId, $bCreation?self::MESSAGE_ADD_DOC:self::MESSAGE_EDIT_DOC, self::ALL_CHAN_ID);
|
|
|
|
|
|
|
|
|
|
//Add record in Search Table
|
|
|
|
|
$this->oSearchEngine->buildIndex($iDbDocId, self::DOC_TYPE);
|
|
|
|
|
@@ -869,7 +863,7 @@ class Databap extends PhpObject
|
|
|
|
|
$asFiles = $this->oMySql->selectRows(array('from'=>MySqlManager::FILE_TABLE, 'constraint'=>array('id_doc'=>$iDocId)));
|
|
|
|
|
foreach($asFiles as $asFile)
|
|
|
|
|
{
|
|
|
|
|
$asDoc['files'][$asFile[MySqlManager::getId(MySqlManager::FILE_TABLE)]] = array('description'=>$asFile['description']);
|
|
|
|
|
$asDoc['files'][$asFile[MySqlManager::getId(MySqlManager::FILE_TABLE)]] = array('description'=>$asFile['description'], 'ext'=>pathinfo($asFile['file_name'], PATHINFO_EXTENSION));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self::jsonExport($asDoc);
|
|
|
|
|
@@ -967,25 +961,39 @@ class Databap extends PhpObject
|
|
|
|
|
$asCode = $this->oMySql->selectRow(MySqlManager::CODE_TABLE, $iCodeId, $asSelect);
|
|
|
|
|
$asCode['description'] = self::getDescriptionFormat($asCode['description']);
|
|
|
|
|
$asCode['led'] = self::getDateFormat($asCode['led']);
|
|
|
|
|
$asCode['timestamp'] = strtotime($asCode['led']);
|
|
|
|
|
return $asCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getProcInfo($iProcId)
|
|
|
|
|
{
|
|
|
|
|
$asProc = $this->oMySql->selectRow(MySqlManager::PROC_TABLE, $iProcId);
|
|
|
|
|
$asProc['title'] = self::getDescriptionFormat($asProc['title']);
|
|
|
|
|
$asProc['description'] = self::getDescriptionFormat($asProc['description']);
|
|
|
|
|
$asProc['led'] = self::getDateFormat($asProc['led']);
|
|
|
|
|
$asProc['timestamp'] = strtotime($asCode['led']);
|
|
|
|
|
return $asProc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getDocInfo($iDocId)
|
|
|
|
|
{
|
|
|
|
|
$asDoc = $this->oMySql->selectRow(MySqlManager::DOC_TABLE, $iDocId);
|
|
|
|
|
$asDoc['title'] = self::getDescriptionFormat($asDoc['title']);
|
|
|
|
|
$asDoc['description'] = self::getDescriptionFormat($asDoc['description']);
|
|
|
|
|
$asDoc['led'] = self::getDateFormat($asDoc['led']);
|
|
|
|
|
$asDoc['timestamp'] = strtotime($asCode['led']);
|
|
|
|
|
return $asDoc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getArticleInfo($iArtId)
|
|
|
|
|
{
|
|
|
|
|
$asArt = $this->oMySql->selectRow(MySqlManager::ART_TABLE, $iArtId);
|
|
|
|
|
$asTransferredInfo = array('link_art'=>$asArt['link'], 'title'=>$asArt['title'], 'link_auth'=>$asArt['email']);
|
|
|
|
|
$asTransferredInfo['date'] = self::getDateFormat($asArt['date'], self::DATE_FORMAT);
|
|
|
|
|
$asTransferredInfo = array('link_art'=>$asArt['link'], 'art_title'=>$asArt['title'], 'link_auth'=>$asArt['email']);
|
|
|
|
|
$asTransferredInfo['art_date'] = self::getDateFormat($asArt['date'], self::DATE_FORMAT);
|
|
|
|
|
$asTransferredInfo['name'] = self::getNameFormat($asArt['first_name'], $asArt['last_name']);
|
|
|
|
|
$asTransferredInfo['description'] = self::getDescriptionFormat($asArt['title']);
|
|
|
|
|
$asTransferredInfo['led'] = self::getDateFormat($asArt['led']);
|
|
|
|
|
$asTransferredInfo['timestamp'] = strtotime($asCode['led']);
|
|
|
|
|
$asTransferredInfo['company'] = 'SAP';
|
|
|
|
|
return $asTransferredInfo;
|
|
|
|
|
}
|
|
|
|
|
@@ -1688,12 +1696,17 @@ class Databap extends PhpObject
|
|
|
|
|
elseif($sMessageType==self::MESSAGE_ADD_PROC || $sMessageType==self::MESSAGE_EDIT_PROC)
|
|
|
|
|
{
|
|
|
|
|
$asProc = $this->getProcInfo($asMessages['messages'][$iMessageId]['message']);
|
|
|
|
|
$asMessages['messages'][$iMessageId]['description'] = $asProc['description'];
|
|
|
|
|
$asMessages['messages'][$iMessageId]['description'] = $asProc['title'];
|
|
|
|
|
}
|
|
|
|
|
elseif($sMessageType==self::MESSAGE_ADD_DOC || $sMessageType==self::MESSAGE_EDIT_DOC)
|
|
|
|
|
{
|
|
|
|
|
$asDoc = $this->getDocInfo($asMessages['messages'][$iMessageId]['message']);
|
|
|
|
|
$asMessages['messages'][$iMessageId]['description'] = $asDoc['title'];
|
|
|
|
|
}
|
|
|
|
|
elseif($sMessageType==self::MESSAGE_ARTICLE)
|
|
|
|
|
{
|
|
|
|
|
$asTransferredInfo = $this->getArticleInfo($asMessages['messages'][$iMessageId]['message']);
|
|
|
|
|
$asMessages['messages'][$iMessageId]['message'] = $this->getJsonMessage($asTransferredInfo);
|
|
|
|
|
$asMessages['messages'][$iMessageId] = array_merge($asMessages['messages'][$iMessageId], $asTransferredInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Switch Chan ID with name for the user to join
|
|
|
|
|
@@ -1959,71 +1972,63 @@ class Databap extends PhpObject
|
|
|
|
|
$sIdCodeCol = MySqlManager::getId(MySqlManager::CODE_TABLE);
|
|
|
|
|
$sIdProcCol = MySqlManager::getId(MySqlManager::PROC_TABLE);
|
|
|
|
|
$sIdArtCol = MySqlManager::getId(MySqlManager::ART_TABLE);
|
|
|
|
|
$sIdDocCol = MySqlManager::getId(MySqlManager::DOC_TABLE);
|
|
|
|
|
$sIdCodeColFull = MySqlManager::getId(MySqlManager::CODE_TABLE, true);
|
|
|
|
|
$sIdUserCol = MySqlManager::getId(MySqlManager::USER_TABLE);
|
|
|
|
|
$sIdUserColFull = MySqlManager::getId(MySqlManager::USER_TABLE, true);
|
|
|
|
|
$sLedColFull = MySqlManager::getFullColumnName(MySqlManager::CODE_TABLE, 'led') ;
|
|
|
|
|
|
|
|
|
|
//Get code Ids
|
|
|
|
|
$asInfo = array('select'=>array("MAX($sIdCodeCol) AS id_item"),
|
|
|
|
|
$asInfo = array('select'=>array("MAX($sIdCodeCol) AS id_item"), //selecting last version among codes having the same refer_id
|
|
|
|
|
'from'=>MySqlManager::CODE_TABLE,
|
|
|
|
|
'groupBy'=>array('refer_id'),
|
|
|
|
|
'orderBy'=>array('id_item'=>'desc'));
|
|
|
|
|
$asCodeIds = $this->oMySql->selectRows($asInfo);
|
|
|
|
|
$asItemIds[Databap::CODE_TYPE] = $this->oMySql->selectRows($asInfo);
|
|
|
|
|
|
|
|
|
|
//get Proc Ids
|
|
|
|
|
$asInfo = array('select'=>array("MAX($sIdProcCol) AS id_item"),
|
|
|
|
|
'from'=>MySqlManager::PROC_TABLE,
|
|
|
|
|
'constraint'=>array('refer_id'=>"0"),
|
|
|
|
|
'constraint'=>array('refer_id'=>"0"), //meaning that there is no newer version
|
|
|
|
|
'orderBy'=>array('id_item'=>'desc'));
|
|
|
|
|
$asProcIds = $this->oMySql->selectRows($asInfo);
|
|
|
|
|
$asItemIds[Databap::PROC_TYPE] = $this->oMySql->selectRows($asInfo);
|
|
|
|
|
|
|
|
|
|
//get Article Ids
|
|
|
|
|
$asInfo = array('select'=>array($sIdArtCol." AS id_item"),
|
|
|
|
|
'from'=>MySqlManager::ART_TABLE,
|
|
|
|
|
'orderBy'=>array('id_item'=>'desc'));
|
|
|
|
|
$asArtIds = $this->oMySql->selectRows($asInfo);
|
|
|
|
|
$asItemIds[Databap::ART_TYPE] = $this->oMySql->selectRows($asInfo);
|
|
|
|
|
|
|
|
|
|
$asItemIds = array(Databap::CODE_TYPE=>$asCodeIds, Databap::PROC_TYPE=>$asProcIds, Databap::ART_TYPE=>$asArtIds);
|
|
|
|
|
//Get documentation
|
|
|
|
|
$asInfo = array('select'=>array("MAX($sIdDocCol) AS id_item"), //selecting last version among docs having the same refer_id
|
|
|
|
|
'from'=>MySqlManager::DOC_TABLE,
|
|
|
|
|
'groupBy'=>array('refer_id'),
|
|
|
|
|
'orderBy'=>array('id_item'=>'desc'));
|
|
|
|
|
$asItemIds[Databap::DOC_TYPE] = $this->oMySql->selectRows($asInfo);
|
|
|
|
|
|
|
|
|
|
$asTypeFunc = array(Databap::CODE_TYPE=>'Code', Databap::PROC_TYPE=>'Proc', Databap::ART_TYPE=>'Article', Databap::DOC_TYPE=>'Doc');
|
|
|
|
|
|
|
|
|
|
//Build code info structure
|
|
|
|
|
//TODO phrases for all item types?
|
|
|
|
|
$asUsers = $asCode = $asItemList = array();
|
|
|
|
|
foreach($asItemIds as $sType=>$asTypedItemIds)
|
|
|
|
|
{
|
|
|
|
|
switch($sType)
|
|
|
|
|
{
|
|
|
|
|
case Databap::CODE_TYPE:
|
|
|
|
|
$sFuncType = 'Code';
|
|
|
|
|
break;
|
|
|
|
|
case Databap::PROC_TYPE:
|
|
|
|
|
$sFuncType = 'Proc';
|
|
|
|
|
break;
|
|
|
|
|
case Databap::ART_TYPE:
|
|
|
|
|
$sFuncType = 'Article';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$asTypedItemIds = array_filter($asTypedItemIds); //null value returned from query (MAX(...))
|
|
|
|
|
foreach($asTypedItemIds as $iItemId)
|
|
|
|
|
{
|
|
|
|
|
//null value returned from query (MAX(...))
|
|
|
|
|
if($iItemId>0)
|
|
|
|
|
{
|
|
|
|
|
$asItem = call_user_func(array($this, 'get'.$sFuncType.'Info'), $iItemId);
|
|
|
|
|
if(array_key_exists($sIdUserCol, $asItem))
|
|
|
|
|
$asItem = call_user_func(array($this, 'get'.$asTypeFunc[$sType].'Info'), $iItemId);
|
|
|
|
|
$asItem['type'] = $sType;
|
|
|
|
|
$asItem['id_item'] = $iItemId;
|
|
|
|
|
if(array_key_exists($sIdUserCol, $asItem)) //replacing user's id with user's name & company (if not done already)
|
|
|
|
|
{
|
|
|
|
|
$iUserId = $asItem[$sIdUserCol];
|
|
|
|
|
if(!array_key_exists($iUserId, $asUsers))
|
|
|
|
|
{
|
|
|
|
|
$asUsers[$iUserId] = $this->getUserInfo($iUserId);
|
|
|
|
|
}
|
|
|
|
|
$asItemList[$sType][$iItemId] = array_merge($asUsers[$iUserId], $asItem);
|
|
|
|
|
}
|
|
|
|
|
else $asItemList[$sType][$iItemId] = $asItem;
|
|
|
|
|
|
|
|
|
|
//$asCodeList[$iItemId]['phrase'] = $this->getPhraseFromIdCode($iCodeId);
|
|
|
|
|
|
|
|
|
|
if(!array_key_exists($iUserId, $asUsers)) $asUsers[$iUserId] = $this->getUserInfo($iUserId);
|
|
|
|
|
$asItem['name'] = $asUsers[$iUserId]['name'];
|
|
|
|
|
$asItem['company'] = $asUsers[$iUserId]['company'];
|
|
|
|
|
}
|
|
|
|
|
$asItemList[$asItem['timestamp'].$asItem['type'].$asItem['id_item']] = $asItem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
krsort($asItemList);
|
|
|
|
|
return $this->jsonExport($asItemList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -2614,6 +2619,18 @@ class Procedure extends PhpObject
|
|
|
|
|
id_code
|
|
|
|
|
line
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Search Engine : Search through all types of databap documents
|
|
|
|
|
*
|
|
|
|
|
* Procedure to add a new type in the search
|
|
|
|
|
* - Add type in the index builder : SearchEngine->buildIndex()
|
|
|
|
|
* - Add type in the rebuild index function : Databap->buildCompleteIndex()
|
|
|
|
|
* - Add type in item info : SearchEngine->setItemInfo()
|
|
|
|
|
* - Add type in .htaccess
|
|
|
|
|
* - Add type in getItemList() and create a get<type>info()
|
|
|
|
|
* - consider the message types : add + edit in Databap->getMessages() and in chat.html
|
|
|
|
|
*/
|
|
|
|
|
class SearchEngine extends PhpObject
|
|
|
|
|
{
|
|
|
|
|
//Objects
|
|
|
|
|
@@ -2643,32 +2660,35 @@ class SearchEngine extends PhpObject
|
|
|
|
|
public function buildIndex($iItemId, $sType)
|
|
|
|
|
{
|
|
|
|
|
//Build keywords
|
|
|
|
|
$sWords = '';
|
|
|
|
|
switch($sType)
|
|
|
|
|
{
|
|
|
|
|
case Databap::CODE_TYPE:
|
|
|
|
|
$asItemData = $this->oMySql->selectRow(MySqlManager::CODE_TABLE, $iItemId);
|
|
|
|
|
$sWords = $asItemData[MySqlManager::getText(MySqlManager::CODE_TABLE)].self::KEYWORDS_SEPARATOR.$asItemData['description'];
|
|
|
|
|
$asWords = array($asItemData[MySqlManager::getText(MySqlManager::CODE_TABLE)], $asItemData['description']);
|
|
|
|
|
break;
|
|
|
|
|
case Databap::PROC_TYPE:
|
|
|
|
|
$sItemIdCol = MySqlManager::getId(MySqlManager::PROC_TABLE);
|
|
|
|
|
$asItemData = $this->oMySql->selectRow(MySqlManager::PROC_TABLE, $iItemId);
|
|
|
|
|
$asItemStepsData = $this->oMySql->selectRows(array('select'=>'description', 'from'=>MySqlManager::STEP_TABLE, 'constraint'=>array('id_procedure'=>$iItemId)));
|
|
|
|
|
$sWords = $asItemData['description'].self::KEYWORDS_SEPARATOR.
|
|
|
|
|
$asItemData['title'].self::KEYWORDS_SEPARATOR.
|
|
|
|
|
implode(self::KEYWORDS_SEPARATOR, $asItemStepsData);
|
|
|
|
|
$asItemStepsData = $this->oMySql->selectRows(array('select'=>'description', 'from'=>MySqlManager::STEP_TABLE, 'constraint'=>array($sItemIdCol=>$iItemId)));
|
|
|
|
|
$asWords = array('desc'=>$asItemData['description'], 'title'=>$asItemData['title']) + $asItemStepsData;
|
|
|
|
|
break;
|
|
|
|
|
case Databap::ART_TYPE:
|
|
|
|
|
$asItemData = $this->oMySql->selectRow(MySqlManager::ART_TABLE, $iItemId);
|
|
|
|
|
$sWords = $asItemData['first_name'].self::KEYWORDS_SEPARATOR.
|
|
|
|
|
$asItemData['last_name'].self::KEYWORDS_SEPARATOR.
|
|
|
|
|
$asItemData['title'];
|
|
|
|
|
$asWords = array($asItemData['first_name'], $asItemData['last_name'], $asItemData['title']);
|
|
|
|
|
break;
|
|
|
|
|
case Databap::DOC_TYPE:
|
|
|
|
|
$sItemIdCol = MySqlManager::getId(MySqlManager::DOC_TABLE);
|
|
|
|
|
$asItemData = $this->oMySql->selectRow(MySqlManager::DOC_TABLE, $iItemId);
|
|
|
|
|
$asItemFilesData = $this->oMySql->selectRows(array('select'=>'description', 'from'=>MySqlManager::FILE_TABLE, 'constraint'=>array($sItemIdCol=>$iItemId)));
|
|
|
|
|
$asWords = array('desc'=>$asItemData['description'], 'title'=>$asItemData['title']) + $asItemFilesData;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$this->addError('function'.__FUNCTION__.'(): Incorrect type "'.$sType.'"');
|
|
|
|
|
$this->addError('function '.__FUNCTION__.'(): Incorrect type "'.$sType.'"');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$sWords = implode(self::KEYWORDS_SEPARATOR, $asWords);
|
|
|
|
|
$sWords = strtolower(str_replace("\n", self::KEYWORDS_SEPARATOR, $sWords));
|
|
|
|
|
$sWords = preg_replace('/(\W+)/', self::KEYWORDS_SEPARATOR, $sWords);
|
|
|
|
|
$sWords = preg_replace('/(\W+)/', self::KEYWORDS_SEPARATOR, $sWords); //remove all non-word characters
|
|
|
|
|
|
|
|
|
|
//Add / Modify search database
|
|
|
|
|
$asData = array('id_item'=>$iItemId, 'type'=>$sType, 'refer_id'=>$asItemData['refer_id'], 'keywords'=>$sWords);
|
|
|
|
|
@@ -2682,6 +2702,12 @@ class SearchEngine extends PhpObject
|
|
|
|
|
$this->setResults();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TODO Customized item preview
|
|
|
|
|
$sCodeLines = implode("\n...\n", $this->getCodeInfo($iItemId, 'code'));
|
|
|
|
|
$oCode = new Reader($sCodeLines);
|
|
|
|
|
$sCodeLines = $oCode->getColoredCode();
|
|
|
|
|
*/
|
|
|
|
|
private function setItemInfo($iSearchId, $iItemType, $iItemId)
|
|
|
|
|
{
|
|
|
|
|
if(!array_key_exists($iSearchId, $this->asItemInfos))
|
|
|
|
|
@@ -2690,43 +2716,60 @@ class SearchEngine extends PhpObject
|
|
|
|
|
switch($iItemType)
|
|
|
|
|
{
|
|
|
|
|
case Databap::CODE_TYPE:
|
|
|
|
|
$asItemInfo = $this->oMySql->selectRow
|
|
|
|
|
(
|
|
|
|
|
MySqlManager::CODE_TABLE,
|
|
|
|
|
$iItemId,
|
|
|
|
|
array(MySqlManager::getId(MySqlManager::USER_TABLE), 'description', 'led')
|
|
|
|
|
);
|
|
|
|
|
$sItemTable = MySqlManager::CODE_TABLE;
|
|
|
|
|
$asItemFields = 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')
|
|
|
|
|
);
|
|
|
|
|
$sItemTable = MySqlManager::PROC_TABLE;
|
|
|
|
|
$asItemFields = 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;
|
|
|
|
|
$sItemTable = MySqlManager::ART_TABLE;
|
|
|
|
|
$asItemFields = array('first_name', 'last_name', 'title AS description', 'led');
|
|
|
|
|
break;
|
|
|
|
|
case Databap::DOC_TYPE:
|
|
|
|
|
$sItemTable = MySqlManager::DOC_TABLE;
|
|
|
|
|
$asItemFields = array(MySqlManager::getId(MySqlManager::USER_TABLE), 'title AS description', 'led');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$this->asItemInfos[$iSearchId] += $asItemInfo;
|
|
|
|
|
$this->asItemInfos[$iSearchId] += $this->oMySql->selectRow($sItemTable, $iItemId, $asItemFields);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getItemInfo($iSearchId, $sInfoName)
|
|
|
|
|
{
|
|
|
|
|
return array_key_exists($iSearchId, $this->asItemInfos)?$this->asItemInfos[$iSearchId][$sInfoName]:false;
|
|
|
|
|
if(array_key_exists($iSearchId, $this->asItemInfos) && array_key_exists($sInfoName, $this->asItemInfos[$iSearchId]))
|
|
|
|
|
return $this->asItemInfos[$iSearchId][$sInfoName];
|
|
|
|
|
else return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function setUserInfo($iUserId)
|
|
|
|
|
{
|
|
|
|
|
if(!array_key_exists($iUserId, $this->asUserInfos) && $iUserId > 0)
|
|
|
|
|
{
|
|
|
|
|
$sCompanyIdCol = MySqlManager::getId(MySqlManager::COMP_TABLE);
|
|
|
|
|
$this->asUserInfos[$iUserId] = $this->oMySql->selectRow
|
|
|
|
|
(
|
|
|
|
|
MySqlManager::USER_TABLE,
|
|
|
|
|
$iUserId,
|
|
|
|
|
array('first_name', 'last_name', $sCompanyIdCol)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->asUserInfos[$iUserId]['company'] = $this->oMySql->selectValue(MySqlManager::COMP_TABLE, MySqlManager::getText(MySqlManager::COMP_TABLE), $this->asUserInfos[$iUserId][$sCompanyIdCol]);
|
|
|
|
|
unset($this->asUserInfos[$iUserId][$sCompanyIdCol]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getUserInfo($iUserId, $sInfoName)
|
|
|
|
|
{
|
|
|
|
|
if(array_key_exists($iUserId, $this->asUserInfos) && array_key_exists($sInfoName, $this->asUserInfos[$iUserId]))
|
|
|
|
|
return $this->asUserInfos[$iUserId][$sInfoName];
|
|
|
|
|
else return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function setResults()
|
|
|
|
|
{
|
|
|
|
|
if($this->iLevelMax>0)
|
|
|
|
|
if($this->iLevelMax > 0)
|
|
|
|
|
{
|
|
|
|
|
//set Results and Ranking
|
|
|
|
|
$aiLevels = range(1, $this->iLevelMax);
|
|
|
|
|
@@ -2745,7 +2788,7 @@ class SearchEngine extends PhpObject
|
|
|
|
|
$sRegExp = implode(self::KEYWORDS_SEPARATOR.'?', $asSequence);
|
|
|
|
|
|
|
|
|
|
//TODO replace with selectRow()
|
|
|
|
|
$sQuery = "SELECT id_search, id_item, type FROM searchs WHERE keywords REGEXP '{$sRegExp}'";
|
|
|
|
|
$sQuery = "SELECT id_search, id_item, type/*, keywords*/ FROM searchs WHERE keywords REGEXP '{$sRegExp}'";
|
|
|
|
|
|
|
|
|
|
//search sequence
|
|
|
|
|
$asItems = $this->oMySql->getArrayQuery($sQuery, true);
|
|
|
|
|
@@ -2754,6 +2797,10 @@ class SearchEngine extends PhpObject
|
|
|
|
|
$iSearchId = $asItem['id_search'];
|
|
|
|
|
$iItemId = $asItem['id_item'];;
|
|
|
|
|
$iItemType = $asItem['type'];
|
|
|
|
|
//$sWords = self::KEYWORDS_SEPARATOR.$asItem['keywords'].self::KEYWORDS_SEPARATOR;
|
|
|
|
|
|
|
|
|
|
//Calculate hit value
|
|
|
|
|
//$iCount =
|
|
|
|
|
|
|
|
|
|
$this->incItemRank($iSearchId, $iLevel);
|
|
|
|
|
|
|
|
|
|
@@ -2774,20 +2821,13 @@ class SearchEngine extends PhpObject
|
|
|
|
|
arsort($this->asItemRanks);
|
|
|
|
|
foreach($this->asItemRanks as $iSearchId=>$iRank)
|
|
|
|
|
{
|
|
|
|
|
/* TODO Customized item preview
|
|
|
|
|
//code
|
|
|
|
|
$sCodeLines = implode("\n...\n", $this->getCodeInfo($iItemId, 'code'));
|
|
|
|
|
$oCode = new Reader($sCodeLines);
|
|
|
|
|
$sCodeLines = $oCode->getColoredCode();
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$iUserId = $this->getItemInfo($iSearchId, MySqlManager::getId(MySqlManager::USER_TABLE));
|
|
|
|
|
$sFirstName = $this->getUserInfo($iUserId, 'first_name')?$this->getUserInfo($iUserId, 'first_name'):$this->getItemInfo($iSearchId, 'first_name');
|
|
|
|
|
$sLastName = $this->getUserInfo($iUserId, 'last_name')?$this->getUserInfo($iUserId, 'last_name'):$this->getItemInfo($iSearchId, 'last_name');
|
|
|
|
|
$sCompany = $this->getUserInfo($iUserId, 'company')?$this->getUserInfo($iUserId, 'company'):'SAP';
|
|
|
|
|
$asResult[] = array('id_item'=>$this->getItemInfo($iSearchId, 'id_item'),
|
|
|
|
|
'type'=>$this->getItemInfo($iSearchId, 'type'),
|
|
|
|
|
'description'=>$this->getItemInfo($iSearchId, 'description'),
|
|
|
|
|
'description'=>/*'['.$iRank.'] '.*/$this->getItemInfo($iSearchId, 'description'),
|
|
|
|
|
'name'=>Databap::getNameFormat($sFirstName, $sLastName),
|
|
|
|
|
'company'=>Databap::getCompanyFormat($sCompany),
|
|
|
|
|
'led'=>Databap::getDateFormat($this->getItemInfo($iSearchId, 'led')));
|
|
|
|
|
@@ -2795,28 +2835,6 @@ class SearchEngine extends PhpObject
|
|
|
|
|
return $asResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getUserInfo($iUserId, $sInfoName)
|
|
|
|
|
{
|
|
|
|
|
return array_key_exists($iUserId, $this->asUserInfos)?$this->asUserInfos[$iUserId][$sInfoName]:false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function setUserInfo($iUserId)
|
|
|
|
|
{
|
|
|
|
|
if(!array_key_exists($iUserId, $this->asUserInfos) && $iUserId > 0)
|
|
|
|
|
{
|
|
|
|
|
$sCompanyIdCol = MySqlManager::getId(MySqlManager::COMP_TABLE);
|
|
|
|
|
$this->asUserInfos[$iUserId] = $this->oMySql->selectRow
|
|
|
|
|
(
|
|
|
|
|
MySqlManager::USER_TABLE,
|
|
|
|
|
$iUserId,
|
|
|
|
|
array('first_name', 'last_name', $sCompanyIdCol)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->asUserInfos[$iUserId]['company'] = $this->oMySql->selectValue(MySqlManager::COMP_TABLE, MySqlManager::getText(MySqlManager::COMP_TABLE), $this->asUserInfos[$iUserId][$sCompanyIdCol]);
|
|
|
|
|
unset($this->asUserInfos[$iUserId][$sCompanyIdCol]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function incItemRank($iSearchId, $iRank)
|
|
|
|
|
{
|
|
|
|
|
if(array_key_exists($iSearchId, $this->asItemRanks))
|
|
|
|
|
|