diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/html.php | 16 | ||||
-rw-r--r-- | inc/httputils.php | 52 | ||||
-rw-r--r-- | inc/lang/sv/lang.php | 5 | ||||
-rw-r--r-- | inc/media.php | 9 | ||||
-rw-r--r-- | inc/parserutils.php | 6 | ||||
-rw-r--r-- | inc/template.php | 5 |
6 files changed, 77 insertions, 16 deletions
diff --git a/inc/html.php b/inc/html.php index 6e187ebe1..de860a0fe 100644 --- a/inc/html.php +++ b/inc/html.php @@ -737,7 +737,7 @@ function html_list_index($item){ /** * Index List item * - * This user function is used in html_build_lidt to build the + * This user function is used in html_buildlist to build the * <li> tags for namespaces when displaying the page index * it gives different classes to opened or closed "folders" * @@ -778,10 +778,20 @@ function html_li_default($item){ * @author Andreas Gohr <andi@splitbrain.org> */ function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ - $level = 0; + if (count($data) === 0) { + return ''; + } + + $level = $data[0]['level']; $opens = 0; $ret = ''; + if ($level < 2) { + // Trigger building a wrapper ul if the first level is + // 0 (we have a root object) or 1 (just the root content) + --$level; + } + foreach ($data as $item){ if( $item['level'] > $level ){ @@ -797,7 +807,7 @@ function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ //close higher lists $ret .= "</ul>\n</li>\n"; } - }else{ + } elseif ($ret !== '') { //close last item $ret .= "</li>\n"; } diff --git a/inc/httputils.php b/inc/httputils.php index 8da42e3b7..0ad97a9a1 100644 --- a/inc/httputils.php +++ b/inc/httputils.php @@ -197,3 +197,55 @@ function http_gzip_valid($uncompressed_file) { return true; } + +/** + * Set HTTP headers and echo cachefile, if useable + * + * This function handles output of cacheable resource files. It ses the needed + * HTTP headers. If a useable cache is present, it is passed to the web server + * and the scrpt is terminated. + */ +function http_cached($cache, $cache_ok) { + global $conf; + + // check cache age & handle conditional request + // since the resource files are timestamped, we can use a long max age: 1 year + header('Cache-Control: public, max-age=31536000'); + header('Pragma: public'); + if($cache_ok){ + http_conditionalRequest(filemtime($cache)); + if($conf['allowdebug']) header("X-CacheUsed: $cache"); + + // finally send output + if ($conf['gzip_output'] && http_gzip_valid($cache)) { + header('Vary: Accept-Encoding'); + header('Content-Encoding: gzip'); + readfile($cache.".gz"); + } else { + if (!http_sendfile($cache)) readfile($cache); + } + exit; + } + + http_conditionalRequest(time()); +} + +/** + * Cache content and print it + */ +function http_cached_finish($file, $content) { + global $conf; + + // save cache file + io_saveFile($file, $content); + if(function_exists('gzopen')) io_saveFile("$file.gz",$content); + + // finally send output + if ($conf['gzip_output']) { + header('Vary: Accept-Encoding'); + header('Content-Encoding: gzip'); + print gzencode($content,9,FORCE_GZIP); + } else { + print $content; + } +} diff --git a/inc/lang/sv/lang.php b/inc/lang/sv/lang.php index 801e2d879..06b21afe8 100644 --- a/inc/lang/sv/lang.php +++ b/inc/lang/sv/lang.php @@ -16,6 +16,7 @@ * @author Emil Lind <emil@sys.nu> * @author Bogge Bogge <bogge@bogge.com> * @author Peter Åström <eaustreum@gmail.com> + * @author mikael@mallander.net */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; @@ -225,8 +226,8 @@ $lang['img_camera'] = 'Kamera'; $lang['img_keywords'] = 'Nyckelord'; $lang['subscr_m_new_header'] = 'Lägg till prenumeration'; $lang['subscr_m_current_header'] = 'Nuvarande prenumerationer'; -$lang['subscr_m_unsubscribe'] = 'Prenumerera'; -$lang['subscr_m_subscribe'] = 'Avsluta prenumeration'; +$lang['subscr_m_unsubscribe'] = 'Avsluta prenumeration'; +$lang['subscr_m_subscribe'] = 'Prenumerera'; $lang['subscr_m_receive'] = 'Ta emot'; $lang['subscr_style_every'] = 'skicka epost vid varje ändring'; $lang['authmodfailed'] = 'Felaktiga inställningar för användarautentisering. Var vänlig meddela wikiadministratören.'; diff --git a/inc/media.php b/inc/media.php index 10da501b0..731ba1668 100644 --- a/inc/media.php +++ b/inc/media.php @@ -767,15 +767,10 @@ function media_nstree($ns){ search($data,$conf['mediadir'],'search_index',array('ns' => $ns, 'nofiles' => true)); // wrap a list with the root level around the other namespaces - $item = array( 'level' => 0, 'id' => '', - 'open' =>'true', 'label' => '['.$lang['mediaroot'].']'); + array_unshift($data, array('level' => 0, 'id' => '', 'open' =>'true', + 'label' => '['.$lang['mediaroot'].']')); - echo '<ul class="idx">'; - echo media_nstree_li($item); - echo media_nstree_item($item); echo html_buildlist($data,'idx','media_nstree_item','media_nstree_li'); - echo '</li>'; - echo '</ul>'; } /** diff --git a/inc/parserutils.php b/inc/parserutils.php index 9ae835893..9384929bf 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -677,12 +677,16 @@ function & p_get_renderer($mode) { global $conf, $plugin_controller; $rname = !empty($conf['renderer_'.$mode]) ? $conf['renderer_'.$mode] : $mode; + $rclass = "Doku_Renderer_$rname"; + + if( class_exists($rclass) ) { + return new $rclass(); + } // try default renderer first: $file = DOKU_INC."inc/parser/$rname.php"; if(@file_exists($file)){ require_once $file; - $rclass = "Doku_Renderer_$rname"; if ( !class_exists($rclass) ) { trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); diff --git a/inc/template.php b/inc/template.php index b9b3951ff..a476e78ab 100644 --- a/inc/template.php +++ b/inc/template.php @@ -972,8 +972,7 @@ function _tpl_img_action($data, $param=NULL) { } /** - * This function inserts a 1x1 pixel gif which in reality - * is the indexer function. + * This function inserts a small gif which in reality is the indexer function. * * Should be called somewhere at the very end of the main.php * template @@ -986,7 +985,7 @@ function tpl_indexerWebBug(){ $p = array(); $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID). '&'.time(); - $p['width'] = 2; + $p['width'] = 2; //no more 1x1 px image because we live in times of ad blockers... $p['height'] = 1; $p['alt'] = ''; $att = buildAttributes($p); |