get() public static method

Return a $_GET variable
public static get ( string $strKey, boolean $blnDecodeEntities = false, boolean $blnKeepUnused = false ) : mixed
$strKey string The variable name
$blnDecodeEntities boolean If true, all entities will be decoded
$blnKeepUnused boolean If true, the parameter will not be marked as used (see #4277)
return mixed The cleaned variable value
 /**
  * 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();
 }
 /**
  * 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&amp;nodes=' . $nodes);
         \Controller::redirect($url);
     }
 }
 /**
  * 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()));
 }
 /**
  * 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;
 }
示例#5
0
 /**
  * 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();
 }
示例#6
0
 /**
  * @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);
     }
 }
示例#7
0
文件: AjaxApi.php 项目: alnv/fmodul
 /**
  * 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;
     }
 }
 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;
 }
 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
0
 /**
  * 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
0
 /**
  * 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);
 }
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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('../');
 }
 /**
  * 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);
     }
 }
示例#16
0
 /**
  * @param $row
  * @param $href
  * @param $label
  * @param $title
  * @param $icon
  * @param $attributes
  * @return string
  */
 public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
 {
     if (strlen(Input::get('tid'))) {
         $this->toggleVisibility(Input::get('tid'), Input::get('state') == 1, @func_get_arg(12) ?: null);
         $this->redirect($this->getReferer());
     }
     // Check permissions AFTER checking the tid, so hacking attempts are logged
     if (!$this->User->hasAccess('tl_api_client::disable', 'alexf')) {
         return '';
     }
     $href .= '&amp;tid=' . $row['id'] . '&amp;state=' . $row['disable'];
     if ($row['disable']) {
         $icon = 'invisible.gif';
     }
     return '<a href="' . $this->addToUrl($href) . '" title="' . specialchars($title) . '"' . $attributes . '>' . Image::getHtml($icon, $label, 'data-state="' . ($row['disable'] ? 0 : 1) . '"') . '</a> ';
 }
 protected function compile()
 {
     global $objPage;
     // Get the current news item
     $objNewsItem = NewsModel::findPublishedByParentAndIdOrAlias(Input::get('items'), $this->news_archives);
     if ($objNewsItem === null) {
         parent::compile();
     }
     $objPage->canonicalType = $objNewsItem->canonicalType;
     $objPage->canonicalJumpTo = $objNewsItem->canonicalJumpTo;
     $objPage->canonicalWebsite = $objNewsItem->canonicalWebsite;
     if ($objNewsItem->canonicalType == 'self') {
         $objPage->canonicalType = 'external';
         $objPage->canonicalWebsite = Environment::get('url') . TL_PATH . '/' . Environment::get('request');
     }
     parent::compile();
 }
 /**
  * Generate the module
  *
  * @throws \Exception
  */
 protected function compile()
 {
     if (Input::get($this->redirectParamName)) {
         $this->redirectToModule(Input::get($this->redirectParamName, true));
     }
     System::loadLanguageFile('seo_serp_module');
     $this->Template->backHref = System::getReferer(true);
     $modules = $this->getModules();
     if (count($modules) > 0) {
         $GLOBALS['TL_CSS'][] = 'system/modules/seo_serp_preview/assets/css/module.min.css';
         $GLOBALS['TL_CSS'][] = 'system/modules/seo_serp_preview/assets/css/tests.min.css';
         $this->Template->modules = $this->generateModules($modules);
     }
     // Rebuild the cache in status manager
     $statusManager = new StatusManager();
     $statusManager->rebuildCache();
 }
示例#19
0
    /**
     * Generate the widget and return it as string
     *
     * @return string
     */
    public function generate()
    {
        $action = Input::get('actionPSTag');
        $tags = Input::get('ps_tags');
        $requestUri = Environment::get('requestUri');
        $requestUri = Helper::removeRequestTokenFromUri($requestUri);
        if ($action && $action == 'updateTags') {
            $this->updateTags($tags);
        }
        if ($action && $action == 'removeTags') {
            $this->removeTags($tags);
        }
        $GLOBALS['TL_JAVASCRIPT'][] = $GLOBALS['PS_PUBLIC_PATH'] . 'vendor/mootagify.js|static';
        $GLOBALS['TL_CSS'][] = $GLOBALS['PS_PUBLIC_PATH'] . 'css/mootagify-bootstrap.css|static';
        $GLOBALS['TL_CSS'][] = $GLOBALS['PS_PUBLIC_PATH'] . 'css/mootagify.css|static';
        $options = $this->options ? $this->options : array();
        $script = sprintf('<script>' . 'window.addEvent("domready", function(){

                var tagify = new mooTagify(document.id("tagWrap_%s"), null ,{
                    autoSuggest: true,
                    availableOptions: ' . json_encode($options) . '
                });

                tagify.addEvent("tagsUpdate", function(){

                    var tags = tagify.getTags();
                    document.id("ctrl_%s").set("value", tags.join());

                    new Request({url: "%s&actionPSTag=updateTags"}).get({"ps_tags": tags, "rt": Contao.request_token });

                });

                tagify.addEvent("tagRemove", function(tag){

                    var tags = tagify.getTags()

                    var deleted = tag;

                    document.id("ctrl_%s").set("value", tags.join());

                    new Request({url: "%s&actionPSTag=removeTags"}).get({ "ps_tags": deleted, "rt": Contao.request_token });

                });
            });' . '</script>', $this->strId, $this->strId, $requestUri, $this->strId, $requestUri);
        return sprintf('<input type="hidden" id="ctrl_%s" name="%s" value="%s"><div id="tagWrap_%s" class="hide"> <div class="tag-wrapper"></div> <div class="tag-input"> <input type="text" id="listTags" class="tl_text" name="listTags" value="%s" placeholder="%s"> </div> <div class="clear"></div></div>' . $script . '', $this->strId, $this->strName, specialchars($this->varValue), $this->strId, specialchars($this->varValue), $GLOBALS['TL_LANG']['MSC']['TagTextField']['tag']);
    }
 protected function compile()
 {
     global $objPage;
     // Get the current event
     $objEvent = CalendarEventsModel::findPublishedByParentAndIdOrAlias(Input::get('events'), $this->cal_calendar);
     if ($objEvent === null) {
         parent::compile();
     }
     $objPage->canonicalType = $objEvent->canonicalType;
     $objPage->canonicalJumpTo = $objEvent->canonicalJumpTo;
     $objPage->canonicalWebsite = $objEvent->canonicalWebsite;
     if ($objEvent->canonicalType == 'self') {
         $objPage->canonicalType = 'external';
         $objPage->canonicalWebsite = Environment::get('url') . TL_PATH . '/' . Environment::get('request');
     }
     parent::compile();
 }
 /**
  * Auto expand the tree
  *
  * @throws \Exception
  */
 public function autoExpandTree()
 {
     $session = Session::getInstance()->getData();
     if ($session['seo_serp_expand_tree'] !== 'tl_page' && !Input::get('serp_tests_expand')) {
         return;
     }
     $nodes = Database::getInstance()->execute("SELECT DISTINCT pid FROM tl_page WHERE pid>0");
     // Reset the array first
     $session['tl_page_tree'] = [];
     // Expand the tree
     while ($nodes->next()) {
         $session['tl_page_tree'][$nodes->pid] = 1;
     }
     // Avoid redirect loop
     $session['seo_serp_expand_tree'] = null;
     Session::getInstance()->setData($session);
     Backend::redirect(str_replace('serp_tests_expand=1', '', Environment::get('request')));
 }
 /**
  * Generate the widget and return it as string
  *
  * @return string
  */
 public function generate()
 {
     if (!is_array($this->varValue)) {
         $this->varValue = [];
     }
     $options = [];
     // Generate the options
     foreach ((array) $this->options as $option) {
         $linkId = sprintf('ctrl_%s_%s_%s_%s_link', $this->objDca->field, $this->objDca->id, $this->strId, $option['value']);
         $reference = $GLOBALS['TL_DCA'][$this->objDca->table]['fields'][$this->objDca->field]['reference'][$option['value']];
         $options[] = ['type' => ['label' => $option['label'], 'hint' => is_array($reference) ? $reference[1] : ''], 'picker' => ['tag' => $linkId, 'url' => sprintf('contao/page.php?do=%s&table=%s&field=%s&value=%s', Input::get('do'), $this->objDca->table, $this->objDca->field, str_replace(['{{link_url::', '}}'], '', $this->varValue[$option['value']]['link']))], 'link' => ['id' => $linkId, 'name' => sprintf('%s[%s][link]', $this->strId, $option['value']), 'value' => $this->varValue[$option['value']]['link']], 'title' => ['name' => sprintf('%s[%s][title]', $this->strId, $option['value']), 'value' => $this->varValue[$option['value']]['title']]];
     }
     $template = new BackendTemplate('be_cfg_link_registry_widget');
     $template->options = $options;
     $template->field = $this->objDca->field;
     $template->picker = ['id' => $this->objDca->field, 'title' => str_replace("'", "\\'", $GLOBALS['TL_LANG']['MOD']['page'][0]), 'image' => Image::getHtml('pickpage.gif', $GLOBALS['TL_LANG']['MSC']['pagepicker'], 'style="vertical-align:top;cursor:pointer"')];
     return $template->parse();
 }
示例#23
0
 /**
  * Run the controller and parse the template
  */
 public function run()
 {
     $template = new BackendTemplate('be_main');
     $template->main = '';
     // Ajax request
     if ($_POST && Environment::get('isAjaxRequest')) {
         $this->objAjax = new Ajax(Input::post('action'));
         $this->objAjax->executePreActions();
     }
     $strTable = Input::get('table');
     $strField = Input::get('field');
     // Define the current ID
     define('CURRENT_ID', Input::get('table') ? $this->Session->get('CURRENT_ID') : Input::get('id'));
     Controller::loadDataContainer($strTable);
     $strDriver = 'DC_' . $GLOBALS['TL_DCA'][$strTable]['config']['dataContainer'];
     $objDca = new $strDriver($strTable);
     $objDca->field = $strField;
     // Set the active record
     if ($this->Database->tableExists($strTable)) {
         /** @var Model $strModel $strModel */
         $strModel = Model::getClassFromTable($strTable);
         if (class_exists($strModel)) {
             $objModel = $strModel::findByPk(Input::get('id'));
             if ($objModel !== null) {
                 $objDca->activeRecord = $objModel;
             }
         }
     }
     // AJAX request
     if ($_POST && Environment::get('isAjaxRequest')) {
         $this->objAjax->executePostActions($objDca);
     }
     $partial = new BackendTemplate('be_rte_table_editor');
     $template->isPopup = true;
     $template->main = $partial->parse();
     $template->theme = Backend::getTheme();
     $template->base = Environment::get('base');
     $template->language = $GLOBALS['TL_LANGUAGE'];
     $template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pagepicker']);
     $template->charset = Config::get('characterSet');
     Config::set('debugMode', false);
     $template->output();
 }
示例#24
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var PageModel $objPage */
     global $objPage;
     $intActive = null;
     $articles = array();
     $intCount = 1;
     while ($this->objArticles->next()) {
         /** @var ArticleModel $objArticle */
         $objArticle = $this->objArticles->current();
         $strAlias = $objArticle->alias ?: $objArticle->id;
         // Active article
         if (\Input::get('articles') == $strAlias) {
             $articles[] = array('isActive' => true, 'href' => $this->generateFrontendUrl($objPage->row(), '/articles/' . $strAlias), 'title' => specialchars($objArticle->title, true), 'link' => $intCount);
             $intActive = $intCount - 1;
         } else {
             $articles[] = array('isActive' => false, 'href' => $this->generateFrontendUrl($objPage->row(), '/articles/' . $strAlias), 'title' => specialchars($objArticle->title, true), 'link' => $intCount);
         }
         ++$intCount;
     }
     $this->Template->articles = $articles;
     $total = count($articles);
     // Link to first element
     if ($intActive > 1) {
         $this->Template->first = array('href' => $articles[0]['href'], 'title' => $articles[0]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['first']);
     }
     $key = $intActive - 1;
     // Link to previous element
     if ($intCount > 1 && $key >= 0) {
         $this->Template->previous = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['previous']);
     }
     $key = $intActive + 1;
     // Link to next element
     if ($intCount > 1 && $key < $total) {
         $this->Template->next = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['next']);
     }
     $key = $total - 1;
     // Link to last element
     if ($intCount > 1 && $intActive < $key - 1) {
         $this->Template->last = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['last']);
     }
 }
示例#25
0
 /**
  * Initialize the controller
  *
  * 1. Import the user
  * 2. Call the parent constructor
  * 3. Login the user
  * 4. Load the language files
  * DO NOT CHANGE THIS ORDER!
  */
 public function __construct()
 {
     $this->import('BackendUser', 'User');
     parent::__construct();
     // Login
     if ($this->User->login()) {
         $strUrl = 'contao/main.php';
         // Redirect to the last page visited
         if (\Input::get('referer', true) != '') {
             $strUrl = base64_decode(\Input::get('referer', true));
         }
         $this->redirect($strUrl);
     } elseif (!empty($_POST['username']) && !empty($_POST['password'])) {
         $this->reload();
     } elseif ($this->User->logout()) {
         $this->reload();
     }
     \System::loadLanguageFile('default');
     \System::loadLanguageFile('tl_user');
 }
 protected function compile()
 {
     $db = \Database::getInstance();
     $intID = Input::get('companyID');
     $objCompany = CompanyModel::findByPk($intID);
     if ($objCompany) {
         global $objPage;
         $objPage->pageTitle = $objCompany->company;
         $objTemplate = new FrontendTemplate('company_detail');
         $objFile = FilesModel::findByPk($objCompany->logo);
         $arrSize = deserialize($this->imgSize);
         // Get Categories
         $strCategory = '';
         $arrCategories = deserialize($objCompany->category);
         if (count($arrCategories) > 0) {
             $arrCategory = array();
             $objCompanyCategories = $db->prepare("SELECT * FROM tl_company_category WHERE id IN(" . implode(',', $arrCategories) . ")")->execute();
             while ($objCompanyCategories->next()) {
                 $arrCategory[] = $objCompanyCategories->title;
             }
             $strCategory = implode(', ', $arrCategory);
         }
         $objTemplate->company = $objCompany->company;
         $objTemplate->contact_person = $objCompany->contact_person;
         $objTemplate->category = $strCategory;
         $objTemplate->street = $objCompany->street;
         $objTemplate->postal_code = $objCompany->postal_code;
         $objTemplate->city = $objCompany->city;
         $objTemplate->phone = $objCompany->phone;
         $objTemplate->fax = $objCompany->fax;
         $objTemplate->email = $objCompany->email;
         $objTemplate->homepage = $objCompany->homepage;
         $objTemplate->lat = $objCompany->lat;
         $objTemplate->lng = $objCompany->lng;
         $objTemplate->logo = \Image::get($objFile->path, $arrSize[0], $arrSize[1], $arrSize[2]);
         $objTemplate->imageWidth = $arrSize[0];
         $objTemplate->imageHeight = $arrSize[1];
         $objTemplate->information = $objCompany->information;
         $this->Template->strHtml = $objTemplate->parse();
     }
 }
示例#27
0
 /**
  * Run the controller
  *
  * @return Response
  */
 public function run()
 {
     switch (\Input::get('p')) {
         case 'facebook':
             $query = '?u=' . rawurlencode(\Input::get('u', true));
             $query .= '&t=' . rawurlencode(\Input::get('t', true));
             $query .= '&display=popup';
             $query .= '&redirect_uri=http%3A%2F%2Fwww.facebook.com';
             return new RedirectResponse('https://www.facebook.com/sharer/sharer.php' . $query);
             break;
         case 'twitter':
             $query = '?url=' . rawurlencode(\Input::get('u', true));
             $query .= '&text=' . rawurlencode(\Input::get('t', true));
             return new RedirectResponse('https://twitter.com/share' . $query);
             break;
         case 'gplus':
             $query = '?url=' . rawurlencode(\Input::get('u', true));
             return new RedirectResponse('https://plus.google.com/share' . $query);
             break;
     }
     return new RedirectResponse('../');
 }
 /**
  * Generate the icons by the given conditions.
  *
  * @param array $row The current record.
  *
  * @return string
  */
 public function generateDeviceConditionConfiguration($row)
 {
     if (!Input::get('do') == 'article' || !Input::get('do') == 'postmanager' || Input::get('task') == 'indexmanager') {
         return;
     }
     $conditions = deserialize($row['device_condition']);
     $allConditions = array('desktop', 'mobile');
     $return = '';
     Controller::loadLanguageFile('default');
     if (!$conditions) {
         foreach ($allConditions as $condition) {
             $return .= Image::getHtml('/system/modules/z_device-condition/assets/icons/' . $condition . '.png', $this->getTranslationForCondition($condition));
         }
     } else {
         foreach ($allConditions as $condition) {
             if (in_array($condition, $conditions)) {
                 $return .= Image::getHtml('/system/modules/z_device-condition/assets/icons/' . $condition . '.png', $this->getTranslationForCondition($condition));
             } else {
                 $return .= Image::getHtml('/system/modules/z_device-condition/assets/icons/disabled/' . $condition . '.png', $this->getTranslationForCondition($condition));
             }
         }
     }
     return $return;
 }
 public static function createLoadCallback($strTable, $fieldName)
 {
     return [function ($varValue, $dc) use($strTable, $fieldName) {
         // pull eloquent information out of dca
         $eloquent = $GLOBALS['TL_DCA'][$strTable]['fields'][$fieldName]['eloquent'];
         // creates method name for relation
         $relation = DCAEloquentifier::relationFromField($fieldName, @$eloquent['method']);
         // get relation from our model
         $collection = $GLOBALS['TL_DCA'][$strTable]['config']['model']::with($relation)->find($dc->id)->{$relation};
         if (!$collection) {
             if (Input::get('act') == 'edit' && $eloquent['relation'] == 'belongsTo' && Input::get('pid')) {
                 return $varValue;
             }
             return null;
         }
         // return one or multiple ids
         if ($eloquent['relation'] == 'hasOne' || $eloquent['relation'] == 'belongsTo') {
             return $collection->id;
         } elseif ($eloquent['relation'] == 'hasMany' || $eloquent['relation'] == 'belongsToMany') {
             return $collection->pluck('id')->toArray();
         }
         return null;
     }];
 }
 /**
  * @param integer $intId
  * @return string
  */
 protected function getCssClassName($intId)
 {
     return 'cssClass' . (Input::get('act') == 'editAll' ? '_' . $intId : '');
 }