add link to tables in error messages

This commit is contained in:
2014-09-06 00:12:03 +02:00
parent ecc3471ebc
commit 3f63181ec3
4 changed files with 32 additions and 30 deletions

View File

@@ -950,11 +950,10 @@ class Databap extends PhpObject
//New table info //New table info
$sTitle = mb_strtolower($bCreation?trim($sTitle):$asPrevTableInfo['title']); $sTitle = mb_strtolower($bCreation?trim($sTitle):$asPrevTableInfo['title']);
$sDescription = mb_strtolower(trim($sDescription)); $sDescription = mb_strtolower(trim($sDescription));
$sRightTableLink = '<a href="'.$this->getInternalLink('table', $sTitle).'" target="_blank">table '.self::getTableFormat($sTitle).'</a>';
//Check for existing table with the same name //Check for existing table with the same name
if($bCreation && $this->checkValue(self::TABL_TABLE, array('title'=>$sTitle))) $sDesc = 'Une documentation existe déjà pour la '.$sRightTableLink; if($bCreation && $this->checkValue(self::TABL_TABLE, array('title'=>$sTitle))) $sDesc = ToolBox::findReplaceLinks('Une documentation existe déjà pour la table '.self::getTableFormat($sTitle));
elseif(!$bCreation && $iPrevTableId!=$this->getUpToDateId(self::TABL_TABLE, $sTitle)) $sDesc = 'Une version plus récente de cette documentation existe : '.$sRightTableLink; elseif(!$bCreation && $iPrevTableId!=$this->getUpToDateId(self::TABL_TABLE, $sTitle)) $sDesc = ToolBox::findReplaceLinks('Une version plus récente de la table '.self::getTableFormat($sTitle).' existe');
elseif(!$bSimul) elseif(!$bSimul)
{ {
//Load table into database //Load table into database
@@ -999,8 +998,8 @@ class Databap extends PhpObject
$asTable['company'] = $asUser['company']; $asTable['company'] = $asUser['company'];
//Out of date warning //Out of date warning
$sRightTableLink = '<a href="'.$this->getInternalLink('table', $asTable['title']).'" target="_blank">table '.self::getTableFormat($asTable['title']).'</a>'; $sRightTableLink = ToolBox::findReplaceLinks('Il existe une documentation plus à jour pour la table '.self::getTableFormat($asTable['title']));
$asTable['warning'] = ($bReadById && $iTableId!=$this->getUpToDateId(self::TABL_TABLE, $iTableId))?'Il existe une documentation plus à jour pour la '.$sRightTableLink:''; $asTable['warning'] = ($bReadById && $iTableId!=$this->getUpToDateId(self::TABL_TABLE, $iTableId))?$sRightTableLink:'';
} }
else $sDesc = self::NOT_FOUND; else $sDesc = self::NOT_FOUND;
@@ -1151,14 +1150,17 @@ class Databap extends PhpObject
private function getTableInfo($iTableId, $bFormatting=true) private function getTableInfo($iTableId, $bFormatting=true)
{ {
$asTable = $this->oMySql->selectRow(self::TABL_TABLE, $iTableId); $asTable = $this->oMySql->selectRow(self::TABL_TABLE, $iTableId);
$asTable['timestamp'] = strtotime($asTable['led']); if(!empty($asTable))
if($bFormatting)
{ {
$asTable['system'] = self::getTableFormat($asTable['system']); $asTable['timestamp'] = strtotime($asTable['led']);
$asTable['title'] = self::getTableFormat($asTable['title']); if($bFormatting)
$asTable['description'] = self::getDescriptionFormat($asTable['description']); {
$asTable['led'] = self::getDateFormat($asTable['led']); $asTable['system'] = self::getTableFormat($asTable['system']);
$asTable['formatted_keywords'] = str_replace("\n", '<br />', ToolBox::findReplaceLinks($asTable['keywords'])); $asTable['title'] = self::getTableFormat($asTable['title']);
$asTable['description'] = self::getDescriptionFormat($asTable['description']);
$asTable['led'] = self::getDateFormat($asTable['led']);
$asTable['formatted_keywords'] = str_replace("\n", '<br />', ToolBox::findReplaceLinks($asTable['keywords']));
}
} }
return $asTable; return $asTable;
} }

View File

@@ -276,8 +276,8 @@ class ToolBox
//Phase 3: Rebuild link //Phase 3: Rebuild link
$asPatterns = array(); $asPatterns = array();
$sPreChar = '(^|\ |\*|\')'; $sPreChar = '(^|\ |\*|\'|\()';
$sPostChar = '(\ |\.|\:|$)'; $sPostChar = '(\ |\.|\:|\)|$)';
foreach($asReplacements as $sHash=>$sPage) foreach($asReplacements as $sHash=>$sPage)
{ {
if(mb_strlen($sHash)>1) if(mb_strlen($sHash)>1)
@@ -288,7 +288,7 @@ class ToolBox
$asPatterns['`'.$sPreChar.$sHash.'\ ([\d]+)'.$sPostChar.'`mui'] = '$1<a href="#'.$sPage.'-$2" target="_blank" class="internal_link round"><i class="fa fa-inline fa-c-'.$sPage.'"></i><span class="type">'.$sTitle.'</span> n°<span class="item">$2</span></a>$3'; $asPatterns['`'.$sPreChar.$sHash.'\ ([\d]+)'.$sPostChar.'`mui'] = '$1<a href="#'.$sPage.'-$2" target="_blank" class="internal_link round"><i class="fa fa-inline fa-c-'.$sPage.'"></i><span class="type">'.$sTitle.'</span> n°<span class="item">$2</span></a>$3';
//Type + phrase //Type + phrase
if($sPage=='table') $asPatterns['`'.$sPreChar.'(?i)'.$sHash.'(?-i)\ ([_A-Z0-9]+)'.$sPostChar.'`mu'] = '$1<a href="#'.$sPage.'-$2" target="_blank" class="internal_link round"><i class="fa fa-inline fa-c-'.$sPage.'"></i><span class="type">'.$sTitle.'</span> <span class="item">$2</span></a>$3'; if($sPage=='table') $asPatterns['`'.$sPreChar.'(?i)'.$sHash.'(?-i)\ ([_A-Z0-9\*\/]+)'.$sPostChar.'`mu'] = '$1<a href="#'.$sPage.'-$2" target="_blank" class="internal_link round"><i class="fa fa-inline fa-c-'.$sPage.'"></i><span class="type">'.$sTitle.'</span> <span class="item">$2</span></a>$3';
} }
} }
$sText = preg_replace(array_keys($asPatterns), array_values($asPatterns), $sText); $sText = preg_replace(array_keys($asPatterns), array_values($asPatterns), $sText);

4
jquery/databap.js vendored
View File

@@ -840,14 +840,14 @@ function Databap()
this.addMsgBefore = function(msg, msgClass, elem) this.addMsgBefore = function(msg, msgClass, elem)
{ {
var $msg = $('<p>', {'class':msgClass}).append($('<i>', {'class':'fa fa-inline'})).append(msg); var $msg = $('<p>', {'class':msgClass}).append($('<i>', {'class':'fa fa-inline fa-c-'+msgClass})).append(msg);
$msg.hide().insertBefore(elem).slideDown('fast', function(){databap.updateScrollBar('bottom');}).delay(5000).slideUp('fast', function(){$(this).remove();databap.updateScrollBar();}); $msg.hide().insertBefore(elem).slideDown('fast', function(){databap.updateScrollBar('bottom');}).delay(5000).slideUp('fast', function(){$(this).remove();databap.updateScrollBar();});
}; };
this.feedback = function(sClass, sMsg) this.feedback = function(sClass, sMsg)
{ {
$('<span>', {'class':'feedback '+sClass}) $('<span>', {'class':'feedback '+sClass})
.append($('<i>', {'class':'fa fa-inline'})) .append($('<i>', {'class':'fa fa-inline fa-c-'+sClass}))
.append(self.addPunctuation(sMsg)) .append(self.addPunctuation(sMsg))
.appendTo('#title_feedback') .appendTo('#title_feedback')
.slideDown('fast') .slideDown('fast')

View File

@@ -652,20 +652,31 @@ vertical-align 0% -5% -10% -15% -20% -25% -30%
content: "\f191"; content: "\f191";
} }
.fa-c-success:before, .fa-c-ok:before, .available .fa:before {
content: "\f00c";
}
.fa-c-warning { .fa-c-warning {
color:#EFAB00; color:#EFAB00;
} }
.fa-c-warning:before, .warning .fa:before { .fa-c-warning:before {
content: "\f071"; content: "\f071";
} }
.fa-c-error { .fa-c-error {
color:red; color:red;
} }
.fa-c-error:before, .error .fa:before { .fa-c-error:before {
content: "\f071"; content: "\f071";
} }
.fa-c-ko {
color:red;
}
.fa-c-ko:before, .unavailable .fa:before {
content: "\f00d";
}
.fa-c-search:before { .fa-c-search:before {
content: "\f002"; content: "\f002";
} }
@@ -674,17 +685,6 @@ vertical-align 0% -5% -10% -15% -20% -25% -30%
content: /*"\f087"*/"\f015"; content: /*"\f087"*/"\f015";
} }
.fa-c-ok:before, .available .fa:before, .success .fa:before {
content: "\f00c";
}
.fa-c-ko {
color:red;
}
.fa-c-ko:before, .unavailable .fa:before {
content: "\f00d";
}
.fa-c-loading:before { .fa-c-loading:before {
content: "\f110"; content: "\f110";
} }