Provide methods to handle data container arrays.
Inheritance: extends Backend
 /**
  * @param DataContainer $objDC
  * @return DataContainer
  */
 public function translateDCObject(DataContainer $objDC)
 {
     // Get table
     $strTable = $objDC->current()->getTable();
     // Load current data container
     Controller::loadDataContainer($strTable);
     if (count($GLOBALS['TL_DCA'][$strTable]['fields']) > 0) {
         foreach ($GLOBALS['TL_DCA'][$strTable]['fields'] as $field => $arrValues) {
             $objDC->{$field} = $this->translateField($arrValues['inputType'], $objDC->{$field});
         }
     }
     return $objDC;
 }
Beispiel #2
0
 /**
  * Initialize the object
  *
  * @param string $strTable
  */
 public function __construct($strTable)
 {
     parent::__construct();
     $this->intId = \Input::get('id');
     // Check whether the table is defined
     if ($strTable == '' || !isset($GLOBALS['TL_DCA'][$strTable])) {
         $this->log('Could not load data container configuration for "' . $strTable . '"', __METHOD__, TL_ERROR);
         trigger_error('Could not load data container configuration', E_USER_ERROR);
     }
     // Build object from global configuration array
     $this->strTable = $strTable;
     // Call onload_callback (e.g. to check permissions)
     if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) {
         foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $this->{$callback}[0]->{$callback}[1]($this);
             } elseif (is_callable($callback)) {
                 $callback($this);
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Return an object property
  *
  * @param string $strKey
  *
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'id':
             return $this->intId;
             break;
         case 'parentTable':
             return $this->ptable;
             break;
         case 'childTable':
             return $this->ctable;
             break;
         case 'rootIds':
             return $this->root;
             break;
         case 'createNewVersion':
             return $this->blnCreateNewVersion;
             break;
     }
     return parent::__get($strKey);
 }
Beispiel #4
0
 /**
  * @param DataContainer $dc
  * @return array
  */
 protected function getParameters(DataContainer $dc)
 {
     if (!$dc->activeRecord) {
         return array();
     }
     $dc->loadDataContainer($dc->table);
     $strType = $this->getType($dc);
     $arrParameters = array();
     $arrFields = $GLOBALS['TL_DCA'][$dc->table]['fields'];
     if (is_array($arrFields)) {
         foreach ($arrFields as $strField => $arrField) {
             if (isset($dc->activeRecord->{$strField})) {
                 $arrParameters[$strField] = $this->renderParameterValue($dc->table, $this->getAccountLanguage($dc), $strField, $dc->activeRecord->{$strField});
             }
         }
     }
     // Replace the password, because it's generated new
     $arrParameters['password'] = $this->getPostPassword($dc->id);
     // HOOK: replaceAccountmailParameters
     if (isset($GLOBALS['TL_HOOKS']['replaceAccountmailParameters']) && is_array($GLOBALS['TL_HOOKS']['replaceAccountmailParameters'])) {
         foreach ($GLOBALS['TL_HOOKS']['replaceAccountmailParameters'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $arrParameters = $this->{$callback}[0]->{$callback}[1]($strType, $arrParameters, $dc);
             } elseif (is_callable($callback)) {
                 $arrParameters = $callback($strType, $arrParameters, $dc);
             }
         }
     }
     return $arrParameters;
 }
Beispiel #5
0
 /**
  * Return an object property
  *
  * @param string $strKey
  *
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'path':
             return $this->strPath;
             break;
         case 'extension':
             return $this->strExtension;
             break;
         case 'createNewVersion':
             return $this->blnCreateNewVersion;
             break;
         case 'isDbAssisted':
             return $this->blnIsDbAssisted;
             break;
     }
     return parent::__get($strKey);
 }