internal links in procedure

This commit is contained in:
2014-09-07 21:08:09 +02:00
parent f3bd550c28
commit 89d3443ebb
6 changed files with 2649 additions and 2656 deletions

View File

@@ -1159,7 +1159,7 @@ class Databap extends PhpObject
$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']));
$asTable['formated_keywords'] = ToolBox::formatText($asTable['keywords']);
}
}
return $asTable;
@@ -2621,7 +2621,7 @@ class Databap extends PhpObject
public static function getDescriptionFormat($sDescription)
{
return ToolBox::mb_ucfirst($sDescription);
return ToolBox::mb_ucfirst(ToolBox::findReplaceLinks($sDescription));
}
public static function getTableFormat($sTable)

View File

@@ -229,27 +229,18 @@ class Procedure extends PhpObject
public function getProcedure()
{
// [id_step]=>text
// [id_step][id_image]=>array('name'=>file name, 'desc'=> description)
/*
$asSteps = $asImages = array();
$iLocalStepId = 1;
foreach($this->asSteps as $iStepId=>$sStepDesc)
foreach($this->asSteps as $iStepId=>$asStep)
{
$asSteps[$iLocalStepId] = $sStepDesc;
if(array_key_exists($iStepId, $this->asImages))
{
$asImages[] =
$this->asSteps[$iStepId]['formated_description'] = ToolBox::formatText($asStep['description']);
}
$iLocalStepId++;
}*/
return array( 'proc_id'=>$this->iProcId,
'id_user'=>$this->iUserId,
'title'=>Databap::getDescriptionFormat($this->sTitle),
'description'=>Databap::getDescriptionFormat($this->sDescription),
'led'=>Databap::getDateFormat($this->dLed),
'steps'=>$this->asSteps,
'images'=>$this->asImages);
'id_user'=>$this->iUserId,
'title'=>Databap::getDescriptionFormat($this->sTitle),
'description'=>Databap::getDescriptionFormat($this->sDescription),
'led'=>Databap::getDateFormat($this->dLed),
'steps'=>$this->asSteps,
'images'=>$this->asImages);
}
private function refreshProcId()

View File

@@ -265,6 +265,11 @@ class ToolBox
setcookie($sCookieName, $sCookieValue, $iTimeLimit);
}
public static function formatText($sText)
{
return str_replace("\n", '<br />', self::findReplaceLinks($sText));
}
//TODO implement link pattern
public static function findReplaceLinks($sText, $sLinkPattern='')
{

View File

@@ -21,9 +21,9 @@
</div>
</div>
<div id="titles_read" class="step_box round hide">
<p class="read_title"><span id="titles_read_title"></span></p>
<p class="read_title"><span id="title_read" class="read"></span></p>
<p class="read_details">Cr&eacute;&eacute; par <span id="titles_read_user"></span> (<span id="titles_read_company"></span>) le <span id="titles_read_led"></span></p>
<p class="read_description"><span id="titles_read_description"></span></p>
<p class="read_description"><span id="description_read" class="read"></span></p>
</div>
<div id="procedure_steps"></div>
<div class="proc_menu" id="bottom_menu">
@@ -45,7 +45,10 @@
<td colspan="2" class="step_nb_box">&Eacute;tape <span id="step_nb"></span></td>
</tr>
<tr>
<td class="step_margin"><textarea id="step_text" name="step_text" class="round"></textarea></td>
<td class="step_margin">
<textarea id="step_text" name="step_text" class="round"></textarea>
<div id="step_text_read" class="read textarea round"></div>
</td>
<td class="image_box_container">
<div id="step_images"></div>
<div id="step_images_thumbs"></div>
@@ -148,18 +151,14 @@ function resizeDescription()
function setDisplay(sNewMode)
{
//On page first load
var sOldMode = databap.vars.mode;
if(!sOldMode || sOldMode=='')
{
sOldMode = (sNewMode=='read')?'edit':'read';
}
sNewMode = sNewMode || '';
//On page first load
if(sOldMode=='') sOldMode = (sNewMode=='read')?'edit':'read';
//default behaviour : switch to alternative display
if(!sNewMode)
{
sNewMode = (sOldMode=='read')?'edit':'read';
}
if(!sNewMode) sNewMode = (sOldMode=='read')?'edit':'read';
//Set new Display
if(sNewMode!=sOldMode)
@@ -167,14 +166,11 @@ function setDisplay(sNewMode)
var sDisabled;
//Set read mode data
if(sNewMode=='read')
{
syncReadModeData();
}
if(sNewMode=='read' && databap.vars.mode!='') syncReadModeData();
//Hide / show boxes
var $EditBoxes = databap.getMainElem('.uploader_box, .step_buttons, #add_step, #submit_procedure, #titles_edit');
var $ReadBoxes = databap.getMainElem('#share, #titles_read');
var $EditBoxes = databap.getMainElem('.uploader_box, .step_buttons, #add_step, #submit_procedure, #titles_edit, textarea[id$="step_text"]');
var $ReadBoxes = databap.getMainElem('#share, #titles_read, div[id$="step_text_read"]');
switch(sNewMode)
{
@@ -210,13 +206,14 @@ function setDisplay(sNewMode)
function syncReadModeData()
{
//Title & description
var $EditBox = databap.getMainElem('#titles_edit');
var $ReadBox = databap.getMainElem('#titles_read');
$ReadBox.find('#titles_read_title').text($EditBox.find('#title').val());
$ReadBox.find('#titles_read_description').text($EditBox.find('#description').val());
//Steps
$('.read').each(function()
{
$This = $(this);
var sEditValue = $('#'+$This.attr('id').substr(0, $This.attr('id').length - '_read'.length)).val();
var sReadValue = sEditValue.replace(/(?:\r\n|\r|\n)/g, '<br />');
$This.html(sReadValue);
});
databap.feedback('warning', 'Le formattage du texte reviendra lors de la validation');
}
function setThumbnails(bShow)
@@ -288,7 +285,7 @@ function getImageUrl(sImageName, bThumbnail)
return sImageUrl;
}
function addStep(stepId, sPosition, sDesc)
function addStep(stepId, sPosition, sDesc, sFormatedDesc)
{
//Set Step Count
iCurrentStep = '0';
@@ -298,6 +295,7 @@ function addStep(stepId, sPosition, sDesc)
//Add Step text
if(sDesc) $step.find('#step_text').val(sDesc);
if(sFormatedDesc) $step.find('#step_text_read').html(sFormatedDesc);
//Insert new step before this step
$step.find('#insert_step_before').click
@@ -449,7 +447,6 @@ function saveProcedure()
databap.addSuccessBefore('La proc&eacute;dure est enregistr&eacute;e', '#bottom_menu');
databap.addSuccessIcon();
//setDisplay('read');
//Unblock exit & go
databap.tmp('started', false);
@@ -507,7 +504,7 @@ function loadProcedure(iProcId, fOnSuccess)
proc_info.steps,
function(iStepId, sStepDesc)
{
iDisplayedStepId = addStep(false, false, sStepDesc.description);
iDisplayedStepId = addStep(false, false, sStepDesc.description, sStepDesc.formated_description);
//Image
if(iStepId in proc_info.images)
@@ -544,10 +541,15 @@ function loadProcedure(iProcId, fOnSuccess)
);
}
//TODO delete this silly function and rethink the whole thing
function addExtraReadElements(data)
{
debug(data);
//Add extra read-mode data
$ReadTitles = databap.getMainElem('#titles_read');
$ReadTitles.find('#title_read').text(data.title);
$ReadTitles.find('#description_read').text(data.description);
$ReadTitles.find('#titles_read_user').text(data.name);
$ReadTitles.find('#titles_read_company').text(data.company);
$ReadTitles.find('#titles_read_led').text(data.led);

View File

@@ -18,7 +18,7 @@
<div id="table_main" class="step_box form_success round">
<p class="step_box_title"><!-- <a href="http://fr.wikipedia.org/wiki/Le_Monde_de_monsieur_Fred" target="_blank"> --><span title="Helmut Perchut">&quot;J'ai explication !&quot;</span><!-- </a> --></p>
<textarea name="keywords" id="keywords" class="edit inc_border round"></textarea>
<p class="read" id="read_formatted_keywords"></p>
<p class="read" id="read_formated_keywords"></p>
</div>
<div id="validation" class="form_success"></div>
</form>

View File

@@ -356,28 +356,42 @@ a[href^="table"].internal_link span.item {
color:#04357B;
border: 2px solid #04357B;
}
.step_box:nth-child(even) {
background:#DCF2FB;
}
.step_box input, .step_box textarea, .step_box select {
.step_box input, .step_box textarea, .step_box select, .step_box .read.textarea, .step_box .read.input {
margin-top:10px;
background:white;
font-size:14px;
border-width:1px;
}
.step_box input:disabled, .step_box textarea:disabled, .step_box select:disabled, .step_box input:hover:disabled, .step_box textarea:hover:disabled, .step_box select:hover:disabled {
background-color:white;
}
.step_box input[type=text], .step_box textarea {
.step_box input[type=text], .step_box textarea, .step_box .read.textarea, .step_box .read.input {
width:100%;
}
.step_box textarea {
.step_box textarea, .step_box .read.textarea {
height:200px;
padding:5px;
background:white;
border:1px solid #04357B;
}
.step_box .read.textarea, .step_box .read.input {
border-color:#D9E5F2;
font-weight:bold;
}
.step_box .read.textarea {
background-color:#DCF2FB;
}
.step_box:nth-child(even) .read.textarea {
background-color:#D9E5F2;
}
.step_box .read.input {
background-color:#D9E5F2;
padding-left:0;
}
.step_box .step_nb_box, .step_box .step_box_title {
border-bottom:1px solid #04357B;
@@ -2263,10 +2277,6 @@ vertical-align 0% -5% -10% -15% -20% -25% -30%
width:100%;
}
#procedure table.step_box:nth-child(even) {
background:#DCF2FB;
}
#procedure table.step_box td {
text-align:left;
margin:0;
@@ -2313,21 +2323,6 @@ vertical-align 0% -5% -10% -15% -20% -25% -30%
/* Procedure - Read */
#procedure input:disabled, #procedure textarea:disabled {
border-color:#D9E5F2;
font-weight:bold;
}
#procedure textarea:disabled {
background-color:#DCF2FB;
}
#procedure table.step_box:nth-child(even) textarea:disabled {
background-color:#D9E5F2;
}
#procedure input:disabled {
background-color:#D9E5F2;
padding-left:0;
}
#procedure .thumbnail_box {
margin:10px 0;
height: 100px;
@@ -2416,7 +2411,7 @@ vertical-align 0% -5% -10% -15% -20% -25% -30%
font-style: italic;
}
#table #read_formatted_keywords {
#table #read_formated_keywords {
margin:10px 0 0 0;
font-size: 0.9em;
}