本文整理汇总了PHP中Contao\Input::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::get方法的具体用法?PHP Input::get怎么用?PHP Input::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contao\Input
的用法示例。
在下文中一共展示了Input::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirect
/**
* Redirect to the content page when trying to access the content node.
*
* This fixes the edit links on the header.
*
* @return void
*/
public function redirect()
{
if ($this->input->get('table') === 'tl_content_node') {
$model = \ContentModel::findByPk($this->input->get('id'));
if (!$model) {
\Controller::log(sprintf('Content node "%s" not found', $this->input->get('id')), __METHOD__, TL_ERROR);
\Controller::redirect('contao/main.php?act=error');
}
$nodes = $model->ptable === 'tl_content_node' ? '1' : '';
$url = \Backend::addToUrl('table=tl_content&nodes=' . $nodes);
\Controller::redirect($url);
}
}
示例2: removeSubscriber
/**
* Remove the recipient
*/
protected function removeSubscriber()
{
$varInput = Idna::encodeEmail(Input::get('email', true));
// Validate e-mail address
if (!Validator::isEmail($varInput)) {
$_SESSION['UNSUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['email'];
$this->redirect($this->generateFrontendUrl($this->objModel->getRelated('jumpTo')->row()));
}
$objCleverReach = new CleverReach();
switch ($this->clr_unsubscribe) {
case 'inactive':
foreach ($this->clr_groups as $strGroupId) {
$objCleverReach->receiverSetInactive($varInput, $strGroupId);
}
break;
case 'delete':
foreach ($this->clr_groups as $strGroupId) {
$objCleverReach->receiverDelete($varInput, $strGroupId);
}
break;
case 'email':
default:
$objCleverReach->sendUnsubscribeMail($varInput, $this->clr_form);
break;
}
$this->redirect($this->generateFrontendUrl($this->objModel->getRelated('jumpTo')->row()));
}
示例3: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$this->Template->content = '';
$this->Template->referer = 'javascript:history.go(-1)';
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
$objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
if (null === $objNewsletter) {
throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
}
// Overwrite the page title (see #2853 and #4955)
if ($objNewsletter->subject != '') {
$objPage->pageTitle = strip_tags(\StringUtil::stripInsertTags($objNewsletter->subject));
}
// Add enclosure
if ($objNewsletter->addFile) {
$this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files');
}
// Support plain text newsletters (thanks to Hagen Klemp)
if ($objNewsletter->sendText) {
$strContent = nl2br_html5($objNewsletter->text);
} else {
$strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
}
// Parse simple tokens and insert tags
$strContent = $this->replaceInsertTags($strContent);
$strContent = \StringUtil::parseSimpleTokens($strContent, array());
// Encode e-mail addresses
$strContent = \StringUtil::encodeEmail($strContent);
$this->Template->content = $strContent;
$this->Template->subject = $objNewsletter->subject;
}
示例4: run
/**
* Run the controller and parse the login template
*
* @return Response
*/
public function run()
{
/** @var \BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_login');
// Show a cookie warning
if (\Input::get('referer', true) != '' && empty($_COOKIE)) {
$objTemplate->noCookies = $GLOBALS['TL_LANG']['MSC']['noCookies'];
}
$strHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['loginTo'], \Config::get('websiteTitle'));
$objTemplate->theme = \Backend::getTheme();
$objTemplate->messages = \Message::generate();
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
$objTemplate->languages = \System::getLanguages(true);
$objTemplate->title = specialchars($strHeadline);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->userLanguage = $GLOBALS['TL_LANG']['tl_user']['language'][0];
$objTemplate->headline = $strHeadline;
$objTemplate->curLanguage = \Input::post('language') ?: str_replace('-', '_', $GLOBALS['TL_LANGUAGE']);
$objTemplate->curUsername = \Input::post('username') ?: '';
$objTemplate->uClass = $_POST && empty($_POST['username']) ? ' class="login_error"' : '';
$objTemplate->pClass = $_POST && empty($_POST['password']) ? ' class="login_error"' : '';
$objTemplate->loginButton = specialchars($GLOBALS['TL_LANG']['MSC']['loginBT']);
$objTemplate->username = $GLOBALS['TL_LANG']['tl_user']['username'][0];
$objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
$objTemplate->feLink = $GLOBALS['TL_LANG']['MSC']['feLink'];
$objTemplate->disableCron = \Config::get('disableCron');
$objTemplate->default = $GLOBALS['TL_LANG']['MSC']['default'];
return $objTemplate->getResponse();
}
示例5: onCopyAddFView
/**
* @param $id
* @param \Contao\DataContainer $dca
*/
public function onCopyAddFView($id, \Contao\DataContainer $dca)
{
$view = \Contao\Input::get('view');
if ($id && $view) {
$this->Database->prepare('UPDATE tl_content SET fview = ? WHERE id = ? LIMIT 1')->execute($view, $id);
}
}
示例6: getAjaxResponse
/**
* F Module Ajax Api
* More: http://fmodul.alexandernaumov.de/ressourcen.html
*/
public function getAjaxResponse()
{
$action = Input::get('do');
if ($action) {
switch ($action) {
case 'getEntities':
$this->getEntities();
break;
case 'getDetail':
$this->getDetail();
break;
case 'getAutoCompletion':
$this->getAutoCompletion();
break;
default:
$this->getDefault();
break;
}
} else {
header('HTTP/1.1 500 Internal Server');
header('Content-Type: application/json; charset=UTF-8');
echo json_encode(array("No method defined"));
exit;
}
}
示例7: run
/**
* Run the controller and parse the template
*
* @return Response
*/
public function run()
{
/** @var \BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_preview');
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
$objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['fePreview']);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->site = \Input::get('site', true);
$objTemplate->switchHref = \System::getContainer()->get('router')->generate('contao_backend_switch');
if (\Input::get('url')) {
$objTemplate->url = \Environment::get('base') . \Input::get('url');
} elseif (\Input::get('page')) {
$objTemplate->url = $this->redirectToFrontendPage(\Input::get('page'), \Input::get('article'), true);
} else {
$objTemplate->url = \System::getContainer()->get('router')->generate('contao_root', [], UrlGeneratorInterface::ABSOLUTE_URL);
}
// Switch to a particular member (see #6546)
if (\Input::get('user') && $this->User->isAdmin) {
$objUser = \MemberModel::findByUsername(\Input::get('user'));
if ($objUser !== null) {
$strHash = $this->getSessionHash('FE_USER_AUTH');
// Remove old sessions
$this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute(time() - \Config::get('sessionTimeout'), $strHash);
// Insert the new session
$this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute($objUser->id, time(), 'FE_USER_AUTH', \System::getContainer()->get('session')->getId(), \Environment::get('ip'), $strHash);
// Set the cookie
$this->setCookie('FE_USER_AUTH', $strHash, time() + \Config::get('sessionTimeout'), null, null, false, true);
$objTemplate->user = \Input::post('user');
}
}
return $objTemplate->getResponse();
}
示例8: getAllEvents
public function getAllEvents($arrEvents, $arrCalendars, $intStart, $intEnd, \Contao\Module $objModule)
{
// FIXME it's possible to filter a list for categories, it doesn't allow by its configuration
$result = array();
$modCats = deserialize($objModule->event_categories, true);
$hasCatCfg = is_array($modCats) && count($modCats) > 0;
$filterParam_ar = array('category');
$objFilterMod = Database::getInstance()->prepare("SELECT mae_event_catname FROM tl_module WHERE mae_event_catname != '' AND type='mae_event_filter' AND mae_event_list=?")->execute($objModule->id);
while ($objFilterMod->fetchAssoc()) {
$filterParam_ar[] = $objFilterMod->mae_event_catname;
}
foreach ($filterParam_ar as $paramName) {
$filterCat = Input::get($paramName);
if (!empty($filterCat) && $filterCat != "all") {
if (!is_numeric($filterCat)) {
$objCat = Database::getInstance()->prepare("SELECT id FROM tl_mae_event_cat WHERE alias=?")->execute($filterCat);
if ($objCat->numRows == 1) {
$filterCat = $objCat->id;
}
}
if ($hasCatCfg) {
$modCats = array($filterCat);
$hasCatCfg = false;
} else {
$modCats[] = $filterCat;
}
}
// have filter value
}
// each possible category url parameter
if (is_array($arrEvents) && count($arrEvents) > 0 && count($modCats) > 0) {
foreach ($arrEvents as $day => $times) {
foreach ($times as $time => $events) {
foreach ($events as $event) {
$evtCats = unserialize($event['categories']);
if (!is_array($evtCats)) {
$evtCats = array();
}
foreach ($modCats as $modCat) {
if (in_array($modCat, $evtCats)) {
$result[$day][$time][] = $event;
break;
}
}
// compare categories module <=> event
}
// event
}
// times
}
// days
} else {
$result = $arrEvents;
}
// if no category filter set
return $result;
}
示例9: checkAccess
public function checkAccess()
{
$this->import('Input');
// If no access
if (Input::get('id') != '' && Input::get('id') != null && in_array(Input::get('id'), $this->filterFields(true))) {
$this->log('No access on secure access data ID "' . Input::get('id') . '"', 'tl_secure_accessdata __construct', TL_ERROR);
$this->redirect('main.php?act=error');
}
}
示例10: compile
/**
* Generate the module
*/
protected function compile()
{
$limit = null;
$offset = intval($this->skipFirst);
// Maximum number of items
if ($this->numberOfItems > 0) {
$limit = $this->numberOfItems;
}
// Handle featured news
if ($this->news_featured == 'featured') {
$blnFeatured = true;
} elseif ($this->news_featured == 'unfeatured') {
$blnFeatured = false;
} else {
$blnFeatured = null;
}
$this->Template->articles = array();
$this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyList'];
// Get the total number of items
$intTotal = $this->countItems($this->news_archives, $blnFeatured);
if ($intTotal < 1) {
return;
}
$total = $intTotal - $offset;
// Split the results
if ($this->perPage > 0 && (!isset($limit) || $this->numberOfItems > $this->perPage)) {
// Adjust the overall limit
if (isset($limit)) {
$total = min($limit, $total);
}
// Get the current page
$id = 'page_n' . $this->id;
$page = \Input::get($id) !== null ? \Input::get($id) : 1;
// Do not index or cache the page if the page number is outside the range
if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
throw new PageNotFoundException('Page not found');
}
// Set limit and offset
$limit = $this->perPage;
$offset += (max($page, 1) - 1) * $this->perPage;
$skip = intval($this->skipFirst);
// Overall limit
if ($offset + $limit > $total + $skip) {
$limit = $total + $skip - $offset;
}
// Add the pagination menu
$objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id);
$this->Template->pagination = $objPagination->generate("\n ");
}
$objArticles = $this->fetchItems($this->news_archives, $blnFeatured, $limit ?: 0, $offset);
// Add the articles
if ($objArticles !== null) {
$this->Template->articles = $this->parseArticles($objArticles);
}
$this->Template->archives = $this->news_archives;
}
示例11: generate
/**
* Redirect to an internal page
*
* @param \PageModel $objPage
*/
public function generate($objPage)
{
// Forward to the jumpTo or first published page
if ($objPage->jumpTo) {
/** @var \PageModel $objNextPage */
$objNextPage = $objPage->getRelated('jumpTo');
} else {
$objNextPage = \PageModel::findFirstPublishedRegularByPid($objPage->id);
}
// Forward page does not exist
if ($objNextPage === null) {
$this->log('Forward page ID "' . $objPage->jumpTo . '" does not exist', __METHOD__, TL_ERROR);
throw new ForwardPageNotFoundException('Forward page not found');
}
$strForceLang = null;
// Check the target page language (see #4706)
if (\Config::get('addLanguageToUrl')) {
$objNextPage->loadDetails();
// see #3983
$strForceLang = $objNextPage->language;
}
$strGet = '';
$strQuery = \Environment::get('queryString');
$arrQuery = array();
// Extract the query string keys (see #5867)
if ($strQuery != '') {
$arrChunks = explode('&', $strQuery);
foreach ($arrChunks as $strChunk) {
list($k, ) = explode('=', $strChunk, 2);
$arrQuery[] = $k;
}
}
// Add $_GET parameters
if (!empty($_GET)) {
foreach (array_keys($_GET) as $key) {
if (\Config::get('addLanguageToUrl') && $key == 'language') {
continue;
}
// Ignore the query string parameters (see #5867)
if (in_array($key, $arrQuery)) {
continue;
}
// Ignore the auto_item parameter (see #5886)
if ($key == 'auto_item') {
$strGet .= '/' . \Input::get($key);
} else {
$strGet .= '/' . $key . '/' . \Input::get($key);
}
}
}
// Append the query string (see #5867)
if ($strQuery != '') {
$strQuery = '?' . $strQuery;
}
$this->redirect($this->generateFrontendUrl($objNextPage->row(), $strGet, $strForceLang) . $strQuery, $objPage->redirect == 'temporary' ? 302 : 301);
}
示例12: appendPalettes
/**
* Append all current palettes with the device-condition field.
*
* @param string $table The current table.
*
* @return void
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function appendPalettes($table)
{
if (!is_array($GLOBALS['TL_DCA'][$table]['palettes']) || (!Input::get('do') == 'article' || !Input::get('do') == 'postmanager' || Input::get('task') == 'indexmanager')) {
return;
}
foreach (array_keys($GLOBALS['TL_DCA'][$table]['palettes']) as $palette) {
if ($palette != '__selector__') {
$GLOBALS['TL_DCA'][$table]['palettes'][$palette] .= ';{device_condition_legend},device_condition';
}
}
}
示例13: generate
/**
* Generate the widget and return it as string
*
* @return string
*/
public function generate()
{
$arrOptions = array();
if (!$this->multiple && count($this->arrOptions) > 1) {
$this->arrOptions = array($this->arrOptions[0]);
}
// The "required" attribute only makes sense for single checkboxes
if ($this->mandatory && !$this->multiple) {
$this->arrAttributes['required'] = 'required';
}
/** @var AttributeBagInterface $objSessionBag */
$objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
$state = $objSessionBag->get('checkbox_groups');
// Toggle the checkbox group
if (\Input::get('cbc')) {
$state[\Input::get('cbc')] = isset($state[\Input::get('cbc')]) && $state[\Input::get('cbc')] == 1 ? 0 : 1;
$objSessionBag->set('checkbox_groups', $state);
$this->redirect(preg_replace('/(&(amp;)?|\\?)cbc=[^& ]*/i', '', \Environment::get('request')));
}
$blnFirst = true;
$blnCheckAll = true;
foreach ($this->arrOptions as $i => $arrOption) {
// Single dimension array
if (is_numeric($i)) {
$arrOptions[] = $this->generateCheckbox($arrOption, $i);
continue;
}
$id = 'cbc_' . $this->strId . '_' . \StringUtil::standardize($i);
$img = 'folPlus.svg';
$display = 'none';
if (!isset($state[$id]) || !empty($state[$id])) {
$img = 'folMinus.svg';
$display = 'block';
}
$arrOptions[] = '<div class="checkbox_toggler' . ($blnFirst ? '_first' : '') . '"><a href="' . $this->addToUrl('cbc=' . $id) . '" onclick="AjaxRequest.toggleCheckboxGroup(this,\'' . $id . '\');Backend.getScrollOffset();return false">' . \Image::getHtml($img) . '</a>' . $i . '</div><fieldset id="' . $id . '" class="tl_checkbox_container checkbox_options" style="display:' . $display . '"><input type="checkbox" id="check_all_' . $id . '" class="tl_checkbox" onclick="Backend.toggleCheckboxGroup(this, \'' . $id . '\')"> <label for="check_all_' . $id . '" style="color:#a6a6a6"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label>';
// Multidimensional array
foreach ($arrOption as $k => $v) {
$arrOptions[] = $this->generateCheckbox($v, standardize($i) . '_' . $k);
}
$arrOptions[] = '</fieldset>';
$blnFirst = false;
$blnCheckAll = false;
}
// Add a "no entries found" message if there are no options
if (empty($arrOptions)) {
$arrOptions[] = '<p class="tl_noopt">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>';
$blnCheckAll = false;
}
if ($this->multiple) {
return sprintf('<fieldset id="ctrl_%s" class="tl_checkbox_container%s"><legend>%s%s%s%s</legend><input type="hidden" name="%s" value="">%s%s</fieldset>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->mandatory ? '<span class="invisible">' . $GLOBALS['TL_LANG']['MSC']['mandatory'] . ' </span>' : '', $this->strLabel, $this->mandatory ? '<span class="mandatory">*</span>' : '', $this->xlabel, $this->strName, $blnCheckAll ? '<input type="checkbox" id="check_all_' . $this->strId . '" class="tl_checkbox" onclick="Backend.toggleCheckboxGroup(this,\'ctrl_' . $this->strId . '\')' . ($this->onclick ? ';' . $this->onclick : '') . '"> <label for="check_all_' . $this->strId . '" style="color:#a6a6a6"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label><br>' : '', str_replace('<br></fieldset><br>', '</fieldset>', implode('<br>', $arrOptions)), $this->wizard);
} else {
return sprintf('<div id="ctrl_%s" class="tl_checkbox_single_container%s"><input type="hidden" name="%s" value="">%s</div>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->strName, str_replace('<br></div><br>', '</div>', implode('<br>', $arrOptions)), $this->wizard);
}
}
示例14: run
/**
* Run the controller
*
* @return RedirectResponse
*/
public function run()
{
switch (\Input::get('p')) {
case 'facebook':
return new RedirectResponse('https://www.facebook.com/sharer/sharer.php' . '?u=' . rawurlencode(\Input::get('u', true)));
case 'twitter':
return new RedirectResponse('https://twitter.com/intent/tweet' . '?url=' . rawurlencode(\Input::get('u', true)) . '&text=' . rawurlencode(\Input::get('t', true)));
case 'gplus':
return new RedirectResponse('https://plus.google.com/share' . '?url=' . rawurlencode(\Input::get('u', true)));
}
return new RedirectResponse('../');
}
示例15: restrict
/**
* Restrict the content elements.
*
* @param int $contentId The id of the current content element.
* @param Node $node The node type.
*
* @return void
* @throws AccessDeniedException When an invalid content element type is accessed.
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function restrict($contentId, Node $node = null)
{
$nodeType = $node ? $node->getName() : null;
$allowedElements = $this->registry->filterContentElements($GLOBALS['TL_CTE'], $nodeType);
if (empty($allowedElements)) {
$this->closeDataContainer();
} elseif (!in_array($this->definition->get('fields/type/default'), $allowedElements)) {
$this->setDefaults($allowedElements);
}
if ($this->input->get('act') != '' && $this->input->get('act') !== 'select') {
$GLOBALS['TL_CTE'] = $allowedElements;
$this->restrictIds($allowedElements, $contentId);
}
}