1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-06 06:07:31 +02:00

Version 1.4.0: Fix Markdown and custom fields

This commit is contained in:
trendschau
2020-10-31 07:47:40 +01:00
parent c9a59b84c1
commit 0ef48e831a
2 changed files with 36 additions and 22 deletions

View File

@@ -124,7 +124,7 @@ class MetaApiController extends ContentController
$metadata[$tabname][$fieldname] = isset($pagemeta[$tabname][$fieldname]) ? $pagemeta[$tabname][$fieldname] : null;
# special treatment for customfields
if(isset($fielddefinitions['type']) && ($fielddefinitions['type'] == 'customfields' ) )
if(isset($fielddefinitions['type']) && ($fielddefinitions['type'] == 'customfields' ) && isset($metadata[$tabname][$fieldname]) )
{
# loop through the customdata
foreach($metadata[$tabname][$fieldname] as $key => $value)
@@ -132,17 +132,10 @@ class MetaApiController extends ContentController
# and make sure that arrays are transformed back into strings
if(isset($value['value']) && is_array($value['value']))
{
$valuestring = implode('\n',$value['value']);
$metadata[$tabname][$fieldname][$key]['value'] = $valuestring;
$valuestring = implode(PHP_EOL . '- ', $value['value']);
$metadata[$tabname][$fieldname][$key]['value'] = '- ' . $valuestring;
}
}
/*
echo 'fielddefinition: <pre>';
print_r($fielddefinitions);
echo '</pre>metadata: <pre>';
print_r($pagemeta[$tabname][$fieldname]);
die();
*/
}
}
}
@@ -231,20 +224,22 @@ class MetaApiController extends ContentController
$errors[$tab][$fieldName] = $result[$fieldName][0];
}
# special treatment for customfields
# special treatment for customfields: if data is array, then lists wil transformed into array.
if($fieldDefinition && isset($fieldDefinition['type']) && ($fieldDefinition['type'] == 'customfields' ) && isset($fieldDefinition['data']) && ($fieldDefinition['data'] == 'array' ) )
{
foreach($fieldValue as $key => $valuePair)
{
if(isset($valuePair['value']))
{
$arrayValues = explode(PHP_EOL,$valuePair['value']);
echo '<pre>';
print_r($arrayValues);
$arrayValues = explode(PHP_EOL . '- ',$valuePair['value']);
if(count($arrayValues) > 1)
{
$arrayValues = array_map(function($item) { return trim($item, '- '); }, $arrayValues);
$metaInput[$fieldName][$key]['value'] = $arrayValues;
}
}
}
die();
}
}
}
}

View File

@@ -775,8 +775,15 @@ class ParsedownExtension extends \ParsedownExtra
if (isset($CurrentBlock['continuable']))
{
$methodName = 'block' . $CurrentBlock['type'] . 'Continue';
/* fix definition list */
if($CurrentBlock['type'] == 'DefinitionList' && isset($CurrentBlock['interrupted']))
{
$mdCurrentBlock = $mdCurrentBlock . "\n\n";
}
$Block = $this->$methodName($Line, $CurrentBlock);
# if this line still belongs to the current multiline block
if (isset($Block))
{
@@ -795,7 +802,7 @@ class ParsedownExtension extends \ParsedownExtra
/*new*/ $mdCurrentBlock = $mdCurrentBlock;
}
}
}
}
# ~
@@ -815,11 +822,19 @@ class ParsedownExtension extends \ParsedownExtra
#
# ~
foreach ($blockTypes as $blockType)
{
$Block = $this->{"block$blockType"}($Line, $CurrentBlock);
/*new*/ $mdBlock = $line;
/* new */ $mdBlock = $line;
/* dirty fix for tables and definition lists, not sure why this happens */
if ( ($blockType == "Table" OR $blockType == "DefinitionList") && isset($mdCurrentBlock) )
{
$mdBlock = $mdCurrentBlock . "\n" . $line;
}
/* fix end */
if (isset($Block))
{
$Block['type'] = $blockType;
@@ -841,6 +856,7 @@ class ParsedownExtension extends \ParsedownExtra
$CurrentBlock = $Block;
/*new*/ $mdCurrentBlock = $mdBlock;
continue 2;
}
}
@@ -885,14 +901,17 @@ class ParsedownExtension extends \ParsedownExtra
# ~
if (isset($CurrentBlock))
{
{
$Elements[] = $this->extractElement($CurrentBlock);
/*new*/ $mdElements[] = $mdCurrentBlock;
}
# ~
/* echo '<pre>';
print_r($mdElements);
die();
/*new*/ return $mdElements;
# return $Elements;
# return $Elements;
}