本文整理汇总了PHP中Xoops\Core\Request::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getMethod方法的具体用法?PHP Request::getMethod怎么用?PHP Request::getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xoops\Core\Request
的用法示例。
在下文中一共展示了Request::getMethod方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$xoops = Xoops::getInstance();
// Warning: code depending on Xoops\Core\HttpRequest may need to change
$request = \Xoops\Core\HttpRequest::getInstance();
$xoops->header();
\Xoops\Utils::dumpVar(Request::get());
$result['id'] = Request::getInt('id', 13);
$result['string'] = Request::getString('string', 'defaultValueHere');
$result['bool'] = Request::getBool('bool', false);
$result['order'] = Request::getString('order', 'ASC');
$result['url'] = $request->getUrl();
$result['uri'] = $request->getUri();
$result['referer'] = $request->getReferer();
$result['phpsessid_cookie'] = Request::getString('PHPSESSID', '', 'cookie');
$result['ip'] = $request->getClientIp();
$result['isget'] = 'GET' === Request::getMethod();
$result['ispost'] = 'POST' === Request::getMethod();
$result['ismobile'] = $request->is('mobile');
$result['isrobot'] = $request->is('robot');
$result['files'] = Request::getArray('file_identifier', array(), 'files');
\Xoops\Utils::dumpVar($result);
echo '<a href="?id=12&string=I love you&bool=everythingsistrue&order=DESC">Good uri</a>';
echo ' - <a href="?id=test&order=DESCENDING">Bad uri</a>';
// Form
$form = new Xoops\Form\SimpleForm('', 'form_id', 'request.php?id=666', true);
$form->setExtra('enctype="multipart/form-data"');
$code = new Xoops\Form\Text('String', 'string', 2, 25, '', 'string...');
$code->setDescription('Description text');
$code->setPattern('^.{3,}$', 'You need at least 3 characters');
$code->setDatalist(array('list 1', 'list 2', 'list 3'));
$form->addElement($code, true);
$select = new Xoops\Form\Select('Select', 'id', '', 1, false);
示例2: displayPost
public function displayPost()
{
$xoops = Xoops::getInstance();
if (Request::getMethod() !== 'POST') {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$id = Request::getInt('com_id');
$modid = Request::getInt('com_modid');
if (empty($modid)) {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
/* @var $comment CommentsComment */
$comment = $this->getHandlerComment()->get($id);
if (!is_object($comment)) {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
if (!$comment->isNew()) {
$modid = $comment->getVar('modid');
} else {
$comment->setVar('modid', $modid);
}
$module = $xoops->getModuleById($modid);
if (!is_object($module)) {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$moddir = $module->getVar('dirname');
if ($xoops->isAdminSide) {
if (empty($id)) {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$redirect_page = $this->url('admin/main.php?com_modid=' . $modid . '&com_itemid');
} else {
if (COMMENTS_APPROVENONE == $xoops->getModuleConfig('com_rule', $module->getVar('dirname'))) {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$redirect_page = '';
}
/* @var $plugin CommentsPluginInterface */
if ($plugin = \Xoops\Module\Plugin::getPlugin($moddir, 'comments')) {
if (!$xoops->isAdminSide) {
$redirect_page = $xoops->url('modules/' . $moddir . '/' . $plugin->pageName() . '?');
if (is_array($extraParams = $plugin->extraParams())) {
$extra_params = '';
foreach ($extraParams as $extra_param) {
$extra_params .= isset($_POST[$extra_param]) ? $extra_param . '=' . htmlspecialchars($_POST[$extra_param]) . '&' : $extra_param . '=amp;';
}
$redirect_page .= $extra_params;
}
$redirect_page .= $plugin->itemName();
}
$comment_url = $redirect_page;
$op = Request::getBool('com_dopost') ? 'post' : '';
$op = Request::getBool('com_dopreview') ? 'preview' : $op;
$op = Request::getBool('com_dodelete') ? 'delete' : $op;
if ($op === 'preview' || $op === 'post') {
if (!$xoops->security()->check()) {
$op = '';
}
}
if ($op === 'post' && !$xoops->isUser()) {
$xoopsCaptcha = XoopsCaptcha::getInstance();
if (!$xoopsCaptcha->verify()) {
$captcha_message = $xoopsCaptcha->getMessage();
$op = 'preview';
}
}
$title = XoopsLocale::trim(Request::getString('com_title'));
$text = XoopsLocale::trim(Request::getString('com_text'));
$mode = XoopsLocale::trim(Request::getString('com_mode', 'flat'));
$order = XoopsLocale::trim(Request::getString('com_order', COMMENTS_OLD1ST));
$itemid = Request::getInt('com_itemid');
$pid = Request::getInt('com_pid');
$rootid = Request::getInt('com_rootid');
$status = Request::getInt('com_status');
$dosmiley = Request::getBool('com_dosmiley');
$doxcode = Request::getBool('com_doxcode');
$dobr = Request::getBool('com_dobr');
$dohtml = Request::getBool('com_html');
$doimage = Request::getBool('com_doimage');
$icon = XoopsLocale::trim(Request::getString('com_icon'));
$comment->setVar('title', $title);
$comment->setVar('text', $text);
$comment->setVar('itemid', $itemid);
$comment->setVar('pid', $pid);
$comment->setVar('rootid', $rootid);
$comment->setVar('status', $status);
$comment->setVar('dosmiley', $dosmiley);
$comment->setVar('doxcode', $doxcode);
$comment->setVar('dobr', $dobr);
$comment->setVar('dohtml', $dohtml);
$comment->setVar('doimage', $doimage);
$comment->setVar('icon', $icon);
switch ($op) {
case "delete":
$this->displayDelete();
break;
case "preview":
$comment->setVar('doimage', 1);
if ($comment->getVar('dohtml') != 0) {
if ($xoops->isUser()) {
//.........这里部分代码省略.........
示例3: Permission
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package debugbar
* @since
* @author XOOPS Development Team
*/
use Xoops\Core\Request;
use Xmf\Module\Helper;
use Xmf\Module\Permission;
include_once __DIR__ . '/admin_header.php';
$moduleAdmin = new \Xoops\Module\Admin();
$moduleAdmin->displayNavigation('permissions.php');
$helper = Helper::getHelper('monolog');
$permHelper = new Permission();
if ($permHelper) {
// this is the name and item we are going to work with
$gperm_name = 'use_monolog';
$gperm_itemid = 0;
// if this is a post operation get our variables
if ('POST' === Request::getMethod()) {
$name = $permHelper->defaultFieldName($gperm_name, $gperm_itemid);
$groups = Request::getVar($name, array(), 'POST');
$permHelper->savePermissionForItem($gperm_name, $gperm_itemid, $groups);
echo $xoops->alert('success', _MA_MONOLOG_FORM_PROCESSED, _MA_MONOLOG_PERMISSION_FORM);
}
$form = new \Xoops\Form\ThemeForm(_MA_MONOLOG_PERMISSION_FORM, 'form', '', 'POST');
$permElement = $permHelper->getGroupSelectFormForItem($gperm_name, $gperm_itemid, _MA_MONOLOG_PERMISSION_GROUPS, null, true);
$form->addElement($permElement);
$form->addElement(new \Xoops\Form\Button('', 'submit', _MA_MONOLOG_FORM_SUBMIT, 'submit'));
echo $form->render();
}
include_once __DIR__ . '/admin_footer.php';
示例4: array
$op = Request::getString('op', 'list');
$memberslist_id = Request::getArray('memberslist_id', array());
// Call Header
$xoops->header('admin:mailusers/mailusers_send_mail.tpl');
// Define Stylesheet
$xoops->theme()->addBaseStylesheetAssets('modules/system/css/admin.css');
$xoops->theme()->addBaseScriptAssets(array('@jquery', 'media/xoops/xoops.js', 'modules/system/js/admin.js'));
$admin_page = new \Xoops\Module\Admin();
$admin_page->renderNavigation('send_mails.php');
switch ($op) {
case 'list':
default:
$display_criteria = 1;
$form = new Xoops\Form\ThemeForm(_AM_MAILUSERS_LIST, "mailusers", "send_mails.php", 'post', true);
//----------------------------------------
if (!empty($memberslist_id) && Request::getMethod() == 'POST') {
$user_count = count($memberslist_id);
$display_names = "";
for ($i = 0; $i < $user_count; ++$i) {
$uid_hidden = new Xoops\Form\Hidden("mail_to_user[]", $memberslist_id[$i]);
$form->addElement($uid_hidden);
$display_names .= "<a href='" . \XoopsBaseConfig::get('url') . "/userinfo.php?uid=" . $memberslist_id[$i] . "' rel='external'>" . XoopsUser::getUnameFromId($memberslist_id[$i]) . "</a>, ";
unset($uid_hidden);
}
$users_label = new Xoops\Form\Label(_AM_MAILUSERS_SENDTOUSERS2, substr($display_names, 0, -2));
$form->addElement($users_label);
$form->addElement($users_label);
$display_criteria = 0;
}
//----------------------------------------
if (!empty($display_criteria)) {
示例5: testGetMethod
/**
* @covers Xoops\Core\Request::getMethod
*/
public function testGetMethod()
{
$method = Request::getMethod();
$this->assertTrue(in_array($method, array('GET', 'HEAD', 'POST', 'PUT')));
}