* @inheritdoc
*/
public function preProcess() {
global $ID;
global $REV;
global $conf;
global $lang;
$pre = '';
$post = '';
$headers = array();
// search engines: never cache exported docs! (Google only currently)
$headers['X-Robots-Tag'] = 'noindex';
$mode = substr($this->actionname, 7);
switch($mode) {
case 'raw':
$headers['Content-Type'] = 'text/plain; charset=utf-8';
$headers['Content-Disposition'] = 'attachment; filename=' . noNS($ID) . '.txt';
$output = rawWiki($ID, $REV);
break;
case 'xhtml':
$pre .= '' . DOKU_LF;
$pre .= '' . DOKU_LF;
$pre .= '' . DOKU_LF;
$pre .= ' ' . DOKU_LF; // FIXME improve wrapper
$pre .= ' ' . $ID . '' . DOKU_LF;
// get metaheaders
ob_start();
tpl_metaheaders();
$pre .= ob_get_clean();
$pre .= '' . DOKU_LF;
$pre .= '' . DOKU_LF;
$pre .= '' . DOKU_LF;
// get toc
$pre .= tpl_toc(true);
$headers['Content-Type'] = 'text/html; charset=utf-8';
$output = p_wiki_xhtml($ID, $REV, false);
$post .= '
' . DOKU_LF;
$post .= '' . DOKU_LF;
$post .= '' . DOKU_LF;
break;
case 'xhtmlbody':
$headers['Content-Type'] = 'text/html; charset=utf-8';
$output = p_wiki_xhtml($ID, $REV, false);
break;
default:
$output = p_cached_output(wikiFN($ID, $REV), $mode, $ID);
$headers = p_get_metadata($ID, "format $mode");
break;
}
// prepare event data
$data = array();
$data['id'] = $ID;
$data['mode'] = $mode;
$data['headers'] = $headers;
$data['output'] =& $output;
Event::createAndTrigger('ACTION_EXPORT_POSTPROCESS', $data);
if(!empty($data['output'])) {
if(is_array($data['headers'])) foreach($data['headers'] as $key => $val) {
header("$key: $val");
}
print $pre . $data['output'] . $post;
exit;
}
throw new ActionAbort();
}
}
PK ! Bl Check.phpnu [ handleSubscribeData();
} catch(ActionAbort $e) {
throw $e;
} catch(\Exception $e) {
msg($e->getMessage(), -1);
}
}
/** @inheritdoc */
public function tplContent() {
tpl_subscribe();
}
/**
* Handle page 'subscribe'
*
* @author Adrian Lang
* @throws \Exception if (un)subscribing fails
* @throws ActionAbort when (un)subscribing worked
*/
protected function handleSubscribeData() {
global $lang;
global $INFO;
global $INPUT;
// get and preprocess data.
$params = array();
foreach(array('target', 'style', 'action') as $param) {
if($INPUT->has("sub_$param")) {
$params[$param] = $INPUT->str("sub_$param");
}
}
// any action given? if not just return and show the subscription page
if(empty($params['action']) || !checkSecurityToken()) return;
// Handle POST data, may throw exception.
Event::createAndTrigger('ACTION_HANDLE_SUBSCRIBE', $params, array($this, 'handlePostData'));
$target = $params['target'];
$style = $params['style'];
$action = $params['action'];
// Perform action.
$subManager = new SubscriberManager();
if($action === 'unsubscribe') {
$ok = $subManager->remove($target, $INPUT->server->str('REMOTE_USER'), $style);
} else {
$ok = $subManager->add($target, $INPUT->server->str('REMOTE_USER'), $style);
}
if($ok) {
msg(
sprintf(
$lang["subscr_{$action}_success"], hsc($INFO['userinfo']['name']),
prettyprint_id($target)
), 1
);
throw new ActionAbort('redirect');
}
throw new \Exception(
sprintf(
$lang["subscr_{$action}_error"],
hsc($INFO['userinfo']['name']),
prettyprint_id($target)
)
);
}
/**
* Validate POST data
*
* Validates POST data for a subscribe or unsubscribe request. This is the
* default action for the event ACTION_HANDLE_SUBSCRIBE.
*
* @author Adrian Lang
*
* @param array &$params the parameters: target, style and action
* @throws \Exception
*/
public function handlePostData(&$params) {
global $INFO;
global $lang;
global $INPUT;
// Get and validate parameters.
if(!isset($params['target'])) {
throw new \Exception('no subscription target given');
}
$target = $params['target'];
$valid_styles = array('every', 'digest');
if(substr($target, -1, 1) === ':') {
// Allow “list” subscribe style since the target is a namespace.
$valid_styles[] = 'list';
}
$style = valid_input_set(
'style', $valid_styles, $params,
'invalid subscription style given'
);
$action = valid_input_set(
'action', array('subscribe', 'unsubscribe'),
$params, 'invalid subscription action given'
);
// Check other conditions.
if($action === 'subscribe') {
if($INFO['userinfo']['mail'] === '') {
throw new \Exception($lang['subscr_subscribe_noaddress']);
}
} elseif($action === 'unsubscribe') {
$is = false;
foreach($INFO['subscribed'] as $subscr) {
if($subscr['target'] === $target) {
$is = true;
}
}
if($is === false) {
throw new \Exception(
sprintf(
$lang['subscr_not_subscribed'],
$INPUT->server->str('REMOTE_USER'),
prettyprint_id($target)
)
);
}
// subscription_set deletes a subscription if style = null.
$style = null;
}
$params = compact('target', 'style', 'action');
}
}
PK ! O\>4 4 Recover.phpnu [ str('show_changes');
if(!empty($show_changes)) {
set_doku_pref('show_changes', $show_changes);
$this->showType = $show_changes;
} else {
$this->showType = get_doku_pref('show_changes', 'both');
}
}
/** @inheritdoc */
public function tplContent() {
global $INPUT;
html_recent((int) $INPUT->extract('first')->int('first'), $this->showType);
}
}
PK ! >u u Backlink.phpnu [ actionname = $actionname;
} else {
// http://stackoverflow.com/a/27457689/172068
$this->actionname = strtolower(substr(strrchr(get_class($this), '\\'), 1));
}
}
/**
* Return the minimum permission needed
*
* This needs to return one of the AUTH_* constants. It will be checked against
* the current user and page after checkPermissions() ran through. If it fails,
* the user will be shown the Denied action.
*
* @return int
*/
abstract public function minimumPermission();
/**
* Check conditions are met to run this action
*
* @throws ActionException
* @return void
*/
public function checkPreconditions() {
}
/**
* Process data
*
* This runs before any output is sent to the browser.
*
* Throw an Exception if a different action should be run after this step.
*
* @throws ActionException
* @return void
*/
public function preProcess() {
}
/**
* Output whatever content is wanted within tpl_content();
*
* @fixme we may want to return a Ui class here
*/
public function tplContent() {
throw new FatalException('No content for Action ' . $this->actionname);
}
/**
* Returns the name of this action
*
* This is usually the lowercased class name, but may differ for some actions.
* eg. the export_ modes or for the Plugin action.
*
* @return string
*/
public function getActionName() {
return $this->actionname;
}
}
PK ! 9p AbstractUserAction.phpnu [ server->str('REMOTE_USER')) {
throw new ActionUserRequiredException();
}
}
}
PK ! нћ
Search.phpnu [ has('q')) {
parse_str($INPUT->server->str('QUERY_STRING'), $urlParts);
$urlParts['q'] = $urlParts['id'];
unset($urlParts['id']);
$url = wl($ID, $urlParts, true, '&');
send_redirect($url);
}
if ($s === '') throw new ActionAbort();
$this->adjustGlobalQuery();
}
/** @inheritdoc */
public function tplContent()
{
$this->execute();
$search = new \dokuwiki\Ui\Search($this->pageLookupResults, $this->fullTextResults, $this->highlight);
$search->show();
}
/**
* run the search
*/
protected function execute()
{
global $INPUT, $QUERY;
$after = $INPUT->str('min');
$before = $INPUT->str('max');
$this->pageLookupResults = ft_pageLookup($QUERY, true, useHeading('navigation'), $after, $before);
$this->fullTextResults = ft_pageSearch($QUERY, $highlight, $INPUT->str('srt'), $after, $before);
$this->highlight = $highlight;
}
/**
* Adjust the global query accordingly to the config search_nslimit and search_fragment
*
* This will only do something if the search didn't originate from the form on the searchpage itself
*/
protected function adjustGlobalQuery()
{
global $conf, $INPUT, $QUERY, $ID;
if ($INPUT->bool('sf')) {
return;
}
$Indexer = idx_get_indexer();
$parsedQuery = ft_queryParser($Indexer, $QUERY);
if (empty($parsedQuery['ns']) && empty($parsedQuery['notns'])) {
if ($conf['search_nslimit'] > 0) {
if (getNS($ID) !== false) {
$nsParts = explode(':', getNS($ID));
$ns = implode(':', array_slice($nsParts, 0, $conf['search_nslimit']));
$QUERY .= " @$ns";
}
}
}
if ($conf['search_fragment'] !== 'exact') {
if (empty(array_diff($parsedQuery['words'], $parsedQuery['and']))) {
if (strpos($QUERY, '*') === false) {
$queryParts = explode(' ', $QUERY);
$queryParts = array_map(function ($part) {
if (strpos($part, '@') === 0) {
return $part;
}
if (strpos($part, 'ns:') === 0) {
return $part;
}
if (strpos($part, '^') === 0) {
return $part;
}
if (strpos($part, '-ns:') === 0) {
return $part;
}
global $conf;
if ($conf['search_fragment'] === 'starts_with') {
return $part . '*';
}
if ($conf['search_fragment'] === 'ends_with') {
return '*' . $part;
}
return '*' . $part . '*';
}, $queryParts);
$QUERY = implode(' ', $queryParts);
}
}
}
}
}
PK ! vm m Conflict.phpnu [ 4 4 Recover.phpnu [ PK ! v+~ ~
V Recent.phpnu [ PK ! >u u Backlink.phpnu [ PK ! f ]; ; Edit.phpnu [ PK ! ~(Yu 2 AbstractAction.phpnu [ PK ! 9p ^ AbstractUserAction.phpnu [ PK ! нћ
Search.phpnu [ PK ! vm m Conflict.phpnu [ PK , ,
+