Changeset 926 for trunk


Ignore:
Timestamp:
01/08/08 03:33:40 (12 years ago)
Author:
gogo
Message:

Allow specification of base url to use (so that a subdirectory can be used as $dir and return appropriate urls to the files (prefixing the url)).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/Linker/scan.php

    r591 r926  
    11<?php 
    2     // /home/username/foo/public_html/ 
     2    // /home/username/foo/public_html/bar 
    33    $dir          = dirname(__FILE__)."/../.."; 
     4     
     5    // http://example.com/bar (or relative url, or semi absolute) 
     6    $url       = ''; 
     7     
    48    $include      = '/\.(php|shtml|html|htm|shtm|cgi|txt|doc|pdf|rtf|xls|csv)$/'; 
    59    $exclude      = ''; 
     
    4650    //------------------------------------------------------------------------ 
    4751 
    48  
     52    // Neither dir nor url should have trailing slash 
     53    $dir = preg_replace('/\/$/', '', $dir); 
     54    $url = preg_replace('/\/$/', '', $url); 
     55     
    4956    function scan($dir, $durl = '') 
    5057    { 
     
    98105    function dircomp($a, $b) 
    99106    { 
    100       if(is_array($a)) $a = array_shift($a); 
    101       if(is_array($b)) $b = array_shift($b); 
    102       return strcmp(strtolower($a), strtolower($b)); 
     107      if(isset($a['children']) && !isset($b['children'])) return -1; 
     108      if(isset($b['children']) && !isset($a['children'])) return 1; 
     109       
     110      return strcmp(strtolower($a['url']), strtolower($b['url'])); 
    103111    } 
    104112    
    105     echo xinha_to_js(scan($dir)); 
     113    echo xinha_to_js(scan($dir,$url)); 
    106114?> 
Note: See TracChangeset for help on using the changeset viewer.