public function current() { if (version_compare(VERSION, '3', '>=')) { return System::getReferer(); } else { return $this->getReferer(); } }
/** * @param \NotificationCenter\Model\Notification[] $notifications * @param int[] $ids * * @return string */ public static function generateForm(array $notifications, array $ids) { $return = ' <div id="tl_buttons"> <a href="' . \System::getReferer(true) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a> </div> <h2 class="sub_headline">' . $GLOBALS['TL_LANG']['tl_lead']['notification'][0] . '</h2> ' . \Message::generate() . ' <form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_leads_notification" class="tl_form" method="post"> <div class="tl_formbody_edit"> <input type="hidden" name="FORM_SUBMIT" value="tl_leads_notification"> <input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '"> <input type="hidden" name="IDS[]" value="' . implode('"> <input type="hidden" name="IDS[]" value="', $ids) . '"> <div class="tl_tbox"> <h3><label for="notification">' . $GLOBALS['TL_LANG']['tl_lead']['notification_list'][0] . '</label></h3> <select name="notification" id="notification" class="tl_select">'; // Generate options foreach ($notifications as $id => $name) { $return .= '<option value="' . $id . '">' . $name . '</option>'; } $return .= ' </select> <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_lead']['notification_list'][1] . '</p> </div> </div> <div class="tl_formbody_submit"> <div class="tl_submit_container"> <input type="submit" name="save" id="save" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['tl_lead']['notification'][0]) . '"> </div> </div> </form>'; return $return; }
/** * Show header of the parent table and list all records of the current table * @return string */ protected function parentView() { $blnClipboard = false; $arrClipboard = $this->Session->get('CLIPBOARD'); $blnHasSorting = false; $blnMultiboard = false; // Check clipboard if (!empty($arrClipboard[$this->strTable])) { $blnClipboard = true; $arrClipboard = $arrClipboard[$this->strTable]; if (is_array($arrClipboard['id'])) { $blnMultiboard = true; } } // Load the fonts to display the paste hint $GLOBALS['TL_CONFIG']['loadGoogleFonts'] = $blnClipboard; $strBackUrl = \Input::get('id') ? 'contao/main.php?do=iso_products' : \System::getReferer(true, $this->ptable); $return = ' <div id="tl_buttons">' . (\Input::get('nb') ? ' ' : ' <a href="' . $strBackUrl . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b" onclick="Backend.getScrollOffset()">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>') . ' ' . (!$blnClipboard ? \Input::get('act') != 'select' ? (!$GLOBALS['TL_DCA'][$this->strTable]['config']['closed'] && !$GLOBALS['TL_DCA'][$this->strTable]['config']['notCreatable'] ? ' <a href="' . $this->addToUrl($blnHasSorting ? 'act=paste&mode=create' : 'act=create&mode=2&pid=' . $this->intId) . '" class="header_new" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['new'][1]) . '" accesskey="n" onclick="Backend.getScrollOffset()">' . $GLOBALS['TL_LANG'][$this->strTable]['new'][0] . '</a> ' : '') . $this->generateGlobalButtons() : '' : '<a href="' . $this->addToUrl('clipboard=1') . '" class="header_clipboard" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['clearClipboard']) . '" accesskey="x">' . $GLOBALS['TL_LANG']['MSC']['clearClipboard'] . '</a> ') . ' </div>' . \Message::generate(true); // Get all details of the parent record $objParent = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute(CURRENT_ID); if ($objParent->numRows < 1) { return $return; } $return .= (\Input::get('act') == 'select' ? ' <form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_select" class="tl_form" method="post"> <div class="tl_formbody"> <input type="hidden" name="FORM_SUBMIT" value="tl_select"> <input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">' : '') . ($blnClipboard ? ' <div id="paste_hint"> <p>' . $GLOBALS['TL_LANG']['MSC']['selectNewPosition'] . '</p> </div>' : '') . ' <div class="tl_listing_container iso_listing_container parent_view"> <div class="tl_header click2edit" onmouseover="Theme.hoverDiv(this,1)" onmouseout="Theme.hoverDiv(this,0)">'; // List all records of the child table if (!\Input::get('act') || \Input::get('act') == 'paste' || \Input::get('act') == 'select') { $imagePasteAfter = \Image::getHtml('pasteafter.gif', $GLOBALS['TL_LANG'][$this->strTable]['pasteafter'][0]); $imageEditHeader = \Image::getHtml('edit.gif', $GLOBALS['TL_LANG'][$this->strTable]['edit'][0]); $strEditHeader = $GLOBALS['TL_LANG'][$this->strTable]['edit'][0]; $return .= ' <div class="tl_content_right">' . (\Input::get('act') == 'select' ? ' <label for="tl_select_trigger" class="tl_select_label">' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</label> <input type="checkbox" id="tl_select_trigger" onclick="Backend.toggleCheckboxes(this)" class="tl_tree_checkbox">' : (!$GLOBALS['TL_DCA'][$this->ptable]['config']['notEditable'] ? ' <a href="' . preg_replace('/&(amp;)?table=[^& ]*/i', $this->ptable != '' ? '&table=' . $this->ptable : '', $this->addToUrl('act=edit')) . '" class="edit" title="' . specialchars($strEditHeader) . '">' . $imageEditHeader . '</a>' : '') . ($blnHasSorting && !$GLOBALS['TL_DCA'][$this->strTable]['config']['closed'] && !$GLOBALS['TL_DCA'][$this->strTable]['config']['notCreatable'] ? ' <a href="' . $this->addToUrl('act=create&mode=2&pid=' . $objParent->id . '&id=' . $this->intId) . '" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['pastenew'][0]) . '">' . $imagePasteNew . '</a>' : '') . ($blnClipboard ? ' <a href="' . $this->addToUrl('act=' . $arrClipboard['mode'] . '&mode=2&pid=' . $objParent->id . (!$blnMultiboard ? '&id=' . $arrClipboard['id'] : '')) . '" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['pasteafter'][0]) . '" onclick="Backend.getScrollOffset()">' . $imagePasteAfter . '</a>' : '')) . ' </div>'; // Format header fields $add = array(); $headerFields = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['headerFields']; foreach ($headerFields as $v) { $_v = deserialize($objParent->{$v}); if (is_array($_v)) { $_v = implode(', ', $_v); } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['multiple']) { $_v = $_v != '' ? $GLOBALS['TL_LANG']['MSC']['yes'] : $GLOBALS['TL_LANG']['MSC']['no']; } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['rgxp'] == 'date') { $_v = $_v ? \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $_v) : '-'; } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['rgxp'] == 'time') { $_v = $_v ? \Date::parse($GLOBALS['TL_CONFIG']['timeFormat'], $_v) : '-'; } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['rgxp'] == 'datim') { $_v = $_v ? \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $_v) : '-'; } elseif ($v == 'tstamp') { $objMaxTstamp = $this->Database->prepare("SELECT MAX(tstamp) AS tstamp FROM " . $this->strTable . " WHERE pid=?")->execute($objParent->id); if (!$objMaxTstamp->tstamp) { $objMaxTstamp->tstamp = $objParent->tstamp; } $_v = \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], max($objParent->tstamp, $objMaxTstamp->tstamp)); } elseif (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['foreignKey'])) { $arrForeignKey = explode('.', $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['foreignKey'], 2); $objLabel = $this->Database->prepare("SELECT " . $arrForeignKey[1] . " AS value FROM " . $arrForeignKey[0] . " WHERE id=?")->limit(1)->execute($_v); if ($objLabel->numRows) { $_v = $objLabel->value; } } elseif (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$_v])) { $_v = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$_v][0]; } elseif (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$_v])) { $_v = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$_v]; } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['isAssociative'] || array_is_assoc($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options'])) { $_v = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options'][$_v]; } // Add the sorting field if ($_v != '') { $key = isset($GLOBALS['TL_LANG'][$this->strTable][$v][0]) ? $GLOBALS['TL_LANG'][$this->strTable][$v][0] : $v; $add[$key] = $_v; } } // Trigger the header_callback (see #3417) if (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['header_callback'])) { $strClass = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['header_callback'][0]; $strMethod = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['header_callback'][1]; $this->import($strClass); $add = $this->{$strClass}->{$strMethod}($add, $this); } elseif (is_callable($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['header_callback'])) { $add = call_user_func($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['header_callback'], $add, $this); } // Output the header data $return .= ' <table class="tl_header_table">'; foreach ($add as $k => $v) { if (is_array($v)) { $v = $v[0]; } $return .= ' <tr> <td><span class="tl_label">' . $k . ':</span> </td> <td>' . $v . '</td> </tr>'; } $return .= ' </table> </div>'; $orderBy = array(); $firstOrderBy = array(); // Add all records of the current table $query = "SELECT * FROM " . $this->strTable; if (is_array($this->orderBy) && strlen($this->orderBy[0])) { $orderBy = $this->orderBy; $firstOrderBy = preg_replace('/\\s+.*$/', '', $orderBy[0]); // Order by the foreign key if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$firstOrderBy]['foreignKey'])) { $key = explode('.', $GLOBALS['TL_DCA'][$this->strTable]['fields'][$firstOrderBy]['foreignKey'], 2); $query = "SELECT *, (SELECT " . $key[1] . " FROM " . $key[0] . " WHERE " . $this->strTable . "." . $firstOrderBy . "=" . $key[0] . ".id) AS foreignKey FROM " . $this->strTable; $orderBy[0] = 'foreignKey'; } } elseif (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['fields'])) { $orderBy = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['fields']; $firstOrderBy = preg_replace('/\\s+.*$/', '', $orderBy[0]); } $this->procedure[] = "pid=?"; $this->values[] = CURRENT_ID; // Support empty ptable fields (backwards compatibility) if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dynamicPtable']) { $this->procedure[] = "ptable=?"; $this->values[] = $this->strTable; } // WHERE if (!empty($this->procedure)) { $query .= " WHERE " . implode(' AND ', $this->procedure); } if (!empty($this->root) && is_array($this->root)) { $query .= (!empty($this->procedure) ? " AND " : " WHERE ") . "id IN(" . implode(',', array_map('intval', $this->root)) . ")"; } // ORDER BY if (!empty($orderBy) && is_array($orderBy)) { $query .= " ORDER BY " . implode(', ', $orderBy); } $objOrderByStmt = $this->Database->prepare($query); // LIMIT if (strlen($this->limit)) { $arrLimit = explode(',', $this->limit); $objOrderByStmt->limit($arrLimit[1], $arrLimit[0]); } $objOrderBy = $objOrderByStmt->execute($this->values); if ($objOrderBy->numRows < 1) { return $return . ' <p class="tl_empty_parent_view">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p> </div>'; } $result = $objOrderBy->fetchAllAssoc(); $return .= ' <table class="tl_listing' . ($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['showColumns'] ? ' showColumns' : '') . '">'; // Automatically add the "order by" field as last column if we do not have group headers if ($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['showColumns']) { $blnFound = false; // Extract the real key and compare it to $firstOrderBy foreach ($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['fields'] as $f) { if (strpos($f, ':') !== false) { list($f, ) = explode(':', $f, 2); } if ($firstOrderBy == $f) { $blnFound = true; break; } } if (!$blnFound) { $GLOBALS['TL_DCA'][$this->strTable]['list']['label']['fields'][] = $firstOrderBy; } } // Generate the table header if the "show columns" option is active if ($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['showColumns']) { $return .= ' <tr>'; foreach ($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['fields'] as $f) { if (strpos($f, ':') !== false) { list($f, ) = explode(':', $f, 2); } $return .= ' <th class="tl_folder_tlist col_' . $f . ($f == $firstOrderBy ? ' ordered_by' : '') . '">' . (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$f]['label']) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$f]['label'][0] : $GLOBALS['TL_DCA'][$this->strTable]['fields'][$f]['label']) . '</th>'; } $return .= ' <th class="tl_folder_tlist tl_right_nowrap iso_operations"> </th> </tr>'; } // Process result and add label and buttons $remoteCur = false; $groupclass = 'tl_folder_tlist'; $eoCount = -1; foreach ($result as $row) { $args = array(); $this->current[] = $row['id']; $showFields = $GLOBALS['TL_DCA'][$this->strTable]['list']['label']['fields']; // Label foreach ($showFields as $k => $v) { // Decrypt the value if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['encrypt']) { $row[$v] = \Encryption::decrypt(deserialize($row[$v])); } if (strpos($v, ':') !== false) { list($strKey, $strTable) = explode(':', $v); list($strTable, $strField) = explode('.', $strTable); $objRef = $this->Database->prepare("SELECT " . $strField . " FROM " . $strTable . " WHERE id=?")->limit(1)->execute($row[$strKey]); $args[$k] = $objRef->numRows ? $objRef->{$strField} : ''; } elseif (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['flag'], array(5, 6, 7, 8, 9, 10))) { if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['rgxp'] == 'date') { $args[$k] = $row[$v] ? \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $row[$v]) : '-'; } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['rgxp'] == 'time') { $args[$k] = $row[$v] ? \Date::parse($GLOBALS['TL_CONFIG']['timeFormat'], $row[$v]) : '-'; } else { $args[$k] = $row[$v] ? \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $row[$v]) : '-'; } } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['multiple']) { $args[$k] = $row[$v] != '' ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['label'][0] : ''; } else { $row_v = deserialize($row[$v]); if (is_array($row_v)) { $args_k = array(); foreach ($row_v as $option) { $args_k[] = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$option] ?: $option; } $args[$k] = implode(', ', $args_k); } elseif (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$row[$v]])) { $args[$k] = is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$row[$v]]) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$row[$v]][0] : $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$row[$v]]; } elseif (($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['isAssociative'] || array_is_assoc($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options'])) && isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options'][$row[$v]])) { $args[$k] = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options'][$row[$v]]; } else { $args[$k] = $row[$v]; } } } // Shorten the label it if it is too long $label = vsprintf($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['format'] ?: '%s', $args); if ($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['maxCharacters'] > 0 && $GLOBALS['TL_DCA'][$this->strTable]['list']['label']['maxCharacters'] < strlen(strip_tags($label))) { $label = trim(\String::substrHtml($label, $GLOBALS['TL_DCA'][$this->strTable]['list']['label']['maxCharacters'])) . ' …'; } // Remove empty brackets (), [], {}, <> and empty tags from the label $label = preg_replace('/\\( *\\) ?|\\[ *\\] ?|\\{ *\\} ?|< *> ?/', '', $label); $label = preg_replace('/<[^>]+>\\s*<\\/[^>]+>/', '', $label); // Build the sorting groups if ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] > 0) { $current = $row[$firstOrderBy]; $orderBy = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['fields']; $sortingMode = count($orderBy) == 1 && $firstOrderBy == $orderBy[0] && $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['flag'] != '' && $GLOBALS['TL_DCA'][$this->strTable]['fields'][$firstOrderBy]['flag'] == '' ? $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['flag'] : $GLOBALS['TL_DCA'][$this->strTable]['fields'][$firstOrderBy]['flag']; $remoteNew = $this->formatCurrentValue($firstOrderBy, $current, $sortingMode); // Add the group header if (!$GLOBALS['TL_DCA'][$this->strTable]['list']['label']['showColumns'] && !$GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['disableGrouping'] && ($remoteNew != $remoteCur || $remoteCur === false)) { $eoCount = -1; $group = $this->formatGroupHeader($firstOrderBy, $remoteNew, $sortingMode, $row); $remoteCur = $remoteNew; $return .= ' <tr> <td colspan="2" class="' . $groupclass . '">' . $group . '</td> </tr>'; $groupclass = 'tl_folder_list'; } } $return .= ' <tr class="' . (++$eoCount % 2 == 0 ? 'even' : 'odd') . ' click2edit" onmouseover="Theme.hoverRow(this,1)" onmouseout="Theme.hoverRow(this,0)" onclick="Theme.toggleSelect(this)"> '; $colspan = 1; // Call the label callback ($row, $label, $this) if (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['label_callback']) || is_callable($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['label_callback'])) { if (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['label_callback'])) { $strClass = $GLOBALS['TL_DCA'][$this->strTable]['list']['label']['label_callback'][0]; $strMethod = $GLOBALS['TL_DCA'][$this->strTable]['list']['label']['label_callback'][1]; $this->import($strClass); $args = $this->{$strClass}->{$strMethod}($row, $label, $this, $args); } else { $args = call_user_func($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['label_callback'], $row, $label, $this, $args); } // Handle strings and arrays (backwards compatibility) if (!$GLOBALS['TL_DCA'][$this->strTable]['list']['label']['showColumns']) { $label = is_array($args) ? implode(' ', $args) : $args; } elseif (!is_array($args)) { $args = array($args); $colspan = count($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['fields']); } } // Show columns if ($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['showColumns']) { foreach ($args as $j => $arg) { $return .= '<td colspan="' . $colspan . '" class="tl_file_list col_' . $GLOBALS['TL_DCA'][$this->strTable]['list']['label']['fields'][$j] . ($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['fields'][$j] == $firstOrderBy ? ' ordered_by' : '') . '">' . ($arg ?: '-') . '</td>'; } } else { $return .= '<td class="tl_file_list">' . $label . '</td>'; } // Buttons ($row, $table, $root, $blnCircularReference, $childs, $previous, $next) $return .= (\Input::get('act') == 'select' ? ' <td class="tl_file_list tl_right_nowrap iso_operations"><input type="checkbox" name="IDS[]" id="ids_' . $row['id'] . '" class="tl_tree_checkbox" value="' . $row['id'] . '"></td>' : ' <td class="tl_file_list tl_right_nowrap iso_operations">' . $this->generateButtons($row, $this->strTable, $this->root) . '</td>') . ' </tr>'; } // Close the table $return .= ' </table> </div>'; } // Close form if (\Input::get('act') == 'select') { // Submit buttons $arrButtons = array(); if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['notDeletable']) { $arrButtons['delete'] = '<input type="submit" name="delete" id="delete" class="tl_submit" accesskey="d" onclick="return confirm(\'' . $GLOBALS['TL_LANG']['MSC']['delAllConfirm'] . '\')" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['deleteSelected']) . '">'; } if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['notSortable']) { $arrButtons['cut'] = '<input type="submit" name="cut" id="cut" class="tl_submit" accesskey="x" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['moveSelected']) . '">'; } if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['notCopyable']) { $arrButtons['copy'] = '<input type="submit" name="copy" id="copy" class="tl_submit" accesskey="c" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['copySelected']) . '">'; } if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['notEditable']) { $arrButtons['override'] = '<input type="submit" name="override" id="override" class="tl_submit" accesskey="v" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['overrideSelected']) . '">'; $arrButtons['edit'] = '<input type="submit" name="edit" id="edit" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['editSelected']) . '">'; } // Call the buttons_callback (see #4691) if (is_array($GLOBALS['TL_DCA'][$this->strTable]['select']['buttons_callback'])) { foreach ($GLOBALS['TL_DCA'][$this->strTable]['select']['buttons_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $arrButtons = $this->{$callback}[0]->{$callback}[1]($arrButtons, $this); } elseif (is_callable($callback)) { $arrButtons = $callback($arrButtons, $this); } } } $return .= ' <div class="tl_formbody_submit" style="text-align:right"> <div class="tl_submit_container"> ' . implode(' ', $arrButtons) . ' </div> </div> </div> </form>'; } return $return; }
/** * * Add contao core tokens, as long as the cron job does not have these information * on sending mail in queue mode * * @param $arrTokens * @param $strLanguage * @return bool false if context_tokens has been set already (required by cron) */ protected function addContextTokens($objMessage, &$arrTokens, $strLanguage) { // add context tokens only once (queue will trigger this function again, and tokens might be overwritten) if (isset($arrTokens['context_tokens'])) { return false; } $arrTokens['context_tokens'] = true; // add environment variables as token $arrTokens['env_host'] = \Idna::decode(\Environment::get('host')); $arrTokens['env_http_host'] = \Idna::decode(\Environment::get('httpHost')); $arrTokens['env_url'] = \Idna::decode(\Environment::get('url')); $arrTokens['env_path'] = \Idna::decode(\Environment::get('base')); $arrTokens['env_request'] = \Idna::decode(\Environment::get('indexFreeRequest')); $arrTokens['env_ip'] = \Idna::decode(\Environment::get('ip')); $arrTokens['env_referer'] = \System::getReferer(); $arrTokens['env_files_url'] = TL_FILES_URL; $arrTokens['env_plugins_url'] = TL_ASSETS_URL; $arrTokens['env_script_url'] = TL_ASSETS_URL; // add date tokens $arrTokens['date'] = \Controller::replaceInsertTags('{{date}}'); $arrTokens['last_update'] = \Controller::replaceInsertTags('{{last_update}}'); if (TL_MODE == 'FE') { // add current page as token global $objPage; if ($objPage !== null) { foreach ($objPage->row() as $key => $value) { $arrTokens['page_' . $key] = $value; } if ($objPage->pageTitle == '') { $arrTokens['pageTitle'] = $objPage->title; } else { if ($objPage->parentPageTitle == '') { $arrTokens['parentPageTitle'] = $objPage->parentTitle; } else { if ($objPage->mainPageTitle == '') { $arrTokens['mainPageTitle'] = $objPage->mainTitle; } } } } // add user attributes as token if (FE_USER_LOGGED_IN) { $arrUserData = \FrontendUser::getInstance()->getData(); if (is_array($arrUserData)) { foreach ($arrUserData as $key => $value) { if (!is_array($value) && \Validator::isBinaryUuid($value)) { $value = \StringUtil::binToUuid($value); $objFile = \FilesModel::findByUuid($value); if ($objFile !== null) { $value = $objFile->path; } } $arrTokens['user_' . $key] = $value; } } } } }
/** * Undo the record manually triggered in the backend * @param \DataContainer */ public function callback(\DataContainer $dc) { static::undo($dc->id); \System::redirect(\System::getReferer()); }
/** * Contao Open Source CMS * * Copyright (C) 2005-2015 Leo Feyer * * @copyright Tim Gatzky 2013, Premium Contao Webworks, Premium Contao Themes * @author Tim Gatzky <*****@*****.**> * @package pct_customelements * @subpackage pct_customelements_plugin_customcatalog * @subpackage pct_customelements_customcatalog_feeds * @link http://contao.org */ /** * Load language file */ $this->loadLanguageFile('tl_news_feed'); $objDcaHelper = \PCT\CustomElements\Plugins\CustomCatalog\Helper\DcaHelper::getInstance()->setTable('tl_pct_customcatalog_feed'); /** * Table tl_pct_customcatalog_feed */ $GLOBALS['TL_DCA'][$objDcaHelper->getTable()] = array('config' => array('dataContainer' => 'Table', 'enableVersioning' => true, 'ptable' => 'tl_pct_customelement', 'onload_callback' => array(array('PCT\\CustomCatalog\\Feeds\\TableCustomCatalogFeed', 'generateFeed')), 'onsubmit_callback' => array(array('PCT\\CustomCatalog\\Feeds\\TableCustomCatalogFeed', 'scheduleUpdate')), 'sql' => array('keys' => array('id' => 'primary', 'alias' => 'index')), 'backlink' => \System::getReferer()), 'list' => array('sorting' => array('mode' => 1, 'fields' => array('title'), 'flag' => 1, 'panelLayout' => 'filter;search,limit'), 'label' => array('fields' => array('title'), 'format' => '%s'), 'global_operations' => array('all' => array('label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'href' => 'act=select', 'class' => 'header_edit_all', 'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"')), 'operations' => array('edit' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['edit'], 'href' => 'act=edit', 'icon' => 'edit.gif'), 'copy' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['copy'], 'href' => 'act=copy', 'icon' => 'copy.gif'), 'delete' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['delete'], 'href' => 'act=delete', 'icon' => 'delete.gif', 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'), 'show' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['show'], 'href' => 'act=show', 'icon' => 'show.gif')))); /** * Palettes */ $arrPalettes = array('title_legend' => array('title', 'alias', 'language'), 'configs_legend' => array('configs', 'jumpTo'), 'export_legend' => array('titleField', 'publishedField', 'descriptionField', 'authorField', 'imageField'), 'config_legend' => array('format', 'maxItems', 'feedBase', 'description')); $GLOBALS['TL_DCA'][$objDcaHelper->getTable()]['palettes']['default'] = $objDcaHelper->generatePalettes($arrPalettes); /** * Fields */ $objDcaHelper->addFields(array('id' => array('sql' => "int(10) unsigned NOT NULL auto_increment"), 'pid' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'tstamp' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'title' => array('label' => &$GLOBALS['TL_LANG']['tl_news_feed']['title'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 255), 'sql' => "varchar(255) NOT NULL default ''"), 'alias' => array('label' => &$GLOBALS['TL_LANG']['tl_news_feed']['alias'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('mandatory' => true, 'rgxp' => 'alias', 'unique' => true, 'maxlength' => 128, 'tl_class' => 'w50'), 'save_callback' => array(array('PCT\\CustomCatalog\\Feeds\\TableCustomCatalogFeed', 'checkFeedAlias')), 'sql' => "varchar(128) COLLATE utf8_bin NOT NULL default ''"), 'language' => array('label' => &$GLOBALS['TL_LANG']['tl_news_feed']['language'], 'exclude' => true, 'search' => true, 'filter' => true, 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 32, 'tl_class' => 'w50'), 'sql' => "varchar(32) NOT NULL default ''"), 'configs' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['configs'], 'exclude' => true, 'search' => true, 'inputType' => 'checkbox', 'options_callback' => array('PCT\\CustomCatalog\\Feeds\\TableCustomCatalogFeed', 'getAllowedConfigurations'), 'eval' => array('multiple' => true, 'mandatory' => true), 'sql' => "blob NULL"), 'jumpTo' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['jumpTo'], 'exclude' => true, 'inputType' => 'pageTree', 'eval' => array('tl_class' => '', 'mandatory' => true), 'sql' => "int(10) NOT NULL default '0'"), 'format' => array('label' => &$GLOBALS['TL_LANG']['tl_news_feed']['format'], 'default' => 'rss', 'exclude' => true, 'filter' => true, 'inputType' => 'select', 'options' => array('rss' => 'RSS 2.0', 'atom' => 'Atom'), 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(32) NOT NULL default ''"), 'maxItems' => array('label' => &$GLOBALS['TL_LANG']['tl_news_feed']['maxItems'], 'default' => 25, 'exclude' => true, 'inputType' => 'text', 'eval' => array('mandatory' => true, 'rgxp' => 'natural', 'tl_class' => 'w50'), 'sql' => "smallint(5) unsigned NOT NULL default '0'"), 'feedBase' => array('label' => &$GLOBALS['TL_LANG']['tl_news_feed']['feedBase'], 'default' => \Environment::get('base'), 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('trailingSlash' => true, 'rgxp' => 'url', 'decodeEntities' => true, 'maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''"), 'description' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['description'], 'exclude' => true, 'search' => true, 'inputType' => 'textarea', 'eval' => array('style' => 'height:60px', 'tl_class' => 'clr'), 'sql' => "text NULL"), 'titleField' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['titleField'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('PCT\\CustomCatalog\\Feeds\\TableCustomCatalogFeed', 'getTextAttributes'), 'eval' => array('tl_class' => 'w50', 'includeBlankOption' => true, 'chosen' => true), 'sql' => "int(10) NOT NULL default '0'"), 'descriptionField' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['descriptionField'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('PCT\\CustomCatalog\\Feeds\\TableCustomCatalogFeed', 'getTextAttributes'), 'eval' => array('tl_class' => 'w50', 'includeBlankOption' => true, 'chosen' => true), 'sql' => "int(10) NOT NULL default '0'"), 'publishedField' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['publishedField'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('PCT\\CustomCatalog\\Feeds\\TableCustomCatalogFeed', 'getTimestampAttributes'), 'eval' => array('tl_class' => 'w50', 'includeBlankOption' => true, 'chosen' => true), 'sql' => "int(10) NOT NULL default '0'"), 'authorField' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['authorField'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('PCT\\CustomCatalog\\Feeds\\TableCustomCatalogFeed', 'getTextAttributes'), 'eval' => array('tl_class' => 'w50', 'includeBlankOption' => true, 'chosen' => true), 'sql' => "int(10) NOT NULL default '0'"), 'imageField' => array('label' => &$GLOBALS['TL_LANG'][$objDcaHelper->getTable()]['imageField'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('PCT\\CustomCatalog\\Feeds\\TableCustomCatalogFeed', 'getImageAttributes'), 'eval' => array('tl_class' => 'w50', 'includeBlankOption' => true, 'chosen' => true), 'sql' => "int(10) NOT NULL default '0'")));
/** * Retrieve the current referrer url. * * @param GetReferrerEvent $event The event. * * @return void */ public function handleGetReferer(GetReferrerEvent $event) { $event->setReferrerUrl(\System::getReferer($event->isEncodeAmpersands(), $event->getTableName())); }
/** * Try to export and catch ExportFailedException. * * @param $intConfig * @param $arrIds */ public function exportAndCatchExceptions($intConfig, $arrIds) { try { \Leads\Leads::export($intConfig, $arrIds); } catch (\Leads\Exporter\ExportFailedException $e) { \Message::addError($e->getMessage()); \Controller::redirect(\System::getReferer()); } }
/** * Return the "toggle visibility" button * * @param array $row * @param string $href * @param string $label * @param string $title * @param string $icon * @param string $attributes * * @return string */ public function forVisibilityToggle($row, $href, $label, $title, $icon, $attributes) { if (strlen(\Input::get('tid'))) { $this->toggleVisibility(\Input::get('tid'), \Input::get('state') == 1); \Controller::redirect(\System::getReferer()); } /** @var \BackendUser $user */ $user = \BackendUser::getInstance(); // Check permissions AFTER checking the tid, so hacking attempts are logged if (!$user->isAdmin && !$user->hasAccess('tl_iso_product::published', 'alexf')) { return ''; } $time = time(); $arrAttributes = array(); if (($objProductType = ProductType::findByProductData($row)) !== null) { $arrAttributes = $row['pid'] ? $objProductType->getVariantAttributes() : $objProductType->getAttributes(); } if ($arrAttributes['start']['enabled'] && $row['start'] != '' && $row['start'] > $time || $arrAttributes['stop']['enabled'] && $row['stop'] != '' && $row['stop'] < $time) { return \Image::getHtml('system/modules/isotope/assets/images/invisible-startstop.png', $label) . ' '; } elseif ($row['published'] != '1') { $icon = 'invisible.gif'; } $href .= '&tid=' . $row['id'] . '&state=' . ($row['published'] ? '' : 1); return '<a href="' . \Backend::addToUrl($href) . '" title="' . specialchars($title) . '"' . $attributes . '>' . \Image::getHtml($icon, $label) . '</a> '; }
/** * Generate the module * * @return string */ public function run() { $this->import('BackendUser', 'User'); $this->registerEvents(); $time = time(); /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_filecredits_sync'); $objTemplate->action = ampersand(\Environment::get('request')); $objTemplate->syncHeadline = $GLOBALS['TL_LANG']['tl_filecredit']['syncHeadline']; $objTemplate->isActive = $this->isActive(); $objTemplate->pageSelection = $this->generatePageSelection(); if (!\Config::get('headerAddXFrame') || !\Config::get('headerAllowOrigins')) { $objTemplate->originInfo = $GLOBALS['TL_LANG']['tl_filecredit']['originInfo']; } // Add the error message if ($_SESSION['REBUILD_FILECREDIT_ERROR'] != '') { $objTemplate->indexMessage = $_SESSION['REBUILD_FILECREDIT_ERROR']; $_SESSION['REBUILD_FILECREDIT_ERROR'] = ''; } // Rebuild the index if (\Input::get('act') == 'index') { // Check the request token (see #4007) if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) { $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request')); $this->redirect('contao/confirm.php'); } $arrPages = static::findFileCreditPages(); // HOOK: take additional pages (news, events…) if (isset($GLOBALS['TL_HOOKS']['getSearchablePages']) && is_array($GLOBALS['TL_HOOKS']['getSearchablePages'])) { foreach ($GLOBALS['TL_HOOKS']['getSearchablePages'] as $callback) { $this->import($callback[0]); $arrPages = $this->{$callback}[0]->{$callback}[1]($arrPages); } } $blnTruncateTable = true; if (\Input::get('limitfilecreditpages')) { $arrSelectedPages = \Input::get('filecreditpages'); if (is_array($arrSelectedPages) && !empty($arrSelectedPages)) { $arrPages = array_keys(array_intersect(array_flip($arrPages), $arrSelectedPages)); $blnTruncateTable = false; } } // Return if there are no pages if (empty($arrPages)) { $_SESSION['REBUILD_FILECREDIT_ERROR'] = $GLOBALS['TL_LANG']['tl_filecredit']['noSearchable']; \Controller::redirect(\System::getReferer()); } // Truncate the search tables if ($blnTruncateTable) { Automator::purgeFileCreditTables(); } // Hide unpublished elements $this->setCookie('FE_PREVIEW', 0, $time - 86400); // Calculate the hash $strHash = sha1(session_id() . (!\Config::get('disableIpCheck') ? \Environment::get('ip') : '') . 'FE_USER_AUTH'); // Remove old sessions $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute($time - \Config::get('sessionTimeout'), $strHash); // Log in the front end user if (is_numeric(\Input::get('user')) && \Input::get('user') > 0) { // Insert a new session $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute(\Input::get('user'), $time, 'FE_USER_AUTH', session_id(), \Environment::get('ip'), $strHash); // Set the cookie $this->setCookie('FE_USER_AUTH', $strHash, $time + \Config::get('sessionTimeout'), null, null, false, true); } else { // Unset the cookies $this->setCookie('FE_USER_AUTH', $strHash, $time - 86400, null, null, false, true); $this->setCookie('FE_AUTO_LOGIN', \Input::cookie('FE_AUTO_LOGIN'), $time - 86400, null, null, false, true); } $strBuffer = ''; $rand = rand(); // Display the pages for ($i = 0, $c = count($arrPages); $i < $c; $i++) { if (!\Validator::isUrl($arrPages[$i])) { continue; } $strBuffer .= '<span class="page_url" data-url="' . $arrPages[$i] . '#' . $rand . $i . '">' . \StringUtil::substr($arrPages[$i], 100) . '</span><br>'; unset($arrPages[$i]); // see #5681 } $objTemplate->content = $strBuffer; $objTemplate->note = $GLOBALS['TL_LANG']['tl_filecredit']['indexNote']; $objTemplate->loading = $GLOBALS['TL_LANG']['tl_filecredit']['indexLoading']; $objTemplate->complete = $GLOBALS['TL_LANG']['tl_filecredit']['indexComplete']; $objTemplate->indexContinue = $GLOBALS['TL_LANG']['MSC']['continue']; $objTemplate->theme = \Backend::getTheme(); $objTemplate->isRunning = true; } // Default variables $objTemplate->indexSubmit = $GLOBALS['TL_LANG']['tl_filecredit']['syncSubmit']; $objTemplate->backHref = \System::getReferer(true); $objTemplate->backTitle = specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']); $objTemplate->backButton = $GLOBALS['TL_LANG']['MSC']['backBT']; return $objTemplate->parse(); }