diff --git a/system/Controllers/MetaApiController.php b/system/Controllers/MetaApiController.php index 520bbd8..27ce7fc 100644 --- a/system/Controllers/MetaApiController.php +++ b/system/Controllers/MetaApiController.php @@ -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:
'; - print_r($fielddefinitions); - echo 'metadata:
'; - 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 ''; - 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(); - } + } } } diff --git a/system/Extensions/ParsedownExtension.php b/system/Extensions/ParsedownExtension.php index 65a28bb..fcecb31 100644 --- a/system/Extensions/ParsedownExtension.php +++ b/system/Extensions/ParsedownExtension.php @@ -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 ''; + print_r($mdElements); + die(); /*new*/ return $mdElements; -# return $Elements; +# return $Elements; }