/** * Returns an array with all attribute names not used in template * * We accept Tx_Rnbase_Domain_Model_DataInterface, but the model must also * implement IteratorAggregate! * * @param Tx_Rnbase_Domain_Model_Data $item * @param string $template * @param string $marker * @return array */ public static function findUnusedAttributes(Tx_Rnbase_Domain_Model_DataInterface $item, $template, $marker) { $ignore = array(); $minfo = self::containsMarker($template, $marker . '___MINFO'); $minfoArr = array(); foreach ($item as $key => $value) { if ($minfo) { $minfoArr[$key] = $marker . '_' . strtoupper($key); } if (!self::containsMarker($template, $marker . '_' . strtoupper($key))) { $ignore[] = $key; } } if ($minfo) { tx_rnbase::load('tx_rnbase_util_Debug'); $item->setProperty('__MINFO', tx_rnbase_util_Debug::viewArray($minfoArr)); } return $ignore; }
/** * Links vorbereiten * * @param Tx_Rnbase_Domain_Model_DataInterface $item * @param string $marker * @param array $markerArray * @param array $wrappedSubpartArray * @param string $confId * @param tx_rnbase_util_FormatUtil $formatter */ protected function prepareLinks($item, $marker, &$markerArray, &$subpartArray, &$wrappedSubpartArray, $confId, $formatter, $template) { $configurations = $formatter->getConfigurations(); $pluginData = $configurations->getCObj()->data; $configurations->getCObj()->data = $item->getProperty(); $linkIds = $configurations->getKeyNames($confId . 'links.'); for ($i = 0, $cnt = count($linkIds); $i < $cnt; $i++) { $linkId = $linkIds[$i]; // Check if link is defined in template if (!self::checkLinkExistence($linkId, $marker, $template)) { continue; } $linkConfId = $confId . 'links.' . $linkId; // Die Parameter erzeugen $params = array(); $paramMap = (array) $configurations->get($linkConfId . '._cfg.params.'); foreach ($paramMap as $paramName => $colName) { if (is_scalar($colName) && array_key_exists($colName, $item->getProperty())) { $params[$paramName] = $item->getProperty($colName); } elseif (is_array($colName)) { $paramName = substr($paramName, 0, strlen($paramName) - 1); $params[$paramName] = $this->createParam($paramName, $colName, $item); } } // check for charbrowser config and add the parameter if ($configurations->getBool($linkConfId . '._cfg.charbrowser')) { $cbId = $configurations->get($linkConfId . '._cfg.charbrowser.cbid'); $cbId = empty($cbId) ? 'charpointer' : $cbId; $cbColname = $configurations->get($linkConfId . '._cfg.charbrowser.colname'); $cbColname = empty($cbColname) ? 'uid' : $cbColname; $params[$cbId] = strtoupper(substr((string) $item->getProperty($cbColname), 0, 1)); } // @TODO: that only works on Tx_Rnbase_Domain_Model_DomainInterface! if ($configurations->getBool($linkConfId . '.skipPersistedCheck') || $item->isPersisted()) { $this->initLink($markerArray, $subpartArray, $wrappedSubpartArray, $formatter, $confId, $linkId, $marker, $params, $template); } else { $linkMarker = $marker . '_' . strtoupper($linkId) . 'LINK'; $remove = intval($configurations->get($linkConfId . '.removeIfDisabled')); $this->disableLink($markerArray, $subpartArray, $wrappedSubpartArray, $linkMarker, $remove > 0); } } $configurations->getCObj()->data = $pluginData; }
/** * * @param Tx_Rnbase_Domain_Model_DataInterface $options * @param Tx_Rnbase_Domain_Model_Base $obj * @param tx_rnbase_util_FormTool $formTool * @return string */ private static function addLinker($options, $obj, $formTool) { $out = ''; $linkerArr = $options->getLinker(); if ((is_array($linkerArr) || $linkerArr instanceof Traversable) && !empty($linkerArr)) { $linkerimplode = $options->getLinkerimplode() ? $options->getLinkerimplode() : '<br />'; $currentPid = (int) $options->getPid(); foreach ($linkerArr as $linker) { if (!$linker instanceof tx_rnbase_mod_LinkerInterface) { // backward compatibility, the interface with the makeLink method is new! if (!is_callable(array($linker, 'makeLink'))) { throw new Exception('Linker "' . get_class($linker) . '" has to implement interface "tx_rnbase_mod_LinkerInterface".'); } $utility = tx_rnbase_util_Typo3Classes::getGeneralUtilityClass(); $utility::deprecationLog('Linker "' . get_class($linker) . '" has to implement interface "tx_rnbase_mod_LinkerInterface".'); } $out .= $linker->makeLink($obj, $formTool, $currentPid, $options); $out .= $linkerimplode; } } return $out; }
/** * Link zur Detailseite erzeugen * * @param Tx_Rnbase_Domain_Model_Base $item * @param tx_rnbase_util_FormTool $formTool * @param int $currentPid * @param Tx_Rnbase_Domain_Model_DataInterface $options * @return string */ public function makeLink($item, $formTool, $currentPid, $options) { $uidkey = $options->getShowDetailsKey() ? $options->getShowDetailsKey() : 'showDetails[' . $item->getTableName() . ']'; $label = $options->hasShowDetailsLabel() ? $options->getShowDetailsLabel() : '###LABEL_SHOW_DETAILS###'; return $formTool->createSubmit($uidkey . '[' . $item->uid . ']', $label); }