/** * Call the oncreate_callback. * * @param mixed $insertID The id from the new record. * * @param array $arrRecord The new record. * * @return void */ public function oncreateCallback($insertID, $arrRecord) { // Load DCA $arrDCA = $this->objDC->getDCA(); // Call the oncreate_callback if (is_array($arrDCA['config']['oncreate_callback'])) { foreach ($arrDCA['config']['oncreate_callback'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($this->objDC->getTable(), $insertID, $arrRecord, $this->objDC); } } }
protected function viewTree($intMode = 5) { // Init some Vars switch ($intMode) { case 5: $treeClass = 'tree'; break; case 6: $treeClass = 'tree_xtnd'; break; } // Label + Icon $strLabelText = strlen($this->getDC()->arrDCA['config']['label']) == 0 ? 'DC General Tree View Ultimate' : $this->getDC()->arrDCA['config']['label']; $strLabelIcon = strlen($this->getDC()->arrDCA['list']['sorting']['icon']) ? $this->getDC()->arrDCA['list']['sorting']['icon'] : 'pagemounts.gif'; // Rootpage pasteinto if ($this->getDC()->isClipboard()) { $arrClipboard = $this->getDC()->getClipboard(); // TODO: @CS we definately need into and after handling here instead of different modes. $imagePasteInto = $this->generateImage('pasteinto.gif', $GLOBALS['TL_LANG'][$this->getDC()->getTable()]['pasteinto'][0], 'class="blink"'); $strRootPasteinto = '<a href="' . $this->addToUrl('act=' . $arrClipboard['mode'] . '&mode=2&after=0&pid=0&id=' . $arrClipboard['id'] . '&childs=' . $arrClipboard['childs']) . '" title="' . specialchars($GLOBALS['TL_LANG'][$this->getDC()->getTable()]['pasteinto'][0]) . '" onclick="Backend.getScrollOffset()">' . $imagePasteInto . '</a> '; // Callback for paste btn. $strButtonCallback = $this->getDC()->getCallbackClass()->pasteButtonCallback($this->getDC(), $this->getDC()->getDataProvider($this->getDC()->getTable())->getEmptyModel()->getPropertiesAsArray(), $this->getDC()->getTable(), false, $arrClipboard, null, null); if ($strButtonCallback !== false) { $strRootPasteinto = $strButtonCallback; } } // Create treeview $strHTML = $this->generateTreeView($this->getDC()->getCurrentCollecion(), $intMode, $treeClass); // Build template $objTemplate = new BackendTemplate('dcbe_general_treeview'); $objTemplate->treeClass = 'tl_' . $treeClass; $objTemplate->tableName = strlen($this->objDC->getTable()) ? $this->objDC->getTable() : 'none'; $objTemplate->strLabelIcon = $this->generateImage($strLabelIcon); $objTemplate->strLabelText = $strLabelText; $objTemplate->strHTML = $strHTML; $objTemplate->intMode = $intMode; $objTemplate->strRootPasteinto = $strRootPasteinto; // Add breadcrumb, if we have one $strBreadcrumb = $this->breadcrumb(); if ($strBreadcrumb != null) { $objTemplate->breadcrumb = $strBreadcrumb; } // Return :P return $objTemplate->parse(); }
/** * Callback and startpoint for this programm. * * @param DC_General $objDC * * @return array */ public function generateBreadcrumbItems($objDC) { // Store init id. $this->intID = $objDC->getId(); $arrReturn = array(); // Build navigation. // Each get*Level() call will alter the id property to the next pid. switch ($objDC->getTable()) { case 'tl_metamodel_attribute': $arrReturn[] = $this->getSecondLevel('tl_metamodel_attribute', 'fields.png'); break; case 'tl_metamodel_rendersetting': $arrReturn[] = $this->getThirdLevel('tl_metamodel_rendersetting', 'tl_metamodel_rendersettings', 'render_setting.png'); case 'tl_metamodel_rendersettings': $arrReturn[] = $this->getSecondLevel('tl_metamodel_rendersettings', 'render_settings.png'); break; case 'tl_metamodel_dcasetting': if (Input::getInstance()->get('subpaletteid')) { $arrReturn[] = $this->getFourthLevel('metamodel_dcasetting_subpalette', 'tl_metamodel_dcasetting', 'dca_subpalette.png'); } $arrReturn[] = $this->getThirdLevel('tl_metamodel_dcasetting', 'tl_metamodel_dca', 'dca_setting.png'); case 'tl_metamodel_dca': $arrReturn[] = $this->getSecondLevel('tl_metamodel_dca', 'dca.png'); break; case 'tl_metamodel_filtersetting': $arrReturn[] = $this->getThirdLevel('tl_metamodel_filtersetting', 'tl_metamodel_filter', 'filter_setting.png'); case 'tl_metamodel_filter': $arrReturn[] = $this->getSecondLevel('tl_metamodel_filter', 'filter.png'); break; default: break; } // Always add root from mm as first entry. $arrReturn[] = $this->getFirstLevel(); // Return array. return array_reverse($arrReturn); }
/** * Create a variant of the model currently loaded. * * @param DC_General $objDC The data container holding the current model. * * @return void */ public function createvariant(DC_General $objDC) { // Check if table is editable. if (!$objDC->isEditable()) { $this->log('Table ' . $objDC->getTable() . ' is not editable', 'DC_General - Controller - edit()', TL_ERROR); $this->redirect('contao/main.php?act=error'); } // Load fields. $objDC->loadEditableFields(); $objDC->setWidgetID($objDC->getId()); // Check if we have fields. if (!$objDC->hasEditableFields()) { $this->redirect($this->getReferer()); } // Load rich text editor. $objDC->preloadTinyMce(); // Set buttons. $objDC->addButton('save'); $objDC->addButton('saveNclose'); // Load record from data provider. $objDBModel = $objDC->getDataProvider()->createVariant($objDC->getDataProvider()->getEmptyConfig()->setId($objDC->getId())); if ($objDBModel == null) { $objDBModel = $objDC->getDataProvider()->getEmptyModel(); } $objDC->setCurrentModel($objDBModel); // Check if we have a auto submit. if ($objDC->isAutoSubmitted()) { // Process input and update changed properties. foreach (array_keys($objDC->getFieldList()) as $key) { $varNewValue = $objDC->processInput($key); if ($objDBModel->getProperty($key) != $varNewValue) { $objDBModel->setProperty($key, $varNewValue); } } $objDC->setCurrentModel($objDBModel); } // Check submit. if ($objDC->isSubmitted() == true) { // @codingStandardsIgnoreStart - we know that access to $_POST is discouraged. if (isset($_POST['save'])) { $this->getDC()->updateModelFromPOST(); // Process input and update changed properties. if ($this->doSave($objDC) !== false) { // Call the on create callbacks. $objDC->getCallbackClass()->oncreateCallback($objDBModel->getID(), $objDBModel->getPropertiesAsArray()); // Log the creation. $this->log(sprintf('A new entry in table "%s" has been created (ID: %s)', $objDC->getTable(), $objDBModel->getID()), 'DC_General - Controller - createvariant()', TL_GENERAL); // Redirect to edit mode. $this->redirect($this->addToUrl('id=' . $objDBModel->getID() . '&act=edit')); } } elseif (isset($_POST['saveNclose'])) { $this->getDC()->updateModelFromPOST(); // Process input and update changed properties. if ($this->doSave($objDC) !== false) { setcookie('BE_PAGE_OFFSET', 0, 0, '/'); // @codingStandardsIgnoreStart - we know that access to $_SESSION is discouraged. $_SESSION['TL_INFO'] = array(); $_SESSION['TL_ERROR'] = array(); $_SESSION['TL_CONFIRM'] = array(); // @codingStandardsIgnoreEnd $this->redirect($this->getReferer()); } } // Maybe Callbacks? } }