コード例 #1
0
 protected function setRequestToken()
 {
     if (!\Config::get('disableRefererCheck')) {
         $token = \RequestToken::get();
         $this->builder->add('REQUEST_TOKEN', 'hidden', array('data' => $token));
     }
 }
コード例 #2
0
 /**
  * Get a request token
  * @return void
  */
 public function run()
 {
     if (AjaxInput::post('action') == 'getRequestToken') {
         $objResponse = new HtmlResponse(\RequestToken::get());
         $objResponse->send();
     }
 }
コード例 #3
0
 /**
  * Compile the view
  */
 protected function compile()
 {
     if (!$this->getConfigAttribute('plain')) {
         if ($this->getConfigAttribute('table') === true) {
             $this->setConfigAttribute('table', $this->definition->getName());
         }
         if ($this->getConfigAttribute('id') === true) {
             $this->setConfigAttribute('id', \Input::get('id'));
         }
         $strHref = \Environment::get('script') . '?do=' . \Input::get('do');
         if ($this->view->getHref() != '') {
             $strHref .= '&' . $this->view->getHref();
         }
         $this->setConfigAttribute('rt', \RequestToken::get());
         $attributes = array();
         if ($this->getConfigAttribute('id')) {
             $attributes[] = 'id';
         }
         if ($this->getConfigAttribute('table')) {
             $attributes[] = 'table';
         }
         $attributes[] = 'rt';
         $strHref .= '&' . $this->buildHref($attributes);
         $this->view->setHref($strHref);
     }
 }
コード例 #4
0
 /**
  * Get edit map link wizard.
  *
  * @param \DataContainer $dataContainer The dataContainer driver.
  *
  * @return string
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function getEditMapLink($dataContainer)
 {
     if ($dataContainer->value < 1) {
         return '';
     }
     $pattern = 'title="%s" style="padding-left: 3px" onclick="Backend.openModalIframe(';
     $pattern .= '{\'width\':768,\'title\':\'%s\',\'url\':this.href});return false"';
     return sprintf('<a href="%s%s&amp;popup=1&amp;rt=%s" %s>%s</a>', 'contao/main.php?do=leaflet&amp;table=tl_leaflet_map&amp;act=edit&amp;id=', $dataContainer->value, \RequestToken::get(), sprintf($pattern, specialchars(sprintf($GLOBALS['TL_LANG']['tl_content']['editalias'][1], $dataContainer->value)), specialchars(str_replace("'", "\\'", sprintf($GLOBALS['TL_LANG']['tl_content']['editalias'][1], $dataContainer->value)))), \Image::getHtml('alias.gif', $GLOBALS['TL_LANG']['tl_content']['editalias'][0], 'style="vertical-align:top"'));
 }
コード例 #5
0
ファイル: Ajax.php プロジェクト: netzmacht/contao-bootstrap
 /**
  * Output data, encode to json and replace insert tags.
  *
  * @param string $buffer
  * @return string
  */
 protected function output($buffer)
 {
     $buffer = $this->replaceInsertTags($buffer);
     $buffer = str_replace(array('{{request_token}}', '[{]', '[}]'), array(REQUEST_TOKEN, '{{', '}}'), $buffer);
     $buffer = str_replace('{{request_token}}', \RequestToken::get(), $buffer);
     if (is_array($buffer) || is_object($buffer)) {
         $buffer = json_encode($buffer);
     }
     echo $buffer;
     exit;
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function generate()
 {
     if (TL_MODE === 'BE') {
         $template = new \BackendTemplate('be_wildcard');
         $subform = \FormModel::findByPk($this->subform);
         $template->wildcard = sprintf('### %s ###', $GLOBALS['TL_LANG']['tl_form_field']['subform'][0]);
         $template->id = $this->id;
         $template->link = $subform->title;
         $template->href = sprintf('contao/main.php?do=form&table=tl_form_field&id=%s&rt=%s', $this->subform, \RequestToken::get());
         return $template->parse();
     }
     return '';
 }
コード例 #7
0
 /**
  * Combine
  */
 protected function compileDefaultView()
 {
     if (!$this->getConfigAttribute('table')) {
         $this->setConfigAttribute('table', $this->model->getProviderName());
     }
     if (!$this->getConfigAttribute('id') && !$this->getConfigAttribute('id') !== false) {
         $this->setConfigAttribute('id', $this->model->getId());
     }
     $this->setConfigAttribute('rt', \RequestToken::get());
     $href = \Environment::get('script') . '?do=' . \Input::get('do');
     if ($this->getConfigAttribute('id') === false) {
         $add = $this->buildHref(array('table', 'rt'));
     } else {
         $add = $this->buildHref();
     }
     if ($this->view->getHref()) {
         $href .= '&amp;' . $this->view->getHref();
     }
     if ($add) {
         $href .= '&amp;' . $add;
     }
     $this->view->setHref($href);
 }
コード例 #8
0
 protected function loadDcaConfig()
 {
     // in MB
     $this->maxFilesize = $this->maxUploadSize ?: $this->getMaximumUploadSize() / 1024 / 1024;
     $this->acceptedFiles = implode(',', array_map(function ($a) {
         return '.' . $a;
     }, trimsplit(',', strtolower($this->extensions ?: \Config::get('uploadTypes')))));
     // labels & messages
     $this->labels = $this->labels ?: $GLOBALS['TL_LANG']['MSC']['dropzone']['labels'];
     $this->messages = $this->messages ?: $GLOBALS['TL_LANG']['MSC']['dropzone']['messages'];
     foreach ($this->messages as $strKey => $strMessage) {
         $this->{$strKey} = $strMessage;
     }
     foreach ($this->labels as $strKey => $strMessage) {
         $this->{$strKey} = $strMessage;
     }
     $this->thumbnailWidth = $this->thumbnailWidth ?: 90;
     $this->thumbnailHeight = $this->thumbnailHeight ?: 90;
     $this->createImageThumbnails = $this->createImageThumbnails ?: true;
     $this->requestToken = \RequestToken::get();
     $this->previewsContainer = '#ctrl_' . $this->id . ' .dropzone-previews';
     $this->uploadMultiple = $this->fieldType == 'checkbox';
     $this->maxFiles = $this->uploadMultiple ? $this->maxFiles ?: null : 1;
 }
コード例 #9
0
 protected function generateHref()
 {
     $strUrl = $this->base;
     $arrParameters = $this->prepareParameter($this->act);
     foreach ($arrParameters as $key => $value) {
         $strUrl = \Haste\Util\Url::addQueryString($key . '=' . $value, $strUrl);
     }
     if (in_array('popup', $arrParameters)) {
         $strUrl = \Haste\Util\Url::addQueryString('popup=1', $strUrl);
         $this->arrOptions['attributes']['onclick'] = 'onclick="FieldPaletteBackend.openModalIframe({\'action\':\'' . FieldPalette::$strFieldpaletteRefreshAction . '\',\'syncId\':\'' . $this->syncId . '\',\'width\':768,\'title\':\'' . specialchars(sprintf($this->modalTitle, $this->id)) . '\',\'url\':this.href});return false;"';
     }
     $strUrl = \Haste\Util\Url::addQueryString('rt=' . \RequestToken::get(), $strUrl);
     // TODO: DC_TABLE : 2097 - catch POST and Cookie from saveNClose and do not redirect and just close modal
     $strUrl = \Haste\Util\Url::addQueryString('nb=1', $strUrl);
     // required by DC_TABLE::getNewPosition() within nested fieldpalettes
     $strUrl = \Haste\Util\Url::addQueryString('mode=2', $strUrl);
     return $strUrl;
 }
コード例 #10
0
ファイル: FileTree.php プロジェクト: zonky2/dc-general
 /**
  * Generate the adjust selection link.
  *
  * @param array $values The selected files (string uuids).
  *
  * @return string
  */
 private function generateLink($values)
 {
     $inputProvider = $this->getEnvironment()->getInputProvider();
     return sprintf('contao/file.php?do=%s&amp;table=%s&amp;field=%s&amp;act=show&amp;id=%s&amp;value=%s&amp;rt=%s', $inputProvider->getParameter('do'), $this->getModel()->getProviderName(), $this->strField, $this->getModel()->getId(), implode(',', $values), \RequestToken::get());
 }
コード例 #11
0
ファイル: FileTree.php プロジェクト: davidmaack/dc-general
 /**
  * Generate the adjust selection link.
  *
  * @param array $values The selected files.
  *
  * @return string
  */
 private function generateLink($values)
 {
     $inputProvider = $this->getEnvironment()->getInputProvider();
     // Contao passed File ids sinc 3.3.4
     // @see https://github.com/contao/core/commit/c1472209fdfd6e2446013430753ed65530b5a1d1
     if (version_compare(VERSION . '.' . BUILD, '3.3.4', '>=')) {
         $values = array_keys($values);
     } else {
         $values = array_map('String::binToUuid', $values);
     }
     return sprintf('contao/file.php?do=%s&amp;table=%s&amp;field=%s&amp;act=show&amp;id=%s&amp;value=%s&amp;rt=%s', $inputProvider->getParameter('do'), $this->getModel()->getProviderName(), $this->strField, $this->getModel()->getId(), implode(',', $values), \RequestToken::get());
 }
コード例 #12
0
 /**
  * Render the form.
  *
  * @return string
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function render()
 {
     $template = new \BackendTemplate($this->templateName);
     $template->submitLabel = $GLOBALS['TL_LANG']['MSC']['workflowSubmitLabel'];
     $template->name = $this->formName;
     $template->fieldsets = $this->renderSubForms();
     $template->requestToken = \RequestToken::get();
     return $template->parse();
 }
コード例 #13
0
 /**
  * Compile buttons from the table configuration array and return them as HTML
  *
  * @param array   $arrRow
  * @param string  $strTable
  * @param array   $arrRootIds
  * @param boolean $blnCircularReference
  * @param array   $arrChildRecordIds
  * @param string  $strPrevious
  * @param string  $strNext
  *
  * @return string
  */
 protected function generateButtons($objRow, $arrRootIds = array(), $blnCircularReference = false, $arrChildRecordIds = null, $strPrevious = null, $strNext = null)
 {
     if (empty($this->arrDca['list']['operations'])) {
         return '';
     }
     $return = '';
     $dc = new DC_Table(\Config::get('fieldpalette_table'));
     $dc->id = $this->currentRecord;
     $dc->activeRecord = $objRow;
     foreach ($this->arrDca['list']['operations'] as $k => $v) {
         $v = is_array($v) ? $v : array($v);
         $id = specialchars(rawurldecode($objRow->id));
         $label = $v['label'][0] ?: $k;
         $title = sprintf($v['label'][1] ?: $k, $id);
         $attributes = $v['attributes'] != '' ? ltrim(sprintf($v['attributes'], $id, $id)) : '';
         $objButton = FieldPaletteButton::getInstance();
         $objButton->addOptions($this->arrButtonDefaults);
         $objButton->setType($k);
         $objButton->setId($objRow->id);
         $objButton->setModalTitle(sprintf($GLOBALS['TL_LANG']['tl_fieldpalette']['modalTitle'], $GLOBALS['TL_LANG'][$this->strTable][$this->strName][0] ?: $this->strName, sprintf($title, $objRow->id)));
         $objButton->setAttributes(array($attributes));
         $objButton->setLabel(\Image::getHtml($v['icon'], $label));
         $objButton->setTitle(specialchars($title));
         // Call a custom function instead of using the default button
         if (is_array($v['button_callback'])) {
             $this->import($v['button_callback'][0]);
             $return .= $this->{$v['button_callback'][0]}->{$v['button_callback'][1]}($objRow->row(), $objButton->getHref(), $label, $title, $v['icon'], $attributes, \Config::get('fieldpalette_table'), $arrRootIds, $arrChildRecordIds, $blnCircularReference, $strPrevious, $strNext, $dc);
             continue;
         } elseif (is_callable($v['button_callback'])) {
             $return .= $v['button_callback']($objRow->row(), $objButton->getHref(), $label, $title, $v['icon'], $attributes, \Config::get('fieldpalette_table'), $arrRootIds, $arrChildRecordIds, $blnCircularReference, $strPrevious, $strNext, $dc);
             continue;
         }
         // Generate all buttons except "move up" and "move down" buttons
         if ($k != 'move' && $v != 'move') {
             $return .= $objButton->generate();
             continue;
         }
         $arrDirections = array('up', 'down');
         $arrRootIds = is_array($arrRootIds) ? $arrRootIds : array($arrRootIds);
         foreach ($arrDirections as $dir) {
             $label = $GLOBALS['TL_LANG'][\Config::get('fieldpalette_table')][$dir][0] ?: $dir;
             $title = $GLOBALS['TL_LANG'][\Config::get('fieldpalette_table')][$dir][1] ?: $dir;
             $label = \Image::getHtml($dir . '.gif', $label);
             $href = $v['href'] ?: '&amp;act=move';
             if ($dir == 'up') {
                 $return .= (is_numeric($strPrevious) && (!in_array($objRow->id, $arrRootIds) || empty($this->arrDca['list']['sorting']['root'])) ? '<a href="' . $this->addToUrl($href . '&amp;id=' . $objRow->id) . '&amp;sid=' . intval($strPrevious) . '" title="' . specialchars($title) . '"' . $attributes . '>' . $label . '</a> ' : \Image::getHtml('up_.gif')) . ' ';
                 continue;
             }
             $return .= (is_numeric($strNext) && (!in_array($objRow->id, $arrRootIds) || empty($this->arrDca['list']['sorting']['root'])) ? '<a href="' . $this->addToUrl($href . '&amp;id=' . $objRow->id) . '&amp;sid=' . intval($strNext) . '" title="' . specialchars($title) . '"' . $attributes . '>' . $label . '</a> ' : \Image::getHtml('down_.gif')) . ' ';
         }
     }
     // Sort elements
     if (!$this->arrDca['config']['notSortable']) {
         $href = 'contao/main.php';
         $href .= '?do=' . \Input::get('do');
         $href .= '&amp;table=' . \Config::get('fieldpalette_table');
         $href .= '&amp;id=' . $objRow->id;
         $href .= '&amp;' . FieldPalette::$strTableRequestKey . '=' . $this->strTable;
         $href .= '&amp;' . FieldPalette::$strPaletteRequestKey . '=' . $this->strName;
         $href .= '&amp;rt=' . \RequestToken::get();
         $return .= ' ' . \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG'][$this->strTable]['cut'][1], $objRow->id) . '" data-href="' . $href . '" data-id="' . $objRow->id . '" data-pid="' . $objRow->pid . '"');
     }
     return trim($return);
 }
コード例 #14
0
 protected function prepare()
 {
     if ($this->multiple) {
         $this->addAttribute('multiple', true);
         $this->strName .= '[]';
     } else {
         $this->addAttribute('data-max-tags', 1);
     }
     if ($this->submitOnChange) {
         unset($this->arrAttributes['onchange']);
         $this->addAttribute('data-submitonchange', true);
     }
     // add remote options or freeInput options
     $this->arrOptions = $this->getOptions(deserialize($this->varValue, true));
     // Add an empty option (XHTML) if there are none
     if (empty($this->arrOptions)) {
         $this->arrOptions = array(array('value' => '', 'label' => '-'));
     }
     foreach ($this->arrOptions as $strKey => $arrOption) {
         if (isset($arrOption['value'])) {
             $this->arrTags[] = $arrOption;
             // add only selected values as option
             if ($this->isSelected($arrOption)) {
                 $this->arrSelectedOptions[] = sprintf('<option value="%s"%s%s>%s</option>', is_numeric($arrOption['value']) ? $arrOption['value'] : specialchars($arrOption['label']), $arrOption['class'] != '' ? 'class="' . $arrOption['class'] . '"' : '', $arrOption['target'] != '' ? 'data-target="' . $arrOption['class'] . '"' : '', $arrOption['label']);
             }
         }
     }
     $this->addAttribute('data-items', htmlspecialchars(json_encode($this->arrTags), ENT_QUOTES, 'UTF-8'));
     $this->addAttribute('data-free-input', $this->canInputFree() !== false ? 'true' : 'false');
     $strMode = $this->arrConfiguration['mode'] ?: static::MODE_LOCAL;
     $this->addAttribute('data-mode', $strMode);
     switch ($strMode) {
         case static::MODE_REMOTE:
             $this->addAttribute('data-post-data', htmlspecialchars(json_encode(array('action' => static::ACTION_FETCH_REMOTE_OPTIONS, 'name' => $this->strId, 'REQUEST_TOKEN' => \RequestToken::get()))));
             break;
     }
     if ($this->arrConfiguration['placeholder']) {
         $this->addAttribute('data-placeholder', $this->arrConfiguration['placeholder']);
     }
 }
コード例 #15
0
 protected function redirectAfterSubmission()
 {
     global $objPage;
     $blnRedirect = false;
     $strUrl = \Controller::generateFrontendUrl($objPage->row());
     if (($objTarget = \PageModel::findByPk($this->jumpTo)) !== null) {
         $blnRedirect = true;
         $strUrl = \Controller::generateFrontendUrl($objTarget->row(), null, null, true);
     }
     $arrPreserveParams = trimsplit(',', $this->jumpToPreserveParams);
     foreach ($arrPreserveParams as $strParam) {
         $varValue = \Input::get($strParam);
         if ($varValue === null) {
             continue;
         }
         switch ($strParam) {
             case 'token':
                 if ($this->deactivateTokens) {
                     break;
                 }
                 $strUrl = Url::addQueryString($strParam . '=' . \RequestToken::get(), $strUrl);
                 break;
             default:
                 $strUrl = Url::addQueryString($strParam . '=' . $varValue, $strUrl);
         }
     }
     if ($blnRedirect) {
         \HeimrichHannot\StatusMessages\StatusMessage::reset($this->objModule->id);
     }
     if ($this->async) {
         if ($blnRedirect) {
             $objResponse = new ResponseRedirect();
             $objResponse->setUrl($strUrl);
             $objResponse->output();
         }
         return;
     }
     if (!$blnRedirect) {
         if ($this->getReset()) {
             $this->reset(true);
         }
         return;
     }
     \Controller::redirect($strUrl);
 }
コード例 #16
0
 public static function getModalEditLink($strModule, $intId, $strLabel = null, $strTable = '')
 {
     if ($intId) {
         $strLabel = sprintf(specialchars($strLabel ?: $GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $intId);
         return sprintf(' <a href="contao/main.php?do=%s&amp;act=edit&amp;id=%s%s&amp;popup=1&amp;nb=1&amp;rt=%s" title="%s" ' . 'style="padding-left:3px" onclick="Backend.openModalIframe({\'width\':768,\'title\':\'%s' . '\',\'url\':this.href});return false">%s</a>', $strModule, $intId, $strTable ? '&amp;table=' . $strTable : '', \RequestToken::get(), $strLabel, $strLabel, \Image::getHtml('alias.gif', $strLabel, 'style="vertical-align:top"'));
     }
 }
コード例 #17
0
 protected function compile()
 {
     $this->Template->headline = $this->headline;
     $this->Template->hl = $this->hl;
     $this->Template->wrapperClass = $this->strWrapperClass;
     $this->Template->wrapperId = $this->strWrapperId;
     $this->strFormId = $this->formHybridDataContainer . '_' . $this->id;
     $strAction = $this->defaultAction ?: \Input::get('act');
     $this->arrEditable = deserialize($this->formHybridEditable, true);
     $this->strToken = $this->strToken ?: \Input::get('token');
     // Do not change this order (see #6191)
     $this->Template->style = !empty($this->arrStyle) ? implode(' ', $this->arrStyle) : '';
     $this->Template->class = trim('mod_' . $this->type . ' ' . $this->cssID[1]);
     $this->Template->cssID = $this->cssID[0] != '' ? ' id="' . $this->cssID[0] . '"' : '';
     $this->Template->inColumn = $this->strColumn;
     if ($this->Template->headline == '') {
         $this->Template->headline = $this->headline;
     }
     if ($this->Template->hl == '') {
         $this->Template->hl = $this->hl;
     }
     if (!empty($this->classes) && is_array($this->classes)) {
         $this->Template->class .= ' ' . implode(' ', $this->classes);
     }
     $this->addDefaultArchive();
     // at first check for the correct request token to be set
     if (!$this->deactivateTokens && !\RequestToken::validate($this->strToken)) {
         if (!$this->blnSilentMode) {
             StatusMessage::addError(sprintf($GLOBALS['TL_LANG']['frontendedit']['requestTokenExpired'], Url::replaceParameterInUri(Url::getUrl(), 'token', \RequestToken::get())), $this->id, 'requestTokenExpired');
         }
         return;
     }
     if ($this->formHybridAllowIdAsGetParameter) {
         $intId = \Input::get($this->formHybridIdGetParameter);
         if (is_numeric($intId)) {
             $this->intId = $intId;
         }
     }
     $strItemClass = \Model::getClassFromTable($this->formHybridDataContainer);
     // get id from share
     if ($strShare = \Input::get('share')) {
         if (($objItem = $strItemClass::findByShareToken($strShare)) !== null && !FormHybridList::shareTokenExpiredOrEmpty($objItem, time())) {
             $this->intId = $objItem->id;
         }
     }
     if (!$this->intId) {
         if (isset($GLOBALS['TL_HOOKS']['frontendEditAddNoIdBehavior']) && is_array($GLOBALS['TL_HOOKS']['frontendEditAddNoIdBehavior'])) {
             foreach ($GLOBALS['TL_HOOKS']['frontendEditAddNoIdBehavior'] as $arrCallback) {
                 $this->import($arrCallback[0]);
                 if ($this->{$arrCallback}[0]->{$arrCallback}[1]($this) === false) {
                     return;
                 }
             }
         }
         if ($this->noIdBehavior == 'error') {
             if (!$this->blnSilentMode) {
                 StatusMessage::addError($GLOBALS['TL_LANG']['frontendedit']['noIdFound'], $this->id, 'noidfound');
             }
             return;
         } elseif ($this->noIdBehavior == 'redirect' || $this->noIdBehavior == 'create_until') {
             $arrConditions = deserialize($this->existanceConditions, true);
             if ($this->existanceConditions && !empty($arrConditions)) {
                 $arrColumns = array();
                 $arrValues = array();
                 foreach ($arrConditions as $arrCondition) {
                     if (!$arrCondition['field']) {
                         continue;
                     }
                     $arrColumns[] = $arrCondition['field'] . '=?';
                     $arrValues[] = $this->replaceInsertTags($arrCondition['value']);
                 }
                 if (!empty($arrColumns) && ($objItem = $strItemClass::findOneBy($arrColumns, $arrValues)) !== null) {
                     $this->intId = $objItem->id;
                 }
             }
         }
         if (!$this->intId) {
             if ($this->noIdBehavior == 'redirect') {
                 if (!$this->blnSilentMode) {
                     StatusMessage::addError($GLOBALS['TL_LANG']['frontendedit']['noIdFound'], $this->id, 'noidfound');
                 }
                 return;
             } else {
                 $strFormId = FormHelper::getFormId($this->formHybridDataContainer, $this->id);
                 // get id from FormSession
                 if ($_POST) {
                     if ($intId = FormSession::getSubmissionId($strFormId)) {
                         $this->intId = $intId;
                     }
                 }
                 if (!$this->intId) {
                     // if no id is given a new instance is initiated
                     $objConfiguration = new FormConfiguration($this->arrData);
                     // ajax handling, required in this manor, as we have no real ajax controller in contao and ajax request not related to this module
                     // might trigger this module beforhand and new submission will be created after the submission was transfered to the user and id wont match any more
                     if (Ajax::isRelated(Form::FORMHYBRID_NAME) !== null) {
                         if ($intId = FormSession::getSubmissionId($strFormId)) {
                             $this->intId = $intId;
                         } else {
                             $objConfiguration->forceCreate = true;
                         }
                     }
                     $this->objForm = new $this->strFormClass($objConfiguration, $this->arrSubmitCallbacks, $this->intId ?: 0, $this);
                     if ($intId = $this->objForm->getId()) {
                         $this->intId = $intId;
                     }
                 }
             }
         }
     }
     // intId is set at this point!
     if (!$this->checkEntityExists($this->intId)) {
         if (!$this->blnSilentMode) {
             StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id, 'nopermission');
         }
         if (Ajax::isRelated(Form::FORMHYBRID_NAME)) {
             $objResponse = new ResponseError();
             $objResponse->setResult(StatusMessage::generate($this->id));
             $objResponse->output();
         }
         return;
     }
     // page title
     if ($this->setPageTitle) {
         global $objPage;
         if (($objItem = General::getModelInstance($this->formHybridDataContainer, $this->intId)) !== null) {
             $objPage->pageTitle = $objItem->{$this->pageTitleField};
         }
     }
     if ($strAction == FRONTENDEDIT_ACT_DELETE) {
         if ($this->checkDeletePermission($this->intId)) {
             $blnResult = $this->deleteItem($this->intId);
             if (\Environment::get('isAjaxRequest')) {
                 die($blnResult);
             }
             // return to the list
             \Controller::redirect(Url::removeQueryString(array('act', 'id', 'token'), Url::getUrl()));
         } else {
             if (!$this->blnSilentMode) {
                 StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id, 'nopermission');
             }
             return;
         }
     } else {
         if ($this->checkUpdatePermission($this->intId)) {
             // create a new lock if necessary
             if (in_array('entity_lock', \ModuleLoader::getActive()) && $this->addEntityLock) {
                 if (\HeimrichHannot\EntityLock\EntityLockModel::isLocked($this->formHybridDataContainer, $this->intId, $this)) {
                     $objLock = \HeimrichHannot\EntityLock\EntityLockModel::findActiveLock($this->formHybridDataContainer, $this->intId, $this);
                     $objItem = General::getModelInstance($this->formHybridDataContainer, $this->intId);
                     if (!$this->blnSilentMode) {
                         $strMessage = \HeimrichHannot\EntityLock\EntityLock::generateErrorMessage($this->formHybridDataContainer, $this->intId, $this);
                         if ($this->allowLockDeletion) {
                             $strUnlockForm = $this->generateUnlockForm($objItem, $objLock);
                             $strMessage .= $strUnlockForm;
                         }
                         StatusMessage::addError($strMessage, $this->id, 'locked');
                     }
                     if ($this->readOnlyOnLocked) {
                         $this->formHybridViewMode = FORMHYBRID_VIEW_MODE_READONLY;
                         $this->formHybridReadonlyTemplate = 'formhybridreadonly_default';
                     } else {
                         return;
                     }
                 } else {
                     \HeimrichHannot\EntityLock\EntityLockModel::create($this->formHybridDataContainer, $this->intId, $this);
                 }
             }
             if ($this->objForm === null) {
                 $this->objForm = new $this->strFormClass(new FormConfiguration($this->arrData), $this->arrSubmitCallbacks, $this->intId, $this);
             }
             $this->Template->form = $this->objForm->generate();
             $this->Template->item = $this->objForm->activeRecord;
             if (\Environment::get('isAjaxRequest') && \Input::get('scope') == 'modal') {
                 $objItem = General::getModelInstance($this->formHybridDataContainer, $this->intId);
                 $objModalWrapper = new \FrontendTemplate($this->modalTpl ?: 'formhybrid_reader_modal_bootstrap');
                 if ($objItem !== null) {
                     $objModalWrapper->setData($objItem->row());
                 }
                 $objModalWrapper->module = Arrays::arrayToObject($this->arrData);
                 $objModalWrapper->item = $this->replaceInsertTags($this->Template->parse());
                 die($objModalWrapper->parse());
             }
         } else {
             if (!$this->blnSilentMode) {
                 StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id, 'nopermission');
             }
             return;
         }
     }
 }
コード例 #18
0
 public function addItemColumns($objItem, &$arrItem)
 {
     parent::addItemColumns($objItem, $arrItem);
     global $objPage;
     // edit
     if ($this->addEditCol) {
         $arrItem['addEditCol'] = true;
         $strUrl = $this->addAjaxPagination ? Url::getCurrentUrlWithoutParameters() : Url::getUrl();
         if (($objPageJumpTo = \PageModel::findByPk($this->jumpToEdit)) !== null && $this->jumpToEdit != $objPage->id) {
             $strUrl = \Controller::generateFrontendUrl($objPageJumpTo->row(), null, null, true);
         }
         $arrItem['editUrl'] = Url::addQueryString($this->formHybridIdGetParameter . '=' . $objItem->id . (!$this->deactivateTokens ? '&token=' . \RequestToken::get() : ''), $strUrl);
     }
     // delete url
     if ($this->addDeleteCol) {
         $arrItem['addDeleteCol'] = true;
         $arrItem['deleteUrl'] = Url::addQueryString($this->formHybridIdGetParameter . '=' . $objItem->id . '&act=delete' . (!$this->deactivateTokens ? '&token=' . \RequestToken::get() : ''), $this->addAjaxPagination ? Url::getCurrentUrlWithoutParameters() : Url::getUrl());
     }
     // publish url
     if ($this->addPublishCol) {
         $arrItem['addPublishCol'] = true;
         $arrItem['publishUrl'] = Url::addQueryString($this->formHybridIdGetParameter . '=' . $objItem->id . '&act=publish' . (!$this->deactivateTokens ? '&token=' . \RequestToken::get() : ''), $this->addAjaxPagination ? Url::getCurrentUrlWithoutParameters() : Url::getUrl());
     }
 }
 public function editOrder(\DataContainer $objDc)
 {
     return $objDc->value < 1 ? '' : ' <a href="contao/main.php?do=iso_orders&act=edit&id=' . $objDc->value . '&rt=' . \RequestToken::get() . '" title="' . sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $objDc->value) . '" style="padding-left:3px">' . \Image::getHtml('alias.gif', $GLOBALS['TL_LANG']['tl_content']['editalias'][0], 'style="vertical-align:top"') . '</a>';
 }
コード例 #20
0
 public static function getGenerateInternalCacheAction()
 {
     \RequestToken::initialize();
     return 'contao/main.php?do=maintenance&bic=1&rt=' . \RequestToken::get();
 }
コード例 #21
0
 public function processFormDataHook($arrSubmitted, $arrData, $arrFiles, $arrLabels, $objForm)
 {
     $formId = $objForm->formID != '' ? 'auto_' . $objForm->formID : 'auto_form_' . $objForm->id;
     // Get all form fields
     $arrFields = array();
     $objFields = \FormFieldModel::findPublishedByPid($objForm->id);
     // default order by sorting
     $strReturn = null;
     if ($objFields !== null) {
         $start = false;
         while ($objFields->next()) {
             if ($objFields->successType == 'successStart') {
                 $start = true;
             }
             if ($start || !$objForm->hideFormOnSuccess) {
                 $arrFields[] = $objFields->current();
             }
             if ($objFields->successType == 'successStop') {
                 $start = false;
                 // hideFormOnSuccess: do not render other fields than successStart, fields inside and successStop
                 if ($objForm->hideFormOnSuccess) {
                     break;
                 }
             }
         }
     }
     if (!empty($arrFields) && is_array($arrFields)) {
         $row = 0;
         $max_row = count($arrFields);
         foreach ($arrFields as $objField) {
             $strClass = $GLOBALS['TL_FFL'][$objField->type];
             // Continue if the class is not defined
             if (!class_exists($strClass)) {
                 continue;
             }
             $arrData = $objField->row();
             $arrData['decodeEntities'] = true;
             $arrData['allowHtml'] = $objForm->allowTags;
             $arrData['rowClass'] = 'row_' . $row . ($row == 0 ? ' row_first' : ($row == $max_row - 1 ? ' row_last' : '')) . ($row % 2 == 0 ? ' even' : ' odd');
             $arrData['tableless'] = $objForm->tableless;
             // Increase the row count if its a password field
             if ($objField->type == 'password') {
                 ++$row;
                 ++$max_row;
                 $arrData['rowClassConfirm'] = 'row_' . $row . ($row == $max_row - 1 ? ' row_last' : '') . ($row % 2 == 0 ? ' even' : ' odd');
             }
             // Submit buttons do not use the name attribute
             if ($objField->type == 'submit') {
                 $arrData['name'] = '';
             }
             // Unset the default value depending on the field type (see #4722)
             if (!empty($arrData['value'])) {
                 if (!in_array('value', trimsplit('[,;]', $GLOBALS['TL_DCA']['tl_form_field']['palettes'][$objField->type]))) {
                     $arrData['value'] = '';
                 }
             }
             $objWidget = new $strClass($arrData);
             $objWidget->required = $objField->mandatory ? true : false;
             // HOOK: load form field callback
             if (isset($GLOBALS['TL_HOOKS']['loadFormField']) && is_array($GLOBALS['TL_HOOKS']['loadFormField'])) {
                 foreach ($GLOBALS['TL_HOOKS']['loadFormField'] as $callback) {
                     $this->import($callback[0]);
                     $objWidget = $this->{$callback}[0]->{$callback}[1]($objWidget, $formId, $arrData, $objForm);
                 }
             }
             $strReturn .= $objWidget->parse();
             ++$row;
         }
     }
     if ($objForm->isAjaxForm && !is_null($strReturn)) {
         $strReturn .= '<input type="hidden" name="FORM_SUBMIT" value="' . $formId . '">';
         $strReturn .= '<input type="hidden" name="REQUEST_TOKEN" value="' . \RequestToken::get() . '">';
         die(\Controller::replaceInsertTags($strReturn));
     }
 }
コード例 #22
0
 public static function getGenerateButton($arrRow, $strKey, $strLabel, $strTitle)
 {
     $strHref = sprintf('contao/main.php?do=code_config&%s&id=%s&rt=%s', $strKey, $arrRow['id'], \RequestToken::get());
     return sprintf("<a href=\"%s\" title=\"%s\" onclick=\"count=prompt('%s', '');" . "if (count) {self.location.href='/%s&count=' + count;} return false;\"><img src=\"%s\"></a>", $strHref, $strTitle, $GLOBALS['TL_LANG']['MSC']['codeGenerator']['codesPrompt'], $strHref, 'system/modules/code_generator/assets/img/generate.png');
 }