Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 protected function loadFiletree(DataContainerInterface $objDc)
 {
     $table = $objDc->getEnvironment()->getDataDefinition()->getName();
     $arrData['strTable'] = $table;
     $arrData['id'] = self::getAjaxName() ?: $objDc->getId();
     $arrData['name'] = self::getPost('name');
     /** @var \FileTree $objWidget */
     $objWidget = new $GLOBALS['BE_FFL']['fileTree']($arrData, $objDc);
     // Load a particular node.
     if (self::getPost('folder', true) != '') {
         echo $objWidget->generateAjax(self::getPost('folder', true), self::getPost('field'), intval(self::getPost('level')));
     } else {
         // Reload the whole tree.
         $user = \BackendUser::getInstance();
         $strTree = '';
         $path = $GLOBALS['TL_DCA'][$table]['fields'][self::getPost('field')]['eval']['path'];
         // Set a custom path.
         if (strlen($GLOBALS['TL_DCA'][$table]['fields'][self::getPost('field')]['eval']['path'])) {
             $strTree = $objWidget->generateAjax($GLOBALS['TL_DCA'][$table]['fields'][self::getPost('field')]['eval']['path'], self::getPost('field'), intval(self::getPost('level')));
         } elseif ($user->isAdmin) {
             $strTree = $objWidget->generateAjax($GLOBALS['TL_CONFIG']['uploadPath'], self::getPost('field'), intval(self::getPost('level')));
         } else {
             foreach ($this->eliminateNestedPaths($this->User->filemounts) as $node) {
                 $strTree .= $objWidget->generateAjax($node, self::getPost('field'), intval(self::getPost('level')), true);
             }
         }
         echo $strTree;
     }
     exit;
 }
Esempio n. 2
0
 /**
  * Parse the template.
  *
  * @return string
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 public function generate()
 {
     $GLOBALS['TL_CSS'][] = 'system/modules/metamodels/assets/css/style.css';
     $arrModule = $GLOBALS['BE_MOD']['metamodels']['metamodels'];
     // Custom action (if key is not defined in config.php the default action will be called).
     if (\Input::get('key') && isset($arrModule[\Input::get('key')])) {
         Callbacks::call($arrModule[\Input::get('key')], $this, $arrModule);
     }
     $act = \Input::get('act');
     if (!strlen($act)) {
         $act = 'showAll';
     }
     return $this->dataContainer->getEnvironment()->getController()->handle(new Action($act));
 }
Esempio n. 3
0
 /**
  * Handle the post actions from DcGeneral.
  *
  * @param DataContainerInterface $objDc The data container.
  *
  * @return void
  */
 public function executePostActions($objDc)
 {
     header('Content-Type: text/html; charset=' . $GLOBALS['TL_CONFIG']['characterSet']);
     $action = $objDc->getEnvironment()->getInputProvider()->getValue('action');
     switch ($action) {
         case 'toggleFeatured':
             // This is impossible to handle generically in DcGeneral.
         // This is impossible to handle generically in DcGeneral.
         case 'toggleSubpalette':
             // DcGeneral handles sub palettes differently.
             return;
             // Load nodes of the page structure tree. Compatible between 2.X and 3.X.
         // Load nodes of the page structure tree. Compatible between 2.X and 3.X.
         case 'loadStructure':
             $this->loadStructure($objDc);
             break;
             // Load nodes of the file manager tree.
         // Load nodes of the file manager tree.
         case 'loadFileManager':
             $this->loadFileManager($objDc);
             break;
             // Load nodes of the page tree.
         // Load nodes of the page tree.
         case 'loadPagetree':
             $this->loadPagetree($objDc);
             break;
             // Load nodes of the file tree.
         // Load nodes of the file tree.
         case 'loadFiletree':
             $this->loadFiletree($objDc);
             break;
             // Reload the page/file picker.
         // Reload the page/file picker.
         case 'reloadPagetree':
             $this->reloadPagetree($objDc);
             break;
         case 'reloadFiletree':
             $this->reloadFiletree($objDc);
             break;
             // Pass unknown actions to original Contao handler.
         // Pass unknown actions to original Contao handler.
         default:
             $ajax = new \Ajax($action);
             $ajax->executePreActions();
             $ajax->executePostActions(new DcCompat($objDc->getEnvironment()));
             break;
     }
 }
Esempio n. 4
0
 /**
  * Reload the file tree.
  *
  * @param string                 $strType The type.
  *
  * @param DataContainerInterface $objDc   The data container.
  *
  * @return void
  */
 protected function reloadTree($strType, DataContainerInterface $objDc)
 {
     $environment = $objDc->getEnvironment();
     $input = $environment->getInputProvider();
     $serializedId = $input->hasParameter('id') ? $input->getParameter('id') : null;
     $fieldName = $input->hasValue('name') ? $input->getValue('name') : null;
     // Handle the keys in "edit multiple" mode.
     if (self::getGet('act') == 'editAll') {
         // TODO: change here when implementing editAll.
         $serializedId = preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', $fieldName);
         $field = preg_replace('/(.*)_[0-9a-zA-Z]+$/', '$1', $fieldName);
     }
     if (!is_null($serializedId)) {
         $id = IdSerializer::fromSerialized($serializedId);
         $dataProvider = $objDc->getEnvironment()->getDataProvider($id->getDataProviderName());
         $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($id->getId()));
         if (is_null($model)) {
             $this->log('A record with the ID "' . $serializedId . '" does not exist in "' . $objDc->getEnvironment()->getDataDefinition()->getName() . '"', 'Ajax executePostActions()', TL_ERROR);
             header('HTTP/1.1 400 Bad Request');
             die('Bad Request');
         }
     }
     $varValue = $this->getTreeValue($strType, $input->getValue('value'));
     $strKey = $strType . 'Tree';
     // Set the new value.
     if (isset($model)) {
         $model->setProperty($fieldName, $varValue);
         $arrAttribs['activeRecord'] = $model;
     } else {
         $arrAttribs['activeRecord'] = null;
     }
     $arrAttribs['id'] = $fieldName;
     $arrAttribs['name'] = $fieldName;
     $arrAttribs['value'] = $varValue;
     $arrAttribs['strTable'] = $objDc->getEnvironment()->getDataDefinition()->getName();
     $arrAttribs['strField'] = $fieldName;
     /** @var \Widget $objWidget */
     $objWidget = new $GLOBALS['BE_FFL'][$strKey]($arrAttribs);
     echo $objWidget->generate();
     exit;
 }