/** * action edit * * @param \MASK\Mask\Domain\Model\BackendLayout $layout * @return void */ public function editAction($layout) { $storage = $this->storageRepository->loadElement("pages", $layout->getUid()); $this->prepareStorage($storage); $this->view->assign('backendLayout', $layout); $this->view->assign('storage', $storage); $this->view->assign('editMode', 1); }
/** * * @param Icon $icon * @param array $options * @author Benjamin Butschell <*****@*****.**> */ public function prepareIconMarkup(Icon $icon, array $options = array()) { // error checking if (empty($options['contentElementKey'])) { throw new \InvalidArgumentException('The option "contentElementKey" is required and must not be empty', 1440754978); } $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $this->storageRepository = $this->objectManager->get("MASK\\Mask\\Domain\\Repository\\StorageRepository"); $this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['mask']); $this->contentElement = $this->storageRepository->loadElement("tt_content", $options["contentElementKey"]); $icon->setMarkup($this->generateMarkup($icon, $options)); }
/** * action edit * * @param string $type * @param string $key * @return void */ public function editAction($type, $key) { $storage = $this->storageRepository->loadElement($type, $key); $this->prepareStorage($storage); $this->view->assign('storage', $storage); $this->view->assign('editMode', 1); }
/** * Checks if a key for an element is available * * @param array $params Array of parameters from the AJAX interface, not * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler * @author Benjamin Butschell <*****@*****.**> * @return void */ public function checkElementKey($params = array(), \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj = NULL) { $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $this->storageRepository = $this->objectManager->get("MASK\\Mask\\Domain\\Repository\\StorageRepository"); // Get parameters, is there a better way? $params is not used yet $elementKey = $_GET["key"]; // check if elementKey is available $isAvailable = TRUE; if ($this->storageRepository->loadElement("tt_content", $elementKey)) { $isAvailable = FALSE; } // return infos as json $ajaxObj->setContentFormat("plain"); $ajaxObj->addContent("isAvailable", json_encode($isAvailable)); }
/** * Returns the formType of a field in an element * * @param string $fieldKey Key if Field * @param string $elementKey Key of Element * @param string $type elementtype * @return string formType * @author Benjamin Butschell <*****@*****.**> */ public function getFormType($fieldKey, $elementKey = "", $type = "tt_content") { $this->storageRepository = $this->objectManager->get("MASK\\Mask\\Domain\\Repository\\StorageRepository"); $formType = "String"; // Load element and TCA of field if ($elementKey) { $element = $this->storageRepository->loadElement($type, $elementKey); } // load tca for field from $GLOBALS $tca = $GLOBALS["TCA"][$type]["columns"][$fieldKey]; if (!$tca["config"]) { $tca = $GLOBALS["TCA"][$type]["columns"]["tx_mask_" . $fieldKey]; } if (!$tca["config"]) { $tca = $element["tca"][$fieldKey]; } // if field is in inline table, load tca from json if (!in_array($type, array("tt_content", "pages"))) { $tca = $this->storageRepository->loadField($type, $fieldKey); if (!$tca["config"]) { $tca = $this->storageRepository->loadField($type, "tx_mask_" . $fieldKey); } } $tcaType = $tca["config"]["type"]; $evals = explode(",", $tca["config"]["eval"]); if ($tca["options"] == "file") { $formType = "File"; } // And decide via different tca settings which formType it is switch ($tcaType) { case "input": $formType = "String"; if (array_search(strtolower("int"), $evals) !== FALSE) { $formType = "Integer"; } else { if (array_search(strtolower("double2"), $evals) !== FALSE) { $formType = "Float"; } else { if (array_search(strtolower("date"), $evals) !== FALSE) { $formType = "Date"; } else { if (array_search(strtolower("datetime"), $evals) !== FALSE) { $formType = "Datetime"; } else { if (is_array($tca["config"]["wizards"]["link"])) { $formType = "Link"; } else { $formType = "String"; } } } } } break; case "text": $formType = "Text"; if (in_array($type, array("tt_content", "pages"))) { if ($elementKey) { $fieldNumberKey = -1; if (is_array($element["columns"])) { foreach ($element["columns"] as $numberKey => $column) { if ($column == $fieldKey) { $fieldNumberKey = $numberKey; } } } if ($fieldNumberKey >= 0) { $option = $element["options"][$fieldNumberKey]; if ($option == "rte") { $formType = "Richtext"; } else { $formType = "Text"; } } } else { $formType = "Text"; } } else { if ($tca["rte"]) { $formType = "Richtext"; } else { $formType = "Text"; } } break; case "check": $formType = "Check"; break; case "radio": $formType = "Radio"; break; case "select": $formType = "Select"; break; case "group": break; case "none": break; case "passthrough": break; case "user": break; case "flex": break; case "inline": $formType = "Inline"; if ($tca["config"]["foreign_table"] == "sys_file_reference") { $formType = "File"; } else { $formType = "Inline"; } break; default: break; } return $formType; }