当前位置: 首页>>代码示例>>PHP>>正文


PHP Input::setPost方法代码示例

本文整理汇总了PHP中Input::setPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::setPost方法的具体用法?PHP Input::setPost怎么用?PHP Input::setPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Input的用法示例。


在下文中一共展示了Input::setPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRegexpPrice

 public function testRegexpPrice()
 {
     \Input::setPost('test_rgxp_price', 'foobar');
     $objWidget = new \TextField(array('name' => 'test_rgxp_price'));
     $objWidget->rgxp = 'price';
     $objWidget->validate();
     $this->assertTrue($objWidget->hasErrors());
     unset($objWidget);
     \Input::setPost('test_rgxp_price', '20.00');
     $objWidget = new \TextField(array('name' => 'test_rgxp_price'));
     $objWidget->rgxp = 'price';
     $objWidget->validate();
     $this->assertFalse($objWidget->hasErrors());
     unset($objWidget);
     \Input::setPost('test_rgxp_price', '20');
     $objWidget = new \TextField(array('name' => 'test_rgxp_price'));
     $objWidget->rgxp = 'price';
     $objWidget->validate();
     $this->assertFalse($objWidget->hasErrors());
     unset($objWidget);
     \Input::setPost('test_rgxp_price', '-20');
     $objWidget = new \TextField(array('name' => 'test_rgxp_price'));
     $objWidget->rgxp = 'price';
     $objWidget->validate();
     $this->assertFalse($objWidget->hasErrors());
     unset($objWidget);
     \Input::setPost('test_rgxp_price', '20.-');
     $objWidget = new \TextField(array('name' => 'test_rgxp_price'));
     $objWidget->rgxp = 'price';
     $objWidget->validate();
     $this->assertFalse($objWidget->hasErrors());
     unset($objWidget);
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:33,代码来源:IsotopeTest.php

示例2: compileFormFields

 /**
  * Adjust form fields to given page.
  *
  * @param \FormFieldModel[] $formFields
  * @param string            $formId
  * @param \Form             $form
  */
 public function compileFormFields($formFields, $formId, \Form $form)
 {
     // Make sure empty form fields arrays are skipped
     if (0 === count($formFields)) {
         return $formFields;
     }
     $manager = new MPFormsFormManager($form->id);
     // Don't try to render multi page form if no valid combination
     if (!$manager->isValidFormFieldCombination()) {
         return $manager->getFieldsWithoutPageBreaks();
     }
     // Do not let Contao validate anything if user wants to go back
     if ('back' === $_POST['mp_form_pageswitch']) {
         $this->redirectToStep($manager, $manager->getPreviousStep());
     }
     // Validate previous steps data
     if (!$manager->isFirstStep()) {
         $vResult = $manager->validateSteps(0, $manager->getCurrentStep() - 1);
         if (true !== $vResult) {
             $manager->setPreviousStepsWereInvalid();
             $this->redirectToStep($manager, $vResult);
         }
     }
     // If someone wanted to skip the page, fake form submission so fields
     // are validated and show the error message.
     if ($manager->getPreviousStepsWereInvalid()) {
         \Input::setPost('FORM_SUBMIT', $manager->getFormId());
         $manager->resetPreviousStepsWereInvalid();
     }
     return $manager->getFieldsForStep($manager->getCurrentStep());
 }
开发者ID:terminal42,项目名称:contao-mp_forms,代码行数:38,代码来源:MPForms.php

示例3: testInput

 /**
  * @dataProvider inputProvider
  */
 public function testInput($input, $output, $exception = null)
 {
     if ($exception) {
         $this->setExpectedException($exception);
     }
     \Input::setPost('test_number_field', $input);
     $objWidget = new BackendWidget(array('name' => 'test_number_field', 'value' => $input));
     $objWidget->validate();
     $this->assertEquals($output, $objWidget->value);
 }
开发者ID:codefog,项目名称:contao-haste,代码行数:13,代码来源:BackendWidgetTest.php

示例4: recordUsername

 public function recordUsername($intId, &$arrData)
 {
     if (!strlen($arrData['username'])) {
         $arrData['username'] = $arrData['email'];
         \Input::setPost('username', $arrData['email']);
         \Database::getInstance()->prepare("UPDATE tl_member SET username=? WHERE id=?")->execute($arrData['email'], $intId);
         $memberModel = \MemberModel::findByPk($intId);
         // Fix the problem with versions (see #7)
         if (null !== $memberModel) {
             $memberModel->refresh();
         }
     }
 }
开发者ID:terminal42,项目名称:contao-mailusername,代码行数:13,代码来源:MailUsername.php

示例5: testBindModel

 public function testBindModel()
 {
     $this->instance->addFormField('pageTitle', array('inputType' => 'text'))->addFormField('jumpTo', array('inputType' => 'text'));
     $objModel = new \PageModel();
     $this->instance->bindModel($objModel);
     \Input::setPost('pageTitle', 'My page title test');
     \Input::setPost('jumpTo', 42);
     if ($this->instance->validate()) {
         $objBoundModel = $this->instance->getBoundModel();
         $this->assertTrue(spl_object_hash($objModel) === spl_object_hash($objBoundModel));
         $this->assertEquals('My page title test', $objBoundModel->pageTitle);
         $this->assertEquals(42, $objBoundModel->jumpTo);
     }
 }
开发者ID:codefog,项目名称:contao-haste,代码行数:14,代码来源:FormTest.php

示例6: importUserHook

 /**
  * This Hook provides case-insensitive contao-login by email usernames
  *
  * RFC 5321, section-2.3.11 says that email addresses should be treated as case-insensitive
  *
  * @param $strUser
  * @param $strPassword
  * @param $strTable
  *
  * @return bool
  */
 public function importUserHook($strUser, $strPassword, $strTable)
 {
     if (!\Validator::isEmail($strUser)) {
         return false;
     }
     switch ($strTable) {
         case 'tl_member':
             $objUser = \FrontendUser::getInstance();
             if ($objUser->findBy('LOWER(username)', strtolower($strUser)) !== false) {
                 // set post user name to the users username
                 \Input::setPost('username', $objUser->username);
                 return true;
             }
             break;
     }
     return false;
 }
开发者ID:heimrichhannot,项目名称:contao-email2username,代码行数:28,代码来源:Hooks.php

示例7: changeAjaxPostActions

 /**
  * 
  */
 public function changeAjaxPostActions()
 {
     if (version_compare(VERSION, '3.1', '>=')) {
         if (Environment::get('isAjaxRequest')) {
             switch (Input::post('action')) {
                 case 'reloadPagetree':
                 case 'reloadFiletree':
                     //get the fieldnames
                     $strRef = $this->Session->get('filePickerRef');
                     $strRef = substr($strRef, stripos($strRef, 'field=') + 6);
                     $arrRef = explode('&', $strRef);
                     $arrRefField = explode('__', $arrRef[0]);
                     $arrField = preg_split('/_row[0-9]*_/i', \Input::post('name'));
                     //change action if modal selector was found
                     if (count($arrRefField) > 1 && $arrRefField === $arrField) {
                         Input::setPost('action', Input::post('action') . '_mcw');
                     }
                     break;
             }
         }
     }
 }
开发者ID:amenk,项目名称:MultiColumnWizard,代码行数:25,代码来源:MultiColumnWizardHelper.php

示例8: saveClassesToCssClass

 /**
  * @param array $arrClasses
  * @param \DataContainer $dc
  */
 protected function saveClassesToCssClass(array $arrClasses, \DataContainer $dc)
 {
     $strCssClassName = $this->getCssClassName($dc->id);
     $strClasses = implode(' ', $arrClasses);
     $strClasses = str_replace('  ', ' ', $strClasses);
     $strClasses = trim($strClasses);
     $dc->activeRecord->cssClass = $strClasses;
     \Input::setPost($strCssClassName, $strClasses);
     $objDatabase = \Database::getInstance();
     $objDatabase->prepare("UPDATE {$dc->table} SET cssClass=? WHERE id=?")->execute($strClasses, $dc->id);
 }
开发者ID:craffft,项目名称:contao-css-style-selector,代码行数:15,代码来源:CssStyleSelectorHelper.php

示例9: validateEmailAddresses

 /**
  * @param string $strAddresses
  * @param $field
  * @return array
  */
 private function validateEmailAddresses($strAddresses = '', $field)
 {
     $arrEmailAddresses = array();
     trim(strtolower($strAddresses));
     if ($strAddresses == '') {
         // update the db
         $this->Database->prepare('UPDATE tl_be_email SET ' . $field . '=? WHERE id=?')->execute('', \Input::get('id'));
         \Input::setPost($field, '');
         return $arrEmailAddresses;
     }
     $arrEmailAddresses = array();
     preg_match_all('/\\w[-._\\w]*\\w@\\w[-._\\w]*\\w\\.\\w{2,6}/i', $strAddresses, $arrEmailAddresses);
     // remove doubble entries
     $arrEmailAddresses = array_unique($arrEmailAddresses[0]);
     // update the db
     $this->Database->prepare('UPDATE tl_be_email SET ' . $field . '=? WHERE id=?')->execute(implode('; ', $arrEmailAddresses), \Input::get('id'));
     \Input::setPost($field, implode('; ', $arrEmailAddresses));
     return $arrEmailAddresses;
 }
开发者ID:markocupic,项目名称:be_email,代码行数:24,代码来源:tl_be_email.php

示例10: setPostPassword

 /**
  * @param $strNewPassword
  * @param null $intId
  */
 protected function setPostPassword($strNewPassword, $intId = null)
 {
     if (\Input::get('act') == 'editAll' && is_numeric($intId)) {
         \Input::setPost('password_' . $intId, $strNewPassword);
         \Input::setPost('password_' . $intId . '_confirm', $strNewPassword);
     } else {
         \Input::setPost('password', $strNewPassword);
         \Input::setPost('password_confirm', $strNewPassword);
     }
 }
开发者ID:craffft,项目名称:contao-accountmail,代码行数:14,代码来源:Account.php

示例11: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     if (\Input::post('FORM_SUBMIT') == 'tl_bn_edit_entry' && (int) $this->User->library_id > 0) {
         $bnImageArr = $this->getBnImages();
         $set = array('bibliotheksname' => \Input::post('bibliotheksname'), 'zweigstellenname' => \Input::post('zweigstellenname'), 'traeger' => \Input::post('traeger'), 'medienbestand' => \Input::post('medienbestand'), 'strasse' => \Input::post('strasse'), 'hausnummer' => \Input::post('hausnummer'), 'plz' => \Input::post('plz'), 'ort' => \Input::post('ort'), 'gemeinde' => \Input::post('gemeinde'), 'landkreis' => \Input::post('landkreis'), 'leiter_name' => \Input::post('leiter_name'), 'telefon' => \Input::post('telefon'), 'fax' => \Input::post('fax'), 'email' => \Input::post('email'), 'website' => \Input::post('website'), 'blog' => \Input::post('blog'), 'facebook' => \Input::post('facebook'), 'twitter' => \Input::post('twitter'), 'gplus' => \Input::post('gplus'), 'onleihe' => \Input::post('onleihe'), 'webkatalog' => \Input::post('webkatalog'), 'medien' => \Input::post('medien'), 'leistungen' => \Input::post('leistungen'), 'sonst_oeffnungszeiten' => \Input::post('sonst_oeffnungszeiten'), 'sonstmedien' => \Input::post('sonstmedien'), 'sonstleistungen' => \Input::post('sonstleistungen'), 'image_1' => $bnImageArr[1], 'image_2' => $bnImageArr[2], 'image_3' => $bnImageArr[3], 'image_4' => $bnImageArr[4], 'image_5' => $bnImageArr[5]);
         $opendates = $this->getOpenDatesForDB();
         $set = array_merge($set, $opendates);
         $geoData = $this->getcurrentGeoData();
         $set = array_merge($set, $geoData);
         $this->Database->prepare('UPDATE `tl_bn_libraries` %s WHERE `id`=?')->set($set)->execute($this->User->library_id);
         \Input::setPost('FORM_SUBMIT', '');
         $this->reload();
     }
     // Get the total number of items
     $objLibrary = \BnLibrariesModel::findLibByIdOrAlias($this->User->library_id);
     if ($objLibrary === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->articles = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     $libData = $objLibrary->row();
     // print_r($libData);
     // Leitungen
     $leitungen = array();
     $leitungenObj = $this->Database->prepare('SELECT * FROM `tl_bn_leitung` ORDER BY `sorting`')->execute();
     if ($leitungenObj->numRows > 0) {
         while ($leitungenObj->next()) {
             $leitungen[$leitungenObj->id] = $leitungenObj->name;
         }
     }
     $libData['leitungenArr'] = $leitungen;
     // Traeger
     $traeger = array();
     $traegerObj = $this->Database->prepare('SELECT * FROM `tl_bn_traeger` ORDER BY `sorting`')->execute();
     if ($traegerObj->numRows > 0) {
         while ($traegerObj->next()) {
             $traeger[$traegerObj->id] = $traegerObj->name;
         }
     }
     $libData['traegerArr'] = $traeger;
     // Medien
     $medien = array();
     $medienObj = $this->Database->prepare('SELECT * FROM `tl_bn_medien` ORDER BY `sorting`')->execute();
     if ($medienObj->numRows > 0) {
         while ($medienObj->next()) {
             $medien[$medienObj->id] = $medienObj->name;
         }
     }
     $libData['medienArr'] = $medien;
     // Leistungen
     $leistungen = array();
     $leistungenObj = $this->Database->prepare('SELECT * FROM `tl_bn_leistungen` ORDER BY `sorting`')->execute();
     if ($leistungenObj->numRows > 0) {
         while ($leistungenObj->next()) {
             $leistungen[$leistungenObj->id] = $leistungenObj->name;
         }
     }
     $libData['leistungenArr'] = $leistungen;
     // Email
     $this->import('String');
     $libData['email'] = $this->String->encodeEmail($libData['email']);
     // Open-Status
     $libData['open_status'] = $this->getCurrentOpenStatus($objLibrary);
     $GLOBALS['TL_JAVASCRIPT'][] = '.' . BN_PATH . '/assets/js/bn_fe.js';
     // Google-Maps url-search-string
     $libData['gmapsplace'] = ampersand($libData['strasse'] . ' ' . $libData['hausnummer'] . ', ' . $libData['plz'] . ' ' . $libData['ort'] . ', Niedersachsen');
     // media
     $medienIds = unserialize($libData['medien']);
     if (is_array($medienIds) && count($medienIds) > 0) {
         $medienArr = array();
         $medienObj = $this->Database->prepare("SELECT * FROM `tl_bn_medien` WHERE id IN(" . implode(',', array_map('intval', $medienIds)) . ")")->execute();
         if ($medienObj->numRows > 0) {
             while ($medienObj->next()) {
                 $medienArr[] = $medienObj->name;
             }
             $libData['medien'] = $medienArr;
         }
     }
     // leistungen
     $leistungenIds = unserialize($libData['leistungen']);
     if (is_array($leistungenIds) && count($leistungenIds) > 0) {
         $leistungenArr = array();
         $leistungenObj = $this->Database->prepare("SELECT * FROM `tl_bn_leistungen` WHERE id IN(" . implode(',', array_map('intval', $leistungenIds)) . ")")->execute();
         if ($leistungenObj->numRows > 0) {
             while ($leistungenObj->next()) {
                 $leistungenArr[] = $leistungenObj->name;
             }
             $libData['leistungen'] = $leistungenArr;
         }
     }
     $this->Template->data = $libData;
     $this->Template->articles = '';
//.........这里部分代码省略.........
开发者ID:srhinow,项目名称:branch_management,代码行数:101,代码来源:ModuleBmEditEntry.php

示例12: filterAllEvents

 /**
  * @param array   $events
  * @param array   $calendars
  * @param         $startTime
  * @param         $endTime
  * @param \Module $eventList
  *
  * @return array
  */
 public function filterAllEvents(array $events, array $calendars, $startTime, $endTime, \Module &$eventList)
 {
     global $container;
     if (!$eventList->calendarFilterField) {
         return $events;
     }
     $eventList->calendarFilterField = deserialize($eventList->calendarFilterField);
     if (!empty($eventList->calendarFilterField)) {
         if (empty($eventList->customTpl)) {
             $eventList->Template->setName('mod_eventlist_filter');
         }
         $eventList->Template->filterForm = '';
         if ($eventList->calendarFilterMergeMonth) {
             $eventList->calendarFilterField = implode(',', $eventList->calendarFilterField);
             $eventList->calendarFilterField = str_replace('startDate', 'startDate,mergeMonth', $eventList->calendarFilterField);
             $eventList->calendarFilterField = explode(',', $eventList->calendarFilterField);
         }
     }
     $this->eventList =& $eventList;
     $this->events = $events;
     $deleteSession = true;
     foreach ($eventList->calendarFilterField as $filterField) {
         if (\Input::post($filterField)) {
             continue;
         }
         $deleteSession = false;
     }
     if ($deleteSession) {
         \Session::getInstance()->remove('eventlistfilterreload_' . $this->eventList->id);
     }
     if (\Input::post('resetFilter') === '') {
         foreach ($eventList->calendarFilterField as $filterField) {
             if (!\Input::post($filterField)) {
                 continue;
             }
             \Input::setPost($filterField, '');
         }
     }
     \Session::getInstance()->set('eventlistfilterreload_' . $this->eventList->id, true);
     $restorePost = \Session::getInstance()->get('eventlistfilterpost_' . $this->eventList->id);
     if ($restorePost) {
         foreach ($restorePost as $postField => $postValue) {
             if (\Input::post($postField) === null) {
                 \Input::setPost($postField, $postValue);
             }
         }
         \Session::getInstance()->set('eventlistfilterreload_' . $this->eventList->id, false);
     }
     /** @var EventDispatcher $eventDispatcher */
     $eventDispatcher = $container['event-dispatcher'];
     if (!($filter = \Session::getInstance()->get('eventlistfilter_' . $this->eventList->id))) {
         $filter = array();
         foreach ($eventList->calendarFilterField as $filterField) {
             $filter[$filterField] = '';
         }
     }
     foreach ($filter as $post => $value) {
         if ($postValue = \Input::post($post)) {
             $filterEventsEvent = new PostFilterEventsEvent($post, $postValue);
             $filterEventsEvent->setEvents($this->events);
             $eventDispatcher->dispatch(PostFilterEventsEvent::NAME, $filterEventsEvent);
             $this->events = $filterEventsEvent->getEvents();
             $filterOptionsEvent = new GetFilterOptionsEvent();
             $eventDispatcher->dispatch(GetFilterOptionsEvent::NAME, $filterOptionsEvent);
             if ($filterOptionsEvent->hasOption($post)) {
                 continue;
             }
             $this->filterCalendar($this->events, array('field' => $post, 'value' => $postValue));
         }
     }
     $this->getFilter($filter);
     $postSession = array();
     foreach (array_keys($filter) as $postField) {
         $postValue = \Input::post($postField);
         if (!$postValue || $postValue === '') {
             continue;
         }
         $postSession[$postField] = $postValue;
     }
     if (count($postSession) > 0) {
         \Session::getInstance()->set('eventlistfilterpost_' . $this->eventList->id, $postSession);
     }
     if (count($postSession) < 1) {
         \Session::getInstance()->set('eventlistfilterpost_' . $this->eventList->id, null);
     }
     $this->eventList->Template->filterForm = $this->compileFilterForm($filter);
     $reload = false;
     if (\Session::getInstance()->get('eventlistfilterreload_' . $this->eventList->id)) {
         foreach ($this->eventList->calendarFilterField as $filterField) {
             if (\Input::post($filterField) != null && \Input::post($filterField) !== '0') {
                 $reload = true;
//.........这里部分代码省略.........
开发者ID:contaoblackforest,项目名称:contao-calendar-filter,代码行数:101,代码来源:Events.php

示例13: generate

 /**
  * Display a login form
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var \BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['login'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = '' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     // Set the last page visited
     if (!$_POST && $this->redirectBack) {
         $_SESSION['LAST_PAGE_VISITED'] = $this->getReferer();
     }
     // Login
     if (\Input::post('FORM_SUBMIT') == 'tl_login') {
         // Check whether username and password are set
         if (empty($_POST['username']) || empty($_POST['password'])) {
             $_SESSION['LOGIN_ERROR'] = $GLOBALS['TL_LANG']['MSC']['emptyField'];
             $this->reload();
         }
         $this->import('FrontendUser', 'User');
         $strRedirect = \Environment::get('request');
         // Redirect to the last page visited
         if ($this->redirectBack && $_SESSION['LAST_PAGE_VISITED'] != '') {
             $strRedirect = $_SESSION['LAST_PAGE_VISITED'];
         } else {
             // Redirect to the jumpTo page
             if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) {
                 $strRedirect = $this->generateFrontendUrl($objTarget->row());
             }
             // Overwrite the jumpTo page with an individual group setting
             $objMember = \MemberModel::findByUsername(\Input::post('username'));
             if ($objMember !== null) {
                 $arrGroups = deserialize($objMember->groups);
                 if (!empty($arrGroups) && is_array($arrGroups)) {
                     $objGroupPage = \MemberGroupModel::findFirstActiveWithJumpToByIds($arrGroups);
                     if ($objGroupPage !== null) {
                         $strRedirect = $this->generateFrontendUrl($objGroupPage->row());
                     }
                 }
             }
         }
         // Auto login is not allowed
         if (isset($_POST['autologin']) && !$this->autologin) {
             unset($_POST['autologin']);
             \Input::setPost('autologin', null);
         }
         // Login and redirect
         if ($this->User->login()) {
             $this->redirect($strRedirect);
         }
         $this->reload();
     }
     // Logout and redirect to the website root if the current page is protected
     if (\Input::post('FORM_SUBMIT') == 'tl_logout') {
         /** @var \PageModel $objPage */
         global $objPage;
         $this->import('FrontendUser', 'User');
         $strRedirect = \Environment::get('request');
         // Redirect to last page visited
         if ($this->redirectBack && strlen($_SESSION['LAST_PAGE_VISITED'])) {
             $strRedirect = $_SESSION['LAST_PAGE_VISITED'];
         } elseif ($objPage->protected) {
             $strRedirect = \Environment::get('base');
         }
         // Logout and redirect
         if ($this->User->logout()) {
             $this->redirect($strRedirect);
         }
         $this->reload();
     }
     return parent::generate();
 }
开发者ID:rheintechnology,项目名称:core,代码行数:81,代码来源:ModuleLogin.php

示例14: storeFileMetaInformation

 /**
  * Pre-fill the "alt" and "caption" fields with the file meta data
  * @param mixed
  * @param \DataContainer
  * @return mixed
  */
 public function storeFileMetaInformation($varValue, \DataContainer $dc)
 {
     if ($dc->activeRecord->singleSRC == $varValue) {
         return $varValue;
     }
     $objFile = \FilesModel::findByUuid($varValue);
     if ($objFile !== null) {
         $arrMeta = deserialize($objFile->meta);
         if (!empty($arrMeta)) {
             $strLanguage = "de";
             if (isset($arrMeta[$strLanguage])) {
                 \Input::setPost('alt', $arrMeta[$strLanguage]['title']);
                 \Input::setPost('caption', $arrMeta[$strLanguage]['caption']);
             }
         }
     }
     return $varValue;
 }
开发者ID:pressi,项目名称:zdps_customize,代码行数:24,代码来源:Tables.php

示例15: loadDataContainerHook

 /**
  * loadDataContainer hook
  *
  * - Saves the referrer in the session if it is a frontend URL
  * - Preselects the original template in the template editor
  *
  * @param  string $table The data container table name
  * @return void
  */
 public function loadDataContainerHook($table)
 {
     if (TL_MODE !== 'BE') {
         return;
     }
     if (defined('TL_REFERER_ID') && \Input::get('ref')) {
         $referrerSession = \Session::getInstance()->get('referer');
         if (!empty($referrerSession[\Input::get('ref')]['current'])) {
             $referrerSession[\Input::get('ref')]['current'] = preg_replace('(([&?])rsfhr=1(&|$))', '$1', $referrerSession[\Input::get('ref')]['current']);
             \Session::getInstance()->set('referer', $referrerSession);
         }
     }
     // Only handle requests from the frontend helper
     if (!\Input::get('rsfhr')) {
         return;
     }
     if ($table === 'tl_templates' && \Input::get('key') === 'new_tpl') {
         if (\Input::get('original') && !\Input::post('original')) {
             // Preselect the original template
             \Input::setPost('original', \Input::get('original'));
         }
         if (\Input::get('target') && !\Input::post('target')) {
             // Preselect the target template folder
             \Input::setPost('target', \Input::get('target'));
         }
     }
     $base = \Environment::get('path');
     if (version_compare(VERSION, '4.0', '>=')) {
         $base .= \System::getContainer()->get('router')->generate('contao_backend');
     } else {
         $base .= '/contao';
     }
     $referrer = parse_url(\Environment::get('httpReferer'));
     $referrer = $referrer['path'] . ($referrer['query'] ? '?' . $referrer['query'] : '');
     // Stop if the referrer is a backend URL
     if (substr($referrer, 0, strlen($base)) === $base && in_array(substr($referrer, strlen($base), 1), array(false, '/', '?'), true)) {
         return;
     }
     // Fix empty referrers
     if (empty($referrer)) {
         $referrer = '/';
     }
     // Make homepage possible as referrer
     if ($referrer === \Environment::get('path') . '/') {
         $referrer .= '?';
     }
     $assetsDir = version_compare(VERSION, '4.0', '>=') ? 'bundles/rocksolidfrontendhelper' : 'system/modules/rocksolid-frontend-helper/assets';
     $referrer = \Environment::get('path') . '/' . $assetsDir . '/html/referrer.html?referrer=' . rawurlencode($referrer);
     // set the frontend URL as referrer
     $referrerSession = \Session::getInstance()->get('referer');
     if (defined('TL_REFERER_ID') && !\Input::get('ref')) {
         $referrer = substr($referrer, strlen(TL_PATH) + 1);
         $tlRefererId = substr(md5(TL_START - 1), 0, 8);
         $referrerSession[$tlRefererId]['current'] = $referrer;
         \Input::setGet('ref', $tlRefererId);
         $requestUri = \Environment::get('requestUri');
         $requestUri .= (strpos($requestUri, '?') === false ? '?' : '&') . 'ref=' . $tlRefererId;
         \Environment::set('requestUri', $requestUri);
         if (version_compare(VERSION, '4.0', '>=')) {
             \System::getContainer()->get('request_stack')->getCurrentRequest()->query->set('ref', $tlRefererId);
         }
     } else {
         if (!defined('TL_REFERER_ID')) {
             $referrerSession['current'] = $referrer;
         }
     }
     \Session::getInstance()->set('referer', $referrerSession);
 }
开发者ID:madeyourday,项目名称:contao-rocksolid-frontend-helper,代码行数:77,代码来源:FrontendHelper.php


注:本文中的Input::setPost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。