/** * Constructor * @param $strName * @param DataContainer $objDataContainer */ public function __construct($strName, DataContainer $objDataContainer) { $definition =& $objDataContainer->getDefinition(); if (!isset($definition['palettes'][$strName])) { $definition['palettes'][$strName] = ''; } parent::__construct($strName, $objDataContainer, $definition['palettes'][$strName]); $this->loadFromDefinition(); }
/** * Get a data container * @param string $strName * * @return DataContainer * * @throws \RuntimeException */ public static function getDataContainer($strName) { BackendBindings::loadDataContainer($strName); BackendBindings::loadLanguageFile($strName); if (!isset($GLOBALS['TL_DCA'][$strName])) { throw new \RuntimeException("DataContainer {$strName} does not exist."); } return DataContainer::getInstance($strName); }
/** * @return string */ protected function getDefaultError() { if (\Input::get('act') != '') { $defaultError = sprintf('User "%s" has not enough permission to run action "%s" for DataContainer "%s"', \BackendUser::getInstance()->username, \Input::get('act'), $this->definition->getName()); if (\Input::get('id') != '') { $defaultError .= ' on item with ID "' . \Input::get('id') . '"'; } } else { $defaultError = sprintf('User "%s" has not enough permission to access module "%s"', \BackendUser::getInstance()->username, \Input::get('do')); } return $defaultError; }
/** * Translate a key * * If key starts with a trailing slash, it tries to find it in the global language array. Otherwise it will * have a look into the data container language vars * * @param $key * @return string */ public function translate($key) { $chunks = explode('/', $key); if (substr($key, 0, 1) == '/') { $value = $GLOBALS['TL_LANG']; array_shift($chunks); } else { $value = $GLOBALS['TL_LANG'][$this->definition->getName()]; } foreach ($chunks as $chunk) { if (!isset($value[$chunk])) { return ''; } $value = $value[$chunk]; } return $value; }
public function testGetProperty() { $this->assertInstanceOf('DcaTools\\Definition\\Property', Definition::getProperty('tl_test', 'test')); $this->assertEquals($this->objDataContainer->getProperty('test'), Definition::getProperty('tl_test', 'test')); }
public function testHasSelector() { $this->assertTrue($this->objDataContainer->hasSelectors()); $this->assertTrue($this->objDataContainer->hasSelector('done')); $this->assertFalse($this->objDataContainer->hasSelector('test')); }
/** * Constructor * @param string $strName * @param DataContainer $objDataContainer */ public function __construct($strName, DataContainer $objDataContainer) { $definition =& $objDataContainer->getDefinition(); parent::__construct($strName, $objDataContainer, $definition['list']['operations'][$strName]); }
/** * @param string $strName * @param DataContainer $objDataContainer * @param PropertyContainer $objParent */ public function __construct($strName, DataContainer $objDataContainer, PropertyContainer $objParent = null) { $arrDefinition =& $objDataContainer->getDefinition(); parent::__construct($strName, $objDataContainer, $arrDefinition['fields'][$strName]); $this->objParent = $objParent === null ? $objDataContainer : $objParent; }