/**
  * Most of the code below was copied from HasManyComplexTableField.
  * Painful, but necessary, until PHP supports multiple inheritance.
  */
 function __construct($controller, $name, $sourceClass, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "")
 {
     parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
     $this->Markable = true;
     if ($controllerClass = $this->controllerClass()) {
         $this->joinField = $this->getParentIdName($controllerClass, $this->sourceClass);
     } else {
         user_error("Can't figure out the data class of {$controller}", E_USER_WARNING);
     }
 }
 public function __construct($controller, $name = null, $sourceClass = null, $fileFieldName = null, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "Created DESC", $sourceJoin = "")
 {
     if (!class_exists("SWFUploadField")) {
         die("<strong>" . _t('DataObjectManager.ERROR', 'Error') . "</strong>: " . _t('FileDataObjectManager.SWFUPLOAD', 'DataObjectManager requires the SWFUpload module.'));
     }
     parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
     // Intelligent constructor for fileFieldName
     $SNG = singleton($this->sourceClass());
     if ($fileFieldName === null) {
         if ($has_ones = $SNG->stat('has_one')) {
             foreach ($has_ones as $relation => $value) {
                 if (is_subclass_of($value, "File")) {
                     $fileFieldName = $relation;
                     $fileClassName = $value;
                     break;
                 }
             }
         }
     }
     if (isset($_REQUEST['ctf'][$this->Name()])) {
         $this->view = $_REQUEST['ctf'][$this->Name()]['view'];
     }
     if ($this->sourceClass() == "File" || is_subclass_of($this->sourceClass(), "File")) {
         $this->hasDataObject = false;
         $this->fileFieldName = $name;
         $this->fileClassName = $this->sourceClass();
         $this->dataObjectFieldName = null;
     } else {
         $this->dataObjectFieldName = $name;
         $this->fileFieldName = $fileFieldName;
         $this->fileClassName = $SNG->has_one($this->fileFieldName);
         if (!$this->fileClassName) {
             die("<strong>FileDataObjectManager::__construct():</strong>" . _t('FileDataObjectManager.FILERELATION', 'Could not determine file relationship'));
         }
     }
     $this->controllerClassName = $controller->class;
     if ($key = array_search($this->controllerClassName, $SNG->stat('has_one'))) {
         $this->controllerFieldName = $key;
     } else {
         $this->controllerFieldName = $this->controllerClassName;
     }
     $this->controllerID = $controller->ID;
     // Check for allowed file types
     if ($types = Object::get_static($this->fileClassName, 'allowed_file_types')) {
         $this->setAllowedFileTypes($types);
     }
 }