Example #1
0
 /**
  * Generates TCA Selectbox-Options-Array for a specific TCA-type.
  *
  * @param string $type TCA Type
  * @param string $table Tablename
  * @return array all TCA elements of this attribut
  * @author Gernot Ploiner <*****@*****.**>
  * @author Benjamin Butschell <*****@*****.**>
  */
 public function render($type, $table)
 {
     $this->utility = new \MASK\Mask\Utility\MaskUtility($this->objectManager);
     // in tt_content allow all fields except $forbiddenFields
     if ($table == "tt_content") {
         $forbiddenFields = array('starttime', 'endtime', 'hidden', 'sectionIndex', 'linkToTop', 'fe_group', 'CType', 'doktype', 'title', 'TSconfig', 'php_tree_stop', 'storage_pid', 'tx_impexp_origuid', 't3ver_label', 'editlock', 'url_scheme', 'extendToSubpages', 'nav_title', 'nav_hide', 'subtitle', 'target', 'alias', 'url', 'urltype', 'lastUpdated', 'newUntil', 'cache_timeout', 'cache_tags', 'no_cache', 'no_search', 'shortcut', 'shortcut_mode', 'content_from_pid', 'mount_pid', 'keywords', 'description', 'abstract', 'author', 'author_email', 'is_siteroot', 'mount_pid_ol', 'module', 'fe_login_mode', 'l18n_cfg', 'backend_layout', 'backend_layout_next_level');
         foreach ($GLOBALS['TCA'][$table]['columns'] as $tcaField => $tcaConfig) {
             $fieldType = $this->utility->getFormType($tcaField, "", $table);
             if (($fieldType == $type || $fieldType == "Text" && ($type == "Text" || $type == "Richtext")) && array_search($tcaField, $forbiddenFields) === FALSE) {
                 $temp["field"] = $tcaField;
                 $temp["label"] = $tcaConfig["label"];
                 $content[] = $temp;
             }
         }
     } else {
         // in pages allow only fields already created by mask
         foreach ($GLOBALS['TCA'][$table]['columns'] as $tcaField => $tcaConfig) {
             $fieldType = $this->utility->getFormType($tcaField, "", $table);
             if (($fieldType == $type || $fieldType == "Text" && ($type == "Text" || $type == "Richtext")) && strrpos($tcaField, "tx_mask_", -strlen($tcaField)) !== false) {
                 $temp["field"] = $tcaField;
                 $temp["label"] = $tcaConfig["label"];
                 $content[] = $temp;
             }
         }
     }
     return $content;
 }
Example #2
0
 /**
  * Returns the label of a field in an element
  *
  * @param string $elementKey Key of Element
  * @param string $fieldKey Key of Field
  * @param array $field whole field, to better determine correct label
  * @param string $table tt_content or pages, to better determine correct label
  * @return string Label
  * @author Benjamin Butschell bb@webprofil.at>
  */
 public function render($elementKey, $fieldKey, $field = NULL, $table = NULL)
 {
     $this->utility = new \MASK\Mask\Utility\MaskUtility($this->objectManager);
     // if we have the whole field configuration
     if ($field) {
         // check if this field is in an repeating field
         if ($field["inlineParent"]) {
             // if yes, the label is in the configuration
             $label = $field["label"];
         } else {
             // otherwise the type can only be tt_content or pages
             if ($table) {
                 // if we have table param, the type must be the table
                 $type = $table;
             } else {
                 // otherwise try to get the label, set param $excludeInlineFields to true
                 $type = $this->utility->getFieldType($fieldKey, $elementKey, true);
             }
             $label = $this->utility->getLabel($elementKey, $fieldKey, $type);
         }
     } else {
         // if we don't have the field configuration, try the best to fetch the type and the correct label
         $type = $this->utility->getFieldType($fieldKey, $elementKey, false);
         $label = $this->utility->getLabel($elementKey, $fieldKey, $type);
     }
     return $label;
 }
Example #3
0
 /**
  * Displays the content in the frontend
  *
  * @return void
  */
 public function contentelementAction()
 {
     $this->view->setTemplatePathAndFilename($this->settings["file"]);
     $data = $this->configurationManager->getContentObject()->data;
     $this->utility->addFilesToData($data, "tt_content");
     $this->utility->addIrreToData($data);
     $this->view->assign('data', $data);
 }
Example #4
0
 /**
  * Assign content object renderer data and current to view, called by TYPO3 6.2
  *
  * @param array $conf Configuration
  * @author Benjamin Butschell <*****@*****.**>
  * @return void
  */
 protected function assignContentObjectDataAndCurrent(array $conf = array())
 {
     // Call Parent Function to maintain core functions
     parent::assignContentObjectDataAndCurrent($conf);
     $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->utility = $this->objectManager->get("MASK\\Mask\\Utility\\MaskUtility");
     // Make some enhancements to data
     $data = $this->cObj->data;
     $this->utility->addFilesToData($data, "pages");
     $this->utility->addIrreToData($data, "pages");
     $this->view->assign('data', $data);
 }
Example #5
0
 /**
  * Returns the label of a field in an element
  *
  * @param string $elementKey Key of Element
  * @param string $fieldKey Key if Field
  * @param array $field
  * @return string Label
  * @author Benjamin Butschell bb@webprofil.at>
  */
 public function render($elementKey, $fieldKey, $field = NULL)
 {
     $this->utility = new \MASK\Mask\Utility\MaskUtility($this->objectManager);
     $type = $this->utility->getFieldType($fieldKey, $elementKey);
     if ($field) {
         if ($field["inlineParent"]) {
             $label = $field["label"];
         } else {
             $label = $this->utility->getLabel($elementKey, $fieldKey, $type);
         }
     } else {
         $label = $this->utility->getLabel($elementKey, $fieldKey, $type);
     }
     return $label;
 }
Example #6
0
 /**
  * Checks if a $evalValue is set in a field
  *
  * @param string $fieldKey TCA Type
  * @param string $elementKey TCA Type
  * @param string $evalValue value to search for
  * @param array $field
  * @return boolean $evalValue is set
  * @author Benjamin Butschell bb@webprofil.at>
  */
 public function render($fieldKey, $elementKey, $evalValue, $field = NULL)
 {
     $this->utility = new \MASK\Mask\Utility\MaskUtility($this->objectManager);
     if ($field) {
         if ($field["inlineParent"]) {
             $type = $field["inlineParent"];
             $fieldKey = "tx_mask_" . $field["key"];
         } else {
             $type = $this->utility->getFieldType($fieldKey, $elementKey);
         }
     } else {
         $type = $this->utility->getFieldType($fieldKey, $elementKey);
     }
     return $this->utility->isEvalValueSet($fieldKey, $evalValue, $type);
 }
 /**
  * Removes a field from the json, also recursively all inline-fields
  * @author Benjamin Butschell <*****@*****.**>
  *
  * @param string $table
  * @param string $field
  * @param array $json
  * @return array
  */
 private function removeField($table, $field, $json)
 {
     // init utility
     $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->utility = new \MASK\Mask\Utility\MaskUtility($this->objectManager, $this);
     // and unset field only if not needed anymore
     $elementsInUse = array();
     if ($json["tt_content"]["elements"]) {
         foreach ($json["tt_content"]["elements"] as $element) {
             if ($element["columns"]) {
                 foreach ($element["columns"] as $column) {
                     if ($column == $field) {
                         $elementsInUse[] = $element;
                     }
                 }
             }
         }
     }
     // Recursively delete all inline-fields
     if ($json[$table]["tca"][$field]["config"]["type"] == "inline") {
         $inlineFields = $this->loadInlineFields($field);
         if ($inlineFields) {
             foreach ($inlineFields as $inlineField) {
                 $json = $this->removeField($inlineField["inlineParent"], "tx_mask_" . $inlineField["key"], $json);
             }
         }
     }
     if (count($elementsInUse) < 1) {
         unset($json[$table]["tca"][$field]);
         unset($json[$table]["sql"][$field]);
         // If field is of type file, also delete entry in sys_file_reference
         if ($this->utility->getFormType($field) == "File") {
             unset($json["sys_file_reference"]["sql"][$field]);
             $json = $this->cleanTable("sys_file_reference", $json);
         }
     }
     return $this->cleanTable($table, $json);
 }
Example #8
0
 /**
  * Returns the label of a field in an element
  *
  * @param string $elementKey Key of Element
  * @param string $fieldKey Key if Field
  * @param string $type table
  * @return string formType
  * @author Benjamin Butschell bb@webprofil.at>
  */
 public function render($elementKey, $fieldKey, $type = "tt_content")
 {
     $this->utility = new \MASK\Mask\Utility\MaskUtility($this->objectManager);
     $formType = $this->utility->getFormType($fieldKey, $elementKey, $type);
     return $formType;
 }
Example #9
0
    /**
     * Generates HTML for a field
     * @param string $fieldKey
     * @param string $elementKey
     * @param string $table
     * @param string $datafield
     * @return string $html
     * @author Gernot Ploiner <*****@*****.**>
     * @author Benjamin Butschell <*****@*****.**>
     */
    public function generateFieldHtml($fieldKey, $elementKey, $table = "tt_content", $datafield = "data")
    {
        $html = "";
        switch ($this->utility->getFormType($fieldKey, $elementKey, $table)) {
            case "Check":
                $html .= "{f:if(condition: " . $datafield . "." . $fieldKey . ", then: 'On', else: 'Off')}<br />\n\n";
                break;
            case "Content":
                // TODO: Benjamin, Fluid-Vorlage für Feld "Content Verbindung":
                $html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n\n";
                break;
            case "Date":
                $html .= '<f:format.date format="d.m.Y">{' . $datafield . '.' . $fieldKey . '}</f:format.date><br />' . "\n\n";
                break;
            case "Datetime":
                $html .= '<f:format.date format="d.m.Y - H:i:s">{' . $datafield . '.' . $fieldKey . '}</f:format.date><br />' . "\n\n";
                break;
            case "File":
                $html .= '<f:for each="{' . $datafield . '.' . $fieldKey . '}" as="file">
  <f:image src="{file.uid}" alt="{file.alternative}" title="{file.title}" treatIdAsReference="1" width="200" /><br />
  {file.description} / {file.identifier}<br />
</f:for>' . "\n\n";
                break;
            case "Float":
                $html .= '<f:format.number decimals="2" decimalSeparator="," thousandsSeparator=".">{' . $datafield . '.' . $fieldKey . '}</f:format.number><br />' . "\n\n";
                break;
            case "Inline":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= "<ul>\n";
                $html .= "<f:for each=\"{" . $datafield . "." . $fieldKey . "}\" as=\"" . $datafield . "_item" . "\">\n<li>";
                $inlineFields = $this->storageRepository->loadInlineFields($fieldKey);
                if ($inlineFields) {
                    foreach ($inlineFields as $inlineField) {
                        $html .= $this->generateFieldHtml($inlineField["maskKey"], $elementKey, $fieldKey, $datafield . "_item") . "\n";
                    }
                }
                $html .= "</li>\n</f:for>" . "\n";
                $html .= "</ul>\n";
                $html .= "</f:if>\n\n";
                break;
            case "Integer":
                $html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n\n";
                break;
            case "Link":
                $html .= '<f:link.page pageUid="{' . $datafield . '.' . $fieldKey . '}">{data.' . $fieldKey . '}</f:link.page><br />' . "\n\n";
                break;
            case "Radio":
                $html .= '<f:switch expression="{' . $datafield . '.' . $fieldKey . '}">
  <f:case value="1">Value is: 1</f:case>
  <f:case value="2">Value is: 2</f:case>
  <f:case value="3">Value is: 3</f:case>
</f:switch><br />' . "\n\n";
                break;
            case "Richtext":
                $html .= '<f:format.html parseFuncTSPath="lib.parseFunc_RTE">{' . $datafield . '.' . $fieldKey . '}</f:format.html><br />' . "\n\n";
                break;
            case "Select":
                $html .= '<f:switch expression="{' . $datafield . '.' . $fieldKey . '}">
  <f:case value="1">Value is: 1</f:case>
  <f:case value="2">Value is: 2</f:case>
  <f:case value="3">Value is: 3</f:case>
</f:switch><br />' . "\n\n";
                break;
            case "String":
                $html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n\n";
                break;
            case "Text":
                $html .= '<f:format.nl2br>{' . $datafield . '.' . $fieldKey . '}</f:format.nl2br><br />' . "\n\n";
                break;
        }
        return $html;
    }
Example #10
0
 /**
  * Returns all elements that use this field
  *
  * @param string $key TCA Type
  * @param string $elementKey Key of the element
  * @return array elements in use
  * @author Benjamin Butschell bb@webprofil.at>
  */
 public function render($key, $elementKey)
 {
     $this->utility = new \MASK\Mask\Utility\MaskUtility($this->objectManager);
     $type = $this->utility->getFieldType($key, $elementKey);
     return $this->utility->getElementsWhichUseField($key, $type);
 }
Example #11
0
 /**
  * Checks if a $evalValue is set in a field
  *
  * @param string $fieldKey TCA Type
  * @param string $elementKey key of the element
  * @param string $evalValue value to search for
  * @return boolean $evalValue is set
  * @author Benjamin Butschell bb@webprofil.at>
  */
 public function render($fieldKey, $elementKey, $evalValue)
 {
     $this->utility = new \MASK\Mask\Utility\MaskUtility($this->objectManager);
     $type = $this->utility->getFieldType($fieldKey, $elementKey);
     return $this->utility->isBlindLinkOptionSet($fieldKey, $evalValue, $type);
 }
Example #12
0
 /**
  * Removes a field from the json, also recursively all inline-fields
  * @author Benjamin Butschell <*****@*****.**>
  *
  * @param string $table
  * @param string $field
  * @param array $json
  * @param array $remainingFields
  * @return array
  */
 private function removeField($table, $field, $json, $remainingFields = array())
 {
     // init utility
     $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->utility = new \MASK\Mask\Utility\MaskUtility($this->objectManager, $this);
     // check if this field is used in any other elements
     $elementsInUse = array();
     if ($json[$table]["elements"]) {
         foreach ($json[$table]["elements"] as $element) {
             if ($element["columns"]) {
                 foreach ($element["columns"] as $column) {
                     if ($column == $field) {
                         $elementsInUse[] = $element;
                     }
                 }
             }
         }
     }
     // check if father gets deleted
     $fatherFound = false;
     if ($remainingFields) {
         foreach ($remainingFields as $remainingField) {
             if ($field == "tx_mask_" . $remainingField) {
                 $fatherFound = true;
             }
         }
     }
     $fatherGetsDeleted = !$fatherFound;
     // if the field is a repeating field, make some exceptions
     if ($json[$table]["tca"][$field]["config"]["type"] == "inline") {
         $inlineFields = $this->loadInlineFields($field);
         if ($inlineFields) {
             // Recursively delete all inline-fields if necessary
             foreach ($inlineFields as $inlineField) {
                 $found = false;
                 // check if the fields are really deleted, or if they are just deleted temporarly for update action
                 if ($remainingFields) {
                     foreach ($remainingFields as $remainingField) {
                         if ($inlineField["key"] == $remainingField) {
                             $found = true;
                         }
                     }
                 }
                 if ($found) {
                     // was not really deleted => can be deleted temporarly because it will be readded
                     $json = $this->removeField($inlineField["inlineParent"], "tx_mask_" . $inlineField["key"], $json);
                 } else {
                     // was really deleted and can only be deleted if father is not in use in another element
                     if ($fatherGetsDeleted && count($elementsInUse) == 0 || !$fatherGetsDeleted) {
                         $json = $this->removeField($inlineField["inlineParent"], "tx_mask_" . $inlineField["key"], $json);
                     }
                 }
             }
         }
     }
     // then delete the field, if it is not in use in another element
     if (count($elementsInUse) < 1) {
         unset($json[$table]["tca"][$field]);
         unset($json[$table]["sql"][$field]);
         // If field is of type file, also delete entry in sys_file_reference
         if ($this->utility->getFormType($field) == "File") {
             unset($json["sys_file_reference"]["sql"][$field]);
             $json = $this->cleanTable("sys_file_reference", $json);
         }
     }
     return $this->cleanTable($table, $json);
 }