From 50046b56faaba37f083209cbd653fa517ad9ff14 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Mon, 1 Feb 2016 06:04:59 +0100 Subject: add property: Optimize tca column-definition positioning Place the column definition before the bracket with the same indentation as the line with "'columns' =>" --- add_extbase_property.sh | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/add_extbase_property.sh b/add_extbase_property.sh index 2881a1a..d6582fd 100755 --- a/add_extbase_property.sh +++ b/add_extbase_property.sh @@ -196,17 +196,29 @@ else sed -i "s/\('showitem' => '..*\)'),/\1, $field'),/" $tca_file fi -sed -i "s#'columns'.*#&\n\n\ - '${field}' => array(\n\ - 'exclude' => 1,\n\ - 'label' => 'LLL:EXT:${extension}/Resources/Private/Language/locallang_db.xlf:${tablename}.${field}',\n\ - 'config' => array(\n\ - 'type' => '${tca_type}',\n\ - $tca_options,\n\ - 'eval' => 'trim'\n\ - ),\n\ - ),#" \ - $tca_file + +sed -i -f - $tca_file << EOF +/[ ]*'columns' =>/ { + :loop + + /^\([ \t]*\)'columns'.*\n\1[])],/! { + N + b loop + } + + s|^\([ \t]*\)\('columns'.*[^\n]\)\(\n\n*\)\1\([])],\)|\1\2\3\ +\1 '${field}' => array(\n\ +\1 'exclude' => 1,\n\ +\1 'label' => 'LLL:EXT:${extension}/Resources/Private/Language/locallang_db.xlf:${tablename}.${field}',\n\ +\1 'config' => array(\n\ +\1 'type' => '${tca_type}',\n\ +\1 $tca_options,\n\ +\1 'eval' => 'trim'\n\ +\1 ),\n\ +\1 ),\3\ +\1\4| +} +EOF # Locallang fixes sed -i "s/.*<\/body>/\t\t\t\n\t\t\t\t${uproperty}<\/source>\n\t\t\t<\/trans-unit>\n&/" \ @@ -305,5 +317,3 @@ echo "Created \$${property} in ${model}" echo echo "Edit Resources/Private/Language/locallang_db.xlf to edit the label shown in the TCA." echo "Edit Resources/Private/Language/locallang.xlf to edit the label shown in the Frontend." -echo -echo "You should edit $tca_file to move the column definition to the proper place." -- cgit