/** * Disable/enable a user group * @param integer * @param boolean */ public function toggleVisibility($intId, $blnVisible) { // Check permissions to edit $objInput = \Input::getInstance(); $objInput->setGet('id', $intId); $objInput->setGet('act', 'toggle'); #$this->checkPermission(); // Check permissions to publish if (!$this->User->isAdmin && !$this->User->hasAccess('tl_glossary_term::published', 'alexf')) { $this->log('Not enough permissions to publish/unpublish item ID "' . $intId . '"', 'tl_glossary_term toggleVisibility', TL_ERROR); $this->redirect('contao/main.php?act=error'); } $objVersions = new \Versions('tl_glossary_term', $intId); $objVersions->initialize(); // Trigger the save_callback if (is_array($GLOBALS['TL_DCA']['tl_glossary_term']['fields']['published']['save_callback'])) { foreach ($GLOBALS['TL_DCA']['tl_glossary_term']['fields']['published']['save_callback'] as $callback) { $this->import($callback[0]); $blnVisible = $this->{$callback}[0]->{$callback}[1]($blnVisible, $this); } } // Update the database \Database::getInstance()->prepare("UPDATE tl_glossary_term SET tstamp=" . time() . ", published='" . ($blnVisible ? 1 : '') . "' WHERE id=?")->execute($intId); $objVersions->create(); $this->log('A new version of record "tl_glossary_term.id=' . $intId . '" has been created', 'tl_revolutionslider_slides toggleVisibility()', TL_GENERAL); }
/** * @param DC_General $dc */ public function renderPreviewView(EnvironmentInterface $environment) { /** @var EventDispatcher $eventDispatcher */ $eventDispatcher = $GLOBALS['container']['event-dispatcher']; $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, new LoadLanguageFileEvent('avisota_message_preview')); $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, new LoadLanguageFileEvent('orm_avisota_message')); $input = \Input::getInstance(); $messageRepository = EntityHelper::getRepository('Avisota\\Contao:Message'); $messageId = IdSerializer::fromSerialized($input->get('id') ? $input->get('id') : $input->get('pid')); $message = $messageRepository->find($messageId->getId()); if (!$message) { $environment = \Environment::getInstance(); $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent(preg_replace('#&(act=preview|id=[a-f0-9\\-]+)#', '', $environment->request))); } $modules = new \StringBuilder(); /** @var \Avisota\Contao\Message\Core\Send\SendModuleInterface $module */ foreach ($GLOBALS['AVISOTA_SEND_MODULE'] as $className) { $class = new \ReflectionClass($className); $module = $class->newInstance(); $modules->append($module->run($message)); } $context = array('message' => $message, 'modules' => $modules); $template = new \TwigTemplate('avisota/backend/preview', 'html5'); return $template->parse($context); }
/** * Initialize object stack. * * @return void */ public static function intializeObjectStack() { \Config::getInstance(); \Environment::getInstance(); \Input::getInstance(); static::getUser(); \Database::getInstance(); }
/** * Compat wrapper for contao 2.X and 3.X - delegates to the relevant input handler. * * @param string $key The key to retrieve. * * @param bool $blnDecodeEntities Decode the entities. * * @return mixed */ protected static function getPost($key, $blnDecodeEntities = false) { // TODO: use dependency injection here. if (version_compare(VERSION, '3.0', '>=')) { return \Input::post($key, $blnDecodeEntities); } return \Input::getInstance()->post($key, $blnDecodeEntities); }
/** * @return MessageCategory|null */ public static function resolveCategoryFromInput() { $input = \Input::getInstance(); $id = $input->get('id'); $pid = $input->get('pid'); $modelId = null; $parentModelId = null; /** @var MessageCategory $category */ $category = null; /** @var Message $message */ $message = null; /** @var MessageContent $content */ $content = null; if ($id) { $modelId = IdSerializer::fromSerialized($id); } if ($pid) { $parentModelId = IdSerializer::fromSerialized($pid); } // $id or $pid is a category ID if ($modelId && $modelId->getDataProviderName() == 'orm_avisota_message_category') { $repository = EntityHelper::getRepository('Avisota\\Contao:MessageCategory'); $category = $repository->find($modelId->getId()); } else { if ($parentModelId && $parentModelId->getDataProviderName() == 'orm_avisota_message_category') { $repository = EntityHelper::getRepository('Avisota\\Contao:MessageCategory'); $category = $repository->find($parentModelId->getId()); } else { if ($modelId && $modelId->getDataProviderName() == 'orm_avisota_message') { $repository = EntityHelper::getRepository('Avisota\\Contao:Message'); $message = $repository->find($modelId->getId()); $category = $message->getCategory(); } else { if ($parentModelId && $parentModelId->getDataProviderName() == 'orm_avisota_message') { $repository = EntityHelper::getRepository('Avisota\\Contao:Message'); $message = $repository->find($parentModelId->getId()); $category = $message->getCategory(); } else { if ($modelId && $modelId->getDataProviderName() == 'orm_avisota_message_content') { $repository = EntityHelper::getRepository('Avisota\\Contao:MessageContent'); $content = $repository->find($modelId->getId()); $message = $content->getMessage(); $category = $message->getCategory(); } else { if ($parentModelId && $parentModelId->getDataProviderName() == 'orm_avisota_message_content') { $repository = EntityHelper::getRepository('Avisota\\Contao:MessageContent'); $content = $repository->find($parentModelId->getId()); $message = $content->getMessage(); $category = $message->getCategory(); } } } } } } return $category; }
/** * Retrieve all filter parameters from the input class for the specified filter setting. * * @param MetaModelList $objItemRenderer * * @return string[] */ protected function getFilterParameters($objItemRenderer) { $arrReturn = array(); foreach (array_keys($objItemRenderer->getFilterSettings()->getParameterFilterNames()) as $strName) { $varValue = \Input::getInstance()->get($strName); if (is_string($varValue)) { $arrReturn[$strName] = $varValue; } } return $arrReturn; }
protected function execute(Message $message, \BackendUser $user) { global $container; /** @var \Symfony\Component\EventDispatcher\EventDispatcher $eventDispatcher */ $eventDispatcher = $GLOBALS['container']['event-dispatcher']; $input = \Input::getInstance(); $user = $input->get('recipient_user'); /** @var \Doctrine\DBAL\Connection $connection */ $connection = $container['doctrine.connection.default']; $queryBuilder = $connection->createQueryBuilder(); /** @var \Doctrine\DBAL\Statement $statement */ $statement = $queryBuilder->select('u.*')->from('tl_user', 'u')->where('id=:id')->setParameter(':id', $user)->execute(); $userData = $statement->fetch(); if (!$userData) { $_SESSION['AVISOTA_SEND_PREVIEW_TO_USER_EMPTY'] = true; header('Location: ' . $url); exit; } $idSerializer = new IdSerializer(); $idSerializer->setDataProviderName('orm_avisota_message'); $idSerializer->setId($message->getId()); $pidSerializer = new IdSerializer(); $pidSerializer->setDataProviderName('orm_avisota_message_category'); $pidSerializer->setId($message->getCategory()->getId()); $environment = Environment::getInstance(); $url = sprintf('%scontao/main.php?do=avisota_newsletter&table=orm_avisota_message&act=preview&id=%s&pid=%s', $environment->base, $idSerializer->getSerialized(), $pidSerializer->getSerialized()); if ($message->getCategory()->getViewOnlinePage()) { $event = new LoadLanguageFileEvent('avisota_message'); $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, $event); $viewOnlineLink = sprintf($GLOBALS['TL_LANG']['avisota_message']['viewOnline'], $url); } else { $viewOnlineLink = false; } $event = new \Avisota\Contao\Core\Event\CreateFakeRecipientEvent($message); $eventDispatcher->dispatch(\Avisota\Contao\Core\CoreEvents::CREATE_FAKE_RECIPIENT, $event); $recipient = $event->getRecipient(); $recipient->setEmail($userData['email']); $additionalData = array('view_online_link' => $viewOnlineLink); /** @var \Avisota\Contao\Message\Core\Renderer\MessageRendererInterface $renderer */ $renderer = $container['avisota.message.renderer']; $messageTemplate = $renderer->renderMessage($message); $messageMail = $messageTemplate->render($recipient, $additionalData); /** @var \Avisota\Transport\TransportInterface $transport */ $transport = $GLOBALS['container']['avisota.transport.' . $message->getQueue()->getTransport()->getId()]; $transport->send($messageMail); $event = new \ContaoCommunityAlliance\Contao\Bindings\Events\System\LoadLanguageFileEvent('avisota_message_preview'); $eventDispatcher->dispatch(\ContaoCommunityAlliance\Contao\Bindings\ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, $event); $_SESSION['TL_CONFIRM'][] = sprintf($GLOBALS['TL_LANG']['avisota_message_preview']['previewSend'], $recipient->getEmail()); header('Location: ' . $url); exit; }
/** * Modify field dca depending on loaded module * @param object, DataContainer * @return object, DataContainer */ public function modifyDCA(\DataContainer $objDC) { if (\Input::getInstance()->get('act') != 'edit') { return $objDC; } $objActiveRecord = \Database::getInstance()->prepare("SELECT * FROM " . $objDC->table . " WHERE id=?")->limit(1)->execute($objDC->id); if ($objActiveRecord->type == 'onepagewebsiteregular') { $GLOBALS['TL_DCA']['tl_module']['fields']['showLevel']['eval']['tl_class'] = ''; $GLOBALS['TL_DCA']['tl_module']['fields']['hardLimit']['eval']['tl_class'] = 'w50'; } if ($objActiveRecord->type == 'onepagewebsitenavigation') { $GLOBALS['TL_DCA']['tl_module']['fields']['rootPage'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['rootModule'], 'exclude' => false, 'inputType' => 'radio', 'options_callback' => array('OnePageWebsite\\Backend\\TableModule', 'getModules')); } return $objDC; }
/** * This initializes the Contao Singleton object stack as it must be, * when using singletons within the config.php file of an Extension. * * @return void */ protected static function initializeContaoObjectStack() { // all of these getInstance calls are neccessary to keep the instance stack intact // and therefore prevent an Exception in unknown on line 0. // Hopefully this will get fixed with Contao Reloaded or Contao 3. Config::getInstance(); Environment::getInstance(); Input::getInstance(); // request token became available in 2.11 if (version_compare(TL_VERSION, '2.11', '>=')) { RequestToken::getInstance(); } self::getUser(); Database::getInstance(); }
/** * This initializes the Contao Singleton object stack as it must be, * when using singletons within the config.php file of an Extension. * * @return bool */ protected static function initializeContaoObjectStack() { if (!file_exists(TL_ROOT . '/system/config/localconfig.php')) { return false; } // all of these getInstance calls are neccessary to keep the instance stack intact // and therefore prevent an Exception in unknown on line 0. // Hopefully this will get fixed with Contao Reloaded or Contao 3. require_once TL_ROOT . '/system/config/localconfig.php'; Config::getInstance(); Environment::getInstance(); Input::getInstance(); self::getUser(); Database::getInstance(); return true; }
/** * Initialize the composer environment. */ public static function initialize() { if (version_compare(PHP_VERSION, COMPOSER_MIN_PHPVERSION, '<')) { return; } if (TL_MODE == 'BE') { $GLOBALS['TL_HOOKS']['loadLanguageFile']['composer'] = array('ContaoCommunityAlliance\\Contao\\Composer\\Client', 'disableOldClientHook'); $input = \Input::getInstance(); if ($input->get('do') == 'repository_manager') { $environment = \Environment::getInstance(); header('Location: ' . $environment->base . 'contao/main.php?do=composer'); exit; } } static::registerVendorClassLoader(); }
public function run() { $input = \Input::getInstance(); $messageRepository = \Contao\Doctrine\ORM\EntityHelper::getRepository('Avisota\\Contao:Message'); $messageId = $input->get('id'); $message = $messageRepository->find($messageId); /** @var \Avisota\Contao\Entity\Message $message */ if (!$message) { header("HTTP/1.0 404 Not Found"); echo '<h1>404 Not Found</h1>'; exit; } $user = \BackendUser::getInstance(); $user->authenticate(); $this->execute($message, $user); }
public function getClasses() { // only in backend if (TL_MODE == 'BE') { // order is important \BackendUser::getInstance(); \Database::getInstance(); \Config::getInstance(); \Environment::getInstance(); \Input::getInstance(); // init language files and start f module if (\Database::getInstance()->tableExists('tl_fmodules')) { $saveLanguage = $_SESSION['fm_language'] ? $_SESSION['fm_language'] : 'de'; \Backend::loadLanguageFile('tl_fmodules_language_pack', $saveLanguage); $dcaCreator = new DCACreator(); $dcaCreator->loadModules(); $dcaCreator->createLabels(); } } }
protected function executeQueue(EntityRepository $queueRepository) { global $container; $input = \Input::getInstance(); $executeId = $input->get('execute'); if ($executeId) { /** @var Queue $queueData */ $queueData = $queueRepository->find($executeId); if (!$queueData->getAllowManualSending()) { return; } $serviceName = sprintf('avisota.queue.%s', $queueData->getId()); /** @var QueueInterface $queue */ $queue = $container[$serviceName]; $this->Template->setName('avisota/backend/outbox_execute'); $this->Template->queue = $queue; $this->Template->config = $queueData; $GLOBALS['TL_CSS'][] = 'assets/avisota/core/css/be_outbox.css'; $GLOBALS['TL_JAVASCRIPT'][] = 'assets/avisota/core/js/Number.js'; $GLOBALS['TL_JAVASCRIPT'][] = 'assets/avisota/core/js/be_outbox.js'; } }
/** * {@inheritdoc} */ public function handle(\Input $input) { $outFile = new \File(self::OUT_FILE_PATHNAME); $pidFile = new \File(self::PID_FILE_PATHNAME); $output = $outFile->getContent(); $pid = $pidFile->getContent(); // We send special signal 0 to test for existance of the process which is much more bullet proof than // using anything like shell_exec() wrapped ps/pgrep magic (which is not available on all systems). $isRunning = (bool) posix_kill($pid, 0); $startTime = new \DateTime(); $startTime->setTimestamp(filectime(TL_ROOT . '/' . self::PID_FILE_PATHNAME)); $endTime = new \DateTime(); $endTime->setTimestamp($isRunning ? time() : filemtime(TL_ROOT . '/' . self::OUT_FILE_PATHNAME)); $uptime = $endTime->diff($startTime); $uptime = $uptime->format('%h h %I m %S s'); if (!$isRunning && \Input::getInstance()->post('close')) { $outFile->renameTo(UpdatePackagesController::OUTPUT_FILE_PATHNAME); $pidFile->delete(); $this->redirect('contao/main.php?do=composer&update=database'); } else { if ($isRunning && \Input::getInstance()->post('terminate')) { posix_kill($pid, SIGTERM); $this->reload(); } } $converter = new ConsoleColorConverter(); $output = $converter->parse($output); if (\Environment::getInstance()->isAjaxRequest) { header('Content-Type: application/json; charset=utf-8'); echo json_encode(array('output' => $output, 'isRunning' => $isRunning, 'uptime' => $uptime)); exit; } else { $template = new \BackendTemplate('be_composer_client_detached'); $template->output = $output; $template->isRunning = $isRunning; $template->uptime = $uptime; return $template->parse(); } }
public function run() { global $container; /** @var \Symfony\Component\EventDispatcher\EventDispatcher $eventDispatcher */ $eventDispatcher = $GLOBALS['container']['event-dispatcher']; $input = \Input::getInstance(); $messageRepository = \Contao\Doctrine\ORM\EntityHelper::getRepository('Avisota\\Contao:Message'); $messageId = $input->get('id'); /** @var \Avisota\Contao\Entity\Message $message */ $message = $messageRepository->find($messageId); if (!$message) { header("HTTP/1.0 404 Not Found"); echo '<h1>404 Not Found</h1>'; exit; } $user = BackendUser::getInstance(); $user->authenticate(); $event = new \Avisota\Contao\Core\Event\CreateFakeRecipientEvent($message); $eventDispatcher->dispatch(\Avisota\Contao\Core\CoreEvents::CREATE_FAKE_RECIPIENT, $event); $recipient = $event->getRecipient(); if ($message->getCategory()->getViewOnlinePage()) { $event = new LoadLanguageFileEvent('avisota_message'); $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, $event); $environment = \Environment::getInstance(); $url = sprintf($GLOBALS['TL_LANG']['avisota_message']['viewOnline'], sprintf('%ssystem/modules/avisota-message/web/preview.php?id=%s', $environment->base, $message->getId())); } else { $url = false; } $additionalData = array('view_online_link' => $url); /** @var \Avisota\Contao\Message\Core\Renderer\MessageRendererInterface $renderer */ $renderer = $container['avisota.message.renderer']; $messageTemplate = $renderer->renderMessage($message); $messagePreview = $messageTemplate->renderPreview($recipient, $additionalData); header('Content-Type: ' . $messageTemplate->getContentType() . '; charset=' . $messageTemplate->getContentEncoding()); header('Content-Disposition: inline; filename="' . $messageTemplate->getContentName() . '"'); echo $messagePreview; exit; }
/** * {@inheritdoc} */ public function handle(\Input $input) { $outFile = new \File(self::OUT_FILE_PATHNAME); $pidFile = new \File(self::PID_FILE_PATHNAME); $output = $outFile->getContent(); $pid = $pidFile->getContent(); $isRunning = $this->isPidStillRunning($pid); $startTime = new \DateTime(); $startTime->setTimestamp(filectime(TL_ROOT . '/' . self::PID_FILE_PATHNAME)); $endTime = new \DateTime(); $endTime->setTimestamp($isRunning ? time() : filemtime(TL_ROOT . '/' . self::OUT_FILE_PATHNAME)); $uptime = $endTime->diff($startTime); $uptime = $uptime->format('%h h %I m %S s'); if (!$isRunning && \Input::getInstance()->post('close')) { $outFile->renameTo(UpdatePackagesController::OUTPUT_FILE_PATHNAME); $pidFile->delete(); $this->redirect('contao/main.php?do=composer&update=database'); } else { if ($isRunning && \Input::getInstance()->post('terminate')) { $this->killPid($pid); $this->reload(); } } $converter = new ConsoleColorConverter(); $output = $converter->parse($output); if (\Environment::getInstance()->isAjaxRequest) { header('Content-Type: application/json; charset=utf-8'); echo json_encode(array('output' => $output, 'isRunning' => $isRunning, 'uptime' => $uptime)); exit; } else { $template = new \BackendTemplate('be_composer_client_detached'); $template->output = $output; $template->isRunning = $isRunning; $template->uptime = $uptime; return $template->parse(); } }
/** * Compile the current element */ public function generate() { Runtime::setUp(); $this->loadLanguageFile('composer_client'); $input = \Input::getInstance(); // check the environment $errors = Runtime::checkEnvironment(); if ($errors !== true && count($errors)) { $template = new \BackendTemplate('be_composer_client_errors'); $template->errors = $errors; return $template->parse(); } // check composer.phar is installed if (!file_exists(COMPOSER_DIR_ABSOULTE . '/composer.phar')) { // switch template $template = new \BackendTemplate('be_composer_client_install_composer'); // do install composer library if ($input->post('install')) { $this->updateComposer(); $this->reload(); } return $template->parse(); } if (file_exists(TL_ROOT . '/' . DetachedController::PID_FILE_PATHNAME)) { $controller = new DetachedController(); $output = $controller->handle($input); return $output; } // update composer.phar if requested if ($input->get('update') == 'composer') { $this->updateComposer(); $this->redirect('contao/main.php?do=composer'); } // load composer and the composer class loader $this->loadComposer(); /** @var RootPackage $rootPackage */ $rootPackage = $this->composer->getPackage(); $extra = $rootPackage->getExtra(); $controller = null; // do migration if (!array_key_exists('contao', $extra) || !array_key_exists('migrated', $extra['contao']) || !$extra['contao']['migrated']) { $controller = new MigrationWizardController(); } // do update database if ($input->get('update') == 'database') { $controller = new UpdateDatabaseController(); } // do clear composer cache if ($input->get('clear') == 'composer-cache') { $controller = new ClearComposerCacheController(); } // show tools dialog if ($input->get('tools') == 'dialog') { $controller = new ToolsController(); } // show resync tool if ($input->get('tools') == 'resync') { $controller = new ResyncController(); } // show settings dialog if ($input->get('settings') == 'dialog') { $controller = new SettingsController(); } // show experts editor if ($input->get('settings') == 'experts') { $controller = new ExpertsEditorController(); } // show dependency graph if ($input->get('show') == 'dependency-graph') { $controller = new DependencyGraphController(); } // do search if ($input->get('keyword')) { $controller = new SearchController(); } // do install if ($input->get('install')) { $controller = new DetailsController(); } // do solve if ($input->get('solve')) { $controller = new SolveController(); } // do update packages if ($input->get('update') == 'packages' || $input->post('update') == 'packages') { $controller = new UpdatePackagesController(); } // do pin/unpin package version if ($input->post('pin')) { $controller = new PinController(); } // do remove package if ($input->post('remove')) { $controller = new RemovePackageController(); } if (!$controller) { $controller = new InstalledController(); } $controller->setConfigPathname($this->configPathname); $controller->setIo($this->io); $controller->setComposer($this->composer); $output = $controller->handle($input); chdir(TL_ROOT); return $output; }
/** * Initianize get parameter */ protected function initGetParams() { // Get Client id if (strlen(\Input::getInstance()->get("id")) != 0) { $this->intClientID = intval(\Input::getInstance()->get("id")); } else { $this->mixStep = self::STEP_ERROR_FILES; return; } // Load information $this->loadClientInformation(); // Get next step if (strlen(\Input::getInstance()->get("step")) != 0) { $this->mixStep = \Input::getInstance()->get("step"); } else { $this->mixStep = self::STEP_SHOW_FILES; } }
/** * Initianize get parameter */ protected function initGetParams() { // Get Client id if (strlen(\Input::getInstance()->get('id')) != 0) { $this->intClientID = intval(\Input::getInstance()->get('id')); } else { $this->mixStep = self::STEP_ERROR_DB; return; } // Get next step if (strlen(\Input::getInstance()->get('step')) != 0) { $this->mixStep = \Input::getInstance()->get('step'); } else { $this->mixStep = self::STEP_NORMAL_DB; } // Get direction if (strlen(\Input::getInstance()->get('direction')) != 0) { $this->strMode = \Input::getInstance()->get('direction'); } }
/** * {@inheritDoc} */ public function hasValue($strKey) { return \Input::getInstance()->post($strKey) !== null; }
<?php /** * @package contao-bootstrap * @author David Molineus <*****@*****.**> * @license LGPL 3+ * @copyright 2013-2015 netzmacht creative David Molineus */ /** * Table tl_columnset */ $GLOBALS['TL_DCA']['tl_columnset'] = array('config' => array('dataContainer' => 'Table', 'enableVersioning' => true, 'onload_callback' => array(array('Netzmacht\\Bootstrap\\Grid\\DataContainer\\ColumnSet', 'appendColumnSizesToPalette')), 'sql' => array('keys' => array('id' => 'primary'))), 'list' => array('label' => array('fields' => array('title', 'columns'), 'format' => '%s <span style="color:#ccc;">[%s ' . $GLOBALS['TL_LANG']['tl_columnset']['formatColumns'] . ']</span>'), 'sorting' => array('mode' => 2, 'flag' => 1, 'fields' => array('title', 'columns'), 'panelLayout' => 'sort,search,limit'), 'global_operations' => array('all' => array('label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'href' => 'act=select', 'class' => 'header_edit_all', 'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"')), 'operations' => array('edit' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['edit'], 'href' => 'act=edit', 'icon' => 'edit.gif'), 'copy' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['copy'], 'href' => 'act=copy', 'icon' => 'copy.gif', 'attributes' => 'onclick="Backend.getScrollOffset()"'), 'delete' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['delete'], 'href' => 'act=delete', 'icon' => 'delete.gif', 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'), 'toggle' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['toggle'], 'icon' => 'visible.gif', 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', 'button_callback' => function () { $callback = new Netzmacht\Bootstrap\Grid\DataContainer\ToggleIconCallback(\BackendUser::getInstance(), \Input::getInstance(), \Database::getInstance(), 'tl_columnset', 'published'); return call_user_func_array($callback, func_get_args()); }), 'show' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['show'], 'href' => 'act=show', 'icon' => 'show.gif'))), 'metapalettes' => array('default' => array('title' => array('title', 'description', 'columns'), 'columnset' => array('sizes'), 'expert' => array(':hide', 'resets', 'rowClass', 'customClasses'), 'published' => array('published'))), 'fields' => array('id' => array('sql' => "int(10) unsigned NOT NULL auto_increment"), 'pid' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'tstamp' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'title' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['title'], 'exclude' => true, 'sorting' => true, 'flag' => 1, 'search' => true, 'inputType' => 'text', 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''"), 'description' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['description'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''"), 'columns' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['columns'], 'exclude' => true, 'sorting' => true, 'flag' => 3, 'length' => 1, 'inputType' => 'select', 'options_callback' => array('Netzmacht\\Bootstrap\\Grid\\DataContainer\\ColumnSet', 'getColumns'), 'reference' => &$GLOBALS['TL_LANG']['tl_columnset'], 'eval' => array('submitOnChange' => true, 'chosen' => true), 'sql' => "int(10) unsigned NOT NULL default '0'"), 'sizes' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['sizes'], 'exclude' => true, 'inputType' => 'checkbox', 'options' => array('xs', 'sm', 'md', 'lg'), 'reference' => &$GLOBALS['TL_LANG']['tl_columnset'], 'eval' => array('multiple' => true, 'submitOnChange' => true), 'sql' => "mediumblob NULL"), 'resets' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['resets'], 'exclude' => true, 'inputType' => 'multiColumnWizard', 'eval' => array('columnFields' => array('column' => array('label' => $GLOBALS['TL_LANG']['tl_columnset']['column'], 'inputType' => 'select', 'options_callback' => array('Netzmacht\\Bootstrap\\Grid\\DataContainer\\ColumnSet', 'getColumnNumbers'), 'eval' => array('style' => 'width: 100px;', 'chosen' => true)), 'xs' => array('label' => $GLOBALS['TL_LANG']['tl_columnset']['xs'], 'inputType' => 'checkbox', 'eval' => array('style' => 'width: 80px;', 'includeBlankOption' => true)), 'sm' => array('label' => $GLOBALS['TL_LANG']['tl_columnset']['sm'], 'inputType' => 'checkbox', 'eval' => array('style' => 'width: 50px;', 'includeBlankOption' => true)), 'md' => array('label' => $GLOBALS['TL_LANG']['tl_columnset']['md'], 'inputType' => 'checkbox', 'eval' => array('style' => 'width: 50px;', 'includeBlankOption' => true)), 'lg' => array('label' => $GLOBALS['TL_LANG']['tl_columnset']['lg'], 'inputType' => 'checkbox', 'eval' => array('style' => 'width: 50px;', 'includeBlankOption' => true)))), 'sql' => "blob NULL"), 'customClasses' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['customClasses'], 'exclude' => true, 'inputType' => 'multiColumnWizard', 'eval' => array('columnFields' => array('column' => array('label' => $GLOBALS['TL_LANG']['tl_columnset']['column'], 'inputType' => 'select', 'options_callback' => array('Netzmacht\\Bootstrap\\Grid\\DataContainer\\ColumnSet', 'getColumnNumbers'), 'eval' => array('style' => 'width: 100px;', 'chosen' => true)), 'class' => array('label' => $GLOBALS['TL_LANG']['tl_columnset']['class'], 'inputType' => 'text', 'eval' => array('style' => 'width: 260px;')))), 'sql' => "blob NULL"), 'rowClass' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['rowClass'], 'exclude' => true, 'default' => '', 'inputType' => 'text', 'reference' => &$GLOBALS['TL_LANG']['tl_columnset'], 'eval' => array(), 'sql' => "varchar(64) NOT NULL default ''"), 'published' => array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['published'], 'exclude' => true, 'default' => '1', 'inputType' => 'checkbox', 'reference' => &$GLOBALS['TL_LANG']['tl_columnset'], 'eval' => array(), 'sql' => "char(1) NULL"))); // defining col set fields $colSetTemplate = array('exclude' => true, 'inputType' => 'multiColumnWizard', 'load_callback' => array(array('Netzmacht\\Bootstrap\\Grid\\DataContainer\\ColumnSet', 'createColumns')), 'eval' => array('includeBlankOption' => true, 'columnFields' => array('width' => array('label' => $GLOBALS['TL_LANG']['tl_columnset']['width'], 'inputType' => 'select', 'options_callback' => array('Netzmacht\\Bootstrap\\Grid\\DataContainer\\ColumnSet', 'getWidths'), 'eval' => array('style' => 'width: 100px;', 'chosen' => true)), 'offset' => array('label' => $GLOBALS['TL_LANG']['tl_columnset']['offset'], 'inputType' => 'select', 'options_callback' => array('Netzmacht\\Bootstrap\\Grid\\DataContainer\\ColumnSet', 'getOffsets'), 'reference' => ['null' => '0 '], 'eval' => array('style' => 'width: 100px;', 'includeBlankOption' => true, 'chosen' => true, 'isAssociative' => false)), 'order' => array('label' => $GLOBALS['TL_LANG']['tl_columnset']['order'], 'inputType' => 'select', 'options_callback' => array('Netzmacht\\Bootstrap\\Grid\\DataContainer\\ColumnSet', 'getColumnOrders'), 'eval' => array('style' => 'width: 160px;', 'includeBlankOption' => true, 'chosen' => true))), 'buttons' => array('copy' => false, 'delete' => false)), 'sql' => "blob NULL"); $colSetXsTemplate = $colSetTemplate; unset($colSetXsTemplate['eval']['columnFields']['order']); $GLOBALS['TL_DCA']['tl_columnset']['fields']['columnset_xs'] = array_merge($colSetXsTemplate, array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['columnset_xs'])); $GLOBALS['TL_DCA']['tl_columnset']['fields']['columnset_sm'] = array_merge($colSetTemplate, array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['columnset_sm'])); $GLOBALS['TL_DCA']['tl_columnset']['fields']['columnset_md'] = array_merge($colSetTemplate, array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['columnset_md'])); $GLOBALS['TL_DCA']['tl_columnset']['fields']['columnset_lg'] = array_merge($colSetTemplate, array('label' => &$GLOBALS['TL_LANG']['tl_columnset']['columnset_lg']));
<?php /** * Contao Open Source CMS * * @copyright MEN AT WORK 2014 * @package syncCto * @license GNU/LGPL * @filesource */ use ContaoCommunityAlliance\Contao\EventDispatcher\Event\CreateEventDispatcherEvent; $objInput = \Input::getInstance(); /** * Current syncCto version */ $GLOBALS['SYC_VERSION'] = '3.2.0'; /** * Back end modules */ $i = array_search('system', array_keys($GLOBALS['BE_MOD'])); array_insert($GLOBALS['BE_MOD'], $i + 1, array('syncCto' => array('syncCto_settings' => array('tables' => array('tl_syncCto_settings'), 'icon' => 'system/modules/syncCto/assets/images/nav/iconSettings.png'), 'synccto_clients' => array('tables' => array('tl_synccto_clients', 'tl_syncCto_clients_syncTo', 'tl_syncCto_clients_syncFrom', 'tl_syncCto_clients_showExtern'), 'icon' => 'system/modules/syncCto/assets/images/nav/iconClients.png', 'callback' => 'SyncCtoModuleClient', 'stylesheet' => 'system/modules/syncCto/assets/css/systemcheck.css'), 'syncCto_backups' => array('tables' => array('tl_syncCto_backup_file', 'tl_syncCto_backup_db', 'tl_syncCto_restore_file', 'tl_syncCto_restore_db'), 'icon' => 'system/modules/syncCto/assets/images/nav/iconBackups.png', 'callback' => 'SyncCtoModuleBackup'), 'syncCto_check' => array('icon' => 'system/modules/syncCto/assets/images/nav/iconCheck.png', 'callback' => 'SyncCtoModuleCheck', 'stylesheet' => 'system/modules/syncCto/assets/css/systemcheck.css')))); /** * DcGeneral event callbacks */ $GLOBALS['TL_EVENTS'][CreateEventDispatcherEvent::NAME][] = 'SyncCto\\DcGeneral\\Events\\Subscriber::registerEvents'; /** * Mime types */ $GLOBALS['SYC_CONFIG']['mime_types'] = array_merge((array) $GLOBALS['SYC_CONFIG']['mime_types'], array('xl' => array('application/excel', 'iconOFFICE.gif'), 'xls' => array('application/excel', 'iconOFFICE.gif'), 'hqx' => array('application/mac-binhex40', 'iconPLAIN.gif'), 'cpt' => array('application/mac-compactpro', 'iconPLAIN.gif'), 'bin' => array('application/macbinary', 'iconPLAIN.gif'), 'doc' => array('application/msword', 'iconOFFICE.gif'), 'word' => array('application/msword', 'iconOFFICE.gif'), 'cto' => array('application/octet-stream', 'iconCTO.gif'), 'dms' => array('application/octet-stream', 'iconPLAIN.gif'), 'lha' => array('application/octet-stream', 'iconPLAIN.gif'), 'lzh' => array('application/octet-stream', 'iconPLAIN.gif'), 'exe' => array('application/octet-stream', 'iconPLAIN.gif'), 'class' => array('application/octet-stream', 'iconPLAIN.gif'), 'so' => array('application/octet-stream', 'iconPLAIN.gif'), 'sea' => array('application/octet-stream', 'iconPLAIN.gif'), 'dll' => array('application/octet-stream', 'iconPLAIN.gif'), 'oda' => array('application/oda', 'iconPLAIN.gif'), 'pdf' => array('application/pdf', 'iconPDF.gif'), 'ai' => array('application/postscript', 'iconPLAIN.gif'), 'eps' => array('application/postscript', 'iconPLAIN.gif'), 'ps' => array('application/postscript', 'iconPLAIN.gif'), 'pps' => array('application/powerpoint', 'iconOFFICE.gif'), 'ppt' => array('application/powerpoint', 'iconOFFICE.gif'), 'smi' => array('application/smil', 'iconPLAIN.gif'), 'smil' => array('application/smil', 'iconPLAIN.gif'), 'mif' => array('application/vnd.mif', 'iconPLAIN.gif'), 'odc' => array('application/vnd.oasis.opendocument.chart', 'iconOFFICE.gif'), 'odf' => array('application/vnd.oasis.opendocument.formula', 'iconOFFICE.gif'), 'odg' => array('application/vnd.oasis.opendocument.graphics', 'iconOFFICE.gif'), 'odi' => array('application/vnd.oasis.opendocument.image', 'iconOFFICE.gif'), 'odp' => array('application/vnd.oasis.opendocument.presentation', 'iconOFFICE.gif'), 'ods' => array('application/vnd.oasis.opendocument.spreadsheet', 'iconOFFICE.gif'), 'odt' => array('application/vnd.oasis.opendocument.text', 'iconOFFICE.gif'), 'wbxml' => array('application/wbxml', 'iconPLAIN.gif'), 'wmlc' => array('application/wmlc', 'iconPLAIN.gif'), 'dmg' => array('application/x-apple-diskimage', 'iconRAR.gif'), 'dcr' => array('application/x-director', 'iconPLAIN.gif'), 'dir' => array('application/x-director', 'iconPLAIN.gif'), 'dxr' => array('application/x-director', 'iconPLAIN.gif'), 'dvi' => array('application/x-dvi', 'iconPLAIN.gif'), 'gtar' => array('application/x-gtar', 'iconRAR.gif'), 'inc' => array('application/x-httpd-php', 'iconPHP.gif'), 'php' => array('application/x-httpd-php', 'iconPHP.gif'), 'php3' => array('application/x-httpd-php', 'iconPHP.gif'), 'php4' => array('application/x-httpd-php', 'iconPHP.gif'), 'php5' => array('application/x-httpd-php', 'iconPHP.gif'), 'phtml' => array('application/x-httpd-php', 'iconPHP.gif'), 'phps' => array('application/x-httpd-php-source', 'iconPHP.gif'), 'js' => array('application/x-javascript', 'iconJS.gif'), 'psd' => array('application/x-photoshop', 'iconPLAIN.gif'), 'rar' => array('application/x-rar', 'iconRAR.gif'), 'fla' => array('application/x-shockwave-flash', 'iconSWF.gif'), 'swf' => array('application/x-shockwave-flash', 'iconSWF.gif'), 'sit' => array('application/x-stuffit', 'iconRAR.gif'), 'tar' => array('application/x-tar', 'iconRAR.gif'), 'tgz' => array('application/x-tar', 'iconRAR.gif'), 'xhtml' => array('application/xhtml+xml', 'iconPLAIN.gif'), 'xht' => array('application/xhtml+xml', 'iconPLAIN.gif'), 'zip' => array('application/zip', 'iconRAR.gif'), 'm4a' => array('audio/x-m4a', 'iconAUDIO.gif'), 'mp3' => array('audio/mp3', 'iconAUDIO.gif'), 'wma' => array('audio/wma', 'iconAUDIO.gif'), 'mpeg' => array('audio/mpeg', 'iconAUDIO.gif'), 'wav' => array('audio/wav', 'iconAUDIO.gif'), 'ogg' => array('audio/ogg', 'iconAUDIO.gif'), 'mid' => array('audio/midi', 'iconAUDIO.gif'), 'midi' => array('audio/midi', 'iconAUDIO.gif'), 'aif' => array('audio/x-aiff', 'iconAUDIO.gif'), 'aiff' => array('audio/x-aiff', 'iconAUDIO.gif'), 'aifc' => array('audio/x-aiff', 'iconAUDIO.gif'), 'ram' => array('audio/x-pn-realaudio', 'iconAUDIO.gif'), 'rm' => array('audio/x-pn-realaudio', 'iconAUDIO.gif'), 'rpm' => array('audio/x-pn-realaudio-plugin', 'iconAUDIO.gif'), 'ra' => array('audio/x-realaudio', 'iconAUDIO.gif'), 'bmp' => array('image/bmp', 'iconBMP.gif'), 'gif' => array('image/gif', 'iconGIF.gif'), 'jpeg' => array('image/jpeg', 'iconJPG.gif'), 'jpg' => array('image/jpeg', 'iconJPG.gif'), 'jpe' => array('image/jpeg', 'iconJPG.gif'), 'png' => array('image/png', 'iconTIF.gif'), 'tiff' => array('image/tiff', 'iconTIF.gif'), 'tif' => array('image/tiff', 'iconTIF.gif'), 'eml' => array('message/rfc822', 'iconPLAIN.gif'), 'asp' => array('text/asp', 'iconPLAIN.gif'), 'css' => array('text/css', 'iconCSS.gif'), 'html' => array('text/html', 'iconHTML.gif'), 'htm' => array('text/html', 'iconHTML.gif'), 'shtml' => array('text/html', 'iconHTML.gif'), 'txt' => array('text/plain', 'iconPLAIN.gif'), 'text' => array('text/plain', 'iconPLAIN.gif'), 'log' => array('text/plain', 'iconPLAIN.gif'), 'rtx' => array('text/richtext', 'iconPLAIN.gif'), 'rtf' => array('text/rtf', 'iconPLAIN.gif'), 'xml' => array('text/xml', 'iconPLAIN.gif'), 'xsl' => array('text/xml', 'iconPLAIN.gif'), 'mp4' => array('video/mp4', 'iconVIDEO.gif'), 'm4v' => array('video/x-m4v', 'iconVIDEO.gif'), 'mov' => array('video/mov', 'iconVIDEO.gif'), 'wmv' => array('video/wmv', 'iconVIDEO.gif'), 'webm' => array('video/webm', 'iconVIDEO.gif'), 'qt' => array('video/quicktime', 'iconVIDEO.gif'), 'rv' => array('video/vnd.rn-realvideo', 'iconVIDEO.gif'), 'avi' => array('video/x-msvideo', 'iconVIDEO.gif'), 'ogv' => array('video/ogg', 'iconVIDEO.gif'), 'movie' => array('video/x-sgi-movie', 'iconVIDEO.gif'))); /** * Hooks
/** * Determine if the select mode is currently active or not. * * @return bool */ protected function isSelectModeActive() { return \Input::getInstance()->get('act') == 'select'; }
/** * Generate backup page */ protected function compileBackup() { // Check if start is set if (\Input::getInstance()->get("act") != "start" || \Input::getInstance()->get("do") != "syncCto_backups") { $_SESSION["TL_ERROR"] = array($GLOBALS['TL_LANG']['ERR']['call_directly']); $this->redirect("contao/main.php?do=syncCto_backups"); } // Get step if (\Input::getInstance()->get("step") == "" || \Input::getInstance()->get("step") == null) { $this->intStep = 0; } else { $this->intStep = intval(\Input::getInstance()->get("step")); } // Set template $this->Template->showControl = false; // Load content from session if ($this->intStep != 0) { $this->loadContenData(); } // Load settings from dca $this->loadBackupSettings(); // Which table is in use switch (\Input::getInstance()->get("table")) { case 'tl_syncCto_backup_db': $this->pageDbBackup(); break; case 'tl_syncCto_restore_db': $this->pageDbRestorePage(); break; case 'tl_syncCto_backup_file': $this->pageFileBackupPage(); break; case 'tl_syncCto_restore_file': $this->pageFileRestorePage(); break; default: $_SESSION["TL_ERROR"][] = $GLOBALS['TL_LANG']['ERR']['unknown_function']; $this->redirect("contao/main.php?do=syncCto_backups"); break; } // Save content in session $this->saveContentData(); // Set Vars for the template $this->setTemplateVars(); // Save Steppool $this->saveStepPool(); }
/** +---------------------------------------------------------- * 得到传递的参数 +---------------------------------------------------------- * @access protected +---------------------------------------------------------- * @param string $type 输入数据类型 * @param string $name 参数名称 * @param string $filter 参数过滤方法 * @param string $default 参数默认值 +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ protected function getParam($type, $name = '', $filter = '', $default = '') { $Input = Input::getInstance(); $value = $Input->{$type}($name, $filter, $default); return $value; }
<?php /** * Contao Open Source CMS * * @copyright MEN AT WORK 2013 * @package clipboard * @license GNU/LGPL * @filesource */ // Allowed clipboard locations $arrAllowedLocations = array('page', 'article', 'content', 'module'); $strDo = Input::getInstance()->get('do'); $strAct = Input::getInstance()->get('act'); $strTable = Input::getInstance()->get('table'); if (TL_MODE == 'BE' && (in_array($strDo, $arrAllowedLocations) || $strDo == 'themes' && $strTable == 'tl_module') && (!$strAct || $strAct == 'select')) { /** * Set header informations */ $GLOBALS['TL_CSS']['clipboard'] = "system/modules/clipboard/html/clipboard.css"; $GLOBALS['TL_JAVASCRIPT']['clipboard'] = "system/modules/clipboard/html/clipboard.js"; /** * Hooks */ $GLOBALS['TL_HOOKS']['outputBackendTemplate'][] = array('Clipboard', 'outputBackendTemplate'); $GLOBALS['TL_HOOKS']['clipboardButtons'][] = array('ClipboardHelper', 'clipboardButtons'); $GLOBALS['TL_HOOKS']['clipboardActSelectButtonsTreeView'][] = array('ClipboardHelper', 'clipboardActSelectButtons'); $GLOBALS['TL_HOOKS']['clipboardActSelectButtonsParentView'][] = array('ClipboardHelper', 'clipboardActSelectButtons'); /** * Config */
public function __construct() { $this->uri = URI::getInstance(); $this->request = Request::getInstance(); $this->input = Input::getInstance(); }
/** * Parse|Check|Validate each field and save it. * * @param string $strField Name of current field * @return void */ public function processInput($strField) { if (in_array($strField, $this->arrProcessedNames)) { return $this->arrProcessed[$strField]; } $this->arrProcessedNames[] = $strField; $strInputName = $strField . '_' . $this->mixWidgetID; // Return if no submit, field is not editable or not in input if (!($this->blnSubmitted && isset($this->arrInputs[$strInputName]) && $this->isEditableField($strField) && !(isset($this->arrDCA['fields'][$strField]['eval']['readonly']) && $this->arrDCA['fields'][$strField]['eval']['readonly']))) { return $this->arrProcessed[$strField] = null; } // Build widget $objWidget = $this->getWidget($strField); if (!$objWidget instanceof Widget) { return $this->arrProcessed[$strField] = null; } // Validate $objWidget->validate(); if (Input::getInstance()->post('SUBMIT_TYPE') == 'auto') { // HACK: we would need a Widget::clearErrors() here but something like this does not exist, hence we have a class that does this for us. WidgetAccessor::resetErrors($objWidget); } // Check if ($objWidget->hasErrors()) { $this->blnNoReload = true; return $this->arrProcessed[$strField] = null; } if (!$objWidget->submitInput()) { return $this->arrProcessed[$strField] = $this->objCurrentModel->getProperty($strField); } // Get value and config $varNew = $objWidget->value; $arrConfig = $this->getFieldDefinition($strField); // If array sort if (is_array($varNew)) { ksort($varNew); } else { if ($varNew != '' && isset(self::$arrDates[$arrConfig['eval']['rgxp']])) { // OH: this should be a widget feature $objDate = new Date($varNew, $GLOBALS['TL_CONFIG'][$arrConfig['eval']['rgxp'] . 'Format']); $varNew = $objDate->tstamp; } } $this->import('Input'); //Handle multi-select fields in "override all" mode // OH: this should be a widget feature if (($arrConfig['inputType'] == 'checkbox' || $arrConfig['inputType'] == 'checkboxWizard') && $arrConfig['eval']['multiple'] && $this->Input->get('act') == 'overrideAll') { if ($arrNew == null || !is_array($arrNew)) { $arrNew = array(); } // FIXME: this will NOT work, as it still uses activeRecord - otoh, what is this intended for? wizards? switch ($this->Input->post($objWidget->name . '_update')) { case 'add': $varNew = array_values(array_unique(array_merge(deserialize($this->objActiveRecord->{$strField}, true), $arrNew))); break; case 'remove': $varNew = array_values(array_diff(deserialize($this->objActiveRecord->{$strField}, true), $arrNew)); break; case 'replace': $varNew = $arrNew; break; } if (!$varNew) { $varNew = ''; } } // Call the save callbacks try { $varNew = $this->objCallbackClass->saveCallback($arrConfig, $varNew); } catch (Exception $e) { $this->blnNoReload = true; $objWidget->addError($e->getMessage()); return $this->arrProcessed[$strField] = null; } // Check on value empty if ($varNew == '' && $arrConfig['eval']['doNotSaveEmpty']) { $this->blnNoReload = true; $objWidget->addError($GLOBALS['TL_LANG']['ERR']['mdtryNoLabel']); return $this->arrProcessed[$strField] = null; } if ($varNew != '') { if ($arrConfig['eval']['encrypt']) { $varNew = $this->Encryption->encrypt(is_array($varNew) ? serialize($varNew) : $varNew); } else { if ($arrConfig['eval']['unique'] && !$this->getDataProvider($this->objCurrentModel->getProviderName())->isUniqueValue($strField, $varNew, $this->objCurrentModel->getID())) { $this->blnNoReload = true; $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $objWidget->label)); return $this->arrProcessed[$strField] = null; } else { if ($arrConfig['eval']['fallback']) { $this->getDataProvider($this->objCurrentModel->getProviderName())->resetFallback($strField); } } } } $this->arrProcessed[$strField] = $varNew; return $varNew; }
/** * Calculate the new position of an element * * Warning this function needs the cdp (current data provider). * Warning this function needs the pdp (parent data provider). * * Based on backbone87 PR - "creating items in parent modes generates sorting value of 0" * * @param InterfaceGeneralData $objCDP - Current data provider * @param InterfaceGeneralData $objPDP - Parent data provider * @param InterfaceGeneralModel $objDBModel - Model of element which should moved * @param mixed $mixAfter - Target element * @param string $strMode - Mode like cut | create and so on * @param integer $intInsertMode - Insert Mode => 1 After | 2 Into * @param mixed $mixParentID - Parent ID of table or element * * @return void */ protected function getNewPosition($objCDP, $objPDP, $objDBModel, $mixAfter, $mixInto, $strMode, $mixParentID = null, $intInsertMode = null, $blnWithoutReorder = false) { // Check if we have a sorting field, if not skip here. if (!$objCDP->fieldExists('sorting')) { return; } // Load default DataProvider. if (is_null($objCDP)) { $objCDP = $this->getDC()->getDataProvider(); } if ($mixAfter === DCGE::INSERT_AFTER_START) { $mixAfter = 0; } // Search for the highest sorting. Default - Add to end off all. // ToDo: We have to check the child <=> parent condition . To get all sortings for one level. // If we get a after 0, add to top. if ($mixAfter === 0) { // Build filter for conditions $arrFilter = array(); if (in_array($this->getDC()->arrDCA['list']['sorting']['mode'], array(4, 5, 6))) { $arrConditions = $this->objDC->getRootConditions($objCDP->getEmptyModel()->getProviderName()); if ($arrConditions) { foreach ($arrConditions as $arrCondition) { if (key_exists('remote', $arrCondition)) { $arrFilter[] = array('value' => Input::getInstance()->get($arrCondition['remote']), 'property' => $arrCondition['property'], 'operation' => $arrCondition['operation']); } else { if (key_exists('remote_value', $arrCondition)) { $arrFilter[] = array('value' => Input::getInstance()->get($arrCondition['remote_value']), 'property' => $arrCondition['property'], 'operation' => $arrCondition['operation']); } else { $arrFilter[] = array('value' => $arrCondition['value'], 'property' => $arrCondition['property'], 'operation' => $arrCondition['operation']); } } } } } // Build config $objConfig = $objCDP->getEmptyConfig(); $objConfig->setFields(array('sorting')); $objConfig->setSorting(array('sorting' => DCGE::MODEL_SORTING_ASC)); $objConfig->setAmount(1); $objConfig->setFilter($arrFilter); $objCollection = $objCDP->fetchAll($objConfig); if ($objCollection->length()) { $intLowestSorting = $objCollection->get(0)->getProperty('sorting'); $intNextSorting = round($intLowestSorting / 2); } else { $intNextSorting = 256; } // Check if we have a valide sorting. if (($intLowestSorting < 2 || $intNextSorting <= 2) && !$blnWithoutReorder) { // ToDo: Add child <=> parent config. $objConfig = $objCDP->getEmptyConfig(); $objConfig->setFilter($arrFilter); $this->reorderSorting($objConfig); $this->getNewPosition($objCDP, $objPDP, $objDBModel, $mixAfter, $mixInto, $strMode, $mixParentID, $intInsertMode, true); return; } else { if ($intNextSorting <= 2) { $intNextSorting = 256; } } $objDBModel->setProperty('sorting', $intNextSorting); } else { if (!empty($mixAfter)) { // Init some vars. $intAfterSorting = 0; $intNextSorting = 0; // Get "after" sorting value value. $objAfterConfig = $objCDP->getEmptyConfig(); $objAfterConfig->setAmount(1); $objAfterConfig->setFilter(array(array('value' => $mixAfter, 'property' => 'id', 'operation' => '='))); $objAfterCollection = $objCDP->fetchAll($objAfterConfig); if ($objAfterCollection->length()) { $intAfterSorting = $objAfterCollection->get(0)->getProperty('sorting'); } // Get "next" sorting value value. $objNextConfig = $objCDP->getEmptyConfig(); $objNextConfig->setFields(array('sorting')); $objNextConfig->setAmount(1); $objNextConfig->setSorting(array('sorting' => DCGE::MODEL_SORTING_ASC)); $arrFilterSettings = array(array('value' => $intAfterSorting, 'property' => 'sorting', 'operation' => '>')); $arrFilterChildCondition = array(); // If we have mode 4, 5, 6 build the child <=> parent condition. if (in_array($this->getDC()->arrDCA['list']['sorting']['mode'], array(4, 5, 6))) { $arrChildCondition = $this->objDC->getParentChildCondition($objAfterCollection->get(0), $objCDP->getEmptyModel()->getProviderName()); $arrChildCondition = $arrChildCondition['setOn']; if ($arrChildCondition) { foreach ($arrChildCondition as $arrOperation) { if (array_key_exists('to_field', $arrOperation)) { $arrFilterChildCondition[] = array('value' => $objAfterCollection->get(0)->getProperty($arrOperation['to_field']), 'property' => $arrOperation['to_field'], 'operation' => '='); } else { $arrFilterChildCondition[] = array('value' => $arrOperation['property'], 'property' => $arrOperation['to_field'], 'operation' => '='); } } } } $objNextConfig->setFilter(array_merge($arrFilterSettings, $arrFilterChildCondition)); $objNextCollection = $objCDP->fetchAll($objNextConfig); if ($objNextCollection->length()) { $intNextSorting = $objNextCollection->get(0)->getProperty('sorting'); } else { $intNextSorting = $intAfterSorting + 2 * 256; } // Check if we have a valide sorting. if (($intAfterSorting < 2 || $intNextSorting < 2 || round(($intNextSorting - $intAfterSorting) / 2) <= 2) && !$blnWithoutReorder) { // ToDo: Add child <=> parent config. $objConfig = $objCDP->getEmptyConfig(); $objConfig->setFilter($arrFilterChildCondition); $this->reorderSorting($objConfig); $this->getNewPosition($objCDP, $objPDP, $objDBModel, $mixAfter, $mixInto, $strMode, $mixParentID, $intInsertMode, true); return; } else { if ($intNextSorting <= 2) { $intNextSorting = 256; } } // Get sorting between these two values. $intNewSorting = $intAfterSorting + round(($intNextSorting - $intAfterSorting) / 2); // Save in model. $objDBModel->setProperty('sorting', $intNewSorting); } else { $objConfig = $objCDP->getEmptyConfig(); $objConfig->setFields(array('sorting')); $objConfig->setSorting(array('sorting' => DCGE::MODEL_SORTING_DESC)); $objConfig->setAmount(1); $objCollection = $objCDP->fetchAll($objConfig); $intHighestSorting = 0; if ($objCollection->length()) { $intHighestSorting = $objCollection->get(0)->getProperty('sorting') + 256; } $objDBModel->setProperty('sorting', $intHighestSorting); } } }