diff options
Diffstat (limited to 'lib/exe')
-rw-r--r-- | lib/exe/css.php | 84 | ||||
-rw-r--r-- | lib/exe/detail.php | 21 | ||||
-rw-r--r-- | lib/exe/fetch.php | 8 | ||||
-rw-r--r-- | lib/exe/jquery.php | 4 | ||||
-rw-r--r-- | lib/exe/js.php | 26 | ||||
-rw-r--r-- | lib/exe/mediamanager.php | 5 | ||||
-rw-r--r-- | lib/exe/xmlrpc.php | 66 |
7 files changed, 102 insertions, 112 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php index 19ae5570e..40de4b828 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -6,7 +6,10 @@ * @author Andreas Gohr <andi@splitbrain.org> */ -if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); +use dokuwiki\Cache\Cache; +use dokuwiki\Extension\Event; + +if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__ .'/../../'); if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session or authentication here (better caching) if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT',1); // we gzip ourself here if(!defined('NL')) define('NL',"\n"); @@ -67,7 +70,8 @@ function css_out(){ // load jQuery-UI theme if ($mediatype == 'screen') { - $files[DOKU_INC.'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE.'lib/scripts/jquery/jquery-ui-theme/'; + $files[DOKU_INC.'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = + DOKU_BASE.'lib/scripts/jquery/jquery-ui-theme/'; } // load plugin styles $files = array_merge($files, css_pluginstyles($mediatype)); @@ -84,7 +88,7 @@ function css_out(){ // Let plugins decide to either put more styles here or to remove some $media_files[$mediatype] = css_filewrapper($mediatype, $files); - $CSSEvt = new Doku_Event('CSS_STYLES_INCLUDED', $media_files[$mediatype]); + $CSSEvt = new Event('CSS_STYLES_INCLUDED', $media_files[$mediatype]); // Make it preventable. if ( $CSSEvt->advise_before() ) { @@ -99,8 +103,17 @@ function css_out(){ } // The generated script depends on some dynamic options - $cache = new cache('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].$INPUT->bool('preview').DOKU_BASE.$tpl.$type,'.css'); - $cache->_event = 'CSS_CACHE_USE'; + $cache = new Cache( + 'styles' . + $_SERVER['HTTP_HOST'] . + $_SERVER['SERVER_PORT'] . + $INPUT->bool('preview') . + DOKU_BASE . + $tpl . + $type, + '.css' + ); + $cache->setEvent('CSS_CACHE_USE'); // check cache age & handle conditional request // This may exit if a cache can be used @@ -114,7 +127,7 @@ function css_out(){ // plugins decide whether to include the DW default styles. // This can be done by preventing the Default. $media_files['DW_DEFAULT'] = css_filewrapper('DW_DEFAULT'); - trigger_event('CSS_STYLES_INCLUDED', $media_files['DW_DEFAULT'], 'css_defaultstyles'); + Event::createAndTrigger('CSS_STYLES_INCLUDED', $media_files['DW_DEFAULT'], 'css_defaultstyles'); // build the stylesheet foreach ($mediatypes as $mediatype) { @@ -454,18 +467,13 @@ class DokuCssFile { */ public function replacements($match) { - // not a relative url? - no adjustment required - if (preg_match('#^(/|data:|https?://)#',$match[3])) { + if (preg_match('#^(/|data:|https?://)#', $match[3])) { // not a relative url? - no adjustment required return $match[0]; - } - // a less file import? - requires a file system location - else if (substr($match[3],-5) == '.less') { + } elseif (substr($match[3], -5) == '.less') { // a less file import? - requires a file system location if ($match[3]{0} != '/') { $match[3] = $this->getRelativePath() . '/' . $match[3]; } - } - // everything else requires a url adjustment - else { + } else { // everything else requires a url adjustment $match[3] = $this->location . $match[3]; } @@ -547,18 +555,50 @@ function css_compress($css){ $css = preg_replace('/ ?: /',':',$css); // number compression - $css = preg_replace('/([: ])0+(\.\d+?)0*((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2$3', $css); // "0.1em" to ".1em", "1.10em" to "1.1em" - $css = preg_replace('/([: ])\.(0)+((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2', $css); // ".0em" to "0" - $css = preg_replace('/([: ]0)0*(\.0*)?((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1', $css); // "0.0em" to "0" - $css = preg_replace('/([: ]\d+)(\.0*)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$3', $css); // "1.0em" to "1em" - $css = preg_replace('/([: ])0+(\d+|\d*\.\d+)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$2$3', $css); // "001em" to "1em" + $css = preg_replace( + '/([: ])0+(\.\d+?)0*((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', + '$1$2$3', + $css + ); // "0.1em" to ".1em", "1.10em" to "1.1em" + $css = preg_replace( + '/([: ])\.(0)+((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', + '$1$2', + $css + ); // ".0em" to "0" + $css = preg_replace( + '/([: ]0)0*(\.0*)?((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', + '$1', + $css + ); // "0.0em" to "0" + $css = preg_replace( + '/([: ]\d+)(\.0*)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', + '$1$3', + $css + ); // "1.0em" to "1em" + $css = preg_replace( + '/([: ])0+(\d+|\d*\.\d+)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', + '$1$2$3', + $css + ); // "001em" to "1em" // shorten attributes (1em 1em 1em 1em -> 1em) - $css = preg_replace('/(?<![\w\-])((?:margin|padding|border|border-(?:width|radius)):)([\w\.]+)( \2)+(?=[;\}]| !)/', '$1$2', $css); // "1em 1em 1em 1em" to "1em" - $css = preg_replace('/(?<![\w\-])((?:margin|padding|border|border-(?:width)):)([\w\.]+) ([\w\.]+) \2 \3(?=[;\}]| !)/', '$1$2 $3', $css); // "1em 2em 1em 2em" to "1em 2em" + $css = preg_replace( + '/(?<![\w\-])((?:margin|padding|border|border-(?:width|radius)):)([\w\.]+)( \2)+(?=[;\}]| !)/', + '$1$2', + $css + ); // "1em 1em 1em 1em" to "1em" + $css = preg_replace( + '/(?<![\w\-])((?:margin|padding|border|border-(?:width)):)([\w\.]+) ([\w\.]+) \2 \3(?=[;\}]| !)/', + '$1$2 $3', + $css + ); // "1em 2em 1em 2em" to "1em 2em" // shorten colors - $css = preg_replace("/#([0-9a-fA-F]{1})\\1([0-9a-fA-F]{1})\\2([0-9a-fA-F]{1})\\3(?=[^\{]*[;\}])/", "#\\1\\2\\3", $css); + $css = preg_replace( + "/#([0-9a-fA-F]{1})\\1([0-9a-fA-F]{1})\\2([0-9a-fA-F]{1})\\3(?=[^\{]*[;\}])/", + "#\\1\\2\\3", + $css + ); return $css; } diff --git a/lib/exe/detail.php b/lib/exe/detail.php index ec1a9b874..a6cffa770 100644 --- a/lib/exe/detail.php +++ b/lib/exe/detail.php @@ -1,4 +1,7 @@ <?php + +use dokuwiki\Extension\Event; + if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); define('DOKU_MEDIADETAIL',1); require_once(DOKU_INC.'inc/init.php'); @@ -12,31 +15,17 @@ $REV = $INPUT->int('rev'); $INFO = array_merge(pageinfo(),mediainfo()); $tmp = array(); -trigger_event('DETAIL_STARTED', $tmp); +Event::createAndTrigger('DETAIL_STARTED', $tmp); //close session session_write_close(); -if($conf['allowdebug'] && $INPUT->has('debug')){ - print '<pre>'; - foreach(explode(' ','basedir userewrite baseurl useslash') as $x){ - print '$'."conf['$x'] = '".$conf[$x]."';\n"; - } - foreach(explode(' ','DOCUMENT_ROOT HTTP_HOST SCRIPT_FILENAME PHP_SELF '. - 'REQUEST_URI SCRIPT_NAME PATH_INFO PATH_TRANSLATED') as $x){ - print '$'."_SERVER['$x'] = '".$_SERVER[$x]."';\n"; - } - print "getID('media'): ".getID('media')."\n"; - print "getID('media',false): ".getID('media',false)."\n"; - print '</pre>'; -} - $ERROR = false; // check image permissions $AUTH = auth_quickaclcheck($IMG); if($AUTH >= AUTH_READ){ // check if image exists - $SRC = mediaFN($IMG,$REV); + $SRC = mediaFN($IMG,$REV); if(!file_exists($SRC)){ //doesn't exist! http_status(404); diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 933367e35..5c5ae899b 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -6,6 +6,8 @@ * @author Andreas Gohr <andi@splitbrain.org> */ +use dokuwiki\Extension\Event; + if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../'); if (!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1); require_once(DOKU_INC.'inc/init.php'); @@ -14,7 +16,7 @@ session_write_close(); //close session require_once(DOKU_INC.'inc/fetch.functions.php'); if (defined('SIMPLE_TEST')) { - $INPUT = new Input(); + $INPUT = new \dokuwiki\Input\Input(); } // BEGIN main @@ -56,7 +58,7 @@ if (defined('SIMPLE_TEST')) { ); // handle the file status - $evt = new Doku_Event('FETCH_MEDIA_STATUS', $data); + $evt = new Event('FETCH_MEDIA_STATUS', $data); if($evt->advise_before()) { // redirects if($data['status'] > 300 && $data['status'] <= 304) { @@ -87,7 +89,7 @@ if (defined('SIMPLE_TEST')) { } // finally send the file to the client - $evt = new Doku_Event('MEDIA_SENDFILE', $data); + $evt = new Event('MEDIA_SENDFILE', $data); if($evt->advise_before()) { sendFile($data['file'], $data['mime'], $data['download'], $data['cache'], $data['ispublic'], $data['orig']); } diff --git a/lib/exe/jquery.php b/lib/exe/jquery.php index f32aef7d3..13c0c1639 100644 --- a/lib/exe/jquery.php +++ b/lib/exe/jquery.php @@ -1,5 +1,7 @@ <?php +use dokuwiki\Cache\Cache; + if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__) . '/../../'); if(!defined('NOSESSION')) define('NOSESSION', true); // we do not use a session or authentication here (better caching) if(!defined('NL')) define('NL', "\n"); @@ -19,7 +21,7 @@ jquery_out(); * uses cache or fills it */ function jquery_out() { - $cache = new cache('jquery', '.js'); + $cache = new Cache('jquery', '.js'); $files = array( DOKU_INC . 'lib/scripts/jquery/jquery.min.js', DOKU_INC . 'lib/scripts/jquery/jquery-ui.min.js', diff --git a/lib/exe/js.php b/lib/exe/js.php index 81afaf053..ae6a6366f 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -6,7 +6,10 @@ * @author Andreas Gohr <andi@splitbrain.org> */ -if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); +use dokuwiki\Cache\Cache; +use dokuwiki\Extension\Event; + +if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__ .'/../../'); if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session or authentication here (better caching) if(!defined('NL')) define('NL',"\n"); if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT',1); // we gzip ourself here @@ -73,11 +76,11 @@ function js_out(){ } // Let plugins decide to either put more scripts here or to remove some - trigger_event('JS_SCRIPT_LIST', $files); + Event::createAndTrigger('JS_SCRIPT_LIST', $files); // The generated script depends on some dynamic options - $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].md5(serialize($files)),'.js'); - $cache->_event = 'JS_CACHE_USE'; + $cache = new Cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].md5(serialize($files)),'.js'); + $cache->setEvent('JS_CACHE_USE'); $cache_files = array_merge($files, getConfigFiles('main')); $cache_files[] = __FILE__; @@ -90,18 +93,21 @@ function js_out(){ // start output buffering and build the script ob_start(); - $json = new JSON(); // add some global variables print "var DOKU_BASE = '".DOKU_BASE."';"; print "var DOKU_TPL = '".tpl_basedir($tpl)."';"; - print "var DOKU_COOKIE_PARAM = " . $json->encode( + print "var DOKU_COOKIE_PARAM = " . json_encode( array( 'path' => empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir'], 'secure' => $conf['securecookie'] && is_ssl() )).";"; // FIXME: Move those to JSINFO - print "Object.defineProperty(window, 'DOKU_UHN', { get: function() { console.warn('Using DOKU_UHN is deprecated. Please use JSINFO.useHeadingNavigation instead'); return JSINFO.useHeadingNavigation; } });"; - print "Object.defineProperty(window, 'DOKU_UHC', { get: function() { console.warn('Using DOKU_UHC is deprecated. Please use JSINFO.useHeadingContent instead'); return JSINFO.useHeadingContent; } });"; + print "Object.defineProperty(window, 'DOKU_UHN', { get: function() {". + "console.warn('Using DOKU_UHN is deprecated. Please use JSINFO.useHeadingNavigation instead');". + "return JSINFO.useHeadingNavigation; } });"; + print "Object.defineProperty(window, 'DOKU_UHC', { get: function() {". + "console.warn('Using DOKU_UHC is deprecated. Please use JSINFO.useHeadingContent instead');". + "return JSINFO.useHeadingContent; } });"; // load JS specific translations $lang['js']['plugins'] = js_pluginstrings(); @@ -109,7 +115,7 @@ function js_out(){ if(!empty($templatestrings)) { $lang['js']['template'] = $templatestrings; } - echo 'LANG = '.$json->encode($lang['js']).";\n"; + echo 'LANG = '.json_encode($lang['js']).";\n"; // load toolbar toolbar_JSdefines('toolbar'); @@ -170,7 +176,7 @@ function js_load($file){ // is it a include_once? if($match[1]){ - $base = utf8_basename($ifile); + $base = \dokuwiki\Utf8\PhpString::basename($ifile); if(array_key_exists($base, $loaded) && $loaded[$base] === true){ $data = str_replace($match[0], '' ,$data); continue; diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index 722254423..b43cff745 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -1,4 +1,7 @@ <?php + +use dokuwiki\Extension\Event; + if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); define('DOKU_MEDIAMANAGER',1); @@ -38,7 +41,7 @@ $AUTH = $INFO['perm']; // shortcut for historical reasons $tmp = array(); - trigger_event('MEDIAMANAGER_STARTED', $tmp); + Event::createAndTrigger('MEDIAMANAGER_STARTED', $tmp); session_write_close(); //close session // do not display the manager if user does not have read access diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 3046f47e9..dc0438ee1 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -1,67 +1,15 @@ <?php -if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); - -require_once(DOKU_INC.'inc/init.php'); -session_write_close(); //close session - -if(!$conf['remote']) die((new IXR_Error(-32605, "XML-RPC server not enabled."))->getXml()); - /** - * Contains needed wrapper functions and registers all available - * XMLRPC functions. + * XMLRPC API backend */ -class dokuwiki_xmlrpc_server extends IXR_Server { - protected $remote; - - /** - * Constructor. Register methods and run Server - */ - public function __construct(){ - $this->remote = new RemoteAPI(); - $this->remote->setDateTransformation(array($this, 'toDate')); - $this->remote->setFileTransformation(array($this, 'toFile')); - parent::__construct(); - } - /** - * @param string $methodname - * @param array $args - * @return IXR_Error|mixed - */ - public function call($methodname, $args){ - try { - $result = $this->remote->call($methodname, $args); - return $result; - } catch (RemoteAccessDeniedException $e) { - if (!isset($_SERVER['REMOTE_USER'])) { - http_status(401); - return new IXR_Error(-32603, "server error. not authorized to call method $methodname"); - } else { - http_status(403); - return new IXR_Error(-32604, "server error. forbidden to call the method $methodname"); - } - } catch (RemoteException $e) { - return new IXR_Error($e->getCode(), $e->getMessage()); - } - } +use dokuwiki\Remote\XmlRpcServer; - /** - * @param string|int $data iso date(yyyy[-]mm[-]dd[ hh:mm[:ss]]) or timestamp - * @return IXR_Date - */ - public function toDate($data) { - return new IXR_Date($data); - } +if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../'); - /** - * @param string $data - * @return IXR_Base64 - */ - public function toFile($data) { - return new IXR_Base64($data); - } -} +require_once(DOKU_INC.'inc/init.php'); +session_write_close(); //close session -$server = new dokuwiki_xmlrpc_server(); +if(!$conf['remote']) die((new IXR_Error(-32605, "XML-RPC server not enabled."))->getXml()); -// vim:ts=4:sw=4:et: +$server = new XmlRpcServer(); |