[TASK] Clean up the phpDoc of t3lib/tree/
[Packages/TYPO3.CMS.git] / t3lib / tree / tca / class.t3lib_tree_tca_dataproviderfactory.php
index 6199f9d..52cf6e4 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 2010 Steffen Ritter <info@steffen-ritter.net>
+ *  (c) 2010-2011 Steffen Ritter <info@steffen-ritter.net>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -37,7 +37,6 @@ class t3lib_tree_Tca_DataProviderFactory {
        /**
         * Gets the data provider, depending on TCA configuration
         *
-        * @static
         * @param array $tcaConfiguration
         * @return t3lib_tree_Tca_DatabaseTreeDataProvider
         * @throws InvalidArgumentException
@@ -50,20 +49,24 @@ class t3lib_tree_Tca_DataProviderFactory {
                }
 
                if ($tcaConfiguration['internal_type'] == 'db') {
-                       /**
-                        * @var $dataProvider t3lib_tree_Tca_DatabaseTreeDataProvider
-                        */
+                       $unselectableUids = array();
+
+                       /** @var $dataProvider t3lib_tree_Tca_DatabaseTreeDataProvider */
                        $dataProvider = t3lib_div::makeInstance('t3lib_tree_Tca_DatabaseTreeDataProvider');
 
                        if (isset($tcaConfiguration['foreign_table'])) {
                                $tableName = $tcaConfiguration['foreign_table'];
                                $dataProvider->setTableName($tableName);
 
+                               if ($tableName == $table) {
+                                       $unselectableUids[] = $currentValue['uid'];
+                               }
+
                                t3lib_div::loadTCA($tableName);
                        } else {
                                throw new InvalidArgumentException(
                                        'TCA Tree configuration is invalid: "foreign_table" not set',
-                                       '1288215888'
+                                       1288215888
                                );
                        }
 
@@ -82,7 +85,7 @@ class t3lib_tree_Tca_DataProviderFactory {
                                }
 
                                if (isset($treeConfiguration['appearance']['expandAll'])) {
-                                       $dataProvider->setExpandAll((boolean)$treeConfiguration['appearance']['expandAll']);
+                                       $dataProvider->setExpandAll((boolean) $treeConfiguration['appearance']['expandAll']);
                                }
 
                                if (isset($treeConfiguration['appearance']['maxLevels'])) {
@@ -104,32 +107,35 @@ class t3lib_tree_Tca_DataProviderFactory {
                                } else {
                                        throw new InvalidArgumentException(
                                                'TCA Tree configuration is invalid: neither "childrenField" nor "parentField" is set',
-                                               '1288215889'
+                                               1288215889
                                        );
                                }
+
+                               $dataProvider->setItemUnselectableList($unselectableUids);
                        } else {
                                throw new InvalidArgumentException(
                                        'TCA Tree configuration is invalid: "treeConfig" array is missing',
-                                       '1288215890'
+                                       1288215890
                                );
                        }
 
                } elseif ($tcaConfiguration['internal_type'] == 'file') {
-                               // Not implemented yet
+                               // TODO Not implemented yet
                        throw new InvalidArgumentException(
                                'TCA Tree configuration is invalid: tree for "internal_type=file" not implemented yet',
-                               '1288215891'
+                               1288215891
                        );
                } else {
                        throw new InvalidArgumentException(
                                'TCA Tree configuration is invalid: tree for "internal_type=' .
-                                       $tcaConfiguration['internal_type'] .
-                                       '" not implemented yet',
-                               '1288215892'
+                               $tcaConfiguration['internal_type'] .
+                               '" not implemented yet',
+                               1288215892
                        );
                }
+
                return $dataProvider;
        }
 }
 
-?>
+?>
\ No newline at end of file