本文整理汇总了PHP中Contao\Input::postRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::postRaw方法的具体用法?PHP Input::postRaw怎么用?PHP Input::postRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contao\Input
的用法示例。
在下文中一共展示了Input::postRaw方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchMenu
/**
* Return a search form that allows to search results using regular expressions
*
* @return string
*/
protected function searchMenu()
{
$searchFields = array();
/** @var AttributeBagInterface $objSessionBag */
$objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
$session = $objSessionBag->all();
// Get search fields
foreach ($GLOBALS['TL_DCA'][$this->strTable]['fields'] as $k => $v) {
if ($v['search']) {
$searchFields[] = $k;
}
}
// Return if there are no search fields
if (empty($searchFields)) {
return '';
}
// Store search value in the current session
if (\Input::post('FORM_SUBMIT') == 'tl_filters') {
$strField = \Input::post('tl_field', true);
$strKeyword = ltrim(\Input::postRaw('tl_value'), '*');
// Make sure the regular expression is valid
if ($strKeyword != '') {
try {
$this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE " . $strField . " REGEXP ?")->limit(1)->execute($strKeyword);
} catch (\Exception $e) {
$strKeyword = '';
}
}
$session['search'][$this->strTable]['field'] = $strField;
$session['search'][$this->strTable]['value'] = $strKeyword;
$objSessionBag->replace($session);
} elseif ($session['search'][$this->strTable]['value'] != '') {
$strPattern = "CAST(%s AS CHAR) REGEXP ?";
if (substr(\Config::get('dbCollation'), -3) == '_ci') {
$strPattern = "LOWER(CAST(%s AS CHAR)) REGEXP LOWER(?)";
}
$fld = $session['search'][$this->strTable]['field'];
if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$fld]['foreignKey'])) {
list($t, $f) = explode('.', $GLOBALS['TL_DCA'][$this->strTable]['fields'][$fld]['foreignKey']);
$this->procedure[] = "(" . sprintf($strPattern, $fld) . " OR " . sprintf($strPattern, "(SELECT {$f} FROM {$t} WHERE {$t}.id={$this->strTable}.{$fld})") . ")";
$this->values[] = $session['search'][$this->strTable]['value'];
} else {
$this->procedure[] = sprintf($strPattern, $fld);
}
$this->values[] = $session['search'][$this->strTable]['value'];
}
$options_sorter = array();
foreach ($searchFields as $field) {
$option_label = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['label'][0] ?: (is_array($GLOBALS['TL_LANG']['MSC'][$field]) ? $GLOBALS['TL_LANG']['MSC'][$field][0] : $GLOBALS['TL_LANG']['MSC'][$field]);
$options_sorter[Utf8::toAscii($option_label) . '_' . $field] = ' <option value="' . specialchars($field) . '"' . ($field == $session['search'][$this->strTable]['field'] ? ' selected="selected"' : '') . '>' . $option_label . '</option>';
}
// Sort by option values
$options_sorter = natcaseksort($options_sorter);
$active = $session['search'][$this->strTable]['value'] != '' ? true : false;
return '
<div class="tl_search tl_subpanel">
<strong>' . $GLOBALS['TL_LANG']['MSC']['search'] . ':</strong>
<select name="tl_field" class="tl_select' . ($active ? ' active' : '') . '">
' . implode("\n", $options_sorter) . '
</select>
<span> = </span>
<input type="search" name="tl_value" class="tl_text' . ($active ? ' active' : '') . '" value="' . specialchars($session['search'][$this->strTable]['value']) . '">
</div>';
}
示例2: generate
/**
* Generate the widget and return it as string
*
* @return string
*/
public function generate()
{
$this->import('BackendUser', 'User');
$this->convertValuesToPaths();
if ($this->extensions != '') {
$this->arrValidFileTypes = \StringUtil::trimsplit(',', strtolower($this->extensions));
}
/** @var AttributeBagInterface $objSessionBag */
$objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
// Store the keyword
if (\Input::post('FORM_SUBMIT') == 'item_selector') {
$strKeyword = ltrim(\Input::postRaw('keyword'), '*');
// Make sure the regular expression is valid
if ($strKeyword != '') {
try {
$this->Database->prepare("SELECT * FROM tl_files WHERE name REGEXP ?")->limit(1)->execute($strKeyword);
} catch (\Exception $e) {
$strKeyword = '';
}
}
$objSessionBag->set('file_selector_search', $strKeyword);
$this->reload();
}
$tree = '';
$for = $objSessionBag->get('file_selector_search');
$arrFound = array();
// Search for a specific file
if ($for != '') {
// Wrap in a try catch block in case the regular expression is invalid (see #7743)
try {
$strPattern = "CAST(name AS CHAR) REGEXP ?";
if (substr(\Config::get('dbCollation'), -3) == '_ci') {
$strPattern = "LOWER(CAST(name AS CHAR)) REGEXP LOWER(?)";
}
$strType = '';
if (strpos($for, 'type:file') !== false) {
$strType = " AND type='file'";
$for = trim(str_replace('type:file', '', $for));
}
if (strpos($for, 'type:folder') !== false) {
$strType = " AND type='folder'";
$for = trim(str_replace('type:folder', '', $for));
}
$objRoot = $this->Database->prepare("SELECT path, type, extension FROM tl_files WHERE {$strPattern} {$strType} GROUP BY path")->execute($for);
if ($objRoot->numRows < 1) {
$GLOBALS['TL_DCA']['tl_files']['list']['sorting']['root'] = array('');
} else {
$arrPaths = array();
// Respect existing limitations
if ($this->path != '') {
while ($objRoot->next()) {
if (strncmp($this->path . '/', $objRoot->path . '/', strlen($this->path) + 1) === 0) {
if ($objRoot->type == 'folder' || empty($this->arrValidFileTypes) || in_array($objRoot->extension, $this->arrValidFileTypes)) {
$arrFound[] = $objRoot->path;
}
$arrPaths[] = $objRoot->type == 'folder' ? $objRoot->path : dirname($objRoot->path);
}
}
} elseif ($this->User->isAdmin) {
// Show all files to admins
while ($objRoot->next()) {
if ($objRoot->type == 'folder' || empty($this->arrValidFileTypes) || in_array($objRoot->extension, $this->arrValidFileTypes)) {
$arrFound[] = $objRoot->path;
}
$arrPaths[] = $objRoot->type == 'folder' ? $objRoot->path : dirname($objRoot->path);
}
} else {
if (is_array($this->User->filemounts)) {
while ($objRoot->next()) {
// Show only mounted folders to regular users
foreach ($this->User->filemounts as $path) {
if (strncmp($path . '/', $objRoot->path . '/', strlen($path) + 1) === 0) {
if ($objRoot->type == 'folder' || empty($this->arrValidFileTypes) || in_array($objRoot->extension, $this->arrValidFileTypes)) {
$arrFound[] = $objRoot->path;
}
$arrPaths[] = $objRoot->type == 'folder' ? $objRoot->path : dirname($objRoot->path);
}
}
}
}
}
$GLOBALS['TL_DCA']['tl_files']['list']['sorting']['root'] = array_unique($arrPaths);
}
} catch (\Exception $e) {
}
}
$strNode = $objSessionBag->get('tl_files_picker');
// Unset the node if it is not within the path (see #5899)
if ($strNode != '' && $this->path != '') {
if (strncmp($strNode . '/', $this->path . '/', strlen($this->path) + 1) !== 0) {
$objSessionBag->remove('tl_files_picker');
}
}
// Add the breadcrumb menu
if (\Input::get('do') != 'files') {
//.........这里部分代码省略.........
示例3: source
/**
* Load the source editor
*
* @return string
*/
public function source()
{
$this->isValid($this->intId);
if (is_dir(TL_ROOT . '/' . $this->intId)) {
$this->log('Folder "' . $this->intId . '" cannot be edited', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
} elseif (!file_exists(TL_ROOT . '/' . $this->intId)) {
$this->log('File "' . $this->intId . '" does not exist', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
$this->import('BackendUser', 'User');
// Check user permission
if (!$this->User->hasAccess('f5', 'fop')) {
$this->log('Not enough permissions to edit the file source of file "' . $this->intId . '"', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
$objFile = new \File($this->intId);
// Check whether file type is editable
if (!in_array($objFile->extension, trimsplit(',', \Config::get('editableFiles')))) {
$this->log('File type "' . $objFile->extension . '" (' . $this->intId . ') is not allowed to be edited', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
// Add the versioning routines
if ($this->blnIsDbAssisted) {
$objMeta = \FilesModel::findByPath($objFile->value);
if ($objMeta === null) {
$objMeta = \Dbafs::addResource($objFile->value);
}
$objVersions = new \Versions($this->strTable, $objMeta->id);
if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['hideVersionMenu']) {
// Compare versions
if (\Input::get('versions')) {
$objVersions->compare();
}
// Restore a version
if (\Input::post('FORM_SUBMIT') == 'tl_version' && \Input::post('version') != '') {
$objVersions->restore(\Input::post('version'));
// Purge the script cache (see #7005)
if ($objFile->extension == 'css' || $objFile->extension == 'scss' || $objFile->extension == 'less') {
$this->import('Automator');
$this->Automator->purgeScriptCache();
}
$this->reload();
}
}
$objVersions->initialize();
}
$strContent = $objFile->getContent();
if ($objFile->extension == 'svgz') {
$strContent = gzdecode($strContent);
}
// Process the request
if (\Input::post('FORM_SUBMIT') == 'tl_files') {
// Restore the basic entities (see #7170)
$strSource = \StringUtil::restoreBasicEntities(\Input::postRaw('source'));
// Save the file
if (md5($strContent) != md5($strSource)) {
if ($objFile->extension == 'svgz') {
$strSource = gzencode($strSource);
}
// Write the file
$objFile->write($strSource);
$objFile->close();
// Update the database
if ($this->blnIsDbAssisted) {
/** @var \FilesModel $objMeta */
$objMeta->hash = $objFile->hash;
$objMeta->save();
$objVersions->create();
}
// Purge the script cache (see #7005)
if ($objFile->extension == 'css' || $objFile->extension == 'scss' || $objFile->extension == 'less') {
$this->import('Automator');
$this->Automator->purgeScriptCache();
}
}
if (isset($_POST['saveNclose'])) {
\System::setCookie('BE_PAGE_OFFSET', 0, 0);
$this->redirect($this->getReferer());
}
$this->reload();
}
$codeEditor = '';
// Prepare the code editor
if (\Config::get('useCE')) {
/** @var \BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_ace');
$objTemplate->selector = 'ctrl_source';
$objTemplate->type = $objFile->extension;
$codeEditor = $objTemplate->parse();
}
// Versions overview
if ($this->blnIsDbAssisted && $GLOBALS['TL_DCA'][$this->strTable]['config']['enableVersioning'] && !$GLOBALS['TL_DCA'][$this->strTable]['config']['hideVersionMenu']) {
$version = $objVersions->renderDropdown();
} else {
//.........这里部分代码省略.........
示例4: generate
/**
* Generate the widget and return it as string
*
* @return string
*/
public function generate()
{
$this->import('BackendUser', 'User');
/** @var AttributeBagInterface $objSessionBag */
$objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
// Store the keyword
if (\Input::post('FORM_SUBMIT') == 'item_selector') {
$strKeyword = ltrim(\Input::postRaw('keyword'), '*');
// Make sure the regular expression is valid
if ($strKeyword != '') {
try {
$this->Database->prepare("SELECT * FROM tl_page WHERE title REGEXP ?")->limit(1)->execute($strKeyword);
} catch (\Exception $e) {
$strKeyword = '';
}
}
$objSessionBag->set('page_selector_search', $strKeyword);
$this->reload();
}
$tree = '';
$this->getPathNodes();
$for = $objSessionBag->get('page_selector_search');
$arrFound = array();
// Search for a specific page
if ($for != '') {
// Wrap in a try catch block in case the regular expression is invalid (see #7743)
try {
$strPattern = "CAST(title AS CHAR) REGEXP ?";
if (substr(\Config::get('dbCollation'), -3) == '_ci') {
$strPattern = "LOWER(CAST(title AS CHAR)) REGEXP LOWER(?)";
}
$objRoot = $this->Database->prepare("SELECT id FROM tl_page WHERE {$strPattern} GROUP BY id")->execute($for);
if ($objRoot->numRows < 1) {
$GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = array(0);
} else {
$arrIds = array();
// Respect existing limitations
if (is_array($this->rootNodes)) {
while ($objRoot->next()) {
// Predefined node set (see #3563)
if (count(array_intersect($this->rootNodes, $this->Database->getParentRecords($objRoot->id, 'tl_page'))) > 0) {
$arrFound[] = $objRoot->id;
$arrIds[] = $objRoot->id;
}
}
} elseif ($this->User->isAdmin) {
// Show all pages to admins
while ($objRoot->next()) {
$arrFound[] = $objRoot->id;
$arrIds[] = $objRoot->id;
}
} else {
while ($objRoot->next()) {
// Show only mounted pages to regular users
if (count(array_intersect($this->User->pagemounts, $this->Database->getParentRecords($objRoot->id, 'tl_page'))) > 0) {
$arrFound[] = $objRoot->id;
$arrIds[] = $objRoot->id;
}
}
}
$GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = array_unique($arrIds);
}
} catch (\Exception $e) {
}
}
$strNode = $objSessionBag->get('tl_page_picker');
// Unset the node if it is not within the predefined node set (see #5899)
if ($strNode > 0 && is_array($this->rootNodes)) {
if (!in_array($strNode, $this->Database->getChildRecords($this->rootNodes, 'tl_page'))) {
$objSessionBag->remove('tl_page_picker');
}
}
// Add the breadcrumb menu
if (\Input::get('do') != 'page') {
\Backend::addPagesBreadcrumb('tl_page_picker');
}
// Root nodes (breadcrumb menu)
if (!empty($GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'])) {
$root = $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'];
// Allow only those roots that are allowed in root nodes
if (is_array($this->rootNodes)) {
$root = array_intersect(array_merge($this->rootNodes, $this->Database->getChildRecords($this->rootNodes, 'tl_page')), $root);
if (empty($root)) {
$root = $this->rootNodes;
// Hide the breadcrumb
$GLOBALS['TL_DCA']['tl_page']['list']['sorting']['breadcrumb'] = '';
}
}
$nodes = $this->eliminateNestedPages($root);
foreach ($nodes as $node) {
$tree .= $this->renderPagetree($node, -20, false, false, $arrFound);
}
} elseif (is_array($this->rootNodes)) {
$nodes = $this->eliminateNestedPages($this->rootNodes);
foreach ($nodes as $node) {
//.........这里部分代码省略.........
示例5: searchMenu
/**
* Return a search form that allows to search results using regular expressions
*
* @return string
*/
protected function searchMenu()
{
/** @var AttributeBagInterface $objSessionBag */
$objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
$session = $objSessionBag->all();
// Store search value in the current session
if (\Input::post('FORM_SUBMIT') == 'tl_filters') {
$strField = \Input::post('tl_field', true);
$strKeyword = ltrim(\Input::postRaw('tl_value'), '*');
// Make sure the regular expression is valid
if ($strKeyword != '') {
try {
$this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE " . $strField . " REGEXP ?")->limit(1)->execute($strKeyword);
} catch (\Exception $e) {
$strKeyword = '';
}
}
$session['search'][$this->strTable]['field'] = $strField;
$session['search'][$this->strTable]['value'] = $strKeyword;
$objSessionBag->replace($session);
} elseif ($session['search'][$this->strTable]['value'] != '') {
$strPattern = "CAST(name AS CHAR) REGEXP ?";
if (substr(\Config::get('dbCollation'), -3) == '_ci') {
$strPattern = "LOWER(CAST(name AS CHAR)) REGEXP LOWER(?)";
}
if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields']['name']['foreignKey'])) {
list($t, $f) = explode('.', $GLOBALS['TL_DCA'][$this->strTable]['fields']['name']['foreignKey']);
$this->procedure[] = "(" . $strPattern . " OR " . sprintf($strPattern, "(SELECT {$f} FROM {$t} WHERE {$t}.id={$this->strTable}.name)") . ")";
$this->values[] = $session['search'][$this->strTable]['value'];
} else {
$this->procedure[] = $strPattern;
}
$this->values[] = $session['search'][$this->strTable]['value'];
}
$active = $session['search'][$this->strTable]['value'] != '' ? true : false;
return '
<div class="tl_search tl_subpanel">
<strong>' . $GLOBALS['TL_LANG']['MSC']['search'] . ':</strong>
<select name="tl_field" class="tl_select' . ($active ? ' active' : '') . '">
<option value="name">' . ($GLOBALS['TL_DCA'][$this->strTable]['fields']['name']['label'][0] ?: (is_array($GLOBALS['TL_LANG']['MSC']['name']) ? $GLOBALS['TL_LANG']['MSC']['name'][0] : $GLOBALS['TL_LANG']['MSC']['name'])) . '</option>
</select>
<span> = </span>
<input type="search" name="tl_value" class="tl_text' . ($active ? ' active' : '') . '" value="' . \StringUtil::specialchars($session['search'][$this->strTable]['value']) . '">
</div>';
}