Skip to content

Commit

Permalink
FAL support for tt_products_articles and tt_products_cat
Browse files Browse the repository at this point in the history
  • Loading branch information
franzholz committed Feb 18, 2021
1 parent 205e3bf commit 8d0be8a
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 31 deletions.
2 changes: 2 additions & 0 deletions model/class.tx_ttproducts_table_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ abstract class tx_ttproducts_table_base implements \TYPO3\CMS\Core\SingletonInte
'endtime' => 'tx_ttproducts_field_datetime',
'graduated_price_uid' => 'tx_ttproducts_field_graduated_price',
'image' => 'tx_ttproducts_field_image',
'image_uid' => 'tx_ttproducts_field_image',
'smallimage' => 'tx_ttproducts_field_image',
'smallimage_uid' => 'tx_ttproducts_field_image',
'itemnumber' => 'tx_ttproducts_field_text',
'note' => 'tx_ttproducts_field_note',
'note2' => 'tx_ttproducts_field_note',
Expand Down
3 changes: 2 additions & 1 deletion model/field/class.tx_ttproducts_field_media.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
*/


use TYPO3\CMS\Core\Utility\GeneralUtility;


class tx_ttproducts_field_media extends tx_ttproducts_field_base {

Expand Down Expand Up @@ -70,7 +72,6 @@ public function getFileArray (
$sysfileRowArray = array();

if (
$tablename == 'tt_products' &&
isset($imageRow['ext']) &&
is_array($imageRow['ext']) &&
isset($imageRow['ext']['tt_products_articles']) &&
Expand Down
8 changes: 4 additions & 4 deletions view/class.tx_ttproducts_article_base_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ public function getPriceMarkerArray ($basketExtra, &$markerArray, $row, $markerK
*/
public function getModelMarkerArray (
&$row,
$markerKey,
$markerParam,
&$markerArray,
$catTitle,
$imageNum=0,
$imageRenderObj='image',
&$tagArray,
$tagArray,
$forminfoArray=array(),
$theCode='',
$basketExtra=array(),
Expand All @@ -157,7 +157,7 @@ public function getModelMarkerArray (
$linkWrap='',
$bHtml=true,
$charset=''
) {
) {
$modelObj = $this->getModelObj();
$imageObj = GeneralUtility::makeInstance('tx_ttproducts_field_image_view');

Expand All @@ -173,7 +173,7 @@ public function getModelMarkerArray (
$variantFieldArray = $modelObj->variant->getFieldArray();
$variantMarkerArray = array();

$this->getRowMarkerArray (
$this->getRowMarkerArray(
$row,
$marker,
$markerArray,
Expand Down
3 changes: 0 additions & 3 deletions view/class.tx_ttproducts_basket_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ public function getView (
$articleViewTagArray,
$articleParentArray
);

$prodUidField = $cnf->getTableDesc($articleTable->getTableObj()->name, 'uid_product');
$fieldsArray = array_merge($fieldsArray, $articleFieldsArray);
$uidKey = array_search($prodUidField, $fieldsArray);
Expand Down Expand Up @@ -536,7 +535,6 @@ public function getView (
$bHtml,
'UTF-8'
);

$articleViewObj->getItemMarkerSubpartArrays(
$t['item'],
$articleViewObj->getModelObj()->getFuncTablename(),
Expand Down Expand Up @@ -645,7 +643,6 @@ public function getView (
$subpartArray,
$wrappedSubpartArray
);

$tempContent = $parser->substituteMarkerArray(
$tempContent,
$markerArray
Expand Down
6 changes: 4 additions & 2 deletions view/class.tx_ttproducts_list_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -1896,8 +1896,10 @@ class_exists('t3lib_utility_Math') ?
// use the product if no article row has been found
if ($articleRow) {
$itemTable->mergeAttributeFields($prodVariantRow, $articleRow, false);
}

$prodVariantRow['ext']['tt_products_articles'][] = $articleRow;
} else {
$prodVariantRow['ext']['tt_products_articles'] = array();
}
$itemTableView->getModelMarkerArray(
$prodVariantRow,
$itemTableViewArray['article']->getMarker(),
Expand Down
9 changes: 3 additions & 6 deletions view/class.tx_ttproducts_product_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function getModelMarkerArray (
$catTitle,
$imageNum=0,
$imageRenderObj='image',
&$tagArray,
$tagArray,
$forminfoArray=array(),
$theCode='',
$basketExtra=array(),
Expand All @@ -153,7 +153,7 @@ public function getModelMarkerArray (
$linkWrap='',
$bHtml=true,
$charset=''
) {
) {
// Returns a markerArray ready for substitution with information for the tt_producst record, $row
$tablesObj = GeneralUtility::makeInstance('tx_ttproducts_tables');
$modelObj = $this->getModelObj ();
Expand Down Expand Up @@ -184,8 +184,7 @@ public function getModelMarkerArray (
$bHtml,
$charset
);
// Todo: das mit datasheet hier löschen

// Todo: remove datasheet part from here:
$datafieldViewObj = $this->getFieldObj('datasheet');
if (isset($datafieldViewObj) && is_object($datafieldViewObj)) {
$datafieldViewObj->getRowMarkerArray(
Expand Down Expand Up @@ -400,5 +399,3 @@ public function getModelMarkerArray (
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/tt_products/view/class.tx_ttproducts_product_view.php']);
}



8 changes: 8 additions & 0 deletions view/class.tx_ttproducts_single_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,14 @@ public function printView (&$templateCode, &$errorCode, $pageAsCategory, $templa
$row['inStock'] = $articleRow['inStock'];
}
}

if (
!empty($articleRow) &&
isset($prodVariantRow['ext']) &&
!isset($prodVariantRow['ext']['tt_products_articles'])
) {
$prodVariantRow['ext']['tt_products_articles'][] = $articleRow;
}

$itemTableViewArray[$this->type]->getModelMarkerArray(
$row,
Expand Down
2 changes: 0 additions & 2 deletions view/field/class.tx_ttproducts_field_image_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function getRowMarkerArrayEnhanced (
if ($mediaNum > 0) {
$imageNum = $mediaNum;
}
// hack end

$imageRow = $row;
$bImages = false;
Expand Down Expand Up @@ -300,7 +299,6 @@ public function getRowMarkerArrayEnhanced (
}
}
}

// empty all image fields with no available image
foreach ($tagArray as $value => $k1) {
$keyMarker = '###'.$value.'###';
Expand Down
53 changes: 40 additions & 13 deletions view/field/class.tx_ttproducts_field_media_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,32 +212,62 @@ public function getCodeMarkerArray (
}

foreach($imageArray as $c => $val) {

$imageConf = $imageConfStart;
if ($c == $mediaNum) {
break;
}
$bUseImage = false;
$meta = false;
if ($val) {
$imageConf['file'] = $dirname.$val;
$bUseImage = true;
if (!empty($val)) {
$filename = '';
if (is_array($val)) {
if (isset($val['name'])) {
$filename = 'fileadmin' . $val['identifier'];
}
} else {
$filename = $dirname . $val;
}
$imageConfFile = $filename;
}

if (!$this->conf['separateImage']) {
$key = 0; // show all images together as one image
} else if (is_array($val)) {
$key = $val['name'];
} else {
$key = ($val ? $val : $c);
$key = (!empty($val) ? $val : $c);
}

$tagkey = '';
if ($val) {
$tagkey = $this->getMarkerkey($imageMarkerArray, $markerKey, $key, $c + 1);
}

if (is_array($val)) {
$meta = $val;
}

$cObj->alternativeData = ($meta ? $meta : $imageRow);
$imageConf['params'] = preg_replace('/\s+/',' ',$imageConf['params']);
$this->replaceMarkerArray($markerArray, $imageConf, $cObj->alternativeData);
$imageConf['params'] = preg_replace('/\s+/', ' ', $imageConf['params']);
if (!isset($imageConf['altText']) && isset($cObj->alternativeData['alternative'])) {
$imageConf['altText'] = $cObj->alternativeData['alternative'];
}
if (!isset($imageConf['titleText']) && isset($cObj->alternativeData['title'])) {
$imageConf['titleText'] = $cObj->alternativeData['title'];
}

$bGifBuilder = ($imageConf['file'] == 'GIFBUILDER');
if (isset($imageConfFile)) {
$imageConf['file'] = $imageConfFile;
}
$filename = '';
if (is_array($val)) {
$filename = $imageConfFile;
} else {
$filename = $val;
}

$markerArray['###FILE###'] = $filename;

$this->replaceMarkerArray($markerArray, $imageConf, $cObj->alternativeData);
$tmpImgCode = $this->getImageCode($imageConf, $theCode);

if ($tmpImgCode != '') {
Expand Down Expand Up @@ -267,7 +297,6 @@ public function getCodeMarkerArray (
$imgCodeArray[0] = $cObj->stdWrap($imgCodeArray[0], $tableConf['joinedImagesWrap.']);
}
}

return $imgCodeArray;
}

Expand Down Expand Up @@ -412,7 +441,7 @@ private function getMediaMarkerArray (
} // if (!$bImages) {

if (!$bImages) {
$imgs = $this->getModelObj()->getFileArray($theTablename, $imageRow, $fieldname, true);
$imgs = $this->getModelObj()->getFileArray($functablename, $imageRow, $fieldname, true);
}

$specialConf = array();
Expand Down Expand Up @@ -454,7 +483,6 @@ private function getMediaMarkerArray (

$c = 1;
$countArray = array();

foreach($theImgCode as $k1 => $val) {

$bIsSpecial = true;
Expand Down Expand Up @@ -558,7 +586,6 @@ public function getRowMarkerArray (
$fieldname,
$theCode
);

if ($mediaNum) {

$this->getMediaMarkerArray(
Expand Down

0 comments on commit 8d0be8a

Please sign in to comment.