本文整理汇总了PHP中Doku_Event::preventDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP Doku_Event::preventDefault方法的具体用法?PHP Doku_Event::preventDefault怎么用?PHP Doku_Event::preventDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doku_Event
的用法示例。
在下文中一共展示了Doku_Event::preventDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: msg
/**
* Handles input from the newform and redirects to the edit mode
*
* @author Andreas Gohr <gohr@cosmocode.de>
* @author Gina Haeussge <osd@foosel.net>
*
* @param Doku_Event $event event object by reference
* @param array $param empty array as passed to register_hook()
* @return bool
*/
function handle_act_preprocess(Doku_Event $event, $param)
{
global $TEXT;
global $ID;
if ($event->data != 'btngnew') {
return true;
}
/** @var helper_plugin_blogtng_tools $tools */
$tools = plugin_load('helper', 'blogtng_tools');
if (!$tools->getParam('new/title')) {
msg($this->getLang('err_notitle'), -1);
$event->data = 'show';
return true;
}
$event->preventDefault();
$new = $tools->mkpostid($tools->getParam('new/format'), $tools->getParam('new/title'));
if ($ID != $new) {
$urlparams = array('do' => 'btngnew', 'btng[post][blog]' => $tools->getParam('post/blog'), 'btng[post][tags]' => $tools->getParam('post/tags'), 'btng[post][commentstatus]' => $tools->getParam('post/commentstatus'), 'btng[new][format]' => $tools->getParam('new/format'), 'btng[new][title]' => $tools->getParam('new/title'));
send_redirect(wl($new, $urlparams, true, '&'));
return false;
//never reached
} else {
$TEXT = $this->_prepare_template($new, $tools->getParam('new/title'));
$event->data = 'preview';
return false;
}
}
示例2: ajax
/**
* @param Doku_Event$event
* @param $param
*/
public function ajax(Doku_Event $event, $param)
{
if ($event->data !== 'bureaucracy_user_field') {
return;
}
$event->stopPropagation();
$event->preventDefault();
$search = $_REQUEST['search'];
/** @var DokuWiki_Auth_Plugin $auth */
global $auth;
$users = array();
foreach ($auth->retrieveUsers() as $username => $data) {
if ($search === '' || stripos($username, $search) === 0 || stripos($data['name'], $search) !== false) {
// Full name
$users[$username] = $data['name'];
}
if (count($users) === 10) {
break;
}
}
if (count($users) === 1 && key($users) === $search) {
$users = array();
}
require_once DOKU_INC . 'inc/JSON.php';
$json = new JSON();
echo $json->encode($users);
}
示例3: isset
/**
* @param Doku_Event $event event object by reference
* @param array $param empty array as passed to register_hook()
*/
function handle_ajax_call(Doku_Event $event, $param)
{
/** @var DokuWiki_Auth_Plugin $auth */
global $auth;
if ($event->data != 'blogtng__comment_preview') {
return;
}
$event->preventDefault();
$event->stopPropagation();
require_once DOKU_PLUGIN . 'blogtng/helper/comments.php';
$comment = new blogtng_comment();
$comment->data['text'] = $_REQUEST['text'];
$comment->data['name'] = $_REQUEST['name'];
$comment->data['mail'] = $_REQUEST['mail'];
$comment->data['web'] = isset($_REQUEST['web']) ? $_REQUEST['web'] : '';
$comment->data['cid'] = 'preview';
$comment->data['created'] = time();
$comment->data['status'] = 'visible';
if (!$comment->data['name'] && $_SERVER['REMOTE_USER']) {
if ($auth and $info = $auth->getUserData($_SERVER['REMOTE_USER'])) {
$comment->data['name'] = $info['name'];
$comment->data['mail'] = $info['mail'];
}
}
$comment->output($_REQUEST['tplname']);
}
示例4: handle_auth_user_change
/**
* [Custom event handler which performs action]
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_auth_user_change(Doku_Event &$event, $param)
{
if ($event->data['type'] !== 'create') {
return;
}
$domains = array_map(function ($domain) {
return trim($domain);
}, explode(';', $this->getConf('_domainWhiteList')));
$email = $event->data['params'][3];
$checks = array(in_array(trim(substr(strrchr($email, "@"), 1)), $domains), (bool) preg_match($this->getConf('_emailRegex', '/@/'), $email));
if ($this->getConf('checksAnd', true)) {
$status = array_reduce($checks, function ($a, $b) {
return $a && $b;
}, true);
} else {
$status = array_reduce($checks, function ($a, $b) {
return $a || $b;
}, false);
}
if (!$status) {
$event->preventDefault();
$event->stopPropagation();
$event->result = false;
msg($this->getConf('_domainlistErrorMEssage'), -1);
}
}
示例5: handle_do_action
/**
* Gets the thumbnail
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_do_action(Doku_Event &$event, $param)
{
if ($event->data !== 'obsaudioupload_frame_thumbnail') {
return;
}
//no other ajax call handlers needed
$event->stopPropagation();
$event->preventDefault();
// get the url of the image to make into a thumbnail
$url = $GLOBALS['INPUT']->str('img');
$imageInfo = getimagesize($url);
// 0=width, 1=height, 2=format
if ($imageInfo[2] == IMG_PNG) {
$img = imagecreatefrompng($url);
} else {
$img = imagecreatefromjpeg($url);
}
$newHeight = 50;
$newWidth = (int) ($imageInfo[0] * $newHeight / $imageInfo[1]);
$newImg = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresized($newImg, $img, 0, 0, 0, 0, $newWidth, $newHeight, $imageInfo[0], $imageInfo[1]);
// output
header('Content-Type: application/jpeg');
imagejpeg($newImg, null, 60);
exit;
}
示例6: onAjaxCallUnknown
public function onAjaxCallUnknown(\Doku_Event $event, $action)
{
if ($event->data != 'yk') {
return;
}
// skip if not our plugin
$do = $this->G['INPUT']->post->str('action', '');
if ($action !== $do) {
return;
// not match. skip this, continue with another
}
$event->preventDefault();
// what does it do?
$event->stopPropagation();
//our hooker found, skip others
$pageId = $this->G['INPUT']->post->str('id', '');
$pageNewId = $this->G['INPUT']->post->str('new_page_id', null);
$json = new \stdClass();
$json->error = false;
try {
$this->logger(strtoupper($do), 'PAGE ' . $pageId);
$json->result = $this->doAction($pageId, $pageNewId);
$this->logger('SUCCESS');
} catch (\Exception $e) {
$json->error = date('H:i:s') . ' ' . $e->getMessage();
$this->logger('ERROR', $e->getMessage());
}
//header('Content-Type: application/json');
echo json_encode($json);
}
示例7: handle_ajax
/**
* Step up
*
* @param Doku_Event $event
*/
public function handle_ajax(Doku_Event $event)
{
if ($event->data != 'plugin_move_progress') {
return;
}
$event->preventDefault();
$event->stopPropagation();
global $INPUT;
global $USERINFO;
if (!auth_ismanager($_SERVER['REMOTE_USER'], $USERINFO['grps'])) {
http_status(403);
exit;
}
$return = array('error' => '', 'complete' => false, 'progress' => 0);
/** @var helper_plugin_move_plan $plan */
$plan = plugin_load('helper', 'move_plan');
if (!$plan->isCommited()) {
// There is no plan. Something went wrong
$return['complete'] = true;
} else {
$todo = $plan->nextStep($INPUT->bool('skip'));
$return['progress'] = $plan->getProgress();
$return['error'] = $plan->getLastError();
if ($todo === 0) {
$return['complete'] = true;
}
}
$json = new JSON();
header('Content-Type: application/json');
echo $json->encode($return);
}
示例8: handle_ajax
/**
* Rename a single page
*/
public function handle_ajax(Doku_Event $event)
{
if ($event->data != 'plugin_move_rename') {
return;
}
$event->preventDefault();
$event->stopPropagation();
global $MSG;
global $INPUT;
$src = cleanID($INPUT->str('id'));
$dst = cleanID($INPUT->str('newid'));
/** @var helper_plugin_move_op $MoveOperator */
$MoveOperator = plugin_load('helper', 'move_op');
$JSON = new JSON();
header('Content-Type: application/json');
if ($this->renameOkay($src) && $MoveOperator->movePage($src, $dst)) {
// all went well, redirect
echo $JSON->encode(array('redirect_url' => wl($dst, '', true, '&')));
} else {
if (isset($MSG[0])) {
$error = $MSG[0];
// first error
} else {
$error = $this->getLang('cantrename');
}
echo $JSON->encode(array('error' => $error));
}
}
示例9: info
/**
* Create the detail info for a single plugin
*
* @param Doku_Event $event
* @param $param
*/
public function info(Doku_Event &$event, $param)
{
global $USERINFO;
global $INPUT;
if ($event->data != 'plugin_extension') {
return;
}
$event->preventDefault();
$event->stopPropagation();
if (empty($_SERVER['REMOTE_USER']) || !auth_isadmin($_SERVER['REMOTE_USER'], $USERINFO['grps'])) {
http_status(403);
echo 'Forbidden';
exit;
}
header('Content-Type: text/html; charset=utf-8');
$ext = $INPUT->str('ext');
if (!$ext) {
echo 'no extension given';
return;
}
/** @var helper_plugin_extension_extension $extension */
$extension = plugin_load('helper', 'extension_extension');
$extension->setExtension($ext);
/** @var helper_plugin_extension_list $list */
$list = plugin_load('helper', 'extension_list');
echo $list->make_info($extension);
}
示例10: handle_ajax_call_unknown
/**
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_ajax_call_unknown(Doku_Event &$event, $param)
{
if ($event->data !== 'tagapi_list') {
return;
}
$event->stopPropagation();
$event->preventDefault();
if ($this->tagplugin = $this->loadHelper('tag')) {
$tags = $this->tagplugin->tagOccurrences(array(), NULL, true);
$a = print_r($tags, true);
// file_put_contents(DOKU_INC . 'tags.txt', $a);
} else {
$tags = array();
}
// sort tags by name ($tags is in the form $tag => $count)
ksort($tags);
echo '{"tags":[';
$firstelement = true;
foreach (array_keys($tags) as $tag) {
if ($firstelement) {
$firstelement = false;
} else {
echo ',';
}
echo '{"name":"' . $this->tagToName($tag) . '","id":"' . $tag . '"}';
}
echo ']}';
}
示例11: handle_schema
/**
* Load a whole schema as fields
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
*/
public function handle_schema(Doku_Event $event, $param)
{
$args = $event->data['args'];
if ($args[0] != 'struct_schema') {
return false;
}
$event->preventDefault();
$event->stopPropagation();
/** @var helper_plugin_bureaucracy_field $helper */
$helper = plugin_load('helper', 'bureaucracy_field');
$helper->initialize($args);
$schema = new Schema($helper->opt['label']);
if (!$schema->getId()) {
msg('This schema does not exist', -1);
return false;
}
foreach ($schema->getColumns(false) as $column) {
/** @var helper_plugin_struct_field $field */
$field = plugin_load('helper', 'struct_field');
// we don't initialize the field but set the appropriate values
$field->opt = $helper->opt;
// copy all the settings to each field
$field->opt['label'] = $column->getFullQualifiedLabel();
$field->column = $column;
$event->data['fields'][] = $field;
}
return true;
}
示例12: explode
/**
* Display the tag page
*
* @param Doku_Event $event The TPL_ACT_UNKNOWN event
* @param array $param optional parameters (unused)
*/
function _handle_tpl_act(Doku_Event &$event, $param)
{
global $lang;
if ($event->data != 'showtag') {
return;
}
$event->preventDefault();
$tagns = $this->getConf('namespace');
$flags = explode(',', str_replace(" ", "", $this->getConf('pagelist_flags')));
$tag = trim(str_replace($this->getConf('namespace') . ':', '', $_REQUEST['tag']));
$ns = trim($_REQUEST['ns']);
/* @var helper_plugin_tag $helper */
if ($helper = $this->loadHelper('tag')) {
$pages = $helper->getTopic($ns, '', $tag);
}
if (!empty($pages)) {
// let Pagelist Plugin do the work for us
if (!($pagelist = $this->loadHelper('pagelist'))) {
return false;
}
/* @var helper_plugin_pagelist $pagelist */
$pagelist->setFlags($flags);
$pagelist->startList();
foreach ($pages as $page) {
$pagelist->addPage($page);
}
print '<h1>TAG: ' . hsc(str_replace('_', ' ', $_REQUEST['tag'])) . '</h1>' . DOKU_LF;
print '<div class="level1">' . DOKU_LF;
print $pagelist->finishList();
print '</div>' . DOKU_LF;
} else {
print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>';
}
}
示例13: _handle_before
/**
* Hook js script into page headers.
*
* @author Samuele Tognini <samuele@cli.di.unipi.it>
*/
public function _handle_before(Doku_Event $event, $param)
{
$act = act_clean($event->data);
if ($act != 'diff') {
return;
}
$event->preventDefault();
revisionsfull_html_diff();
}
示例14: handle_register_action
/**
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_register_action(Doku_Event &$event, $param)
{
if ($event->data !== 'register') {
return;
}
//no other action handlers needed
$event->stopPropagation();
$event->preventDefault();
$this->override_html_register();
}
示例15: handle_ajax_call_unknown
/**
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_ajax_call_unknown(Doku_Event &$event, $param)
{
if ($event->data !== 'iwiki_list') {
return;
}
$event->stopPropagation();
$event->preventDefault();
$a = getInterwiki();
ksort($a);
echo json_encode($a);
}